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);
}
});
}
}
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);
}
}
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);
}
Aggregations