Target VCode adapter for the reusable register allocator
Dependencies
///|
fn example_abi() -> @abi.EmbeddingABI {
let call_conv : @abi.CallConventionLayout = {
context_arg: { index: 27, class: Int },
user_arg_gprs: [{ index: 0, class: Int }, { index: 1, class: Int }],
arg_fprs: [{ index: 0, class: Float64 }, { index: 1, class: Float64 }],
ret_gprs: [{ index: 0, class: Int }],
ret_fprs: [{ index: 0, class: Float64 }],
}
EmbeddingABI(call_conv, reserve_context_role=false)
}
///|
test "allocate a MachV copy" {
let builder = @machv.FunctionBuilder::FunctionBuilder("copy")
let src = builder.add_param(Int)
let dst = builder.new_vreg(Int)
builder.append(Move, uses=[Virtual(src)], defs=[{ reg: Virtual(dst) }])
|> ignore
builder.terminate(Return([Virtual(dst)]))
let allocated = allocate_registers_backtracking_with_isa(
builder.finish(),
AArch64,
embedding_abi=Some(example_abi()),
)
inspect(allocated.blocks.length(), content="1")
inspect(allocated.blocks[0].terminator is Some(Return(_)), content="true")
}///|
test "read operand locations from regalloc output" {
let builder = @machv.FunctionBuilder::FunctionBuilder("rewrite")
let src = builder.add_param(Int)
let dst = builder.new_vreg(Int)
builder.append(Move, uses=[Virtual(src)], defs=[{ reg: Virtual(dst) }])
|> ignore
builder.terminate(Return([Virtual(dst)]))
let (_func, output) = allocate_registers_backtracking_output_with_isa(
builder.finish(),
AArch64,
embedding_abi=Some(example_abi()),
)
inspect(output.get_num_spillslots(), content="0")
inspect(output.inst_def_loc(0, 0, false, 0) is Reg(_), content="true")
inspect(output.inst_use_loc(0, 0, false, 0) is Reg(_), content="true")
}type AArch64StackFrameimpl Show for AArch64StackFrametype Bundletype BundleSettype LiveRangetype LiveRangeSetpub struct LivenessResult {
intervals : Map[Int, LiveInterval]
use_def : Map[Int, UseDefInfo]
use_def_dense : Array[UseDefInfo?]
live_in : Array[Set[Int]]
live_out : Array[Set[Int]]
live_in_dense : Array[Array[Int]]?
live_out_dense : Array[Array[Int]]?
block_order : FixedArray[Int]
call_points : Array[(ProgPoint, CallClobberClass)]
}pub struct Output {
param_locs : Array[Loc]
allocs : Array[Loc]
operand_ranges : Array[(Int, Int, Bool, Int, Int, Int)]
inst_operand_range_index : Array[Array[Int]]
term_operand_range_index : Array[Int]
edits : Array[((Int, Int, ProgPos), Edit)]
edits_before_dense : Array[Array[Array[Edit]]]
edits_after_dense : Array[Array[Array[Edit]]]
used_int_pregs_any : Array[Bool]
used_fp_pregs_any : Array[Bool]
num_spillslots : Int
}type ProgPointRangeimpl Show for ProgPointRangefn ProgPointRange::contains(self : ProgPointRange, point : ProgPoint, block_order : FixedArray[Int]) -> Booltype RegMovetype SpillBundletype StackFrameimpl Show for StackFrametype StackSlotimpl Show for StackSlotKindtype UseKindfn allocate_registers_backtracking_output(func : Function, embedding_abi? : EmbeddingABI?) -> (Function, Output)fn allocate_registers_backtracking_output_with_isa(func : Function, isa : ISA, embedding_abi? : EmbeddingABI?) -> (Function, Output)fn allocate_registers_backtracking_with_isa(func : Function, isa : ISA, embedding_abi? : EmbeddingABI?) -> Functionfn apply_allocation(func : Function, alloc : RegAllocResult, isa : ISA, embedding_abi : EmbeddingABI) -> Functionfn verify_allocation(func : Function, liveness : LivenessResult, alloc : RegAllocResult, isa : ISA, embedding_abi : EmbeddingABI) -> UnitTarget VCode adapter for the reusable register allocator
Dependencies