Search in sources :

Example 1 with OperandFlag

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

the class SSALinearScanLifetimeAnalysisPhase method addRegisterHint.

@Override
protected void addRegisterHint(final LIRInstruction op, final Value targetValue, OperandMode mode, EnumSet<OperandFlag> flags, final boolean hintAtDef) {
    super.addRegisterHint(op, targetValue, mode, flags, hintAtDef);
    if (hintAtDef && op instanceof LabelOp) {
        LabelOp label = (LabelOp) op;
        Interval to = allocator.getOrCreateInterval((AllocatableValue) targetValue);
        SSAUtil.forEachPhiRegisterHint(allocator.getLIR(), allocator.blockForId(label.id()), label, targetValue, mode, (ValueConsumer) (registerHint, valueMode, valueFlags) -> {
            if (LinearScan.isVariableOrRegister(registerHint)) {
                Interval from = allocator.getOrCreateInterval((AllocatableValue) registerHint);
                setHint(debug, op, to, from);
                setHint(debug, op, from, to);
            }
        });
    }
}
Also used : OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode) Interval(org.graalvm.compiler.lir.alloc.lsra.Interval) ValueConsumer(org.graalvm.compiler.lir.ValueConsumer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) RegisterPriority(org.graalvm.compiler.lir.alloc.lsra.Interval.RegisterPriority) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) DebugContext(org.graalvm.compiler.debug.DebugContext) LinearScan(org.graalvm.compiler.lir.alloc.lsra.LinearScan) LinearScanLifetimeAnalysisPhase(org.graalvm.compiler.lir.alloc.lsra.LinearScanLifetimeAnalysisPhase) SSAUtil(org.graalvm.compiler.lir.ssa.SSAUtil) EnumSet(java.util.EnumSet) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) Interval(org.graalvm.compiler.lir.alloc.lsra.Interval)

Example 2 with OperandFlag

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

the class RegisterVerifier method processOperations.

void processOperations(AbstractBlockBase<?> block, final Interval[] inputState) {
    ArrayList<LIRInstruction> ops = allocator.getLIR().getLIRforBlock(block);
    DebugContext debug = allocator.getDebug();
    InstructionValueConsumer useConsumer = new InstructionValueConsumer() {

        @Override
        public void visitValue(LIRInstruction op, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
            // we skip spill moves inserted by the spill position optimization
            if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand) && op.id() != LinearScan.DOMINATOR_SPILL_MOVE_ID) {
                Interval interval = intervalAt(operand);
                if (op.id() != -1) {
                    interval = interval.getSplitChildAtOpId(op.id(), mode, allocator);
                }
                assert checkState(block, op, inputState, interval.operand, interval.location(), interval.splitParent());
            }
        }
    };
    InstructionValueConsumer defConsumer = (op, operand, mode, flags) -> {
        if (LinearScan.isVariableOrRegister(operand) && allocator.isProcessed(operand)) {
            Interval interval = intervalAt(operand);
            if (op.id() != -1) {
                interval = interval.getSplitChildAtOpId(op.id(), mode, allocator);
            }
            statePut(debug, inputState, interval.location(), interval.splitParent());
        }
    };
    // visit all instructions of the block
    for (int i = 0; i < ops.size(); i++) {
        final LIRInstruction op = ops.get(i);
        if (debug.isLogEnabled()) {
            debug.log("%s", op.toStringWithIdPrefix());
        }
        // check if input operands are correct
        op.visitEachInput(useConsumer);
        // invalidate all caller save registers at calls
        if (op.destroysCallerSavedRegisters()) {
            for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) {
                statePut(debug, inputState, r.asValue(), null);
            }
        }
        op.visitEachAlive(useConsumer);
        // set temp operands (some operations use temp operands also as output operands, so
        // can't set them null)
        op.visitEachTemp(defConsumer);
        // set output operands
        op.visitEachOutput(defConsumer);
    }
}
Also used : AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) Register(jdk.vm.ci.code.Register) ArrayList(java.util.ArrayList) BlockMap(org.graalvm.compiler.core.common.cfg.BlockMap) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) DebugContext(org.graalvm.compiler.debug.DebugContext) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) EnumSet(java.util.EnumSet) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) EnumSet(java.util.EnumSet) Value(jdk.vm.ci.meta.Value) DebugContext(org.graalvm.compiler.debug.DebugContext) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Example 3 with OperandFlag

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

the class RegisterVerifier method processOperations.

