Search in sources :

Example 6 with LabelOp

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));
    }
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) JumpOp(org.graalvm.compiler.lir.StandardOp.JumpOp)

Example 7 with LabelOp

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;
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 8 with LabelOp

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]);
    }
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) JumpOp(org.graalvm.compiler.lir.StandardOp.JumpOp) LIRValueUtil.isStackSlotValue(org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue) TraceUtil.isShadowedRegisterValue(org.graalvm.compiler.lir.alloc.trace.TraceUtil.isShadowedRegisterValue) TraceUtil.asShadowedRegisterValue(org.graalvm.compiler.lir.alloc.trace.TraceUtil.asShadowedRegisterValue) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) RegisterValue(jdk.vm.ci.code.RegisterValue) ValueUtil.asRegisterValue(jdk.vm.ci.code.ValueUtil.asRegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

LabelOp (org.graalvm.compiler.lir.StandardOp.LabelOp)8 Value (jdk.vm.ci.meta.Value)4 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 EnumSet (java.util.EnumSet)2 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)2 JumpOp (org.graalvm.compiler.lir.StandardOp.JumpOp)2 ValueConsumer (org.graalvm.compiler.lir.ValueConsumer)2 Register (jdk.vm.ci.code.Register)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 ValueUtil.asRegisterValue (jdk.vm.ci.code.ValueUtil.asRegisterValue)1 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)1 GraalError (org.graalvm.compiler.debug.GraalError)1 Indent (org.graalvm.compiler.debug.Indent)1 GraalGraphError (org.graalvm.compiler.graph.GraalGraphError)1 Node (org.graalvm.compiler.graph.Node)1 OperandFlag (org.graalvm.compiler.lir.LIRInstruction.OperandFlag)1 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)1 LIRValueUtil.isStackSlotValue (org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue)1