Search in sources :

Example 1 with ComputeBlockOrder

use of org.graalvm.compiler.core.common.alloc.ComputeBlockOrder in project graal by oracle.

the class LinearScanLifetimeAnalysisPhase method numberInstructions.

/**
 * Numbers all instructions in all blocks. The numbering follows the
 * {@linkplain ComputeBlockOrder linear scan order}.
 */
protected void numberInstructions() {
    allocator.initIntervals();
    ValueConsumer setVariableConsumer = (value, mode, flags) -> {
        if (isVariable(value)) {
            allocator.getOrCreateInterval(asVariable(value));
        }
    };
    // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node.
    int numInstructions = 0;
    for (AbstractBlockBase<?> block : allocator.sortedBlocks()) {
        numInstructions += allocator.getLIR().getLIRforBlock(block).size();
    }
    // initialize with correct length
    allocator.initOpIdMaps(numInstructions);
    int opId = 0;
    int index = 0;
    for (AbstractBlockBase<?> block : allocator.sortedBlocks()) {
        allocator.initBlockData(block);
        ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(block);
        int numInst = instructions.size();
        for (int j = 0; j < numInst; j++) {
            LIRInstruction op = instructions.get(j);
            op.setId(opId);
            allocator.putOpIdMaps(index, op, block);
            assert allocator.instructionForId(opId) == op : "must match";
            op.visitEachTemp(setVariableConsumer);
            op.visitEachOutput(setVariableConsumer);
            index++;
            // numbering of lirOps by two
            opId += 2;
        }
    }
    assert index == numInstructions : "must match";
    assert (index << 1) == opId : "must match: " + (index << 1);
}
Also used : AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException) Constant(jdk.vm.ci.meta.Constant) LoadConstantOp(org.graalvm.compiler.lir.StandardOp.LoadConstantOp) BitMap2D(org.graalvm.compiler.core.common.util.BitMap2D) LIRValueUtil.asVariable(org.graalvm.compiler.lir.LIRValueUtil.asVariable) EconomicSet(org.graalvm.collections.EconomicSet) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) Register(jdk.vm.ci.code.Register) Assertions(org.graalvm.compiler.debug.Assertions) ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) ArrayList(java.util.ArrayList) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) SpillState(org.graalvm.compiler.lir.alloc.lsra.Interval.SpillState) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) DebugContext(org.graalvm.compiler.debug.DebugContext) RegisterArray(jdk.vm.ci.code.RegisterArray) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ComputeBlockOrder(org.graalvm.compiler.core.common.alloc.ComputeBlockOrder) BlockData(org.graalvm.compiler.lir.alloc.lsra.LinearScan.BlockData) LIRGenerationDebugContext.getSourceForOperandFromDebugContext(org.graalvm.compiler.lir.debug.LIRGenerationDebugContext.getSourceForOperandFromDebugContext) Equivalence(org.graalvm.collections.Equivalence) EnumSet(java.util.EnumSet) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode) ValueConsumer(org.graalvm.compiler.lir.ValueConsumer) LIRValueUtil.isVariable(org.graalvm.compiler.lir.LIRValueUtil.isVariable) LIRKind(org.graalvm.compiler.core.common.LIRKind) AllocationContext(org.graalvm.compiler.lir.phases.AllocationPhase.AllocationContext) TargetDescription(jdk.vm.ci.code.TargetDescription) JavaConstant(jdk.vm.ci.meta.JavaConstant) RegisterPriority(org.graalvm.compiler.lir.alloc.lsra.Interval.RegisterPriority) Value(jdk.vm.ci.meta.Value) ValueMoveOp(org.graalvm.compiler.lir.StandardOp.ValueMoveOp) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) StackSlot(jdk.vm.ci.code.StackSlot) BitSet(java.util.BitSet) ArrayDeque(java.util.ArrayDeque) ValueKind(jdk.vm.ci.meta.ValueKind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) ValueConsumer(org.graalvm.compiler.lir.ValueConsumer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Aggregations

ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 EnumSet (java.util.EnumSet)1 Register (jdk.vm.ci.code.Register)1 RegisterArray (jdk.vm.ci.code.RegisterArray)1 StackSlot (jdk.vm.ci.code.StackSlot)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)1 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)1 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)1 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 Constant (jdk.vm.ci.meta.Constant)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 Value (jdk.vm.ci.meta.Value)1 ValueKind (jdk.vm.ci.meta.ValueKind)1 EconomicSet (org.graalvm.collections.EconomicSet)1 Equivalence (org.graalvm.collections.Equivalence)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1