module Platform.AArch64.CardInfo import Compiler.MachineAArch64 import Compiler.MachineAArch64Assembly import Platform.Linux.Nvidia.DeviceBinding -- AAPCS64 twin of nvidiaCardInfoGPUIdCode: x0 destination/result, x1 rows, -- x2 count, x3 minor; x4 match flag, x5 selected GPU ID, x6 scratch. The -- destination is written only after the complete inventory is unambiguous. def aarch64CardInfoAssembly = (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X2) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64Equal) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X2) nvidiaCardInfoMaximumRows) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64UnsignedHigher) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X3) nvidiaCardMinorMaximum) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64UnsignedHigher) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X4) 0 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyLabel b"row" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64LoadMemory8ZeroExtend (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X1) nvidiaCardInfoValidOffset) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X6) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64Equal) b"next" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X6) 1) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64NotEqual) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64LoadMemory32ZeroExtend (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X1) nvidiaCardInfoMinorOffset) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareRegister (constructor AArch64Register AArch64X6) (constructor AArch64Register AArch64X3)) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64NotEqual) b"next" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X4) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64NotEqual) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64AddImmediate (constructor AArch64Register AArch64X4) (constructor AArch64Register AArch64X4) 1) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64LoadMemory32ZeroExtend (constructor AArch64Register AArch64X5) (constructor AArch64Register AArch64X1) nvidiaCardInfoGPUIdOffset) (constructor AArch64Assembly AArch64AssemblyLabel b"next" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64AddImmediate (constructor AArch64Register AArch64X1) (constructor AArch64Register AArch64X1) nvidiaCardInfoRowBytes) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64SubtractImmediate (constructor AArch64Register AArch64X2) (constructor AArch64Register AArch64X2) 1) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X2) 0) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64NotEqual) b"row" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64CompareImmediate (constructor AArch64Register AArch64X4) 1) (constructor AArch64Assembly AArch64AssemblyBranchIf (constructor AArch64Condition AArch64NotEqual) b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64StoreMemory32 (constructor AArch64Register AArch64X0) 0 (constructor AArch64Register AArch64X5)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 0 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64Return) (constructor AArch64Assembly AArch64AssemblyLabel b"invalid" (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64MoveWideZero (constructor AArch64Register AArch64X0) 1 (constructor AArch64HalfwordShift AArch64Shift0)) (constructor AArch64Assembly AArch64AssemblyEmit (constructor AArch64Instruction AArch64Return) (constructor AArch64Assembly AArch64AssemblyEnd)))))))))))))))))))))))))))))))))) def aarch64CardInfoCode : Bytes = (eliminate AArch64AssemblyResult (lambda unrestricted value : (family AArch64AssemblyResult) . Bytes) (aarch64Assemble aarch64CardInfoAssembly) (branch AArch64AssemblyEncoded code . code) (branch AArch64AssemblyEncodeDuplicateLabel name . b"") (branch AArch64AssemblyMissingLabel name . b"") (branch AArch64AssemblyDisplacementOutOfRange name . b"") (branch AArch64AssemblyOperandRefused value . b""))