Target VCode adapter for the reusable register allocator
Dependencies
///|
test "allocate Target VCode" {
let builder : @vcode.Builder[Unit] = @vcode.Builder::new("copy", [I64])
let entry = builder.entry_block()
let source = builder.parameter(0)
let (_, result) = builder.append_body(
entry,
(),
[@vcode.Input::any(source)],
[@vcode.Output::any(I64)],
[],
@vcode.InstructionMetadata::empty(),
)
builder.set_terminator(
entry,
(),
[@vcode.Input::any(result[0])],
[],
[],
@vcode.InstructionMetadata::empty(),
)
|> ignore
let function = builder.finish()
let allocation = allocate_vcode(
function,
VCodeAllocationEnvironment::new([@vcode.PhysicalReg::new(0, Int)], [
@vcode.PhysicalReg::new(1, Int),
]),
)
inspect(allocation.source_instruction_count(), content="2")
}pub suberror VCodeAllocationError {
InvalidSelected(cause~ : VCodeVerifyError)
RegallocFailure(cause~ : VerifyError)
AllocationConstructionRejected
InvalidAllocation(cause~ : AllocationVerifyError)
} derive(Debug)impl Show for VCodeAllocationErrorpub struct VCodeAllocationEnvironment {
allocatable_regs : Array[PhysicalReg]
spill_scratch_regs : Array[PhysicalReg]
fixed_operand_regs : Array[PhysicalReg]
}fn VCodeAllocationEnvironment::new(allocatable_regs : Array[PhysicalReg], spill_scratch_regs : Array[PhysicalReg]) -> VCodeAllocationEnvironmentfn VCodeAllocationEnvironment::with_fixed_operand_regs(self : VCodeAllocationEnvironment, fixed_operand_regs : Array[PhysicalReg]) -> VCodeAllocationEnvironmentfn[Inst] allocate_selected_vcode(function : Function[Inst], environment : VCodeAllocationEnvironment, on_phase? : (String?) -> Unit?, verify? : Bool) -> Allocation raise VCodeAllocationErrorfn[Inst] allocate_vcode(function : Function[Inst], environment : VCodeAllocationEnvironment) -> Allocation raise VCodeAllocationErrorTarget VCode adapter for the reusable register allocator
Dependencies