AArch64 target pipeline from semantic MachV to native code
Dependencies
///|
test "validate the AArch64 internal ABI" {
InternalAbi::new(
0,
8,
[1, 2, 3, 4, 5, 6, 7],
[0, 1, 2, 3, 4, 5, 6, 7],
[0, 1, 2, 3, 4, 5, 6, 7],
[0, 1, 2, 3, 4, 5, 6, 7],
)
|> ignore
}pub suberror AArch64AllocationError {
InvalidVCode(cause~ : TargetVCodeVerifyError)
AllocatorFailure(cause~ : VCodeAllocationError)
InvalidAllocation(cause~ : AllocationVerifyError)
IllegalRegister(reg~ : PhysicalReg)
} derive(Debug)impl Show for AArch64AllocationErrorpub suberror AArch64CompileError {
TargetValidationFailed(cause~ : TargetVCodeVerifyError)
AllocationFailed(cause~ : AArch64AllocationError)
FramePlanningFailed(cause~ : AArch64FrameError)
EmissionFailed(cause~ : AArch64EmitError)
} derive(Debug)impl Show for AArch64CompileErrorpub suberror AArch64EmitError {
InvalidFrame(cause~ : AArch64FrameError)
InvalidCodeObject(cause~ : CodeObjectVerifyError)
InvalidParallelMove(cause~ : MoveResolveError)
InvalidCallTransfer(cause~ : CallTransferError)
UnresolvedStackMove
MissingStackObjectArea
MissingResultArea
MissingEmergencyMoveArea
UnexpectedStackOperand(instruction~ : Instruction, operand~ : Int)
FrameOffsetOutOfRange(offset~ : Int)
InvalidScalarMemoryAccess
InvalidFloatInstruction
InvalidVectorInstruction
InvalidConversionInstruction
BranchTargetMissing(block~ : Block)
BranchLabelUnbound(label~ : Int)
BranchSpanNotFixed(offset~ : Int)
BranchOutOfRange(offset~ : Int, bits~ : Int)
} derive(Debug)impl Show for AArch64EmitErrorpub suberror AArch64FrameError {
InvalidAllocation(cause~ : AArch64AllocationError)
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 AArch64FrameErrorpub suberror AArch64LowerError {
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 AArch64LowerErrorpub suberror TargetVCodeVerifyError {
CommonFailure(cause~ : VCodeVerifyError)
InvalidInstruction(instruction~ : Instruction, message~ : String)
} derive(Eq, Debug)impl Show for TargetVCodeVerifyErrorpub(all) enum AArch64Address {
Code(CodeSymbol)
External(ExternalSymbol)
Data(DataSymbol)
} derive(Eq, Debug)pub(all) enum AArch64Conversion {
WrapI64ToI32
ExtendI32ToI64(Signedness)
SignExtend(IntegerType, AccessWidth)
DemoteF64ToF32
PromoteF32ToF64
Bitcast(ValueType, ValueType)
IntToFloat(IntegerType, FloatType, Signedness)
FloatToInt(FloatType, IntegerType, Signedness)
} derive(Eq, Debug)pub struct AArch64Frame {
// private fields
}pub(all) enum AArch64Inst {
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(AArch64Address)
StackAddress(AArch64StackObject)
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, AArch64VectorIntUnary)
VectorIntBinary(VectorLane, AArch64VectorIntBinary)
VectorIntShift(VectorLane, VectorIntShiftOp)
VectorIntCompare(VectorLane, VectorIntComparison)
VectorConvert(AArch64VectorConversion)
VectorPredicate(AArch64VectorPredicate)
VectorFloatUnary(VectorLane, VectorFloatUnaryOp)
VectorFloatBinary(VectorLane, VectorFloatBinaryOp)
VectorFloatTernary(VectorLane, FloatTernaryOp)
VectorFloatCompare(VectorLane, VectorFloatComparison)
VectorPairwiseAddI16x8
VectorRelaxedDot8To16
IntUnary(GprWidth, AArch64IntUnary)
IntBinary(GprWidth, AArch64IntBinary)
IntBinaryImmediate(GprWidth, AArch64IntBinary, UInt64)
IntMultiplyAdd(GprWidth)
IntShiftRegister(GprWidth, AArch64Shift)
IntShiftImmediate(GprWidth, AArch64Shift, Int)
IntAddShiftedLeft(GprWidth, Int)
PopulationCount(GprWidth)
IntHighMultiply(GprWidth, Signedness)
IntWithOverflow(GprWidth, IntOverflowOp)
IntRemainder(GprWidth, Signedness)
TrapIfZero(GprWidth)
TrapIfSignedDivOverflow(GprWidth)
CompareSet(GprWidth, AArch64Condition)
ReferenceCompareSet(ValueType, AArch64Condition)
FloatUnary(ValueType, AArch64FloatUnary)
FloatBinary(ValueType, AArch64FloatBinary)
FloatTernary(ValueType, AArch64FloatTernary)
FloatCompareSet(ValueType, AArch64FloatCondition)
TrapIfFloat(ValueType, AArch64FloatTrapCondition)
Convert(AArch64Conversion)
AddAddress
AddAddressImmediate(UInt64)
AddAddressUxtw(Int)
ScalarLoad(AccessWidth, LoadExtension, ValueType, UInt64)
ScalarLoadUxtw(AccessWidth, LoadExtension, ValueType, Int)
ScalarStore(AccessWidth, ValueType, UInt64)
ScalarStoreUxtw(AccessWidth, ValueType, Int)
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
BranchNonZero(GprWidth)
BranchCompare(GprWidth, AArch64Condition)
BranchCompareImmediate(GprWidth, AArch64Condition, UInt64)
Switch(GprWidth, Array[UInt64])
Trap(TrapReason)
Return
} derive(Eq, Debug)fn AArch64LinkPlan::link(self : AArch64LinkPlan, code_address : Int64, resolve : (RelocationTarget) -> Int64?) -> Array[Byte] raise AArch64LinkErrorfn AArch64StackObject::new(offset : Int, size : Int, alignment : Int, area_size : Int, area_alignment : Int) -> AArch64StackObjectpub(all) enum AArch64VectorConversion {
ExtendLow(VectorLane, Signedness)
ExtendHigh(VectorLane, Signedness)
Narrow(VectorLane, Signedness)
FloatToInt(VectorLane, Signedness)
IntToFloat(VectorLane, Signedness)
PromoteLowF32x4
DemoteZeroF64x2
} derive(Eq, Debug)pub(all) enum AArch64VectorIntBinary {
Add
Sub
Mul
AverageUnsigned
Min(Signedness)
Max(Signedness)
SaturatingAdd(Signedness)
SaturatingSub(Signedness)
ExtendMultiply(VectorHalf, Signedness)
Dot16To32Signed
Q15MultiplyRoundedSaturating
} derive(Eq, Debug)pub(all) enum AArch64VectorIntUnary {
Absolute
Negate
PopulationCount
ExtendAddPairwise(Signedness)
} derive(Eq, Debug)pub(all) enum AArch64VectorPredicate {
AnyTrue
AllTrue(VectorLane)
BitMask(VectorLane)
} derive(Eq, Debug)pub 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]) -> LoweringContextfn compile(function : Function[AArch64Inst], on_event? : (TargetCompileEvent) -> Unit, verify_allocation? : Bool) -> (UnlinkedCodeObject, Int) raise AArch64CompileErrorfn emit(function : Function[AArch64Inst], allocation : Allocation, frame : AArch64Frame) -> UnlinkedCodeObject raise AArch64EmitErrorfn lower(function : Function, context : LoweringContext) -> Function[AArch64Inst] raise AArch64LowerErrorfn plan_frame(function : Function[AArch64Inst], allocation : Allocation) -> AArch64Frame raise AArch64FrameErrorfn verify_allocation(function : Function[AArch64Inst], allocation : Allocation) -> Unit raise AArch64AllocationErrorfn verify_frame(function : Function[AArch64Inst], allocation : Allocation, frame : AArch64Frame) -> Unit raise AArch64FrameErrorAArch64 target pipeline from semantic MachV to native code
Dependencies