# HG changeset patch # User Thomas Wuerthinger # Date 1307619691 -7200 # Node ID e37f27b6af77e088e54ecaaffe757f1e9de6a433 # Parent d01b4f44161339b64730a025082c5f007eb694de Changes to LIRBranch. diff -r d01b4f441613 -r e37f27b6af77 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Thu Jun 09 13:25:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java Thu Jun 09 13:41:31 2011 +0200 @@ -385,6 +385,23 @@ emitXir(snippet, x, stateFor(x), null, true); } + + @Override + public void visitGuardNode(GuardNode x) { + FrameState state = lastState; + assert state != null : "deoptimize instruction always needs a state"; + + if (deoptimizationStubs == null) { + deoptimizationStubs = new ArrayList(); + } + + DeoptimizationStub stub = new DeoptimizationStub(state); + deoptimizationStubs.add(stub); + throw new RuntimeException(); + //lir.branch(x.condition.negate(), stub.label, stub.info); + } + + @Override public void visitConstant(Constant x) { if (!canInlineAsConstant(x)) { @@ -594,7 +611,7 @@ int len = x.numberOfCases(); for (int i = 0; i < len; i++) { lir.cmp(Condition.EQ, tag, x.keyAt(i)); - lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i))); + lir.branch(Condition.EQ, getLIRBlock(x.blockSuccessor(i))); } lir.jump(getLIRBlock(x.defaultSuccessor())); } else { @@ -856,7 +873,7 @@ int len = x.numberOfCases(); for (int i = 0; i < len; i++) { lir.cmp(Condition.EQ, tag, i + loKey); - lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i))); + lir.branch(Condition.EQ, getLIRBlock(x.blockSuccessor(i))); } lir.jump(getLIRBlock(x.defaultSuccessor())); } else { @@ -991,18 +1008,18 @@ LIRBlock dest = oneRange.sux; if (lowKey == highKey) { lir.cmp(Condition.EQ, value, lowKey); - lir.branch(Condition.EQ, CiKind.Int, dest); + lir.branch(Condition.EQ, dest); } else if (highKey - lowKey == 1) { lir.cmp(Condition.EQ, value, lowKey); - lir.branch(Condition.EQ, CiKind.Int, dest); + lir.branch(Condition.EQ, dest); lir.cmp(Condition.EQ, value, highKey); - lir.branch(Condition.EQ, CiKind.Int, dest); + lir.branch(Condition.EQ, dest); } else { Label l = new Label(); lir.cmp(Condition.LT, value, lowKey); lir.branch(Condition.LT, l); lir.cmp(Condition.LE, value, highKey); - lir.branch(Condition.LE, CiKind.Int, dest); + lir.branch(Condition.LE, dest); lir.branchDestination(l); } } diff -r d01b4f441613 -r e37f27b6af77 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java Thu Jun 09 13:25:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ValueVisitor.java Thu Jun 09 13:41:31 2011 +0200 @@ -72,4 +72,5 @@ public abstract void visitLoopBegin(LoopBegin loopBegin); public abstract void visitLoopEnd(LoopEnd loopEnd); public abstract void visitValueAnchor(ValueAnchor valueAnchor); + public abstract void visitGuardNode(GuardNode guardNode); } diff -r d01b4f441613 -r e37f27b6af77 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java Thu Jun 09 13:25:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBranch.java Thu Jun 09 13:41:31 2011 +0200 @@ -34,7 +34,6 @@ public class LIRBranch extends LIRInstruction { private Condition cond; - private CiKind kind; private Label label; /** @@ -73,19 +72,17 @@ * @param block * */ - public LIRBranch(Condition cond, CiKind kind, LIRBlock block) { + public LIRBranch(Condition cond, LIRBlock block) { super(LIROpcode.Branch, CiValue.IllegalValue, null, false); this.cond = cond; - this.kind = kind; this.label = block.label(); this.block = block; this.unorderedBlock = null; } - public LIRBranch(Condition cond, CiKind kind, LIRBlock block, LIRBlock ublock) { + public LIRBranch(Condition cond, LIRBlock block, LIRBlock ublock) { super(LIROpcode.CondFloatBranch, CiValue.IllegalValue, null, false); this.cond = cond; - this.kind = kind; this.label = block.label(); this.block = block; this.unorderedBlock = ublock; diff -r d01b4f441613 -r e37f27b6af77 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java Thu Jun 09 13:25:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRList.java Thu Jun 09 13:41:31 2011 +0200 @@ -245,7 +245,7 @@ } public void jump(LIRBlock block) { - append(new LIRBranch(Condition.TRUE, CiKind.Illegal, block)); + append(new LIRBranch(Condition.TRUE, block)); } public void branch(Condition cond, Label lbl) { @@ -256,14 +256,12 @@ append(new LIRBranch(cond, lbl, info)); } - public void branch(Condition cond, CiKind kind, LIRBlock block) { - assert kind != CiKind.Float && kind != CiKind.Double : "no fp comparisons"; - append(new LIRBranch(cond, kind, block)); + public void branch(Condition cond, LIRBlock block) { + append(new LIRBranch(cond, block)); } - public void branch(Condition cond, CiKind kind, LIRBlock block, LIRBlock unordered) { - assert kind == CiKind.Float || kind == CiKind.Double : "fp comparisons only"; - append(new LIRBranch(cond, kind, block, unordered)); + public void branch(Condition cond, LIRBlock block, LIRBlock unordered) { + append(new LIRBranch(cond, block, unordered)); } public void tableswitch(CiValue index, int lowKey, LIRBlock defaultTargets, LIRBlock[] targets) { diff -r d01b4f441613 -r e37f27b6af77 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Thu Jun 09 13:25:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Thu Jun 09 13:41:31 2011 +0200 @@ -472,12 +472,28 @@ @Override public void visitIf(If x) { - CiKind kind = x.compare().x().kind; - + emitCompare(x.compare()); Condition cond = x.compare().condition(); + if (x.compare().x().kind.isFloat() || x.compare().x().kind.isDouble()) { + Instruction unorderedSucc = x.falseSuccessor(); + if (x.compare().unorderedIsTrue()) { + unorderedSucc = x.trueSuccessor(); + } + lir.branch(cond, getLIRBlock(x.trueSuccessor()), getLIRBlock(unorderedSucc)); + } else { + lir.branch(cond, getLIRBlock(x.trueSuccessor())); + } + assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination above"; + lir.jump(getLIRBlock(x.defaultSuccessor())); + } - LIRItem xitem = new LIRItem(x.compare().x(), this); - LIRItem yitem = new LIRItem(x.compare().y(), this); + public void emitCompare(Compare compare) { + CiKind kind = compare.x().kind; + + Condition cond = compare.condition(); + + LIRItem xitem = new LIRItem(compare.x(), this); + LIRItem yitem = new LIRItem(compare.y(), this); LIRItem xin = xitem; LIRItem yin = yitem; @@ -499,22 +515,9 @@ yin.loadItem(); } - setNoResult(x); - CiValue left = xin.result(); CiValue right = yin.result(); lir.cmp(cond, left, right); - if (x.compare().x().kind.isFloat() || x.compare().x().kind.isDouble()) { - Instruction unorderedSucc = x.falseSuccessor(); - if (x.compare().unorderedIsTrue()) { - unorderedSucc = x.trueSuccessor(); - } - lir.branch(cond, right.kind, getLIRBlock(x.trueSuccessor()), getLIRBlock(unorderedSucc)); - } else { - lir.branch(cond, right.kind, getLIRBlock(x.trueSuccessor())); - } - assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination above"; - lir.jump(getLIRBlock(x.defaultSuccessor())); } @Override @@ -530,7 +533,7 @@ CiValue result = emitXir(snippet, x, stateFor(x), null, true); lir.cmp(Condition.EQ, result, CiConstant.TRUE); - lir.branch(Condition.EQ, CiKind.Boolean, getLIRBlock(x.catchSuccessor())); + lir.branch(Condition.EQ, getLIRBlock(x.catchSuccessor())); lir.jump(getLIRBlock(x.otherSuccessor())); }