use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class HotSpotZapRegistersPhase method run.
@Override
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PostAllocationOptimizationContext context) {
Stub stub = ((HotSpotLIRGenerationResult) lirGenRes).getStub();
boolean zapRegisters = stub != null && !stub.preservesRegisters();
boolean zapStack = false;
for (AllocatableValue arg : lirGenRes.getCallingConvention().getArguments()) {
if (isStackSlot(arg)) {
zapStack = true;
break;
}
}
if (zapRegisters || zapStack) {
LIR lir = lirGenRes.getLIR();
processLIR(context.diagnosticLirGenTool, (HotSpotLIRGenerationResult) lirGenRes, lir, zapRegisters, zapStack);
}
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class TraceGlobalMoveResolutionPhase method resolve.
public static void resolve(TargetDescription target, LIRGenerationResult lirGenRes, TraceAllocationContext context) {
LIR lir = lirGenRes.getLIR();
DebugContext debug = lir.getDebug();
debug.dump(DebugContext.VERBOSE_LEVEL, lir, "Before TraceGlobalMoveResultion");
MoveFactory spillMoveFactory = context.spillMoveFactory;
resolveGlobalDataFlow(context.resultTraces, lirGenRes, spillMoveFactory, target.arch, context.livenessInfo, context.registerAllocationConfig);
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class TraceRegisterAllocationPhase method run.
@Override
@SuppressWarnings("try")
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) {
MoveFactory spillMoveFactory = context.spillMoveFactory;
RegisterAllocationConfig registerAllocationConfig = context.registerAllocationConfig;
LIR lir = lirGenRes.getLIR();
DebugContext debug = lir.getDebug();
TraceBuilderResult resultTraces = context.contextLookup(TraceBuilderResult.class);
GlobalLivenessInfo livenessInfo = context.contextLookup(GlobalLivenessInfo.class);
assert livenessInfo != null;
TraceAllocationContext traceContext = new TraceAllocationContext(spillMoveFactory, registerAllocationConfig, resultTraces, livenessInfo);
AllocatableValue[] cachedStackSlots = Options.TraceRACacheStackSlots.getValue(lir.getOptions()) ? new AllocatableValue[lir.numVariables()] : null;
// currently this is not supported
boolean neverSpillConstant = false;
final TraceRegisterAllocationPolicy plan = DefaultTraceRegisterAllocationPolicy.allocationPolicy(target, lirGenRes, spillMoveFactory, registerAllocationConfig, cachedStackSlots, resultTraces, neverSpillConstant, livenessInfo, lir.getOptions());
try (DebugContext.Scope s0 = debug.scope("AllocateTraces", resultTraces, livenessInfo)) {
for (Trace trace : resultTraces.getTraces()) {
tracesCounter.increment(debug);
TraceAllocationPhase<TraceAllocationContext> allocator = plan.selectStrategy(trace);
try (Indent i = debug.logAndIndent("Allocating Trace%d: %s (%s)", trace.getId(), trace, allocator);
DebugContext.Scope s = debug.scope("AllocateTrace", trace)) {
allocator.apply(target, lirGenRes, trace, traceContext);
}
}
} catch (Throwable e) {
throw debug.handle(e);
}
TraceGlobalMoveResolutionPhase.resolve(target, lirGenRes, traceContext);
deconstructSSAForm(lir);
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class BottomUpAllocator method resolveFindInsertPos.
private void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock) {
LIR lir = lirGenRes.getLIR();
if (fromBlock.getSuccessorCount() <= 1) {
if (debug.isLogEnabled()) {
debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
}
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(fromBlock);
LIRInstruction instr = instructions.get(instructions.size() - 1);
if (instr instanceof StandardOp.JumpOp) {
// insert moves before branch
moveResolver.setInsertPosition(instructions, instructions.size() - 1);
} else {
moveResolver.setInsertPosition(instructions, instructions.size());
}
} else {
if (debug.isLogEnabled()) {
debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
}
if (Assertions.detailedAssertionsEnabled(getLIR().getOptions())) {
assert lir.getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
/*
* Because the number of predecessor edges matches the number of successor edges,
* blocks which are reached by switch statements may have be more than one
* predecessor but it will be guaranteed that all predecessors will be the same.
*/
for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) {
assert fromBlock == predecessor : "all critical edges must be broken";
}
}
moveResolver.setInsertPosition(lir.getLIRforBlock(toBlock), 1);
}
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class SubstrateAMD64Backend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenResult, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
Assembler masm = createAssembler(frameMap);
SharedMethod method = ((SubstrateLIRGenerationResult) lirGenResult).getMethod();
Deoptimizer.StubType stubType = method.getDeoptStubType();
DataBuilder dataBuilder = new SubstrateDataBuilder();
FrameContext frameContext;
if (stubType == Deoptimizer.StubType.EntryStub) {
frameContext = new DeoptEntryStubContext();
} else if (stubType == Deoptimizer.StubType.ExitStub) {
frameContext = new DeoptExitStubContext();
} else {
frameContext = new SubstrateAMD64FrameContext();
}
LIR lir = lirGenResult.getLIR();
OptionValues options = lir.getOptions();
DebugContext debug = lir.getDebug();
CompilationResultBuilder tasm = factory.createBuilder(getCodeCache(), getForeignCalls(), lirGenResult.getFrameMap(), masm, dataBuilder, frameContext, options, debug, compilationResult);
tasm.setTotalFrameSize(lirGenResult.getFrameMap().totalFrameSize());
return tasm;
}
Aggregations