Search in sources :

Example 36 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class LinearScanWalker method excludeFromUse.

void excludeFromUse(Interval i) {
    Value location = i.location();
    int i1 = asRegister(location).number;
    if (isRegisterInRange(i1)) {
        usePos[i1] = 0;
    }
}
Also used : LIRValueUtil.isStackSlotValue(org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue) Value(jdk.vm.ci.meta.Value)

Example 37 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class LinearScanWalker method activateCurrent.

// allocate a physical register or memory location to an interval
@Override
@SuppressWarnings("try")
protected boolean activateCurrent(Interval interval) {
    boolean result = true;
    DebugContext debug = allocator.getDebug();
    try (Indent indent = debug.logAndIndent("activating interval %s,  splitParent: %d", interval, interval.splitParent().operandNumber)) {
        final Value operand = interval.operand;
        if (interval.location() != null && isStackSlotValue(interval.location())) {
            // used for method parameters
            if (debug.isLogEnabled()) {
                debug.log("interval has spill slot assigned (method parameter) . split it before first use");
            }
            splitStackInterval(interval);
            result = false;
        } else {
            if (interval.location() == null) {
                // (this is the normal case for most intervals)
                if (debug.isLogEnabled()) {
                    debug.log("normal allocation of register");
                }
                // assign same spill slot to non-intersecting intervals
                combineSpilledIntervals(interval);
                initVarsForAlloc(interval);
                if (noAllocationPossible(interval) || !allocFreeRegister(interval)) {
                    // no empty register available.
                    // split and spill another interval so that this interval gets a register
                    allocLockedRegister(interval);
                }
                // spilled intervals need not be move to active-list
                if (!isRegister(interval.location())) {
                    result = false;
                }
            }
        }
        // load spilled values that become active from stack slot to register
        if (interval.insertMoveWhenActivated()) {
            assert interval.isSplitChild();
            assert interval.currentSplitChild() != null;
            assert !interval.currentSplitChild().operand.equals(operand) : "cannot insert move between same interval";
            if (debug.isLogEnabled()) {
                debug.log("Inserting move from interval %d to %d because insertMoveWhenActivated is set", interval.currentSplitChild().operandNumber, interval.operandNumber);
            }
            insertMove(interval.from(), interval.currentSplitChild(), interval);
        }
        interval.makeCurrentSplitChild();
    }
    // true = interval is moved to active list
    return result;
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRValueUtil.isStackSlotValue(org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue) Value(jdk.vm.ci.meta.Value) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 38 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class MoveResolver method unblockRegisters.

// mark assignedReg and assignedRegHi of the interval as unblocked
private void unblockRegisters(Interval interval) {
    Value location = interval.location();
    if (mightBeBlocked(location)) {
        assert valueBlocked(location) > 0 : "location already marked as unused: " + location;
        setValueBlocked(location, -1);
        allocator.getDebug().log("unblock %s", location);
    }
}
Also used : Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 39 with Value

use of jdk.vm.ci.meta.Value in project graal by oracle.

the class MoveResolver method printMapping.

@SuppressWarnings("try")
private void printMapping() {
    DebugContext debug = allocator.getDebug();
    try (Indent indent = debug.logAndIndent("Mapping")) {
        for (int i = mappingFrom.size() - 1; i >= 0; i--) {
            Interval fromInterval = mappingFrom.get(i);
            Interval toInterval = mappingTo.get(i);
            String from;
            Value to = toInterval.location();
            if (fromInterval == null) {
                from = mappingFromOpr.get(i).toString();
            } else {
                from = fromInterval.location().toString();
            }
            debug.log("move %s <- %s", from, to);
        }
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 40 with Value

use of jdk.vm.ci.meta.Value 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)

Aggregations

Value (jdk.vm.ci.meta.Value)151 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)76 RegisterValue (jdk.vm.ci.code.RegisterValue)33 LIRKind (org.graalvm.compiler.core.common.LIRKind)18 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)14 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)14 LIRValueUtil.isStackSlotValue (org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue)14 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)12 Variable (org.graalvm.compiler.lir.Variable)12 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)11 Indent (org.graalvm.compiler.debug.Indent)11 EnumSet (java.util.EnumSet)10 DebugContext (org.graalvm.compiler.debug.DebugContext)10 GraalError (org.graalvm.compiler.debug.GraalError)10 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)10 BitSet (java.util.BitSet)9 Register (jdk.vm.ci.code.Register)9 ConstantValue (org.graalvm.compiler.lir.ConstantValue)9 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)9 ValueNode (org.graalvm.compiler.nodes.ValueNode)9