use of org.graalvm.compiler.lir.StandardOp.LabelOp 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.LabelOp in project graal by oracle.
the class SSALinearScanEliminateSpillMovePhase method isPhiResolutionMove.
@SuppressWarnings("try")
private boolean isPhiResolutionMove(AbstractBlockBase<?> block, MoveOp move, Interval toInterval) {
if (!toInterval.isSplitParent()) {
return false;
}
if ((toInterval.from() & 1) == 1) {
// phi intervals start at even positions.
return false;
}
if (block.getSuccessorCount() != 1) {
return false;
}
LIRInstruction op = allocator.instructionForId(toInterval.from());
if (!(op instanceof LabelOp)) {
return false;
}
AbstractBlockBase<?> intStartBlock = allocator.blockForId(toInterval.from());
assert allocator.getLIR().getLIRforBlock(intStartBlock).get(0).equals(op);
if (!block.getSuccessors()[0].equals(intStartBlock)) {
return false;
}
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.indent()) {
debug.log("Is a move (%s) to phi interval %s", move, toInterval);
}
return true;
}
use of org.graalvm.compiler.lir.StandardOp.LabelOp 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]);
}
}
Aggregations