use of jdk.vm.ci.code.RegisterArray in project graal by oracle.
the class AArch64HotSpotRegisterAllocationConfig method initAllocatable.
@Override
protected RegisterArray initAllocatable(RegisterArray registers) {
BitSet regMap = new BitSet(registerConfig.getAllocatableRegisters().size());
for (Register reg : registers) {
regMap.set(reg.number);
}
ArrayList<Register> allocatableRegisters = new ArrayList<>(registers.size());
for (Register reg : registerAllocationOrder) {
if (regMap.get(reg.number)) {
allocatableRegisters.add(reg);
}
}
return super.initAllocatable(new RegisterArray(allocatableRegisters));
}
use of jdk.vm.ci.code.RegisterArray in project graal by oracle.
the class AArch64HotSpotBackendFactory method createNativeABICallerSaveRegisters.
protected static Value[] createNativeABICallerSaveRegisters(@SuppressWarnings("unused") GraalHotSpotVMConfig config, RegisterConfig regConfig) {
AArch64HotSpotRegisterConfig conf = (AArch64HotSpotRegisterConfig) regConfig;
RegisterArray callerSavedRegisters = conf.getCallerSaveRegisters();
int size = callerSavedRegisters.size();
Value[] nativeABICallerSaveRegisters = new Value[size];
for (int i = 0; i < size; i++) {
nativeABICallerSaveRegisters[i] = callerSavedRegisters.get(i).asValue();
}
return nativeABICallerSaveRegisters;
}
use of jdk.vm.ci.code.RegisterArray in project graal by oracle.
the class AMD64HotSpotRegisterAllocationConfig method initAllocatable.
@Override
protected RegisterArray initAllocatable(RegisterArray registers) {
BitSet regMap = new BitSet(registerConfig.getAllocatableRegisters().size());
for (Register reg : registers) {
regMap.set(reg.number);
}
ArrayList<Register> allocatableRegisters = new ArrayList<>(registers.size());
for (Register reg : registerAllocationOrder) {
if (regMap.get(reg.number)) {
allocatableRegisters.add(reg);
}
}
return super.initAllocatable(new RegisterArray(allocatableRegisters));
}
use of jdk.vm.ci.code.RegisterArray in project graal by oracle.
the class SPARCHotSpotRegisterAllocationConfig method initAllocatable.
@Override
protected RegisterArray initAllocatable(RegisterArray registers) {
BitSet regMap = new BitSet(registerConfig.getAllocatableRegisters().size());
for (Register reg : registers) {
regMap.set(reg.number);
}
ArrayList<Register> allocatableRegisters = new ArrayList<>(registers.size());
for (Register reg : registerAllocationOrder) {
if (regMap.get(reg.number)) {
allocatableRegisters.add(reg);
}
}
return super.initAllocatable(new RegisterArray(allocatableRegisters));
}
use of jdk.vm.ci.code.RegisterArray in project graal by oracle.
the class LinearScanLifetimeAnalysisPhase method buildIntervals.
@SuppressWarnings("try")
protected void buildIntervals(boolean detailedAsserts) {
try (Indent indent = debug.logAndIndent("build intervals")) {
InstructionValueConsumer outputConsumer = (op, operand, mode, flags) -> {
if (LinearScan.isVariableOrRegister(operand)) {
addDef((AllocatableValue) operand, op, registerPriorityOfOutputOperand(op), operand.getValueKind(), detailedAsserts);
addRegisterHint(op, operand, mode, flags, true);
}
};
InstructionValueConsumer tempConsumer = (op, operand, mode, flags) -> {
if (LinearScan.isVariableOrRegister(operand)) {
addTemp((AllocatableValue) operand, op.id(), RegisterPriority.MustHaveRegister, operand.getValueKind(), detailedAsserts);
addRegisterHint(op, operand, mode, flags, false);
}
};
InstructionValueConsumer aliveConsumer = (op, operand, mode, flags) -> {
if (LinearScan.isVariableOrRegister(operand)) {
RegisterPriority p = registerPriorityOfInputOperand(flags);
int opId = op.id();
int blockFrom = allocator.getFirstLirInstructionId((allocator.blockForId(opId)));
addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getValueKind(), detailedAsserts);
addRegisterHint(op, operand, mode, flags, false);
}
};
InstructionValueConsumer inputConsumer = (op, operand, mode, flags) -> {
if (LinearScan.isVariableOrRegister(operand)) {
int opId = op.id();
int blockFrom = allocator.getFirstLirInstructionId((allocator.blockForId(opId)));
RegisterPriority p = registerPriorityOfInputOperand(flags);
addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getValueKind(), detailedAsserts);
addRegisterHint(op, operand, mode, flags, false);
}
};
InstructionValueConsumer stateProc = (op, operand, mode, flags) -> {
if (LinearScan.isVariableOrRegister(operand)) {
int opId = op.id();
int blockFrom = allocator.getFirstLirInstructionId((allocator.blockForId(opId)));
addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getValueKind(), detailedAsserts);
}
};
// create a list with all caller-save registers (cpu, fpu, xmm)
RegisterArray callerSaveRegs = allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters();
// iterate all blocks in reverse order
for (int i = allocator.blockCount() - 1; i >= 0; i--) {
AbstractBlockBase<?> block = allocator.blockAt(i);
try (Indent indent2 = debug.logAndIndent("handle block %d", block.getId())) {
ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(block);
final int blockFrom = allocator.getFirstLirInstructionId(block);
int blockTo = allocator.getLastLirInstructionId(block);
assert blockFrom == instructions.get(0).id();
assert blockTo == instructions.get(instructions.size() - 1).id();
// Update intervals for operands live at the end of this block;
BitSet live = allocator.getBlockData(block).liveOut;
for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) {
assert live.get(operandNum) : "should not stop here otherwise";
AllocatableValue operand = allocator.intervalFor(operandNum).operand;
if (debug.isLogEnabled()) {
debug.log("live in %d: %s", operandNum, operand);
}
addUse(operand, blockFrom, blockTo + 2, RegisterPriority.None, LIRKind.Illegal, detailedAsserts);
/*
* Add special use positions for loop-end blocks when the interval is used
* anywhere inside this loop. It's possible that the block was part of a
* non-natural loop, so it might have an invalid loop index.
*/
if (block.isLoopEnd() && block.getLoop() != null && isIntervalInLoop(operandNum, block.getLoop().getIndex())) {
allocator.intervalFor(operandNum).addUsePos(blockTo + 1, RegisterPriority.LiveAtLoopEnd, detailedAsserts);
}
}
/*
* Iterate all instructions of the block in reverse order. definitions of
* intervals are processed before uses.
*/
for (int j = instructions.size() - 1; j >= 0; j--) {
final LIRInstruction op = instructions.get(j);
final int opId = op.id();
try (Indent indent3 = debug.logAndIndent("handle inst %d: %s", opId, op)) {
// caller-save registers
if (op.destroysCallerSavedRegisters()) {
for (Register r : callerSaveRegs) {
if (allocator.attributes(r).isAllocatable()) {
addTemp(r.asValue(), opId, RegisterPriority.None, LIRKind.Illegal, detailedAsserts);
}
}
if (debug.isLogEnabled()) {
debug.log("operation destroys all caller-save registers");
}
}
op.visitEachOutput(outputConsumer);
op.visitEachTemp(tempConsumer);
op.visitEachAlive(aliveConsumer);
op.visitEachInput(inputConsumer);
/*
* Add uses of live locals from interpreter's point of view for proper
* debug information generation. Treat these operands as temp values (if
* the live range is extended to a call site, the value would be in a
* register at the call otherwise).
*/
op.visitEachState(stateProc);
// special steps for some instructions (especially moves)
handleMethodArguments(op);
}
}
// end of instruction iteration
}
}
/*
* Add the range [0, 1] to all fixed intervals. the register allocator need not handle
* unhandled fixed intervals.
*/
for (Interval interval : allocator.intervals()) {
if (interval != null && isRegister(interval.operand)) {
interval.addRange(0, 1);
}
}
}
}
Aggregations