x64 direct MilkIR target pipeline to native code
///|
test "validate the x64 internal ABI" {
@x64_target.InternalAbi::new(
7,
10,
[6, 2, 1, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7],
[0, 2],
[0, 1],
)
|> ignore
}pub suberror X64AllocationError {
InvalidVCode(cause~ : TargetVCodeVerifyError)
AllocatorFailure(cause~ : VCodeAllocationError)
InvalidAllocation(cause~ : AllocationVerifyError)
IllegalRegister(reg~ : PhysicalReg)
} derive(Debug)pub suberror X64CompileError {
TargetValidationFailed(cause~ : TargetVCodeVerifyError)
AllocationFailed(cause~ : X64AllocationError)
FramePlanningFailed(cause~ : X64FrameError)
EmissionFailed(cause~ : X64EmitError)
} derive(Debug)pub suberror X64EmitError {
InvalidFrame(cause~ : X64FrameError)
InvalidCodeObject(cause~ : CodeObjectVerifyError)
InvalidParallelMove(cause~ : MoveResolveError)
InvalidCallTransfer(cause~ : CallTransferError)
UnresolvedStackMove
MissingStackObjectArea
MissingResultArea
MissingEmergencyMoveArea
UnexpectedStackOperand(instruction~ : Instruction, operand~ : Int)
FrameOffsetOutOfRange(offset~ : Int)
InvalidScalarMemoryAccess
InvalidFloatInstruction
InvalidVectorInstruction
ScratchRegisterUnavailable
InvalidConversionInstruction
BranchTargetMissing(block~ : Block)
BranchOutOfRange(offset~ : Int, bits~ : Int)
} derive(Debug)impl Show for X64EmitErrorpub suberror X64FrameError {
InvalidAllocation(cause~ : X64AllocationError)
InvalidGenericFrame(cause~ : FrameVerifyError)
InvalidSavedRegister(reg~ : PhysicalReg, offset~ : Int)
InvalidStackSlot(slot~ : StackSlot)
OutgoingAreaMismatch(expected~ : Int, actual~ : Int)
ResultAreaMismatch(expected~ : Int, actual~ : Int)
TailAreaMismatch(expected_incoming~ : Int, actual_incoming~ : Int, expected_tail~ : Int, actual_tail~ : Int)
InvalidStackObjectArea(message~ : String)
MovePlanningFailed(cause~ : MoveResolveError)
CallPlanningFailed(cause~ : CallTransferError)
InvalidEmergencyMoveArea(offset~ : Int?)
StaleAllocation(expected_edits~ : Int, actual_edits~ : Int)
SavedRegisterSetMismatch
} derive(Debug)impl Show for X64FrameErrorpub suberror X64LowerError {
UnsupportedOperation(block_index~ : Int, instruction_index~ : Int, operation~ : Operation)
UnsupportedAbi(message~ : String)
BuildFailure(cause~ : VCodeBuildError)
InvalidTarget(cause~ : TargetVCodeVerifyError)
} derive(Debug)impl Show for X64LowerErrorpub(all) struct CompilationDiagnostics {
target_vcode : String
allocated_vcode : String
object : UnlinkedCodeObject
}pub struct CompilationSession {
// private fields
}fn CompilationSession::compile_selected(self : CompilationSession, selected : SelectedFunction, on_event? : (TargetCompileEvent) -> Unit, verify_allocation? : Bool, on_diagnostics? : (String, String) -> Unit?) -> (UnlinkedCodeObject, Int) raise X64CompileErrorpub struct DirectLoweringSession {
// private fields
}fn DirectLoweringSession::finish_selected(self : DirectLoweringSession, verify_selected? : Bool) -> SelectedFunction raise X64LowerErrorfn DirectLoweringSession::new(name : String, protocol : CallProtocol, parameter_types : Array[ValueType], result_types : Array[ValueType], context : LoweringContext, on_event? : (TargetCompileEvent) -> Unit) -> DirectLoweringSession raise X64LowerErrorpub struct SelectedFunction {
// private fields
}pub(all) enum X64Conversion {
WrapI64ToI32
ExtendI32ToI64(Signedness)
SignExtend(IntegerType, AccessWidth)
DemoteF64ToF32
PromoteF32ToF64
Bitcast(ValueType, ValueType)
IntToFloat(IntegerType, FloatType, Signedness)
FloatToInt(FloatType, IntegerType, Signedness)
FloatToIntSaturating(FloatType, IntegerType, Signedness)
} derive(Eq, Debug)pub struct X64Frame {
// private fields
}pub(all) enum X64Inst {
IncomingReg(ValueType, PhysicalReg)
IncomingStack(ValueType, Int)
IncomingResultArea(PhysicalReg)
IncomingCallResult(ValueType, PhysicalReg)
IncomingCallAreaResult(ValueType, Int)
OutgoingReg(ValueType, PhysicalReg)
OutgoingAreaResult(ValueType, Int)
KeepAlive(ValueType)
LoadConstant(RegisterWidth, UInt64)
LoadVectorConstant(UInt64, UInt64)
LoadNull(ValueType)
LoadAddress(SymbolicAddress)
StackAddress(SizedStackObject)
LoadFloatConstant(ValueType, UInt64)
Move(ValueType)
CarrierMove(ValueType, ValueType)
Select(ValueType)
SpectreGuard
VectorSelect
VectorSplat(VectorLane)
VectorExtractLane(VectorLane, Int, Signedness?)
VectorReplaceLane(VectorLane, Int)
VectorShuffle(FixedArray[Int])
VectorSwizzle
VectorBitwise(VectorBitwiseOp)
VectorIntUnary(VectorLane, VectorIntUnaryOp)
VectorIntBinary(VectorLane, VectorIntBinaryOp)
VectorIntShift(VectorLane, VectorIntShiftOp)
VectorIntCompare(VectorLane, VectorIntComparison)
VectorConvert(VectorConversion)
VectorPredicate(VectorPredicateOp)
VectorFloatUnary(VectorLane, VectorFloatUnaryOp)
VectorFloatBinary(VectorLane, VectorFloatBinaryOp)
VectorFloatTernary(VectorLane, FloatTernaryOp)
VectorFloatCompare(VectorLane, VectorFloatComparison)
VectorPairwiseAddI16x8
VectorRelaxedDot8To16
IntUnary(RegisterWidth, ScalarIntUnary)
IntBinary(RegisterWidth, X64IntBinary)
PopulationCount(RegisterWidth)
IntHighMultiply(RegisterWidth, Signedness)
IntWithOverflow(RegisterWidth, IntOverflowOp)
IntRemainder(RegisterWidth, Signedness)
TrapIfZero(RegisterWidth)
TrapIfSignedDivOverflow(RegisterWidth)
CompareSet(RegisterWidth, IntegerCondition)
ReferenceCompareSet(ValueType, IntegerCondition)
FloatUnary(ValueType, FloatUnaryOp)
FloatBinary(ValueType, FloatBinaryOp)
FloatTernary(ValueType, FloatTernaryOp)
FloatCompareSet(ValueType, FloatComparison)
TrapIfFloat(ValueType, FloatTrapCondition)
Convert(X64Conversion)
AddAddress
ScalarLoad(AccessWidth, LoadExtension, ValueType, UInt64)
ScalarStore(AccessWidth, ValueType, UInt64)
StoreRepeated64(UInt64, UInt, UInt64)
VectorLoad128(UInt64)
VectorStore128(UInt64)
VectorLoadSplat(VectorLane, UInt64)
VectorLoadExtend(VectorLane, Signedness, UInt64)
VectorLoadZero(AccessWidth, UInt64)
VectorLoadLane(VectorLane, Int, UInt64)
VectorStoreLane(VectorLane, Int, UInt64)
AtomicLoad(AccessWidth, ValueType)
AtomicStore(AccessWidth, ValueType)
AtomicRmw(AccessWidth, ValueType, AtomicRmwOp)
AtomicCompareExchange(AccessWidth, ValueType)
AtomicFence
SafepointMarker
PlatformCall(ExternalSymbol, Signature)
ReturnsTwicePlatformCall(ExternalSymbol, Signature)
InternalCall(CodeSymbol, Signature, InternalCallPlan)
InternalCallIndirect(Signature, InternalCallPlan)
TailCallDirect(CodeSymbol, Signature, InternalCallPlan)
TailCallIndirect(Signature, InternalCallPlan)
Jump
BranchNonZero32
BranchCompare(RegisterWidth, IntegerCondition)
Switch(RegisterWidth, Array[UInt64])
Trap(TrapReason)
Return
} derive(Eq, Debug)fn X64LinkPlan::link(self : X64LinkPlan, code_address : Int64, resolve : (RelocationTarget) -> Int64?) -> Array[Byte] raise X64LinkErrorfn compile(function : Function[X64Inst], on_event? : (TargetCompileEvent) -> Unit, verify_allocation? : Bool) -> (UnlinkedCodeObject, Int) raise X64CompileErrorfn compile_selected(selected : SelectedFunction, on_event? : (TargetCompileEvent) -> Unit, verify_allocation? : Bool) -> (UnlinkedCodeObject, Int) raise X64CompileErrorfn emit(function : Function[X64Inst], allocation : Allocation, frame : X64Frame) -> UnlinkedCodeObject raise X64EmitErrorfn plan_frame(function : Function[X64Inst], allocation : Allocation) -> X64Frame raise X64FrameErrorfn verify_allocation(function : Function[X64Inst], allocation : Allocation) -> Unit raise X64AllocationErrorfn verify_frame(function : Function[X64Inst], allocation : Allocation, frame : X64Frame) -> Unit raise X64FrameError