ARMInstrVFP.td 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893
  1. //===-- ARMInstrVFP.td - VFP support for ARM ---------------*- 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 describes the ARM VFP instruction set.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
  13. def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
  14. SDTCisSameAs<1, 2>]>;
  15. def SDT_VMOVRRD : SDTypeProfile<2, 1, [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>,
  16. SDTCisVT<2, f64>]>;
  17. def SDT_VMOVSR : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisVT<1, i32>]>;
  18. def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>;
  19. def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutGlue]>;
  20. def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>;
  21. def arm_cmpfpe : SDNode<"ARMISD::CMPFPE", SDT_ARMCmp, [SDNPOutGlue]>;
  22. def arm_cmpfpe0: SDNode<"ARMISD::CMPFPEw0",SDT_CMPFP0, [SDNPOutGlue]>;
  23. def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
  24. def arm_fmrrd : SDNode<"ARMISD::VMOVRRD", SDT_VMOVRRD>;
  25. def arm_vmovsr : SDNode<"ARMISD::VMOVSR", SDT_VMOVSR>;
  26. def SDT_VMOVhr : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, i32>] >;
  27. def SDT_VMOVrh : SDTypeProfile<1, 1, [SDTCisVT<0, i32>, SDTCisFP<1>] >;
  28. def arm_vmovhr : SDNode<"ARMISD::VMOVhr", SDT_VMOVhr>;
  29. def arm_vmovrh : SDNode<"ARMISD::VMOVrh", SDT_VMOVrh>;
  30. //===----------------------------------------------------------------------===//
  31. // Operand Definitions.
  32. //
  33. // 8-bit floating-point immediate encodings.
  34. def FPImmOperand : AsmOperandClass {
  35. let Name = "FPImm";
  36. let ParserMethod = "parseFPImm";
  37. }
  38. def vfp_f16imm : Operand<f16>,
  39. PatLeaf<(f16 fpimm), [{
  40. return ARM_AM::getFP16Imm(N->getValueAPF()) != -1;
  41. }], SDNodeXForm<fpimm, [{
  42. APFloat InVal = N->getValueAPF();
  43. uint32_t enc = ARM_AM::getFP16Imm(InVal);
  44. return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
  45. }]>> {
  46. let PrintMethod = "printFPImmOperand";
  47. let ParserMatchClass = FPImmOperand;
  48. }
  49. def vfp_f32f16imm_xform : SDNodeXForm<fpimm, [{
  50. APFloat InVal = N->getValueAPF();
  51. uint32_t enc = ARM_AM::getFP32FP16Imm(InVal);
  52. return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
  53. }]>;
  54. def vfp_f32f16imm : PatLeaf<(f32 fpimm), [{
  55. return ARM_AM::getFP32FP16Imm(N->getValueAPF()) != -1;
  56. }], vfp_f32f16imm_xform>;
  57. def vfp_f32imm_xform : SDNodeXForm<fpimm, [{
  58. APFloat InVal = N->getValueAPF();
  59. uint32_t enc = ARM_AM::getFP32Imm(InVal);
  60. return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
  61. }]>;
  62. def gi_vfp_f32imm : GICustomOperandRenderer<"renderVFPF32Imm">,
  63. GISDNodeXFormEquiv<vfp_f32imm_xform>;
  64. def vfp_f32imm : Operand<f32>,
  65. PatLeaf<(f32 fpimm), [{
  66. return ARM_AM::getFP32Imm(N->getValueAPF()) != -1;
  67. }], vfp_f32imm_xform> {
  68. let PrintMethod = "printFPImmOperand";
  69. let ParserMatchClass = FPImmOperand;
  70. let GISelPredicateCode = [{
  71. const auto &MO = MI.getOperand(1);
  72. if (!MO.isFPImm())
  73. return false;
  74. return ARM_AM::getFP32Imm(MO.getFPImm()->getValueAPF()) != -1;
  75. }];
  76. }
  77. def vfp_f64imm_xform : SDNodeXForm<fpimm, [{
  78. APFloat InVal = N->getValueAPF();
  79. uint32_t enc = ARM_AM::getFP64Imm(InVal);
  80. return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
  81. }]>;
  82. def gi_vfp_f64imm : GICustomOperandRenderer<"renderVFPF64Imm">,
  83. GISDNodeXFormEquiv<vfp_f64imm_xform>;
  84. def vfp_f64imm : Operand<f64>,
  85. PatLeaf<(f64 fpimm), [{
  86. return ARM_AM::getFP64Imm(N->getValueAPF()) != -1;
  87. }], vfp_f64imm_xform> {
  88. let PrintMethod = "printFPImmOperand";
  89. let ParserMatchClass = FPImmOperand;
  90. let GISelPredicateCode = [{
  91. const auto &MO = MI.getOperand(1);
  92. if (!MO.isFPImm())
  93. return false;
  94. return ARM_AM::getFP64Imm(MO.getFPImm()->getValueAPF()) != -1;
  95. }];
  96. }
  97. def alignedload16 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  98. return cast<LoadSDNode>(N)->getAlignment() >= 2;
  99. }]>;
  100. def alignedload32 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
  101. return cast<LoadSDNode>(N)->getAlignment() >= 4;
  102. }]>;
  103. def alignedstore16 : PatFrag<(ops node:$val, node:$ptr),
  104. (store node:$val, node:$ptr), [{
  105. return cast<StoreSDNode>(N)->getAlignment() >= 2;
  106. }]>;
  107. def alignedstore32 : PatFrag<(ops node:$val, node:$ptr),
  108. (store node:$val, node:$ptr), [{
  109. return cast<StoreSDNode>(N)->getAlignment() >= 4;
  110. }]>;
  111. // The VCVT to/from fixed-point instructions encode the 'fbits' operand
  112. // (the number of fixed bits) differently than it appears in the assembly
  113. // source. It's encoded as "Size - fbits" where Size is the size of the
  114. // fixed-point representation (32 or 16) and fbits is the value appearing
  115. // in the assembly source, an integer in [0,16] or (0,32], depending on size.
  116. def fbits32_asm_operand : AsmOperandClass { let Name = "FBits32"; }
  117. def fbits32 : Operand<i32> {
  118. let PrintMethod = "printFBits32";
  119. let ParserMatchClass = fbits32_asm_operand;
  120. }
  121. def fbits16_asm_operand : AsmOperandClass { let Name = "FBits16"; }
  122. def fbits16 : Operand<i32> {
  123. let PrintMethod = "printFBits16";
  124. let ParserMatchClass = fbits16_asm_operand;
  125. }
  126. //===----------------------------------------------------------------------===//
  127. // Load / store Instructions.
  128. //
  129. let canFoldAsLoad = 1, isReMaterializable = 1 in {
  130. def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
  131. IIC_fpLoad64, "vldr", "\t$Dd, $addr",
  132. [(set DPR:$Dd, (f64 (alignedload32 addrmode5:$addr)))]>,
  133. Requires<[HasFPRegs]>;
  134. def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
  135. IIC_fpLoad32, "vldr", "\t$Sd, $addr",
  136. [(set SPR:$Sd, (alignedload32 addrmode5:$addr))]>,
  137. Requires<[HasFPRegs]> {
  138. // Some single precision VFP instructions may be executed on both NEON and VFP
  139. // pipelines.
  140. let D = VFPNeonDomain;
  141. }
  142. let isUnpredicable = 1 in
  143. def VLDRH : AHI5<0b1101, 0b01, (outs HPR:$Sd), (ins addrmode5fp16:$addr),
  144. IIC_fpLoad16, "vldr", ".16\t$Sd, $addr",
  145. [(set HPR:$Sd, (f16 (alignedload16 addrmode5fp16:$addr)))]>,
  146. Requires<[HasFPRegs16]>;
  147. } // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
  148. def : Pat<(bf16 (alignedload16 addrmode5fp16:$addr)),
  149. (VLDRH addrmode5fp16:$addr)> {
  150. let Predicates = [HasFPRegs16];
  151. }
  152. def : Pat<(bf16 (alignedload16 addrmode3:$addr)),
  153. (COPY_TO_REGCLASS (LDRH addrmode3:$addr), HPR)> {
  154. let Predicates = [HasNoFPRegs16, IsARM];
  155. }
  156. def : Pat<(bf16 (alignedload16 t2addrmode_imm12:$addr)),
  157. (COPY_TO_REGCLASS (t2LDRHi12 t2addrmode_imm12:$addr), HPR)> {
  158. let Predicates = [HasNoFPRegs16, IsThumb];
  159. }
  160. def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
  161. IIC_fpStore64, "vstr", "\t$Dd, $addr",
  162. [(alignedstore32 (f64 DPR:$Dd), addrmode5:$addr)]>,
  163. Requires<[HasFPRegs]>;
  164. def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
  165. IIC_fpStore32, "vstr", "\t$Sd, $addr",
  166. [(alignedstore32 SPR:$Sd, addrmode5:$addr)]>,
  167. Requires<[HasFPRegs]> {
  168. // Some single precision VFP instructions may be executed on both NEON and VFP
  169. // pipelines.
  170. let D = VFPNeonDomain;
  171. }
  172. let isUnpredicable = 1 in
  173. def VSTRH : AHI5<0b1101, 0b00, (outs), (ins HPR:$Sd, addrmode5fp16:$addr),
  174. IIC_fpStore16, "vstr", ".16\t$Sd, $addr",
  175. [(alignedstore16 (f16 HPR:$Sd), addrmode5fp16:$addr)]>,
  176. Requires<[HasFPRegs16]>;
  177. def : Pat<(alignedstore16 (bf16 HPR:$Sd), addrmode5fp16:$addr),
  178. (VSTRH (bf16 HPR:$Sd), addrmode5fp16:$addr)> {
  179. let Predicates = [HasFPRegs16];
  180. }
  181. def : Pat<(alignedstore16 (bf16 HPR:$Sd), addrmode3:$addr),
  182. (STRH (COPY_TO_REGCLASS $Sd, GPR), addrmode3:$addr)> {
  183. let Predicates = [HasNoFPRegs16, IsARM];
  184. }
  185. def : Pat<(alignedstore16 (bf16 HPR:$Sd), t2addrmode_imm12:$addr),
  186. (t2STRHi12 (COPY_TO_REGCLASS $Sd, GPR), t2addrmode_imm12:$addr)> {
  187. let Predicates = [HasNoFPRegs16, IsThumb];
  188. }
  189. //===----------------------------------------------------------------------===//
  190. // Load / store multiple Instructions.
  191. //
  192. multiclass vfp_ldst_mult<string asm, bit L_bit,
  193. InstrItinClass itin, InstrItinClass itin_upd> {
  194. let Predicates = [HasFPRegs] in {
  195. // Double Precision
  196. def DIA :
  197. AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
  198. IndexModeNone, itin,
  199. !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
  200. let Inst{24-23} = 0b01; // Increment After
  201. let Inst{21} = 0; // No writeback
  202. let Inst{20} = L_bit;
  203. }
  204. def DIA_UPD :
  205. AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
  206. variable_ops),
  207. IndexModeUpd, itin_upd,
  208. !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  209. let Inst{24-23} = 0b01; // Increment After
  210. let Inst{21} = 1; // Writeback
  211. let Inst{20} = L_bit;
  212. }
  213. def DDB_UPD :
  214. AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
  215. variable_ops),
  216. IndexModeUpd, itin_upd,
  217. !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  218. let Inst{24-23} = 0b10; // Decrement Before
  219. let Inst{21} = 1; // Writeback
  220. let Inst{20} = L_bit;
  221. }
  222. // Single Precision
  223. def SIA :
  224. AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops),
  225. IndexModeNone, itin,
  226. !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
  227. let Inst{24-23} = 0b01; // Increment After
  228. let Inst{21} = 0; // No writeback
  229. let Inst{20} = L_bit;
  230. // Some single precision VFP instructions may be executed on both NEON and
  231. // VFP pipelines.
  232. let D = VFPNeonDomain;
  233. }
  234. def SIA_UPD :
  235. AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
  236. variable_ops),
  237. IndexModeUpd, itin_upd,
  238. !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  239. let Inst{24-23} = 0b01; // Increment After
  240. let Inst{21} = 1; // Writeback
  241. let Inst{20} = L_bit;
  242. // Some single precision VFP instructions may be executed on both NEON and
  243. // VFP pipelines.
  244. let D = VFPNeonDomain;
  245. }
  246. def SDB_UPD :
  247. AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
  248. variable_ops),
  249. IndexModeUpd, itin_upd,
  250. !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  251. let Inst{24-23} = 0b10; // Decrement Before
  252. let Inst{21} = 1; // Writeback
  253. let Inst{20} = L_bit;
  254. // Some single precision VFP instructions may be executed on both NEON and
  255. // VFP pipelines.
  256. let D = VFPNeonDomain;
  257. }
  258. }
  259. }
  260. let hasSideEffects = 0 in {
  261. let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
  262. defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>;
  263. let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
  264. defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpStore_m, IIC_fpStore_mu>;
  265. } // hasSideEffects
  266. def : MnemonicAlias<"vldm", "vldmia">;
  267. def : MnemonicAlias<"vstm", "vstmia">;
  268. //===----------------------------------------------------------------------===//
  269. // Lazy load / store multiple Instructions
  270. //
  271. def VLLDM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone,
  272. NoItinerary, "vlldm${p}\t$Rn", "", []>,
  273. Requires<[HasV8MMainline, Has8MSecExt]> {
  274. let Inst{24-23} = 0b00;
  275. let Inst{22} = 0;
  276. let Inst{21} = 1;
  277. let Inst{20} = 1;
  278. let Inst{15-12} = 0;
  279. let Inst{7-0} = 0;
  280. let mayLoad = 1;
  281. let Defs = [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, VPR, FPSCR, FPSCR_NZCV];
  282. }
  283. def VLSTM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone,
  284. NoItinerary, "vlstm${p}\t$Rn", "", []>,
  285. Requires<[HasV8MMainline, Has8MSecExt]> {
  286. let Inst{24-23} = 0b00;
  287. let Inst{22} = 0;
  288. let Inst{21} = 1;
  289. let Inst{20} = 0;
  290. let Inst{15-12} = 0;
  291. let Inst{7-0} = 0;
  292. let mayStore = 1;
  293. }
  294. def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r), 0>,
  295. Requires<[HasFPRegs]>;
  296. def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r), 0>,
  297. Requires<[HasFPRegs]>;
  298. def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r), 0>,
  299. Requires<[HasFPRegs]>;
  300. def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r), 0>,
  301. Requires<[HasFPRegs]>;
  302. defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
  303. (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>;
  304. defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
  305. (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>;
  306. defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
  307. (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>;
  308. defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
  309. (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>;
  310. // FLDMX, FSTMX - Load and store multiple unknown precision registers for
  311. // pre-armv6 cores.
  312. // These instruction are deprecated so we don't want them to get selected.
  313. // However, there is no UAL syntax for them, so we keep them around for
  314. // (dis)assembly only.
  315. multiclass vfp_ldstx_mult<string asm, bit L_bit> {
  316. let Predicates = [HasFPRegs], hasNoSchedulingInfo = 1 in {
  317. // Unknown precision
  318. def XIA :
  319. AXXI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
  320. IndexModeNone, !strconcat(asm, "iax${p}\t$Rn, $regs"), "", []> {
  321. let Inst{24-23} = 0b01; // Increment After
  322. let Inst{21} = 0; // No writeback
  323. let Inst{20} = L_bit;
  324. }
  325. def XIA_UPD :
  326. AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
  327. IndexModeUpd, !strconcat(asm, "iax${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  328. let Inst{24-23} = 0b01; // Increment After
  329. let Inst{21} = 1; // Writeback
  330. let Inst{20} = L_bit;
  331. }
  332. def XDB_UPD :
  333. AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
  334. IndexModeUpd, !strconcat(asm, "dbx${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
  335. let Inst{24-23} = 0b10; // Decrement Before
  336. let Inst{21} = 1; // Writeback
  337. let Inst{20} = L_bit;
  338. }
  339. }
  340. }
  341. defm FLDM : vfp_ldstx_mult<"fldm", 1>;
  342. defm FSTM : vfp_ldstx_mult<"fstm", 0>;
  343. def : VFP2MnemonicAlias<"fldmeax", "fldmdbx">;
  344. def : VFP2MnemonicAlias<"fldmfdx", "fldmiax">;
  345. def : VFP2MnemonicAlias<"fstmeax", "fstmiax">;
  346. def : VFP2MnemonicAlias<"fstmfdx", "fstmdbx">;
  347. //===----------------------------------------------------------------------===//
  348. // FP Binary Operations.
  349. //
  350. let TwoOperandAliasConstraint = "$Dn = $Dd" in
  351. def VADDD : ADbI<0b11100, 0b11, 0, 0,
  352. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  353. IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
  354. [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>,
  355. Sched<[WriteFPALU64]>;
  356. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  357. def VADDS : ASbIn<0b11100, 0b11, 0, 0,
  358. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  359. IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
  360. [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>,
  361. Sched<[WriteFPALU32]> {
  362. // Some single precision VFP instructions may be executed on both NEON and
  363. // VFP pipelines on A8.
  364. let D = VFPNeonA8Domain;
  365. }
  366. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  367. def VADDH : AHbI<0b11100, 0b11, 0, 0,
  368. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  369. IIC_fpALU16, "vadd", ".f16\t$Sd, $Sn, $Sm",
  370. [(set (f16 HPR:$Sd), (fadd (f16 HPR:$Sn), (f16 HPR:$Sm)))]>,
  371. Sched<[WriteFPALU32]>;
  372. let TwoOperandAliasConstraint = "$Dn = $Dd" in
  373. def VSUBD : ADbI<0b11100, 0b11, 1, 0,
  374. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  375. IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
  376. [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>,
  377. Sched<[WriteFPALU64]>;
  378. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  379. def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
  380. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  381. IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
  382. [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>,
  383. Sched<[WriteFPALU32]>{
  384. // Some single precision VFP instructions may be executed on both NEON and
  385. // VFP pipelines on A8.
  386. let D = VFPNeonA8Domain;
  387. }
  388. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  389. def VSUBH : AHbI<0b11100, 0b11, 1, 0,
  390. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  391. IIC_fpALU16, "vsub", ".f16\t$Sd, $Sn, $Sm",
  392. [(set (f16 HPR:$Sd), (fsub (f16 HPR:$Sn), (f16 HPR:$Sm)))]>,
  393. Sched<[WriteFPALU32]>;
  394. let TwoOperandAliasConstraint = "$Dn = $Dd" in
  395. def VDIVD : ADbI<0b11101, 0b00, 0, 0,
  396. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  397. IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
  398. [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>,
  399. Sched<[WriteFPDIV64]>;
  400. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  401. def VDIVS : ASbI<0b11101, 0b00, 0, 0,
  402. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  403. IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
  404. [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>,
  405. Sched<[WriteFPDIV32]>;
  406. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  407. def VDIVH : AHbI<0b11101, 0b00, 0, 0,
  408. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  409. IIC_fpDIV16, "vdiv", ".f16\t$Sd, $Sn, $Sm",
  410. [(set (f16 HPR:$Sd), (fdiv (f16 HPR:$Sn), (f16 HPR:$Sm)))]>,
  411. Sched<[WriteFPDIV32]>;
  412. let TwoOperandAliasConstraint = "$Dn = $Dd" in
  413. def VMULD : ADbI<0b11100, 0b10, 0, 0,
  414. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  415. IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
  416. [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>,
  417. Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>;
  418. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  419. def VMULS : ASbIn<0b11100, 0b10, 0, 0,
  420. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  421. IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
  422. [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>,
  423. Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> {
  424. // Some single precision VFP instructions may be executed on both NEON and
  425. // VFP pipelines on A8.
  426. let D = VFPNeonA8Domain;
  427. }
  428. let TwoOperandAliasConstraint = "$Sn = $Sd" in
  429. def VMULH : AHbI<0b11100, 0b10, 0, 0,
  430. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  431. IIC_fpMUL16, "vmul", ".f16\t$Sd, $Sn, $Sm",
  432. [(set (f16 HPR:$Sd), (fmul (f16 HPR:$Sn), (f16 HPR:$Sm)))]>,
  433. Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>;
  434. def VNMULD : ADbI<0b11100, 0b10, 1, 0,
  435. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  436. IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
  437. [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>,
  438. Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>;
  439. def VNMULS : ASbI<0b11100, 0b10, 1, 0,
  440. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  441. IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
  442. [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>,
  443. Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> {
  444. // Some single precision VFP instructions may be executed on both NEON and
  445. // VFP pipelines on A8.
  446. let D = VFPNeonA8Domain;
  447. }
  448. def VNMULH : AHbI<0b11100, 0b10, 1, 0,
  449. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  450. IIC_fpMUL16, "vnmul", ".f16\t$Sd, $Sn, $Sm",
  451. [(set (f16 HPR:$Sd), (fneg (fmul (f16 HPR:$Sn), (f16 HPR:$Sm))))]>,
  452. Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>;
  453. multiclass vsel_inst<string op, bits<2> opc, int CC> {
  454. let DecoderNamespace = "VFPV8", PostEncoderMethod = "",
  455. Uses = [CPSR], AddedComplexity = 4, isUnpredicable = 1 in {
  456. def H : AHbInp<0b11100, opc, 0,
  457. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  458. NoItinerary, !strconcat("vsel", op, ".f16\t$Sd, $Sn, $Sm"),
  459. [(set (f16 HPR:$Sd), (ARMcmov (f16 HPR:$Sm), (f16 HPR:$Sn), CC))]>,
  460. Requires<[HasFullFP16]>;
  461. def S : ASbInp<0b11100, opc, 0,
  462. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  463. NoItinerary, !strconcat("vsel", op, ".f32\t$Sd, $Sn, $Sm"),
  464. [(set SPR:$Sd, (ARMcmov SPR:$Sm, SPR:$Sn, CC))]>,
  465. Requires<[HasFPARMv8]>;
  466. def D : ADbInp<0b11100, opc, 0,
  467. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  468. NoItinerary, !strconcat("vsel", op, ".f64\t$Dd, $Dn, $Dm"),
  469. [(set DPR:$Dd, (ARMcmov (f64 DPR:$Dm), (f64 DPR:$Dn), CC))]>,
  470. Requires<[HasFPARMv8, HasDPVFP]>;
  471. }
  472. }
  473. // The CC constants here match ARMCC::CondCodes.
  474. defm VSELGT : vsel_inst<"gt", 0b11, 12>;
  475. defm VSELGE : vsel_inst<"ge", 0b10, 10>;
  476. defm VSELEQ : vsel_inst<"eq", 0b00, 0>;
  477. defm VSELVS : vsel_inst<"vs", 0b01, 6>;
  478. multiclass vmaxmin_inst<string op, bit opc, SDNode SD> {
  479. let DecoderNamespace = "VFPV8", PostEncoderMethod = "",
  480. isUnpredicable = 1 in {
  481. def H : AHbInp<0b11101, 0b00, opc,
  482. (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
  483. NoItinerary, !strconcat(op, ".f16\t$Sd, $Sn, $Sm"),
  484. [(set (f16 HPR:$Sd), (SD (f16 HPR:$Sn), (f16 HPR:$Sm)))]>,
  485. Requires<[HasFullFP16]>;
  486. def S : ASbInp<0b11101, 0b00, opc,
  487. (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
  488. NoItinerary, !strconcat(op, ".f32\t$Sd, $Sn, $Sm"),
  489. [(set SPR:$Sd, (SD SPR:$Sn, SPR:$Sm))]>,
  490. Requires<[HasFPARMv8]>;
  491. def D : ADbInp<0b11101, 0b00, opc,
  492. (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
  493. NoItinerary, !strconcat(op, ".f64\t$Dd, $Dn, $Dm"),
  494. [(set DPR:$Dd, (f64 (SD (f64 DPR:$Dn), (f64 DPR:$Dm))))]>,
  495. Requires<[HasFPARMv8, HasDPVFP]>;
  496. }
  497. }
  498. defm VFP_VMAXNM : vmaxmin_inst<"vmaxnm", 0, fmaxnum>;
  499. defm VFP_VMINNM : vmaxmin_inst<"vminnm", 1, fminnum>;
  500. // Match reassociated forms only if not sign dependent rounding.
  501. def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
  502. (VNMULD DPR:$a, DPR:$b)>,
  503. Requires<[NoHonorSignDependentRounding,HasDPVFP]>;
  504. def : Pat<(fmul (fneg SPR:$a), SPR:$b),
  505. (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
  506. // These are encoded as unary instructions.
  507. let Defs = [FPSCR_NZCV] in {
  508. def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
  509. (outs), (ins DPR:$Dd, DPR:$Dm),
  510. IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
  511. [(arm_cmpfpe DPR:$Dd, (f64 DPR:$Dm))]>;
  512. def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
  513. (outs), (ins SPR:$Sd, SPR:$Sm),
  514. IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
  515. [(arm_cmpfpe SPR:$Sd, SPR:$Sm)]> {
  516. // Some single precision VFP instructions may be executed on both NEON and
  517. // VFP pipelines on A8.
  518. let D = VFPNeonA8Domain;
  519. }
  520. def VCMPEH : AHuI<0b11101, 0b11, 0b0100, 0b11, 0,
  521. (outs), (ins HPR:$Sd, HPR:$Sm),
  522. IIC_fpCMP16, "vcmpe", ".f16\t$Sd, $Sm",
  523. [(arm_cmpfpe (f16 HPR:$Sd), (f16 HPR:$Sm))]>;
  524. def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
  525. (outs), (ins DPR:$Dd, DPR:$Dm),
  526. IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
  527. [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
  528. def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
  529. (outs), (ins SPR:$Sd, SPR:$Sm),
  530. IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
  531. [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
  532. // Some single precision VFP instructions may be executed on both NEON and
  533. // VFP pipelines on A8.
  534. let D = VFPNeonA8Domain;
  535. }
  536. def VCMPH : AHuI<0b11101, 0b11, 0b0100, 0b01, 0,
  537. (outs), (ins HPR:$Sd, HPR:$Sm),
  538. IIC_fpCMP16, "vcmp", ".f16\t$Sd, $Sm",
  539. [(arm_cmpfp (f16 HPR:$Sd), (f16 HPR:$Sm))]>;
  540. } // Defs = [FPSCR_NZCV]
  541. //===----------------------------------------------------------------------===//
  542. // FP Unary Operations.
  543. //
  544. def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
  545. (outs DPR:$Dd), (ins DPR:$Dm),
  546. IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
  547. [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
  548. def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
  549. (outs SPR:$Sd), (ins SPR:$Sm),
  550. IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
  551. [(set SPR:$Sd, (fabs SPR:$Sm))]> {
  552. // Some single precision VFP instructions may be executed on both NEON and
  553. // VFP pipelines on A8.
  554. let D = VFPNeonA8Domain;
  555. }
  556. def VABSH : AHuI<0b11101, 0b11, 0b0000, 0b11, 0,
  557. (outs HPR:$Sd), (ins HPR:$Sm),
  558. IIC_fpUNA16, "vabs", ".f16\t$Sd, $Sm",
  559. [(set (f16 HPR:$Sd), (fabs (f16 HPR:$Sm)))]>;
  560. let Defs = [FPSCR_NZCV] in {
  561. def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
  562. (outs), (ins DPR:$Dd),
  563. IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
  564. [(arm_cmpfpe0 (f64 DPR:$Dd))]> {
  565. let Inst{3-0} = 0b0000;
  566. let Inst{5} = 0;
  567. }
  568. def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
  569. (outs), (ins SPR:$Sd),
  570. IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
  571. [(arm_cmpfpe0 SPR:$Sd)]> {
  572. let Inst{3-0} = 0b0000;
  573. let Inst{5} = 0;
  574. // Some single precision VFP instructions may be executed on both NEON and
  575. // VFP pipelines on A8.
  576. let D = VFPNeonA8Domain;
  577. }
  578. def VCMPEZH : AHuI<0b11101, 0b11, 0b0101, 0b11, 0,
  579. (outs), (ins HPR:$Sd),
  580. IIC_fpCMP16, "vcmpe", ".f16\t$Sd, #0",
  581. [(arm_cmpfpe0 (f16 HPR:$Sd))]> {
  582. let Inst{3-0} = 0b0000;
  583. let Inst{5} = 0;
  584. }
  585. def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
  586. (outs), (ins DPR:$Dd),
  587. IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
  588. [(arm_cmpfp0 (f64 DPR:$Dd))]> {
  589. let Inst{3-0} = 0b0000;
  590. let Inst{5} = 0;
  591. }
  592. def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
  593. (outs), (ins SPR:$Sd),
  594. IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
  595. [(arm_cmpfp0 SPR:$Sd)]> {
  596. let Inst{3-0} = 0b0000;
  597. let Inst{5} = 0;
  598. // Some single precision VFP instructions may be executed on both NEON and
  599. // VFP pipelines on A8.
  600. let D = VFPNeonA8Domain;
  601. }
  602. def VCMPZH : AHuI<0b11101, 0b11, 0b0101, 0b01, 0,
  603. (outs), (ins HPR:$Sd),
  604. IIC_fpCMP16, "vcmp", ".f16\t$Sd, #0",
  605. [(arm_cmpfp0 (f16 HPR:$Sd))]> {
  606. let Inst{3-0} = 0b0000;
  607. let Inst{5} = 0;
  608. }
  609. } // Defs = [FPSCR_NZCV]
  610. def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
  611. (outs DPR:$Dd), (ins SPR:$Sm),
  612. IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
  613. [(set DPR:$Dd, (fpextend SPR:$Sm))]>,
  614. Sched<[WriteFPCVT]> {
  615. // Instruction operands.
  616. bits<5> Dd;
  617. bits<5> Sm;
  618. // Encode instruction operands.
  619. let Inst{3-0} = Sm{4-1};
  620. let Inst{5} = Sm{0};
  621. let Inst{15-12} = Dd{3-0};
  622. let Inst{22} = Dd{4};
  623. let Predicates = [HasVFP2, HasDPVFP];
  624. let hasSideEffects = 0;
  625. }
  626. // Special case encoding: bits 11-8 is 0b1011.
  627. def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
  628. IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
  629. [(set SPR:$Sd, (fpround DPR:$Dm))]>,
  630. Sched<[WriteFPCVT]> {
  631. // Instruction operands.
  632. bits<5> Sd;
  633. bits<5> Dm;
  634. // Encode instruction operands.
  635. let Inst{3-0} = Dm{3-0};
  636. let Inst{5} = Dm{4};
  637. let Inst{15-12} = Sd{4-1};
  638. let Inst{22} = Sd{0};
  639. let Inst{27-23} = 0b11101;
  640. let Inst{21-16} = 0b110111;
  641. let Inst{11-8} = 0b1011;
  642. let Inst{7-6} = 0b11;
  643. let Inst{4} = 0;
  644. let Predicates = [HasVFP2, HasDPVFP];
  645. let hasSideEffects = 0;
  646. }
  647. // Between half, single and double-precision.
  648. let hasSideEffects = 0 in
  649. def VCVTBHS: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
  650. /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
  651. [/* Intentionally left blank, see patterns below */]>,
  652. Requires<[HasFP16]>,
  653. Sched<[WriteFPCVT]>;
  654. def : FP16Pat<(f32 (fpextend (f16 HPR:$Sm))),
  655. (VCVTBHS (COPY_TO_REGCLASS (f16 HPR:$Sm), SPR))>;
  656. def : FP16Pat<(f16_to_fp GPR:$a),
  657. (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
  658. let hasSideEffects = 0 in
  659. def VCVTBSH: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
  660. /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
  661. [/* Intentionally left blank, see patterns below */]>,
  662. Requires<[HasFP16]>,
  663. Sched<[WriteFPCVT]>;
  664. def : FP16Pat<(f16 (fpround SPR:$Sm)),
  665. (COPY_TO_REGCLASS (VCVTBSH SPR:$Sm), HPR)>;
  666. def : FP16Pat<(fp_to_f16 SPR:$a),
  667. (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
  668. def : FP16Pat<(insertelt (v8f16 MQPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_even:$lane),
  669. (v8f16 (INSERT_SUBREG (v8f16 MQPR:$src1), (VCVTBSH SPR:$src2),
  670. (SSubReg_f16_reg imm:$lane)))>;
  671. def : FP16Pat<(insertelt (v4f16 DPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_even:$lane),
  672. (v4f16 (INSERT_SUBREG (v4f16 DPR:$src1), (VCVTBSH SPR:$src2),
  673. (SSubReg_f16_reg imm:$lane)))>;
  674. let hasSideEffects = 0 in
  675. def VCVTTHS: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
  676. /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
  677. [/* Intentionally left blank, see patterns below */]>,
  678. Requires<[HasFP16]>,
  679. Sched<[WriteFPCVT]>;
  680. def : FP16Pat<(f32 (fpextend (extractelt (v8f16 MQPR:$src), imm_odd:$lane))),
  681. (VCVTTHS (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane)))>;
  682. def : FP16Pat<(f32 (fpextend (extractelt (v4f16 DPR:$src), imm_odd:$lane))),
  683. (VCVTTHS (EXTRACT_SUBREG
  684. (v2f32 (COPY_TO_REGCLASS (v4f16 DPR:$src), DPR_VFP2)),
  685. (SSubReg_f16_reg imm_odd:$lane)))>;
  686. let hasSideEffects = 0 in
  687. def VCVTTSH: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
  688. /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
  689. [/* Intentionally left blank, see patterns below */]>,
  690. Requires<[HasFP16]>,
  691. Sched<[WriteFPCVT]>;
  692. def : FP16Pat<(insertelt (v8f16 MQPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_odd:$lane),
  693. (v8f16 (INSERT_SUBREG (v8f16 MQPR:$src1), (VCVTTSH SPR:$src2),
  694. (SSubReg_f16_reg imm:$lane)))>;
  695. def : FP16Pat<(insertelt (v4f16 DPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_odd:$lane),
  696. (v4f16 (INSERT_SUBREG (v4f16 DPR:$src1), (VCVTTSH SPR:$src2),
  697. (SSubReg_f16_reg imm:$lane)))>;
  698. def VCVTBHD : ADuI<0b11101, 0b11, 0b0010, 0b01, 0,
  699. (outs DPR:$Dd), (ins SPR:$Sm),
  700. NoItinerary, "vcvtb", ".f64.f16\t$Dd, $Sm",
  701. [/* Intentionally left blank, see patterns below */]>,
  702. Requires<[HasFPARMv8, HasDPVFP]>,
  703. Sched<[WriteFPCVT]> {
  704. // Instruction operands.
  705. bits<5> Sm;
  706. // Encode instruction operands.
  707. let Inst{3-0} = Sm{4-1};
  708. let Inst{5} = Sm{0};
  709. let hasSideEffects = 0;
  710. }
  711. def : FullFP16Pat<(f64 (fpextend (f16 HPR:$Sm))),
  712. (VCVTBHD (COPY_TO_REGCLASS (f16 HPR:$Sm), SPR))>,
  713. Requires<[HasFPARMv8, HasDPVFP]>;
  714. def : FP16Pat<(f64 (f16_to_fp GPR:$a)),
  715. (VCVTBHD (COPY_TO_REGCLASS GPR:$a, SPR))>,
  716. Requires<[HasFPARMv8, HasDPVFP]>;
  717. def VCVTBDH : ADuI<0b11101, 0b11, 0b0011, 0b01, 0,
  718. (outs SPR:$Sd), (ins DPR:$Dm),
  719. NoItinerary, "vcvtb", ".f16.f64\t$Sd, $Dm",
  720. [/* Intentionally left blank, see patterns below */]>,
  721. Requires<[HasFPARMv8, HasDPVFP]> {
  722. // Instruction operands.
  723. bits<5> Sd;
  724. bits<5> Dm;
  725. // Encode instruction operands.
  726. let Inst{3-0} = Dm{3-0};
  727. let Inst{5} = Dm{4};
  728. let Inst{15-12} = Sd{4-1};
  729. let Inst{22} = Sd{0};
  730. let hasSideEffects = 0;
  731. }
  732. def : FullFP16Pat<(f16 (fpround DPR:$Dm)),
  733. (COPY_TO_REGCLASS (VCVTBDH DPR:$Dm), HPR)>,
  734. Requires<[HasFPARMv8, HasDPVFP]>;
  735. def : FP16Pat<(fp_to_f16 (f64 DPR:$a)),
  736. (i32 (COPY_TO_REGCLASS (VCVTBDH DPR:$a), GPR))>,
  737. Requires<[HasFPARMv8, HasDPVFP]>;
  738. def VCVTTHD : ADuI<0b11101, 0b11, 0b0010, 0b11, 0,
  739. (outs DPR:$Dd), (ins SPR:$Sm),
  740. NoItinerary, "vcvtt", ".f64.f16\t$Dd, $Sm",
  741. []>, Requires<[HasFPARMv8, HasDPVFP]> {
  742. // Instruction operands.
  743. bits<5> Sm;
  744. // Encode instruction operands.
  745. let Inst{3-0} = Sm{4-1};
  746. let Inst{5} = Sm{0};
  747. let hasSideEffects = 0;
  748. }
  749. def VCVTTDH : ADuI<0b11101, 0b11, 0b0011, 0b11, 0,
  750. (outs SPR:$Sd), (ins DPR:$Dm),
  751. NoItinerary, "vcvtt", ".f16.f64\t$Sd, $Dm",
  752. []>, Requires<[HasFPARMv8, HasDPVFP]> {
  753. // Instruction operands.
  754. bits<5> Sd;
  755. bits<5> Dm;
  756. // Encode instruction operands.
  757. let Inst{15-12} = Sd{4-1};
  758. let Inst{22} = Sd{0};
  759. let Inst{3-0} = Dm{3-0};
  760. let Inst{5} = Dm{4};
  761. let hasSideEffects = 0;
  762. }
  763. multiclass vcvt_inst<string opc, bits<2> rm,
  764. SDPatternOperator node = null_frag> {
  765. let PostEncoderMethod = "", DecoderNamespace = "VFPV8", hasSideEffects = 0 in {
  766. def SH : AHuInp<0b11101, 0b11, 0b1100, 0b11, 0,
  767. (outs SPR:$Sd), (ins HPR:$Sm),
  768. NoItinerary, !strconcat("vcvt", opc, ".s32.f16\t$Sd, $Sm"),
  769. []>,
  770. Requires<[HasFullFP16]> {
  771. let Inst{17-16} = rm;
  772. }
  773. def UH : AHuInp<0b11101, 0b11, 0b1100, 0b01, 0,
  774. (outs SPR:$Sd), (ins HPR:$Sm),
  775. NoItinerary, !strconcat("vcvt", opc, ".u32.f16\t$Sd, $Sm"),
  776. []>,
  777. Requires<[HasFullFP16]> {
  778. let Inst{17-16} = rm;
  779. }
  780. def SS : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0,
  781. (outs SPR:$Sd), (ins SPR:$Sm),
  782. NoItinerary, !strconcat("vcvt", opc, ".s32.f32\t$Sd, $Sm"),
  783. []>,
  784. Requires<[HasFPARMv8]> {
  785. let Inst{17-16} = rm;
  786. }
  787. def US : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0,
  788. (outs SPR:$Sd), (ins SPR:$Sm),
  789. NoItinerary, !strconcat("vcvt", opc, ".u32.f32\t$Sd, $Sm"),
  790. []>,
  791. Requires<[HasFPARMv8]> {
  792. let Inst{17-16} = rm;
  793. }
  794. def SD : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0,
  795. (outs SPR:$Sd), (ins DPR:$Dm),
  796. NoItinerary, !strconcat("vcvt", opc, ".s32.f64\t$Sd, $Dm"),
  797. []>,
  798. Requires<[HasFPARMv8, HasDPVFP]> {
  799. bits<5> Dm;
  800. let Inst{17-16} = rm;
  801. // Encode instruction operands.
  802. let Inst{3-0} = Dm{3-0};
  803. let Inst{5} = Dm{4};
  804. let Inst{8} = 1;
  805. }
  806. def UD : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0,
  807. (outs SPR:$Sd), (ins DPR:$Dm),
  808. NoItinerary, !strconcat("vcvt", opc, ".u32.f64\t$Sd, $Dm"),
  809. []>,
  810. Requires<[HasFPARMv8, HasDPVFP]> {
  811. bits<5> Dm;
  812. let Inst{17-16} = rm;
  813. // Encode instruction operands
  814. let Inst{3-0} = Dm{3-0};
  815. let Inst{5} = Dm{4};
  816. let Inst{8} = 1;
  817. }
  818. }
  819. let Predicates = [HasFPARMv8] in {
  820. let Predicates = [HasFullFP16] in {
  821. def : Pat<(i32 (fp_to_sint (node (f16 HPR:$a)))),
  822. (COPY_TO_REGCLASS
  823. (!cast<Instruction>(NAME#"SH") (f16 HPR:$a)),
  824. GPR)>;
  825. def : Pat<(i32 (fp_to_uint (node (f16 HPR:$a)))),
  826. (COPY_TO_REGCLASS
  827. (!cast<Instruction>(NAME#"UH") (f16 HPR:$a)),
  828. GPR)>;
  829. }
  830. def : Pat<(i32 (fp_to_sint (node SPR:$a))),
  831. (COPY_TO_REGCLASS
  832. (!cast<Instruction>(NAME#"SS") SPR:$a),
  833. GPR)>;
  834. def : Pat<(i32 (fp_to_uint (node SPR:$a))),
  835. (COPY_TO_REGCLASS
  836. (!cast<Instruction>(NAME#"US") SPR:$a),
  837. GPR)>;
  838. }
  839. let Predicates = [HasFPARMv8, HasDPVFP] in {
  840. def : Pat<(i32 (fp_to_sint (node (f64 DPR:$a)))),
  841. (COPY_TO_REGCLASS
  842. (!cast<Instruction>(NAME#"SD") DPR:$a),
  843. GPR)>;
  844. def : Pat<(i32 (fp_to_uint (node (f64 DPR:$a)))),
  845. (COPY_TO_REGCLASS
  846. (!cast<Instruction>(NAME#"UD") DPR:$a),
  847. GPR)>;
  848. }
  849. }
  850. defm VCVTA : vcvt_inst<"a", 0b00, fround>;
  851. defm VCVTN : vcvt_inst<"n", 0b01>;
  852. defm VCVTP : vcvt_inst<"p", 0b10, fceil>;
  853. defm VCVTM : vcvt_inst<"m", 0b11, ffloor>;
  854. def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
  855. (outs DPR:$Dd), (ins DPR:$Dm),
  856. IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
  857. [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
  858. def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
  859. (outs SPR:$Sd), (ins SPR:$Sm),
  860. IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
  861. [(set SPR:$Sd, (fneg SPR:$Sm))]> {
  862. // Some single precision VFP instructions may be executed on both NEON and
  863. // VFP pipelines on A8.
  864. let D = VFPNeonA8Domain;
  865. }
  866. def VNEGH : AHuI<0b11101, 0b11, 0b0001, 0b01, 0,
  867. (outs HPR:$Sd), (ins HPR:$Sm),
  868. IIC_fpUNA16, "vneg", ".f16\t$Sd, $Sm",
  869. [(set (f16 HPR:$Sd), (fneg (f16 HPR:$Sm)))]>;
  870. multiclass vrint_inst_zrx<string opc, bit op, bit op2, SDPatternOperator node> {
  871. def H : AHuI<0b11101, 0b11, 0b0110, 0b11, 0,
  872. (outs HPR:$Sd), (ins HPR:$Sm),
  873. NoItinerary, !strconcat("vrint", opc), ".f16\t$Sd, $Sm",
  874. [(set (f16 HPR:$Sd), (node (f16 HPR:$Sm)))]>,
  875. Requires<[HasFullFP16]> {
  876. let Inst{7} = op2;
  877. let Inst{16} = op;
  878. }
  879. def S : ASuI<0b11101, 0b11, 0b0110, 0b11, 0,
  880. (outs SPR:$Sd), (ins SPR:$Sm),
  881. NoItinerary, !strconcat("vrint", opc), ".f32\t$Sd, $Sm",
  882. [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>,
  883. Requires<[HasFPARMv8]> {
  884. let Inst{7} = op2;
  885. let Inst{16} = op;
  886. }
  887. def D : ADuI<0b11101, 0b11, 0b0110, 0b11, 0,
  888. (outs DPR:$Dd), (ins DPR:$Dm),
  889. NoItinerary, !strconcat("vrint", opc), ".f64\t$Dd, $Dm",
  890. [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>,
  891. Requires<[HasFPARMv8, HasDPVFP]> {
  892. let Inst{7} = op2;
  893. let Inst{16} = op;
  894. }
  895. def : InstAlias<!strconcat("vrint", opc, "$p.f16.f16\t$Sd, $Sm"),
  896. (!cast<Instruction>(NAME#"H") SPR:$Sd, SPR:$Sm, pred:$p), 0>,
  897. Requires<[HasFullFP16]>;
  898. def : InstAlias<!strconcat("vrint", opc, "$p.f32.f32\t$Sd, $Sm"),
  899. (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm, pred:$p), 0>,
  900. Requires<[HasFPARMv8]>;
  901. def : InstAlias<!strconcat("vrint", opc, "$p.f64.f64\t$Dd, $Dm"),
  902. (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm, pred:$p), 0>,
  903. Requires<[HasFPARMv8,HasDPVFP]>;
  904. }
  905. defm VRINTZ : vrint_inst_zrx<"z", 0, 1, ftrunc>;
  906. defm VRINTR : vrint_inst_zrx<"r", 0, 0, fnearbyint>;
  907. defm VRINTX : vrint_inst_zrx<"x", 1, 0, frint>;
  908. multiclass vrint_inst_anpm<string opc, bits<2> rm,
  909. SDPatternOperator node = null_frag> {
  910. let PostEncoderMethod = "", DecoderNamespace = "VFPV8",
  911. isUnpredicable = 1 in {
  912. def H : AHuInp<0b11101, 0b11, 0b1000, 0b01, 0,
  913. (outs HPR:$Sd), (ins HPR:$Sm),
  914. NoItinerary, !strconcat("vrint", opc, ".f16\t$Sd, $Sm"),
  915. [(set (f16 HPR:$Sd), (node (f16 HPR:$Sm)))]>,
  916. Requires<[HasFullFP16]> {
  917. let Inst{17-16} = rm;
  918. }
  919. def S : ASuInp<0b11101, 0b11, 0b1000, 0b01, 0,
  920. (outs SPR:$Sd), (ins SPR:$Sm),
  921. NoItinerary, !strconcat("vrint", opc, ".f32\t$Sd, $Sm"),
  922. [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>,
  923. Requires<[HasFPARMv8]> {
  924. let Inst{17-16} = rm;
  925. }
  926. def D : ADuInp<0b11101, 0b11, 0b1000, 0b01, 0,
  927. (outs DPR:$Dd), (ins DPR:$Dm),
  928. NoItinerary, !strconcat("vrint", opc, ".f64\t$Dd, $Dm"),
  929. [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>,
  930. Requires<[HasFPARMv8, HasDPVFP]> {
  931. let Inst{17-16} = rm;
  932. }
  933. }
  934. def : InstAlias<!strconcat("vrint", opc, ".f16.f16\t$Sd, $Sm"),
  935. (!cast<Instruction>(NAME#"H") HPR:$Sd, HPR:$Sm), 0>,
  936. Requires<[HasFullFP16]>;
  937. def : InstAlias<!strconcat("vrint", opc, ".f32.f32\t$Sd, $Sm"),
  938. (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm), 0>,
  939. Requires<[HasFPARMv8]>;
  940. def : InstAlias<!strconcat("vrint", opc, ".f64.f64\t$Dd, $Dm"),
  941. (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm), 0>,
  942. Requires<[HasFPARMv8,HasDPVFP]>;
  943. }
  944. defm VRINTA : vrint_inst_anpm<"a", 0b00, fround>;
  945. defm VRINTN : vrint_inst_anpm<"n", 0b01, int_arm_neon_vrintn>;
  946. defm VRINTP : vrint_inst_anpm<"p", 0b10, fceil>;
  947. defm VRINTM : vrint_inst_anpm<"m", 0b11, ffloor>;
  948. def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
  949. (outs DPR:$Dd), (ins DPR:$Dm),
  950. IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
  951. [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>,
  952. Sched<[WriteFPSQRT64]>;
  953. def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
  954. (outs SPR:$Sd), (ins SPR:$Sm),
  955. IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
  956. [(set SPR:$Sd, (fsqrt SPR:$Sm))]>,
  957. Sched<[WriteFPSQRT32]>;
  958. def VSQRTH : AHuI<0b11101, 0b11, 0b0001, 0b11, 0,
  959. (outs HPR:$Sd), (ins HPR:$Sm),
  960. IIC_fpSQRT16, "vsqrt", ".f16\t$Sd, $Sm",
  961. [(set (f16 HPR:$Sd), (fsqrt (f16 HPR:$Sm)))]>;
  962. let hasSideEffects = 0 in {
  963. let isMoveReg = 1 in {
  964. def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
  965. (outs DPR:$Dd), (ins DPR:$Dm),
  966. IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>,
  967. Requires<[HasFPRegs64]>;
  968. def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
  969. (outs SPR:$Sd), (ins SPR:$Sm),
  970. IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>,
  971. Requires<[HasFPRegs]>;
  972. } // isMoveReg
  973. let PostEncoderMethod = "", DecoderNamespace = "VFPV8", isUnpredicable = 1 in {
  974. def VMOVH : ASuInp<0b11101, 0b11, 0b0000, 0b01, 0,
  975. (outs SPR:$Sd), (ins SPR:$Sm),
  976. IIC_fpUNA16, "vmovx.f16\t$Sd, $Sm", []>,
  977. Requires<[HasFullFP16]>;
  978. def VINSH : ASuInp<0b11101, 0b11, 0b0000, 0b11, 0,
  979. (outs SPR:$Sd), (ins SPR:$Sda, SPR:$Sm),
  980. IIC_fpUNA16, "vins.f16\t$Sd, $Sm", []>,
  981. Requires<[HasFullFP16]> {
  982. let Constraints = "$Sd = $Sda";
  983. }
  984. } // PostEncoderMethod
  985. } // hasSideEffects
  986. //===----------------------------------------------------------------------===//
  987. // FP <-> GPR Copies. Int <-> FP Conversions.
  988. //
  989. let isMoveReg = 1 in {
  990. def VMOVRS : AVConv2I<0b11100001, 0b1010,
  991. (outs GPR:$Rt), (ins SPR:$Sn),
  992. IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
  993. [(set GPR:$Rt, (bitconvert SPR:$Sn))]>,
  994. Requires<[HasFPRegs]>,
  995. Sched<[WriteFPMOV]> {
  996. // Instruction operands.
  997. bits<4> Rt;
  998. bits<5> Sn;
  999. // Encode instruction operands.
  1000. let Inst{19-16} = Sn{4-1};
  1001. let Inst{7} = Sn{0};
  1002. let Inst{15-12} = Rt;
  1003. let Inst{6-5} = 0b00;
  1004. let Inst{3-0} = 0b0000;
  1005. // Some single precision VFP instructions may be executed on both NEON and VFP
  1006. // pipelines.
  1007. let D = VFPNeonDomain;
  1008. }
  1009. // Bitcast i32 -> f32. NEON prefers to use VMOVDRR.
  1010. def VMOVSR : AVConv4I<0b11100000, 0b1010,
  1011. (outs SPR:$Sn), (ins GPR:$Rt),
  1012. IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
  1013. [(set SPR:$Sn, (bitconvert GPR:$Rt))]>,
  1014. Requires<[HasFPRegs, UseVMOVSR]>,
  1015. Sched<[WriteFPMOV]> {
  1016. // Instruction operands.
  1017. bits<5> Sn;
  1018. bits<4> Rt;
  1019. // Encode instruction operands.
  1020. let Inst{19-16} = Sn{4-1};
  1021. let Inst{7} = Sn{0};
  1022. let Inst{15-12} = Rt;
  1023. let Inst{6-5} = 0b00;
  1024. let Inst{3-0} = 0b0000;
  1025. // Some single precision VFP instructions may be executed on both NEON and VFP
  1026. // pipelines.
  1027. let D = VFPNeonDomain;
  1028. }
  1029. } // isMoveReg
  1030. def : Pat<(arm_vmovsr GPR:$Rt), (VMOVSR GPR:$Rt)>, Requires<[HasVFP2, UseVMOVSR]>;
  1031. let hasSideEffects = 0 in {
  1032. def VMOVRRD : AVConv3I<0b11000101, 0b1011,
  1033. (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
  1034. IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
  1035. [(set GPR:$Rt, GPR:$Rt2, (arm_fmrrd DPR:$Dm))]>,
  1036. Requires<[HasFPRegs]>,
  1037. Sched<[WriteFPMOV]> {
  1038. // Instruction operands.
  1039. bits<5> Dm;
  1040. bits<4> Rt;
  1041. bits<4> Rt2;
  1042. // Encode instruction operands.
  1043. let Inst{3-0} = Dm{3-0};
  1044. let Inst{5} = Dm{4};
  1045. let Inst{15-12} = Rt;
  1046. let Inst{19-16} = Rt2;
  1047. let Inst{7-6} = 0b00;
  1048. // Some single precision VFP instructions may be executed on both NEON and VFP
  1049. // pipelines.
  1050. let D = VFPNeonDomain;
  1051. // This instruction is equivalent to
  1052. // $Rt = EXTRACT_SUBREG $Dm, ssub_0
  1053. // $Rt2 = EXTRACT_SUBREG $Dm, ssub_1
  1054. let isExtractSubreg = 1;
  1055. }
  1056. def VMOVRRS : AVConv3I<0b11000101, 0b1010,
  1057. (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
  1058. IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
  1059. [/* For disassembly only; pattern left blank */]>,
  1060. Requires<[HasFPRegs]>,
  1061. Sched<[WriteFPMOV]> {
  1062. bits<5> src1;
  1063. bits<4> Rt;
  1064. bits<4> Rt2;
  1065. // Encode instruction operands.
  1066. let Inst{3-0} = src1{4-1};
  1067. let Inst{5} = src1{0};
  1068. let Inst{15-12} = Rt;
  1069. let Inst{19-16} = Rt2;
  1070. let Inst{7-6} = 0b00;
  1071. // Some single precision VFP instructions may be executed on both NEON and VFP
  1072. // pipelines.
  1073. let D = VFPNeonDomain;
  1074. let DecoderMethod = "DecodeVMOVRRS";
  1075. }
  1076. } // hasSideEffects
  1077. // FMDHR: GPR -> SPR
  1078. // FMDLR: GPR -> SPR
  1079. def VMOVDRR : AVConv5I<0b11000100, 0b1011,
  1080. (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
  1081. IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
  1082. [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]>,
  1083. Requires<[HasFPRegs]>,
  1084. Sched<[WriteFPMOV]> {
  1085. // Instruction operands.
  1086. bits<5> Dm;
  1087. bits<4> Rt;
  1088. bits<4> Rt2;
  1089. // Encode instruction operands.
  1090. let Inst{3-0} = Dm{3-0};
  1091. let Inst{5} = Dm{4};
  1092. let Inst{15-12} = Rt;
  1093. let Inst{19-16} = Rt2;
  1094. let Inst{7-6} = 0b00;
  1095. // Some single precision VFP instructions may be executed on both NEON and VFP
  1096. // pipelines.
  1097. let D = VFPNeonDomain;
  1098. // This instruction is equivalent to
  1099. // $Dm = REG_SEQUENCE $Rt, ssub_0, $Rt2, ssub_1
  1100. let isRegSequence = 1;
  1101. }
  1102. // Hoist an fabs or a fneg of a value coming from integer registers
  1103. // and do the fabs/fneg on the integer value. This is never a lose
  1104. // and could enable the conversion to float to be removed completely.
  1105. def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)),
  1106. (VMOVDRR GPR:$Rl, (BFC GPR:$Rh, (i32 0x7FFFFFFF)))>,
  1107. Requires<[IsARM, HasV6T2]>;
  1108. def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)),
  1109. (VMOVDRR GPR:$Rl, (t2BFC GPR:$Rh, (i32 0x7FFFFFFF)))>,
  1110. Requires<[IsThumb2, HasV6T2]>;
  1111. def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)),
  1112. (VMOVDRR GPR:$Rl, (EORri GPR:$Rh, (i32 0x80000000)))>,
  1113. Requires<[IsARM]>;
  1114. def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)),
  1115. (VMOVDRR GPR:$Rl, (t2EORri GPR:$Rh, (i32 0x80000000)))>,
  1116. Requires<[IsThumb2]>;
  1117. let hasSideEffects = 0 in
  1118. def VMOVSRR : AVConv5I<0b11000100, 0b1010,
  1119. (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
  1120. IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
  1121. [/* For disassembly only; pattern left blank */]>,
  1122. Requires<[HasFPRegs]>,
  1123. Sched<[WriteFPMOV]> {
  1124. // Instruction operands.
  1125. bits<5> dst1;
  1126. bits<4> src1;
  1127. bits<4> src2;
  1128. // Encode instruction operands.
  1129. let Inst{3-0} = dst1{4-1};
  1130. let Inst{5} = dst1{0};
  1131. let Inst{15-12} = src1;
  1132. let Inst{19-16} = src2;
  1133. let Inst{7-6} = 0b00;
  1134. // Some single precision VFP instructions may be executed on both NEON and VFP
  1135. // pipelines.
  1136. let D = VFPNeonDomain;
  1137. let DecoderMethod = "DecodeVMOVSRR";
  1138. }
  1139. // Move H->R, clearing top 16 bits
  1140. def VMOVRH : AVConv2I<0b11100001, 0b1001,
  1141. (outs rGPR:$Rt), (ins HPR:$Sn),
  1142. IIC_fpMOVSI, "vmov", ".f16\t$Rt, $Sn",
  1143. []>,
  1144. Requires<[HasFPRegs16]>,
  1145. Sched<[WriteFPMOV]> {
  1146. // Instruction operands.
  1147. bits<4> Rt;
  1148. bits<5> Sn;
  1149. // Encode instruction operands.
  1150. let Inst{19-16} = Sn{4-1};
  1151. let Inst{7} = Sn{0};
  1152. let Inst{15-12} = Rt;
  1153. let Inst{6-5} = 0b00;
  1154. let Inst{3-0} = 0b0000;
  1155. let isUnpredicable = 1;
  1156. }
  1157. // Move R->H, clearing top 16 bits
  1158. def VMOVHR : AVConv4I<0b11100000, 0b1001,
  1159. (outs HPR:$Sn), (ins rGPR:$Rt),
  1160. IIC_fpMOVIS, "vmov", ".f16\t$Sn, $Rt",
  1161. []>,
  1162. Requires<[HasFPRegs16]>,
  1163. Sched<[WriteFPMOV]> {
  1164. // Instruction operands.
  1165. bits<5> Sn;
  1166. bits<4> Rt;
  1167. // Encode instruction operands.
  1168. let Inst{19-16} = Sn{4-1};
  1169. let Inst{7} = Sn{0};
  1170. let Inst{15-12} = Rt;
  1171. let Inst{6-5} = 0b00;
  1172. let Inst{3-0} = 0b0000;
  1173. let isUnpredicable = 1;
  1174. }
  1175. def : FPRegs16Pat<(arm_vmovrh (f16 HPR:$Sn)), (VMOVRH (f16 HPR:$Sn))>;
  1176. def : FPRegs16Pat<(arm_vmovrh (bf16 HPR:$Sn)), (VMOVRH (bf16 HPR:$Sn))>;
  1177. def : FPRegs16Pat<(f16 (arm_vmovhr rGPR:$Rt)), (VMOVHR rGPR:$Rt)>;
  1178. def : FPRegs16Pat<(bf16 (arm_vmovhr rGPR:$Rt)), (VMOVHR rGPR:$Rt)>;
  1179. // FMRDH: SPR -> GPR
  1180. // FMRDL: SPR -> GPR
  1181. // FMRRS: SPR -> GPR
  1182. // FMRX: SPR system reg -> GPR
  1183. // FMSRR: GPR -> SPR
  1184. // FMXR: GPR -> VFP system reg
  1185. // Int -> FP:
  1186. class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1187. bits<4> opcod4, dag oops, dag iops,
  1188. InstrItinClass itin, string opc, string asm,
  1189. list<dag> pattern>
  1190. : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1191. pattern> {
  1192. // Instruction operands.
  1193. bits<5> Dd;
  1194. bits<5> Sm;
  1195. // Encode instruction operands.
  1196. let Inst{3-0} = Sm{4-1};
  1197. let Inst{5} = Sm{0};
  1198. let Inst{15-12} = Dd{3-0};
  1199. let Inst{22} = Dd{4};
  1200. let Predicates = [HasVFP2, HasDPVFP];
  1201. let hasSideEffects = 0;
  1202. }
  1203. class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1204. bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
  1205. string opc, string asm, list<dag> pattern>
  1206. : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1207. pattern> {
  1208. // Instruction operands.
  1209. bits<5> Sd;
  1210. bits<5> Sm;
  1211. // Encode instruction operands.
  1212. let Inst{3-0} = Sm{4-1};
  1213. let Inst{5} = Sm{0};
  1214. let Inst{15-12} = Sd{4-1};
  1215. let Inst{22} = Sd{0};
  1216. let hasSideEffects = 0;
  1217. }
  1218. class AVConv1IHs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1219. bits<4> opcod4, dag oops, dag iops,
  1220. InstrItinClass itin, string opc, string asm,
  1221. list<dag> pattern>
  1222. : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1223. pattern> {
  1224. // Instruction operands.
  1225. bits<5> Sd;
  1226. bits<5> Sm;
  1227. // Encode instruction operands.
  1228. let Inst{3-0} = Sm{4-1};
  1229. let Inst{5} = Sm{0};
  1230. let Inst{15-12} = Sd{4-1};
  1231. let Inst{22} = Sd{0};
  1232. let Predicates = [HasFullFP16];
  1233. let hasSideEffects = 0;
  1234. }
  1235. def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
  1236. (outs DPR:$Dd), (ins SPR:$Sm),
  1237. IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
  1238. []>,
  1239. Sched<[WriteFPCVT]> {
  1240. let Inst{7} = 1; // s32
  1241. }
  1242. let Predicates=[HasVFP2, HasDPVFP] in {
  1243. def : VFPPat<(f64 (sint_to_fp GPR:$a)),
  1244. (VSITOD (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1245. def : VFPPat<(f64 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))),
  1246. (VSITOD (VLDRS addrmode5:$a))>;
  1247. }
  1248. def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
  1249. (outs SPR:$Sd),(ins SPR:$Sm),
  1250. IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
  1251. []>,
  1252. Sched<[WriteFPCVT]> {
  1253. let Inst{7} = 1; // s32
  1254. // Some single precision VFP instructions may be executed on both NEON and
  1255. // VFP pipelines on A8.
  1256. let D = VFPNeonA8Domain;
  1257. }
  1258. def : VFPNoNEONPat<(f32 (sint_to_fp GPR:$a)),
  1259. (VSITOS (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1260. def : VFPNoNEONPat<(f32 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))),
  1261. (VSITOS (VLDRS addrmode5:$a))>;
  1262. def VSITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001,
  1263. (outs HPR:$Sd), (ins SPR:$Sm),
  1264. IIC_fpCVTIH, "vcvt", ".f16.s32\t$Sd, $Sm",
  1265. []>,
  1266. Sched<[WriteFPCVT]> {
  1267. let Inst{7} = 1; // s32
  1268. let isUnpredicable = 1;
  1269. }
  1270. def : VFPNoNEONPat<(f16 (sint_to_fp GPR:$a)),
  1271. (VSITOH (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1272. def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
  1273. (outs DPR:$Dd), (ins SPR:$Sm),
  1274. IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
  1275. []>,
  1276. Sched<[WriteFPCVT]> {
  1277. let Inst{7} = 0; // u32
  1278. }
  1279. let Predicates=[HasVFP2, HasDPVFP] in {
  1280. def : VFPPat<(f64 (uint_to_fp GPR:$a)),
  1281. (VUITOD (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1282. def : VFPPat<(f64 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))),
  1283. (VUITOD (VLDRS addrmode5:$a))>;
  1284. }
  1285. def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
  1286. (outs SPR:$Sd), (ins SPR:$Sm),
  1287. IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
  1288. []>,
  1289. Sched<[WriteFPCVT]> {
  1290. let Inst{7} = 0; // u32
  1291. // Some single precision VFP instructions may be executed on both NEON and
  1292. // VFP pipelines on A8.
  1293. let D = VFPNeonA8Domain;
  1294. }
  1295. def : VFPNoNEONPat<(f32 (uint_to_fp GPR:$a)),
  1296. (VUITOS (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1297. def : VFPNoNEONPat<(f32 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))),
  1298. (VUITOS (VLDRS addrmode5:$a))>;
  1299. def VUITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001,
  1300. (outs HPR:$Sd), (ins SPR:$Sm),
  1301. IIC_fpCVTIH, "vcvt", ".f16.u32\t$Sd, $Sm",
  1302. []>,
  1303. Sched<[WriteFPCVT]> {
  1304. let Inst{7} = 0; // u32
  1305. let isUnpredicable = 1;
  1306. }
  1307. def : VFPNoNEONPat<(f16 (uint_to_fp GPR:$a)),
  1308. (VUITOH (COPY_TO_REGCLASS GPR:$a, SPR))>;
  1309. // FP -> Int:
  1310. class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1311. bits<4> opcod4, dag oops, dag iops,
  1312. InstrItinClass itin, string opc, string asm,
  1313. list<dag> pattern>
  1314. : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1315. pattern> {
  1316. // Instruction operands.
  1317. bits<5> Sd;
  1318. bits<5> Dm;
  1319. // Encode instruction operands.
  1320. let Inst{3-0} = Dm{3-0};
  1321. let Inst{5} = Dm{4};
  1322. let Inst{15-12} = Sd{4-1};
  1323. let Inst{22} = Sd{0};
  1324. let Predicates = [HasVFP2, HasDPVFP];
  1325. let hasSideEffects = 0;
  1326. }
  1327. class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1328. bits<4> opcod4, dag oops, dag iops,
  1329. InstrItinClass itin, string opc, string asm,
  1330. list<dag> pattern>
  1331. : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1332. pattern> {
  1333. // Instruction operands.
  1334. bits<5> Sd;
  1335. bits<5> Sm;
  1336. // Encode instruction operands.
  1337. let Inst{3-0} = Sm{4-1};
  1338. let Inst{5} = Sm{0};
  1339. let Inst{15-12} = Sd{4-1};
  1340. let Inst{22} = Sd{0};
  1341. let hasSideEffects = 0;
  1342. }
  1343. class AVConv1IsH_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
  1344. bits<4> opcod4, dag oops, dag iops,
  1345. InstrItinClass itin, string opc, string asm,
  1346. list<dag> pattern>
  1347. : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1348. pattern> {
  1349. // Instruction operands.
  1350. bits<5> Sd;
  1351. bits<5> Sm;
  1352. // Encode instruction operands.
  1353. let Inst{3-0} = Sm{4-1};
  1354. let Inst{5} = Sm{0};
  1355. let Inst{15-12} = Sd{4-1};
  1356. let Inst{22} = Sd{0};
  1357. let Predicates = [HasFullFP16];
  1358. let hasSideEffects = 0;
  1359. }
  1360. // Always set Z bit in the instruction, i.e. "round towards zero" variants.
  1361. def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
  1362. (outs SPR:$Sd), (ins DPR:$Dm),
  1363. IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
  1364. []>,
  1365. Sched<[WriteFPCVT]> {
  1366. let Inst{7} = 1; // Z bit
  1367. }
  1368. let Predicates=[HasVFP2, HasDPVFP] in {
  1369. def : VFPPat<(i32 (fp_to_sint (f64 DPR:$a))),
  1370. (COPY_TO_REGCLASS (VTOSIZD DPR:$a), GPR)>;
  1371. def : VFPPat<(i32 (fp_to_sint_sat (f64 DPR:$a), i32)),
  1372. (COPY_TO_REGCLASS (VTOSIZD DPR:$a), GPR)>;
  1373. def : VFPPat<(alignedstore32 (i32 (fp_to_sint (f64 DPR:$a))), addrmode5:$ptr),
  1374. (VSTRS (VTOSIZD DPR:$a), addrmode5:$ptr)>;
  1375. def : VFPPat<(alignedstore32 (i32 (fp_to_sint_sat (f64 DPR:$a), i32)), addrmode5:$ptr),
  1376. (VSTRS (VTOSIZD DPR:$a), addrmode5:$ptr)>;
  1377. }
  1378. def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
  1379. (outs SPR:$Sd), (ins SPR:$Sm),
  1380. IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
  1381. []>,
  1382. Sched<[WriteFPCVT]> {
  1383. let Inst{7} = 1; // Z bit
  1384. // Some single precision VFP instructions may be executed on both NEON and
  1385. // VFP pipelines on A8.
  1386. let D = VFPNeonA8Domain;
  1387. }
  1388. def : VFPNoNEONPat<(i32 (fp_to_sint SPR:$a)),
  1389. (COPY_TO_REGCLASS (VTOSIZS SPR:$a), GPR)>;
  1390. def : VFPPat<(i32 (fp_to_sint_sat SPR:$a, i32)),
  1391. (COPY_TO_REGCLASS (VTOSIZS SPR:$a), GPR)>;
  1392. def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_sint (f32 SPR:$a))),
  1393. addrmode5:$ptr),
  1394. (VSTRS (VTOSIZS SPR:$a), addrmode5:$ptr)>;
  1395. def : VFPPat<(alignedstore32 (i32 (fp_to_sint_sat (f32 SPR:$a), i32)),
  1396. addrmode5:$ptr),
  1397. (VSTRS (VTOSIZS SPR:$a), addrmode5:$ptr)>;
  1398. def VTOSIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001,
  1399. (outs SPR:$Sd), (ins HPR:$Sm),
  1400. IIC_fpCVTHI, "vcvt", ".s32.f16\t$Sd, $Sm",
  1401. []>,
  1402. Sched<[WriteFPCVT]> {
  1403. let Inst{7} = 1; // Z bit
  1404. let isUnpredicable = 1;
  1405. }
  1406. def : VFPNoNEONPat<(i32 (fp_to_sint (f16 HPR:$a))),
  1407. (COPY_TO_REGCLASS (VTOSIZH (f16 HPR:$a)), GPR)>;
  1408. def : VFPPat<(i32 (fp_to_sint_sat (f16 HPR:$a), i32)),
  1409. (COPY_TO_REGCLASS (VTOSIZH (f16 HPR:$a)), GPR)>;
  1410. def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
  1411. (outs SPR:$Sd), (ins DPR:$Dm),
  1412. IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
  1413. []>,
  1414. Sched<[WriteFPCVT]> {
  1415. let Inst{7} = 1; // Z bit
  1416. }
  1417. let Predicates=[HasVFP2, HasDPVFP] in {
  1418. def : VFPPat<(i32 (fp_to_uint (f64 DPR:$a))),
  1419. (COPY_TO_REGCLASS (VTOUIZD DPR:$a), GPR)>;
  1420. def : VFPPat<(i32 (fp_to_uint_sat (f64 DPR:$a), i32)),
  1421. (COPY_TO_REGCLASS (VTOUIZD DPR:$a), GPR)>;
  1422. def : VFPPat<(alignedstore32 (i32 (fp_to_uint (f64 DPR:$a))), addrmode5:$ptr),
  1423. (VSTRS (VTOUIZD DPR:$a), addrmode5:$ptr)>;
  1424. def : VFPPat<(alignedstore32 (i32 (fp_to_uint_sat (f64 DPR:$a), i32)), addrmode5:$ptr),
  1425. (VSTRS (VTOUIZD DPR:$a), addrmode5:$ptr)>;
  1426. }
  1427. def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
  1428. (outs SPR:$Sd), (ins SPR:$Sm),
  1429. IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
  1430. []>,
  1431. Sched<[WriteFPCVT]> {
  1432. let Inst{7} = 1; // Z bit
  1433. // Some single precision VFP instructions may be executed on both NEON and
  1434. // VFP pipelines on A8.
  1435. let D = VFPNeonA8Domain;
  1436. }
  1437. def : VFPNoNEONPat<(i32 (fp_to_uint SPR:$a)),
  1438. (COPY_TO_REGCLASS (VTOUIZS SPR:$a), GPR)>;
  1439. def : VFPPat<(i32 (fp_to_uint_sat SPR:$a, i32)),
  1440. (COPY_TO_REGCLASS (VTOUIZS SPR:$a), GPR)>;
  1441. def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_uint (f32 SPR:$a))),
  1442. addrmode5:$ptr),
  1443. (VSTRS (VTOUIZS SPR:$a), addrmode5:$ptr)>;
  1444. def : VFPPat<(alignedstore32 (i32 (fp_to_uint_sat (f32 SPR:$a), i32)),
  1445. addrmode5:$ptr),
  1446. (VSTRS (VTOUIZS SPR:$a), addrmode5:$ptr)>;
  1447. def VTOUIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001,
  1448. (outs SPR:$Sd), (ins HPR:$Sm),
  1449. IIC_fpCVTHI, "vcvt", ".u32.f16\t$Sd, $Sm",
  1450. []>,
  1451. Sched<[WriteFPCVT]> {
  1452. let Inst{7} = 1; // Z bit
  1453. let isUnpredicable = 1;
  1454. }
  1455. def : VFPNoNEONPat<(i32 (fp_to_uint (f16 HPR:$a))),
  1456. (COPY_TO_REGCLASS (VTOUIZH (f16 HPR:$a)), GPR)>;
  1457. def : VFPPat<(i32 (fp_to_uint_sat (f16 HPR:$a), i32)),
  1458. (COPY_TO_REGCLASS (VTOUIZH (f16 HPR:$a)), GPR)>;
  1459. // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
  1460. let Uses = [FPSCR] in {
  1461. def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
  1462. (outs SPR:$Sd), (ins DPR:$Dm),
  1463. IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
  1464. [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>,
  1465. Sched<[WriteFPCVT]> {
  1466. let Inst{7} = 0; // Z bit
  1467. }
  1468. def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
  1469. (outs SPR:$Sd), (ins SPR:$Sm),
  1470. IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
  1471. [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]>,
  1472. Sched<[WriteFPCVT]> {
  1473. let Inst{7} = 0; // Z bit
  1474. }
  1475. def VTOSIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001,
  1476. (outs SPR:$Sd), (ins SPR:$Sm),
  1477. IIC_fpCVTHI, "vcvtr", ".s32.f16\t$Sd, $Sm",
  1478. []>,
  1479. Sched<[WriteFPCVT]> {
  1480. let Inst{7} = 0; // Z bit
  1481. let isUnpredicable = 1;
  1482. }
  1483. def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
  1484. (outs SPR:$Sd), (ins DPR:$Dm),
  1485. IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
  1486. [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>,
  1487. Sched<[WriteFPCVT]> {
  1488. let Inst{7} = 0; // Z bit
  1489. }
  1490. def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
  1491. (outs SPR:$Sd), (ins SPR:$Sm),
  1492. IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
  1493. [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]>,
  1494. Sched<[WriteFPCVT]> {
  1495. let Inst{7} = 0; // Z bit
  1496. }
  1497. def VTOUIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001,
  1498. (outs SPR:$Sd), (ins SPR:$Sm),
  1499. IIC_fpCVTHI, "vcvtr", ".u32.f16\t$Sd, $Sm",
  1500. []>,
  1501. Sched<[WriteFPCVT]> {
  1502. let Inst{7} = 0; // Z bit
  1503. let isUnpredicable = 1;
  1504. }
  1505. }
  1506. // v8.3-a Javascript Convert to Signed fixed-point
  1507. def VJCVT : AVConv1IsD_Encode<0b11101, 0b11, 0b1001, 0b1011,
  1508. (outs SPR:$Sd), (ins DPR:$Dm),
  1509. IIC_fpCVTDI, "vjcvt", ".s32.f64\t$Sd, $Dm",
  1510. []>,
  1511. Requires<[HasFPARMv8, HasV8_3a]> {
  1512. let Inst{7} = 1; // Z bit
  1513. }
  1514. // Convert between floating-point and fixed-point
  1515. // Data type for fixed-point naming convention:
  1516. // S16 (U=0, sx=0) -> SH
  1517. // U16 (U=1, sx=0) -> UH
  1518. // S32 (U=0, sx=1) -> SL
  1519. // U32 (U=1, sx=1) -> UL
  1520. let Constraints = "$a = $dst" in {
  1521. // FP to Fixed-Point:
  1522. // Single Precision register
  1523. class AVConv1XInsS_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4,
  1524. bit op5, dag oops, dag iops, InstrItinClass itin,
  1525. string opc, string asm, list<dag> pattern>
  1526. : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
  1527. bits<5> dst;
  1528. // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
  1529. let Inst{22} = dst{0};
  1530. let Inst{15-12} = dst{4-1};
  1531. let hasSideEffects = 0;
  1532. }
  1533. // Double Precision register
  1534. class AVConv1XInsD_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4,
  1535. bit op5, dag oops, dag iops, InstrItinClass itin,
  1536. string opc, string asm, list<dag> pattern>
  1537. : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
  1538. bits<5> dst;
  1539. // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
  1540. let Inst{22} = dst{4};
  1541. let Inst{15-12} = dst{3-0};
  1542. let hasSideEffects = 0;
  1543. let Predicates = [HasVFP2, HasDPVFP];
  1544. }
  1545. let isUnpredicable = 1 in {
  1546. def VTOSHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 0,
  1547. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1548. IIC_fpCVTHI, "vcvt", ".s16.f16\t$dst, $a, $fbits", []>,
  1549. Requires<[HasFullFP16]>,
  1550. Sched<[WriteFPCVT]>;
  1551. def VTOUHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 0,
  1552. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1553. IIC_fpCVTHI, "vcvt", ".u16.f16\t$dst, $a, $fbits", []>,
  1554. Requires<[HasFullFP16]>,
  1555. Sched<[WriteFPCVT]>;
  1556. def VTOSLH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 1,
  1557. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1558. IIC_fpCVTHI, "vcvt", ".s32.f16\t$dst, $a, $fbits", []>,
  1559. Requires<[HasFullFP16]>,
  1560. Sched<[WriteFPCVT]>;
  1561. def VTOULH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 1,
  1562. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1563. IIC_fpCVTHI, "vcvt", ".u32.f16\t$dst, $a, $fbits", []>,
  1564. Requires<[HasFullFP16]>,
  1565. Sched<[WriteFPCVT]>;
  1566. } // End of 'let isUnpredicable = 1 in'
  1567. def VTOSHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 0,
  1568. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1569. IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []>,
  1570. Sched<[WriteFPCVT]> {
  1571. // Some single precision VFP instructions may be executed on both NEON and
  1572. // VFP pipelines on A8.
  1573. let D = VFPNeonA8Domain;
  1574. }
  1575. def VTOUHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 0,
  1576. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1577. IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []>,
  1578. Sched<[WriteFPCVT]> {
  1579. // Some single precision VFP instructions may be executed on both NEON and
  1580. // VFP pipelines on A8.
  1581. let D = VFPNeonA8Domain;
  1582. }
  1583. def VTOSLS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 1,
  1584. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1585. IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []>,
  1586. Sched<[WriteFPCVT]> {
  1587. // Some single precision VFP instructions may be executed on both NEON and
  1588. // VFP pipelines on A8.
  1589. let D = VFPNeonA8Domain;
  1590. }
  1591. def VTOULS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 1,
  1592. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1593. IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []>,
  1594. Sched<[WriteFPCVT]> {
  1595. // Some single precision VFP instructions may be executed on both NEON and
  1596. // VFP pipelines on A8.
  1597. let D = VFPNeonA8Domain;
  1598. }
  1599. def VTOSHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 0,
  1600. (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
  1601. IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>,
  1602. Sched<[WriteFPCVT]>;
  1603. def VTOUHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 0,
  1604. (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
  1605. IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>,
  1606. Sched<[WriteFPCVT]>;
  1607. def VTOSLD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 1,
  1608. (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
  1609. IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>,
  1610. Sched<[WriteFPCVT]>;
  1611. def VTOULD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 1,
  1612. (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
  1613. IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>,
  1614. Sched<[WriteFPCVT]>;
  1615. // Fixed-Point to FP:
  1616. let isUnpredicable = 1 in {
  1617. def VSHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 0,
  1618. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1619. IIC_fpCVTIH, "vcvt", ".f16.s16\t$dst, $a, $fbits", []>,
  1620. Requires<[HasFullFP16]>,
  1621. Sched<[WriteFPCVT]>;
  1622. def VUHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 0,
  1623. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1624. IIC_fpCVTIH, "vcvt", ".f16.u16\t$dst, $a, $fbits", []>,
  1625. Requires<[HasFullFP16]>,
  1626. Sched<[WriteFPCVT]>;
  1627. def VSLTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 1,
  1628. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1629. IIC_fpCVTIH, "vcvt", ".f16.s32\t$dst, $a, $fbits", []>,
  1630. Requires<[HasFullFP16]>,
  1631. Sched<[WriteFPCVT]>;
  1632. def VULTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 1,
  1633. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1634. IIC_fpCVTIH, "vcvt", ".f16.u32\t$dst, $a, $fbits", []>,
  1635. Requires<[HasFullFP16]>,
  1636. Sched<[WriteFPCVT]>;
  1637. } // End of 'let isUnpredicable = 1 in'
  1638. def VSHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 0,
  1639. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1640. IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []>,
  1641. Sched<[WriteFPCVT]> {
  1642. // Some single precision VFP instructions may be executed on both NEON and
  1643. // VFP pipelines on A8.
  1644. let D = VFPNeonA8Domain;
  1645. }
  1646. def VUHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 0,
  1647. (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
  1648. IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []>,
  1649. Sched<[WriteFPCVT]> {
  1650. // Some single precision VFP instructions may be executed on both NEON and
  1651. // VFP pipelines on A8.
  1652. let D = VFPNeonA8Domain;
  1653. }
  1654. def VSLTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 1,
  1655. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1656. IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []>,
  1657. Sched<[WriteFPCVT]> {
  1658. // Some single precision VFP instructions may be executed on both NEON and
  1659. // VFP pipelines on A8.
  1660. let D = VFPNeonA8Domain;
  1661. }
  1662. def VULTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 1,
  1663. (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
  1664. IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []>,
  1665. Sched<[WriteFPCVT]> {
  1666. // Some single precision VFP instructions may be executed on both NEON and
  1667. // VFP pipelines on A8.
  1668. let D = VFPNeonA8Domain;
  1669. }
  1670. def VSHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 0,
  1671. (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
  1672. IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>,
  1673. Sched<[WriteFPCVT]>;
  1674. def VUHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 0,
  1675. (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
  1676. IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>,
  1677. Sched<[WriteFPCVT]>;
  1678. def VSLTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 1,
  1679. (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
  1680. IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>,
  1681. Sched<[WriteFPCVT]>;
  1682. def VULTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 1,
  1683. (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
  1684. IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>,
  1685. Sched<[WriteFPCVT]>;
  1686. } // End of 'let Constraints = "$a = $dst" in'
  1687. // BFloat16 - Single precision, unary, predicated
  1688. class BF16_VCVT<string opc, bits<2> op7_6>
  1689. : VFPAI<(outs SPR:$Sd), (ins SPR:$dst, SPR:$Sm),
  1690. VFPUnaryFrm, NoItinerary,
  1691. opc, ".bf16.f32\t$Sd, $Sm", []>,
  1692. RegConstraint<"$dst = $Sd">,
  1693. Requires<[HasBF16]>,
  1694. Sched<[]> {
  1695. bits<5> Sd;
  1696. bits<5> Sm;
  1697. // Encode instruction operands.
  1698. let Inst{3-0} = Sm{4-1};
  1699. let Inst{5} = Sm{0};
  1700. let Inst{15-12} = Sd{4-1};
  1701. let Inst{22} = Sd{0};
  1702. let Inst{27-23} = 0b11101; // opcode1
  1703. let Inst{21-20} = 0b11; // opcode2
  1704. let Inst{19-16} = 0b0011; // opcode3
  1705. let Inst{11-8} = 0b1001;
  1706. let Inst{7-6} = op7_6;
  1707. let Inst{4} = 0;
  1708. let DecoderNamespace = "VFPV8";
  1709. let hasSideEffects = 0;
  1710. }
  1711. def BF16_VCVTB : BF16_VCVT<"vcvtb", 0b01>;
  1712. def BF16_VCVTT : BF16_VCVT<"vcvtt", 0b11>;
  1713. //===----------------------------------------------------------------------===//
  1714. // FP Multiply-Accumulate Operations.
  1715. //
  1716. def VMLAD : ADbI<0b11100, 0b00, 0, 0,
  1717. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1718. IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
  1719. [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
  1720. (f64 DPR:$Ddin)))]>,
  1721. RegConstraint<"$Ddin = $Dd">,
  1722. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
  1723. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1724. def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
  1725. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1726. IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
  1727. [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
  1728. SPR:$Sdin))]>,
  1729. RegConstraint<"$Sdin = $Sd">,
  1730. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
  1731. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1732. // Some single precision VFP instructions may be executed on both NEON and
  1733. // VFP pipelines on A8.
  1734. let D = VFPNeonA8Domain;
  1735. }
  1736. def VMLAH : AHbI<0b11100, 0b00, 0, 0,
  1737. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1738. IIC_fpMAC16, "vmla", ".f16\t$Sd, $Sn, $Sm",
  1739. [(set (f16 HPR:$Sd), (fadd_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)),
  1740. (f16 HPR:$Sdin)))]>,
  1741. RegConstraint<"$Sdin = $Sd">,
  1742. Requires<[HasFullFP16,UseFPVMLx]>;
  1743. def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
  1744. (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
  1745. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
  1746. def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
  1747. (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
  1748. Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx]>;
  1749. def : Pat<(fadd_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)),
  1750. (VMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1751. Requires<[HasFullFP16,DontUseNEONForFP, UseFPVMLx]>;
  1752. def VMLSD : ADbI<0b11100, 0b00, 1, 0,
  1753. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1754. IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
  1755. [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
  1756. (f64 DPR:$Ddin)))]>,
  1757. RegConstraint<"$Ddin = $Dd">,
  1758. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
  1759. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1760. def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
  1761. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1762. IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
  1763. [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
  1764. SPR:$Sdin))]>,
  1765. RegConstraint<"$Sdin = $Sd">,
  1766. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
  1767. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1768. // Some single precision VFP instructions may be executed on both NEON and
  1769. // VFP pipelines on A8.
  1770. let D = VFPNeonA8Domain;
  1771. }
  1772. def VMLSH : AHbI<0b11100, 0b00, 1, 0,
  1773. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1774. IIC_fpMAC16, "vmls", ".f16\t$Sd, $Sn, $Sm",
  1775. [(set (f16 HPR:$Sd), (fadd_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))),
  1776. (f16 HPR:$Sdin)))]>,
  1777. RegConstraint<"$Sdin = $Sd">,
  1778. Requires<[HasFullFP16,UseFPVMLx]>;
  1779. def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
  1780. (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
  1781. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
  1782. def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
  1783. (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
  1784. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
  1785. def : Pat<(fsub_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)),
  1786. (VMLSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1787. Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
  1788. def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
  1789. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1790. IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
  1791. [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
  1792. (f64 DPR:$Ddin)))]>,
  1793. RegConstraint<"$Ddin = $Dd">,
  1794. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
  1795. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1796. def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
  1797. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1798. IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
  1799. [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
  1800. SPR:$Sdin))]>,
  1801. RegConstraint<"$Sdin = $Sd">,
  1802. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
  1803. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1804. // Some single precision VFP instructions may be executed on both NEON and
  1805. // VFP pipelines on A8.
  1806. let D = VFPNeonA8Domain;
  1807. }
  1808. def VNMLAH : AHbI<0b11100, 0b01, 1, 0,
  1809. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1810. IIC_fpMAC16, "vnmla", ".f16\t$Sd, $Sn, $Sm",
  1811. [(set (f16 HPR:$Sd), (fsub_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))),
  1812. (f16 HPR:$Sdin)))]>,
  1813. RegConstraint<"$Sdin = $Sd">,
  1814. Requires<[HasFullFP16,UseFPVMLx]>;
  1815. // (-(a * b) - dst) -> -(dst + (a * b))
  1816. def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
  1817. (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
  1818. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
  1819. def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
  1820. (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
  1821. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
  1822. def : Pat<(fsub_mlx (fneg (fmul_su (f16 HPR:$a), HPR:$b)), HPR:$dstin),
  1823. (VNMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1824. Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
  1825. // (-dst - (a * b)) -> -(dst + (a * b))
  1826. def : Pat<(fsub_mlx (fneg DPR:$dstin), (fmul_su DPR:$a, (f64 DPR:$b))),
  1827. (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
  1828. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
  1829. def : Pat<(fsub_mlx (fneg SPR:$dstin), (fmul_su SPR:$a, SPR:$b)),
  1830. (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
  1831. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
  1832. def : Pat<(fsub_mlx (fneg HPR:$dstin), (fmul_su (f16 HPR:$a), HPR:$b)),
  1833. (VNMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1834. Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
  1835. def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
  1836. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1837. IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
  1838. [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
  1839. (f64 DPR:$Ddin)))]>,
  1840. RegConstraint<"$Ddin = $Dd">,
  1841. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
  1842. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1843. def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
  1844. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1845. IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
  1846. [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
  1847. RegConstraint<"$Sdin = $Sd">,
  1848. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
  1849. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1850. // Some single precision VFP instructions may be executed on both NEON and
  1851. // VFP pipelines on A8.
  1852. let D = VFPNeonA8Domain;
  1853. }
  1854. def VNMLSH : AHbI<0b11100, 0b01, 0, 0,
  1855. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1856. IIC_fpMAC16, "vnmls", ".f16\t$Sd, $Sn, $Sm",
  1857. [(set (f16 HPR:$Sd), (fsub_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), (f16 HPR:$Sdin)))]>,
  1858. RegConstraint<"$Sdin = $Sd">,
  1859. Requires<[HasFullFP16,UseFPVMLx]>;
  1860. def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
  1861. (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
  1862. Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
  1863. def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
  1864. (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
  1865. Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
  1866. def : Pat<(fsub_mlx (fmul_su (f16 HPR:$a), HPR:$b), HPR:$dstin),
  1867. (VNMLSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1868. Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
  1869. //===----------------------------------------------------------------------===//
  1870. // Fused FP Multiply-Accumulate Operations.
  1871. //
  1872. def VFMAD : ADbI<0b11101, 0b10, 0, 0,
  1873. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1874. IIC_fpFMAC64, "vfma", ".f64\t$Dd, $Dn, $Dm",
  1875. [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
  1876. (f64 DPR:$Ddin)))]>,
  1877. RegConstraint<"$Ddin = $Dd">,
  1878. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
  1879. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1880. def VFMAS : ASbIn<0b11101, 0b10, 0, 0,
  1881. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1882. IIC_fpFMAC32, "vfma", ".f32\t$Sd, $Sn, $Sm",
  1883. [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
  1884. SPR:$Sdin))]>,
  1885. RegConstraint<"$Sdin = $Sd">,
  1886. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
  1887. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1888. // Some single precision VFP instructions may be executed on both NEON and
  1889. // VFP pipelines.
  1890. }
  1891. def VFMAH : AHbI<0b11101, 0b10, 0, 0,
  1892. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1893. IIC_fpFMAC16, "vfma", ".f16\t$Sd, $Sn, $Sm",
  1894. [(set (f16 HPR:$Sd), (fadd_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)),
  1895. (f16 HPR:$Sdin)))]>,
  1896. RegConstraint<"$Sdin = $Sd">,
  1897. Requires<[HasFullFP16,UseFusedMAC]>,
  1898. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1899. def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
  1900. (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>,
  1901. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
  1902. def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
  1903. (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>,
  1904. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
  1905. def : Pat<(fadd_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)),
  1906. (VFMAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1907. Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>;
  1908. // Match @llvm.fma.* intrinsics
  1909. // (fma x, y, z) -> (vfms z, x, y)
  1910. def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, DPR:$Ddin)),
  1911. (VFMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  1912. Requires<[HasVFP4,HasDPVFP]>;
  1913. def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, SPR:$Sdin)),
  1914. (VFMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  1915. Requires<[HasVFP4]>;
  1916. def : Pat<(f16 (fma HPR:$Sn, HPR:$Sm, (f16 HPR:$Sdin))),
  1917. (VFMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  1918. Requires<[HasFullFP16]>;
  1919. def VFMSD : ADbI<0b11101, 0b10, 1, 0,
  1920. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1921. IIC_fpFMAC64, "vfms", ".f64\t$Dd, $Dn, $Dm",
  1922. [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
  1923. (f64 DPR:$Ddin)))]>,
  1924. RegConstraint<"$Ddin = $Dd">,
  1925. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
  1926. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1927. def VFMSS : ASbIn<0b11101, 0b10, 1, 0,
  1928. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1929. IIC_fpFMAC32, "vfms", ".f32\t$Sd, $Sn, $Sm",
  1930. [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
  1931. SPR:$Sdin))]>,
  1932. RegConstraint<"$Sdin = $Sd">,
  1933. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
  1934. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1935. // Some single precision VFP instructions may be executed on both NEON and
  1936. // VFP pipelines.
  1937. }
  1938. def VFMSH : AHbI<0b11101, 0b10, 1, 0,
  1939. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1940. IIC_fpFMAC16, "vfms", ".f16\t$Sd, $Sn, $Sm",
  1941. [(set (f16 HPR:$Sd), (fadd_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))),
  1942. (f16 HPR:$Sdin)))]>,
  1943. RegConstraint<"$Sdin = $Sd">,
  1944. Requires<[HasFullFP16,UseFusedMAC]>,
  1945. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1946. def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
  1947. (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>,
  1948. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
  1949. def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
  1950. (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>,
  1951. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
  1952. def : Pat<(fsub_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)),
  1953. (VFMSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>,
  1954. Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>;
  1955. // Match @llvm.fma.* intrinsics
  1956. // (fma (fneg x), y, z) -> (vfms z, x, y)
  1957. def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin)),
  1958. (VFMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  1959. Requires<[HasVFP4,HasDPVFP]>;
  1960. def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin)),
  1961. (VFMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  1962. Requires<[HasVFP4]>;
  1963. def : Pat<(f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (f16 HPR:$Sdin))),
  1964. (VFMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  1965. Requires<[HasFullFP16]>;
  1966. def VFNMAD : ADbI<0b11101, 0b01, 1, 0,
  1967. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  1968. IIC_fpFMAC64, "vfnma", ".f64\t$Dd, $Dn, $Dm",
  1969. [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
  1970. (f64 DPR:$Ddin)))]>,
  1971. RegConstraint<"$Ddin = $Dd">,
  1972. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
  1973. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1974. def VFNMAS : ASbI<0b11101, 0b01, 1, 0,
  1975. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  1976. IIC_fpFMAC32, "vfnma", ".f32\t$Sd, $Sn, $Sm",
  1977. [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
  1978. SPR:$Sdin))]>,
  1979. RegConstraint<"$Sdin = $Sd">,
  1980. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
  1981. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  1982. // Some single precision VFP instructions may be executed on both NEON and
  1983. // VFP pipelines.
  1984. }
  1985. def VFNMAH : AHbI<0b11101, 0b01, 1, 0,
  1986. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  1987. IIC_fpFMAC16, "vfnma", ".f16\t$Sd, $Sn, $Sm",
  1988. [(set (f16 HPR:$Sd), (fsub_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))),
  1989. (f16 HPR:$Sdin)))]>,
  1990. RegConstraint<"$Sdin = $Sd">,
  1991. Requires<[HasFullFP16,UseFusedMAC]>,
  1992. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  1993. def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
  1994. (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>,
  1995. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
  1996. def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
  1997. (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
  1998. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
  1999. // Match @llvm.fma.* intrinsics
  2000. // (fneg (fma x, y, z)) -> (vfnma z, x, y)
  2001. def : Pat<(fneg (fma (f64 DPR:$Dn), (f64 DPR:$Dm), (f64 DPR:$Ddin))),
  2002. (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  2003. Requires<[HasVFP4,HasDPVFP]>;
  2004. def : Pat<(fneg (fma (f32 SPR:$Sn), (f32 SPR:$Sm), (f32 SPR:$Sdin))),
  2005. (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  2006. Requires<[HasVFP4]>;
  2007. def : Pat<(fneg (fma (f16 HPR:$Sn), (f16 HPR:$Sm), (f16 (f16 HPR:$Sdin)))),
  2008. (VFNMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  2009. Requires<[HasFullFP16]>;
  2010. // (fma (fneg x), y, (fneg z)) -> (vfnma z, x, y)
  2011. def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, (fneg DPR:$Ddin))),
  2012. (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  2013. Requires<[HasVFP4,HasDPVFP]>;
  2014. def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, (fneg SPR:$Sdin))),
  2015. (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  2016. Requires<[HasVFP4]>;
  2017. def : Pat<(f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (fneg (f16 HPR:$Sdin)))),
  2018. (VFNMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  2019. Requires<[HasFullFP16]>;
  2020. def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
  2021. (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
  2022. IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm",
  2023. [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
  2024. (f64 DPR:$Ddin)))]>,
  2025. RegConstraint<"$Ddin = $Dd">,
  2026. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
  2027. Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  2028. def VFNMSS : ASbI<0b11101, 0b01, 0, 0,
  2029. (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
  2030. IIC_fpFMAC32, "vfnms", ".f32\t$Sd, $Sn, $Sm",
  2031. [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
  2032. RegConstraint<"$Sdin = $Sd">,
  2033. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
  2034. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
  2035. // Some single precision VFP instructions may be executed on both NEON and
  2036. // VFP pipelines.
  2037. }
  2038. def VFNMSH : AHbI<0b11101, 0b01, 0, 0,
  2039. (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
  2040. IIC_fpFMAC16, "vfnms", ".f16\t$Sd, $Sn, $Sm",
  2041. [(set (f16 HPR:$Sd), (fsub_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), (f16 HPR:$Sdin)))]>,
  2042. RegConstraint<"$Sdin = $Sd">,
  2043. Requires<[HasFullFP16,UseFusedMAC]>,
  2044. Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
  2045. def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
  2046. (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>,
  2047. Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
  2048. def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
  2049. (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>,
  2050. Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
  2051. // Match @llvm.fma.* intrinsics
  2052. // (fma x, y, (fneg z)) -> (vfnms z, x, y))
  2053. def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, (fneg DPR:$Ddin))),
  2054. (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  2055. Requires<[HasVFP4,HasDPVFP]>;
  2056. def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, (fneg SPR:$Sdin))),
  2057. (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  2058. Requires<[HasVFP4]>;
  2059. def : Pat<(f16 (fma (f16 HPR:$Sn), (f16 HPR:$Sm), (fneg (f16 HPR:$Sdin)))),
  2060. (VFNMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  2061. Requires<[HasFullFP16]>;
  2062. // (fneg (fma (fneg x), y, z)) -> (vfnms z, x, y)
  2063. def : Pat<(fneg (f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin))),
  2064. (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
  2065. Requires<[HasVFP4,HasDPVFP]>;
  2066. def : Pat<(fneg (f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin))),
  2067. (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
  2068. Requires<[HasVFP4]>;
  2069. def : Pat<(fneg (f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (f16 HPR:$Sdin)))),
  2070. (VFNMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>,
  2071. Requires<[HasFullFP16]>;
  2072. //===----------------------------------------------------------------------===//
  2073. // FP Conditional moves.
  2074. //
  2075. let hasSideEffects = 0 in {
  2076. def VMOVDcc : PseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, cmovpred:$p),
  2077. IIC_fpUNA64,
  2078. [(set (f64 DPR:$Dd),
  2079. (ARMcmov DPR:$Dn, DPR:$Dm, cmovpred:$p))]>,
  2080. RegConstraint<"$Dn = $Dd">, Requires<[HasFPRegs64]>;
  2081. def VMOVScc : PseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, cmovpred:$p),
  2082. IIC_fpUNA32,
  2083. [(set (f32 SPR:$Sd),
  2084. (ARMcmov SPR:$Sn, SPR:$Sm, cmovpred:$p))]>,
  2085. RegConstraint<"$Sn = $Sd">, Requires<[HasFPRegs]>;
  2086. def VMOVHcc : PseudoInst<(outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm, cmovpred:$p),
  2087. IIC_fpUNA16,
  2088. [(set (f16 HPR:$Sd),
  2089. (ARMcmov (f16 HPR:$Sn), (f16 HPR:$Sm), cmovpred:$p))]>,
  2090. RegConstraint<"$Sd = $Sn">, Requires<[HasFPRegs]>;
  2091. } // hasSideEffects
  2092. //===----------------------------------------------------------------------===//
  2093. // Move from VFP System Register to ARM core register.
  2094. //
  2095. class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
  2096. list<dag> pattern>:
  2097. VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
  2098. // Instruction operand.
  2099. bits<4> Rt;
  2100. let Inst{27-20} = 0b11101111;
  2101. let Inst{19-16} = opc19_16;
  2102. let Inst{15-12} = Rt;
  2103. let Inst{11-8} = 0b1010;
  2104. let Inst{7} = 0;
  2105. let Inst{6-5} = 0b00;
  2106. let Inst{4} = 1;
  2107. let Inst{3-0} = 0b0000;
  2108. let Unpredictable{7-5} = 0b111;
  2109. let Unpredictable{3-0} = 0b1111;
  2110. }
  2111. let DecoderMethod = "DecodeForVMRSandVMSR" in {
  2112. // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
  2113. // to APSR.
  2114. let Defs = [CPSR], Uses = [FPSCR_NZCV], Predicates = [HasFPRegs],
  2115. Rt = 0b1111 /* apsr_nzcv */ in
  2116. def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
  2117. "vmrs", "\tAPSR_nzcv, fpscr", [(arm_fmstat)]>;
  2118. // Application level FPSCR -> GPR
  2119. let hasSideEffects = 1, Uses = [FPSCR], Predicates = [HasFPRegs] in
  2120. def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPRnopc:$Rt), (ins),
  2121. "vmrs", "\t$Rt, fpscr",
  2122. [(set GPRnopc:$Rt, (int_arm_get_fpscr))]>;
  2123. // System level FPEXC, FPSID -> GPR
  2124. let Uses = [FPSCR] in {
  2125. def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPRnopc:$Rt), (ins),
  2126. "vmrs", "\t$Rt, fpexc", []>;
  2127. def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPRnopc:$Rt), (ins),
  2128. "vmrs", "\t$Rt, fpsid", []>;
  2129. def VMRS_MVFR0 : MovFromVFP<0b0111 /* mvfr0 */, (outs GPRnopc:$Rt), (ins),
  2130. "vmrs", "\t$Rt, mvfr0", []>;
  2131. def VMRS_MVFR1 : MovFromVFP<0b0110 /* mvfr1 */, (outs GPRnopc:$Rt), (ins),
  2132. "vmrs", "\t$Rt, mvfr1", []>;
  2133. let Predicates = [HasFPARMv8] in {
  2134. def VMRS_MVFR2 : MovFromVFP<0b0101 /* mvfr2 */, (outs GPRnopc:$Rt), (ins),
  2135. "vmrs", "\t$Rt, mvfr2", []>;
  2136. }
  2137. def VMRS_FPINST : MovFromVFP<0b1001 /* fpinst */, (outs GPRnopc:$Rt), (ins),
  2138. "vmrs", "\t$Rt, fpinst", []>;
  2139. def VMRS_FPINST2 : MovFromVFP<0b1010 /* fpinst2 */, (outs GPRnopc:$Rt),
  2140. (ins), "vmrs", "\t$Rt, fpinst2", []>;
  2141. let Predicates = [HasV8_1MMainline, HasFPRegs] in {
  2142. // System level FPSCR_NZCVQC -> GPR
  2143. def VMRS_FPSCR_NZCVQC
  2144. : MovFromVFP<0b0010 /* fpscr_nzcvqc */,
  2145. (outs GPR:$Rt), (ins cl_FPSCR_NZCV:$fpscr_in),
  2146. "vmrs", "\t$Rt, fpscr_nzcvqc", []>;
  2147. }
  2148. }
  2149. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2150. // System level FPSCR -> GPR, with context saving for security extensions
  2151. def VMRS_FPCXTNS : MovFromVFP<0b1110 /* fpcxtns */, (outs GPR:$Rt), (ins),
  2152. "vmrs", "\t$Rt, fpcxtns", []>;
  2153. }
  2154. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2155. // System level FPSCR -> GPR, with context saving for security extensions
  2156. def VMRS_FPCXTS : MovFromVFP<0b1111 /* fpcxts */, (outs GPR:$Rt), (ins),
  2157. "vmrs", "\t$Rt, fpcxts", []>;
  2158. }
  2159. let Predicates = [HasV8_1MMainline, HasMVEInt] in {
  2160. // System level VPR/P0 -> GPR
  2161. let Uses = [VPR] in
  2162. def VMRS_VPR : MovFromVFP<0b1100 /* vpr */, (outs GPR:$Rt), (ins),
  2163. "vmrs", "\t$Rt, vpr", []>;
  2164. def VMRS_P0 : MovFromVFP<0b1101 /* p0 */, (outs GPR:$Rt), (ins VCCR:$cond),
  2165. "vmrs", "\t$Rt, p0", []>;
  2166. }
  2167. }
  2168. //===----------------------------------------------------------------------===//
  2169. // Move from ARM core register to VFP System Register.
  2170. //
  2171. class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
  2172. list<dag> pattern>:
  2173. VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
  2174. // Instruction operand.
  2175. bits<4> Rt;
  2176. let Inst{27-20} = 0b11101110;
  2177. let Inst{19-16} = opc19_16;
  2178. let Inst{15-12} = Rt;
  2179. let Inst{11-8} = 0b1010;
  2180. let Inst{7} = 0;
  2181. let Inst{6-5} = 0b00;
  2182. let Inst{4} = 1;
  2183. let Inst{3-0} = 0b0000;
  2184. let Predicates = [HasVFP2];
  2185. let Unpredictable{7-5} = 0b111;
  2186. let Unpredictable{3-0} = 0b1111;
  2187. }
  2188. let DecoderMethod = "DecodeForVMRSandVMSR" in {
  2189. let Defs = [FPSCR] in {
  2190. let Predicates = [HasFPRegs] in
  2191. // Application level GPR -> FPSCR
  2192. def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPRnopc:$Rt),
  2193. "vmsr", "\tfpscr, $Rt",
  2194. [(int_arm_set_fpscr GPRnopc:$Rt)]>;
  2195. // System level GPR -> FPEXC
  2196. def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPRnopc:$Rt),
  2197. "vmsr", "\tfpexc, $Rt", []>;
  2198. // System level GPR -> FPSID
  2199. def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPRnopc:$Rt),
  2200. "vmsr", "\tfpsid, $Rt", []>;
  2201. def VMSR_FPINST : MovToVFP<0b1001 /* fpinst */, (outs), (ins GPRnopc:$Rt),
  2202. "vmsr", "\tfpinst, $Rt", []>;
  2203. def VMSR_FPINST2 : MovToVFP<0b1010 /* fpinst2 */, (outs), (ins GPRnopc:$Rt),
  2204. "vmsr", "\tfpinst2, $Rt", []>;
  2205. }
  2206. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2207. // System level GPR -> FPSCR with context saving for security extensions
  2208. def VMSR_FPCXTNS : MovToVFP<0b1110 /* fpcxtns */, (outs), (ins GPR:$Rt),
  2209. "vmsr", "\tfpcxtns, $Rt", []>;
  2210. }
  2211. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2212. // System level GPR -> FPSCR with context saving for security extensions
  2213. def VMSR_FPCXTS : MovToVFP<0b1111 /* fpcxts */, (outs), (ins GPR:$Rt),
  2214. "vmsr", "\tfpcxts, $Rt", []>;
  2215. }
  2216. let Predicates = [HasV8_1MMainline, HasFPRegs] in {
  2217. // System level GPR -> FPSCR_NZCVQC
  2218. def VMSR_FPSCR_NZCVQC
  2219. : MovToVFP<0b0010 /* fpscr_nzcvqc */,
  2220. (outs cl_FPSCR_NZCV:$fpscr_out), (ins GPR:$Rt),
  2221. "vmsr", "\tfpscr_nzcvqc, $Rt", []>;
  2222. }
  2223. let Predicates = [HasV8_1MMainline, HasMVEInt] in {
  2224. // System level GPR -> VPR/P0
  2225. let Defs = [VPR] in
  2226. def VMSR_VPR : MovToVFP<0b1100 /* vpr */, (outs), (ins GPR:$Rt),
  2227. "vmsr", "\tvpr, $Rt", []>;
  2228. def VMSR_P0 : MovToVFP<0b1101 /* p0 */, (outs VCCR:$cond), (ins GPR:$Rt),
  2229. "vmsr", "\tp0, $Rt", []>;
  2230. }
  2231. }
  2232. //===----------------------------------------------------------------------===//
  2233. // Misc.
  2234. //
  2235. // Materialize FP immediates. VFP3 only.
  2236. let isReMaterializable = 1 in {
  2237. def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
  2238. VFPMiscFrm, IIC_fpUNA64,
  2239. "vmov", ".f64\t$Dd, $imm",
  2240. [(set DPR:$Dd, vfp_f64imm:$imm)]>,
  2241. Requires<[HasVFP3,HasDPVFP]> {
  2242. bits<5> Dd;
  2243. bits<8> imm;
  2244. let Inst{27-23} = 0b11101;
  2245. let Inst{22} = Dd{4};
  2246. let Inst{21-20} = 0b11;
  2247. let Inst{19-16} = imm{7-4};
  2248. let Inst{15-12} = Dd{3-0};
  2249. let Inst{11-9} = 0b101;
  2250. let Inst{8} = 1; // Double precision.
  2251. let Inst{7-4} = 0b0000;
  2252. let Inst{3-0} = imm{3-0};
  2253. }
  2254. def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
  2255. VFPMiscFrm, IIC_fpUNA32,
  2256. "vmov", ".f32\t$Sd, $imm",
  2257. [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
  2258. bits<5> Sd;
  2259. bits<8> imm;
  2260. let Inst{27-23} = 0b11101;
  2261. let Inst{22} = Sd{0};
  2262. let Inst{21-20} = 0b11;
  2263. let Inst{19-16} = imm{7-4};
  2264. let Inst{15-12} = Sd{4-1};
  2265. let Inst{11-9} = 0b101;
  2266. let Inst{8} = 0; // Single precision.
  2267. let Inst{7-4} = 0b0000;
  2268. let Inst{3-0} = imm{3-0};
  2269. }
  2270. def FCONSTH : VFPAI<(outs HPR:$Sd), (ins vfp_f16imm:$imm),
  2271. VFPMiscFrm, IIC_fpUNA16,
  2272. "vmov", ".f16\t$Sd, $imm",
  2273. [(set (f16 HPR:$Sd), vfp_f16imm:$imm)]>,
  2274. Requires<[HasFullFP16]> {
  2275. bits<5> Sd;
  2276. bits<8> imm;
  2277. let Inst{27-23} = 0b11101;
  2278. let Inst{22} = Sd{0};
  2279. let Inst{21-20} = 0b11;
  2280. let Inst{19-16} = imm{7-4};
  2281. let Inst{15-12} = Sd{4-1};
  2282. let Inst{11-8} = 0b1001; // Half precision
  2283. let Inst{7-4} = 0b0000;
  2284. let Inst{3-0} = imm{3-0};
  2285. let isUnpredicable = 1;
  2286. }
  2287. }
  2288. def : Pat<(f32 (vfp_f32f16imm:$imm)),
  2289. (f32 (COPY_TO_REGCLASS (f16 (FCONSTH (vfp_f32f16imm_xform (f32 $imm)))), SPR))> {
  2290. let Predicates = [HasFullFP16];
  2291. }
  2292. //===----------------------------------------------------------------------===//
  2293. // Assembler aliases.
  2294. //
  2295. // A few mnemonic aliases for pre-unifixed syntax. We don't guarantee to
  2296. // support them all, but supporting at least some of the basics is
  2297. // good to be friendly.
  2298. def : VFP2MnemonicAlias<"flds", "vldr">;
  2299. def : VFP2MnemonicAlias<"fldd", "vldr">;
  2300. def : VFP2MnemonicAlias<"fmrs", "vmov">;
  2301. def : VFP2MnemonicAlias<"fmsr", "vmov">;
  2302. def : VFP2MnemonicAlias<"fsqrts", "vsqrt">;
  2303. def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">;
  2304. def : VFP2MnemonicAlias<"fadds", "vadd.f32">;
  2305. def : VFP2MnemonicAlias<"faddd", "vadd.f64">;
  2306. def : VFP2MnemonicAlias<"fmrdd", "vmov">;
  2307. def : VFP2MnemonicAlias<"fmrds", "vmov">;
  2308. def : VFP2MnemonicAlias<"fmrrd", "vmov">;
  2309. def : VFP2MnemonicAlias<"fmdrr", "vmov">;
  2310. def : VFP2MnemonicAlias<"fmuls", "vmul.f32">;
  2311. def : VFP2MnemonicAlias<"fmuld", "vmul.f64">;
  2312. def : VFP2MnemonicAlias<"fnegs", "vneg.f32">;
  2313. def : VFP2MnemonicAlias<"fnegd", "vneg.f64">;
  2314. def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">;
  2315. def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">;
  2316. def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">;
  2317. def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">;
  2318. def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">;
  2319. def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">;
  2320. def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">;
  2321. def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">;
  2322. def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">;
  2323. def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">;
  2324. def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">;
  2325. def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">;
  2326. def : VFP2MnemonicAlias<"fsts", "vstr">;
  2327. def : VFP2MnemonicAlias<"fstd", "vstr">;
  2328. def : VFP2MnemonicAlias<"fmacd", "vmla.f64">;
  2329. def : VFP2MnemonicAlias<"fmacs", "vmla.f32">;
  2330. def : VFP2MnemonicAlias<"fcpys", "vmov.f32">;
  2331. def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">;
  2332. def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">;
  2333. def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">;
  2334. def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">;
  2335. def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">;
  2336. def : VFP2MnemonicAlias<"fmrx", "vmrs">;
  2337. def : VFP2MnemonicAlias<"fmxr", "vmsr">;
  2338. // Be friendly and accept the old form of zero-compare
  2339. def : VFP2DPInstAlias<"fcmpzd${p} $val", (VCMPZD DPR:$val, pred:$p)>;
  2340. def : VFP2InstAlias<"fcmpzs${p} $val", (VCMPZS SPR:$val, pred:$p)>;
  2341. def : InstAlias<"fmstat${p}", (FMSTAT pred:$p), 0>, Requires<[HasFPRegs]>;
  2342. def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm",
  2343. (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
  2344. def : VFP2DPInstAlias<"faddd${p} $Dd, $Dn, $Dm",
  2345. (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
  2346. def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm",
  2347. (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
  2348. def : VFP2DPInstAlias<"fsubd${p} $Dd, $Dn, $Dm",
  2349. (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
  2350. // No need for the size suffix on VSQRT. It's implied by the register classes.
  2351. def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>;
  2352. def : VFP2DPInstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>;
  2353. // VLDR/VSTR accept an optional type suffix.
  2354. def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr",
  2355. (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
  2356. def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr",
  2357. (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
  2358. def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr",
  2359. (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
  2360. def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr",
  2361. (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
  2362. // VMOV can accept optional 32-bit or less data type suffix suffix.
  2363. def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn",
  2364. (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
  2365. def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn",
  2366. (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
  2367. def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn",
  2368. (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
  2369. def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt",
  2370. (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
  2371. def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt",
  2372. (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
  2373. def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt",
  2374. (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
  2375. def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn",
  2376. (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>;
  2377. def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2",
  2378. (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>;
  2379. // VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way
  2380. // VMOVD does.
  2381. def : VFP2InstAlias<"vmov${p} $Sd, $Sm",
  2382. (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>;
  2383. // FCONSTD/FCONSTS alias for vmov.f64/vmov.f32
  2384. // These aliases provide added functionality over vmov.f instructions by
  2385. // allowing users to write assembly containing encoded floating point constants
  2386. // (e.g. #0x70 vs #1.0). Without these alises there is no way for the
  2387. // assembler to accept encoded fp constants (but the equivalent fp-literal is
  2388. // accepted directly by vmovf).
  2389. def : VFP3InstAlias<"fconstd${p} $Dd, $val",
  2390. (FCONSTD DPR:$Dd, vfp_f64imm:$val, pred:$p)>;
  2391. def : VFP3InstAlias<"fconsts${p} $Sd, $val",
  2392. (FCONSTS SPR:$Sd, vfp_f32imm:$val, pred:$p)>;
  2393. def VSCCLRMD : VFPXI<(outs), (ins pred:$p, fp_dreglist_with_vpr:$regs, variable_ops),
  2394. AddrModeNone, 4, IndexModeNone, VFPMiscFrm, NoItinerary,
  2395. "vscclrm{$p}\t$regs", "", []>, Sched<[]> {
  2396. bits<13> regs;
  2397. let Inst{31-23} = 0b111011001;
  2398. let Inst{22} = regs{12};
  2399. let Inst{21-16} = 0b011111;
  2400. let Inst{15-12} = regs{11-8};
  2401. let Inst{11-8} = 0b1011;
  2402. let Inst{7-1} = regs{7-1};
  2403. let Inst{0} = 0;
  2404. let DecoderMethod = "DecodeVSCCLRM";
  2405. list<Predicate> Predicates = [HasV8_1MMainline, Has8MSecExt];
  2406. }
  2407. def VSCCLRMS : VFPXI<(outs), (ins pred:$p, fp_sreglist_with_vpr:$regs, variable_ops),
  2408. AddrModeNone, 4, IndexModeNone, VFPMiscFrm, NoItinerary,
  2409. "vscclrm{$p}\t$regs", "", []>, Sched<[]> {
  2410. bits<13> regs;
  2411. let Inst{31-23} = 0b111011001;
  2412. let Inst{22} = regs{8};
  2413. let Inst{21-16} = 0b011111;
  2414. let Inst{15-12} = regs{12-9};
  2415. let Inst{11-8} = 0b1010;
  2416. let Inst{7-0} = regs{7-0};
  2417. let DecoderMethod = "DecodeVSCCLRM";
  2418. list<Predicate> Predicates = [HasV8_1MMainline, Has8MSecExt];
  2419. }
  2420. //===----------------------------------------------------------------------===//
  2421. // Store VFP System Register to memory.
  2422. //
  2423. class vfp_vstrldr<bit opc, bit P, bit W, bits<4> SysReg, string sysreg,
  2424. dag oops, dag iops, IndexMode im, string Dest, string cstr>
  2425. : VFPI<oops, iops, AddrModeT2_i7s4, 4, im, VFPLdStFrm, IIC_fpSTAT,
  2426. !if(opc,"vldr","vstr"), !strconcat("\t", sysreg, ", ", Dest), cstr, []>,
  2427. Sched<[]> {
  2428. bits<12> addr;
  2429. let Inst{27-25} = 0b110;
  2430. let Inst{24} = P;
  2431. let Inst{23} = addr{7};
  2432. let Inst{22} = SysReg{3};
  2433. let Inst{21} = W;
  2434. let Inst{20} = opc;
  2435. let Inst{19-16} = addr{11-8};
  2436. let Inst{15-13} = SysReg{2-0};
  2437. let Inst{12-7} = 0b011111;
  2438. let Inst{6-0} = addr{6-0};
  2439. list<Predicate> Predicates = [HasFPRegs, HasV8_1MMainline];
  2440. let mayLoad = opc;
  2441. let mayStore = !if(opc, 0b0, 0b1);
  2442. let hasSideEffects = 1;
  2443. }
  2444. multiclass vfp_vstrldr_sysreg<bit opc, bits<4> SysReg, string sysreg,
  2445. dag oops=(outs), dag iops=(ins)> {
  2446. def _off :
  2447. vfp_vstrldr<opc, 1, 0, SysReg, sysreg,
  2448. oops, !con(iops, (ins t2addrmode_imm7s4:$addr)),
  2449. IndexModePost, "$addr", "" > {
  2450. let DecoderMethod = "DecodeVSTRVLDR_SYSREG<false>";
  2451. }
  2452. def _pre :
  2453. vfp_vstrldr<opc, 1, 1, SysReg, sysreg,
  2454. !con(oops, (outs GPRnopc:$wb)),
  2455. !con(iops, (ins t2addrmode_imm7s4_pre:$addr)),
  2456. IndexModePre, "$addr!", "$addr.base = $wb"> {
  2457. let DecoderMethod = "DecodeVSTRVLDR_SYSREG<true>";
  2458. }
  2459. def _post :
  2460. vfp_vstrldr<opc, 0, 1, SysReg, sysreg,
  2461. !con(oops, (outs GPRnopc:$wb)),
  2462. !con(iops, (ins t2_addr_offset_none:$Rn,
  2463. t2am_imm7s4_offset:$addr)),
  2464. IndexModePost, "$Rn$addr", "$Rn.base = $wb"> {
  2465. bits<4> Rn;
  2466. let Inst{19-16} = Rn{3-0};
  2467. let DecoderMethod = "DecodeVSTRVLDR_SYSREG<true>";
  2468. }
  2469. }
  2470. let Defs = [FPSCR] in {
  2471. defm VSTR_FPSCR : vfp_vstrldr_sysreg<0b0,0b0001, "fpscr">;
  2472. defm VSTR_FPSCR_NZCVQC : vfp_vstrldr_sysreg<0b0,0b0010, "fpscr_nzcvqc">;
  2473. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2474. defm VSTR_FPCXTNS : vfp_vstrldr_sysreg<0b0,0b1110, "fpcxtns">;
  2475. defm VSTR_FPCXTS : vfp_vstrldr_sysreg<0b0,0b1111, "fpcxts">;
  2476. }
  2477. }
  2478. let Predicates = [HasV8_1MMainline, HasMVEInt] in {
  2479. let Uses = [VPR] in {
  2480. defm VSTR_VPR : vfp_vstrldr_sysreg<0b0,0b1100, "vpr">;
  2481. }
  2482. defm VSTR_P0 : vfp_vstrldr_sysreg<0b0,0b1101, "p0",
  2483. (outs), (ins VCCR:$P0)>;
  2484. let Defs = [VPR] in {
  2485. defm VLDR_VPR : vfp_vstrldr_sysreg<0b1,0b1100, "vpr">;
  2486. }
  2487. defm VLDR_P0 : vfp_vstrldr_sysreg<0b1,0b1101, "p0",
  2488. (outs VCCR:$P0), (ins)>;
  2489. }
  2490. let Uses = [FPSCR] in {
  2491. defm VLDR_FPSCR : vfp_vstrldr_sysreg<0b1,0b0001, "fpscr">;
  2492. defm VLDR_FPSCR_NZCVQC : vfp_vstrldr_sysreg<0b1,0b0010, "fpscr_nzcvqc">;
  2493. let Predicates = [HasV8_1MMainline, Has8MSecExt] in {
  2494. defm VLDR_FPCXTNS : vfp_vstrldr_sysreg<0b1,0b1110, "fpcxtns">;
  2495. defm VLDR_FPCXTS : vfp_vstrldr_sysreg<0b1,0b1111, "fpcxts">;
  2496. }
  2497. }