PPC.td 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. //===-- PPC.td - Describe the PowerPC Target Machine -------*- 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. // This is the top level entry point for the PowerPC target.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // Get the target-independent interfaces which we are implementing.
  13. //
  14. include "llvm/Target/Target.td"
  15. //===----------------------------------------------------------------------===//
  16. // PowerPC Subtarget features.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. // CPU Directives //
  20. //===----------------------------------------------------------------------===//
  21. def Directive440 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_440", "">;
  22. def Directive601 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_601", "">;
  23. def Directive602 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_602", "">;
  24. def Directive603 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_603", "">;
  25. def Directive604 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_603", "">;
  26. def Directive620 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_603", "">;
  27. def Directive7400: SubtargetFeature<"", "CPUDirective", "PPC::DIR_7400", "">;
  28. def Directive750 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_750", "">;
  29. def Directive970 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_970", "">;
  30. def Directive32 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_32", "">;
  31. def Directive64 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_64", "">;
  32. def DirectiveA2 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_A2", "">;
  33. def DirectiveE500 : SubtargetFeature<"", "CPUDirective",
  34. "PPC::DIR_E500", "">;
  35. def DirectiveE500mc : SubtargetFeature<"", "CPUDirective",
  36. "PPC::DIR_E500mc", "">;
  37. def DirectiveE5500 : SubtargetFeature<"", "CPUDirective",
  38. "PPC::DIR_E5500", "">;
  39. def DirectivePwr3: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR3", "">;
  40. def DirectivePwr4: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR4", "">;
  41. def DirectivePwr5: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR5", "">;
  42. def DirectivePwr5x
  43. : SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR5X", "">;
  44. def DirectivePwr6: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR6", "">;
  45. def DirectivePwr6x
  46. : SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR6X", "">;
  47. def DirectivePwr7: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR7", "">;
  48. def DirectivePwr8: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR8", "">;
  49. def DirectivePwr9: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR9", "">;
  50. def DirectivePwr10: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR10", "">;
  51. def DirectivePwrFuture
  52. : SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR_FUTURE", "">;
  53. // Specifies that the selected CPU supports 64-bit instructions, regardless of
  54. // whether we are in 32-bit or 64-bit mode.
  55. def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true",
  56. "Enable 64-bit instructions">;
  57. def AIXOS: SubtargetFeature<"aix", "IsAIX", "true", "AIX OS">;
  58. def FeatureModernAIXAs
  59. : SubtargetFeature<"modern-aix-as", "HasModernAIXAs", "true",
  60. "AIX system assembler is modern enough to support new mnes">;
  61. def FeatureHardFloat : SubtargetFeature<"hard-float", "HasHardFloat", "true",
  62. "Enable floating-point instructions">;
  63. // Specifies that we are in 64-bit mode or that we should use 64-bit registers
  64. // in 32-bit mode when possible. Requires Feature64Bit to be enabled.
  65. def Feature64BitRegs : SubtargetFeature<"64bitregs","Use64BitRegs", "true",
  66. "Enable 64-bit registers usage for ppc32 [beta]">;
  67. // Specify if we should store and manipulate i1 values in the individual
  68. // condition register bits.
  69. def FeatureCRBits : SubtargetFeature<"crbits", "UseCRBits", "true",
  70. "Use condition-register bits individually">;
  71. def FeatureFPU : SubtargetFeature<"fpu","HasFPU","true",
  72. "Enable classic FPU instructions",
  73. [FeatureHardFloat]>;
  74. def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true",
  75. "Enable Altivec instructions",
  76. [FeatureFPU]>;
  77. def FeatureSPE : SubtargetFeature<"spe","HasSPE", "true",
  78. "Enable SPE instructions",
  79. [FeatureHardFloat]>;
  80. def FeatureEFPU2 : SubtargetFeature<"efpu2", "HasEFPU2", "true",
  81. "Enable Embedded Floating-Point APU 2 instructions",
  82. [FeatureSPE]>;
  83. def FeatureMFOCRF : SubtargetFeature<"mfocrf","HasMFOCRF", "true",
  84. "Enable the MFOCRF instruction">;
  85. def FeatureFSqrt : SubtargetFeature<"fsqrt","HasFSQRT", "true",
  86. "Enable the fsqrt instruction",
  87. [FeatureFPU]>;
  88. def FeatureFCPSGN : SubtargetFeature<"fcpsgn", "HasFCPSGN", "true",
  89. "Enable the fcpsgn instruction",
  90. [FeatureFPU]>;
  91. def FeatureFRE : SubtargetFeature<"fre", "HasFRE", "true",
  92. "Enable the fre instruction",
  93. [FeatureFPU]>;
  94. def FeatureFRES : SubtargetFeature<"fres", "HasFRES", "true",
  95. "Enable the fres instruction",
  96. [FeatureFPU]>;
  97. def FeatureFRSQRTE : SubtargetFeature<"frsqrte", "HasFRSQRTE", "true",
  98. "Enable the frsqrte instruction",
  99. [FeatureFPU]>;
  100. def FeatureFRSQRTES : SubtargetFeature<"frsqrtes", "HasFRSQRTES", "true",
  101. "Enable the frsqrtes instruction",
  102. [FeatureFPU]>;
  103. def FeatureRecipPrec : SubtargetFeature<"recipprec", "HasRecipPrec", "true",
  104. "Assume higher precision reciprocal estimates">;
  105. def FeatureSTFIWX : SubtargetFeature<"stfiwx","HasSTFIWX", "true",
  106. "Enable the stfiwx instruction",
  107. [FeatureFPU]>;
  108. def FeatureLFIWAX : SubtargetFeature<"lfiwax","HasLFIWAX", "true",
  109. "Enable the lfiwax instruction",
  110. [FeatureFPU]>;
  111. def FeatureFPRND : SubtargetFeature<"fprnd", "HasFPRND", "true",
  112. "Enable the fri[mnpz] instructions",
  113. [FeatureFPU]>;
  114. def FeatureFPCVT : SubtargetFeature<"fpcvt", "HasFPCVT", "true",
  115. "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions",
  116. [FeatureFPU]>;
  117. def FeatureISEL : SubtargetFeature<"isel","HasISEL", "true",
  118. "Enable the isel instruction">;
  119. def FeatureBPERMD : SubtargetFeature<"bpermd", "HasBPERMD", "true",
  120. "Enable the bpermd instruction">;
  121. def FeatureExtDiv : SubtargetFeature<"extdiv", "HasExtDiv", "true",
  122. "Enable extended divide instructions">;
  123. def FeatureLDBRX : SubtargetFeature<"ldbrx","HasLDBRX", "true",
  124. "Enable the ldbrx instruction">;
  125. def FeatureCMPB : SubtargetFeature<"cmpb", "HasCMPB", "true",
  126. "Enable the cmpb instruction">;
  127. def FeatureICBT : SubtargetFeature<"icbt","HasICBT", "true",
  128. "Enable icbt instruction">;
  129. def FeatureBookE : SubtargetFeature<"booke", "IsBookE", "true",
  130. "Enable Book E instructions",
  131. [FeatureICBT]>;
  132. def FeatureMSYNC : SubtargetFeature<"msync", "HasOnlyMSYNC", "true",
  133. "Has only the msync instruction instead of sync",
  134. [FeatureBookE]>;
  135. def FeatureE500 : SubtargetFeature<"e500", "IsE500", "true",
  136. "Enable E500/E500mc instructions">;
  137. def FeatureSecurePlt : SubtargetFeature<"secure-plt","IsSecurePlt", "true",
  138. "Enable secure plt mode">;
  139. def FeaturePPC4xx : SubtargetFeature<"ppc4xx", "IsPPC4xx", "true",
  140. "Enable PPC 4xx instructions">;
  141. def FeaturePPC6xx : SubtargetFeature<"ppc6xx", "IsPPC6xx", "true",
  142. "Enable PPC 6xx instructions">;
  143. def FeatureVSX : SubtargetFeature<"vsx","HasVSX", "true",
  144. "Enable VSX instructions",
  145. [FeatureAltivec]>;
  146. def FeatureTwoConstNR :
  147. SubtargetFeature<"two-const-nr", "NeedsTwoConstNR", "true",
  148. "Requires two constant Newton-Raphson computation">;
  149. def FeatureP8Altivec : SubtargetFeature<"power8-altivec", "HasP8Altivec", "true",
  150. "Enable POWER8 Altivec instructions",
  151. [FeatureAltivec]>;
  152. def FeatureP8Crypto : SubtargetFeature<"crypto", "HasP8Crypto", "true",
  153. "Enable POWER8 Crypto instructions",
  154. [FeatureP8Altivec]>;
  155. def FeatureP8Vector : SubtargetFeature<"power8-vector", "HasP8Vector", "true",
  156. "Enable POWER8 vector instructions",
  157. [FeatureVSX, FeatureP8Altivec]>;
  158. def FeatureDirectMove :
  159. SubtargetFeature<"direct-move", "HasDirectMove", "true",
  160. "Enable Power8 direct move instructions",
  161. [FeatureVSX]>;
  162. def FeaturePartwordAtomic : SubtargetFeature<"partword-atomics",
  163. "HasPartwordAtomics", "true",
  164. "Enable l[bh]arx and st[bh]cx.">;
  165. def FeatureQuadwordAtomic : SubtargetFeature<"quadword-atomics",
  166. "HasQuadwordAtomics", "true",
  167. "Enable lqarx and stqcx.">;
  168. def FeatureInvariantFunctionDescriptors :
  169. SubtargetFeature<"invariant-function-descriptors",
  170. "HasInvariantFunctionDescriptors", "true",
  171. "Assume function descriptors are invariant">;
  172. def FeatureLongCall : SubtargetFeature<"longcall", "UseLongCalls", "true",
  173. "Always use indirect calls">;
  174. def FeatureHTM : SubtargetFeature<"htm", "HasHTM", "true",
  175. "Enable Hardware Transactional Memory instructions">;
  176. def FeatureMFTB : SubtargetFeature<"", "IsFeatureMFTB", "true",
  177. "Implement mftb using the mfspr instruction">;
  178. def FeatureFusion : SubtargetFeature<"fusion", "HasFusion", "true",
  179. "Target supports instruction fusion">;
  180. def FeatureAddiLoadFusion : SubtargetFeature<"fuse-addi-load",
  181. "HasAddiLoadFusion", "true",
  182. "Power8 Addi-Load fusion",
  183. [FeatureFusion]>;
  184. def FeatureAddisLoadFusion : SubtargetFeature<"fuse-addis-load",
  185. "HasAddisLoadFusion", "true",
  186. "Power8 Addis-Load fusion",
  187. [FeatureFusion]>;
  188. def FeatureStoreFusion : SubtargetFeature<"fuse-store", "HasStoreFusion", "true",
  189. "Target supports store clustering",
  190. [FeatureFusion]>;
  191. def FeatureArithAddFusion :
  192. SubtargetFeature<"fuse-arith-add", "HasArithAddFusion", "true",
  193. "Target supports Arithmetic Operations with Add fusion",
  194. [FeatureFusion]>;
  195. def FeatureAddLogicalFusion :
  196. SubtargetFeature<"fuse-add-logical", "HasAddLogicalFusion", "true",
  197. "Target supports Add with Logical Operations fusion",
  198. [FeatureFusion]>;
  199. def FeatureLogicalAddFusion :
  200. SubtargetFeature<"fuse-logical-add", "HasLogicalAddFusion", "true",
  201. "Target supports Logical with Add Operations fusion",
  202. [FeatureFusion]>;
  203. def FeatureLogicalFusion :
  204. SubtargetFeature<"fuse-logical", "HasLogicalFusion", "true",
  205. "Target supports Logical Operations fusion",
  206. [FeatureFusion]>;
  207. def FeatureSha3Fusion :
  208. SubtargetFeature<"fuse-sha3", "HasSha3Fusion", "true",
  209. "Target supports SHA3 assist fusion",
  210. [FeatureFusion]>;
  211. def FeatureCompareFusion:
  212. SubtargetFeature<"fuse-cmp", "HasCompareFusion", "true",
  213. "Target supports Comparison Operations fusion",
  214. [FeatureFusion]>;
  215. def FeatureWideImmFusion:
  216. SubtargetFeature<"fuse-wideimm", "HasWideImmFusion", "true",
  217. "Target supports Wide-Immediate fusion",
  218. [FeatureFusion]>;
  219. def FeatureZeroMoveFusion:
  220. SubtargetFeature<"fuse-zeromove", "HasZeroMoveFusion", "true",
  221. "Target supports move to SPR with branch fusion",
  222. [FeatureFusion]>;
  223. def FeatureBack2BackFusion:
  224. SubtargetFeature<"fuse-back2back", "HasBack2BackFusion", "true",
  225. "Target supports general back to back fusion",
  226. [FeatureFusion]>;
  227. def FeatureUnalignedFloats :
  228. SubtargetFeature<"allow-unaligned-fp-access", "AllowsUnalignedFPAccess",
  229. "true", "CPU does not trap on unaligned FP access">;
  230. def FeaturePPCPreRASched:
  231. SubtargetFeature<"ppc-prera-sched", "UsePPCPreRASchedStrategy", "true",
  232. "Use PowerPC pre-RA scheduling strategy">;
  233. def FeaturePPCPostRASched:
  234. SubtargetFeature<"ppc-postra-sched", "UsePPCPostRASchedStrategy", "true",
  235. "Use PowerPC post-RA scheduling strategy">;
  236. def FeatureFloat128 :
  237. SubtargetFeature<"float128", "HasFloat128", "true",
  238. "Enable the __float128 data type for IEEE-754R Binary128.",
  239. [FeatureVSX]>;
  240. def FeaturePOPCNTD : SubtargetFeature<"popcntd","HasPOPCNTD",
  241. "POPCNTD_Fast",
  242. "Enable the popcnt[dw] instructions">;
  243. // Note that for the a2 processor models we should not use popcnt[dw] by
  244. // default. These processors do support the instructions, but they're
  245. // microcoded, and the software emulation is about twice as fast.
  246. def FeatureSlowPOPCNTD : SubtargetFeature<"slow-popcntd","HasPOPCNTD",
  247. "POPCNTD_Slow",
  248. "Has slow popcnt[dw] instructions">;
  249. def DeprecatedDST : SubtargetFeature<"", "IsDeprecatedDST", "true",
  250. "Treat vector data stream cache control instructions as deprecated">;
  251. def FeatureISA2_06 : SubtargetFeature<"isa-v206-instructions", "IsISA2_06",
  252. "true",
  253. "Enable instructions in ISA 2.06.">;
  254. def FeatureISA2_07 : SubtargetFeature<"isa-v207-instructions", "IsISA2_07",
  255. "true",
  256. "Enable instructions in ISA 2.07.">;
  257. def FeatureISA3_0 : SubtargetFeature<"isa-v30-instructions", "IsISA3_0",
  258. "true",
  259. "Enable instructions in ISA 3.0.",
  260. [FeatureISA2_07]>;
  261. def FeatureISA3_1 : SubtargetFeature<"isa-v31-instructions", "IsISA3_1",
  262. "true",
  263. "Enable instructions in ISA 3.1.",
  264. [FeatureISA3_0]>;
  265. def FeatureISAFuture : SubtargetFeature<"isa-future-instructions",
  266. "IsISAFuture", "true",
  267. "Enable instructions for Future ISA.",
  268. [FeatureISA3_1]>;
  269. def FeatureP9Altivec : SubtargetFeature<"power9-altivec", "HasP9Altivec", "true",
  270. "Enable POWER9 Altivec instructions",
  271. [FeatureISA3_0, FeatureP8Altivec]>;
  272. def FeatureP9Vector : SubtargetFeature<"power9-vector", "HasP9Vector", "true",
  273. "Enable POWER9 vector instructions",
  274. [FeatureISA3_0, FeatureP8Vector,
  275. FeatureP9Altivec]>;
  276. def FeatureP10Vector : SubtargetFeature<"power10-vector", "HasP10Vector",
  277. "true",
  278. "Enable POWER10 vector instructions",
  279. [FeatureISA3_1, FeatureP9Vector]>;
  280. // A separate feature for this even though it is equivalent to P9Vector
  281. // because this is a feature of the implementation rather than the architecture
  282. // and may go away with future CPU's.
  283. def FeatureVectorsUseTwoUnits : SubtargetFeature<"vectors-use-two-units",
  284. "VectorsUseTwoUnits",
  285. "true",
  286. "Vectors use two units">;
  287. def FeaturePrefixInstrs : SubtargetFeature<"prefix-instrs", "HasPrefixInstrs",
  288. "true",
  289. "Enable prefixed instructions",
  290. [FeatureISA3_0, FeatureP8Vector,
  291. FeatureP9Altivec]>;
  292. def FeaturePCRelativeMemops :
  293. SubtargetFeature<"pcrelative-memops", "HasPCRelativeMemops", "true",
  294. "Enable PC relative Memory Ops",
  295. [FeatureISA3_0, FeaturePrefixInstrs]>;
  296. def FeaturePairedVectorMemops:
  297. SubtargetFeature<"paired-vector-memops", "PairedVectorMemops", "true",
  298. "32Byte load and store instructions",
  299. [FeatureISA3_0]>;
  300. def FeatureMMA : SubtargetFeature<"mma", "HasMMA", "true",
  301. "Enable MMA instructions",
  302. [FeatureP8Vector, FeatureP9Altivec,
  303. FeaturePairedVectorMemops]>;
  304. def FeatureROPProtect :
  305. SubtargetFeature<"rop-protect", "HasROPProtect", "true",
  306. "Add ROP protect">;
  307. def FeaturePrivileged :
  308. SubtargetFeature<"privileged", "HasPrivileged", "true",
  309. "Add privileged instructions">;
  310. def FeaturePredictableSelectIsExpensive :
  311. SubtargetFeature<"predictable-select-expensive",
  312. "PredictableSelectIsExpensive",
  313. "true",
  314. "Prefer likely predicted branches over selects">;
  315. def FeatureFastMFLR : SubtargetFeature<"fast-MFLR", "HasFastMFLR", "true",
  316. "MFLR is a fast instruction">;
  317. // Since new processors generally contain a superset of features of those that
  318. // came before them, the idea is to make implementations of new processors
  319. // less error prone and easier to read.
  320. // Namely:
  321. // list<SubtargetFeature> P8InheritableFeatures = ...
  322. // list<SubtargetFeature> FutureProcessorAddtionalFeatures =
  323. // [ features that Power8 does not support but inheritable ]
  324. // list<SubtargetFeature> FutureProcessorSpecificFeatures =
  325. // [ features that Power8 does not support and not inheritable ]
  326. // list<SubtargetFeature> FutureProcessorInheritableFeatures =
  327. // !listconcat(P8InheritableFeatures, FutureProcessorAddtionalFeatures)
  328. // list<SubtargetFeature> FutureProcessorFeatures =
  329. // !listconcat(FutureProcessorInheritableFeatures,
  330. // FutureProcessorSpecificFeatures)
  331. // Makes it explicit and obvious what is new in FutureProcessor vs. Power8 as
  332. // well as providing a single point of definition if the feature set will be
  333. // used elsewhere.
  334. def ProcessorFeatures {
  335. // Power7
  336. list<SubtargetFeature> P7InheritableFeatures = [DirectivePwr7,
  337. FeatureAltivec,
  338. FeatureVSX,
  339. FeatureMFOCRF,
  340. FeatureFCPSGN,
  341. FeatureFSqrt,
  342. FeatureFRE,
  343. FeatureFRES,
  344. FeatureFRSQRTE,
  345. FeatureFRSQRTES,
  346. FeatureRecipPrec,
  347. FeatureSTFIWX,
  348. FeatureLFIWAX,
  349. FeatureFPRND,
  350. FeatureFPCVT,
  351. FeatureISEL,
  352. FeaturePOPCNTD,
  353. FeatureCMPB,
  354. FeatureLDBRX,
  355. Feature64Bit,
  356. /* Feature64BitRegs, */
  357. FeatureBPERMD,
  358. FeatureExtDiv,
  359. FeatureMFTB,
  360. DeprecatedDST,
  361. FeatureTwoConstNR,
  362. FeatureUnalignedFloats,
  363. FeatureISA2_06];
  364. list<SubtargetFeature> P7SpecificFeatures = [];
  365. list<SubtargetFeature> P7Features =
  366. !listconcat(P7InheritableFeatures, P7SpecificFeatures);
  367. // Power8
  368. list<SubtargetFeature> P8AdditionalFeatures =
  369. [DirectivePwr8,
  370. FeatureP8Altivec,
  371. FeatureP8Vector,
  372. FeatureP8Crypto,
  373. FeatureHTM,
  374. FeatureDirectMove,
  375. FeatureICBT,
  376. FeaturePartwordAtomic,
  377. FeatureQuadwordAtomic,
  378. FeaturePredictableSelectIsExpensive,
  379. FeatureISA2_07,
  380. FeatureCRBits
  381. ];
  382. list<SubtargetFeature> P8SpecificFeatures = [FeatureAddiLoadFusion,
  383. FeatureAddisLoadFusion];
  384. list<SubtargetFeature> P8InheritableFeatures =
  385. !listconcat(P7InheritableFeatures, P8AdditionalFeatures);
  386. list<SubtargetFeature> P8Features =
  387. !listconcat(P8InheritableFeatures, P8SpecificFeatures);
  388. // Power9
  389. list<SubtargetFeature> P9AdditionalFeatures =
  390. [DirectivePwr9,
  391. FeatureP9Altivec,
  392. FeatureP9Vector,
  393. FeaturePPCPreRASched,
  394. FeaturePPCPostRASched,
  395. FeatureISA3_0,
  396. FeaturePredictableSelectIsExpensive
  397. ];
  398. // Some features are unique to Power9 and there is no reason to assume
  399. // they will be part of any future CPUs. One example is the narrower
  400. // dispatch for vector operations than scalar ones. For the time being,
  401. // this list also includes scheduling-related features since we do not have
  402. // enough info to create custom scheduling strategies for future CPUs.
  403. list<SubtargetFeature> P9SpecificFeatures = [FeatureVectorsUseTwoUnits];
  404. list<SubtargetFeature> P9InheritableFeatures =
  405. !listconcat(P8InheritableFeatures, P9AdditionalFeatures);
  406. list<SubtargetFeature> P9Features =
  407. !listconcat(P9InheritableFeatures, P9SpecificFeatures);
  408. // Power10
  409. // For P10 CPU we assume that all of the existing features from Power9
  410. // still exist with the exception of those we know are Power9 specific.
  411. list<SubtargetFeature> FusionFeatures = [
  412. FeatureStoreFusion, FeatureAddLogicalFusion, FeatureLogicalAddFusion,
  413. FeatureLogicalFusion, FeatureArithAddFusion, FeatureSha3Fusion,
  414. ];
  415. list<SubtargetFeature> P10AdditionalFeatures =
  416. !listconcat(FusionFeatures, [
  417. DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs,
  418. FeaturePCRelativeMemops, FeatureP10Vector, FeatureMMA,
  419. FeaturePairedVectorMemops, FeatureFastMFLR]);
  420. list<SubtargetFeature> P10SpecificFeatures = [];
  421. list<SubtargetFeature> P10InheritableFeatures =
  422. !listconcat(P9InheritableFeatures, P10AdditionalFeatures);
  423. list<SubtargetFeature> P10Features =
  424. !listconcat(P10InheritableFeatures, P10SpecificFeatures);
  425. // Future
  426. // For future CPU we assume that all of the existing features from Power10
  427. // still exist with the exception of those we know are Power10 specific.
  428. list<SubtargetFeature> FutureAdditionalFeatures = [FeatureISAFuture];
  429. list<SubtargetFeature> FutureSpecificFeatures = [];
  430. list<SubtargetFeature> FutureInheritableFeatures =
  431. !listconcat(P10InheritableFeatures, FutureAdditionalFeatures);
  432. list<SubtargetFeature> FutureFeatures =
  433. !listconcat(FutureInheritableFeatures, FutureSpecificFeatures);
  434. }
  435. // Note: Future features to add when support is extended to more
  436. // recent ISA levels:
  437. //
  438. // DFP p6, p6x, p7 decimal floating-point instructions
  439. // POPCNTB p5 through p7 popcntb and related instructions
  440. //===----------------------------------------------------------------------===//
  441. // Classes used for relation maps.
  442. //===----------------------------------------------------------------------===//
  443. // RecFormRel - Filter class used to relate non-record-form instructions with
  444. // their record-form variants.
  445. class RecFormRel;
  446. // AltVSXFMARel - Filter class used to relate the primary addend-killing VSX
  447. // FMA instruction forms with their corresponding factor-killing forms.
  448. class AltVSXFMARel {
  449. bit IsVSXFMAAlt = 0;
  450. }
  451. //===----------------------------------------------------------------------===//
  452. // Relation Map Definitions.
  453. //===----------------------------------------------------------------------===//
  454. def getRecordFormOpcode : InstrMapping {
  455. let FilterClass = "RecFormRel";
  456. // Instructions with the same BaseName and Interpretation64Bit values
  457. // form a row.
  458. let RowFields = ["BaseName", "Interpretation64Bit"];
  459. // Instructions with the same RC value form a column.
  460. let ColFields = ["RC"];
  461. // The key column are the non-record-form instructions.
  462. let KeyCol = ["0"];
  463. // Value columns RC=1
  464. let ValueCols = [["1"]];
  465. }
  466. def getNonRecordFormOpcode : InstrMapping {
  467. let FilterClass = "RecFormRel";
  468. // Instructions with the same BaseName and Interpretation64Bit values
  469. // form a row.
  470. let RowFields = ["BaseName", "Interpretation64Bit"];
  471. // Instructions with the same RC value form a column.
  472. let ColFields = ["RC"];
  473. // The key column are the record-form instructions.
  474. let KeyCol = ["1"];
  475. // Value columns are RC=0
  476. let ValueCols = [["0"]];
  477. }
  478. def getAltVSXFMAOpcode : InstrMapping {
  479. let FilterClass = "AltVSXFMARel";
  480. // Instructions with the same BaseName value form a row.
  481. let RowFields = ["BaseName"];
  482. // Instructions with the same IsVSXFMAAlt value form a column.
  483. let ColFields = ["IsVSXFMAAlt"];
  484. // The key column are the (default) addend-killing instructions.
  485. let KeyCol = ["0"];
  486. // Value columns IsVSXFMAAlt=1
  487. let ValueCols = [["1"]];
  488. }
  489. //===----------------------------------------------------------------------===//
  490. // Register File Description
  491. //===----------------------------------------------------------------------===//
  492. include "PPCRegisterInfo.td"
  493. include "PPCSchedule.td"
  494. include "GISel/PPCRegisterBanks.td"
  495. //===----------------------------------------------------------------------===//
  496. // PowerPC processors supported.
  497. //
  498. def : Processor<"generic", G3Itineraries, [Directive32, FeatureHardFloat,
  499. FeatureMFTB]>;
  500. def : ProcessorModel<"440", PPC440Model, [Directive440, FeatureISEL,
  501. FeatureFRES, FeatureFRSQRTE,
  502. FeatureICBT, FeatureBookE,
  503. FeatureMSYNC, FeatureMFTB]>;
  504. def : ProcessorModel<"450", PPC440Model, [Directive440, FeatureISEL,
  505. FeatureFRES, FeatureFRSQRTE,
  506. FeatureICBT, FeatureBookE,
  507. FeatureMSYNC, FeatureMFTB]>;
  508. def : Processor<"601", G3Itineraries, [Directive601, FeatureFPU]>;
  509. def : Processor<"602", G3Itineraries, [Directive602, FeatureFPU,
  510. FeatureMFTB]>;
  511. def : Processor<"603", G3Itineraries, [Directive603,
  512. FeatureFRES, FeatureFRSQRTE,
  513. FeatureMFTB]>;
  514. def : Processor<"603e", G3Itineraries, [Directive603,
  515. FeatureFRES, FeatureFRSQRTE,
  516. FeatureMFTB]>;
  517. def : Processor<"603ev", G3Itineraries, [Directive603,
  518. FeatureFRES, FeatureFRSQRTE,
  519. FeatureMFTB]>;
  520. def : Processor<"604", G3Itineraries, [Directive604,
  521. FeatureFRES, FeatureFRSQRTE,
  522. FeatureMFTB]>;
  523. def : Processor<"604e", G3Itineraries, [Directive604,
  524. FeatureFRES, FeatureFRSQRTE,
  525. FeatureMFTB]>;
  526. def : Processor<"620", G3Itineraries, [Directive620,
  527. FeatureFRES, FeatureFRSQRTE,
  528. FeatureMFTB]>;
  529. def : Processor<"750", G4Itineraries, [Directive750,
  530. FeatureFRES, FeatureFRSQRTE,
  531. FeatureMFTB]>;
  532. def : Processor<"g3", G3Itineraries, [Directive750,
  533. FeatureFRES, FeatureFRSQRTE,
  534. FeatureMFTB]>;
  535. def : Processor<"7400", G4Itineraries, [Directive7400, FeatureAltivec,
  536. FeatureFRES, FeatureFRSQRTE,
  537. FeatureMFTB]>;
  538. def : Processor<"g4", G4Itineraries, [Directive7400, FeatureAltivec,
  539. FeatureFRES, FeatureFRSQRTE,
  540. FeatureMFTB]>;
  541. def : Processor<"7450", G4PlusItineraries, [Directive7400, FeatureAltivec,
  542. FeatureFRES, FeatureFRSQRTE,
  543. FeatureMFTB]>;
  544. def : Processor<"g4+", G4PlusItineraries, [Directive7400, FeatureAltivec,
  545. FeatureFRES, FeatureFRSQRTE,
  546. FeatureMFTB]>;
  547. def : ProcessorModel<"970", G5Model,
  548. [Directive970, FeatureAltivec,
  549. FeatureMFOCRF, FeatureFSqrt,
  550. FeatureFRES, FeatureFRSQRTE, FeatureSTFIWX,
  551. Feature64Bit /*, Feature64BitRegs */,
  552. FeatureMFTB]>;
  553. def : ProcessorModel<"g5", G5Model,
  554. [Directive970, FeatureAltivec,
  555. FeatureMFOCRF, FeatureFSqrt, FeatureSTFIWX,
  556. FeatureFRES, FeatureFRSQRTE,
  557. Feature64Bit /*, Feature64BitRegs */,
  558. FeatureMFTB, DeprecatedDST]>;
  559. def : ProcessorModel<"e500", PPCE500Model,
  560. [DirectiveE500,
  561. FeatureICBT, FeatureBookE,
  562. FeatureISEL, FeatureMFTB, FeatureMSYNC, FeatureSPE]>;
  563. def : ProcessorModel<"e500mc", PPCE500mcModel,
  564. [DirectiveE500mc,
  565. FeatureSTFIWX, FeatureICBT, FeatureBookE,
  566. FeatureISEL, FeatureMFTB]>;
  567. def : ProcessorModel<"e5500", PPCE5500Model,
  568. [DirectiveE5500, FeatureMFOCRF, Feature64Bit,
  569. FeatureSTFIWX, FeatureICBT, FeatureBookE,
  570. FeatureISEL, FeatureMFTB]>;
  571. def : ProcessorModel<"a2", PPCA2Model,
  572. [DirectiveA2, FeatureICBT, FeatureBookE, FeatureMFOCRF,
  573. FeatureFCPSGN, FeatureFSqrt, FeatureFRE, FeatureFRES,
  574. FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
  575. FeatureSTFIWX, FeatureLFIWAX,
  576. FeatureFPRND, FeatureFPCVT, FeatureISEL,
  577. FeatureSlowPOPCNTD, FeatureCMPB, FeatureLDBRX,
  578. Feature64Bit /*, Feature64BitRegs */, FeatureMFTB,
  579. FeatureISA2_06]>;
  580. def : ProcessorModel<"pwr3", G5Model,
  581. [DirectivePwr3, FeatureAltivec,
  582. FeatureFRES, FeatureFRSQRTE, FeatureMFOCRF,
  583. FeatureSTFIWX, Feature64Bit]>;
  584. def : ProcessorModel<"pwr4", G5Model,
  585. [DirectivePwr4, FeatureAltivec, FeatureMFOCRF,
  586. FeatureFSqrt, FeatureFRES, FeatureFRSQRTE,
  587. FeatureSTFIWX, Feature64Bit, FeatureMFTB]>;
  588. def : ProcessorModel<"pwr5", G5Model,
  589. [DirectivePwr5, FeatureAltivec, FeatureMFOCRF,
  590. FeatureFSqrt, FeatureFRE, FeatureFRES,
  591. FeatureFRSQRTE, FeatureFRSQRTES,
  592. FeatureSTFIWX, Feature64Bit,
  593. FeatureMFTB, DeprecatedDST]>;
  594. def : ProcessorModel<"pwr5x", G5Model,
  595. [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
  596. FeatureFSqrt, FeatureFRE, FeatureFRES,
  597. FeatureFRSQRTE, FeatureFRSQRTES,
  598. FeatureSTFIWX, FeatureFPRND, Feature64Bit,
  599. FeatureMFTB, DeprecatedDST]>;
  600. def : ProcessorModel<"pwr6", G5Model,
  601. [DirectivePwr6, FeatureAltivec,
  602. FeatureMFOCRF, FeatureFCPSGN, FeatureFSqrt, FeatureFRE,
  603. FeatureFRES, FeatureFRSQRTE, FeatureFRSQRTES,
  604. FeatureRecipPrec, FeatureSTFIWX, FeatureLFIWAX, FeatureCMPB,
  605. FeatureFPRND, Feature64Bit /*, Feature64BitRegs */,
  606. FeatureMFTB, DeprecatedDST]>;
  607. def : ProcessorModel<"pwr6x", G5Model,
  608. [DirectivePwr5x, FeatureAltivec, FeatureMFOCRF,
  609. FeatureFCPSGN, FeatureFSqrt, FeatureFRE, FeatureFRES,
  610. FeatureFRSQRTE, FeatureFRSQRTES, FeatureRecipPrec,
  611. FeatureSTFIWX, FeatureLFIWAX, FeatureCMPB,
  612. FeatureFPRND, Feature64Bit,
  613. FeatureMFTB, DeprecatedDST]>;
  614. def : ProcessorModel<"pwr7", P7Model, ProcessorFeatures.P7Features>;
  615. def : ProcessorModel<"pwr8", P8Model, ProcessorFeatures.P8Features>;
  616. def : ProcessorModel<"pwr9", P9Model, ProcessorFeatures.P9Features>;
  617. def : ProcessorModel<"pwr10", P10Model, ProcessorFeatures.P10Features>;
  618. // No scheduler model for future CPU.
  619. def : ProcessorModel<"future", NoSchedModel,
  620. ProcessorFeatures.FutureFeatures>;
  621. def : Processor<"ppc", G3Itineraries, [Directive32, FeatureHardFloat,
  622. FeatureMFTB]>;
  623. def : Processor<"ppc32", G3Itineraries, [Directive32, FeatureHardFloat,
  624. FeatureMFTB]>;
  625. def : ProcessorModel<"ppc64", G5Model,
  626. [Directive64, FeatureAltivec,
  627. FeatureMFOCRF, FeatureFSqrt, FeatureFRES,
  628. FeatureFRSQRTE, FeatureSTFIWX,
  629. Feature64Bit /*, Feature64BitRegs */,
  630. FeatureMFTB]>;
  631. def : ProcessorModel<"ppc64le", P8Model, ProcessorFeatures.P8Features>;
  632. //===----------------------------------------------------------------------===//
  633. // Calling Conventions
  634. //===----------------------------------------------------------------------===//
  635. include "PPCCallingConv.td"
  636. def PPCInstrInfo : InstrInfo {
  637. let isLittleEndianEncoding = 1;
  638. // FIXME: Unset this when no longer needed!
  639. let decodePositionallyEncodedOperands = 1;
  640. let noNamedPositionallyEncodedOperands = 1;
  641. let useDeprecatedPositionallyEncodedOperands = 1;
  642. }
  643. def PPCAsmWriter : AsmWriter {
  644. string AsmWriterClassName = "InstPrinter";
  645. int PassSubtarget = 1;
  646. int Variant = 0;
  647. bit isMCAsmWriter = 1;
  648. }
  649. def PPCAsmParser : AsmParser {
  650. let ShouldEmitMatchRegisterName = 0;
  651. }
  652. def PPCAsmParserVariant : AsmParserVariant {
  653. int Variant = 0;
  654. // We do not use hard coded registers in asm strings. However, some
  655. // InstAlias definitions use immediate literals. Set RegisterPrefix
  656. // so that those are not misinterpreted as registers.
  657. string RegisterPrefix = "%";
  658. string BreakCharacters = ".";
  659. }
  660. def PPC : Target {
  661. // Information about the instructions.
  662. let InstructionSet = PPCInstrInfo;
  663. let AssemblyWriters = [PPCAsmWriter];
  664. let AssemblyParsers = [PPCAsmParser];
  665. let AssemblyParserVariants = [PPCAsmParserVariant];
  666. let AllowRegisterRenaming = 1;
  667. }
  668. //===----------------------------------------------------------------------===//
  669. // Pfm Counters
  670. //===----------------------------------------------------------------------===//
  671. include "PPCPfmCounters.td"