AArch64SchedPredicates.td 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. //===- AArch64SchedPredicates.td - AArch64 Sched Preds -----*- 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 file defines scheduling predicate definitions that are used by the
  10. // AArch64 subtargets.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. // Function mappers.
  14. // Check the extension type in arithmetic instructions.
  15. let FunctionMapper = "AArch64_AM::getArithExtendType" in {
  16. def CheckExtUXTB : CheckImmOperand_s<3, "AArch64_AM::UXTB">;
  17. def CheckExtUXTH : CheckImmOperand_s<3, "AArch64_AM::UXTH">;
  18. def CheckExtUXTW : CheckImmOperand_s<3, "AArch64_AM::UXTW">;
  19. def CheckExtUXTX : CheckImmOperand_s<3, "AArch64_AM::UXTX">;
  20. def CheckExtSXTB : CheckImmOperand_s<3, "AArch64_AM::SXTB">;
  21. def CheckExtSXTH : CheckImmOperand_s<3, "AArch64_AM::SXTH">;
  22. def CheckExtSXTW : CheckImmOperand_s<3, "AArch64_AM::SXTW">;
  23. def CheckExtSXTX : CheckImmOperand_s<3, "AArch64_AM::SXTX">;
  24. }
  25. // Check for shifting in extended arithmetic instructions.
  26. foreach I = {0-3} in {
  27. let FunctionMapper = "AArch64_AM::getArithShiftValue" in
  28. def CheckExtBy#I : CheckImmOperand<3, I>;
  29. }
  30. // Check the extension type in the register offset addressing mode.
  31. let FunctionMapper = "AArch64_AM::getMemExtendType" in {
  32. def CheckMemExtUXTW : CheckImmOperand_s<3, "AArch64_AM::UXTW">;
  33. def CheckMemExtLSL : CheckImmOperand_s<3, "AArch64_AM::UXTX">;
  34. def CheckMemExtSXTW : CheckImmOperand_s<3, "AArch64_AM::SXTW">;
  35. def CheckMemExtSXTX : CheckImmOperand_s<3, "AArch64_AM::SXTX">;
  36. }
  37. // Check for scaling in the register offset addressing mode.
  38. let FunctionMapper = "AArch64_AM::getMemDoShift" in
  39. def CheckMemScaled : CheckImmOperandSimple<4>;
  40. // Check the shifting type in arithmetic and logic instructions.
  41. let FunctionMapper = "AArch64_AM::getShiftType" in {
  42. def CheckShiftLSL : CheckImmOperand_s<3, "AArch64_AM::LSL">;
  43. def CheckShiftLSR : CheckImmOperand_s<3, "AArch64_AM::LSR">;
  44. def CheckShiftASR : CheckImmOperand_s<3, "AArch64_AM::ASR">;
  45. def CheckShiftROR : CheckImmOperand_s<3, "AArch64_AM::ROR">;
  46. def CheckShiftMSL : CheckImmOperand_s<3, "AArch64_AM::MSL">;
  47. }
  48. // Check for shifting in arithmetic and logic instructions.
  49. foreach I = {0-4, 8} in {
  50. let FunctionMapper = "AArch64_AM::getShiftValue" in
  51. def CheckShiftBy#I : CheckImmOperand<3, I>;
  52. }
  53. // Generic predicates.
  54. // Identify whether an instruction is the 16-bit NEON form based on its result.
  55. def CheckHForm : CheckAll<[CheckIsRegOperand<0>,
  56. CheckAny<[CheckRegOperand<0, H0>,
  57. CheckRegOperand<0, H1>,
  58. CheckRegOperand<0, H2>,
  59. CheckRegOperand<0, H3>,
  60. CheckRegOperand<0, H4>,
  61. CheckRegOperand<0, H5>,
  62. CheckRegOperand<0, H6>,
  63. CheckRegOperand<0, H7>,
  64. CheckRegOperand<0, H8>,
  65. CheckRegOperand<0, H9>,
  66. CheckRegOperand<0, H10>,
  67. CheckRegOperand<0, H11>,
  68. CheckRegOperand<0, H12>,
  69. CheckRegOperand<0, H13>,
  70. CheckRegOperand<0, H14>,
  71. CheckRegOperand<0, H15>,
  72. CheckRegOperand<0, H16>,
  73. CheckRegOperand<0, H17>,
  74. CheckRegOperand<0, H18>,
  75. CheckRegOperand<0, H19>,
  76. CheckRegOperand<0, H20>,
  77. CheckRegOperand<0, H21>,
  78. CheckRegOperand<0, H22>,
  79. CheckRegOperand<0, H23>,
  80. CheckRegOperand<0, H24>,
  81. CheckRegOperand<0, H25>,
  82. CheckRegOperand<0, H26>,
  83. CheckRegOperand<0, H27>,
  84. CheckRegOperand<0, H28>,
  85. CheckRegOperand<0, H29>,
  86. CheckRegOperand<0, H30>,
  87. CheckRegOperand<0, H31>]>]>;
  88. // Identify whether an instruction is the 32-bit NEON form based on its result.
  89. def CheckSForm : CheckAll<[CheckIsRegOperand<0>,
  90. CheckAny<[CheckRegOperand<0, S0>,
  91. CheckRegOperand<0, S1>,
  92. CheckRegOperand<0, S2>,
  93. CheckRegOperand<0, S3>,
  94. CheckRegOperand<0, S4>,
  95. CheckRegOperand<0, S5>,
  96. CheckRegOperand<0, S6>,
  97. CheckRegOperand<0, S7>,
  98. CheckRegOperand<0, S8>,
  99. CheckRegOperand<0, S9>,
  100. CheckRegOperand<0, S10>,
  101. CheckRegOperand<0, S11>,
  102. CheckRegOperand<0, S12>,
  103. CheckRegOperand<0, S13>,
  104. CheckRegOperand<0, S14>,
  105. CheckRegOperand<0, S15>,
  106. CheckRegOperand<0, S16>,
  107. CheckRegOperand<0, S17>,
  108. CheckRegOperand<0, S18>,
  109. CheckRegOperand<0, S19>,
  110. CheckRegOperand<0, S20>,
  111. CheckRegOperand<0, S21>,
  112. CheckRegOperand<0, S22>,
  113. CheckRegOperand<0, S23>,
  114. CheckRegOperand<0, S24>,
  115. CheckRegOperand<0, S25>,
  116. CheckRegOperand<0, S26>,
  117. CheckRegOperand<0, S27>,
  118. CheckRegOperand<0, S28>,
  119. CheckRegOperand<0, S29>,
  120. CheckRegOperand<0, S30>,
  121. CheckRegOperand<0, S31>]>]>;
  122. // Identify whether an instruction is the 64-bit NEON form based on its result.
  123. def CheckDForm : CheckAll<[CheckIsRegOperand<0>,
  124. CheckAny<[CheckRegOperand<0, D0>,
  125. CheckRegOperand<0, D1>,
  126. CheckRegOperand<0, D2>,
  127. CheckRegOperand<0, D3>,
  128. CheckRegOperand<0, D4>,
  129. CheckRegOperand<0, D5>,
  130. CheckRegOperand<0, D6>,
  131. CheckRegOperand<0, D7>,
  132. CheckRegOperand<0, D8>,
  133. CheckRegOperand<0, D9>,
  134. CheckRegOperand<0, D10>,
  135. CheckRegOperand<0, D11>,
  136. CheckRegOperand<0, D12>,
  137. CheckRegOperand<0, D13>,
  138. CheckRegOperand<0, D14>,
  139. CheckRegOperand<0, D15>,
  140. CheckRegOperand<0, D16>,
  141. CheckRegOperand<0, D17>,
  142. CheckRegOperand<0, D18>,
  143. CheckRegOperand<0, D19>,
  144. CheckRegOperand<0, D20>,
  145. CheckRegOperand<0, D21>,
  146. CheckRegOperand<0, D22>,
  147. CheckRegOperand<0, D23>,
  148. CheckRegOperand<0, D24>,
  149. CheckRegOperand<0, D25>,
  150. CheckRegOperand<0, D26>,
  151. CheckRegOperand<0, D27>,
  152. CheckRegOperand<0, D28>,
  153. CheckRegOperand<0, D29>,
  154. CheckRegOperand<0, D30>,
  155. CheckRegOperand<0, D31>]>]>;
  156. // Identify whether an instruction is the 128-bit NEON form based on its result.
  157. def CheckQForm : CheckAll<[CheckIsRegOperand<0>,
  158. CheckAny<[CheckRegOperand<0, Q0>,
  159. CheckRegOperand<0, Q1>,
  160. CheckRegOperand<0, Q2>,
  161. CheckRegOperand<0, Q3>,
  162. CheckRegOperand<0, Q4>,
  163. CheckRegOperand<0, Q5>,
  164. CheckRegOperand<0, Q6>,
  165. CheckRegOperand<0, Q7>,
  166. CheckRegOperand<0, Q8>,
  167. CheckRegOperand<0, Q9>,
  168. CheckRegOperand<0, Q10>,
  169. CheckRegOperand<0, Q11>,
  170. CheckRegOperand<0, Q12>,
  171. CheckRegOperand<0, Q13>,
  172. CheckRegOperand<0, Q14>,
  173. CheckRegOperand<0, Q15>,
  174. CheckRegOperand<0, Q16>,
  175. CheckRegOperand<0, Q17>,
  176. CheckRegOperand<0, Q18>,
  177. CheckRegOperand<0, Q19>,
  178. CheckRegOperand<0, Q20>,
  179. CheckRegOperand<0, Q21>,
  180. CheckRegOperand<0, Q22>,
  181. CheckRegOperand<0, Q23>,
  182. CheckRegOperand<0, Q24>,
  183. CheckRegOperand<0, Q25>,
  184. CheckRegOperand<0, Q26>,
  185. CheckRegOperand<0, Q27>,
  186. CheckRegOperand<0, Q28>,
  187. CheckRegOperand<0, Q29>,
  188. CheckRegOperand<0, Q30>,
  189. CheckRegOperand<0, Q31>]>]>;
  190. // Identify arithmetic instructions with extend.
  191. def IsArithExtOp : CheckOpcode<[ADDWrx, ADDXrx, ADDSWrx, ADDSXrx,
  192. SUBWrx, SUBXrx, SUBSWrx, SUBSXrx,
  193. ADDXrx64, ADDSXrx64,
  194. SUBXrx64, SUBSXrx64]>;
  195. // Identify arithmetic immediate instructions.
  196. def IsArithImmOp : CheckOpcode<[ADDWri, ADDXri, ADDSWri, ADDSXri,
  197. SUBWri, SUBXri, SUBSWri, SUBSXri]>;
  198. // Identify arithmetic instructions with shift.
  199. def IsArithShiftOp : CheckOpcode<[ADDWrs, ADDXrs, ADDSWrs, ADDSXrs,
  200. SUBWrs, SUBXrs, SUBSWrs, SUBSXrs]>;
  201. // Identify arithmetic instructions without shift.
  202. def IsArithUnshiftOp : CheckOpcode<[ADDWrr, ADDXrr, ADDSWrr, ADDSXrr,
  203. SUBWrr, SUBXrr, SUBSWrr, SUBSXrr]>;
  204. // Identify logic immediate instructions.
  205. def IsLogicImmOp : CheckOpcode<[ANDWri, ANDXri,
  206. EORWri, EORXri,
  207. ORRWri, ORRXri]>;
  208. // Identify logic instructions with shift.
  209. def IsLogicShiftOp : CheckOpcode<[ANDWrs, ANDXrs, ANDSWrs, ANDSXrs,
  210. BICWrs, BICXrs, BICSWrs, BICSXrs,
  211. EONWrs, EONXrs,
  212. EORWrs, EORXrs,
  213. ORNWrs, ORNXrs,
  214. ORRWrs, ORRXrs]>;
  215. // Identify logic instructions without shift.
  216. def IsLogicUnshiftOp : CheckOpcode<[ANDWrr, ANDXrr, ANDSWrr, ANDSXrr,
  217. BICWrr, BICXrr, BICSWrr, BICSXrr,
  218. EONWrr, EONXrr,
  219. EORWrr, EORXrr,
  220. ORNWrr, ORNXrr,
  221. ORRWrr, ORRXrr]>;
  222. // Identify arithmetic and logic immediate instructions.
  223. def IsArithLogicImmOp : CheckOpcode<!listconcat(IsArithImmOp.ValidOpcodes,
  224. IsLogicImmOp.ValidOpcodes)>;
  225. // Identify arithmetic and logic instructions with shift.
  226. def IsArithLogicShiftOp : CheckOpcode<!listconcat(IsArithShiftOp.ValidOpcodes,
  227. IsLogicShiftOp.ValidOpcodes)>;
  228. // Identify arithmetic and logic instructions without shift.
  229. def IsArithLogicUnshiftOp : CheckOpcode<!listconcat(IsArithUnshiftOp.ValidOpcodes,
  230. IsLogicUnshiftOp.ValidOpcodes)>;
  231. // Identify whether an instruction is an ASIMD
  232. // load using the post index addressing mode.
  233. def IsLoadASIMDPostOp : CheckOpcode<[LD1Onev8b_POST, LD1Onev4h_POST, LD1Onev2s_POST, LD1Onev1d_POST,
  234. LD1Onev16b_POST, LD1Onev8h_POST, LD1Onev4s_POST, LD1Onev2d_POST,
  235. LD1Twov8b_POST, LD1Twov4h_POST, LD1Twov2s_POST, LD1Twov1d_POST,
  236. LD1Twov16b_POST, LD1Twov8h_POST, LD1Twov4s_POST, LD1Twov2d_POST,
  237. LD1Threev8b_POST, LD1Threev4h_POST, LD1Threev2s_POST, LD1Threev1d_POST,
  238. LD1Threev16b_POST, LD1Threev8h_POST, LD1Threev4s_POST, LD1Threev2d_POST,
  239. LD1Fourv8b_POST, LD1Fourv4h_POST, LD1Fourv2s_POST, LD1Fourv1d_POST,
  240. LD1Fourv16b_POST, LD1Fourv8h_POST, LD1Fourv4s_POST, LD1Fourv2d_POST,
  241. LD1i8_POST, LD1i16_POST, LD1i32_POST, LD1i64_POST,
  242. LD1Rv8b_POST, LD1Rv4h_POST, LD1Rv2s_POST, LD1Rv1d_POST,
  243. LD1Rv16b_POST, LD1Rv8h_POST, LD1Rv4s_POST, LD1Rv2d_POST,
  244. LD2Twov8b_POST, LD2Twov4h_POST, LD2Twov2s_POST,
  245. LD2Twov16b_POST, LD2Twov8h_POST, LD2Twov4s_POST, LD2Twov2d_POST,
  246. LD2i8_POST, LD2i16_POST, LD2i32_POST, LD2i64_POST,
  247. LD2Rv8b_POST, LD2Rv4h_POST, LD2Rv2s_POST, LD2Rv1d_POST,
  248. LD2Rv16b_POST, LD2Rv8h_POST, LD2Rv4s_POST, LD2Rv2d_POST,
  249. LD3Threev8b_POST, LD3Threev4h_POST, LD3Threev2s_POST,
  250. LD3Threev16b_POST, LD3Threev8h_POST, LD3Threev4s_POST, LD3Threev2d_POST,
  251. LD3i8_POST, LD3i16_POST, LD3i32_POST, LD3i64_POST,
  252. LD3Rv8b_POST, LD3Rv4h_POST, LD3Rv2s_POST, LD3Rv1d_POST,
  253. LD3Rv16b_POST, LD3Rv8h_POST, LD3Rv4s_POST, LD3Rv2d_POST,
  254. LD4Fourv8b_POST, LD4Fourv4h_POST, LD4Fourv2s_POST,
  255. LD4Fourv16b_POST, LD4Fourv8h_POST, LD4Fourv4s_POST, LD4Fourv2d_POST,
  256. LD4i8_POST, LD4i16_POST, LD4i32_POST, LD4i64_POST,
  257. LD4Rv8b_POST, LD4Rv4h_POST, LD4Rv2s_POST, LD4Rv1d_POST,
  258. LD4Rv16b_POST, LD4Rv8h_POST, LD4Rv4s_POST, LD4Rv2d_POST]>;
  259. // Identify whether an instruction is an ASIMD
  260. // store using the post index addressing mode.
  261. def IsStoreASIMDPostOp : CheckOpcode<[ST1Onev8b_POST, ST1Onev4h_POST, ST1Onev2s_POST, ST1Onev1d_POST,
  262. ST1Onev16b_POST, ST1Onev8h_POST, ST1Onev4s_POST, ST1Onev2d_POST,
  263. ST1Twov8b_POST, ST1Twov4h_POST, ST1Twov2s_POST, ST1Twov1d_POST,
  264. ST1Twov16b_POST, ST1Twov8h_POST, ST1Twov4s_POST, ST1Twov2d_POST,
  265. ST1Threev8b_POST, ST1Threev4h_POST, ST1Threev2s_POST, ST1Threev1d_POST,
  266. ST1Threev16b_POST, ST1Threev8h_POST, ST1Threev4s_POST, ST1Threev2d_POST,
  267. ST1Fourv8b_POST, ST1Fourv4h_POST, ST1Fourv2s_POST, ST1Fourv1d_POST,
  268. ST1Fourv16b_POST, ST1Fourv8h_POST, ST1Fourv4s_POST, ST1Fourv2d_POST,
  269. ST1i8_POST, ST1i16_POST, ST1i32_POST, ST1i64_POST,
  270. ST2Twov8b_POST, ST2Twov4h_POST, ST2Twov2s_POST,
  271. ST2Twov16b_POST, ST2Twov8h_POST, ST2Twov4s_POST, ST2Twov2d_POST,
  272. ST2i8_POST, ST2i16_POST, ST2i32_POST, ST2i64_POST,
  273. ST3Threev8b_POST, ST3Threev4h_POST, ST3Threev2s_POST,
  274. ST3Threev16b_POST, ST3Threev8h_POST, ST3Threev4s_POST, ST3Threev2d_POST,
  275. ST3i8_POST, ST3i16_POST, ST3i32_POST, ST3i64_POST,
  276. ST4Fourv8b_POST, ST4Fourv4h_POST, ST4Fourv2s_POST,
  277. ST4Fourv16b_POST, ST4Fourv8h_POST, ST4Fourv4s_POST, ST4Fourv2d_POST,
  278. ST4i8_POST, ST4i16_POST, ST4i32_POST, ST4i64_POST]>;
  279. // Identify whether an instruction is an ASIMD load
  280. // or store using the post index addressing mode.
  281. def IsLoadStoreASIMDPostOp : CheckOpcode<!listconcat(IsLoadASIMDPostOp.ValidOpcodes,
  282. IsStoreASIMDPostOp.ValidOpcodes)>;
  283. // Identify whether an instruction is a load
  284. // using the register offset addressing mode.
  285. def IsLoadRegOffsetOp : CheckOpcode<[PRFMroW, PRFMroX,
  286. LDRBBroW, LDRBBroX,
  287. LDRSBWroW, LDRSBWroX, LDRSBXroW, LDRSBXroX,
  288. LDRHHroW, LDRHHroX,
  289. LDRSHWroW, LDRSHWroX, LDRSHXroW, LDRSHXroX,
  290. LDRWroW, LDRWroX,
  291. LDRSWroW, LDRSWroX,
  292. LDRXroW, LDRXroX,
  293. LDRBroW, LDRBroX,
  294. LDRHroW, LDRHroX,
  295. LDRSroW, LDRSroX,
  296. LDRDroW, LDRDroX,
  297. LDRQroW, LDRQroX]>;
  298. // Identify whether an instruction is a store
  299. // using the register offset addressing mode.
  300. def IsStoreRegOffsetOp : CheckOpcode<[STRBBroW, STRBBroX,
  301. STRHHroW, STRHHroX,
  302. STRWroW, STRWroX,
  303. STRXroW, STRXroX,
  304. STRBroW, STRBroX,
  305. STRHroW, STRHroX,
  306. STRSroW, STRSroX,
  307. STRDroW, STRDroX,
  308. STRQroW, STRQroX]>;
  309. // Identify whether an instruction is a load or
  310. // store using the register offset addressing mode.
  311. def IsLoadStoreRegOffsetOp : CheckOpcode<!listconcat(IsLoadRegOffsetOp.ValidOpcodes,
  312. IsStoreRegOffsetOp.ValidOpcodes)>;
  313. // Target predicates.
  314. // Identify an instruction that effectively transfers a register to another.
  315. def IsCopyIdiomFn : TIIPredicate<"isCopyIdiom",
  316. MCOpcodeSwitchStatement<
  317. [// MOV {Rd, SP}, {SP, Rn} =>
  318. // ADD {Rd, SP}, {SP, Rn}, #0
  319. MCOpcodeSwitchCase<
  320. [ADDWri, ADDXri],
  321. MCReturnStatement<
  322. CheckAll<
  323. [CheckIsRegOperand<0>,
  324. CheckIsRegOperand<1>,
  325. CheckAny<
  326. [CheckRegOperand<0, WSP>,
  327. CheckRegOperand<0, SP>,
  328. CheckRegOperand<1, WSP>,
  329. CheckRegOperand<1, SP>]>,
  330. CheckZeroOperand<2>]>>>,
  331. // MOV Rd, Rm =>
  332. // ORR Rd, ZR, Rm, LSL #0
  333. MCOpcodeSwitchCase<
  334. [ORRWrs, ORRXrs],
  335. MCReturnStatement<
  336. CheckAll<
  337. [CheckIsRegOperand<1>,
  338. CheckIsRegOperand<2>,
  339. CheckAny<
  340. [CheckRegOperand<1, WZR>,
  341. CheckRegOperand<1, XZR>]>,
  342. CheckShiftBy0]>>>],
  343. MCReturnStatement<FalsePred>>>;
  344. def IsCopyIdiomPred : MCSchedPredicate<IsCopyIdiomFn>;
  345. // Identify arithmetic instructions with an extended register.
  346. def RegExtendedFn : TIIPredicate<"hasExtendedReg",
  347. MCOpcodeSwitchStatement<
  348. [MCOpcodeSwitchCase<
  349. IsArithExtOp.ValidOpcodes,
  350. MCReturnStatement<
  351. CheckNot<CheckZeroOperand<3>>>>],
  352. MCReturnStatement<FalsePred>>>;
  353. def RegExtendedPred : MCSchedPredicate<RegExtendedFn>;
  354. // Identify arithmetic and logic instructions with a shifted register.
  355. def RegShiftedFn : TIIPredicate<"hasShiftedReg",
  356. MCOpcodeSwitchStatement<
  357. [MCOpcodeSwitchCase<
  358. IsArithLogicShiftOp.ValidOpcodes,
  359. MCReturnStatement<
  360. CheckNot<CheckZeroOperand<3>>>>],
  361. MCReturnStatement<FalsePred>>>;
  362. def RegShiftedPred : MCSchedPredicate<RegShiftedFn>;
  363. // Identify a load or store using the register offset addressing mode
  364. // with an extended or scaled register.
  365. def ScaledIdxFn : TIIPredicate<"isScaledAddr",
  366. MCOpcodeSwitchStatement<
  367. [MCOpcodeSwitchCase<
  368. IsLoadStoreRegOffsetOp.ValidOpcodes,
  369. MCReturnStatement<
  370. CheckAny<[CheckNot<CheckMemExtLSL>,
  371. CheckMemScaled]>>>],
  372. MCReturnStatement<FalsePred>>>;
  373. def ScaledIdxPred : MCSchedPredicate<ScaledIdxFn>;
  374. // Identify an instruction that effectively resets a FP register to zero.
  375. def IsZeroFPIdiomFn : TIIPredicate<"isZeroFPIdiom",
  376. MCOpcodeSwitchStatement<
  377. [// MOVI Vd, #0
  378. MCOpcodeSwitchCase<
  379. [MOVIv8b_ns, MOVIv16b_ns,
  380. MOVID, MOVIv2d_ns],
  381. MCReturnStatement<CheckZeroOperand<1>>>,
  382. // MOVI Vd, #0, LSL #0
  383. MCOpcodeSwitchCase<
  384. [MOVIv4i16, MOVIv8i16,
  385. MOVIv2i32, MOVIv4i32],
  386. MCReturnStatement<
  387. CheckAll<
  388. [CheckZeroOperand<1>,
  389. CheckZeroOperand<2>]>>>],
  390. MCReturnStatement<FalsePred>>>;
  391. def IsZeroFPIdiomPred : MCSchedPredicate<IsZeroFPIdiomFn>;
  392. // Identify an instruction that effectively resets a GP register to zero.
  393. def IsZeroIdiomFn : TIIPredicate<"isZeroIdiom",
  394. MCOpcodeSwitchStatement<
  395. [// ORR Rd, ZR, #0
  396. MCOpcodeSwitchCase<
  397. [ORRWri, ORRXri],
  398. MCReturnStatement<
  399. CheckAll<
  400. [CheckIsRegOperand<1>,
  401. CheckAny<
  402. [CheckRegOperand<1, WZR>,
  403. CheckRegOperand<1, XZR>]>,
  404. CheckZeroOperand<2>]>>>],
  405. MCReturnStatement<FalsePred>>>;
  406. def IsZeroIdiomPred : MCSchedPredicate<IsZeroIdiomFn>;