Search in sources :

Example 1 with Interval

use of org.graalvm.compiler.lir.alloc.lsra.Interval 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 Interval

use of org.graalvm.compiler.lir.alloc.lsra.Interval in project graal by oracle.

the class SSALinearScanResolveDataFlowPhase method resolveCollectMappings.

@Override
protected void resolveCollectMappings(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, AbstractBlockBase<?> midBlock, MoveResolver moveResolver) {
    super.resolveCollectMappings(fromBlock, toBlock, midBlock, moveResolver);
    if (toBlock.getPredecessorCount() > 1) {
        int toBlockFirstInstructionId = allocator.getFirstLirInstructionId(toBlock);
        int fromBlockLastInstructionId = allocator.getLastLirInstructionId(fromBlock) + 1;
        AbstractBlockBase<?> phiOutBlock = midBlock != null ? midBlock : fromBlock;
        ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(phiOutBlock);
        int phiOutIdx = SSAUtil.phiOutIndex(allocator.getLIR(), phiOutBlock);
        int phiOutId = midBlock != null ? fromBlockLastInstructionId : instructions.get(phiOutIdx).id();
        assert phiOutId >= 0;
        PhiValueVisitor visitor = new PhiValueVisitor() {

            @Override
            public void visit(Value phiIn, Value phiOut) {
                assert !isRegister(phiOut) : "phiOut is a register: " + phiOut;
                assert !isRegister(phiIn) : "phiIn is a register: " + phiIn;
                Interval toInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiIn), toBlockFirstInstructionId, LIRInstruction.OperandMode.DEF);
                DebugContext debug = allocator.getDebug();
                if (isConstantValue(phiOut)) {
                    numPhiResolutionMoves.increment(debug);
                    moveResolver.addMapping(asConstant(phiOut), toInterval);
                } else {
                    Interval fromInterval = allocator.splitChildAtOpId(allocator.intervalFor(phiOut), phiOutId, LIRInstruction.OperandMode.DEF);
                    if (fromInterval != toInterval && !fromInterval.location().equals(toInterval.location())) {
                        numPhiResolutionMoves.increment(debug);
                        if (!(isStackSlotValue(toInterval.location()) && isStackSlotValue(fromInterval.location()))) {
                            moveResolver.addMapping(fromInterval, toInterval);
                        } else {
                            numStackToStackMoves.increment(debug);
                            moveResolver.addMapping(fromInterval, toInterval);
                        }
                    }
                }
            }
        };
        SSAUtil.forEachPhiValuePair(allocator.getLIR(), toBlock, phiOutBlock, visitor);
        SSAUtil.removePhiOut(allocator.getLIR(), phiOutBlock);
    }
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) LIRValueUtil.isStackSlotValue(org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) Value(jdk.vm.ci.meta.Value) DebugContext(org.graalvm.compiler.debug.DebugContext) PhiValueVisitor(org.graalvm.compiler.lir.ssa.SSAUtil.PhiValueVisitor) Interval(org.graalvm.compiler.lir.alloc.lsra.Interval)

Example 3 with Interval

use of org.graalvm.compiler.lir.alloc.lsra.Interval in project graal by oracle.

the class SSAMoveResolver method breakCycle.

@Override
protected void breakCycle(int spillCandidate) {
    if (spillCandidate != -1) {
        super.breakCycle(spillCandidate);
        return;
    }
    assert mappingFromSize() > 1;
    // Arbitrarily select the first entry for spilling.
    int stackSpillCandidate = 0;
    Interval fromInterval = getMappingFrom(stackSpillCandidate);
    // allocate new stack slot
    VirtualStackSlot spillSlot = getAllocator().getFrameMapBuilder().allocateSpillSlot(fromInterval.kind());
    spillInterval(stackSpillCandidate, fromInterval, spillSlot);
}
Also used : LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) Interval(org.graalvm.compiler.lir.alloc.lsra.Interval)

Aggregations

Interval (org.graalvm.compiler.lir.alloc.lsra.Interval)3 Value (jdk.vm.ci.meta.Value)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)2 EnumSet (java.util.EnumSet)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 OperandFlag (org.graalvm.compiler.lir.LIRInstruction.OperandFlag)1 OperandMode (org.graalvm.compiler.lir.LIRInstruction.OperandMode)1 LIRValueUtil.asVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot)1 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)1 LIRValueUtil.isStackSlotValue (org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue)1 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)1 LabelOp (org.graalvm.compiler.lir.StandardOp.LabelOp)1 ValueConsumer (org.graalvm.compiler.lir.ValueConsumer)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 RegisterPriority (org.graalvm.compiler.lir.alloc.lsra.Interval.RegisterPriority)1 LinearScan (org.graalvm.compiler.lir.alloc.lsra.LinearScan)1 LinearScanLifetimeAnalysisPhase (org.graalvm.compiler.lir.alloc.lsra.LinearScanLifetimeAnalysisPhase)1 SSAUtil (org.graalvm.compiler.lir.ssa.SSAUtil)1 PhiValueVisitor (org.graalvm.compiler.lir.ssa.SSAUtil.PhiValueVisitor)1