comparison graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java @ 2592:fec99fc30af1

checkstyle fixes, updated AccessArray + subclasses
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 15:23:07 +0200
parents c58a301eb2d7
children 91d3952f7eb7
comparison
equal deleted inserted replaced
2587:51ebe5f0516f 2592:fec99fc30af1
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.sun.c1x.ir; 23 package com.sun.c1x.ir;
24 24
25 import com.oracle.graal.graph.*;
25 import com.sun.c1x.value.*; 26 import com.sun.c1x.value.*;
26 import com.sun.cri.ci.*; 27 import com.sun.cri.ci.*;
27 28
28 /** 29 /**
29 * The {@code AccessIndexed} class is the base class of instructions that read or write 30 * The {@code AccessIndexed} class is the base class of instructions that read or write
31 * 32 *
32 * @author Ben L. Titzer 33 * @author Ben L. Titzer
33 */ 34 */
34 public abstract class AccessIndexed extends AccessArray { 35 public abstract class AccessIndexed extends AccessArray {
35 36
36 private Value index; 37 private static final int INPUT_COUNT = 2;
37 private Value length; 38 private static final int INPUT_INDEX = 0;
39 private static final int INPUT_LENGTH = 1;
40
41 private static final int SUCCESSOR_COUNT = 0;
42
43 @Override
44 protected int inputCount() {
45 return super.inputCount() + INPUT_COUNT;
46 }
47
48 @Override
49 protected int successorCount() {
50 return super.successorCount() + SUCCESSOR_COUNT;
51 }
52
53 /**
54 * The instruction producing the index into the array.
55 */
56 public Value index() {
57 return (Value) inputs().get(super.inputCount() + INPUT_INDEX);
58 }
59
60 public Value setIndex(Value n) {
61 return (Value) inputs().set(super.inputCount() + INPUT_INDEX, n);
62 }
63
64 /**
65 * The instruction that produces the length of the array.
66 */
67 public Value length() {
68 return (Value) inputs().get(super.inputCount() + INPUT_LENGTH);
69 }
70
71 public Value setLength(Value n) {
72 return (Value) inputs().set(super.inputCount() + INPUT_LENGTH, n);
73 }
74
38 private final CiKind elementType; 75 private final CiKind elementType;
39 76
40 /** 77 /**
41 * Create an new AccessIndexed instruction. 78 * Create an new AccessIndexed instruction.
42 * @param kind the result kind of the access 79 * @param kind the result kind of the access
43 * @param array the instruction producing the array 80 * @param array the instruction producing the array
44 * @param index the instruction producing the index 81 * @param index the instruction producing the index
45 * @param length the instruction producing the length (used in bounds check elimination?) 82 * @param length the instruction producing the length (used in bounds check elimination?)
46 * @param elementType the type of the elements of the array 83 * @param elementType the type of the elements of the array
47 * @param stateBefore the state before executing this instruction 84 * @param stateBefore the state before executing this instruction
85 * @param inputCount
86 * @param successorCount
87 * @param graph
48 */ 88 */
49 AccessIndexed(CiKind kind, Value array, Value index, Value length, CiKind elementType, FrameState stateBefore) { 89 AccessIndexed(CiKind kind, Value array, Value index, Value length, CiKind elementType, FrameState stateBefore, int inputCount, int successorCount, Graph graph) {
50 super(kind, array, stateBefore); 90 super(kind, array, stateBefore, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
51 this.index = index; 91 setIndex(index);
52 this.length = length; 92 setLength(length);
53 this.elementType = elementType; 93 this.elementType = elementType;
54 }
55
56 /**
57 * Gets the instruction producing the index into the array.
58 * @return the index
59 */
60 public Value index() {
61 return index;
62 }
63
64 /**
65 * Gets the instruction that produces the length of the array.
66 * @return the length
67 */
68 public Value length() {
69 return length;
70 } 94 }
71 95
72 /** 96 /**
73 * Gets the element type of the array. 97 * Gets the element type of the array.
74 * @return the element type 98 * @return the element type
75 */ 99 */
76 public CiKind elementKind() { 100 public CiKind elementKind() {
77 return elementType; 101 return elementType;
78 } 102 }
79 103
80 @Override
81 public void inputValuesDo(ValueClosure closure) {
82 super.inputValuesDo(closure);
83 index = closure.apply(index);
84 if (length != null) {
85 length = closure.apply(length);
86 }
87 }
88 } 104 }