use of org.graalvm.compiler.lir.StandardOp.JumpOp in project graal by oracle.
the class SSAUtil method phiOut.
public static JumpOp phiOut(LIR lir, AbstractBlockBase<?> block) {
assert block.getSuccessorCount() == 1;
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
int index = instructions.size() - 1;
LIRInstruction op = instructions.get(index);
return (JumpOp) op;
}
use of org.graalvm.compiler.lir.StandardOp.JumpOp in project graal by oracle.
the class SSAUtil method forEachPhiValuePair.
/**
* Visits each phi value pair of an edge, i.e. the outgoing value from the predecessor and the
* incoming value to the merge block.
*/
public static void forEachPhiValuePair(LIR lir, AbstractBlockBase<?> merge, AbstractBlockBase<?> pred, PhiValueVisitor visitor) {
if (merge.getPredecessorCount() < 2) {
return;
}
assert Arrays.asList(merge.getPredecessors()).contains(pred) : String.format("%s not in predecessor list: %s", pred, Arrays.toString(merge.getPredecessors()));
assert pred.getSuccessorCount() == 1 : String.format("Merge predecessor block %s has more than one successor? %s", pred, Arrays.toString(pred.getSuccessors()));
assert pred.getSuccessors()[0] == merge : String.format("Predecessor block %s has wrong successor: %s, should be: %s", pred, pred.getSuccessors()[0], merge);
JumpOp jump = phiOut(lir, pred);
LabelOp label = phiIn(lir, merge);
assert label.getPhiSize() == jump.getPhiSize() : String.format("Phi In/Out size mismatch: in=%d vs. out=%d", label.getPhiSize(), jump.getPhiSize());
for (int i = 0; i < label.getPhiSize(); i++) {
visitor.visit(label.getIncomingValue(i), jump.getOutgoingValue(i));
}
}
use of org.graalvm.compiler.lir.StandardOp.JumpOp in project graal by oracle.
the class TraceGlobalMoveResolutionPhase method resolveEdge.
private static void resolveEdge(LIR lir, GlobalLivenessInfo livenessInfo, TraceGlobalMoveResolver moveResolver, AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock) {
assert verifyEdge(fromBlock, toBlock);
if (SSAUtil.isMerge(toBlock)) {
// PHI
JumpOp blockEnd = SSAUtil.phiOut(lir, fromBlock);
LabelOp label = SSAUtil.phiIn(lir, toBlock);
for (int i = 0; i < label.getPhiSize(); i++) {
Value in = label.getIncomingValue(i);
Value out = blockEnd.getOutgoingValue(i);
addMapping(moveResolver, out, in);
}
}
// GLI
Value[] locFrom = livenessInfo.getOutLocation(fromBlock);
Value[] locTo = livenessInfo.getInLocation(toBlock);
if (locFrom == locTo) {
// a strategy might reuse the locations array if locations are the same
return;
}
assert locFrom.length == locTo.length;
for (int i = 0; i < locFrom.length; i++) {
addMapping(moveResolver, locFrom[i], locTo[i]);
}
}
use of org.graalvm.compiler.lir.StandardOp.JumpOp in project graal by oracle.
the class SSAUtil method forEachPhiRegisterHint.
public static void forEachPhiRegisterHint(LIR lir, AbstractBlockBase<?> block, LabelOp label, Value targetValue, OperandMode mode, ValueConsumer valueConsumer) {
assert mode == OperandMode.DEF : "Wrong operand mode: " + mode;
assert lir.getLIRforBlock(block).get(0).equals(label) : String.format("Block %s and Label %s do not match!", block, label);
if (!label.isPhiIn()) {
return;
}
int idx = indexOfValue(label, targetValue);
assert idx >= 0 : String.format("Value %s not in label %s", targetValue, label);
for (AbstractBlockBase<?> pred : block.getPredecessors()) {
JumpOp jump = phiOut(lir, pred);
Value sourceValue = jump.getOutgoingValue(idx);
valueConsumer.visitValue(jump, sourceValue, null, null);
}
}
use of org.graalvm.compiler.lir.StandardOp.JumpOp in project graal by oracle.
the class SSAUtil method removePhiOut.
public static void removePhiOut(LIR lir, AbstractBlockBase<?> block) {
JumpOp jump = phiOut(lir, block);
jump.clearOutgoingValues();
}
Aggregations