LoongArch.td 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //===-- LoongArch.td - Describe the LoongArch Target -------*- 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. include "llvm/Target/Target.td"
  9. //===----------------------------------------------------------------------===//
  10. // LoongArch subtarget features and instruction predicates.
  11. //===----------------------------------------------------------------------===//
  12. // LoongArch is divided into two versions, the 32-bit version (LA32) and the
  13. // 64-bit version (LA64).
  14. def Feature64Bit
  15. : SubtargetFeature<"64bit", "HasLA64", "true",
  16. "LA64 Basic Integer and Privilege Instruction Set">;
  17. def Feature32Bit
  18. : SubtargetFeature<"32bit", "HasLA32", "true",
  19. "LA32 Basic Integer and Privilege Instruction Set">;
  20. def IsLA64
  21. : Predicate<"Subtarget->is64Bit()">,
  22. AssemblerPredicate<(all_of Feature64Bit),
  23. "LA64 Basic Integer and Privilege Instruction Set">;
  24. def IsLA32
  25. : Predicate<"!Subtarget->is64Bit()">,
  26. AssemblerPredicate<(all_of(not Feature64Bit)),
  27. "LA32 Basic Integer and Privilege Instruction Set">;
  28. defvar LA32 = DefaultMode;
  29. def LA64 : HwMode<"+64bit">;
  30. // Single Precision floating point
  31. def FeatureBasicF
  32. : SubtargetFeature<"f", "HasBasicF", "true",
  33. "'F' (Single-Precision Floating-Point)">;
  34. def HasBasicF
  35. : Predicate<"Subtarget->hasBasicF()">,
  36. AssemblerPredicate<(all_of FeatureBasicF),
  37. "'F' (Single-Precision Floating-Point)">;
  38. // Double Precision floating point
  39. def FeatureBasicD
  40. : SubtargetFeature<"d", "HasBasicD", "true",
  41. "'D' (Double-Precision Floating-Point)",
  42. [FeatureBasicF]>;
  43. def HasBasicD
  44. : Predicate<"Subtarget->hasBasicD()">,
  45. AssemblerPredicate<(all_of FeatureBasicD),
  46. "'D' (Double-Precision Floating-Point)">;
  47. // Loongson SIMD eXtension (LSX)
  48. def FeatureExtLSX
  49. : SubtargetFeature<"lsx", "HasExtLSX", "true",
  50. "'LSX' (Loongson SIMD Extension)", [FeatureBasicD]>;
  51. def HasExtLSX
  52. : Predicate<"Subtarget->hasExtLSX()">,
  53. AssemblerPredicate<(all_of FeatureExtLSX),
  54. "'LSX' (Loongson SIMD Extension)">;
  55. // Loongson Advanced SIMD eXtension (LASX)
  56. def FeatureExtLASX
  57. : SubtargetFeature<"lasx", "HasExtLASX", "true",
  58. "'LASX' (Loongson Advanced SIMD Extension)",
  59. [FeatureExtLSX]>;
  60. def HasExtLASX
  61. : Predicate<"Subtarget->hasExtLASX()">,
  62. AssemblerPredicate<(all_of FeatureExtLASX),
  63. "'LASX' (Loongson Advanced SIMD Extension)">;
  64. // Loongson VirtualiZation (LVZ)
  65. def FeatureExtLVZ
  66. : SubtargetFeature<"lvz", "HasExtLVZ", "true",
  67. "'LVZ' (Loongson Virtualization Extension)">;
  68. def HasExtLVZ
  69. : Predicate<"Subtarget->hasExtLVZ()">,
  70. AssemblerPredicate<(all_of FeatureExtLVZ),
  71. "'LVZ' (Loongson Virtualization Extension)">;
  72. // Loongson Binary Translation (LBT)
  73. def FeatureExtLBT
  74. : SubtargetFeature<"lbt", "HasExtLBT", "true",
  75. "'LBT' (Loongson Binary Translation Extension)">;
  76. def HasExtLBT
  77. : Predicate<"Subtarget->hasExtLBT()">,
  78. AssemblerPredicate<(all_of FeatureExtLBT),
  79. "'LBT' (Loongson Binary Translation Extension)">;
  80. // Expand la.global as la.pcrel
  81. def LaGlobalWithPcrel
  82. : SubtargetFeature<"la-global-with-pcrel", "HasLaGlobalWithPcrel", "true",
  83. "Expand la.global as la.pcrel">;
  84. def HasLaGlobalWithPcrel
  85. : Predicate<"Subtarget->hasLaGlobalWithPcrel()">,
  86. AssemblerPredicate<(all_of LaGlobalWithPcrel),
  87. "Expand la.global as la.pcrel">;
  88. // Expand la.global as la.abs
  89. def LaGlobalWithAbs
  90. : SubtargetFeature<"la-global-with-abs", "HasLaGlobalWithAbs", "true",
  91. "Expand la.global as la.abs">;
  92. def HasLaGlobalWithAbs
  93. : Predicate<"Subtarget->hasLaGlobalWithAbs()">,
  94. AssemblerPredicate<(all_of LaGlobalWithAbs),
  95. "Expand la.global as la.abs">;
  96. // Expand la.local as la.abs
  97. def LaLocalWithAbs
  98. : SubtargetFeature<"la-local-with-abs", "HasLaLocalWithAbs", "true",
  99. "Expand la.local as la.abs">;
  100. def HasLaLocalWithAbs
  101. : Predicate<"Subtarget->hasLaLocalWithAbs()">,
  102. AssemblerPredicate<(all_of LaLocalWithAbs),
  103. "Expand la.local as la.abs">;
  104. //===----------------------------------------------------------------------===//
  105. // Registers, instruction descriptions ...
  106. //===----------------------------------------------------------------------===//
  107. include "LoongArchRegisterInfo.td"
  108. include "LoongArchCallingConv.td"
  109. include "LoongArchInstrInfo.td"
  110. //===----------------------------------------------------------------------===//
  111. // LoongArch processors supported.
  112. //===----------------------------------------------------------------------===//
  113. def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
  114. def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit]>;
  115. // Support generic for compatibility with other targets. The triple will be used
  116. // to change to the appropriate la32/la64 version.
  117. def : ProcessorModel<"generic", NoSchedModel, []>;
  118. def : ProcessorModel<"la464", NoSchedModel, [Feature64Bit,
  119. FeatureExtLASX,
  120. FeatureExtLVZ,
  121. FeatureExtLBT]>;
  122. //===----------------------------------------------------------------------===//
  123. // Define the LoongArch target.
  124. //===----------------------------------------------------------------------===//
  125. def LoongArchInstrInfo : InstrInfo {
  126. // guess mayLoad, mayStore, and hasSideEffects
  127. // This option is a temporary migration help. It will go away.
  128. let guessInstructionProperties = 1;
  129. }
  130. def LoongArchAsmParser : AsmParser {
  131. let ShouldEmitMatchRegisterAltName = 1;
  132. let AllowDuplicateRegisterNames = 1;
  133. }
  134. def LoongArchAsmParserVariant : AsmParserVariant {
  135. int Variant = 0;
  136. // Recognize hard coded registers.
  137. string RegisterPrefix = "$";
  138. }
  139. def LoongArchAsmWriter : AsmWriter {
  140. int PassSubtarget = 1;
  141. }
  142. def LoongArch : Target {
  143. let InstructionSet = LoongArchInstrInfo;
  144. let AssemblyParsers = [LoongArchAsmParser];
  145. let AssemblyParserVariants = [LoongArchAsmParserVariant];
  146. let AssemblyWriters = [LoongArchAsmWriter];
  147. let AllowRegisterRenaming = 1;
  148. }