ARMScheduleA57.td 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  1. //=- ARMScheduleA57.td - ARM Cortex-A57 Scheduling 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. // This file defines the machine model for ARM Cortex-A57 to support
  10. // instruction scheduling and other instruction cost heuristics.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //===----------------------------------------------------------------------===//
  14. // *** Common description and scheduling model parameters taken from AArch64 ***
  15. // The Cortex-A57 is a traditional superscalar microprocessor with a
  16. // conservative 3-wide in-order stage for decode and dispatch. Combined with the
  17. // much wider out-of-order issue stage, this produced a need to carefully
  18. // schedule micro-ops so that all three decoded each cycle are successfully
  19. // issued as the reservation station(s) simply don't stay occupied for long.
  20. // Therefore, IssueWidth is set to the narrower of the two at three, while still
  21. // modeling the machine as out-of-order.
  22. def IsCPSRDefinedAndPredicated : CheckAll<[IsCPSRDefined, IsPredicated]>;
  23. def IsCPSRDefinedAndPredicatedPred :
  24. MCSchedPredicate<IsCPSRDefinedAndPredicated>;
  25. // Cortex A57 rev. r1p0 or later (false = r0px)
  26. def IsR1P0AndLaterPred : MCSchedPredicate<FalsePred>;
  27. def IsLdrAm3RegOffPred : MCSchedPredicate<CheckInvalidRegOperand<2>>;
  28. def IsLdrAm3RegOffPredX2 : MCSchedPredicate<CheckInvalidRegOperand<3>>;
  29. def IsLdrAm3RegOffPredX3 : MCSchedPredicate<CheckInvalidRegOperand<4>>;
  30. // If Addrmode3 contains "minus register"
  31. class Am3NegativeRegOffset<int n> : MCSchedPredicate<CheckAll<[
  32. CheckValidRegOperand<n>,
  33. CheckAM3OpSub<!add(n, 1)>]>>;
  34. def IsLdrAm3NegRegOffPred : Am3NegativeRegOffset<2>;
  35. def IsLdrAm3NegRegOffPredX2 : Am3NegativeRegOffset<3>;
  36. def IsLdrAm3NegRegOffPredX3 : Am3NegativeRegOffset<4>;
  37. // Load, scaled register offset, not plus LSL2
  38. class ScaledRegNotPlusLsl2<int n> : CheckNot<
  39. CheckAny<[
  40. CheckAM2NoShift<n>,
  41. CheckAll<[
  42. CheckAM2OpAdd<n>,
  43. CheckAM2ShiftLSL<n>,
  44. CheckAM2Offset<n, 2>
  45. ]>
  46. ]>
  47. >;
  48. def IsLdstsoScaledNotOptimalPredX0 : MCSchedPredicate<ScaledRegNotPlusLsl2<2>>;
  49. def IsLdstsoScaledNotOptimalPred : MCSchedPredicate<ScaledRegNotPlusLsl2<3>>;
  50. def IsLdstsoScaledNotOptimalPredX2 : MCSchedPredicate<ScaledRegNotPlusLsl2<4>>;
  51. def IsLdstsoScaledPredX2 : MCSchedPredicate<CheckNot<CheckAM2NoShift<4>>>;
  52. def IsLdstsoMinusRegPredX0 : MCSchedPredicate<CheckAM2OpSub<2>>;
  53. def IsLdstsoMinusRegPred : MCSchedPredicate<CheckAM2OpSub<3>>;
  54. def IsLdstsoMinusRegPredX2 : MCSchedPredicate<CheckAM2OpSub<4>>;
  55. class A57WriteLMOpsListType<list<SchedWriteRes> writes> {
  56. list <SchedWriteRes> Writes = writes;
  57. SchedMachineModel SchedModel = ?;
  58. }
  59. // *** Common description and scheduling model parameters taken from AArch64 ***
  60. // (AArch64SchedA57.td)
  61. def CortexA57Model : SchedMachineModel {
  62. let IssueWidth = 3; // 3-way decode and dispatch
  63. let MicroOpBufferSize = 128; // 128 micro-op re-order buffer
  64. let LoadLatency = 4; // Optimistic load latency
  65. let MispredictPenalty = 16; // Fetch + Decode/Rename/Dispatch + Branch
  66. // Enable partial & runtime unrolling.
  67. let LoopMicroOpBufferSize = 16;
  68. let CompleteModel = 1;
  69. // FIXME: Remove when all errors have been fixed.
  70. let FullInstRWOverlapCheck = 0;
  71. let UnsupportedFeatures = [HasV8_1MMainline, HasMVEInt, HasMVEFloat,
  72. HasFPRegsV8_1M, HasFP16FML, HasMatMulInt8, HasBF16];
  73. }
  74. //===----------------------------------------------------------------------===//
  75. // Define each kind of processor resource and number available on Cortex-A57.
  76. // Cortex A-57 has 8 pipelines that each has its own 8-entry queue where
  77. // micro-ops wait for their operands and then issue out-of-order.
  78. def A57UnitB : ProcResource<1>; // Type B micro-ops
  79. def A57UnitI : ProcResource<2>; // Type I micro-ops
  80. def A57UnitM : ProcResource<1>; // Type M micro-ops
  81. def A57UnitL : ProcResource<1>; // Type L micro-ops
  82. def A57UnitS : ProcResource<1>; // Type S micro-ops
  83. def A57UnitX : ProcResource<1>; // Type X micro-ops (F1)
  84. def A57UnitW : ProcResource<1>; // Type W micro-ops (F0)
  85. let SchedModel = CortexA57Model in {
  86. def A57UnitV : ProcResGroup<[A57UnitX, A57UnitW]>; // Type V micro-ops
  87. }
  88. let SchedModel = CortexA57Model in {
  89. //===----------------------------------------------------------------------===//
  90. // Define customized scheduler read/write types specific to the Cortex-A57.
  91. include "ARMScheduleA57WriteRes.td"
  92. // To have "CompleteModel = 1", support of pseudos and special instructions
  93. def : InstRW<[WriteNoop], (instregex "(t)?BKPT$", "(t2)?CDP(2)?$",
  94. "(t2)?CLREX$", "CONSTPOOL_ENTRY$", "COPY_STRUCT_BYVAL_I32$",
  95. "(t2)?CPS[123]p$", "(t2)?DBG$", "(t2)?DMB$", "(t2)?DSB$", "ERET$",
  96. "(t2|t)?HINT$", "(t)?HLT$", "(t2)?HVC$", "(t2)?ISB$", "ITasm$",
  97. "(t2)?RFE(DA|DB|IA|IB)", "(t)?SETEND", "(t2)?SETPAN", "(t2)?SMC", "SPACE",
  98. "(t2)?SRS(DA|DB|IA|IB)", "SWP(B)?", "t?TRAP", "(t2|t)?UDF$", "t2DCPS", "t2SG",
  99. "t2TT", "tCPS", "CMP_SWAP", "t?SVC", "t2IT", "CompilerBarrier",
  100. "t__brkdiv0")>;
  101. def : InstRW<[WriteNoop], (instregex "VMRS", "VMSR", "FMSTAT")>;
  102. // Specific memory instrs
  103. def : InstRW<[WriteNoop, WriteNoop], (instregex "(t2)?LDA", "(t2)?LDC", "(t2)?STC",
  104. "(t2)?STL", "(t2)?LDREX", "(t2)?STREX", "MEMCPY")>;
  105. // coprocessor moves
  106. def : InstRW<[WriteNoop, WriteNoop], (instregex
  107. "(t2)?MCR(2|R|R2)?$", "(t2)?MRC(2)?$",
  108. "(t2)?MRRC(2)?$", "(t2)?MRS(banked|sys|_AR|_M|sys_AR)?$",
  109. "(t2)?MSR(banked|i|_AR|_M)?$")>;
  110. // Deprecated instructions
  111. def : InstRW<[WriteNoop], (instregex "FLDM", "FSTM")>;
  112. // Pseudos
  113. def : InstRW<[WriteNoop], (instregex "(t2)?ABS$",
  114. "(t)?ADJCALLSTACKDOWN$", "(t)?ADJCALLSTACKUP$", "(t2|t)?Int_eh_sjlj",
  115. "tLDRpci_pic", "(t2)?SUBS_PC_LR",
  116. "JUMPTABLE", "tInt_WIN_eh_sjlj_longjmp",
  117. "VLD(1|2)LN(d|q)(WB_fixed_|WB_register_)?Asm",
  118. "VLD(3|4)(DUP|LN)?(d|q)(WB_fixed_|WB_register_)?Asm",
  119. "VST(1|2)LN(d|q)(WB_fixed_|WB_register_)?Asm",
  120. "VST(3|4)(DUP|LN)?(d|q)(WB_fixed_|WB_register_)?Asm",
  121. "WIN__CHKSTK", "WIN__DBZCHK")>;
  122. // Miscellaneous
  123. // -----------------------------------------------------------------------------
  124. def : InstRW<[A57Write_1cyc_1I], (instrs COPY)>;
  125. // --- 3.2 Branch Instructions ---
  126. // B, BX, BL, BLX (imm, reg != LR, reg == LR), CBZ, CBNZ
  127. def : InstRW<[A57Write_1cyc_1B], (instregex "(t2|t)?B$", "t?BX", "(t2|t)?Bcc$",
  128. "t?TAILJMP(d|r)", "TCRETURN(d|r)i", "tBfar", "tCBN?Z")>;
  129. def : InstRW<[A57Write_1cyc_1B_1I],
  130. (instregex "t?BL$", "BL_pred$", "t?BLXi", "t?TPsoft")>;
  131. def : InstRW<[A57Write_2cyc_1B_1I], (instregex "BLX", "tBLX(NS)?r")>;
  132. // Pseudos
  133. def : InstRW<[A57Write_2cyc_1B_1I], (instregex "BCCi64", "BCCZi64")>;
  134. def : InstRW<[A57Write_3cyc_1B_1I], (instregex "BR_JTadd", "t?BR_JTr",
  135. "t2BR_JT", "t2BXJ", "(t2)?TB(B|H)(_JT)?$", "tBRIND")>;
  136. def : InstRW<[A57Write_6cyc_1B_1L], (instregex "BR_JTm")>;
  137. // --- 3.3 Arithmetic and Logical Instructions ---
  138. // ADD{S}, ADC{S}, ADR, AND{S}, BIC{S}, CMN, CMP, EOR{S}, ORN{S}, ORR{S},
  139. // RSB{S}, RSC{S}, SUB{S}, SBC{S}, TEQ, TST
  140. def : InstRW<[A57Write_1cyc_1I], (instregex "tADDframe")>;
  141. // Check branch forms of ALU ops:
  142. // check reg 0 for ARM_AM::PC
  143. // if so adds 2 cyc to latency, 1 uop, 1 res cycle for A57UnitB
  144. class A57BranchForm<SchedWriteRes non_br> :
  145. BranchWriteRes<2, 1, [A57UnitB], [1], non_br>;
  146. // shift by register, conditional or unconditional
  147. // TODO: according to the doc, conditional uses I0/I1, unconditional uses M
  148. // Why more complex instruction uses more simple pipeline?
  149. // May be an error in doc.
  150. def A57WriteALUsr : SchedWriteVariant<[
  151. SchedVar<IsPredicatedPred, [CheckBranchForm<0, A57BranchForm<A57Write_2cyc_1I>>]>,
  152. SchedVar<NoSchedPred, [CheckBranchForm<0, A57BranchForm<A57Write_2cyc_1M>>]>
  153. ]>;
  154. def A57WriteALUSsr : SchedWriteVariant<[
  155. SchedVar<IsPredicatedPred, [CheckBranchForm<0, A57BranchForm<A57Write_2cyc_1I>>]>,
  156. SchedVar<NoSchedPred, [CheckBranchForm<0, A57BranchForm<A57Write_2cyc_1M>>]>
  157. ]>;
  158. def A57ReadALUsr : SchedReadVariant<[
  159. SchedVar<IsPredicatedPred, [ReadDefault]>,
  160. SchedVar<NoSchedPred, [ReadDefault]>
  161. ]>;
  162. def : SchedAlias<WriteALUsi, CheckBranchForm<0, A57BranchForm<A57Write_2cyc_1M>>>;
  163. def : SchedAlias<WriteALUsr, A57WriteALUsr>;
  164. def : SchedAlias<WriteALUSsr, A57WriteALUSsr>;
  165. def : SchedAlias<ReadALUsr, A57ReadALUsr>;
  166. def A57WriteCMPsr : SchedWriteVariant<[
  167. SchedVar<IsPredicatedPred, [A57Write_2cyc_1I]>,
  168. SchedVar<NoSchedPred, [A57Write_2cyc_1M]>
  169. ]>;
  170. def : SchedAlias<WriteCMP, A57Write_1cyc_1I>;
  171. def : SchedAlias<WriteCMPsi, A57Write_2cyc_1M>;
  172. def : SchedAlias<WriteCMPsr, A57WriteCMPsr>;
  173. // --- 3.4 Move and Shift Instructions ---
  174. // Move, basic
  175. // MOV{S}, MOVW, MVN{S}
  176. def : InstRW<[A57Write_1cyc_1I], (instregex "MOV(r|i|i16|r_TC)",
  177. "(t2)?MVN(CC)?(r|i)", "BMOVPCB_CALL", "BMOVPCRX_CALL",
  178. "MOVCC(r|i|i16|i32imm)", "tMOV", "tMVN")>;
  179. // Move, shift by immed, setflags/no setflags
  180. // (ASR, LSL, LSR, ROR, RRX)=MOVsi, MVN
  181. // setflags = isCPSRDefined
  182. def A57WriteMOVsi : SchedWriteVariant<[
  183. SchedVar<IsCPSRDefinedPred, [A57Write_2cyc_1M]>,
  184. SchedVar<NoSchedPred, [A57Write_1cyc_1I]>
  185. ]>;
  186. def : InstRW<[A57WriteMOVsi], (instregex "MOV(CC)?si", "MVNsi",
  187. "ASRi", "(t2|t)ASRri", "LSRi", "(t2|t)LSRri", "LSLi", "(t2|t)LSLri", "RORi",
  188. "(t2|t)RORri", "(t2)?RRX", "t2MOV", "tROR")>;
  189. // shift by register, conditional or unconditional, setflags/no setflags
  190. def A57WriteMOVsr : SchedWriteVariant<[
  191. SchedVar<IsCPSRDefinedAndPredicatedPred, [A57Write_2cyc_1I]>,
  192. SchedVar<IsCPSRDefinedPred, [A57Write_2cyc_1M]>,
  193. SchedVar<IsPredicatedPred, [A57Write_2cyc_1I]>,
  194. SchedVar<NoSchedPred, [A57Write_1cyc_1I]>
  195. ]>;
  196. def : InstRW<[A57WriteMOVsr], (instregex "MOV(CC)?sr", "MVNsr", "t2MVNs",
  197. "ASRr", "(t2|t)ASRrr", "LSRr", "(t2|t)LSRrr", "LSLr", "(t2|t)?LSLrr", "RORr",
  198. "(t2|t)RORrr")>;
  199. // Move, top
  200. // MOVT - A57Write_2cyc_1M for r0px, A57Write_1cyc_1I for r1p0 and later
  201. def A57WriteMOVT : SchedWriteVariant<[
  202. SchedVar<IsR1P0AndLaterPred, [A57Write_1cyc_1I]>,
  203. SchedVar<NoSchedPred, [A57Write_2cyc_1M]>
  204. ]>;
  205. def : InstRW<[A57WriteMOVT], (instregex "MOVTi16")>;
  206. def A57WriteI2pc :
  207. WriteSequence<[A57Write_1cyc_1I, A57Write_1cyc_1I, A57Write_1cyc_1I]>;
  208. def A57WriteI2ld :
  209. WriteSequence<[A57Write_1cyc_1I, A57Write_1cyc_1I, A57Write_4cyc_1L]>;
  210. def : InstRW< [A57WriteI2pc], (instregex "MOV_ga_pcrel")>;
  211. def : InstRW< [A57WriteI2ld], (instregex "MOV_ga_pcrel_ldr")>;
  212. // +2cyc for branch forms
  213. def : InstRW<[A57Write_3cyc_1I], (instregex "MOVPC(LR|RX)")>;
  214. // --- 3.5 Divide and Multiply Instructions ---
  215. // Divide: SDIV, UDIV
  216. // latency from documentration: 4 ­‐ 20, maximum taken
  217. def : SchedAlias<WriteDIV, A57Write_20cyc_1M>;
  218. // Multiply: tMul not bound to common WriteRes types
  219. def : InstRW<[A57Write_3cyc_1M], (instregex "tMUL")>;
  220. def : SchedAlias<WriteMUL16, A57Write_3cyc_1M>;
  221. def : SchedAlias<WriteMUL32, A57Write_3cyc_1M>;
  222. def : ReadAdvance<ReadMUL, 0>;
  223. // Multiply accumulate: MLA, MLS, SMLABB, SMLABT, SMLATB, SMLATT, SMLAWB,
  224. // SMLAWT, SMLAD{X}, SMLSD{X}, SMMLA{R}, SMMLS{R}
  225. // Multiply-accumulate pipelines support late-forwarding of accumulate operands
  226. // from similar μops, allowing a typical sequence of multiply-accumulate μops
  227. // to issue one every 1 cycle (sched advance = 2).
  228. def A57WriteMLA : SchedWriteRes<[A57UnitM]> { let Latency = 3; }
  229. def A57WriteMLAL : SchedWriteVariant<[
  230. SchedVar<IsCPSRDefinedPred, [A57Write_5cyc_1I_1M]>,
  231. SchedVar<NoSchedPred, [A57Write_4cyc_1M]>
  232. ]>;
  233. def A57ReadMLA : SchedReadAdvance<2, [A57WriteMLA, A57WriteMLAL]>;
  234. def : InstRW<[A57WriteMLA],
  235. (instregex "t2SMLAD", "t2SMLADX", "t2SMLSD", "t2SMLSDX")>;
  236. def : SchedAlias<WriteMAC16, A57WriteMLA>;
  237. def : SchedAlias<WriteMAC32, A57WriteMLA>;
  238. def : SchedAlias<ReadMAC, A57ReadMLA>;
  239. def : SchedAlias<WriteMAC64Lo, A57WriteMLAL>;
  240. def : SchedAlias<WriteMAC64Hi, A57WriteMLAL>;
  241. // Multiply long: SMULL, UMULL
  242. def : SchedAlias<WriteMUL64Lo, A57Write_4cyc_1M>;
  243. def : SchedAlias<WriteMUL64Hi, A57Write_4cyc_1M>;
  244. // --- 3.6 Saturating and Parallel Arithmetic Instructions ---
  245. // Parallel arith
  246. // SADD16, SADD8, SSUB16, SSUB8, UADD16, UADD8, USUB16, USUB8
  247. // Conditional GE-setting instructions require three extra μops
  248. // and two additional cycles to conditionally update the GE field.
  249. def A57WriteParArith : SchedWriteVariant<[
  250. SchedVar<IsPredicatedPred, [A57Write_4cyc_1I_1M]>,
  251. SchedVar<NoSchedPred, [A57Write_2cyc_1I_1M]>
  252. ]>;
  253. def : InstRW< [A57WriteParArith], (instregex
  254. "(t2)?SADD(16|8)", "(t2)?SSUB(16|8)",
  255. "(t2)?UADD(16|8)", "(t2)?USUB(16|8)")>;
  256. // Parallel arith with exchange: SASX, SSAX, UASX, USAX
  257. def A57WriteParArithExch : SchedWriteVariant<[
  258. SchedVar<IsPredicatedPred, [A57Write_5cyc_1I_1M]>,
  259. SchedVar<NoSchedPred, [A57Write_3cyc_1I_1M]>
  260. ]>;
  261. def : InstRW<[A57WriteParArithExch],
  262. (instregex "(t2)?SASX", "(t2)?SSAX", "(t2)?UASX", "(t2)?USAX")>;
  263. // Parallel halving arith
  264. // SHADD16, SHADD8, SHSUB16, SHSUB8, UHADD16, UHADD8, UHSUB16, UHSUB8
  265. def : InstRW<[A57Write_2cyc_1M], (instregex
  266. "(t2)?SHADD(16|8)", "(t2)?SHSUB(16|8)",
  267. "(t2)?UHADD(16|8)", "(t2)?UHSUB(16|8)")>;
  268. // Parallel halving arith with exchange
  269. // SHASX, SHSAX, UHASX, UHSAX
  270. def : InstRW<[A57Write_3cyc_1I_1M], (instregex "(t2)?SHASX", "(t2)?SHSAX",
  271. "(t2)?UHASX", "(t2)?UHSAX")>;
  272. // Parallel saturating arith
  273. // QADD16, QADD8, QSUB16, QSUB8, UQADD16, UQADD8, UQSUB16, UQSUB8
  274. def : InstRW<[A57Write_2cyc_1M], (instregex "QADD(16|8)", "QSUB(16|8)",
  275. "UQADD(16|8)", "UQSUB(16|8)", "t2(U?)QADD", "t2(U?)QSUB")>;
  276. // Parallel saturating arith with exchange
  277. // QASX, QSAX, UQASX, UQSAX
  278. def : InstRW<[A57Write_3cyc_1I_1M], (instregex "(t2)?QASX", "(t2)?QSAX",
  279. "(t2)?UQASX", "(t2)?UQSAX")>;
  280. // Saturate: SSAT, SSAT16, USAT, USAT16
  281. def : InstRW<[A57Write_2cyc_1M],
  282. (instregex "(t2)?SSAT(16)?", "(t2)?USAT(16)?")>;
  283. // Saturating arith: QADD, QSUB
  284. def : InstRW<[A57Write_2cyc_1M], (instregex "QADD$", "QSUB$")>;
  285. // Saturating doubling arith: QDADD, QDSUB
  286. def : InstRW<[A57Write_3cyc_1I_1M], (instregex "(t2)?QDADD", "(t2)?QDSUB")>;
  287. // --- 3.7 Miscellaneous Data-Processing Instructions ---
  288. // Bit field extract: SBFX, UBFX
  289. def : InstRW<[A57Write_1cyc_1I], (instregex "(t2)?SBFX", "(t2)?UBFX")>;
  290. // Bit field insert/clear: BFI, BFC
  291. def : InstRW<[A57Write_2cyc_1M], (instregex "(t2)?BFI", "(t2)?BFC")>;
  292. // Select bytes, conditional/unconditional
  293. def A57WriteSEL : SchedWriteVariant<[
  294. SchedVar<IsPredicatedPred, [A57Write_2cyc_1I]>,
  295. SchedVar<NoSchedPred, [A57Write_1cyc_1I]>
  296. ]>;
  297. def : InstRW<[A57WriteSEL], (instregex "(t2)?SEL")>;
  298. // Sign/zero extend, normal: SXTB, SXTH, UXTB, UXTH
  299. def : InstRW<[A57Write_1cyc_1I],
  300. (instregex "(t2|t)?SXT(B|H)$", "(t2|t)?UXT(B|H)$")>;
  301. // Sign/zero extend and add, normal: SXTAB, SXTAH, UXTAB, UXTAH
  302. def : InstRW<[A57Write_2cyc_1M],
  303. (instregex "(t2)?SXTA(B|H)$", "(t2)?UXTA(B|H)$")>;
  304. // Sign/zero extend and add, parallel: SXTAB16, UXTAB16
  305. def : InstRW<[A57Write_4cyc_1M], (instregex "(t2)?SXTAB16", "(t2)?UXTAB16")>;
  306. // Sum of absolute differences: USAD8, USADA8
  307. def : InstRW<[A57Write_3cyc_1M], (instregex "(t2)?USAD8", "(t2)?USADA8")>;
  308. // --- 3.8 Load Instructions ---
  309. // Load, immed offset
  310. // LDR and LDRB have LDRi12 and LDRBi12 forms for immediate
  311. def : InstRW<[A57Write_4cyc_1L], (instregex "LDRi12", "LDRBi12",
  312. "LDRcp", "(t2|t)?LDRConstPool", "LDRLIT_ga_(pcrel|abs)",
  313. "PICLDR", "tLDR")>;
  314. def : InstRW<[A57Write_4cyc_1L],
  315. (instregex "t2LDRS?(B|H)?(pcrel|T|i8|i12|pci|pci_pic|s)?$")>;
  316. // For "Load, register offset, minus" we need +1cyc, +1I
  317. def A57WriteLdrAm3 : SchedWriteVariant<[
  318. SchedVar<IsLdrAm3NegRegOffPred, [A57Write_5cyc_1I_1L]>,
  319. SchedVar<NoSchedPred, [A57Write_4cyc_1L]>
  320. ]>;
  321. def : InstRW<[A57WriteLdrAm3], (instregex "LDR(H|SH|SB)$")>;
  322. def A57WriteLdrAm3X2 : SchedWriteVariant<[
  323. SchedVar<IsLdrAm3NegRegOffPredX2, [A57Write_5cyc_1I_1L]>,
  324. SchedVar<NoSchedPred, [A57Write_4cyc_1L]>
  325. ]>;
  326. def : InstRW<[A57WriteLdrAm3X2, A57WriteLdrAm3X2], (instregex "LDRD$")>;
  327. def : InstRW<[A57Write_4cyc_1L, A57Write_4cyc_1L], (instregex "t2LDRDi8")>;
  328. def A57WriteLdrAmLDSTSO : SchedWriteVariant<[
  329. SchedVar<IsLdstsoScaledNotOptimalPred, [A57Write_5cyc_1I_1L]>,
  330. SchedVar<IsLdstsoMinusRegPred, [A57Write_5cyc_1I_1L]>,
  331. SchedVar<NoSchedPred, [A57Write_4cyc_1L]>
  332. ]>;
  333. def : InstRW<[A57WriteLdrAmLDSTSO], (instregex "LDRrs", "LDRBrs")>;
  334. def A57WrBackOne : SchedWriteRes<[]> {
  335. let Latency = 1;
  336. let NumMicroOps = 0;
  337. }
  338. def A57WrBackTwo : SchedWriteRes<[]> {
  339. let Latency = 2;
  340. let NumMicroOps = 0;
  341. }
  342. def A57WrBackThree : SchedWriteRes<[]> {
  343. let Latency = 3;
  344. let NumMicroOps = 0;
  345. }
  346. // --- LDR pre-indexed ---
  347. // Load, immed pre-indexed (4 cyc for load result, 1 cyc for Base update)
  348. def : InstRW<[A57Write_4cyc_1L_1I, A57WrBackOne], (instregex "LDR_PRE_IMM",
  349. "LDRB_PRE_IMM", "t2LDRB_PRE")>;
  350. // Load, register pre-indexed (4 cyc for load result, 2 cyc for Base update)
  351. // (5 cyc load result for not-lsl2 scaled)
  352. def A57WriteLdrAmLDSTSOPre : SchedWriteVariant<[
  353. SchedVar<IsLdstsoScaledNotOptimalPredX2, [A57Write_5cyc_1I_1L]>,
  354. SchedVar<NoSchedPred, [A57Write_4cyc_1L_1I]>
  355. ]>;
  356. def : InstRW<[A57WriteLdrAmLDSTSOPre, A57WrBackTwo],
  357. (instregex "LDR_PRE_REG", "LDRB_PRE_REG")>;
  358. def A57WriteLdrAm3PreWrBack : SchedWriteVariant<[
  359. SchedVar<IsLdrAm3RegOffPredX2, [A57WrBackTwo]>,
  360. SchedVar<NoSchedPred, [A57WrBackOne]>
  361. ]>;
  362. def : InstRW<[A57Write_4cyc_1L, A57WriteLdrAm3PreWrBack],
  363. (instregex "LDR(H|SH|SB)_PRE")>;
  364. def : InstRW<[A57Write_4cyc_1L, A57WrBackOne],
  365. (instregex "t2LDR(H|SH|SB)?_PRE")>;
  366. // LDRD pre-indexed: 5(2) cyc for reg, 4(1) cyc for imm.
  367. def A57WriteLdrDAm3Pre : SchedWriteVariant<[
  368. SchedVar<IsLdrAm3RegOffPredX3, [A57Write_5cyc_1I_1L]>,
  369. SchedVar<NoSchedPred, [A57Write_4cyc_1L_1I]>
  370. ]>;
  371. def A57WriteLdrDAm3PreWrBack : SchedWriteVariant<[
  372. SchedVar<IsLdrAm3RegOffPredX3, [A57WrBackTwo]>,
  373. SchedVar<NoSchedPred, [A57WrBackOne]>
  374. ]>;
  375. def : InstRW<[A57WriteLdrDAm3Pre, A57WriteLdrDAm3Pre, A57WriteLdrDAm3PreWrBack],
  376. (instregex "LDRD_PRE")>;
  377. def : InstRW<[A57Write_4cyc_1L_1I, A57Write_4cyc_1L_1I, A57WrBackOne],
  378. (instregex "t2LDRD_PRE")>;
  379. // --- LDR post-indexed ---
  380. def : InstRW<[A57Write_4cyc_1L_1I, A57WrBackOne], (instregex "LDR(T?)_POST_IMM",
  381. "LDRB(T?)_POST_IMM", "LDR(SB|H|SH)Ti", "t2LDRB_POST")>;
  382. def A57WriteLdrAm3PostWrBack : SchedWriteVariant<[
  383. SchedVar<IsLdrAm3RegOffPred, [A57WrBackTwo]>,
  384. SchedVar<NoSchedPred, [A57WrBackOne]>
  385. ]>;
  386. def : InstRW<[A57Write_4cyc_1L_1I, A57WriteLdrAm3PostWrBack],
  387. (instregex "LDR(H|SH|SB)_POST")>;
  388. def : InstRW<[A57Write_4cyc_1L, A57WrBackOne],
  389. (instregex "t2LDR(H|SH|SB)?_POST")>;
  390. def : InstRW<[A57Write_4cyc_1L_1I, A57WrBackTwo], (instregex "LDR_POST_REG",
  391. "LDRB_POST_REG", "LDR(B?)T_POST$")>;
  392. def A57WriteLdrTRegPost : SchedWriteVariant<[
  393. SchedVar<IsLdstsoScaledPredX2, [A57Write_4cyc_1I_1L_1M]>,
  394. SchedVar<NoSchedPred, [A57Write_4cyc_1L_1I]>
  395. ]>;
  396. def A57WriteLdrTRegPostWrBack : SchedWriteVariant<[
  397. SchedVar<IsLdstsoScaledPredX2, [A57WrBackThree]>,
  398. SchedVar<NoSchedPred, [A57WrBackTwo]>
  399. ]>;
  400. // 4(3) "I0/I1,L,M" for scaled register, otherwise 4(2) "I0/I1,L"
  401. def : InstRW<[A57WriteLdrTRegPost, A57WriteLdrTRegPostWrBack],
  402. (instregex "LDRT_POST_REG", "LDRBT_POST_REG")>;
  403. def : InstRW<[A57Write_4cyc_1L_1I, A57WrBackTwo], (instregex "LDR(SB|H|SH)Tr")>;
  404. def A57WriteLdrAm3PostWrBackX3 : SchedWriteVariant<[
  405. SchedVar<IsLdrAm3RegOffPredX3, [A57WrBackTwo]>,
  406. SchedVar<NoSchedPred, [A57WrBackOne]>
  407. ]>;
  408. // LDRD post-indexed: 4(2) cyc for reg, 4(1) cyc for imm.
  409. def : InstRW<[A57Write_4cyc_1L_1I, A57Write_4cyc_1L_1I,
  410. A57WriteLdrAm3PostWrBackX3], (instregex "LDRD_POST")>;
  411. def : InstRW<[A57Write_4cyc_1L_1I, A57Write_4cyc_1L_1I, A57WrBackOne],
  412. (instregex "t2LDRD_POST")>;
  413. // --- Preload instructions ---
  414. // Preload, immed offset
  415. def : InstRW<[A57Write_4cyc_1L], (instregex "(t2)?PLDi12", "(t2)?PLDWi12",
  416. "t2PLDW?(i8|pci|s)", "(t2)?PLI")>;
  417. // Preload, register offset,
  418. // 5cyc "I0/I1,L" for minus reg or scaled not plus lsl2
  419. // otherwise 4cyc "L"
  420. def A57WritePLD : SchedWriteVariant<[
  421. SchedVar<IsLdstsoScaledNotOptimalPredX0, [A57Write_5cyc_1I_1L]>,
  422. SchedVar<IsLdstsoMinusRegPredX0, [A57Write_5cyc_1I_1L]>,
  423. SchedVar<NoSchedPred, [A57Write_4cyc_1L]>
  424. ]>;
  425. def : InstRW<[A57WritePLD], (instregex "PLDrs", "PLDWrs")>;
  426. // --- Load multiple instructions ---
  427. foreach NumAddr = 1-8 in {
  428. def A57LMAddrPred#NumAddr : MCSchedPredicate<CheckAny<[
  429. CheckNumOperands<!add(!shl(NumAddr, 1), 2)>,
  430. CheckNumOperands<!add(!shl(NumAddr, 1), 3)>]>>;
  431. def A57LMAddrUpdPred#NumAddr : MCSchedPredicate<CheckAny<[
  432. CheckNumOperands<!add(!shl(NumAddr, 1), 3)>,
  433. CheckNumOperands<!add(!shl(NumAddr, 1), 4)>]>>;
  434. }
  435. def A57LDMOpsListNoregin : A57WriteLMOpsListType<
  436. [A57Write_3cyc_1L, A57Write_3cyc_1L,
  437. A57Write_4cyc_1L, A57Write_4cyc_1L,
  438. A57Write_5cyc_1L, A57Write_5cyc_1L,
  439. A57Write_6cyc_1L, A57Write_6cyc_1L,
  440. A57Write_7cyc_1L, A57Write_7cyc_1L,
  441. A57Write_8cyc_1L, A57Write_8cyc_1L,
  442. A57Write_9cyc_1L, A57Write_9cyc_1L,
  443. A57Write_10cyc_1L, A57Write_10cyc_1L]>;
  444. def A57WriteLDMnoreginlist : SchedWriteVariant<[
  445. SchedVar<A57LMAddrPred1, A57LDMOpsListNoregin.Writes[0-1]>,
  446. SchedVar<A57LMAddrPred2, A57LDMOpsListNoregin.Writes[0-3]>,
  447. SchedVar<A57LMAddrPred3, A57LDMOpsListNoregin.Writes[0-5]>,
  448. SchedVar<A57LMAddrPred4, A57LDMOpsListNoregin.Writes[0-7]>,
  449. SchedVar<A57LMAddrPred5, A57LDMOpsListNoregin.Writes[0-9]>,
  450. SchedVar<A57LMAddrPred6, A57LDMOpsListNoregin.Writes[0-11]>,
  451. SchedVar<A57LMAddrPred7, A57LDMOpsListNoregin.Writes[0-13]>,
  452. SchedVar<A57LMAddrPred8, A57LDMOpsListNoregin.Writes[0-15]>,
  453. SchedVar<NoSchedPred, A57LDMOpsListNoregin.Writes[0-15]>
  454. ]> { let Variadic=1; }
  455. def A57LDMOpsListRegin : A57WriteLMOpsListType<
  456. [A57Write_4cyc_1L_1I, A57Write_4cyc_1L_1I,
  457. A57Write_5cyc_1L_1I, A57Write_5cyc_1L_1I,
  458. A57Write_6cyc_1L_1I, A57Write_6cyc_1L_1I,
  459. A57Write_7cyc_1L_1I, A57Write_7cyc_1L_1I,
  460. A57Write_8cyc_1L_1I, A57Write_8cyc_1L_1I,
  461. A57Write_9cyc_1L_1I, A57Write_9cyc_1L_1I,
  462. A57Write_10cyc_1L_1I, A57Write_10cyc_1L_1I,
  463. A57Write_11cyc_1L_1I, A57Write_11cyc_1L_1I]>;
  464. def A57WriteLDMreginlist : SchedWriteVariant<[
  465. SchedVar<A57LMAddrPred1, A57LDMOpsListRegin.Writes[0-1]>,
  466. SchedVar<A57LMAddrPred2, A57LDMOpsListRegin.Writes[0-3]>,
  467. SchedVar<A57LMAddrPred3, A57LDMOpsListRegin.Writes[0-5]>,
  468. SchedVar<A57LMAddrPred4, A57LDMOpsListRegin.Writes[0-7]>,
  469. SchedVar<A57LMAddrPred5, A57LDMOpsListRegin.Writes[0-9]>,
  470. SchedVar<A57LMAddrPred6, A57LDMOpsListRegin.Writes[0-11]>,
  471. SchedVar<A57LMAddrPred7, A57LDMOpsListRegin.Writes[0-13]>,
  472. SchedVar<A57LMAddrPred8, A57LDMOpsListRegin.Writes[0-15]>,
  473. SchedVar<NoSchedPred, A57LDMOpsListRegin.Writes[0-15]>
  474. ]> { let Variadic=1; }
  475. def A57LDMOpsList_Upd : A57WriteLMOpsListType<
  476. [A57WrBackOne,
  477. A57Write_3cyc_1L_1I, A57Write_3cyc_1L_1I,
  478. A57Write_4cyc_1L_1I, A57Write_4cyc_1L_1I,
  479. A57Write_5cyc_1L_1I, A57Write_5cyc_1L_1I,
  480. A57Write_6cyc_1L_1I, A57Write_6cyc_1L_1I,
  481. A57Write_7cyc_1L_1I, A57Write_7cyc_1L_1I,
  482. A57Write_8cyc_1L_1I, A57Write_8cyc_1L_1I,
  483. A57Write_9cyc_1L_1I, A57Write_9cyc_1L_1I,
  484. A57Write_10cyc_1L_1I, A57Write_10cyc_1L_1I]>;
  485. def A57WriteLDM_Upd : SchedWriteVariant<[
  486. SchedVar<A57LMAddrUpdPred1, A57LDMOpsList_Upd.Writes[0-2]>,
  487. SchedVar<A57LMAddrUpdPred2, A57LDMOpsList_Upd.Writes[0-4]>,
  488. SchedVar<A57LMAddrUpdPred3, A57LDMOpsList_Upd.Writes[0-6]>,
  489. SchedVar<A57LMAddrUpdPred4, A57LDMOpsList_Upd.Writes[0-8]>,
  490. SchedVar<A57LMAddrUpdPred5, A57LDMOpsList_Upd.Writes[0-10]>,
  491. SchedVar<A57LMAddrUpdPred6, A57LDMOpsList_Upd.Writes[0-12]>,
  492. SchedVar<A57LMAddrUpdPred7, A57LDMOpsList_Upd.Writes[0-14]>,
  493. SchedVar<A57LMAddrUpdPred8, A57LDMOpsList_Upd.Writes[0-16]>,
  494. SchedVar<NoSchedPred, A57LDMOpsList_Upd.Writes[0-16]>
  495. ]> { let Variadic=1; }
  496. def A57WriteLDM : SchedWriteVariant<[
  497. SchedVar<IsLDMBaseRegInListPred, [A57WriteLDMreginlist]>,
  498. SchedVar<NoSchedPred, [A57WriteLDMnoreginlist]>
  499. ]> { let Variadic=1; }
  500. def : InstRW<[A57WriteLDM], (instregex "(t|t2|sys)?LDM(IA|DA|DB|IB)$")>;
  501. // TODO: no writeback latency defined in documentation (implemented as 1 cyc)
  502. def : InstRW<[A57WriteLDM_Upd],
  503. (instregex "(t|t2|sys)?LDM(IA_UPD|DA_UPD|DB_UPD|IB_UPD|IA_RET)", "tPOP")>;
  504. def : InstRW<[A57Write_5cyc_1L], (instregex "VLLDM")>;
  505. // --- 3.9 Store Instructions ---
  506. // Store, immed offset
  507. def : InstRW<[A57Write_1cyc_1S], (instregex "STRi12", "STRBi12", "PICSTR",
  508. "t2STR(B?)(T|i12|i8|s)", "t2STRDi8", "t2STRH(i12|i8|s)", "tSTR")>;
  509. // Store, register offset
  510. // For minus or for not plus lsl2 scaled we need 3cyc "I0/I1, S",
  511. // otherwise 1cyc S.
  512. def A57WriteStrAmLDSTSO : SchedWriteVariant<[
  513. SchedVar<IsLdstsoScaledNotOptimalPred, [A57Write_3cyc_1I_1S]>,
  514. SchedVar<IsLdstsoMinusRegPred, [A57Write_3cyc_1I_1S]>,
  515. SchedVar<NoSchedPred, [A57Write_1cyc_1S]>
  516. ]>;
  517. def : InstRW<[A57WriteStrAmLDSTSO], (instregex "STRrs", "STRBrs")>;
  518. // STRH,STRD: 3cyc "I0/I1, S" for minus reg, 1cyc S for imm or for plus reg.
  519. def A57WriteStrAm3 : SchedWriteVariant<[
  520. SchedVar<IsLdrAm3NegRegOffPred, [A57Write_3cyc_1I_1S]>,
  521. SchedVar<NoSchedPred, [A57Write_1cyc_1S]>
  522. ]>;
  523. def : InstRW<[A57WriteStrAm3], (instregex "STRH$")>;
  524. def A57WriteStrAm3X2 : SchedWriteVariant<[
  525. SchedVar<IsLdrAm3NegRegOffPredX2, [A57Write_3cyc_1I_1S]>,
  526. SchedVar<NoSchedPred, [A57Write_1cyc_1S]>
  527. ]>;
  528. def : InstRW<[A57WriteStrAm3X2], (instregex "STRD$")>;
  529. // Store, immed pre-indexed (1cyc "S, I0/I1", 1cyc writeback)
  530. def : InstRW<[A57WrBackOne, A57Write_1cyc_1S_1I], (instregex "STR_PRE_IMM",
  531. "STRB_PRE_IMM", "STR(B)?(r|i)_preidx", "(t2)?STRH_(preidx|PRE)",
  532. "t2STR(B?)_(PRE|preidx)", "t2STRD_PRE")>;
  533. // Store, register pre-indexed:
  534. // 1(1) "S, I0/I1" for plus reg
  535. // 3(2) "I0/I1, S" for minus reg
  536. // 1(2) "S, M" for scaled plus lsl2
  537. // 3(2) "I0/I1, S" for other scaled
  538. def A57WriteStrAmLDSTSOPre : SchedWriteVariant<[
  539. SchedVar<IsLdstsoScaledNotOptimalPredX2, [A57Write_3cyc_1I_1S]>,
  540. SchedVar<IsLdstsoMinusRegPredX2, [A57Write_3cyc_1I_1S]>,
  541. SchedVar<IsLdstsoScaledPredX2, [A57Write_1cyc_1S_1M]>,
  542. SchedVar<NoSchedPred, [A57Write_1cyc_1S_1I]>
  543. ]>;
  544. def A57WriteStrAmLDSTSOPreWrBack : SchedWriteVariant<[
  545. SchedVar<IsLdstsoScaledPredX2, [A57WrBackTwo]>,
  546. SchedVar<IsLdstsoMinusRegPredX2, [A57WrBackTwo]>,
  547. SchedVar<NoSchedPred, [A57WrBackOne]>
  548. ]>;
  549. def : InstRW<[A57WriteStrAmLDSTSOPreWrBack, A57WriteStrAmLDSTSOPre],
  550. (instregex "STR_PRE_REG", "STRB_PRE_REG")>;
  551. // pre-indexed STRH/STRD (STRH_PRE, STRD_PRE)
  552. // 1(1) "S, I0/I1" for imm or reg plus
  553. // 3(2) "I0/I1, S" for reg minus
  554. def A57WriteStrAm3PreX2 : SchedWriteVariant<[
  555. SchedVar<IsLdrAm3NegRegOffPredX2, [A57Write_3cyc_1I_1S]>,
  556. SchedVar<NoSchedPred, [A57Write_1cyc_1S_1I]>
  557. ]>;
  558. def A57WriteStrAm3PreWrBackX2 : SchedWriteVariant<[
  559. SchedVar<IsLdrAm3NegRegOffPredX2, [A57WrBackTwo]>,
  560. SchedVar<NoSchedPred, [A57WrBackOne]>
  561. ]>;
  562. def : InstRW<[A57WriteStrAm3PreWrBackX2, A57WriteStrAm3PreX2],
  563. (instregex "STRH_PRE")>;
  564. def A57WriteStrAm3PreX3 : SchedWriteVariant<[
  565. SchedVar<IsLdrAm3NegRegOffPredX3, [A57Write_3cyc_1I_1S]>,
  566. SchedVar<NoSchedPred, [A57Write_1cyc_1S_1I]>
  567. ]>;
  568. def A57WriteStrAm3PreWrBackX3 : SchedWriteVariant<[
  569. SchedVar<IsLdrAm3NegRegOffPredX3, [A57WrBackTwo]>,
  570. SchedVar<NoSchedPred, [A57WrBackOne]>
  571. ]>;
  572. def : InstRW<[A57WriteStrAm3PreWrBackX3, A57WriteStrAm3PreX3],
  573. (instregex "STRD_PRE")>;
  574. def : InstRW<[A57WrBackOne, A57Write_1cyc_1S_1I], (instregex "STR(T?)_POST_IMM",
  575. "STRB(T?)_POST_IMM", "t2STR(B?)_POST")>;
  576. // 1(2) "S, M" for STR/STRB register post-indexed (both scaled or not)
  577. def : InstRW<[A57WrBackTwo, A57Write_1cyc_1S_1M], (instregex "STR(T?)_POST_REG",
  578. "STRB(T?)_POST_REG", "STR(B?)T_POST$")>;
  579. // post-indexed STRH/STRD(STRH_POST, STRD_POST), STRHTi, STRHTr
  580. // 1(1) "S, I0/I1" both for reg or imm
  581. def : InstRW<[A57WrBackOne, A57Write_1cyc_1S_1I],
  582. (instregex "(t2)?STR(H|D)_POST", "STRHT(i|r)", "t2STRHT")>;
  583. // --- Store multiple instructions ---
  584. // TODO: no writeback latency defined in documentation
  585. def A57WriteSTM : SchedWriteVariant<[
  586. SchedVar<A57LMAddrPred1, [A57Write_1cyc_1S]>,
  587. SchedVar<A57LMAddrPred2, [A57Write_2cyc_1S]>,
  588. SchedVar<A57LMAddrPred3, [A57Write_3cyc_1S]>,
  589. SchedVar<A57LMAddrPred4, [A57Write_4cyc_1S]>,
  590. SchedVar<A57LMAddrPred5, [A57Write_5cyc_1S]>,
  591. SchedVar<A57LMAddrPred6, [A57Write_6cyc_1S]>,
  592. SchedVar<A57LMAddrPred7, [A57Write_7cyc_1S]>,
  593. SchedVar<A57LMAddrPred8, [A57Write_8cyc_1S]>,
  594. SchedVar<NoSchedPred, [A57Write_2cyc_1S]>
  595. ]>;
  596. def A57WriteSTM_Upd : SchedWriteVariant<[
  597. SchedVar<A57LMAddrPred1, [A57Write_1cyc_1S_1I]>,
  598. SchedVar<A57LMAddrPred2, [A57Write_2cyc_1S_1I]>,
  599. SchedVar<A57LMAddrPred3, [A57Write_3cyc_1S_1I]>,
  600. SchedVar<A57LMAddrPred4, [A57Write_4cyc_1S_1I]>,
  601. SchedVar<A57LMAddrPred5, [A57Write_5cyc_1S_1I]>,
  602. SchedVar<A57LMAddrPred6, [A57Write_6cyc_1S_1I]>,
  603. SchedVar<A57LMAddrPred7, [A57Write_7cyc_1S_1I]>,
  604. SchedVar<A57LMAddrPred8, [A57Write_8cyc_1S_1I]>,
  605. SchedVar<NoSchedPred, [A57Write_2cyc_1S_1I]>
  606. ]>;
  607. def : InstRW<[A57WriteSTM], (instregex "(t2|sys|t)?STM(IA|DA|DB|IB)$")>;
  608. def : InstRW<[A57WrBackOne, A57WriteSTM_Upd],
  609. (instregex "(t2|sys|t)?STM(IA_UPD|DA_UPD|DB_UPD|IB_UPD)", "tPUSH")>;
  610. def : InstRW<[A57Write_5cyc_1S], (instregex "VLSTM")>;
  611. // --- 3.10 FP Data Processing Instructions ---
  612. def : SchedAlias<WriteFPALU32, A57Write_5cyc_1V>;
  613. def : SchedAlias<WriteFPALU64, A57Write_5cyc_1V>;
  614. def : InstRW<[A57Write_3cyc_1V], (instregex "VABS(S|D|H)")>;
  615. // fp compare - 3cyc F1 for unconditional, 6cyc "F0/F1, F1" for conditional
  616. def A57WriteVcmp : SchedWriteVariant<[
  617. SchedVar<IsPredicatedPred, [A57Write_6cyc_1V_1X]>,
  618. SchedVar<NoSchedPred, [A57Write_3cyc_1X]>
  619. ]>;
  620. def : InstRW<[A57WriteVcmp],
  621. (instregex "VCMP(D|S|H|ZD|ZS|ZH)$", "VCMPE(D|S|H|ZD|ZS|ZH)")>;
  622. // fp convert
  623. def : InstRW<[A57Write_5cyc_1V], (instregex
  624. "VCVT(A|N|P|M)(SH|UH|SS|US|SD|UD)", "VCVT(BDH|THD|TDH)")>;
  625. def : InstRW<[A57Write_5cyc_1V], (instregex "VTOSLS", "VTOUHS", "VTOULS")>;
  626. def : SchedAlias<WriteFPCVT, A57Write_5cyc_1V>;
  627. def : InstRW<[A57Write_5cyc_1V], (instregex "VJCVT")>;
  628. // FP round to integral
  629. def : InstRW<[A57Write_5cyc_1V], (instregex "VRINT(A|N|P|M|Z|R|X)(H|S|D)$")>;
  630. // FP divide, FP square root
  631. def : SchedAlias<WriteFPDIV32, A57Write_17cyc_1W>;
  632. def : SchedAlias<WriteFPDIV64, A57Write_32cyc_1W>;
  633. def : SchedAlias<WriteFPSQRT32, A57Write_17cyc_1W>;
  634. def : SchedAlias<WriteFPSQRT64, A57Write_32cyc_1W>;
  635. def : InstRW<[A57Write_17cyc_1W], (instregex "VSQRTH")>;
  636. // FP max/min
  637. def : InstRW<[A57Write_5cyc_1V], (instregex "VMAX", "VMIN")>;
  638. // FP multiply-accumulate pipelines support late forwarding of the result
  639. // from FP multiply μops to the accumulate operands of an
  640. // FP multiply-accumulate μop. The latter can potentially be issued 1 cycle
  641. // after the FP multiply μop has been issued
  642. // FP multiply, FZ
  643. def A57WriteVMUL : SchedWriteRes<[A57UnitV]> { let Latency = 5; }
  644. def : SchedAlias<WriteFPMUL32, A57WriteVMUL>;
  645. def : SchedAlias<WriteFPMUL64, A57WriteVMUL>;
  646. def : ReadAdvance<ReadFPMUL, 0>;
  647. // FP multiply accumulate, FZ: 9cyc "F0/F1" or 4 cyc for sequenced accumulate
  648. // VFMA, VFMS, VFNMA, VFNMS, VMLA, VMLS, VNMLA, VNMLS
  649. def A57WriteVFMA : SchedWriteRes<[A57UnitV]> { let Latency = 9; }
  650. // VFMA takes 9 cyc for common case and 4 cyc for VFMA->VFMA chain (5 read adv.)
  651. // VMUL takes 5 cyc for common case and 1 cyc for VMUL->VFMA chain (4 read adv.)
  652. // Currently, there is no way to define different read advances for VFMA operand
  653. // from VFMA or from VMUL, so there will be 5 read advance.
  654. // Zero latency (instead of one) for VMUL->VFMA shouldn't break something.
  655. // The same situation with ASIMD VMUL/VFMA instructions
  656. // def A57ReadVFMA : SchedRead;
  657. // def : ReadAdvance<A57ReadVFMA, 5, [A57WriteVFMA]>;
  658. // def : ReadAdvance<A57ReadVFMA, 4, [A57WriteVMUL]>;
  659. def A57ReadVFMA5 : SchedReadAdvance<5, [A57WriteVFMA, A57WriteVMUL]>;
  660. def : SchedAlias<WriteFPMAC32, A57WriteVFMA>;
  661. def : SchedAlias<WriteFPMAC64, A57WriteVFMA>;
  662. def : SchedAlias<ReadFPMAC, A57ReadVFMA5>;
  663. // VMLAH/VMLSH are not binded to scheduling classes by default, so here custom:
  664. def : InstRW<[A57WriteVFMA, A57ReadVFMA5, ReadFPMUL, ReadFPMUL],
  665. (instregex "VMLAH", "VMLSH", "VNMLAH", "VNMLSH")>;
  666. def : InstRW<[A57WriteVMUL],
  667. (instregex "VUDOTD", "VSDOTD", "VUDOTQ", "VSDOTQ")>;
  668. def : InstRW<[A57Write_3cyc_1V], (instregex "VNEG")>;
  669. def : InstRW<[A57Write_3cyc_1V], (instregex "VSEL")>;
  670. // --- 3.11 FP Miscellaneous Instructions ---
  671. // VMOV: 3cyc "F0/F1" for imm/reg
  672. def : InstRW<[A57Write_3cyc_1V], (instregex "FCONST(D|S|H)")>;
  673. def : InstRW<[A57Write_3cyc_1V], (instregex "VMOV(D|S|H)(cc)?$")>;
  674. def : InstRW<[A57Write_3cyc_1V], (instregex "VINSH")>;
  675. // 5cyc L for FP transfer, vfp to core reg,
  676. // 5cyc L for FP transfer, core reg to vfp
  677. def : SchedAlias<WriteFPMOV, A57Write_5cyc_1L>;
  678. // VMOVRRS/VMOVRRD in common code declared with one WriteFPMOV (instead of 2).
  679. def : InstRW<[A57Write_5cyc_1L, A57Write_5cyc_1L], (instregex "VMOV(RRS|RRD)")>;
  680. // 8cyc "L,F0/F1" for FP transfer, core reg to upper or lower half of vfp D-reg
  681. def : InstRW<[A57Write_8cyc_1L_1I], (instregex "VMOVDRR")>;
  682. // --- 3.12 FP Load Instructions ---
  683. def : InstRW<[A57Write_5cyc_1L], (instregex "VLDR(D|S|H)")>;
  684. def : InstRW<[A57Write_5cyc_1L], (instregex "VLDMQIA$")>;
  685. // FP load multiple (VLDM)
  686. def A57VLDMOpsListUncond : A57WriteLMOpsListType<
  687. [A57Write_5cyc_1L, A57Write_5cyc_1L,
  688. A57Write_6cyc_1L, A57Write_6cyc_1L,
  689. A57Write_7cyc_1L, A57Write_7cyc_1L,
  690. A57Write_8cyc_1L, A57Write_8cyc_1L,
  691. A57Write_9cyc_1L, A57Write_9cyc_1L,
  692. A57Write_10cyc_1L, A57Write_10cyc_1L,
  693. A57Write_11cyc_1L, A57Write_11cyc_1L,
  694. A57Write_12cyc_1L, A57Write_12cyc_1L]>;
  695. def A57WriteVLDMuncond : SchedWriteVariant<[
  696. SchedVar<A57LMAddrPred1, A57VLDMOpsListUncond.Writes[0-1]>,
  697. SchedVar<A57LMAddrPred2, A57VLDMOpsListUncond.Writes[0-3]>,
  698. SchedVar<A57LMAddrPred3, A57VLDMOpsListUncond.Writes[0-5]>,
  699. SchedVar<A57LMAddrPred4, A57VLDMOpsListUncond.Writes[0-7]>,
  700. SchedVar<A57LMAddrPred5, A57VLDMOpsListUncond.Writes[0-9]>,
  701. SchedVar<A57LMAddrPred6, A57VLDMOpsListUncond.Writes[0-11]>,
  702. SchedVar<A57LMAddrPred7, A57VLDMOpsListUncond.Writes[0-13]>,
  703. SchedVar<NoSchedPred, A57VLDMOpsListUncond.Writes[0-15]>
  704. ]> { let Variadic=1; }
  705. def A57VLDMOpsListCond : A57WriteLMOpsListType<
  706. [A57Write_5cyc_1L, A57Write_6cyc_1L,
  707. A57Write_7cyc_1L, A57Write_8cyc_1L,
  708. A57Write_9cyc_1L, A57Write_10cyc_1L,
  709. A57Write_11cyc_1L, A57Write_12cyc_1L,
  710. A57Write_13cyc_1L, A57Write_14cyc_1L,
  711. A57Write_15cyc_1L, A57Write_16cyc_1L,
  712. A57Write_17cyc_1L, A57Write_18cyc_1L,
  713. A57Write_19cyc_1L, A57Write_20cyc_1L]>;
  714. def A57WriteVLDMcond : SchedWriteVariant<[
  715. SchedVar<A57LMAddrPred1, A57VLDMOpsListCond.Writes[0-1]>,
  716. SchedVar<A57LMAddrPred2, A57VLDMOpsListCond.Writes[0-3]>,
  717. SchedVar<A57LMAddrPred3, A57VLDMOpsListCond.Writes[0-5]>,
  718. SchedVar<A57LMAddrPred4, A57VLDMOpsListCond.Writes[0-7]>,
  719. SchedVar<A57LMAddrPred5, A57VLDMOpsListCond.Writes[0-9]>,
  720. SchedVar<A57LMAddrPred6, A57VLDMOpsListCond.Writes[0-11]>,
  721. SchedVar<A57LMAddrPred7, A57VLDMOpsListCond.Writes[0-13]>,
  722. SchedVar<NoSchedPred, A57VLDMOpsListCond.Writes[0-15]>
  723. ]> { let Variadic=1; }
  724. def A57WriteVLDM : SchedWriteVariant<[
  725. SchedVar<IsPredicatedPred, [A57WriteVLDMcond]>,
  726. SchedVar<NoSchedPred, [A57WriteVLDMuncond]>
  727. ]> { let Variadic=1; }
  728. def : InstRW<[A57WriteVLDM], (instregex "VLDM(DIA|SIA)$")>;
  729. def A57VLDMOpsListUncond_Upd : A57WriteLMOpsListType<
  730. [A57Write_5cyc_1L_1I, A57Write_5cyc_1L_1I,
  731. A57Write_6cyc_1L_1I, A57Write_6cyc_1L_1I,
  732. A57Write_7cyc_1L_1I, A57Write_7cyc_1L_1I,
  733. A57Write_8cyc_1L_1I, A57Write_8cyc_1L_1I,
  734. A57Write_9cyc_1L_1I, A57Write_9cyc_1L_1I,
  735. A57Write_10cyc_1L_1I, A57Write_10cyc_1L_1I,
  736. A57Write_11cyc_1L_1I, A57Write_11cyc_1L_1I,
  737. A57Write_12cyc_1L_1I, A57Write_12cyc_1L_1I]>;
  738. def A57WriteVLDMuncond_UPD : SchedWriteVariant<[
  739. SchedVar<A57LMAddrPred1, A57VLDMOpsListUncond_Upd.Writes[0-1]>,
  740. SchedVar<A57LMAddrPred2, A57VLDMOpsListUncond_Upd.Writes[0-3]>,
  741. SchedVar<A57LMAddrPred3, A57VLDMOpsListUncond_Upd.Writes[0-5]>,
  742. SchedVar<A57LMAddrPred4, A57VLDMOpsListUncond_Upd.Writes[0-7]>,
  743. SchedVar<A57LMAddrPred5, A57VLDMOpsListUncond_Upd.Writes[0-9]>,
  744. SchedVar<A57LMAddrPred6, A57VLDMOpsListUncond_Upd.Writes[0-11]>,
  745. SchedVar<A57LMAddrPred7, A57VLDMOpsListUncond_Upd.Writes[0-13]>,
  746. SchedVar<NoSchedPred, A57VLDMOpsListUncond_Upd.Writes[0-15]>
  747. ]> { let Variadic=1; }
  748. def A57VLDMOpsListCond_Upd : A57WriteLMOpsListType<
  749. [A57Write_5cyc_1L_1I, A57Write_6cyc_1L_1I,
  750. A57Write_7cyc_1L_1I, A57Write_8cyc_1L_1I,
  751. A57Write_9cyc_1L_1I, A57Write_10cyc_1L_1I,
  752. A57Write_11cyc_1L_1I, A57Write_12cyc_1L_1I,
  753. A57Write_13cyc_1L_1I, A57Write_14cyc_1L_1I,
  754. A57Write_15cyc_1L_1I, A57Write_16cyc_1L_1I,
  755. A57Write_17cyc_1L_1I, A57Write_18cyc_1L_1I,
  756. A57Write_19cyc_1L_1I, A57Write_20cyc_1L_1I]>;
  757. def A57WriteVLDMcond_UPD : SchedWriteVariant<[
  758. SchedVar<A57LMAddrPred1, A57VLDMOpsListCond_Upd.Writes[0-1]>,
  759. SchedVar<A57LMAddrPred2, A57VLDMOpsListCond_Upd.Writes[0-3]>,
  760. SchedVar<A57LMAddrPred3, A57VLDMOpsListCond_Upd.Writes[0-5]>,
  761. SchedVar<A57LMAddrPred4, A57VLDMOpsListCond_Upd.Writes[0-7]>,
  762. SchedVar<A57LMAddrPred5, A57VLDMOpsListCond_Upd.Writes[0-9]>,
  763. SchedVar<A57LMAddrPred6, A57VLDMOpsListCond_Upd.Writes[0-11]>,
  764. SchedVar<A57LMAddrPred7, A57VLDMOpsListCond_Upd.Writes[0-13]>,
  765. SchedVar<NoSchedPred, A57VLDMOpsListCond_Upd.Writes[0-15]>
  766. ]> { let Variadic=1; }
  767. def A57WriteVLDM_UPD : SchedWriteVariant<[
  768. SchedVar<IsPredicatedPred, [A57WriteVLDMcond_UPD]>,
  769. SchedVar<NoSchedPred, [A57WriteVLDMuncond_UPD]>
  770. ]> { let Variadic=1; }
  771. def : InstRW<[A57WrBackOne, A57WriteVLDM_UPD],
  772. (instregex "VLDM(DIA_UPD|DDB_UPD|SIA_UPD|SDB_UPD)")>;
  773. // --- 3.13 FP Store Instructions ---
  774. def : InstRW<[A57Write_1cyc_1S], (instregex "VSTR(D|S|H)")>;
  775. def : InstRW<[A57Write_2cyc_1S], (instregex "VSTMQIA$")>;
  776. def A57WriteVSTMs : SchedWriteVariant<[
  777. SchedVar<A57LMAddrPred1, [A57Write_1cyc_1S]>,
  778. SchedVar<A57LMAddrPred2, [A57Write_2cyc_1S]>,
  779. SchedVar<A57LMAddrPred3, [A57Write_3cyc_1S]>,
  780. SchedVar<A57LMAddrPred4, [A57Write_4cyc_1S]>,
  781. SchedVar<A57LMAddrPred5, [A57Write_5cyc_1S]>,
  782. SchedVar<A57LMAddrPred6, [A57Write_6cyc_1S]>,
  783. SchedVar<A57LMAddrPred7, [A57Write_7cyc_1S]>,
  784. SchedVar<A57LMAddrPred8, [A57Write_8cyc_1S]>,
  785. SchedVar<NoSchedPred, [A57Write_2cyc_1S]>
  786. ]>;
  787. def A57WriteVSTMd : SchedWriteVariant<[
  788. SchedVar<A57LMAddrPred1, [A57Write_2cyc_1S]>,
  789. SchedVar<A57LMAddrPred2, [A57Write_4cyc_1S]>,
  790. SchedVar<A57LMAddrPred3, [A57Write_6cyc_1S]>,
  791. SchedVar<A57LMAddrPred4, [A57Write_8cyc_1S]>,
  792. SchedVar<A57LMAddrPred5, [A57Write_10cyc_1S]>,
  793. SchedVar<A57LMAddrPred6, [A57Write_12cyc_1S]>,
  794. SchedVar<A57LMAddrPred7, [A57Write_14cyc_1S]>,
  795. SchedVar<A57LMAddrPred8, [A57Write_16cyc_1S]>,
  796. SchedVar<NoSchedPred, [A57Write_4cyc_1S]>
  797. ]>;
  798. def A57WriteVSTMs_Upd : SchedWriteVariant<[
  799. SchedVar<A57LMAddrPred1, [A57Write_1cyc_1S_1I]>,
  800. SchedVar<A57LMAddrPred2, [A57Write_2cyc_1S_1I]>,
  801. SchedVar<A57LMAddrPred3, [A57Write_3cyc_1S_1I]>,
  802. SchedVar<A57LMAddrPred4, [A57Write_4cyc_1S_1I]>,
  803. SchedVar<A57LMAddrPred5, [A57Write_5cyc_1S_1I]>,
  804. SchedVar<A57LMAddrPred6, [A57Write_6cyc_1S_1I]>,
  805. SchedVar<A57LMAddrPred7, [A57Write_7cyc_1S_1I]>,
  806. SchedVar<A57LMAddrPred8, [A57Write_8cyc_1S_1I]>,
  807. SchedVar<NoSchedPred, [A57Write_2cyc_1S_1I]>
  808. ]>;
  809. def A57WriteVSTMd_Upd : SchedWriteVariant<[
  810. SchedVar<A57LMAddrPred1, [A57Write_2cyc_1S_1I]>,
  811. SchedVar<A57LMAddrPred2, [A57Write_4cyc_1S_1I]>,
  812. SchedVar<A57LMAddrPred3, [A57Write_6cyc_1S_1I]>,
  813. SchedVar<A57LMAddrPred4, [A57Write_8cyc_1S_1I]>,
  814. SchedVar<A57LMAddrPred5, [A57Write_10cyc_1S_1I]>,
  815. SchedVar<A57LMAddrPred6, [A57Write_12cyc_1S_1I]>,
  816. SchedVar<A57LMAddrPred7, [A57Write_14cyc_1S_1I]>,
  817. SchedVar<A57LMAddrPred8, [A57Write_16cyc_1S_1I]>,
  818. SchedVar<NoSchedPred, [A57Write_2cyc_1S_1I]>
  819. ]>;
  820. def : InstRW<[A57WriteVSTMs], (instregex "VSTMSIA$")>;
  821. def : InstRW<[A57WriteVSTMd], (instregex "VSTMDIA$")>;
  822. def : InstRW<[A57WrBackOne, A57WriteVSTMs_Upd],
  823. (instregex "VSTM(SIA_UPD|SDB_UPD)")>;
  824. def : InstRW<[A57WrBackOne, A57WriteVSTMd_Upd],
  825. (instregex "VSTM(DIA_UPD|DDB_UPD)")>;
  826. // --- 3.14 ASIMD Integer Instructions ---
  827. // ASIMD absolute diff, 3cyc F0/F1 for integer VABD
  828. def : InstRW<[A57Write_3cyc_1V], (instregex "VABD(s|u)")>;
  829. // ASIMD absolute diff accum: 4(1) F1 for D-form, 5(2) F1 for Q-form
  830. def A57WriteVABAD : SchedWriteRes<[A57UnitX]> { let Latency = 4; }
  831. def A57ReadVABAD : SchedReadAdvance<3, [A57WriteVABAD]>;
  832. def : InstRW<[A57WriteVABAD, A57ReadVABAD],
  833. (instregex "VABA(s|u)(v8i8|v4i16|v2i32)")>;
  834. def A57WriteVABAQ : SchedWriteRes<[A57UnitX]> { let Latency = 5; }
  835. def A57ReadVABAQ : SchedReadAdvance<3, [A57WriteVABAQ]>;
  836. def : InstRW<[A57WriteVABAQ, A57ReadVABAQ],
  837. (instregex "VABA(s|u)(v16i8|v8i16|v4i32)")>;
  838. // ASIMD absolute diff accum long: 4(1) F1 for VABAL
  839. def A57WriteVABAL : SchedWriteRes<[A57UnitX]> { let Latency = 4; }
  840. def A57ReadVABAL : SchedReadAdvance<3, [A57WriteVABAL]>;
  841. def : InstRW<[A57WriteVABAL, A57ReadVABAL], (instregex "VABAL(s|u)")>;
  842. // ASIMD absolute diff long: 3cyc F0/F1 for VABDL
  843. def : InstRW<[A57Write_3cyc_1V], (instregex "VABDL(s|u)")>;
  844. // ASIMD arith, basic
  845. def : InstRW<[A57Write_3cyc_1V], (instregex "VADDv", "VADDL", "VADDW",
  846. "VNEG(s8d|s16d|s32d|s8q|s16q|s32q|d|q)",
  847. "VPADDi", "VPADDL", "VSUBv", "VSUBL", "VSUBW")>;
  848. // ASIMD arith, complex
  849. def : InstRW<[A57Write_3cyc_1V], (instregex "VABS", "VADDHN", "VHADD", "VHSUB",
  850. "VQABS", "VQADD", "VQNEG", "VQSUB",
  851. "VRADDHN", "VRHADD", "VRSUBHN", "VSUBHN")>;
  852. // ASIMD compare
  853. def : InstRW<[A57Write_3cyc_1V],
  854. (instregex "VCEQ", "VCGE", "VCGT", "VCLE", "VTST", "VCLT")>;
  855. // ASIMD logical
  856. def : InstRW<[A57Write_3cyc_1V],
  857. (instregex "VAND", "VBIC", "VMVN", "VORR", "VORN", "VEOR")>;
  858. // ASIMD max/min
  859. def : InstRW<[A57Write_3cyc_1V],
  860. (instregex "(VMAX|VMIN)(s|u)", "(VPMAX|VPMIN)(s8|s16|s32|u8|u16|u32)")>;
  861. // ASIMD multiply, D-form: 5cyc F0 for r0px, 4cyc F0 for r1p0 and later
  862. // Cortex-A57 r1p0 and later reduce the latency of ASIMD multiply
  863. // and multiply-with-accumulate instructions relative to r0pX.
  864. def A57WriteVMULD_VecInt : SchedWriteVariant<[
  865. SchedVar<IsR1P0AndLaterPred, [A57Write_4cyc_1W]>,
  866. SchedVar<NoSchedPred, [A57Write_5cyc_1W]>]>;
  867. def : InstRW<[A57WriteVMULD_VecInt], (instregex
  868. "VMUL(v8i8|v4i16|v2i32|pd)", "VMULsl(v4i16|v2i32)",
  869. "VQDMULH(sl)?(v4i16|v2i32)", "VQRDMULH(sl)?(v4i16|v2i32)")>;
  870. // ASIMD multiply, Q-form: 6cyc F0 for r0px, 5cyc F0 for r1p0 and later
  871. def A57WriteVMULQ_VecInt : SchedWriteVariant<[
  872. SchedVar<IsR1P0AndLaterPred, [A57Write_5cyc_1W]>,
  873. SchedVar<NoSchedPred, [A57Write_6cyc_1W]>]>;
  874. def : InstRW<[A57WriteVMULQ_VecInt], (instregex
  875. "VMUL(v16i8|v8i16|v4i32|pq)", "VMULsl(v8i16|v4i32)",
  876. "VQDMULH(sl)?(v8i16|v4i32)", "VQRDMULH(sl)?(v8i16|v4i32)")>;
  877. // ASIMD multiply accumulate, D-form
  878. // 5cyc F0 for r0px, 4cyc F0 for r1p0 and later, 1cyc for accumulate sequence
  879. // (4 or 3 ReadAdvance)
  880. def A57WriteVMLAD_VecInt : SchedWriteVariant<[
  881. SchedVar<IsR1P0AndLaterPred, [A57Write_4cyc_1W]>,
  882. SchedVar<NoSchedPred, [A57Write_5cyc_1W]>]>;
  883. def A57ReadVMLAD_VecInt : SchedReadVariant<[
  884. SchedVar<IsR1P0AndLaterPred, [SchedReadAdvance<3, [A57WriteVMLAD_VecInt]>]>,
  885. SchedVar<NoSchedPred, [SchedReadAdvance<4, [A57WriteVMLAD_VecInt]>]>
  886. ]>;
  887. def : InstRW<[A57WriteVMLAD_VecInt, A57ReadVMLAD_VecInt],
  888. (instregex "VMLA(sl)?(v8i8|v4i16|v2i32)", "VMLS(sl)?(v8i8|v4i16|v2i32)")>;
  889. // ASIMD multiply accumulate, Q-form
  890. // 6cyc F0 for r0px, 5cyc F0 for r1p0 and later, 2cyc for accumulate sequence
  891. // (4 or 3 ReadAdvance)
  892. def A57WriteVMLAQ_VecInt : SchedWriteVariant<[
  893. SchedVar<IsR1P0AndLaterPred, [A57Write_5cyc_1W]>,
  894. SchedVar<NoSchedPred, [A57Write_6cyc_1W]>]>;
  895. def A57ReadVMLAQ_VecInt : SchedReadVariant<[
  896. SchedVar<IsR1P0AndLaterPred, [SchedReadAdvance<3, [A57WriteVMLAQ_VecInt]>]>,
  897. SchedVar<NoSchedPred, [SchedReadAdvance<4, [A57WriteVMLAQ_VecInt]>]>
  898. ]>;
  899. def : InstRW<[A57WriteVMLAQ_VecInt, A57ReadVMLAQ_VecInt],
  900. (instregex "VMLA(sl)?(v16i8|v8i16|v4i32)", "VMLS(sl)?(v16i8|v8i16|v4i32)")>;
  901. // ASIMD multiply accumulate long
  902. // 5cyc F0 for r0px, 4cyc F0 for r1p0 and later, 1cyc for accumulate sequence
  903. // (4 or 3 ReadAdvance)
  904. def A57WriteVMLAL_VecInt : SchedWriteVariant<[
  905. SchedVar<IsR1P0AndLaterPred, [A57Write_4cyc_1W]>,
  906. SchedVar<NoSchedPred, [A57Write_5cyc_1W]>]>;
  907. def A57ReadVMLAL_VecInt : SchedReadVariant<[
  908. SchedVar<IsR1P0AndLaterPred, [SchedReadAdvance<3, [A57WriteVMLAL_VecInt]>]>,
  909. SchedVar<NoSchedPred, [SchedReadAdvance<4, [A57WriteVMLAL_VecInt]>]>
  910. ]>;
  911. def : InstRW<[A57WriteVMLAL_VecInt, A57ReadVMLAL_VecInt],
  912. (instregex "VMLAL(s|u)", "VMLSL(s|u)")>;
  913. // ASIMD multiply accumulate saturating long
  914. // 5cyc F0 for r0px, 4cyc F0 for r1p0 and later, 2cyc for accumulate sequence
  915. // (3 or 2 ReadAdvance)
  916. def A57WriteVQDMLAL_VecInt : SchedWriteVariant<[
  917. SchedVar<IsR1P0AndLaterPred, [A57Write_4cyc_1W]>,
  918. SchedVar<NoSchedPred, [A57Write_5cyc_1W]>]>;
  919. def A57ReadVQDMLAL_VecInt : SchedReadVariant<[
  920. SchedVar<IsR1P0AndLaterPred, [SchedReadAdvance<2, [A57WriteVQDMLAL_VecInt]>]>,
  921. SchedVar<NoSchedPred, [SchedReadAdvance<3, [A57WriteVQDMLAL_VecInt]>]>
  922. ]>;
  923. def : InstRW<[A57WriteVQDMLAL_VecInt, A57ReadVQDMLAL_VecInt],
  924. (instregex "VQDMLAL", "VQDMLSL")>;
  925. // Vector Saturating Rounding Doubling Multiply Accumulate/Subtract Long
  926. // Scheduling info from VQDMLAL/VQDMLSL
  927. def : InstRW<[A57WriteVQDMLAL_VecInt, A57ReadVQDMLAL_VecInt],
  928. (instregex "VQRDMLAH", "VQRDMLSH")>;
  929. // ASIMD multiply long
  930. // 5cyc F0 for r0px, 4cyc F0 for r1p0 and later
  931. def A57WriteVMULL_VecInt : SchedWriteVariant<[
  932. SchedVar<IsR1P0AndLaterPred, [A57Write_4cyc_1W]>,
  933. SchedVar<NoSchedPred, [A57Write_5cyc_1W]>]>;
  934. def : InstRW<[A57WriteVMULL_VecInt],
  935. (instregex "VMULL(s|u|p8|sls|slu)", "VQDMULL")>;
  936. // ASIMD pairwise add and accumulate
  937. // 4cyc F1, 1cyc for accumulate sequence (3cyc ReadAdvance)
  938. def A57WriteVPADAL : SchedWriteRes<[A57UnitX]> { let Latency = 4; }
  939. def A57ReadVPADAL : SchedReadAdvance<3, [A57WriteVPADAL]>;
  940. def : InstRW<[A57WriteVPADAL, A57ReadVPADAL], (instregex "VPADAL(s|u)")>;
  941. // ASIMD shift accumulate
  942. // 4cyc F1, 1cyc for accumulate sequence (3cyc ReadAdvance)
  943. def A57WriteVSRA : SchedWriteRes<[A57UnitX]> { let Latency = 4; }
  944. def A57ReadVSRA : SchedReadAdvance<3, [A57WriteVSRA]>;
  945. def : InstRW<[A57WriteVSRA, A57ReadVSRA], (instregex "VSRA", "VRSRA")>;
  946. // ASIMD shift by immed, basic
  947. def : InstRW<[A57Write_3cyc_1X],
  948. (instregex "VMOVL", "VSHLi", "VSHLL", "VSHR(s|u)", "VSHRN")>;
  949. // ASIMD shift by immed, complex
  950. def : InstRW<[A57Write_4cyc_1X], (instregex
  951. "VQRSHRN", "VQRSHRUN", "VQSHL(si|ui|su)", "VQSHRN", "VQSHRUN", "VRSHR(s|u)",
  952. "VRSHRN")>;
  953. // ASIMD shift by immed and insert, basic, D-form
  954. def : InstRW<[A57Write_4cyc_1X], (instregex
  955. "VSLI(v8i8|v4i16|v2i32|v1i64)", "VSRI(v8i8|v4i16|v2i32|v1i64)")>;
  956. // ASIMD shift by immed and insert, basic, Q-form
  957. def : InstRW<[A57Write_5cyc_1X], (instregex
  958. "VSLI(v16i8|v8i16|v4i32|v2i64)", "VSRI(v16i8|v8i16|v4i32|v2i64)")>;
  959. // ASIMD shift by register, basic, D-form
  960. def : InstRW<[A57Write_3cyc_1X], (instregex
  961. "VSHL(s|u)(v8i8|v4i16|v2i32|v1i64)")>;
  962. // ASIMD shift by register, basic, Q-form
  963. def : InstRW<[A57Write_4cyc_1X], (instregex
  964. "VSHL(s|u)(v16i8|v8i16|v4i32|v2i64)")>;
  965. // ASIMD shift by register, complex, D-form
  966. // VQRSHL, VQSHL, VRSHL
  967. def : InstRW<[A57Write_4cyc_1X], (instregex
  968. "VQRSHL(s|u)(v8i8|v4i16|v2i32|v1i64)", "VQSHL(s|u)(v8i8|v4i16|v2i32|v1i64)",
  969. "VRSHL(s|u)(v8i8|v4i16|v2i32|v1i64)")>;
  970. // ASIMD shift by register, complex, Q-form
  971. def : InstRW<[A57Write_5cyc_1X], (instregex
  972. "VQRSHL(s|u)(v16i8|v8i16|v4i32|v2i64)", "VQSHL(s|u)(v16i8|v8i16|v4i32|v2i64)",
  973. "VRSHL(s|u)(v16i8|v8i16|v4i32|v2i64)")>;
  974. // --- 3.15 ASIMD Floating-Point Instructions ---
  975. // ASIMD FP absolute value
  976. def : InstRW<[A57Write_3cyc_1V], (instregex "VABS(fd|fq|hd|hq)")>;
  977. // ASIMD FP arith
  978. def : InstRW<[A57Write_5cyc_1V], (instregex "VABD(fd|fq|hd|hq)",
  979. "VADD(fd|fq|hd|hq)", "VPADD(f|h)", "VSUB(fd|fq|hd|hq)")>;
  980. def : InstRW<[A57Write_5cyc_1V], (instregex "VCADD", "VCMLA")>;
  981. // ASIMD FP compare
  982. def : InstRW<[A57Write_5cyc_1V], (instregex "VAC(GE|GT|LE|LT)",
  983. "VC(EQ|GE|GT|LE)(fd|fq|hd|hq)")>;
  984. // ASIMD FP convert, integer
  985. def : InstRW<[A57Write_5cyc_1V], (instregex
  986. "VCVT(f2sd|f2ud|s2fd|u2fd|f2sq|f2uq|s2fq|u2fq|f2xsd|f2xud|xs2fd|xu2fd)",
  987. "VCVT(f2xsq|f2xuq|xs2fq|xu2fq)",
  988. "VCVT(AN|MN|NN|PN)(SDf|SQf|UDf|UQf|SDh|SQh|UDh|UQh)")>;
  989. // ASIMD FP convert, half-precision: 8cyc F0/F1
  990. def : InstRW<[A57Write_8cyc_1V], (instregex
  991. "VCVT(h2sd|h2ud|s2hd|u2hd|h2sq|h2uq|s2hq|u2hq|h2xsd|h2xud|xs2hd|xu2hd)",
  992. "VCVT(h2xsq|h2xuq|xs2hq|xu2hq)",
  993. "VCVT(f2h|h2f)")>;
  994. // ASIMD FP max/min
  995. def : InstRW<[A57Write_5cyc_1V], (instregex
  996. "(VMAX|VMIN)(fd|fq|hd|hq)", "(VPMAX|VPMIN)(f|h)", "(NEON|VFP)_VMAXNM",
  997. "(NEON|VFP)_VMINNM")>;
  998. // ASIMD FP multiply
  999. def A57WriteVMUL_VecFP : SchedWriteRes<[A57UnitV]> { let Latency = 5; }
  1000. def : InstRW<[A57WriteVMUL_VecFP], (instregex "VMUL(sl)?(fd|fq|hd|hq)")>;
  1001. // ASIMD FP multiply accumulate: 9cyc F0/F1, 4cyc for accumulate sequence
  1002. def A57WriteVMLA_VecFP : SchedWriteRes<[A57UnitV]> { let Latency = 9; }
  1003. def A57ReadVMLA_VecFP :
  1004. SchedReadAdvance<5, [A57WriteVMLA_VecFP, A57WriteVMUL_VecFP]>;
  1005. def : InstRW<[A57WriteVMLA_VecFP, A57ReadVMLA_VecFP],
  1006. (instregex "(VMLA|VMLS)(sl)?(fd|fq|hd|hq)", "(VFMA|VFMS)(fd|fq|hd|hq)")>;
  1007. // ASIMD FP negate
  1008. def : InstRW<[A57Write_3cyc_1V], (instregex "VNEG(fd|f32q|hd|hq)")>;
  1009. // ASIMD FP round to integral
  1010. def : InstRW<[A57Write_5cyc_1V], (instregex
  1011. "VRINT(AN|MN|NN|PN|XN|ZN)(Df|Qf|Dh|Qh)")>;
  1012. // --- 3.16 ASIMD Miscellaneous Instructions ---
  1013. // ASIMD bitwise insert
  1014. def : InstRW<[A57Write_3cyc_1V], (instregex "VBIF", "VBIT", "VBSL", "VBSP")>;
  1015. // ASIMD count
  1016. def : InstRW<[A57Write_3cyc_1V], (instregex "VCLS", "VCLZ", "VCNT")>;
  1017. // ASIMD duplicate, core reg: 8cyc "L, F0/F1"
  1018. def : InstRW<[A57Write_8cyc_1L_1V], (instregex "VDUP(8|16|32)(d|q)")>;
  1019. // ASIMD duplicate, scalar: 3cyc "F0/F1"
  1020. def : InstRW<[A57Write_3cyc_1V], (instregex "VDUPLN(8|16|32)(d|q)")>;
  1021. // ASIMD extract
  1022. def : InstRW<[A57Write_3cyc_1V], (instregex "VEXT(d|q)(8|16|32|64)")>;
  1023. // ASIMD move, immed
  1024. def : InstRW<[A57Write_3cyc_1V], (instregex
  1025. "VMOV(v8i8|v16i8|v4i16|v8i16|v2i32|v4i32|v1i64|v2i64|v2f32|v4f32)",
  1026. "VMOVD0", "VMOVQ0")>;
  1027. // ASIMD move, narrowing
  1028. def : InstRW<[A57Write_3cyc_1V], (instregex "VMOVN")>;
  1029. // ASIMD move, saturating
  1030. def : InstRW<[A57Write_4cyc_1X], (instregex "VQMOVN")>;
  1031. // ASIMD reciprocal estimate
  1032. def : InstRW<[A57Write_5cyc_1V], (instregex "VRECPE", "VRSQRTE")>;
  1033. // ASIMD reciprocal step, FZ
  1034. def : InstRW<[A57Write_9cyc_1V], (instregex "VRECPS", "VRSQRTS")>;
  1035. // ASIMD reverse, swap, table lookup (1-2 reg)
  1036. def : InstRW<[A57Write_3cyc_1V], (instregex "VREV", "VSWP", "VTB(L|X)(1|2)")>;
  1037. // ASIMD table lookup (3-4 reg)
  1038. def : InstRW<[A57Write_6cyc_1V], (instregex "VTBL(3|4)", "VTBX(3|4)")>;
  1039. // ASIMD transfer, scalar to core reg: 6cyc "L, I0/I1"
  1040. def : InstRW<[A57Write_6cyc_1L_1I], (instregex "VGETLN")>;
  1041. // ASIMD transfer, core reg to scalar: 8cyc "L, F0/F1"
  1042. def : InstRW<[A57Write_8cyc_1L_1V], (instregex "VSETLN")>;
  1043. // ASIMD transpose
  1044. def : InstRW<[A57Write_3cyc_1V, A57Write_3cyc_1V], (instregex "VTRN")>;
  1045. // ASIMD unzip/zip, D-form
  1046. def : InstRW<[A57Write_3cyc_1V, A57Write_3cyc_1V],
  1047. (instregex "VUZPd", "VZIPd")>;
  1048. // ASIMD unzip/zip, Q-form
  1049. def : InstRW<[A57Write_6cyc_1V, A57Write_6cyc_1V],
  1050. (instregex "VUZPq", "VZIPq")>;
  1051. // --- 3.17 ASIMD Load Instructions ---
  1052. // Overriden via InstRW for this processor.
  1053. def : WriteRes<WriteVLD1, []>;
  1054. def : WriteRes<WriteVLD2, []>;
  1055. def : WriteRes<WriteVLD3, []>;
  1056. def : WriteRes<WriteVLD4, []>;
  1057. def : WriteRes<WriteVST1, []>;
  1058. def : WriteRes<WriteVST2, []>;
  1059. def : WriteRes<WriteVST3, []>;
  1060. def : WriteRes<WriteVST4, []>;
  1061. // 1-2 reg: 5cyc L, +I for writeback, 1 cyc wb latency
  1062. def : InstRW<[A57Write_5cyc_1L], (instregex "VLD1(d|q)(8|16|32|64)$")>;
  1063. def : InstRW<[A57Write_5cyc_1L_1I, A57WrBackOne],
  1064. (instregex "VLD1(d|q)(8|16|32|64)wb")>;
  1065. // 3-4 reg: 6cyc L, +I for writeback, 1 cyc wb latency
  1066. def : InstRW<[A57Write_6cyc_1L],
  1067. (instregex "VLD1(d|q)(8|16|32|64)(T|Q)$", "VLD1d64(T|Q)Pseudo")>;
  1068. def : InstRW<[A57Write_6cyc_1L_1I, A57WrBackOne],
  1069. (instregex "VLD1(d|q)(8|16|32|64)(T|Q)wb")>;
  1070. // ASIMD load, 1 element, one lane and all lanes: 8cyc "L, F0/F1"
  1071. def : InstRW<[A57Write_8cyc_1L_1V], (instregex
  1072. "VLD1(LN|DUP)(d|q)(8|16|32)$", "VLD1(LN|DUP)(d|q)(8|16|32)Pseudo$")>;
  1073. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne], (instregex
  1074. "VLD1(LN|DUP)(d|q)(8|16|32)(wb|_UPD)", "VLD1LNq(8|16|32)Pseudo_UPD")>;
  1075. // ASIMD load, 2 element, multiple, 2 reg: 8cyc "L, F0/F1"
  1076. def : InstRW<[A57Write_8cyc_1L_1V],
  1077. (instregex "VLD2(d|q)(8|16|32)$", "VLD2q(8|16|32)Pseudo$")>;
  1078. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1079. (instregex "VLD2(d|q)(8|16|32)wb", "VLD2q(8|16|32)PseudoWB")>;
  1080. // ASIMD load, 2 element, multiple, 4 reg: 9cyc "L, F0/F1"
  1081. def : InstRW<[A57Write_9cyc_1L_1V], (instregex "VLD2b(8|16|32)$")>;
  1082. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1083. (instregex "VLD2b(8|16|32)wb")>;
  1084. // ASIMD load, 2 element, one lane and all lanes: 8cyc "L, F0/F1"
  1085. def : InstRW<[A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V],
  1086. (instregex "VLD2(DUP|LN)(d|q)(8|16|32|8x2|16x2|32x2)$",
  1087. "VLD2LN(d|q)(8|16|32)Pseudo$")>;
  1088. // 2 results + wb result
  1089. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V, A57WrBackOne],
  1090. (instregex "VLD2LN(d|q)(8|16|32)_UPD$")>;
  1091. // 1 result + wb result
  1092. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1093. (instregex "VLD2DUPd(8|16|32|8x2|16x2|32x2)wb",
  1094. "VLD2LN(d|q)(8|16|32)Pseudo_UPD")>;
  1095. // ASIMD load, 3 element, multiple, 3 reg: 9cyc "L, F0/F1"
  1096. // 3 results
  1097. def : InstRW<[A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V],
  1098. (instregex "VLD3(d|q)(8|16|32)$")>;
  1099. // 1 result
  1100. def : InstRW<[A57Write_9cyc_1L_1V],
  1101. (instregex "VLD3(d|q)(8|16|32)(oddP|P)seudo$")>;
  1102. // 3 results + wb
  1103. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I,
  1104. A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1105. (instregex "VLD3(d|q)(8|16|32)_UPD$")>;
  1106. // 1 result + wb
  1107. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1108. (instregex "VLD3(d|q)(8|16|32)(oddP|P)seudo_UPD")>;
  1109. // ASIMD load, 3 element, one lane, size 32: 8cyc "L, F0/F1"
  1110. def : InstRW<[A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V],
  1111. (instregex "VLD3LN(d|q)32$",
  1112. "VLD3LN(d|q)32Pseudo$")>;
  1113. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1114. A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1115. (instregex "VLD3LN(d|q)32_UPD")>;
  1116. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1117. (instregex "VLD3LN(d|q)32Pseudo_UPD")>;
  1118. // ASIMD load, 3 element, one lane, size 8/16: 9cyc "L, F0/F1"
  1119. def : InstRW<[A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V],
  1120. (instregex "VLD3LN(d|q)(8|16)$",
  1121. "VLD3LN(d|q)(8|16)Pseudo$")>;
  1122. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I,
  1123. A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1124. (instregex "VLD3LN(d|q)(8|16)_UPD")>;
  1125. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1126. (instregex "VLD3LN(d|q)(8|16)Pseudo_UPD")>;
  1127. // ASIMD load, 3 element, all lanes: 8cyc "L, F0/F1"
  1128. def : InstRW<[A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V],
  1129. (instregex "VLD3DUP(d|q)(8|16|32)$",
  1130. "VLD3DUP(d|q)(8|16|32)Pseudo$")>;
  1131. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1132. A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1133. (instregex "VLD3DUP(d|q)(8|16|32)_UPD")>;
  1134. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1135. (instregex "VLD3DUP(d|q)(8|16|32)Pseudo_UPD")>;
  1136. // ASIMD load, 4 element, multiple, 4 reg: 9cyc "L, F0/F1"
  1137. def : InstRW<[A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V,
  1138. A57Write_9cyc_1L_1V],
  1139. (instregex "VLD4(d|q)(8|16|32)$")>;
  1140. def : InstRW<[A57Write_9cyc_1L_1V],
  1141. (instregex "VLD4(d|q)(8|16|32)(oddP|P)seudo$")>;
  1142. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I,
  1143. A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1144. (instregex "VLD4(d|q)(8|16|32)_UPD")>;
  1145. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1146. (instregex "VLD4(d|q)(8|16|32)(oddP|P)seudo_UPD")>;
  1147. // ASIMD load, 4 element, one lane, size 32: 8cyc "L, F0/F1"
  1148. def : InstRW<[A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V,
  1149. A57Write_8cyc_1L_1V],
  1150. (instregex "VLD4LN(d|q)32$",
  1151. "VLD4LN(d|q)32Pseudo$")>;
  1152. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1153. A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1154. A57WrBackOne],
  1155. (instregex "VLD4LN(d|q)32_UPD")>;
  1156. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1157. (instregex "VLD4LN(d|q)32Pseudo_UPD")>;
  1158. // ASIMD load, 4 element, one lane, size 8/16: 9cyc "L, F0/F1"
  1159. def : InstRW<[A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V, A57Write_9cyc_1L_1V,
  1160. A57Write_9cyc_1L_1V],
  1161. (instregex "VLD4LN(d|q)(8|16)$",
  1162. "VLD4LN(d|q)(8|16)Pseudo$")>;
  1163. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I,
  1164. A57Write_9cyc_1L_1V_1I, A57Write_9cyc_1L_1V_1I,
  1165. A57WrBackOne],
  1166. (instregex "VLD4LN(d|q)(8|16)_UPD")>;
  1167. def : InstRW<[A57Write_9cyc_1L_1V_1I, A57WrBackOne],
  1168. (instregex "VLD4LN(d|q)(8|16)Pseudo_UPD")>;
  1169. // ASIMD load, 4 element, all lanes: 8cyc "L, F0/F1"
  1170. def : InstRW<[A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V, A57Write_8cyc_1L_1V,
  1171. A57Write_8cyc_1L_1V],
  1172. (instregex "VLD4DUP(d|q)(8|16|32)$",
  1173. "VLD4DUP(d|q)(8|16|32)Pseudo$")>;
  1174. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1175. A57Write_8cyc_1L_1V_1I, A57Write_8cyc_1L_1V_1I,
  1176. A57WrBackOne],
  1177. (instregex "VLD4DUP(d|q)(8|16|32)_UPD")>;
  1178. def : InstRW<[A57Write_8cyc_1L_1V_1I, A57WrBackOne],
  1179. (instregex "VLD4DUP(d|q)(8|16|32)Pseudo_UPD")>;
  1180. // --- 3.18 ASIMD Store Instructions ---
  1181. // ASIMD store, 1 element, multiple, 1 reg: 1cyc S
  1182. def : InstRW<[A57Write_1cyc_1S], (instregex "VST1d(8|16|32|64)$")>;
  1183. def : InstRW<[A57WrBackOne, A57Write_1cyc_1S_1I],
  1184. (instregex "VST1d(8|16|32|64)wb")>;
  1185. // ASIMD store, 1 element, multiple, 2 reg: 2cyc S
  1186. def : InstRW<[A57Write_2cyc_1S], (instregex "VST1q(8|16|32|64)$")>;
  1187. def : InstRW<[A57WrBackOne, A57Write_2cyc_1S_1I],
  1188. (instregex "VST1q(8|16|32|64)wb")>;
  1189. // ASIMD store, 1 element, multiple, 3 reg: 3cyc S
  1190. def : InstRW<[A57Write_3cyc_1S],
  1191. (instregex "VST1d(8|16|32|64)T$", "VST1d64TPseudo$")>;
  1192. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1I],
  1193. (instregex "VST1d(8|16|32|64)Twb", "VST1d64TPseudoWB")>;
  1194. // ASIMD store, 1 element, multiple, 4 reg: 4cyc S
  1195. def : InstRW<[A57Write_4cyc_1S],
  1196. (instregex "VST1d(8|16|32|64)(Q|QPseudo)$")>;
  1197. def : InstRW<[A57WrBackOne, A57Write_4cyc_1S_1I],
  1198. (instregex "VST1d(8|16|32|64)(Qwb|QPseudoWB)")>;
  1199. // ASIMD store, 1 element, one lane: 3cyc "F0/F1, S"
  1200. def : InstRW<[A57Write_3cyc_1S_1V],
  1201. (instregex "VST1LNd(8|16|32)$", "VST1LNq(8|16|32)Pseudo$")>;
  1202. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1203. (instregex "VST1LNd(8|16|32)_UPD", "VST1LNq(8|16|32)Pseudo_UPD")>;
  1204. // ASIMD store, 2 element, multiple, 2 reg: 3cyc "F0/F1, S"
  1205. def : InstRW<[A57Write_3cyc_1S_1V],
  1206. (instregex "VST2(d|b)(8|16|32)$")>;
  1207. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1208. (instregex "VST2(b|d)(8|16|32)wb")>;
  1209. // ASIMD store, 2 element, multiple, 4 reg: 4cyc "F0/F1, S"
  1210. def : InstRW<[A57Write_4cyc_1S_1V],
  1211. (instregex "VST2q(8|16|32)$", "VST2q(8|16|32)Pseudo$")>;
  1212. def : InstRW<[A57WrBackOne, A57Write_4cyc_1S_1V_1I],
  1213. (instregex "VST2q(8|16|32)wb", "VST2q(8|16|32)PseudoWB")>;
  1214. // ASIMD store, 2 element, one lane: 3cyc "F0/F1, S"
  1215. def : InstRW<[A57Write_3cyc_1S_1V],
  1216. (instregex "VST2LN(d|q)(8|16|32)$", "VST2LN(d|q)(8|16|32)Pseudo$")>;
  1217. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1218. (instregex "VST2LN(d|q)(8|16|32)_UPD",
  1219. "VST2LN(d|q)(8|16|32)Pseudo_UPD")>;
  1220. // ASIMD store, 3 element, multiple, 3 reg
  1221. def : InstRW<[A57Write_3cyc_1S_1V],
  1222. (instregex "VST3(d|q)(8|16|32)$", "VST3(d|q)(8|16|32)(oddP|P)seudo$")>;
  1223. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1224. (instregex "VST3(d|q)(8|16|32)_UPD",
  1225. "VST3(d|q)(8|16|32)(oddP|P)seudo_UPD$")>;
  1226. // ASIMD store, 3 element, one lane
  1227. def : InstRW<[A57Write_3cyc_1S_1V],
  1228. (instregex "VST3LN(d|q)(8|16|32)$", "VST3LN(d|q)(8|16|32)Pseudo$")>;
  1229. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1230. (instregex "VST3LN(d|q)(8|16|32)_UPD",
  1231. "VST3LN(d|q)(8|16|32)Pseudo_UPD")>;
  1232. // ASIMD store, 4 element, multiple, 4 reg
  1233. def : InstRW<[A57Write_4cyc_1S_1V],
  1234. (instregex "VST4(d|q)(8|16|32)$", "VST4(d|q)(8|16|32)(oddP|P)seudo$")>;
  1235. def : InstRW<[A57WrBackOne, A57Write_4cyc_1S_1V_1I],
  1236. (instregex "VST4(d|q)(8|16|32)_UPD",
  1237. "VST4(d|q)(8|16|32)(oddP|P)seudo_UPD$")>;
  1238. // ASIMD store, 4 element, one lane
  1239. def : InstRW<[A57Write_3cyc_1S_1V],
  1240. (instregex "VST4LN(d|q)(8|16|32)$", "VST4LN(d|q)(8|16|32)Pseudo$")>;
  1241. def : InstRW<[A57WrBackOne, A57Write_3cyc_1S_1V_1I],
  1242. (instregex "VST4LN(d|q)(8|16|32)_UPD",
  1243. "VST4LN(d|q)(8|16|32)Pseudo_UPD")>;
  1244. // --- 3.19 Cryptography Extensions ---
  1245. // Crypto AES ops
  1246. // AESD, AESE, AESIMC, AESMC: 3cyc F0
  1247. def : InstRW<[A57Write_3cyc_1W], (instregex "^AES")>;
  1248. // Crypto polynomial (64x64) multiply long (VMULL.P64): 3cyc F0
  1249. def : InstRW<[A57Write_3cyc_1W], (instregex "^VMULLp64")>;
  1250. // Crypto SHA1 xor ops: 6cyc F0/F1
  1251. def : InstRW<[A57Write_6cyc_2V], (instregex "^SHA1SU0")>;
  1252. // Crypto SHA1 fast ops: 3cyc F0
  1253. def : InstRW<[A57Write_3cyc_1W], (instregex "^SHA1(H|SU1)")>;
  1254. // Crypto SHA1 slow ops: 6cyc F0
  1255. def : InstRW<[A57Write_6cyc_2W], (instregex "^SHA1[CMP]")>;
  1256. // Crypto SHA256 fast ops: 3cyc F0
  1257. def : InstRW<[A57Write_3cyc_1W], (instregex "^SHA256SU0")>;
  1258. // Crypto SHA256 slow ops: 6cyc F0
  1259. def : InstRW<[A57Write_6cyc_2W], (instregex "^SHA256(H|H2|SU1)")>;
  1260. // --- 3.20 CRC ---
  1261. def : InstRW<[A57Write_3cyc_1W], (instregex "^(t2)?CRC32")>;
  1262. // -----------------------------------------------------------------------------
  1263. // Common definitions
  1264. def : WriteRes<WriteNoop, []> { let Latency = 0; let NumMicroOps = 0; }
  1265. def : SchedAlias<WriteALU, CheckBranchForm<0, A57BranchForm<A57Write_1cyc_1I>>>;
  1266. def : SchedAlias<WriteBr, A57Write_1cyc_1B>;
  1267. def : SchedAlias<WriteBrL, A57Write_1cyc_1B_1I>;
  1268. def : SchedAlias<WriteBrTbl, A57Write_1cyc_1B_1I>;
  1269. def : SchedAlias<WritePreLd, A57Write_4cyc_1L>;
  1270. def : SchedAlias<WriteLd, A57Write_4cyc_1L>;
  1271. def : SchedAlias<WriteST, A57Write_1cyc_1S>;
  1272. def : ReadAdvance<ReadALU, 0>;
  1273. } // SchedModel = CortexA57Model