Target-independent native lowering, VCode, and code-object infrastructure
| Package | Responsibility |
|---|---|
| Milky2018/vcode/native_types | Canonical native value types, signatures, calls, symbols, operation effects, traps, safepoints, source locations, and stack-map metadata. |
| Milky2018/vcode/native_lowering | Streaming producer-to-target protocol, target-neutral operations, transient value and block handles, and call-ABI elaboration. |
| Milky2018/vcode/allocation_types | Minimal register-allocation vocabulary shared by VCode, the allocator, and their adapter: register classes, physical and virtual registers, operand roles and timing, constraints, and compact locations. |
| Milky2018/vcode | Dense target VCode, checked construction, allocation and frame side tables, staged verification, call-transfer planning, and parallel-move resolution. |
| Milky2018/vcode/code_object | Verified machine-code bytes with typed relocations, source and trap sites, safepoints and roots, and target-neutral unwind directives. |
MilkIR and dialect adapters
|
| native_lowering.Operation, one operation at a time
v
target TargetSink --> target-owned Inst in vcode.Function[Inst]
|
| verify_selected
v
regalloc + vcode allocation side tables
|
| verify_allocated
v
target frame layout
|
| verify_framed / verify_emission_input
v
target machine-code emitter
|
v
code_object.UnlinkedCodeObject
|
v
embedding-owned linker and code loader///|
#derive(Debug)
priv enum ExampleInst {
AddOne
Return
}
///|
test "construct and verify target VCode" {
let builder : @vcode.CheckedBuilder[ExampleInst] = @vcode.CheckedBuilder::new_with_results(
"add_one",
[I64],
[I64],
)
let entry = builder.entry_block()
let input = builder.parameter(0)
let (_, results) = builder.append_body(
entry,
AddOne,
[@vcode.Input::any(input)],
[@vcode.Output::any(I64)],
[],
@vcode.InstructionMetadata::empty(),
)
builder.set_terminator(
entry,
Return,
[@vcode.Input::any(results[0])],
[],
[],
@vcode.InstructionMetadata::empty(),
)
|> ignore
let function = builder.finish()
@vcode.verify_selected(function)
inspect(function.parameter_count(), content="1")
inspect(function.instruction_count(), content="2")
inspect(function.summary().contains("AddOne"), content="true")
}///|
let object = @code_object.build(@code_object.X64, [b'\xc3'])pub suberror AllocationVerifyError {
SelectedFailure(cause~ : VCodeVerifyError)
SourceMismatch
MissingValueLocation(value~ : Value)
ForeignLocation(value~ : Value)
LocationClassMismatch(value~ : Value)
MissingOperandLocation(instruction~ : Instruction, operand~ : Int)
OperandClassMismatch(instruction~ : Instruction, operand~ : Int)
RegisterConstraintViolation(instruction~ : Instruction, operand~ : Int)
FixedConstraintViolation(instruction~ : Instruction, operand~ : Int)
PreservedHomeConstraintViolation(instruction~ : Instruction, operand~ : Int)
TiedConstraintViolation(instruction~ : Instruction, operand~ : Int)
Interference(left~ : Value, right~ : Value, location~ : Location)
ClobberViolation(instruction~ : Instruction, value~ : Value)
InvalidStackSlotLayout(slot~ : StackSlot)
InvalidEdit(index~ : Int)
MissingReload(instruction~ : Instruction, operand~ : Int)
InvalidEdgeMove(index~ : Int)
MissingSafepointRoot(instruction~ : Instruction, value~ : Value)
UnexpectedSafepointRoot(instruction~ : Instruction, value~ : Value)
} derive(Eq, Debug)impl Show for AllocationVerifyErrorpub suberror CallTransferError {
InvalidSourceClass(index~ : Int)
ForeignSourceStack(index~ : Int)
InvalidSourceStackType(index~ : Int, expected~ : ValueType, actual~ : ValueType)
InvalidSourceStackLayout(index~ : Int)
InvalidDestinationClass(index~ : Int)
InvalidStackOffset(index~ : Int, offset~ : Int)
InvalidOutgoingStackRange(start~ : Int, size~ : Int)
OutgoingStackDestinationOutOfRange(index~ : Int, offset~ : Int)
DuplicateRegisterDestination(index~ : Int, register~ : PhysicalReg)
OverlappingStackDestination(first~ : Int, second~ : Int)
ProtectedLocationOverwrite(index~ : Int, location~ : Location)
MoveResolutionFailed(cause~ : MoveResolveError)
} derive(Eq, Debug)impl Show for EmissionVerifyErrorpub(all) suberror FrameStorageError {
InvalidSavedRegister(reg~ : PhysicalReg, offset~ : Int)
InvalidStackSlot(slot~ : StackSlot)
ResultAreaMismatch(expected~ : Int, actual~ : Int)
InvalidStackObjectArea(message~ : String)
InvalidEmergencyMoveArea(offset~ : Int?)
SavedRegisterSetMismatch
}pub suberror FrameVerifyError {
AllocationFailure(cause~ : AllocationVerifyError)
SourceMismatch
InvalidFrameSize(size~ : Int)
InvalidFrameAlignment(alignment~ : Int)
MissingStackSlot(slot~ : StackSlot)
MisalignedStackSlot(slot~ : StackSlot)
OverlappingStackSlots(left~ : StackSlot, right~ : StackSlot)
StackSlotOutOfFrame(slot~ : StackSlot)
} derive(Eq, Debug)pub(all) suberror TargetVCodeVerifyError {
CommonFailure(cause~ : VCodeVerifyError)
InvalidInstruction(instruction~ : Instruction, message~ : String)
} derive(Eq, Debug)impl Show for TargetVCodeVerifyErrorfn TargetVCodeVerifyError::not_equal(x : TargetVCodeVerifyError, y : TargetVCodeVerifyError) -> Boolpub suberror VCodeBuildError {
InvalidParameter(index~ : Int)
InvalidBlockParameter(block~ : Block, index~ : Int)
ForeignBlock(block~ : Block)
ForeignValue(value~ : Value)
InvalidOperandConstraint
DuplicateTerminator(block~ : Block)
BlockAlreadyTerminated(block~ : Block)
InvalidEdgeArity(block~ : Block)
EdgeClassMismatch(block~ : Block, index~ : Int)
DuplicateClobber(reg~ : PhysicalReg)
InvalidSafepointRoot(value~ : Value)
InvalidStackMap
MissingTerminator(block~ : Block)
InvalidLayout
} derive(Eq, Debug)pub suberror VCodeVerifyError {
EmptyFunction
MissingTerminator(block~ : Block)
ForeignValue(instruction~ : Instruction, value~ : Value)
ForeignBlock(instruction~ : Instruction, block~ : Block)
InvalidEdgeArity(instruction~ : Instruction, block~ : Block)
EdgeClassMismatch(instruction~ : Instruction, block~ : Block, index~ : Int)
InvalidTie(instruction~ : Instruction, operand~ : Int, tied_to~ : Int)
FixedRegisterClassMismatch(instruction~ : Instruction, operand~ : Int)
InvalidOperandPreference(instruction~ : Instruction, operand~ : Int)
DuplicateClobber(instruction~ : Instruction, reg~ : PhysicalReg)
InvalidSafepointRoot(instruction~ : Instruction, value~ : Value)
InvalidStackMap(instruction~ : Instruction)
UnreachableBlock(block~ : Block)
UseBeforeDefinition(instruction~ : Instruction, value~ : Value)
DefinitionDoesNotDominate(instruction~ : Instruction, value~ : Value)
InvalidLayout
} derive(Eq, Debug)pub(all) enum AbiMaterialization {
Ordinary
PlatformResults(Signature)
InternalResults(Signature, InternalCallPlan)
ForwardResultArea(Int, indirect~ : Bool)
ReceiveResultArea
ReceiveRegisterResult(ValueType, PhysicalReg)
ReceiveAreaResult(ValueType, Int)
ReturnRegisterResult(ValueType)
ReturnAreaResult(ValueType)
Return
}pub struct Allocation {
// private fields
}fn Allocation::add_safepoint_root(self : Allocation, instruction : Instruction, value : Value, location : Location) -> Boolfn Allocation::allocated_operand_location_at(self : Allocation, instruction : Int, operand : Int) -> AllocationLocation?fn Allocation::assign_operand(self : Allocation, instruction : Instruction, operand_index : Int, reg : PhysicalReg) -> Boolfn Allocation::assign_operand_location(self : Allocation, instruction : Instruction, operand_index : Int, location : Location) -> Boolfn Allocation::create_stack_slot(self : Allocation, ty : ValueType, size : Int, alignment : Int) -> StackSlotfn Allocation::edge_edits_at(self : Allocation, source : Block, successor_index : Int) -> ArrayView[Edit]fn Allocation::edits_at(self : Allocation, instruction : Instruction, placement : PointPlacement) -> ArrayView[Edit]fn Allocation::operand_location(self : Allocation, instruction : Instruction, operand_index : Int) -> Location?fn Allocation::safepoint_roots(self : Allocation, instruction : Instruction) -> Array[(Value, Location)]pub struct AllocationBuilder[Inst] {
// private fields
}fn[Inst] AllocationBuilder::add_edge_transfer(self : AllocationBuilder[Inst], source_block : Int, successor : Int, value : Int, from : AllocationLocation, to : AllocationLocation) -> Boolfn[Inst] AllocationBuilder::add_safepoint_root(self : AllocationBuilder[Inst], instruction : Int, value : Int) -> Boolfn[Inst] AllocationBuilder::add_transfer(self : AllocationBuilder[Inst], instruction : Int, placement : PointPlacement, value : Int, from : AllocationLocation, to : AllocationLocation) -> Boolfn[Inst] AllocationBuilder::assign_operand(self : AllocationBuilder[Inst], instruction : Int, operand : Int, location : AllocationLocation) -> Boolfn[Inst] AllocationBuilder::assign_value(self : AllocationBuilder[Inst], value : Int, location : AllocationLocation) -> Boolfn[Inst] AllocationBuilder::create_stack_slot(self : AllocationBuilder[Inst], value : Int, size : Int, alignment : Int) -> Intfn[Inst] AllocationBuilder::for_selected_function(function : Function[Inst]) -> AllocationBuilder[Inst]fn[Inst] AllocationBuilder::value_location(self : AllocationBuilder[Inst], value : Int) -> AllocationLocation?pub struct Block {
// private fields
}pub struct Builder[Inst] {
// private fields
}fn[Inst] Builder::append_body(self : Builder[Inst], block : Block, inst : Inst, inputs : Array[Input], outputs : Array[Output], clobbers : Array[PhysicalReg], metadata : InstructionMetadata) -> (Instruction, Array[Value]) raise VCodeBuildErrorfn[Inst] Builder::block_parameter(self : Builder[Inst], block : Block, index : Int) -> Value raise VCodeBuildErrorfn[Inst] Builder::set_terminator(self : Builder[Inst], block : Block, inst : Inst, inputs : Array[Input], successors : Array[Edge], clobbers : Array[PhysicalReg], metadata : InstructionMetadata) -> Instruction raise VCodeBuildErrorpub struct CallLayout {
arguments : ArrayView[CallArgumentLocation]
stack_size : Int
} derive(Eq, Debug)pub(all) enum CallResultLocation {
CallResultRegister(PhysicalReg)
CallResultArea(Int, PhysicalReg)
} derive(Eq, Debug)pub struct CallTransfer {
// private fields
}fn CallTransfer::to_register(ty : ValueType, source : Location, destination : PhysicalReg) -> CallTransferpub struct CheckedBuilder[Inst] {
// private fields
}fn[Inst] CheckedBuilder::append_body(self : CheckedBuilder[Inst], block : Block, inst : Inst, inputs : Array[Input], outputs : Array[Output], clobbers : Array[PhysicalReg], metadata : InstructionMetadata) -> (Instruction, Array[Value]) raise VCodeBuildErrorfn[Inst] CheckedBuilder::append_body_unconstrained(self : CheckedBuilder[Inst], block : Block, inst : Inst, inputs : Array[Value], output_types : Array[ValueType], clobbers : Array[PhysicalReg], metadata : InstructionMetadata) -> (Instruction, Array[Value]) raise VCodeBuildErrorfn[Inst] CheckedBuilder::append_float_to_int_checks(self : CheckedBuilder[Inst], block : Block, operand : Value, source : FloatType, result : IntegerType, signedness : Signedness, site : DirectOperationSource, float_constant : (ValueType, UInt64) -> Inst, trap_unordered : (ValueType) -> Inst, trap_minimum : (ValueType, Bool) -> Inst, trap_maximum : (ValueType) -> Inst) -> Unit raise VCodeBuildErrorfn[Inst] CheckedBuilder::block_parameter(self : CheckedBuilder[Inst], block : Block, index : Int) -> Value raise VCodeBuildErrorfn[Inst] CheckedBuilder::create_block(self : CheckedBuilder[Inst], parameter_types : Array[ValueType]) -> Blockfn[Inst] CheckedBuilder::finish(self : CheckedBuilder[Inst]) -> Function[Inst] raise VCodeBuildErrorfn[Inst] CheckedBuilder::materialize_abi_words(self : CheckedBuilder[Inst], block : Block, operands : Array[Value], types : Array[ValueType], make_move : (ValueType) -> Inst, operand_start? : Int) -> Array[Value] raise VCodeBuildErrorfn[Inst] CheckedBuilder::materialize_atomic_address(self : CheckedBuilder[Inst], block : Block, operation : Operation, operands : Array[Value], load_offset : (UInt64) -> Inst, add_address : Inst) -> Array[Value] raise VCodeBuildErrorfn[Inst] CheckedBuilder::new(name : String, parameter_types : Array[ValueType]) -> CheckedBuilder[Inst]fn[Inst] CheckedBuilder::new_with_protocol(name : String, protocol : CallProtocol, parameter_types : Array[ValueType], result_types : Array[ValueType]) -> CheckedBuilder[Inst]fn[Inst] CheckedBuilder::new_with_results(name : String, parameter_types : Array[ValueType], result_types : Array[ValueType]) -> CheckedBuilder[Inst]fn[Inst] CheckedBuilder::parameter(self : CheckedBuilder[Inst], index : Int) -> Value raise VCodeBuildErrorfn[Inst] CheckedBuilder::set_terminator(self : CheckedBuilder[Inst], block : Block, inst : Inst, inputs : Array[Input], successors : Array[Edge], clobbers : Array[PhysicalReg], metadata : InstructionMetadata) -> Instruction raise VCodeBuildErrorpub struct CodeSites {
// private fields
}fn CodeSites::build(self : CodeSites, architecture : Architecture, code : Array[Byte], relocations : Array[Relocation], unwind : Array[UnwindDirective]) -> UnlinkedCodeObject raise CodeObjectVerifyErrorfn[Inst] CodeSites::record(self : CodeSites, function : Function[Inst], allocation : Allocation, frame : FrameLayout, instruction : Instruction, metadata : InstructionAnnotations, offset : Int, end : Int) -> Unitpub struct ConditionalEdgeLayout {
first_target : Block
first_moves : ResolvedMovePlan
second_target : Block
second_moves : ResolvedMovePlan
first_when_true : Bool
direct_branch : Bool
second_falls_through : Bool
}pub struct DirectLoweringState[Inst, Failure] {
builder : CheckedBuilder[Inst]
context : LoweringContext
protocol : CallProtocol
signature : Signature
result_area : Value?
on_event : (TargetCompileEvent) -> Unit
// private fields
}fn[Inst, Failure] DirectLoweringState::alias_word_bitcast(self : DirectLoweringState[Inst, Failure], operand_ids : Array[Int], result_types : Array[ValueType], from : ValueType, to : ValueType) -> Int?fn[Inst, Failure] DirectLoweringState::block(self : DirectLoweringState[Inst, Failure], id : Int) -> Blockfn[Inst, Failure] DirectLoweringState::constructed_function(self : DirectLoweringState[Inst, Failure]) -> Function[Inst]?fn[Inst, Failure] DirectLoweringState::create_block(self : DirectLoweringState[Inst, Failure], parameter_types : Array[ValueType]) -> (Int, Array[Int])fn[Inst, Failure] DirectLoweringState::create_stack_object(self : DirectLoweringState[Inst, Failure], size : Int, alignment : Int) -> Intfn[Inst, Failure] DirectLoweringState::edge(self : DirectLoweringState[Inst, Failure], block : Block, target : Int, ids : Array[Int], make_move : (ValueType) -> Inst) -> Edge raise VCodeBuildErrorfn[Inst, Failure] DirectLoweringState::emit_tail_call(self : DirectLoweringState[Inst, Failure], block : Block, call : NativeCall, operands : Array[Value], metadata : InstructionMetadata, make_move : (ValueType) -> Inst, is_allocatable : (PhysicalReg) -> Bool, select : (InternalCallPlan) -> (Inst, Array[PhysicalReg])) -> Unit raise CallMaterializationErrorfn[Inst, Failure] DirectLoweringState::finish_construction(self : DirectLoweringState[Inst, Failure], build_failure : (VCodeBuildError) -> Failure) -> Unitfn[Inst, Failure] DirectLoweringState::first_error(self : DirectLoweringState[Inst, Failure]) -> Failure?fn[Inst, Failure] DirectLoweringState::instruction_index(self : DirectLoweringState[Inst, Failure]) -> Intfn[Inst, Failure] DirectLoweringState::instruction_operands(self : DirectLoweringState[Inst, Failure], operand_ids : Array[Int], root_ids : Array[Int]) -> (Array[Value], Array[ValueType], Array[Value])fn[Inst, Failure] DirectLoweringState::materialize_return_values(self : DirectLoweringState[Inst, Failure], block : Block, values : Array[Value], platform_result_registers : (Array[ValueType]) -> Array[PhysicalReg], outgoing_register : (ValueType, PhysicalReg) -> Inst, outgoing_area : (ValueType, Int) -> Inst) -> Unit raise CallMaterializationErrorfn[Inst, Failure] DirectLoweringState::new(builder : CheckedBuilder[Inst], context : LoweringContext, protocol : CallProtocol, signature : Signature, values : Array[Value], result_area : Value?, on_event : (TargetCompileEvent) -> Unit) -> DirectLoweringState[Inst, Failure]fn[Inst, Failure] DirectLoweringState::record_error(self : DirectLoweringState[Inst, Failure], error : Failure) -> Unitfn[Inst, Failure] DirectLoweringState::record_results(self : DirectLoweringState[Inst, Failure], results : Array[Value], result_types : Array[ValueType]) -> Array[Int]fn[Inst, Failure] DirectLoweringState::stack_object(self : DirectLoweringState[Inst, Failure], id : Int) -> (Int, Int)fn[Inst, Failure] DirectLoweringState::switch_targets(self : DirectLoweringState[Inst, Failure], block : Block, cases : Array[TargetSwitchCase], default_target : Int, default_arguments : Array[Int], make_move : (ValueType) -> Inst) -> (Array[UInt64], Array[Edge]) raise VCodeBuildErrorfn[Inst, Failure] DirectLoweringState::switch_to_block(self : DirectLoweringState[Inst, Failure], block_id : Int) -> Unitfn[Inst, Failure] DirectLoweringState::tail_call_inputs(self : DirectLoweringState[Inst, Failure], call : NativeCall, operands : Array[Value], is_allocatable : (PhysicalReg) -> Bool) -> (InternalCallPlan, Array[Input]) raise CallMaterializationErrorfn[Inst, Failure] DirectLoweringState::target_value(self : DirectLoweringState[Inst, Failure], id : Int) -> Valuefn[Inst, Failure] DirectLoweringState::target_values(self : DirectLoweringState[Inst, Failure], ids : Array[Int]) -> Array[Value]fn[Inst, Failure] DirectLoweringState::terminator_metadata(self : DirectLoweringState[Inst, Failure], source : SourceLocation?, live_gc_roots : Array[Int]) -> InstructionMetadatafn[Inst, Failure] DirectLoweringState::value_type(self : DirectLoweringState[Inst, Failure], id : Int) -> ValueTypepub struct DirectOperationSource {
// private fields
}fn DirectOperationSource::metadata(self : DirectOperationSource, trap? : TrapReason) -> InstructionMetadatafn DirectOperationSource::new(source : SourceLocation?, stack_map : StackMapMetadata?, roots : Array[Value], semantics : OperationSemantics) -> DirectOperationSourcefn DirectOperationSource::selected_metadata(self : DirectOperationSource, operation : Operation) -> InstructionMetadatafn Edit::register_move(point : ProgramPoint, value : Value, from : PhysicalReg, to : PhysicalReg) -> Editpub(all) enum EditKind {
Spill(value~ : Value, reg~ : PhysicalReg, slot~ : StackSlot)
Reload(value~ : Value, slot~ : StackSlot, reg~ : PhysicalReg)
Move(value~ : Value, from~ : PhysicalReg, to~ : PhysicalReg)
EdgeMove(source~ : Block, successor_index~ : Int, value~ : Value, from~ : Location, to~ : Location)
} derive(Eq, Debug)pub struct FrameLayout {
// private fields
}fn[Inst] FrameLayout::new(function : Function[Inst], allocation : Allocation, frame_size : Int, alignment : Int) -> FrameLayoutpub(all) struct FrameRequirements {
outgoing_args_size : Int
incoming_args_size : Int
tail_args_size : Int
result_area_size : Int
has_calls : Bool
stack_objects : StackObjectRequirements?
}pub struct FrameStorage {
// private fields
}fn FrameStorage::plan(requirements : FrameRequirements, allocation : Allocation, requires_emergency_moves : Bool, saved : Array[PhysicalReg]) -> FrameStoragefn FrameStorage::verify(self : FrameStorage, layout : FrameLayout, allocation : Allocation, requirements : FrameRequirements, expected_saved : Array[PhysicalReg]) -> Unit raise FrameStorageErrorpub(all) enum FrameUse {
Call(Int, Int)
Incoming(Int)
Tail(Int)
LocalObject(Int, Int, Int)
}pub struct Function[Inst] {
// private fields
}fn[Inst] Function::allocation_block_parameter_at(self : Function[Inst], block : Int, parameter : Int) -> VirtualRegfn[Inst] Function::allocation_edge_argument_at(self : Function[Inst], block : Int, successor : Int, argument : Int) -> VirtualRegfn[Inst] Function::allocation_instruction_clobbers(self : Function[Inst], instruction : Int) -> ArrayView[PhysicalReg]fn[Inst] Function::allocation_instruction_operands(self : Function[Inst], instruction : Int) -> ArrayView[AllocationOperand]fn[Inst] Function::block_instruction_at(self : Function[Inst], block : Block, index : Int) -> Instruction?fn[Inst] Function::instruction_annotations(self : Function[Inst], instruction : Instruction) -> InstructionAnnotations?fn[Inst] Function::instruction_clobbers(self : Function[Inst], instruction : Instruction) -> Array[PhysicalReg]fn[Inst] Function::instruction_is_terminator(self : Function[Inst], instruction : Instruction) -> Boolfn[Inst] Function::instruction_metadata(self : Function[Inst], instruction : Instruction) -> InstructionMetadata?fn[Inst] Function::instruction_operand_at(self : Function[Inst], instruction : Instruction, index : Int) -> Operand?fn[Inst] Function::instruction_operand_count(self : Function[Inst], instruction : Instruction) -> Intfn[Inst] Function::instruction_operands(self : Function[Inst], instruction : Instruction) -> Array[Operand]fn[Inst] Function::instruction_results(self : Function[Inst], instruction : Instruction) -> Array[Value]fn[Inst] Function::instruction_successor_argument_at(self : Function[Inst], instruction : Instruction, successor : Int, argument : Int) -> Value?fn[Inst] Function::instruction_successor_argument_count(self : Function[Inst], instruction : Instruction, successor : Int) -> Intfn[Inst] Function::instruction_successor_at(self : Function[Inst], instruction : Instruction, index : Int) -> Edge?fn[Inst] Function::instruction_successor_count(self : Function[Inst], instruction : Instruction) -> Intfn[Inst] Function::instruction_successor_target(self : Function[Inst], instruction : Instruction, successor : Int) -> Block?fn[Inst] Function::instruction_successors(self : Function[Inst], instruction : Instruction) -> Array[Edge]fn[Inst] Function::program_point_instruction(self : Function[Inst], point : ProgramPoint) -> Instruction?fn[Inst] Function::set_layout(self : Function[Inst], layout : Array[Block]) -> Unit raise VCodeBuildErrorpub struct Input {
value : Value
constraint : OperandConstraint
preference : PhysicalReg?
timing : OperandTiming
}pub struct Instruction {
// private fields
}pub struct InstructionAnnotations {
// private fields
}pub struct InstructionMetadata {
source : SourceLocation?
trap : TrapReason?
safepoint : SafepointKind?
live_gc_roots : Array[Value]
symbol : SymbolReference?
stack_map : StackMapMetadata?
}fn InstructionMetadata::new(source? : SourceLocation, trap? : TrapReason, safepoint? : SafepointKind, live_gc_roots? : Array[Value], symbol? : SymbolReference, stack_map? : StackMapMetadata) -> InstructionMetadatafn InternalAbi::call_layout(self : InternalAbi, signature : Signature) -> CallLayout raise InternalAbiErrorfn InternalAbi::call_plan(self : InternalAbi, signature : Signature) -> InternalCallPlan raise InternalAbiErrorfn InternalAbi::new(context_argument : Int, result_area_argument : Int, integer_arguments : Array[Int], fp_arguments : Array[Int], integer_results : Array[Int], fp_results : Array[Int]) -> InternalAbi raise InternalAbiErrorfn InternalAbi::result_layout(self : InternalAbi, result_types : Array[ValueType]) -> (ArrayView[CallResultLocation], Int)pub struct InternalCallPlan {
arguments : ArrayView[CallArgumentLocation]
results : ArrayView[CallResultLocation]
stack_size : Int
result_area_size : Int
} derive(Eq, Debug)fn LoweringContext::environment_field_offsets(self : LoweringContext, field : EnvironmentField) -> Array[Int]?fn LoweringContext::with_environment_field_resolver(self : LoweringContext, resolve : (EnvironmentField) -> Array[Int]?) -> LoweringContextpub struct Operand {
value : Value
role : OperandRole
constraint : AllocationConstraint
preference : PhysicalReg?
timing : OperandTiming
tie_id : Int
} derive(Eq, Debug)pub struct Output {
ty : ValueType
constraint : OperandConstraint
preference : PhysicalReg?
timing : OperandTiming
}pub struct ProgramPoint {
// private fields
}fn RegallocLoopStatistics::not_equal(x : RegallocLoopStatistics, y : RegallocLoopStatistics) -> Boolpub struct ResolvedCallTransferPlan {
stack_transfers : Array[StackArgumentTransfer]
register_moves : ResolvedMovePlan
} derive(Eq, Debug)fn ResolvedCallTransferPlan::not_equal(x : ResolvedCallTransferPlan, y : ResolvedCallTransferPlan) -> Boolpub struct ResolvedMovePlan {
steps : Array[ResolvedMoveStep]
requires_emergency : Bool
} derive(Eq, Debug)pub(all) enum ResolvedMoveStep {
Transfer(ParallelMove)
SpillScratchToEmergency(ty~ : ValueType, scratch~ : PhysicalReg)
ReloadScratchFromEmergency(ty~ : ValueType, scratch~ : PhysicalReg)
} derive(Eq, Debug)pub struct StackArgumentTransfer {
ty : ValueType
source : Location
offset : Int
scratch : PhysicalReg?
} derive(Eq, Debug)pub struct StackSlot {
// private fields
}pub(all) enum SymbolReference {
Code(CodeSymbol)
External(ExternalSymbol)
Data(DataSymbol)
} derive(Eq, Debug)pub(all) enum SymbolicAddress {
Code(CodeSymbol)
External(ExternalSymbol)
Data(DataSymbol)
} derive(Eq, Debug)pub(all) enum TargetCompileEvent {
TargetAnalysisStarted
TargetConstructionStarted
TargetValidationStarted
TargetCommonValidationStarted
TargetIsaValidationStarted
TargetSealingStarted
TargetSelectionFinished
RegallocStarted
RegallocPhaseStarted(String)
RegallocPhasesFinished
RegallocLoopMeasured(RegallocLoopStatistics)
RegallocFinished(AllocationStatistics)
FramePlanningStarted
FramePlanningFinished
EmissionStarted
EmissionFinished
} derive(Eq, Debug)pub struct TargetInstructionVerifier[Inst] {
// private fields
}fn[Inst] TargetInstructionVerifier::atomic_compare_exchange(self : TargetInstructionVerifier[Inst], width : AccessWidth, ty : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::atomic_early_def(self : TargetInstructionVerifier[Inst], message : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::atomic_load(self : TargetInstructionVerifier[Inst], width : AccessWidth, ty : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::atomic_rmw(self : TargetInstructionVerifier[Inst], width : AccessWidth, ty : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::atomic_store(self : TargetInstructionVerifier[Inst], width : AccessWidth, ty : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::carrier_move(self : TargetInstructionVerifier[Inst], from : ValueType, to : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::conversion(self : TargetInstructionVerifier[Inst], shape : (ValueType, ValueType)?, raw_word_bitcast : Bool, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::float_binary(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::float_compare(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::float_ternary(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::float_unary(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::incoming_call_area_result(self : TargetInstructionVerifier[Inst], ty : ValueType, offset : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::incoming_call_result(self : TargetInstructionVerifier[Inst], ty : ValueType, reg : PhysicalReg) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::incoming_reg(self : TargetInstructionVerifier[Inst], ty : ValueType, reg : PhysicalReg) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::incoming_result_area(self : TargetInstructionVerifier[Inst], reg : PhysicalReg) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::incoming_stack(self : TargetInstructionVerifier[Inst], ty : ValueType, offset : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::internal_call(self : TargetInstructionVerifier[Inst], signature : Signature, plan : InternalCallPlan, indirect~ : Bool, is_allocatable : (PhysicalReg) -> Bool, clobbers : (InternalCallPlan) -> Array[PhysicalReg]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::load_constant(self : TargetInstructionVerifier[Inst], ty : ValueType, bits : UInt64) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::load_float_constant(self : TargetInstructionVerifier[Inst], ty : ValueType, bits : UInt64) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::load_null(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::new(function : Function[Inst], instruction : Instruction) -> TargetInstructionVerifier[Inst]fn[Inst] TargetInstructionVerifier::outgoing_area_result(self : TargetInstructionVerifier[Inst], ty : ValueType, offset : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::outgoing_reg(self : TargetInstructionVerifier[Inst], ty : ValueType, reg : PhysicalReg) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::platform_call(self : TargetInstructionVerifier[Inst], signature : Signature, layout : (Array[ValueType]) -> CallLayout, is_allocatable : (PhysicalReg) -> Bool, clobbers : () -> Array[PhysicalReg]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::reference_compare(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::return_shape(self : TargetInstructionVerifier[Inst]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::safepoint_marker(self : TargetInstructionVerifier[Inst]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::scalar_load(self : TargetInstructionVerifier[Inst], width : AccessWidth, extension : LoadExtension, result_type : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::scalar_select(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::scalar_store(self : TargetInstructionVerifier[Inst], width : AccessWidth, value_type : ValueType, target~ : String) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::shape(self : TargetInstructionVerifier[Inst], uses : Array[ValueType], defs : Array[ValueType], successors? : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::stack_address(self : TargetInstructionVerifier[Inst], valid : Bool) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::store_repeated64(self : TargetInstructionVerifier[Inst], offset : UInt64, count : UInt) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::switch_shape(self : TargetInstructionVerifier[Inst], ty : ValueType, cases : Array[UInt64]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::trap(self : TargetInstructionVerifier[Inst], reason : TrapReason) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::trap_if_float(self : TargetInstructionVerifier[Inst], ty : ValueType, unordered : Bool) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::trap_if_signed_div_overflow(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::trap_if_zero(self : TargetInstructionVerifier[Inst], ty : ValueType) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_bitwise(self : TargetInstructionVerifier[Inst], operation : VectorBitwiseOp) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_conversion(self : TargetInstructionVerifier[Inst], conversion : VectorConversion) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_extract_lane(self : TargetInstructionVerifier[Inst], lane : VectorLane, index : Int, has_extension : Bool) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_float_binary(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_float_ternary(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_float_unary(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_int_binary(self : TargetInstructionVerifier[Inst], lane : VectorLane, operation : VectorIntBinaryOp) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_int_compare(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_int_shift(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_int_unary(self : TargetInstructionVerifier[Inst], lane : VectorLane, operation : VectorIntUnaryOp) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_load_extend(self : TargetInstructionVerifier[Inst], lane : VectorLane) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_load_lane(self : TargetInstructionVerifier[Inst], lane : VectorLane, index : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_load_zero(self : TargetInstructionVerifier[Inst], width : AccessWidth) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_predicate(self : TargetInstructionVerifier[Inst], predicate : VectorPredicateOp) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_replace_lane(self : TargetInstructionVerifier[Inst], lane : VectorLane, index : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_shuffle(self : TargetInstructionVerifier[Inst], mask : FixedArray[Int]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] TargetInstructionVerifier::vector_store_lane(self : TargetInstructionVerifier[Inst], lane : VectorLane, index : Int) -> Unit raise TargetVCodeVerifyErrorpub struct Value {
// private fields
}pub(all) enum VectorConversion {
ExtendLow(VectorLane, Signedness)
ExtendHigh(VectorLane, Signedness)
Narrow(VectorLane, Signedness)
FloatToInt(VectorLane, Signedness)
IntToFloat(VectorLane, Signedness)
PromoteLowF32x4
DemoteZeroF64x2
} derive(Eq, Debug)fn[Inst] allocation_edge_moves(function : Function[Inst], allocation : Allocation, block : Block, successor_index : Int) -> Array[ParallelMove]fn[Inst] allocation_edit_moves(function : Function[Inst], allocation : Allocation, instruction : Instruction, placement : PointPlacement) -> Array[ParallelMove]fn call_argument_inputs(operands : Array[Value], locations : ArrayView[CallArgumentLocation], is_allocatable : (PhysicalReg) -> Bool) -> Array[Input]fn call_argument_transfers(allocation : Allocation, instruction : Instruction, types : Array[ValueType], locations : ArrayView[CallArgumentLocation], operand_start? : Int, stack_base? : Int, callee? : (Int, PhysicalReg), result_area? : (Int, PhysicalReg)) -> Array[CallTransfer]fn[Inst] collect_frame_requirements(function : Function[Inst], frame_use : (Inst) -> FrameUse?) -> Result[FrameRequirements, String]fn direct_source_metadata(source : SourceLocation?, stack_map : StackMapMetadata?, values : Array[Value], semantics : OperationSemantics, trap? : TrapReason) -> InstructionMetadatafn[Buffer, Frame, E : Error] emit_call_stack_transfers(plan : ResolvedCallTransferPlan, buffer : Buffer, frame : Frame, slot_offset : (Frame, StackSlot) -> Int?, access_stack : (Buffer, Bool, ValueType, PhysicalReg, Int) -> Unit raise E) -> Unit raise Efn[Inst, Buffer, Frame, E : Error] emit_incoming_values(function : Function[Inst], allocation : Allocation, body : ArrayView[Instruction], current_index : Int, describe : (Inst) -> (ValueType, CallArgumentLocation, Int)?, buffer : Buffer, frame : Frame, stack_base : Int?, slot_offset : (Frame, StackSlot) -> Int?, stack_scratch : (ValueType) -> PhysicalReg, int_scratch : PhysicalReg, fp_scratch : PhysicalReg, emit_moves : (Buffer, Frame, ResolvedMovePlan) -> Unit raise E, access_stack : (Buffer, Bool, ValueType, PhysicalReg, Int) -> Unit raise E, invalid_moves : (MoveResolveError) -> E, missing_stack_area : E) -> Unit raise Efn[Buffer, Frame, E : Error] emit_resolved_moves(plan : ResolvedMovePlan, buffer : Buffer, frame : Frame, slot_offset : (Frame, StackSlot) -> Int?, emergency_offset : (Frame) -> Int?, move_register : (Buffer, ValueType, PhysicalReg, PhysicalReg) -> Unit, access_stack : (Buffer, Bool, ValueType, PhysicalReg, Int) -> Unit raise E, unresolved_stack_move : E, missing_emergency_area : E) -> Unit raise Efn[Inst] materialize_call_results(builder : CheckedBuilder[Inst], block : Block, result_types : Array[ValueType], locations : ArrayView[CallResultLocation], live_gc_roots : Array[Value], incoming_register : (ValueType, PhysicalReg) -> Inst, incoming_area : (ValueType, Int) -> Inst, keepalive : Inst, is_allocatable : (PhysicalReg) -> Bool) -> Array[Value] raise VCodeBuildErrorfn[Inst] materialize_entry_arguments(builder : CheckedBuilder[Inst], types : Array[ValueType], arguments : ArrayView[CallArgumentLocation], result_area_register : PhysicalReg?, incoming_register : (ValueType, PhysicalReg) -> Inst, incoming_stack : (ValueType, Int) -> Inst, incoming_result_area : (PhysicalReg) -> Inst, is_allocatable : (PhysicalReg) -> Bool) -> (Array[Value], Value?) raise VCodeBuildErrorfn[Inst : Eq] plan_conditional_edges(function : Function[Inst], allocation : Allocation, block : Block, instruction : Instruction, next_block : Block?, jump : Inst, integer_scratch : PhysicalReg, fp_scratch : PhysicalReg, split_false_first~ : Bool) -> ConditionalEdgeLayout raise MoveResolveErrorfn plan_parallel_moves(moves : Array[ParallelMove], scratch_int : PhysicalReg, scratch_fp : PhysicalReg) -> ResolvedMovePlan raise MoveResolveErrorfn plan_resolved_call_transfers(allocation : Allocation, transfers : Array[CallTransfer], outgoing_stack_start : Int, outgoing_stack_size : Int, stack_scratch_int : Array[PhysicalReg], stack_scratch_fp : Array[PhysicalReg], move_scratch_int : PhysicalReg, move_scratch_fp : PhysicalReg, protected_locations : Array[Location]) -> ResolvedCallTransferPlan raise CallTransferErrorfn platform_result_registers(types : Array[ValueType], integer_registers? : ArrayView[Int]) -> Array[PhysicalReg]fn[Inst] require_call_argument_inputs(function : Function[Inst], instruction : Instruction, operand_start : Int, locations : ArrayView[CallArgumentLocation], is_allocatable : (PhysicalReg) -> Bool) -> Unit raise TargetVCodeVerifyErrorfn[Inst] require_fixed_use(function : Function[Inst], instruction : Instruction, operand_index : Int, expected : PhysicalReg) -> Unit raise TargetVCodeVerifyErrorfn[Inst] require_home_def(function : Function[Inst], instruction : Instruction, operand_index : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] require_instruction_shape(function : Function[Inst], instruction : Instruction, use_types : Array[ValueType], def_types : Array[ValueType], terminator : Bool, successor_count : Int) -> Unit raise TargetVCodeVerifyErrorfn[Inst] require_tail_call_plan(function : Function[Inst], instruction : Instruction, signature : Signature, plan : InternalCallPlan, indirect : Bool, is_allocatable : (PhysicalReg) -> Bool, expected_clobbers : Array[PhysicalReg]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] requires_emergency_move_area(function : Function[Inst], allocation : Allocation, is_abi_materialization : (Inst) -> Bool, int_scratch : PhysicalReg, fp_scratch : PhysicalReg) -> Bool raise MoveResolveErrorfn[Inst] resolve_edge_moves(function : Function[Inst], allocation : Allocation, block : Block, successor_index : Int, integer_scratch : PhysicalReg, fp_scratch : PhysicalReg) -> ResolvedMovePlan raise MoveResolveErrorfn[Inst : Eq] threaded_branch_target(function : Function[Inst], allocation : Allocation, target : Block, jump : Inst, integer_scratch : PhysicalReg, fp_scratch : PhysicalReg) -> Block raise MoveResolveErrorfn[Inst] used_callee_saved_registers(function : Function[Inst], allocation : Allocation, is_callee_saved : (PhysicalReg) -> Bool, link_register? : PhysicalReg?) -> Array[PhysicalReg]fn[Inst] verify_abi_materialization(function : Function[Inst], classify : (Inst) -> AbiMaterialization, platform_results : (Array[ValueType]) -> Array[PhysicalReg]) -> Unit raise TargetVCodeVerifyErrorfn[Inst] verify_allocated(function : Function[Inst], allocation : Allocation) -> Unit raise AllocationVerifyErrorfn[Inst] verify_allocation_invariants(function : Function[Inst], allocation : Allocation) -> Unit raise AllocationVerifyErrorfn[Inst] verify_emission_input(function : Function[Inst], allocation : Allocation, frame : FrameLayout) -> Unit raise EmissionVerifyErrorfn[Inst] verify_framed(function : Function[Inst], allocation : Allocation, frame : FrameLayout) -> Unit raise FrameVerifyErrorInstall
Download zipTarget-independent native lowering, VCode, and code-object infrastructure