NVPTXRegisterInfo.td 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //===-- NVPTXRegisterInfo.td - NVPTX Register defs ---------*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //===----------------------------------------------------------------------===//
  9. // Declarations that describe the PTX register file
  10. //===----------------------------------------------------------------------===//
  11. class NVPTXReg<string n> : Register<n> {
  12. let Namespace = "NVPTX";
  13. }
  14. class NVPTXRegClass<list<ValueType> regTypes, int alignment, dag regList>
  15. : RegisterClass <"NVPTX", regTypes, alignment, regList>;
  16. //===----------------------------------------------------------------------===//
  17. // Registers
  18. //===----------------------------------------------------------------------===//
  19. // Special Registers used as stack pointer
  20. def VRFrame32 : NVPTXReg<"%SP">;
  21. def VRFrame64 : NVPTXReg<"%SP">;
  22. def VRFrameLocal32 : NVPTXReg<"%SPL">;
  23. def VRFrameLocal64 : NVPTXReg<"%SPL">;
  24. // Special Registers used as the stack
  25. def VRDepot : NVPTXReg<"%Depot">;
  26. // We use virtual registers, but define a few physical registers here to keep
  27. // SDAG and the MachineInstr layers happy.
  28. foreach i = 0...4 in {
  29. def P#i : NVPTXReg<"%p"#i>; // Predicate
  30. def RS#i : NVPTXReg<"%rs"#i>; // 16-bit
  31. def R#i : NVPTXReg<"%r"#i>; // 32-bit
  32. def RL#i : NVPTXReg<"%rd"#i>; // 64-bit
  33. def H#i : NVPTXReg<"%h"#i>; // 16-bit float
  34. def HH#i : NVPTXReg<"%hh"#i>; // 2x16-bit float
  35. def F#i : NVPTXReg<"%f"#i>; // 32-bit float
  36. def FL#i : NVPTXReg<"%fd"#i>; // 64-bit float
  37. // Arguments
  38. def ia#i : NVPTXReg<"%ia"#i>;
  39. def la#i : NVPTXReg<"%la"#i>;
  40. def fa#i : NVPTXReg<"%fa"#i>;
  41. def da#i : NVPTXReg<"%da"#i>;
  42. }
  43. foreach i = 0...31 in {
  44. def ENVREG#i : NVPTXReg<"%envreg"#i>;
  45. }
  46. //===----------------------------------------------------------------------===//
  47. // Register classes
  48. //===----------------------------------------------------------------------===//
  49. def Int1Regs : NVPTXRegClass<[i1], 8, (add (sequence "P%u", 0, 4))>;
  50. def Int16Regs : NVPTXRegClass<[i16], 16, (add (sequence "RS%u", 0, 4))>;
  51. def Int32Regs : NVPTXRegClass<[i32], 32, (add (sequence "R%u", 0, 4), VRFrame32, VRFrameLocal32)>;
  52. def Int64Regs : NVPTXRegClass<[i64], 64, (add (sequence "RL%u", 0, 4), VRFrame64, VRFrameLocal64)>;
  53. def Float16Regs : NVPTXRegClass<[f16,bf16], 16, (add (sequence "H%u", 0, 4))>;
  54. def Float16x2Regs : NVPTXRegClass<[v2f16,v2bf16], 32, (add (sequence "HH%u", 0, 4))>;
  55. def Float32Regs : NVPTXRegClass<[f32], 32, (add (sequence "F%u", 0, 4))>;
  56. def Float64Regs : NVPTXRegClass<[f64], 64, (add (sequence "FL%u", 0, 4))>;
  57. def Int32ArgRegs : NVPTXRegClass<[i32], 32, (add (sequence "ia%u", 0, 4))>;
  58. def Int64ArgRegs : NVPTXRegClass<[i64], 64, (add (sequence "la%u", 0, 4))>;
  59. def Float32ArgRegs : NVPTXRegClass<[f32], 32, (add (sequence "fa%u", 0, 4))>;
  60. def Float64ArgRegs : NVPTXRegClass<[f64], 64, (add (sequence "da%u", 0, 4))>;
  61. // Read NVPTXRegisterInfo.cpp to see how VRFrame and VRDepot are used.
  62. def SpecialRegs : NVPTXRegClass<[i32], 32, (add VRFrame32, VRFrameLocal32, VRDepot,
  63. (sequence "ENVREG%u", 0, 31))>;