void processOperations(AbstractBlockBase<?> block, final TraceInterval[] inputState) {
    ArrayList<LIRInstruction> ops = allocator.getLIR().getLIRforBlock(block);
    DebugContext debug = allocator.getDebug();
    InstructionValueConsumer useConsumer = new InstructionValueConsumer() {

        @Override
        public void visitValue(LIRInstruction op, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
            // we skip spill moves inserted by the spill position optimization
            if (isVariableOrRegister(operand) && allocator.isProcessed(operand) && op.id() != TraceLinearScanPhase.DOMINATOR_SPILL_MOVE_ID) {
                TraceInterval interval = intervalAt(asVariable(operand));
                if (op.id() != -1) {
                    interval = interval.getSplitChildAtOpId(op.id(), mode);
                }
                assert checkState(block, op, inputState, allocator.getOperand(interval), interval.location(), interval.splitParent());
            }
        }
    };
    InstructionValueConsumer defConsumer = (op, operand, mode, flags) -> {
        if (isVariableOrRegister(operand) && allocator.isProcessed(operand)) {
            TraceInterval interval = intervalAt(asVariable(operand));
            if (op.id() != -1) {
                interval = interval.getSplitChildAtOpId(op.id(), mode);
            }
            statePut(debug, inputState, interval.location(), interval.splitParent());
        }
    };
    // visit all instructions of the block
    for (int i = 0; i < ops.size(); i++) {
        final LIRInstruction op = ops.get(i);
        if (debug.isLogEnabled()) {
            debug.log("%s", op.toStringWithIdPrefix());
        }
        // check if input operands are correct
        op.visitEachInput(useConsumer);
        // invalidate all caller save registers at calls
        if (op.destroysCallerSavedRegisters()) {
            for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) {
                statePut(debug, inputState, r.asValue(), null);
            }
        }
        op.visitEachAlive(useConsumer);
        // set temp operands (some operations use temp operands also as output operands, so
        // can't set them null)
        op.visitEachTemp(defConsumer);
        // set output operands
        op.visitEachOutput(defConsumer);
    }
}
Also used : AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode) Variable(org.graalvm.compiler.lir.Variable) TraceLinearScanPhase.isVariableOrRegister(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.isVariableOrRegister) TraceLinearScan(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.TraceLinearScan) LIRValueUtil.asVariable(org.graalvm.compiler.lir.LIRValueUtil.asVariable) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) Register(jdk.vm.ci.code.Register) ArrayList(java.util.ArrayList) BlockMap(org.graalvm.compiler.core.common.cfg.BlockMap) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) DebugContext(org.graalvm.compiler.debug.DebugContext) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) EnumSet(java.util.EnumSet) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) TraceLinearScanPhase.isVariableOrRegister(org.graalvm.compiler.lir.alloc.trace.lsra.TraceLinearScanPhase.isVariableOrRegister) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) EnumSet(java.util.EnumSet) Value(jdk.vm.ci.meta.Value) DebugContext(org.graalvm.compiler.debug.DebugContext) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Example 4 with OperandFlag

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

the class FrameMapBuilderImpl method verifyStackSlotAllocation.

private static void verifyStackSlotAllocation(LIRGenerationResult res) {
    LIR lir = res.getLIR();
    InstructionValueConsumer verifySlots = (LIRInstruction op, Value value, OperandMode mode, EnumSet<OperandFlag> flags) -> {
        assert !isVirtualStackSlot(value) : String.format("Instruction %s contains a virtual stack slot %s", op, value);
    };
    for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) {
        lir.getLIRforBlock(block).forEach(op -> {
            op.visitEachInput(verifySlots);
            op.visitEachAlive(verifySlots);
            op.visitEachState(verifySlots);
            op.visitEachTemp(verifySlots);
            op.visitEachOutput(verifySlots);
        });
    }
}
Also used : LIR(org.graalvm.compiler.lir.LIR) InstructionValueConsumer(org.graalvm.compiler.lir.InstructionValueConsumer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) Value(jdk.vm.ci.meta.Value) OperandFlag(org.graalvm.compiler.lir.LIRInstruction.OperandFlag) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

Aggregations

Value (jdk.vm.ci.meta.Value)4 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)4 OperandFlag (org.graalvm.compiler.lir.LIRInstruction.OperandFlag)4 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)4 EnumSet (java.util.EnumSet)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 InstructionValueConsumer (org.graalvm.compiler.lir.InstructionValueConsumer)3 ArrayList (java.util.ArrayList)2 Register (jdk.vm.ci.code.Register)2 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)2 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)2 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)2 BlockMap (org.graalvm.compiler.core.common.cfg.BlockMap)2 GraalError (org.graalvm.compiler.debug.GraalError)2 Indent (org.graalvm.compiler.debug.Indent)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 LIR (org.graalvm.compiler.lir.LIR)1 LIRValueUtil.asVariable (org.graalvm.compiler.lir.LIRValueUtil.asVariable)1 LabelOp (org.graalvm.compiler.lir.StandardOp.LabelOp)1 ValueConsumer (org.graalvm.compiler.lir.ValueConsumer)1