WebAssemblyRegisterInfo.td 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //WebAssemblyRegisterInfo.td-Describe the WebAssembly Registers -*- 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. /// \file
  10. /// This file describes the WebAssembly register classes and some nominal
  11. /// physical registers.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. class WebAssemblyReg<string n> : Register<n> {
  15. let Namespace = "WebAssembly";
  16. }
  17. class WebAssemblyRegClass<list<ValueType> regTypes, int alignment, dag regList>
  18. : RegisterClass<"WebAssembly", regTypes, alignment, regList>;
  19. //===----------------------------------------------------------------------===//
  20. // Registers
  21. //===----------------------------------------------------------------------===//
  22. // Special registers used as the frame and stack pointer.
  23. //
  24. // WebAssembly may someday supports mixed 32-bit and 64-bit heaps in the same
  25. // application, which requires separate width FP and SP.
  26. def FP32 : WebAssemblyReg<"%FP32">;
  27. def FP64 : WebAssemblyReg<"%FP64">;
  28. def SP32 : WebAssemblyReg<"%SP32">;
  29. def SP64 : WebAssemblyReg<"%SP64">;
  30. // The register allocation framework requires register classes have at least
  31. // one register, so we define a few for the integer / floating point register
  32. // classes since we otherwise don't need a physical register in those classes.
  33. // These are also used a "types" in the generated assembly matcher.
  34. def I32_0 : WebAssemblyReg<"%i32.0">;
  35. def I64_0 : WebAssemblyReg<"%i64.0">;
  36. def F32_0 : WebAssemblyReg<"%f32.0">;
  37. def F64_0 : WebAssemblyReg<"%f64.0">;
  38. def V128_0: WebAssemblyReg<"%v128">;
  39. def FUNCREF_0 : WebAssemblyReg<"%funcref.0">;
  40. def EXTERNREF_0 : WebAssemblyReg<"%externref.0">;
  41. // The value stack "register". This is an opaque entity which serves to order
  42. // uses and defs that must remain in LIFO order.
  43. def VALUE_STACK : WebAssemblyReg<"STACK">;
  44. // The incoming arguments "register". This is an opaque entity which serves to
  45. // order the ARGUMENT instructions that are emulating live-in registers and
  46. // must not be scheduled below other instructions.
  47. def ARGUMENTS : WebAssemblyReg<"ARGUMENTS">;
  48. //===----------------------------------------------------------------------===//
  49. // Register classes
  50. //===----------------------------------------------------------------------===//
  51. def I32 : WebAssemblyRegClass<[i32], 32, (add FP32, SP32, I32_0)>;
  52. def I64 : WebAssemblyRegClass<[i64], 64, (add FP64, SP64, I64_0)>;
  53. def F32 : WebAssemblyRegClass<[f32], 32, (add F32_0)>;
  54. def F64 : WebAssemblyRegClass<[f64], 64, (add F64_0)>;
  55. def V128 : WebAssemblyRegClass<[v4f32, v2f64, v2i64, v4i32, v16i8, v8i16], 128,
  56. (add V128_0)>;
  57. def FUNCREF : WebAssemblyRegClass<[funcref], 0, (add FUNCREF_0)>;
  58. def EXTERNREF : WebAssemblyRegClass<[externref], 0, (add EXTERNREF_0)>;