Mercurial > hg > graal-compiler
diff 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 |
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Phi.java Fri May 06 10:25:37 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Phi.java Fri May 06 11:18:15 2011 +0200 @@ -22,6 +22,7 @@ */ package com.sun.c1x.ir; +import com.oracle.graal.graph.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -29,12 +30,36 @@ /** * The {@code Phi} instruction represents the merging of dataflow * in the instruction graph. It refers to a join block and a variable. - * - * @author Ben L. Titzer */ public final class Phi extends Value { - private final BlockBegin block; + private static final int INPUT_COUNT = 1; + private static final int INPUT_BLOCK = 0; + + private static final int SUCCESSOR_COUNT = 0; + + @Override + protected int inputCount() { + return super.inputCount() + INPUT_COUNT; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } + + /** + * The join block for this phi. + */ + @Override + public BlockBegin block() { + return (BlockBegin) inputs().get(super.inputCount() + INPUT_BLOCK); + } + + public BlockBegin setBlock(Value n) { + return (BlockBegin) inputs().set(super.inputCount() + INPUT_BLOCK, n); + } + private final int index; /** @@ -42,20 +67,12 @@ * @param kind the type of the variable * @param block the join point * @param index the index into the stack (if < 0) or local variables + * @param graph */ - public Phi(CiKind kind, BlockBegin block, int index) { - super(kind); - this.block = block; + public Phi(CiKind kind, BlockBegin block, int index, Graph graph) { + super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph); this.index = index; - } - - /** - * Get the join block for this phi. - * @return the join block of this phi - */ - @Override - public BlockBegin block() { - return block; + setBlock(block); } /** @@ -100,10 +117,10 @@ */ public Value inputAt(int i) { FrameState state; - if (block.isExceptionEntry()) { - state = block.exceptionHandlerStates().get(i); + if (block().isExceptionEntry()) { + state = block().exceptionHandlerStates().get(i); } else { - state = block.blockPredecessors().get(i).end().stateAfter(); + state = block().blockPredecessors().get(i).end().stateAfter(); } return inputIn(state); } @@ -126,10 +143,10 @@ * @return the number of inputs in this phi */ public int phiInputCount() { - if (block.isExceptionEntry()) { - return block.exceptionHandlerStates().size(); + if (block().isExceptionEntry()) { + return block().exceptionHandlerStates().size(); } else { - return block.blockPredecessors().size(); + return block().blockPredecessors().size(); } }