001/* 002 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.nodes.java; 024 025import jdk.internal.jvmci.meta.*; 026 027import com.oracle.graal.compiler.common.type.*; 028import com.oracle.graal.graph.*; 029import com.oracle.graal.nodeinfo.*; 030import com.oracle.graal.nodes.*; 031import com.oracle.graal.nodes.spi.*; 032 033/** 034 * The {@code AccessIndexedNode} class is the base class of instructions that read or write elements 035 * of an array. 036 */ 037@NodeInfo 038public abstract class AccessIndexedNode extends AccessArrayNode implements Lowerable { 039 040 public static final NodeClass<AccessIndexedNode> TYPE = NodeClass.create(AccessIndexedNode.class); 041 @Input protected ValueNode index; 042 protected final Kind elementKind; 043 044 public ValueNode index() { 045 return index; 046 } 047 048 /** 049 * Create an new AccessIndexedNode. 050 * 051 * @param stamp the result kind of the access 052 * @param array the instruction producing the array 053 * @param index the instruction producing the index 054 * @param elementKind the kind of the elements of the array 055 */ 056 protected AccessIndexedNode(NodeClass<? extends AccessIndexedNode> c, Stamp stamp, ValueNode array, ValueNode index, Kind elementKind) { 057 super(c, stamp, array); 058 this.index = index; 059 this.elementKind = elementKind; 060 } 061 062 /** 063 * Gets the element type of the array. 064 * 065 * @return the element type 066 */ 067 public Kind elementKind() { 068 return elementKind; 069 } 070 071 @Override 072 public void lower(LoweringTool tool) { 073 tool.getLowerer().lower(this, tool); 074 } 075}