Search in sources :

Example 1 with JumpOp

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

Example 2 with JumpOp

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

Example 3 with JumpOp

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]);
    }
}
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)

Example 4 with JumpOp

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);
    }
}
Also used : JumpOp(org.graalvm.compiler.lir.StandardOp.JumpOp) Value(jdk.vm.ci.meta.Value)

Example 5 with JumpOp

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

Aggregations

JumpOp (org.graalvm.compiler.lir.StandardOp.JumpOp)6 Value (jdk.vm.ci.meta.Value)2 LabelOp (org.graalvm.compiler.lir.StandardOp.LabelOp)2 RegisterValue (jdk.vm.ci.code.RegisterValue)1 ValueUtil.asRegisterValue (jdk.vm.ci.code.ValueUtil.asRegisterValue)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)1 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)1 LIRValueUtil.isStackSlotValue (org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue)1 TraceUtil.asShadowedRegisterValue (org.graalvm.compiler.lir.alloc.trace.TraceUtil.asShadowedRegisterValue)1 TraceUtil.isShadowedRegisterValue (org.graalvm.compiler.lir.alloc.trace.TraceUtil.isShadowedRegisterValue)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1