x64 target pipeline from semantic MachV to native code
Dependencies
///|
test "validate the x64 internal ABI" {
InternalAbi::new(7, 10, [6, 2, 1, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2], [
0, 1,
])
|> ignore
}pub suberror TargetVCodeVerifyError {
CommonFailure(cause~ : VCodeVerifyError)
InvalidInstruction(instruction~ : Instruction, message~ : String)
} derive(Eq, Debug)impl Show for TargetVCodeVerifyErrorpub suberror X64AllocationError {
InvalidVCode(cause~ : TargetVCodeVerifyError)
AllocatorFailure(cause~ : VCodeAllocationError)
InvalidAllocation(cause~ : AllocationVerifyError)
IllegalRegister(reg~ : PhysicalReg)
} derive(Debug)impl Show for X64AllocationErrorpub suberror X64CompileError {
TargetValidationFailed(cause~ : TargetVCodeVerifyError)
AllocationFailed(cause~ : X64AllocationError)
FramePlanningFailed(cause~ : X64FrameError)
EmissionFailed(cause~ : X64EmitError)
} derive(Debug)impl Show for X64CompileErrorpub 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)
InvalidEmergencyMoveArea(offset~ : Int?)
SavedRegisterSetMismatch
} derive(Debug)impl Show for X64FrameErrorpub suberror X64LowerError {
InvalidSemantic(cause~ : MachVVerifyError)
MissingMappedValue(value_index~ : Int)
UnsupportedOperation(block_index~ : Int, instruction_index~ : Int, operation~ : Operation)
UnsupportedAbi(message~ : String)
BuildFailure(cause~ : VCodeBuildError)
InvalidTarget(cause~ : TargetVCodeVerifyError)
} derive(Debug)impl Show for X64LowerErrorpub struct InternalAbi {
// private fields
}fn 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 InternalAbiErrorpub struct LoweringContext {
// private fields
}fn LoweringContext::with_environment_field(self : LoweringContext, field : EnvironmentField, offsets : Array[Int]) -> LoweringContextpub(all) enum X64Address {
Code(CodeSymbol)
External(ExternalSymbol)
Data(DataSymbol)
} derive(Eq, Debug)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(GprWidth, UInt64)
LoadVectorConstant(UInt64, UInt64)
LoadNull(ValueType)
LoadAddress(X64Address)
StackAddress(X64StackObject)
LoadFloatConstant(ValueType, UInt64)
Move(ValueType)
CarrierMove(ValueType, ValueType)
Select(ValueType)
VectorSelect
VectorSplat(VectorLane)
VectorExtractLane(VectorLane, Int, Signedness?)
VectorReplaceLane(VectorLane, Int)
VectorShuffle(FixedArray[Int])
VectorSwizzle
VectorBitwise(VectorBitwiseOp)
VectorIntUnary(VectorLane, X64VectorIntUnary)
VectorIntBinary(VectorLane, X64VectorIntBinary)
VectorIntShift(VectorLane, VectorIntShiftOp)
VectorIntCompare(VectorLane, VectorIntComparison)
VectorConvert(X64VectorConversion)
VectorPredicate(X64VectorPredicate)
VectorFloatUnary(VectorLane, VectorFloatUnaryOp)
VectorFloatBinary(VectorLane, VectorFloatBinaryOp)
VectorFloatTernary(VectorLane, FloatTernaryOp)
VectorFloatCompare(VectorLane, VectorFloatComparison)
VectorPairwiseAddI16x8
VectorRelaxedDot8To16
IntUnary(GprWidth, X64IntUnary)
IntBinary(GprWidth, X64IntBinary)
PopulationCount(GprWidth)
IntHighMultiply(GprWidth, Signedness)
IntWithOverflow(GprWidth, IntOverflowOp)
IntRemainder(GprWidth, Signedness)
TrapIfZero(GprWidth)
TrapIfSignedDivOverflow(GprWidth)
CompareSet(GprWidth, X64Condition)
ReferenceCompareSet(ValueType, X64Condition)
FloatUnary(ValueType, X64FloatUnary)
FloatBinary(ValueType, X64FloatBinary)
FloatTernary(ValueType, X64FloatTernary)
FloatCompareSet(ValueType, X64FloatCondition)
TrapIfFloat(ValueType, X64FloatTrapCondition)
Convert(X64Conversion)
AddAddress
ScalarLoad(AccessWidth, LoadExtension, ValueType, UInt64)
ScalarStore(AccessWidth, ValueType, 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
Switch(GprWidth, Array[UInt64])
Trap(TrapReason)
Return
} derive(Eq, Debug)fn X64LinkPlan::link(self : X64LinkPlan, code_address : Int64, resolve : (RelocationTarget) -> Int64?) -> Array[Byte] raise X64LinkErrorfn X64StackObject::new(offset : Int, size : Int, alignment : Int, area_size : Int, area_alignment : Int) -> X64StackObjectpub(all) enum X64VectorConversion {
ExtendLow(VectorLane, Signedness)
ExtendHigh(VectorLane, Signedness)
Narrow(VectorLane, Signedness)
FloatToInt(VectorLane, Signedness)
IntToFloat(VectorLane, Signedness)
PromoteLowF32x4
DemoteZeroF64x2
} derive(Eq, Debug)pub(all) enum X64VectorIntBinary {
Add
Sub
Mul
AverageUnsigned
Min(Signedness)
Max(Signedness)
SaturatingAdd(Signedness)
SaturatingSub(Signedness)
ExtendMultiply(VectorHalf, Signedness)
Dot16To32Signed
Q15MultiplyRoundedSaturating
} derive(Eq, Debug)pub(all) enum X64VectorIntUnary {
Absolute
Negate
PopulationCount
ExtendAddPairwise(Signedness)
} derive(Eq, Debug)pub(all) enum X64VectorPredicate {
AnyTrue
AllTrue(VectorLane)
BitMask(VectorLane)
} derive(Eq, Debug)fn compile(function : Function[X64Inst], 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 X64FrameErrorx64 target pipeline from semantic MachV to native code
Dependencies