Mercurial > hg > truffle
comparison graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRVerifier.java @ 4522:cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Wed, 08 Feb 2012 15:35:21 -0800 |
parents | 57cb8ec5f6bb |
children | dcc8f5c6f394 |
comparison
equal
deleted
inserted
replaced
4521:333896b40999 | 4522:cf13124efdd9 |
---|---|
31 import com.oracle.max.criutils.*; | 31 import com.oracle.max.criutils.*; |
32 import com.oracle.max.graal.compiler.cfg.*; | 32 import com.oracle.max.graal.compiler.cfg.*; |
33 import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandFlag; | 33 import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandFlag; |
34 import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandMode; | 34 import com.oracle.max.graal.compiler.lir.LIRInstruction.OperandMode; |
35 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure; | 35 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure; |
36 import com.oracle.max.graal.compiler.lir.LIRPhiMapping.PhiValueProcedure; | |
37 import com.oracle.max.graal.compiler.util.*; | 36 import com.oracle.max.graal.compiler.util.*; |
38 | 37 |
39 public final class LIRVerifier { | 38 public final class LIRVerifier { |
40 private final LIR lir; | 39 private final LIR lir; |
41 private final FrameMap frameMap; | 40 private final FrameMap frameMap; |
94 private Block curBlock; | 93 private Block curBlock; |
95 private Object curInstruction; | 94 private Object curInstruction; |
96 private BitSet curRegistersDefined; | 95 private BitSet curRegistersDefined; |
97 | 96 |
98 private void verify() { | 97 private void verify() { |
99 PhiValueProcedure useProc = new PhiValueProcedure() { @Override public CiValue doValue(CiValue value, OperandMode mode, EnumSet<OperandFlag> flags) { return use(value, mode, flags); } }; | 98 ValueProcedure useProc = new ValueProcedure() { @Override public CiValue doValue(CiValue value, OperandMode mode, EnumSet<OperandFlag> flags) { return use(value, mode, flags); } }; |
100 ValueProcedure defProc = new ValueProcedure() { @Override public CiValue doValue(CiValue value, OperandMode mode, EnumSet<OperandFlag> flags) { return def(value, mode, flags); } }; | 99 ValueProcedure defProc = new ValueProcedure() { @Override public CiValue doValue(CiValue value, OperandMode mode, EnumSet<OperandFlag> flags) { return def(value, mode, flags); } }; |
101 | 100 |
102 curRegistersDefined = new BitSet(); | 101 curRegistersDefined = new BitSet(); |
103 for (Block block : lir.linearScanOrder()) { | 102 for (Block block : lir.linearScanOrder()) { |
104 curBlock = block; | 103 curBlock = block; |
105 curVariablesLive = new BitSet(); | 104 curVariablesLive = new BitSet(); |
107 | 106 |
108 if (block.getDominator() != null) { | 107 if (block.getDominator() != null) { |
109 curVariablesLive.or(liveOutFor(block.getDominator())); | 108 curVariablesLive.or(liveOutFor(block.getDominator())); |
110 } | 109 } |
111 | 110 |
112 if (block.phis != null) { | |
113 assert beforeRegisterAllocation; | |
114 curInstruction = block.phis; | |
115 block.phis.forEachOutput(defProc); | |
116 } | |
117 | |
118 assert block.lir.get(0) instanceof StandardOp.LabelOp : "block must start with label"; | 111 assert block.lir.get(0) instanceof StandardOp.LabelOp : "block must start with label"; |
112 if (block.numberOfPreds() > 1) { | |
113 assert block.lir.get(0) instanceof StandardOp.PhiLabelOp : "phi mapping required for multiple predecessors"; | |
114 CiValue[] phiDefinitions = ((StandardOp.PhiLabelOp) block.lir.get(0)).getPhiDefinitions(); | |
115 if (!beforeRegisterAllocation) { | |
116 assert phiDefinitions.length == 0; | |
117 } | |
118 for (Block pred : block.getPredecessors()) { | |
119 assert pred.numberOfSux() == 1; | |
120 LIRInstruction last = pred.lir.get(pred.lir.size() - 1); | |
121 assert last instanceof StandardOp.PhiJumpOp : "phi mapping required for multiple successors"; | |
122 CiValue[] phiUses = ((StandardOp.PhiJumpOp) last).getPhiInputs(); | |
123 if (!beforeRegisterAllocation) { | |
124 assert phiUses.length == 0; | |
125 } | |
126 } | |
127 } | |
128 | |
119 if (block.numberOfSux() > 0) { | 129 if (block.numberOfSux() > 0) { |
120 LIRInstruction last = block.lir.get(block.lir.size() - 1); | 130 LIRInstruction last = block.lir.get(block.lir.size() - 1); |
121 assert last instanceof StandardOp.JumpOp || last instanceof LIRXirInstruction : "block with successor must end with unconditional jump"; | 131 assert last instanceof StandardOp.JumpOp || last instanceof LIRXirInstruction : "block with successor must end with unconditional jump"; |
122 } | 132 } |
123 | 133 |
135 op.forEachState(useProc); | 145 op.forEachState(useProc); |
136 op.forEachTemp(defProc); | 146 op.forEachTemp(defProc); |
137 op.forEachOutput(defProc); | 147 op.forEachOutput(defProc); |
138 | 148 |
139 curInstruction = null; | 149 curInstruction = null; |
140 } | |
141 | |
142 for (Block sux : block.getSuccessors()) { | |
143 if (sux.phis != null) { | |
144 assert beforeRegisterAllocation; | |
145 curInstruction = sux.phis; | |
146 sux.phis.forEachInput(block, useProc); | |
147 } | |
148 } | 150 } |
149 | 151 |
150 setLiveOutFor(block, curVariablesLive); | 152 setLiveOutFor(block, curVariablesLive); |
151 } | 153 } |
152 } | 154 } |