module Platform.AArch64.CyclicRecordOffset import Compiler.MachineAArch64 import Compiler.MachineAArch64Assembly import Runtime.CyclicRecordOffset -- AAPCS64 twin: x0..x5 are the six arguments of the shared contract. -- x6 and x7 are temporaries; interpreter and callee-saved registers survive. -- No division is reached with a zero divisor. Rejection leaves output intact. def aarch64CyclicRecordOffsetAssembly : (family AArch64Assembly) = (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X3) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64Equal) b"reject" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X4) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64Equal) b"reject" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareRegister (constructor AArch64Register AArch64X5) (constructor AArch64Register AArch64X4)) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64CarryClear) b"inside" (constructor AArch64Assembly AArch64AssemblyBranch b"reject" (constructor AArch64Assembly AArch64AssemblyLabel b"inside" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64AddRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X1) (constructor AArch64Register AArch64X2)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X1)) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64CarryClear) b"reject" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X7) 65535 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideKeep (constructor AArch64Register AArch64X7) 65535 (constructor AArch64HalfwordShift AArch64Shift16)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideKeep (constructor AArch64Register AArch64X7) 65535 (constructor AArch64HalfwordShift AArch64Shift32)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideKeep (constructor AArch64Register AArch64X7) 32767 (constructor AArch64HalfwordShift AArch64Shift48)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64DivideRegisterUnsigned (constructor AArch64Register AArch64X7) (constructor AArch64Register AArch64X7) (constructor AArch64Register AArch64X4)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareRegister (constructor AArch64Register AArch64X3) (constructor AArch64Register AArch64X7)) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64UnsignedHigher) b"reject" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64DivideRegisterUnsigned (constructor AArch64Register AArch64X7) (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X3)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MultiplyRegister (constructor AArch64Register AArch64X7) (constructor AArch64Register AArch64X7) (constructor AArch64Register AArch64X3)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64SubtractRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X7)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MultiplyRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X4)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64AddRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X5)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64StoreMemory64 (constructor AArch64Register AArch64X0) 0 (constructor AArch64Register AArch64X6)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 0 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64Return ) (constructor AArch64Assembly AArch64AssemblyLabel b"reject" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 1 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64Return ) (constructor AArch64Assembly AArch64AssemblyEnd)))))))))))))))))))))))))))))) def aarch64CyclicRecordOffsetRoutine : Bytes = (eliminate AArch64AssemblyResult (lambda unrestricted current : (family AArch64AssemblyResult) . Bytes) (aarch64Assemble aarch64CyclicRecordOffsetAssembly) (branch AArch64AssemblyEncoded code . code) (branch AArch64AssemblyEncodeDuplicateLabel name . b"") (branch AArch64AssemblyMissingLabel name . b"") (branch AArch64AssemblyDisplacementOutOfRange name . b"") (branch AArch64AssemblyOperandRefused value . b""))