Search in sources :

Example 26 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class MoveProfiler method doBlock.

private void doBlock(AbstractBlockBase<?> block) {
    ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
    assert instructions.size() >= 2 : "Malformed block: " + block + ", " + instructions;
    assert instructions.get(instructions.size() - 1) instanceof BlockEndOp : "Not a BlockEndOp: " + instructions.get(instructions.size() - 1);
    assert !(instructions.get(instructions.size() - 2) instanceof BlockEndOp) : "Is a BlockEndOp: " + instructions.get(instructions.size() - 2);
    assert instructions.get(0) instanceof LabelOp : "Not a LabelOp: " + instructions.get(0);
    assert !(instructions.get(1) instanceof LabelOp) : "Is a LabelOp: " + instructions.get(1);
    MoveStatistics stats = null;
    // analysis phase
    for (LIRInstruction inst : instructions) {
        if (MoveOp.isMoveOp(inst)) {
            if (stats == null) {
                stats = new MoveStatistics();
                blockMap.put(block, stats);
            }
            stats.add(MoveType.get(inst));
        }
    }
}
Also used : BlockEndOp(org.graalvm.compiler.lir.StandardOp.BlockEndOp) LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 27 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction 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 28 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class SPARCHotSpotBackend method stuffDelayedControlTransfers.

/**
 * Tries to put DelayedControlTransfer instructions and DelayableLIRInstructions together. Also
 * it tries to move the DelayedLIRInstruction to the DelayedControlTransfer instruction, if
 * possible.
 */
private static void stuffDelayedControlTransfers(LIR l, AbstractBlockBase<?> block) {
    ArrayList<LIRInstruction> instructions = l.getLIRforBlock(block);
    if (instructions.size() >= 2) {
        LIRDependencyAccumulator acc = new LIRDependencyAccumulator();
        SPARCDelayedControlTransfer delayedTransfer = null;
        int delayTransferPosition = -1;
        for (int i = instructions.size() - 1; i >= 0; i--) {
            LIRInstruction inst = instructions.get(i);
            boolean adjacent = delayTransferPosition - i == 1;
            if (!adjacent || inst.destroysCallerSavedRegisters() || leavesRegisterWindow(inst)) {
                delayedTransfer = null;
            }
            if (inst instanceof SPARCDelayedControlTransfer) {
                delayedTransfer = (SPARCDelayedControlTransfer) inst;
                acc.start(inst);
                delayTransferPosition = i;
            } else if (delayedTransfer != null) {
                boolean overlap = acc.add(inst);
                if (!overlap && inst instanceof SPARCTailDelayedLIRInstruction) {
                    // We have found a non overlapping LIR instruction which can be delayed
                    ((SPARCTailDelayedLIRInstruction) inst).setDelayedControlTransfer(delayedTransfer);
                    delayedTransfer = null;
                }
            }
        }
    }
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) SPARCTailDelayedLIRInstruction(org.graalvm.compiler.lir.sparc.SPARCTailDelayedLIRInstruction) SPARCDelayedControlTransfer(org.graalvm.compiler.lir.sparc.SPARCDelayedControlTransfer) SPARCTailDelayedLIRInstruction(org.graalvm.compiler.lir.sparc.SPARCTailDelayedLIRInstruction)

Example 29 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class CFGPrinter method printTraceInstructions.

private void printTraceInstructions(Trace trace, TraceBuilderResult traceBuilderResult) {
    if (lir == null) {
        return;
    }
    begin("IR");
    out.println("LIR");
    for (AbstractBlockBase<?> block : trace.getBlocks()) {
        ArrayList<LIRInstruction> lirInstructions = lir.getLIRforBlock(block);
        if (lirInstructions == null) {
            continue;
        }
        printBlockInstruction(block, traceBuilderResult);
        for (int i = 0; i < lirInstructions.size(); i++) {
            LIRInstruction inst = lirInstructions.get(i);
            printLIRInstruction(inst);
        }
    }
    end("IR");
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 30 with LIRInstruction

use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.

the class CFGPrinter method printLIR.

/**
 * Prints the LIR for each instruction in a given block.
 *
 * @param block the block to print
 */
private void printLIR(AbstractBlockBase<?> block) {
    if (lir == null) {
        return;
    }
    ArrayList<LIRInstruction> lirInstructions = lir.getLIRforBlock(block);
    if (lirInstructions == null) {
        return;
    }
    begin("IR");
    out.println("LIR");
    if (livenessInfo != null) {
        int opId = lirInstructions.get(0).id();
        printLiveVars(livenessInfo.getBlockIn(block), "in(var)", opId);
        printLiveLoc(livenessInfo.getInLocation(block), "in(loc)", opId);
    }
    for (int i = 0; i < lirInstructions.size(); i++) {
        LIRInstruction inst = lirInstructions.get(i);
        printLIRInstruction(inst);
    }
    if (livenessInfo != null) {
        int opId = lirInstructions.get(lirInstructions.size() - 1).id();
        printLiveVars(livenessInfo.getBlockOut(block), "out(var)", opId);
        printLiveLoc(livenessInfo.getOutLocation(block), "out(loc)", opId);
    }
    end("IR");
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Aggregations

LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)55 DebugContext (org.graalvm.compiler.debug.DebugContext)25 Indent (org.graalvm.compiler.debug.Indent)19 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)15 Value (jdk.vm.ci.meta.Value)15 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)10 EnumSet (java.util.EnumSet)8 Register (jdk.vm.ci.code.Register)8 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)8 OperandFlag (org.graalvm.compiler.lir.LIRInstruction.OperandFlag)7 BitSet (java.util.BitSet)6 GraalError (org.graalvm.compiler.debug.GraalError)6 InstructionValueConsumer (org.graalvm.compiler.lir.InstructionValueConsumer)6 LIR (org.graalvm.compiler.lir.LIR)6 LIRInsertionBuffer (org.graalvm.compiler.lir.LIRInsertionBuffer)6 ValueConsumer (org.graalvm.compiler.lir.ValueConsumer)6 ArrayList (java.util.ArrayList)5 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)5 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)5 LoadConstantOp (org.graalvm.compiler.lir.StandardOp.LoadConstantOp)5