module Platform.AArch64.Descriptor import Compiler.MachineAArch64 import Compiler.MachineAArch64Assembly -- AAPCS64 twin of Runtime.NativeDescriptor: x0 input/result, x6 scratch. -- The sign check preserves kernel errno before the unsigned INT_MAX bound. -- No callee-saved or interpreter registers are touched. def aarch64DescriptorAssembly = (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X0) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64Minus) b"return" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X6) 65535 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideKeep (constructor AArch64Register AArch64X6) 32767 (constructor AArch64HalfwordShift AArch64Shift16)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareRegister (constructor AArch64Register AArch64X0) (constructor AArch64Register AArch64X6)) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64UnsignedHigher) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 0 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyBranch b"return" (constructor AArch64Assembly AArch64AssemblyLabel b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 0 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X6) 22 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64SubtractRegister (constructor AArch64Register AArch64X0) (constructor AArch64Register AArch64X0) (constructor AArch64Register AArch64X6)) (constructor AArch64Assembly AArch64AssemblyLabel b"return" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64Return) (constructor AArch64Assembly AArch64AssemblyEnd))))))))))))))) def aarch64DescriptorCode : Bytes = (eliminate AArch64AssemblyResult (lambda unrestricted current : (family AArch64AssemblyResult) . Bytes) (aarch64Assemble aarch64DescriptorAssembly) (branch AArch64AssemblyEncoded code . code) (branch AArch64AssemblyEncodeDuplicateLabel name . b"") (branch AArch64AssemblyMissingLabel name . b"") (branch AArch64AssemblyDisplacementOutOfRange name . b"") (branch AArch64AssemblyOperandRefused value . b""))