comparison graal/GraalCompiler/src/com/sun/c1x/ir/Phi.java @ 2603:01c5c0443158

new node layout: Phi
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 06 May 2011 11:18:15 +0200
parents 768d77a1c7af
children 3558ca7088c0
comparison
equal deleted inserted replaced
2602:0c6564c254af 2603:01c5c0443158
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.debug.*; 26 import com.sun.c1x.debug.*;
26 import com.sun.c1x.value.*; 27 import com.sun.c1x.value.*;
27 import com.sun.cri.ci.*; 28 import com.sun.cri.ci.*;
28 29
29 /** 30 /**
30 * The {@code Phi} instruction represents the merging of dataflow 31 * The {@code Phi} instruction represents the merging of dataflow
31 * in the instruction graph. It refers to a join block and a variable. 32 * in the instruction graph. It refers to a join block and a variable.
32 *
33 * @author Ben L. Titzer
34 */ 33 */
35 public final class Phi extends Value { 34 public final class Phi extends Value {
36 35
37 private final BlockBegin block; 36 private static final int INPUT_COUNT = 1;
37 private static final int INPUT_BLOCK = 0;
38
39 private static final int SUCCESSOR_COUNT = 0;
40
41 @Override
42 protected int inputCount() {
43 return super.inputCount() + INPUT_COUNT;
44 }
45
46 @Override
47 protected int successorCount() {
48 return super.successorCount() + SUCCESSOR_COUNT;
49 }
50
51 /**
52 * The join block for this phi.
53 */
54 @Override
55 public BlockBegin block() {
56 return (BlockBegin) inputs().get(super.inputCount() + INPUT_BLOCK);
57 }
58
59 public BlockBegin setBlock(Value n) {
60 return (BlockBegin) inputs().set(super.inputCount() + INPUT_BLOCK, n);
61 }
62
38 private final int index; 63 private final int index;
39 64
40 /** 65 /**
41 * Create a new Phi for the specified join block and local variable (or operand stack) slot. 66 * Create a new Phi for the specified join block and local variable (or operand stack) slot.
42 * @param kind the type of the variable 67 * @param kind the type of the variable
43 * @param block the join point 68 * @param block the join point
44 * @param index the index into the stack (if < 0) or local variables 69 * @param index the index into the stack (if < 0) or local variables
70 * @param graph
45 */ 71 */
46 public Phi(CiKind kind, BlockBegin block, int index) { 72 public Phi(CiKind kind, BlockBegin block, int index, Graph graph) {
47 super(kind); 73 super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
48 this.block = block;
49 this.index = index; 74 this.index = index;
50 } 75 setBlock(block);
51
52 /**
53 * Get the join block for this phi.
54 * @return the join block of this phi
55 */
56 @Override
57 public BlockBegin block() {
58 return block;
59 } 76 }
60 77
61 /** 78 /**
62 * Check whether this phi corresponds to a local variable. 79 * Check whether this phi corresponds to a local variable.
63 * @return {@code true} if this phi refers to a local variable 80 * @return {@code true} if this phi refers to a local variable
98 * @param i the index of the predecessor 115 * @param i the index of the predecessor
99 * @return the instruction that produced the value in the i'th predecessor 116 * @return the instruction that produced the value in the i'th predecessor
100 */ 117 */
101 public Value inputAt(int i) { 118 public Value inputAt(int i) {
102 FrameState state; 119 FrameState state;
103 if (block.isExceptionEntry()) { 120 if (block().isExceptionEntry()) {
104 state = block.exceptionHandlerStates().get(i); 121 state = block().exceptionHandlerStates().get(i);
105 } else { 122 } else {
106 state = block.blockPredecessors().get(i).end().stateAfter(); 123 state = block().blockPredecessors().get(i).end().stateAfter();
107 } 124 }
108 return inputIn(state); 125 return inputIn(state);
109 } 126 }
110 127
111 /** 128 /**
124 /** 141 /**
125 * Get the number of inputs to this phi (i.e. the number of predecessors to the join block). 142 * Get the number of inputs to this phi (i.e. the number of predecessors to the join block).
126 * @return the number of inputs in this phi 143 * @return the number of inputs in this phi
127 */ 144 */
128 public int phiInputCount() { 145 public int phiInputCount() {
129 if (block.isExceptionEntry()) { 146 if (block().isExceptionEntry()) {
130 return block.exceptionHandlerStates().size(); 147 return block().exceptionHandlerStates().size();
131 } else { 148 } else {
132 return block.blockPredecessors().size(); 149 return block().blockPredecessors().size();
133 } 150 }
134 } 151 }
135 152
136 @Override 153 @Override
137 public void accept(ValueVisitor v) { 154 public void accept(ValueVisitor v) {