ARMInstrFormats.td 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785
  1. //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- 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. //
  10. // ARM Instruction Format Definitions.
  11. //
  12. // Format specifies the encoding used by the instruction. This is part of the
  13. // ad-hoc solution used to emit machine instruction encodings by our machine
  14. // code emitter.
  15. class Format<bits<6> val> {
  16. bits<6> Value = val;
  17. }
  18. def Pseudo : Format<0>;
  19. def MulFrm : Format<1>;
  20. def BrFrm : Format<2>;
  21. def BrMiscFrm : Format<3>;
  22. def DPFrm : Format<4>;
  23. def DPSoRegRegFrm : Format<5>;
  24. def LdFrm : Format<6>;
  25. def StFrm : Format<7>;
  26. def LdMiscFrm : Format<8>;
  27. def StMiscFrm : Format<9>;
  28. def LdStMulFrm : Format<10>;
  29. def LdStExFrm : Format<11>;
  30. def ArithMiscFrm : Format<12>;
  31. def SatFrm : Format<13>;
  32. def ExtFrm : Format<14>;
  33. def VFPUnaryFrm : Format<15>;
  34. def VFPBinaryFrm : Format<16>;
  35. def VFPConv1Frm : Format<17>;
  36. def VFPConv2Frm : Format<18>;
  37. def VFPConv3Frm : Format<19>;
  38. def VFPConv4Frm : Format<20>;
  39. def VFPConv5Frm : Format<21>;
  40. def VFPLdStFrm : Format<22>;
  41. def VFPLdStMulFrm : Format<23>;
  42. def VFPMiscFrm : Format<24>;
  43. def ThumbFrm : Format<25>;
  44. def MiscFrm : Format<26>;
  45. def NGetLnFrm : Format<27>;
  46. def NSetLnFrm : Format<28>;
  47. def NDupFrm : Format<29>;
  48. def NLdStFrm : Format<30>;
  49. def N1RegModImmFrm: Format<31>;
  50. def N2RegFrm : Format<32>;
  51. def NVCVTFrm : Format<33>;
  52. def NVDupLnFrm : Format<34>;
  53. def N2RegVShLFrm : Format<35>;
  54. def N2RegVShRFrm : Format<36>;
  55. def N3RegFrm : Format<37>;
  56. def N3RegVShFrm : Format<38>;
  57. def NVExtFrm : Format<39>;
  58. def NVMulSLFrm : Format<40>;
  59. def NVTBLFrm : Format<41>;
  60. def DPSoRegImmFrm : Format<42>;
  61. def N3RegCplxFrm : Format<43>;
  62. // Misc flags.
  63. // The instruction has an Rn register operand.
  64. // UnaryDP - Indicates this is a unary data processing instruction, i.e.
  65. // it doesn't have a Rn operand.
  66. class UnaryDP { bit isUnaryDataProc = 1; }
  67. // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
  68. // a 16-bit Thumb instruction if certain conditions are met.
  69. class Xform16Bit { bit canXformTo16Bit = 1; }
  70. //===----------------------------------------------------------------------===//
  71. // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
  72. //
  73. // FIXME: Once the JIT is MC-ized, these can go away.
  74. // Addressing mode.
  75. class AddrMode<bits<5> val> {
  76. bits<5> Value = val;
  77. }
  78. def AddrModeNone : AddrMode<0>;
  79. def AddrMode1 : AddrMode<1>;
  80. def AddrMode2 : AddrMode<2>;
  81. def AddrMode3 : AddrMode<3>;
  82. def AddrMode4 : AddrMode<4>;
  83. def AddrMode5 : AddrMode<5>;
  84. def AddrMode6 : AddrMode<6>;
  85. def AddrModeT1_1 : AddrMode<7>;
  86. def AddrModeT1_2 : AddrMode<8>;
  87. def AddrModeT1_4 : AddrMode<9>;
  88. def AddrModeT1_s : AddrMode<10>;
  89. def AddrModeT2_i12 : AddrMode<11>;
  90. def AddrModeT2_i8 : AddrMode<12>;
  91. def AddrModeT2_i8pos : AddrMode<13>;
  92. def AddrModeT2_i8neg : AddrMode<14>;
  93. def AddrModeT2_so : AddrMode<15>;
  94. def AddrModeT2_pc : AddrMode<16>;
  95. def AddrModeT2_i8s4 : AddrMode<17>;
  96. def AddrMode_i12 : AddrMode<18>;
  97. def AddrMode5FP16 : AddrMode<19>;
  98. def AddrModeT2_ldrex : AddrMode<20>;
  99. def AddrModeT2_i7s4 : AddrMode<21>;
  100. def AddrModeT2_i7s2 : AddrMode<22>;
  101. def AddrModeT2_i7 : AddrMode<23>;
  102. // Load / store index mode.
  103. class IndexMode<bits<2> val> {
  104. bits<2> Value = val;
  105. }
  106. def IndexModeNone : IndexMode<0>;
  107. def IndexModePre : IndexMode<1>;
  108. def IndexModePost : IndexMode<2>;
  109. def IndexModeUpd : IndexMode<3>;
  110. // Instruction execution domain.
  111. class Domain<bits<4> val> {
  112. bits<4> Value = val;
  113. }
  114. def GenericDomain : Domain<0>;
  115. def VFPDomain : Domain<1>; // Instructions in VFP domain only
  116. def NeonDomain : Domain<2>; // Instructions in Neon domain only
  117. def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
  118. def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
  119. def MVEDomain : Domain<8>; // Instructions in MVE and ARMv8.1m
  120. //===----------------------------------------------------------------------===//
  121. // ARM special operands.
  122. //
  123. // ARM imod and iflag operands, used only by the CPS instruction.
  124. def imod_op : Operand<i32> {
  125. let PrintMethod = "printCPSIMod";
  126. }
  127. def ProcIFlagsOperand : AsmOperandClass {
  128. let Name = "ProcIFlags";
  129. let ParserMethod = "parseProcIFlagsOperand";
  130. }
  131. def iflags_op : Operand<i32> {
  132. let PrintMethod = "printCPSIFlag";
  133. let ParserMatchClass = ProcIFlagsOperand;
  134. }
  135. // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
  136. // register whose default is 0 (no register).
  137. def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
  138. def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
  139. (ops (i32 14), (i32 zero_reg))> {
  140. let PrintMethod = "printPredicateOperand";
  141. let ParserMatchClass = CondCodeOperand;
  142. let DecoderMethod = "DecodePredicateOperand";
  143. }
  144. // Selectable predicate operand for CMOV instructions. We can't use a normal
  145. // predicate because the default values interfere with instruction selection. In
  146. // all other respects it is identical though: pseudo-instruction expansion
  147. // relies on the MachineOperands being compatible.
  148. def cmovpred : Operand<i32>, PredicateOp,
  149. ComplexPattern<i32, 2, "SelectCMOVPred"> {
  150. let MIOperandInfo = (ops i32imm, i32imm);
  151. let PrintMethod = "printPredicateOperand";
  152. }
  153. // Conditional code result for instructions whose 's' bit is set, e.g. subs.
  154. def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
  155. def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
  156. let EncoderMethod = "getCCOutOpValue";
  157. let PrintMethod = "printSBitModifierOperand";
  158. let ParserMatchClass = CCOutOperand;
  159. let DecoderMethod = "DecodeCCOutOperand";
  160. }
  161. // Same as cc_out except it defaults to setting CPSR.
  162. def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
  163. let EncoderMethod = "getCCOutOpValue";
  164. let PrintMethod = "printSBitModifierOperand";
  165. let ParserMatchClass = CCOutOperand;
  166. let DecoderMethod = "DecodeCCOutOperand";
  167. }
  168. // Transform to generate the inverse of a condition code during ISel
  169. def inv_cond_XFORM : SDNodeXForm<imm, [{
  170. ARMCC::CondCodes CC = static_cast<ARMCC::CondCodes>(N->getZExtValue());
  171. return CurDAG->getTargetConstant(ARMCC::getOppositeCondition(CC), SDLoc(N),
  172. MVT::i32);
  173. }]>;
  174. // VPT predicate
  175. def VPTPredNOperand : AsmOperandClass {
  176. let Name = "VPTPredN";
  177. let PredicateMethod = "isVPTPred";
  178. }
  179. def VPTPredROperand : AsmOperandClass {
  180. let Name = "VPTPredR";
  181. let PredicateMethod = "isVPTPred";
  182. }
  183. // Operand classes for the cluster of MC operands describing a
  184. // VPT-predicated MVE instruction.
  185. //
  186. // There are two of these classes. Both of them have the same first
  187. // two options:
  188. //
  189. // $cond (an integer) indicates the instruction's predication status:
  190. // * ARMVCC::None means it's unpredicated
  191. // * ARMVCC::Then means it's in a VPT block and appears with the T suffix
  192. // * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
  193. // During code generation, unpredicated and predicated instructions
  194. // are indicated by setting this parameter to 'None' or to 'Then'; the
  195. // third value 'Else' is only used for assembly and disassembly.
  196. //
  197. // $cond_reg (type VCCR) gives the input predicate register. This is
  198. // always either zero_reg or VPR, but needs to be modelled as an
  199. // explicit operand so that it can be register-allocated and spilled
  200. // when these operands are used in code generation).
  201. //
  202. // For 'vpred_r', there's an extra operand $inactive, which specifies
  203. // the vector register which will supply any lanes of the output
  204. // register that the predication mask prevents from being written by
  205. // this instruction. It's always tied to the actual output register
  206. // (i.e. must be allocated into the same physical reg), but again,
  207. // code generation will need to model it as a separate input value.
  208. //
  209. // 'vpred_n' doesn't have that extra operand: it only has $cond and
  210. // $cond_reg. This variant is used for any instruction that can't, or
  211. // doesn't want to, tie $inactive to the output register. Sometimes
  212. // that's because another input parameter is already tied to it (e.g.
  213. // instructions that both read and write their Qd register even when
  214. // unpredicated, either because they only partially overwrite it like
  215. // a narrowing integer conversion, or simply because the instruction
  216. // encoding doesn't have enough register fields to make the output
  217. // independent of all inputs). It can also be because the instruction
  218. // is defined to set disabled output lanes to zero rather than leaving
  219. // them unchanged (vector loads), or because it doesn't output a
  220. // vector register at all (stores, compares). In any of these
  221. // situations it's unnecessary to have an extra operand tied to the
  222. // output, and inconvenient to leave it there unused.
  223. // Base class for both kinds of vpred.
  224. class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
  225. !con((ops (i32 0), (i32 zero_reg), (i32 zero_reg)), extra_op)> {
  226. let PrintMethod = "printVPTPredicateOperand";
  227. let OperandNamespace = "ARM";
  228. let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg, GPRlr:$tp_reg), extra_mi);
  229. // For convenience, we provide a string value that can be appended
  230. // to the constraints string. It's empty for vpred_n, and for
  231. // vpred_r it ties the $inactive operand to the output q-register
  232. // (which by convention will be called $Qd).
  233. string vpred_constraint;
  234. }
  235. def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
  236. let ParserMatchClass = VPTPredROperand;
  237. let OperandType = "OPERAND_VPRED_R";
  238. let DecoderMethod = "DecodeVpredROperand";
  239. let vpred_constraint = ",$Qd = $vp.inactive";
  240. }
  241. def vpred_n : vpred_ops<(ops), (ops)> {
  242. let ParserMatchClass = VPTPredNOperand;
  243. let OperandType = "OPERAND_VPRED_N";
  244. let vpred_constraint = "";
  245. }
  246. // ARM special operands for disassembly only.
  247. //
  248. def SetEndAsmOperand : ImmAsmOperand<0,1> {
  249. let Name = "SetEndImm";
  250. let ParserMethod = "parseSetEndImm";
  251. }
  252. def setend_op : Operand<i32> {
  253. let PrintMethod = "printSetendOperand";
  254. let ParserMatchClass = SetEndAsmOperand;
  255. }
  256. def MSRMaskOperand : AsmOperandClass {
  257. let Name = "MSRMask";
  258. let ParserMethod = "parseMSRMaskOperand";
  259. }
  260. def msr_mask : Operand<i32> {
  261. let PrintMethod = "printMSRMaskOperand";
  262. let DecoderMethod = "DecodeMSRMask";
  263. let ParserMatchClass = MSRMaskOperand;
  264. }
  265. def BankedRegOperand : AsmOperandClass {
  266. let Name = "BankedReg";
  267. let ParserMethod = "parseBankedRegOperand";
  268. }
  269. def banked_reg : Operand<i32> {
  270. let PrintMethod = "printBankedRegOperand";
  271. let DecoderMethod = "DecodeBankedReg";
  272. let ParserMatchClass = BankedRegOperand;
  273. }
  274. // Shift Right Immediate - A shift right immediate is encoded differently from
  275. // other shift immediates. The imm6 field is encoded like so:
  276. //
  277. // Offset Encoding
  278. // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
  279. // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
  280. // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
  281. // 64 64 - <imm> is encoded in imm6<5:0>
  282. def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
  283. def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
  284. let EncoderMethod = "getShiftRight8Imm";
  285. let DecoderMethod = "DecodeShiftRight8Imm";
  286. let ParserMatchClass = shr_imm8_asm_operand;
  287. }
  288. def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
  289. def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
  290. let EncoderMethod = "getShiftRight16Imm";
  291. let DecoderMethod = "DecodeShiftRight16Imm";
  292. let ParserMatchClass = shr_imm16_asm_operand;
  293. }
  294. def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
  295. def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
  296. let EncoderMethod = "getShiftRight32Imm";
  297. let DecoderMethod = "DecodeShiftRight32Imm";
  298. let ParserMatchClass = shr_imm32_asm_operand;
  299. }
  300. def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
  301. def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
  302. let EncoderMethod = "getShiftRight64Imm";
  303. let DecoderMethod = "DecodeShiftRight64Imm";
  304. let ParserMatchClass = shr_imm64_asm_operand;
  305. }
  306. // ARM Assembler operand for ldr Rd, =expression which generates an offset
  307. // to a constant pool entry or a MOV depending on the value of expression
  308. def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
  309. def const_pool_asm_imm : Operand<i32> {
  310. let ParserMatchClass = const_pool_asm_operand;
  311. }
  312. //===----------------------------------------------------------------------===//
  313. // ARM Assembler alias templates.
  314. //
  315. // Note: When EmitPriority == 1, the alias will be used for printing
  316. class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
  317. : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
  318. class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
  319. : InstAlias<Asm, Result, EmitPriority>,
  320. Requires<[IsARM,UseNegativeImmediates]>;
  321. class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
  322. : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
  323. class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
  324. : InstAlias<Asm, Result, EmitPriority>,
  325. Requires<[IsThumb,UseNegativeImmediates]>;
  326. class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
  327. : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
  328. class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
  329. : InstAlias<Asm, Result, EmitPriority>,
  330. Requires<[IsThumb2,UseNegativeImmediates]>;
  331. class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
  332. : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
  333. class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
  334. : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
  335. class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
  336. : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
  337. class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
  338. : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
  339. class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
  340. : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
  341. class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
  342. Requires<[HasVFP2]>;
  343. class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
  344. Requires<[HasNEON]>;
  345. //===----------------------------------------------------------------------===//
  346. // ARM Instruction templates.
  347. //
  348. class InstTemplate<AddrMode am, int sz, IndexMode im,
  349. Format f, Domain d, string cstr, InstrItinClass itin>
  350. : Instruction {
  351. let Namespace = "ARM";
  352. AddrMode AM = am;
  353. int Size = sz;
  354. IndexMode IM = im;
  355. bits<2> IndexModeBits = IM.Value;
  356. Format F = f;
  357. bits<6> Form = F.Value;
  358. Domain D = d;
  359. bit isUnaryDataProc = 0;
  360. bit canXformTo16Bit = 0;
  361. // The instruction is a 16-bit flag setting Thumb instruction. Used
  362. // by the parser and if-converter to determine whether to require the 'S'
  363. // suffix on the mnemonic (when not in an IT block) or preclude it (when
  364. // in an IT block).
  365. bit thumbArithFlagSetting = 0;
  366. bits<2> VecSize = 0;
  367. bit validForTailPredication = 0;
  368. bit retainsPreviousHalfElement = 0;
  369. bit horizontalReduction = 0;
  370. bit doubleWidthResult = 0;
  371. // If this is a pseudo instruction, mark it isCodeGenOnly.
  372. let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
  373. // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
  374. let TSFlags{4-0} = AM.Value;
  375. let TSFlags{6-5} = IndexModeBits;
  376. let TSFlags{12-7} = Form;
  377. let TSFlags{13} = isUnaryDataProc;
  378. let TSFlags{14} = canXformTo16Bit;
  379. let TSFlags{18-15} = D.Value;
  380. let TSFlags{19} = thumbArithFlagSetting;
  381. let TSFlags{20} = validForTailPredication;
  382. let TSFlags{21} = retainsPreviousHalfElement;
  383. let TSFlags{22} = horizontalReduction;
  384. let TSFlags{23} = doubleWidthResult;
  385. let TSFlags{25-24} = VecSize;
  386. let Constraints = cstr;
  387. let Itinerary = itin;
  388. }
  389. class Encoding {
  390. field bits<32> Inst;
  391. // Mask of bits that cause an encoding to be UNPREDICTABLE.
  392. // If a bit is set, then if the corresponding bit in the
  393. // target encoding differs from its value in the "Inst" field,
  394. // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
  395. field bits<32> Unpredictable = 0;
  396. // SoftFail is the generic name for this field, but we alias it so
  397. // as to make it more obvious what it means in ARM-land.
  398. field bits<32> SoftFail = Unpredictable;
  399. }
  400. class InstARM<AddrMode am, int sz, IndexMode im,
  401. Format f, Domain d, string cstr, InstrItinClass itin>
  402. : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
  403. let DecoderNamespace = "ARM";
  404. }
  405. // This Encoding-less class is used by Thumb1 to specify the encoding bits later
  406. // on by adding flavors to specific instructions.
  407. class InstThumb<AddrMode am, int sz, IndexMode im,
  408. Format f, Domain d, string cstr, InstrItinClass itin>
  409. : InstTemplate<am, sz, im, f, d, cstr, itin> {
  410. let DecoderNamespace = "Thumb";
  411. }
  412. // Pseudo-instructions for alternate assembly syntax (never used by codegen).
  413. // These are aliases that require C++ handling to convert to the target
  414. // instruction, while InstAliases can be handled directly by tblgen.
  415. class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
  416. : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
  417. "", NoItinerary> {
  418. let OutOperandList = oops;
  419. let InOperandList = iops;
  420. let Pattern = [];
  421. let isCodeGenOnly = 0; // So we get asm matcher for it.
  422. let AsmString = asm;
  423. let isPseudo = 1;
  424. let hasNoSchedulingInfo = 1;
  425. }
  426. class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
  427. : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
  428. class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
  429. : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
  430. class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
  431. : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
  432. class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
  433. : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
  434. class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
  435. : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
  436. class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
  437. : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
  438. // Pseudo instructions for the code generator.
  439. class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
  440. : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
  441. GenericDomain, "", itin> {
  442. let OutOperandList = oops;
  443. let InOperandList = iops;
  444. let Pattern = pattern;
  445. let isCodeGenOnly = 1;
  446. let isPseudo = 1;
  447. }
  448. // PseudoInst that's ARM-mode only.
  449. class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
  450. list<dag> pattern>
  451. : PseudoInst<oops, iops, itin, pattern> {
  452. let Size = sz;
  453. list<Predicate> Predicates = [IsARM];
  454. }
  455. // PseudoInst that's Thumb-mode only.
  456. class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
  457. list<dag> pattern>
  458. : PseudoInst<oops, iops, itin, pattern> {
  459. let Size = sz;
  460. list<Predicate> Predicates = [IsThumb];
  461. }
  462. // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
  463. class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
  464. list<dag> pattern>
  465. : PseudoInst<oops, iops, itin, pattern> {
  466. let Size = sz;
  467. list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
  468. }
  469. // PseudoInst that's Thumb2-mode only.
  470. class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
  471. list<dag> pattern>
  472. : PseudoInst<oops, iops, itin, pattern> {
  473. let Size = sz;
  474. list<Predicate> Predicates = [IsThumb2];
  475. }
  476. class ARMPseudoExpand<dag oops, dag iops, int sz,
  477. InstrItinClass itin, list<dag> pattern,
  478. dag Result>
  479. : ARMPseudoInst<oops, iops, sz, itin, pattern>,
  480. PseudoInstExpansion<Result>;
  481. class tPseudoExpand<dag oops, dag iops, int sz,
  482. InstrItinClass itin, list<dag> pattern,
  483. dag Result>
  484. : tPseudoInst<oops, iops, sz, itin, pattern>,
  485. PseudoInstExpansion<Result>;
  486. class t2PseudoExpand<dag oops, dag iops, int sz,
  487. InstrItinClass itin, list<dag> pattern,
  488. dag Result>
  489. : t2PseudoInst<oops, iops, sz, itin, pattern>,
  490. PseudoInstExpansion<Result>;
  491. // Almost all ARM instructions are predicable.
  492. class I<dag oops, dag iops, AddrMode am, int sz,
  493. IndexMode im, Format f, InstrItinClass itin,
  494. string opc, string asm, string cstr,
  495. list<dag> pattern>
  496. : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
  497. bits<4> p;
  498. let Inst{31-28} = p;
  499. let OutOperandList = oops;
  500. let InOperandList = !con(iops, (ins pred:$p));
  501. let AsmString = !strconcat(opc, "${p}", asm);
  502. let Pattern = pattern;
  503. list<Predicate> Predicates = [IsARM];
  504. }
  505. // A few are not predicable
  506. class InoP<dag oops, dag iops, AddrMode am, int sz,
  507. IndexMode im, Format f, InstrItinClass itin,
  508. string opc, string asm, string cstr,
  509. list<dag> pattern>
  510. : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
  511. let OutOperandList = oops;
  512. let InOperandList = iops;
  513. let AsmString = !strconcat(opc, asm);
  514. let Pattern = pattern;
  515. let isPredicable = 0;
  516. list<Predicate> Predicates = [IsARM];
  517. }
  518. // Same as I except it can optionally modify CPSR. Note it's modeled as an input
  519. // operand since by default it's a zero register. It will become an implicit def
  520. // once it's "flipped".
  521. class sI<dag oops, dag iops, AddrMode am, int sz,
  522. IndexMode im, Format f, InstrItinClass itin,
  523. string opc, string asm, string cstr,
  524. list<dag> pattern>
  525. : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
  526. bits<4> p; // Predicate operand
  527. bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
  528. let Inst{31-28} = p;
  529. let Inst{20} = s;
  530. let OutOperandList = oops;
  531. let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
  532. let AsmString = !strconcat(opc, "${s}${p}", asm);
  533. let Pattern = pattern;
  534. list<Predicate> Predicates = [IsARM];
  535. }
  536. // Special cases
  537. class XI<dag oops, dag iops, AddrMode am, int sz,
  538. IndexMode im, Format f, InstrItinClass itin,
  539. string asm, string cstr, list<dag> pattern>
  540. : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
  541. let OutOperandList = oops;
  542. let InOperandList = iops;
  543. let AsmString = asm;
  544. let Pattern = pattern;
  545. list<Predicate> Predicates = [IsARM];
  546. }
  547. class AI<dag oops, dag iops, Format f, InstrItinClass itin,
  548. string opc, string asm, list<dag> pattern>
  549. : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
  550. opc, asm, "", pattern>;
  551. class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
  552. string opc, string asm, list<dag> pattern>
  553. : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
  554. opc, asm, "", pattern>;
  555. class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
  556. string asm, list<dag> pattern>
  557. : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
  558. asm, "", pattern>;
  559. class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
  560. string asm, list<dag> pattern>
  561. : XI<oops, iops, am, 4, IndexModeNone, f, itin,
  562. asm, "", pattern>;
  563. class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
  564. string opc, string asm, list<dag> pattern>
  565. : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
  566. opc, asm, "", pattern>;
  567. // Ctrl flow instructions
  568. class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
  569. string opc, string asm, list<dag> pattern>
  570. : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
  571. opc, asm, "", pattern> {
  572. let Inst{27-24} = opcod;
  573. }
  574. class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
  575. string asm, list<dag> pattern>
  576. : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
  577. asm, "", pattern> {
  578. let Inst{27-24} = opcod;
  579. }
  580. // BR_JT instructions
  581. class JTI<dag oops, dag iops, InstrItinClass itin,
  582. string asm, list<dag> pattern>
  583. : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
  584. asm, "", pattern>;
  585. class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
  586. string opc, string asm, list<dag> pattern>
  587. : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
  588. opc, asm, "", pattern> {
  589. bits<4> Rt;
  590. bits<4> addr;
  591. let Inst{27-23} = 0b00011;
  592. let Inst{22-21} = opcod;
  593. let Inst{20} = 1;
  594. let Inst{19-16} = addr;
  595. let Inst{15-12} = Rt;
  596. let Inst{11-10} = 0b11;
  597. let Inst{9-8} = opcod2;
  598. let Inst{7-0} = 0b10011111;
  599. }
  600. class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
  601. string opc, string asm, list<dag> pattern>
  602. : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
  603. opc, asm, "", pattern> {
  604. bits<4> Rt;
  605. bits<4> addr;
  606. let Inst{27-23} = 0b00011;
  607. let Inst{22-21} = opcod;
  608. let Inst{20} = 0;
  609. let Inst{19-16} = addr;
  610. let Inst{11-10} = 0b11;
  611. let Inst{9-8} = opcod2;
  612. let Inst{7-4} = 0b1001;
  613. let Inst{3-0} = Rt;
  614. }
  615. // Atomic load/store instructions
  616. class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  617. string opc, string asm, list<dag> pattern>
  618. : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
  619. class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  620. string opc, string asm, list<dag> pattern>
  621. : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
  622. bits<4> Rd;
  623. let Inst{15-12} = Rd;
  624. }
  625. // Exclusive load/store instructions
  626. class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  627. string opc, string asm, list<dag> pattern>
  628. : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
  629. Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
  630. class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  631. string opc, string asm, list<dag> pattern>
  632. : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
  633. Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
  634. bits<4> Rd;
  635. let Inst{15-12} = Rd;
  636. }
  637. class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
  638. : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
  639. bits<4> Rt;
  640. bits<4> Rt2;
  641. bits<4> addr;
  642. let Inst{27-23} = 0b00010;
  643. let Inst{22} = b;
  644. let Inst{21-20} = 0b00;
  645. let Inst{19-16} = addr;
  646. let Inst{15-12} = Rt;
  647. let Inst{11-4} = 0b00001001;
  648. let Inst{3-0} = Rt2;
  649. let Unpredictable{11-8} = 0b1111;
  650. let DecoderMethod = "DecodeSwap";
  651. }
  652. // Acquire/Release load/store instructions
  653. class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  654. string opc, string asm, list<dag> pattern>
  655. : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
  656. Requires<[IsARM, HasAcquireRelease]>;
  657. class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
  658. string opc, string asm, list<dag> pattern>
  659. : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
  660. Requires<[IsARM, HasAcquireRelease]> {
  661. let Inst{15-12} = 0b1111;
  662. }
  663. // addrmode1 instructions
  664. class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
  665. string opc, string asm, list<dag> pattern>
  666. : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
  667. opc, asm, "", pattern> {
  668. let Inst{24-21} = opcod;
  669. let Inst{27-26} = 0b00;
  670. }
  671. class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
  672. string opc, string asm, list<dag> pattern>
  673. : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
  674. opc, asm, "", pattern> {
  675. let Inst{24-21} = opcod;
  676. let Inst{27-26} = 0b00;
  677. }
  678. class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
  679. string asm, list<dag> pattern>
  680. : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
  681. asm, "", pattern> {
  682. let Inst{24-21} = opcod;
  683. let Inst{27-26} = 0b00;
  684. }
  685. // loads
  686. // LDR/LDRB/STR/STRB/...
  687. class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
  688. Format f, InstrItinClass itin, string opc, string asm,
  689. list<dag> pattern>
  690. : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
  691. "", pattern> {
  692. let Inst{27-25} = op;
  693. let Inst{24} = 1; // 24 == P
  694. // 23 == U
  695. let Inst{22} = isByte;
  696. let Inst{21} = 0; // 21 == W
  697. let Inst{20} = isLd;
  698. }
  699. // Indexed load/stores
  700. class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
  701. IndexMode im, Format f, InstrItinClass itin, string opc,
  702. string asm, string cstr, list<dag> pattern>
  703. : I<oops, iops, AddrMode2, 4, im, f, itin,
  704. opc, asm, cstr, pattern> {
  705. bits<4> Rt;
  706. let Inst{27-26} = 0b01;
  707. let Inst{24} = isPre; // P bit
  708. let Inst{22} = isByte; // B bit
  709. let Inst{21} = isPre; // W bit
  710. let Inst{20} = isLd; // L bit
  711. let Inst{15-12} = Rt;
  712. }
  713. class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
  714. IndexMode im, Format f, InstrItinClass itin, string opc,
  715. string asm, string cstr, list<dag> pattern>
  716. : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
  717. pattern> {
  718. // AM2 store w/ two operands: (GPR, am2offset)
  719. // {12} isAdd
  720. // {11-0} imm12/Rm
  721. bits<14> offset;
  722. bits<4> Rn;
  723. let Inst{25} = 1;
  724. let Inst{23} = offset{12};
  725. let Inst{19-16} = Rn;
  726. let Inst{11-5} = offset{11-5};
  727. let Inst{4} = 0;
  728. let Inst{3-0} = offset{3-0};
  729. }
  730. class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
  731. IndexMode im, Format f, InstrItinClass itin, string opc,
  732. string asm, string cstr, list<dag> pattern>
  733. : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
  734. pattern> {
  735. // AM2 store w/ two operands: (GPR, am2offset)
  736. // {12} isAdd
  737. // {11-0} imm12/Rm
  738. bits<14> offset;
  739. bits<4> Rn;
  740. let Inst{25} = 0;
  741. let Inst{23} = offset{12};
  742. let Inst{19-16} = Rn;
  743. let Inst{11-0} = offset{11-0};
  744. }
  745. // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
  746. // but for now use this class for STRT and STRBT.
  747. class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
  748. IndexMode im, Format f, InstrItinClass itin, string opc,
  749. string asm, string cstr, list<dag> pattern>
  750. : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
  751. pattern> {
  752. // AM2 store w/ two operands: (GPR, am2offset)
  753. // {17-14} Rn
  754. // {13} 1 == Rm, 0 == imm12
  755. // {12} isAdd
  756. // {11-0} imm12/Rm
  757. bits<18> addr;
  758. let Inst{25} = addr{13};
  759. let Inst{23} = addr{12};
  760. let Inst{19-16} = addr{17-14};
  761. let Inst{11-0} = addr{11-0};
  762. }
  763. // addrmode3 instructions
  764. class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
  765. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  766. : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
  767. opc, asm, "", pattern> {
  768. bits<14> addr;
  769. bits<4> Rt;
  770. let Inst{27-25} = 0b000;
  771. let Inst{24} = 1; // P bit
  772. let Inst{23} = addr{8}; // U bit
  773. let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
  774. let Inst{21} = 0; // W bit
  775. let Inst{20} = op20; // L bit
  776. let Inst{19-16} = addr{12-9}; // Rn
  777. let Inst{15-12} = Rt; // Rt
  778. let Inst{11-8} = addr{7-4}; // imm7_4/zero
  779. let Inst{7-4} = op;
  780. let Inst{3-0} = addr{3-0}; // imm3_0/Rm
  781. let DecoderMethod = "DecodeAddrMode3Instruction";
  782. }
  783. class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
  784. IndexMode im, Format f, InstrItinClass itin, string opc,
  785. string asm, string cstr, list<dag> pattern>
  786. : I<oops, iops, AddrMode3, 4, im, f, itin,
  787. opc, asm, cstr, pattern> {
  788. bits<4> Rt;
  789. let Inst{27-25} = 0b000;
  790. let Inst{24} = isPre; // P bit
  791. let Inst{21} = isPre; // W bit
  792. let Inst{20} = op20; // L bit
  793. let Inst{15-12} = Rt; // Rt
  794. let Inst{7-4} = op;
  795. }
  796. // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
  797. // but for now use this class for LDRSBT, LDRHT, LDSHT.
  798. class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
  799. IndexMode im, Format f, InstrItinClass itin, string opc,
  800. string asm, string cstr, list<dag> pattern>
  801. : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
  802. // {13} 1 == imm8, 0 == Rm
  803. // {12-9} Rn
  804. // {8} isAdd
  805. // {7-4} imm7_4/zero
  806. // {3-0} imm3_0/Rm
  807. bits<4> addr;
  808. bits<4> Rt;
  809. let Inst{27-25} = 0b000;
  810. let Inst{24} = 0; // P bit
  811. let Inst{21} = 1;
  812. let Inst{20} = isLoad; // L bit
  813. let Inst{19-16} = addr; // Rn
  814. let Inst{15-12} = Rt; // Rt
  815. let Inst{7-4} = op;
  816. }
  817. // stores
  818. class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
  819. string opc, string asm, list<dag> pattern>
  820. : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
  821. opc, asm, "", pattern> {
  822. bits<14> addr;
  823. bits<4> Rt;
  824. let Inst{27-25} = 0b000;
  825. let Inst{24} = 1; // P bit
  826. let Inst{23} = addr{8}; // U bit
  827. let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
  828. let Inst{21} = 0; // W bit
  829. let Inst{20} = 0; // L bit
  830. let Inst{19-16} = addr{12-9}; // Rn
  831. let Inst{15-12} = Rt; // Rt
  832. let Inst{11-8} = addr{7-4}; // imm7_4/zero
  833. let Inst{7-4} = op;
  834. let Inst{3-0} = addr{3-0}; // imm3_0/Rm
  835. let DecoderMethod = "DecodeAddrMode3Instruction";
  836. }
  837. // addrmode4 instructions
  838. class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
  839. string asm, string cstr, list<dag> pattern>
  840. : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
  841. bits<4> p;
  842. bits<16> regs;
  843. bits<4> Rn;
  844. let Inst{31-28} = p;
  845. let Inst{27-25} = 0b100;
  846. let Inst{22} = 0; // S bit
  847. let Inst{19-16} = Rn;
  848. let Inst{15-0} = regs;
  849. }
  850. // Unsigned multiply, multiply-accumulate instructions.
  851. class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
  852. string opc, string asm, list<dag> pattern>
  853. : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
  854. opc, asm, "", pattern> {
  855. let Inst{7-4} = 0b1001;
  856. let Inst{20} = 0; // S bit
  857. let Inst{27-21} = opcod;
  858. }
  859. class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
  860. string opc, string asm, list<dag> pattern>
  861. : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
  862. opc, asm, "", pattern> {
  863. let Inst{7-4} = 0b1001;
  864. let Inst{27-21} = opcod;
  865. }
  866. // Most significant word multiply
  867. class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
  868. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  869. : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
  870. opc, asm, "", pattern> {
  871. bits<4> Rd;
  872. bits<4> Rn;
  873. bits<4> Rm;
  874. let Inst{7-4} = opc7_4;
  875. let Inst{20} = 1;
  876. let Inst{27-21} = opcod;
  877. let Inst{19-16} = Rd;
  878. let Inst{11-8} = Rm;
  879. let Inst{3-0} = Rn;
  880. }
  881. // MSW multiple w/ Ra operand
  882. class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
  883. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  884. : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
  885. bits<4> Ra;
  886. let Inst{15-12} = Ra;
  887. }
  888. // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
  889. class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
  890. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  891. : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
  892. opc, asm, "", pattern> {
  893. bits<4> Rn;
  894. bits<4> Rm;
  895. let Inst{4} = 0;
  896. let Inst{7} = 1;
  897. let Inst{20} = 0;
  898. let Inst{27-21} = opcod;
  899. let Inst{6-5} = bit6_5;
  900. let Inst{11-8} = Rm;
  901. let Inst{3-0} = Rn;
  902. }
  903. class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
  904. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  905. : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
  906. bits<4> Rd;
  907. let Inst{19-16} = Rd;
  908. }
  909. // AMulxyI with Ra operand
  910. class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
  911. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  912. : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
  913. bits<4> Ra;
  914. let Inst{15-12} = Ra;
  915. }
  916. // SMLAL*
  917. class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
  918. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  919. : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
  920. bits<4> RdLo;
  921. bits<4> RdHi;
  922. let Inst{19-16} = RdHi;
  923. let Inst{15-12} = RdLo;
  924. }
  925. // Extend instructions.
  926. class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
  927. string opc, string asm, list<dag> pattern>
  928. : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
  929. opc, asm, "", pattern> {
  930. // All AExtI instructions have Rd and Rm register operands.
  931. bits<4> Rd;
  932. bits<4> Rm;
  933. let Inst{15-12} = Rd;
  934. let Inst{3-0} = Rm;
  935. let Inst{7-4} = 0b0111;
  936. let Inst{9-8} = 0b00;
  937. let Inst{27-20} = opcod;
  938. let Unpredictable{9-8} = 0b11;
  939. }
  940. // Misc Arithmetic instructions.
  941. class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
  942. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  943. : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
  944. opc, asm, "", pattern> {
  945. bits<4> Rd;
  946. bits<4> Rm;
  947. let Inst{27-20} = opcod;
  948. let Inst{19-16} = 0b1111;
  949. let Inst{15-12} = Rd;
  950. let Inst{11-8} = 0b1111;
  951. let Inst{7-4} = opc7_4;
  952. let Inst{3-0} = Rm;
  953. }
  954. // Division instructions.
  955. class ADivA1I<bits<3> opcod, dag oops, dag iops,
  956. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  957. : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
  958. opc, asm, "", pattern> {
  959. bits<4> Rd;
  960. bits<4> Rn;
  961. bits<4> Rm;
  962. let Inst{27-23} = 0b01110;
  963. let Inst{22-20} = opcod;
  964. let Inst{19-16} = Rd;
  965. let Inst{15-12} = 0b1111;
  966. let Inst{11-8} = Rm;
  967. let Inst{7-4} = 0b0001;
  968. let Inst{3-0} = Rn;
  969. }
  970. // PKH instructions
  971. def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
  972. let Name = "PKHLSLImm";
  973. let ParserMethod = "parsePKHLSLImm";
  974. }
  975. def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
  976. let PrintMethod = "printPKHLSLShiftImm";
  977. let ParserMatchClass = PKHLSLAsmOperand;
  978. }
  979. def PKHASRAsmOperand : AsmOperandClass {
  980. let Name = "PKHASRImm";
  981. let ParserMethod = "parsePKHASRImm";
  982. }
  983. def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
  984. let PrintMethod = "printPKHASRShiftImm";
  985. let ParserMatchClass = PKHASRAsmOperand;
  986. }
  987. class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
  988. string opc, string asm, list<dag> pattern>
  989. : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
  990. opc, asm, "", pattern> {
  991. bits<4> Rd;
  992. bits<4> Rn;
  993. bits<4> Rm;
  994. bits<5> sh;
  995. let Inst{27-20} = opcod;
  996. let Inst{19-16} = Rn;
  997. let Inst{15-12} = Rd;
  998. let Inst{11-7} = sh;
  999. let Inst{6} = tb;
  1000. let Inst{5-4} = 0b01;
  1001. let Inst{3-0} = Rm;
  1002. }
  1003. //===----------------------------------------------------------------------===//
  1004. // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
  1005. class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
  1006. list<Predicate> Predicates = [IsARM];
  1007. }
  1008. class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
  1009. list<Predicate> Predicates = [IsARM, HasV5T];
  1010. }
  1011. class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
  1012. list<Predicate> Predicates = [IsARM, HasV5TE];
  1013. }
  1014. // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
  1015. class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
  1016. list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
  1017. }
  1018. class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
  1019. list<Predicate> Predicates = [IsARM, HasV6];
  1020. }
  1021. class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
  1022. list<Predicate> Predicates = [HasVFP2];
  1023. }
  1024. class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
  1025. list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
  1026. }
  1027. class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
  1028. list<Predicate> Predicates = [IsThumb2, HasDSP];
  1029. }
  1030. class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
  1031. list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
  1032. }
  1033. class FPRegs16Pat<dag pattern, dag result> : Pat<pattern, result> {
  1034. list<Predicate> Predicates = [HasFPRegs16];
  1035. }
  1036. class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
  1037. list<Predicate> Predicates = [HasFP16];
  1038. }
  1039. class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
  1040. list<Predicate> Predicates = [HasFullFP16];
  1041. }
  1042. //===----------------------------------------------------------------------===//
  1043. // Thumb Instruction Format Definitions.
  1044. //
  1045. class ThumbI<dag oops, dag iops, AddrMode am, int sz,
  1046. InstrItinClass itin, string asm, string cstr, list<dag> pattern>
  1047. : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1048. let OutOperandList = oops;
  1049. let InOperandList = iops;
  1050. let AsmString = asm;
  1051. let Pattern = pattern;
  1052. list<Predicate> Predicates = [IsThumb];
  1053. }
  1054. // TI - Thumb instruction.
  1055. class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
  1056. : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
  1057. // Two-address instructions
  1058. class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
  1059. list<dag> pattern>
  1060. : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
  1061. pattern>;
  1062. // tBL, tBX 32-bit instructions
  1063. class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
  1064. dag oops, dag iops, InstrItinClass itin, string asm,
  1065. list<dag> pattern>
  1066. : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
  1067. Encoding {
  1068. let Inst{31-27} = opcod1;
  1069. let Inst{15-14} = opcod2;
  1070. let Inst{12} = opcod3;
  1071. }
  1072. // BR_JT instructions
  1073. class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
  1074. list<dag> pattern>
  1075. : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
  1076. // Thumb1 only
  1077. class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
  1078. InstrItinClass itin, string asm, string cstr, list<dag> pattern>
  1079. : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1080. let OutOperandList = oops;
  1081. let InOperandList = iops;
  1082. let AsmString = asm;
  1083. let Pattern = pattern;
  1084. list<Predicate> Predicates = [IsThumb, IsThumb1Only];
  1085. }
  1086. class T1I<dag oops, dag iops, InstrItinClass itin,
  1087. string asm, list<dag> pattern>
  1088. : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
  1089. class T1Ix2<dag oops, dag iops, InstrItinClass itin,
  1090. string asm, list<dag> pattern>
  1091. : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
  1092. // Two-address instructions
  1093. class T1It<dag oops, dag iops, InstrItinClass itin,
  1094. string asm, string cstr, list<dag> pattern>
  1095. : Thumb1I<oops, iops, AddrModeNone, 2, itin,
  1096. asm, cstr, pattern>;
  1097. // Thumb1 instruction that can either be predicated or set CPSR.
  1098. class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
  1099. InstrItinClass itin,
  1100. string opc, string asm, string cstr, list<dag> pattern>
  1101. : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1102. let OutOperandList = !con(oops, (outs s_cc_out:$s));
  1103. let InOperandList = !con(iops, (ins pred:$p));
  1104. let AsmString = !strconcat(opc, "${s}${p}", asm);
  1105. let Pattern = pattern;
  1106. let thumbArithFlagSetting = 1;
  1107. list<Predicate> Predicates = [IsThumb, IsThumb1Only];
  1108. let DecoderNamespace = "ThumbSBit";
  1109. }
  1110. class T1sI<dag oops, dag iops, InstrItinClass itin,
  1111. string opc, string asm, list<dag> pattern>
  1112. : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
  1113. // Two-address instructions
  1114. class T1sIt<dag oops, dag iops, InstrItinClass itin,
  1115. string opc, string asm, list<dag> pattern>
  1116. : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
  1117. "$Rn = $Rdn", pattern>;
  1118. // Thumb1 instruction that can be predicated.
  1119. class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
  1120. InstrItinClass itin,
  1121. string opc, string asm, string cstr, list<dag> pattern>
  1122. : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1123. let OutOperandList = oops;
  1124. let InOperandList = !con(iops, (ins pred:$p));
  1125. let AsmString = !strconcat(opc, "${p}", asm);
  1126. let Pattern = pattern;
  1127. list<Predicate> Predicates = [IsThumb, IsThumb1Only];
  1128. }
  1129. class T1pI<dag oops, dag iops, InstrItinClass itin,
  1130. string opc, string asm, list<dag> pattern>
  1131. : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
  1132. // Two-address instructions
  1133. class T1pIt<dag oops, dag iops, InstrItinClass itin,
  1134. string opc, string asm, list<dag> pattern>
  1135. : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
  1136. "$Rn = $Rdn", pattern>;
  1137. class T1pIs<dag oops, dag iops,
  1138. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1139. : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
  1140. class Encoding16 : Encoding {
  1141. let Inst{31-16} = 0x0000;
  1142. }
  1143. // A6.2 16-bit Thumb instruction encoding
  1144. class T1Encoding<bits<6> opcode> : Encoding16 {
  1145. let Inst{15-10} = opcode;
  1146. }
  1147. // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
  1148. class T1General<bits<5> opcode> : Encoding16 {
  1149. let Inst{15-14} = 0b00;
  1150. let Inst{13-9} = opcode;
  1151. }
  1152. // A6.2.2 Data-processing encoding.
  1153. class T1DataProcessing<bits<4> opcode> : Encoding16 {
  1154. let Inst{15-10} = 0b010000;
  1155. let Inst{9-6} = opcode;
  1156. }
  1157. // A6.2.3 Special data instructions and branch and exchange encoding.
  1158. class T1Special<bits<4> opcode> : Encoding16 {
  1159. let Inst{15-10} = 0b010001;
  1160. let Inst{9-6} = opcode;
  1161. }
  1162. // A6.2.4 Load/store single data item encoding.
  1163. class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
  1164. let Inst{15-12} = opA;
  1165. let Inst{11-9} = opB;
  1166. }
  1167. class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
  1168. class T1BranchCond<bits<4> opcode> : Encoding16 {
  1169. let Inst{15-12} = opcode;
  1170. }
  1171. // Helper classes to encode Thumb1 loads and stores. For immediates, the
  1172. // following bits are used for "opA" (see A6.2.4):
  1173. //
  1174. // 0b0110 => Immediate, 4 bytes
  1175. // 0b1000 => Immediate, 2 bytes
  1176. // 0b0111 => Immediate, 1 byte
  1177. class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
  1178. InstrItinClass itin, string opc, string asm,
  1179. list<dag> pattern>
  1180. : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
  1181. T1LoadStore<0b0101, opcode> {
  1182. bits<3> Rt;
  1183. bits<8> addr;
  1184. let Inst{8-6} = addr{5-3}; // Rm
  1185. let Inst{5-3} = addr{2-0}; // Rn
  1186. let Inst{2-0} = Rt;
  1187. }
  1188. class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
  1189. InstrItinClass itin, string opc, string asm,
  1190. list<dag> pattern>
  1191. : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
  1192. T1LoadStore<opA, {opB,?,?}> {
  1193. bits<3> Rt;
  1194. bits<8> addr;
  1195. let Inst{10-6} = addr{7-3}; // imm5
  1196. let Inst{5-3} = addr{2-0}; // Rn
  1197. let Inst{2-0} = Rt;
  1198. }
  1199. // A6.2.5 Miscellaneous 16-bit instructions encoding.
  1200. class T1Misc<bits<7> opcode> : Encoding16 {
  1201. let Inst{15-12} = 0b1011;
  1202. let Inst{11-5} = opcode;
  1203. }
  1204. // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
  1205. class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
  1206. InstrItinClass itin,
  1207. string opc, string asm, string cstr, list<dag> pattern>
  1208. : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1209. let OutOperandList = oops;
  1210. let InOperandList = !con(iops, (ins pred:$p));
  1211. let AsmString = !strconcat(opc, "${p}", asm);
  1212. let Pattern = pattern;
  1213. list<Predicate> Predicates = [IsThumb2];
  1214. let DecoderNamespace = "Thumb2";
  1215. }
  1216. // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
  1217. // input operand since by default it's a zero register. It will become an
  1218. // implicit def once it's "flipped".
  1219. //
  1220. // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
  1221. // more consistent.
  1222. class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
  1223. InstrItinClass itin,
  1224. string opc, string asm, string cstr, list<dag> pattern>
  1225. : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1226. bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
  1227. let Inst{20} = s;
  1228. let OutOperandList = oops;
  1229. let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
  1230. let AsmString = !strconcat(opc, "${s}${p}", asm);
  1231. let Pattern = pattern;
  1232. list<Predicate> Predicates = [IsThumb2];
  1233. let DecoderNamespace = "Thumb2";
  1234. }
  1235. // Special cases
  1236. class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
  1237. InstrItinClass itin,
  1238. string asm, string cstr, list<dag> pattern>
  1239. : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1240. let OutOperandList = oops;
  1241. let InOperandList = iops;
  1242. let AsmString = asm;
  1243. let Pattern = pattern;
  1244. list<Predicate> Predicates = [IsThumb2];
  1245. let DecoderNamespace = "Thumb2";
  1246. }
  1247. class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
  1248. InstrItinClass itin,
  1249. string asm, string cstr, list<dag> pattern>
  1250. : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
  1251. let OutOperandList = oops;
  1252. let InOperandList = iops;
  1253. let AsmString = asm;
  1254. let Pattern = pattern;
  1255. list<Predicate> Predicates = [IsThumb, IsThumb1Only];
  1256. let DecoderNamespace = "Thumb";
  1257. }
  1258. class T2I<dag oops, dag iops, InstrItinClass itin,
  1259. string opc, string asm, list<dag> pattern, AddrMode am = AddrModeNone>
  1260. : Thumb2I<oops, iops, am, 4, itin, opc, asm, "", pattern>;
  1261. class T2Ii12<dag oops, dag iops, InstrItinClass itin,
  1262. string opc, string asm, list<dag> pattern>
  1263. : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
  1264. class T2Ii8p<dag oops, dag iops, InstrItinClass itin,
  1265. string opc, string asm, list<dag> pattern>
  1266. : Thumb2I<oops, iops, AddrModeT2_i8pos, 4, itin, opc, asm, "", pattern>;
  1267. class T2Ii8n<dag oops, dag iops, InstrItinClass itin,
  1268. string opc, string asm, list<dag> pattern>
  1269. : Thumb2I<oops, iops, AddrModeT2_i8neg, 4, itin, opc, asm, "", pattern>;
  1270. class T2Iso<dag oops, dag iops, InstrItinClass itin,
  1271. string opc, string asm, list<dag> pattern>
  1272. : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
  1273. class T2Ipc<dag oops, dag iops, InstrItinClass itin,
  1274. string opc, string asm, list<dag> pattern>
  1275. : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
  1276. class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
  1277. string opc, string asm, string cstr, list<dag> pattern>
  1278. : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
  1279. pattern> {
  1280. bits<4> Rt;
  1281. bits<4> Rt2;
  1282. bits<13> addr;
  1283. let Inst{31-25} = 0b1110100;
  1284. let Inst{24} = P;
  1285. let Inst{23} = addr{8};
  1286. let Inst{22} = 1;
  1287. let Inst{21} = W;
  1288. let Inst{20} = isLoad;
  1289. let Inst{19-16} = addr{12-9};
  1290. let Inst{15-12} = Rt{3-0};
  1291. let Inst{11-8} = Rt2{3-0};
  1292. let Inst{7-0} = addr{7-0};
  1293. }
  1294. class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
  1295. InstrItinClass itin, string opc, string asm, string cstr,
  1296. list<dag> pattern>
  1297. : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
  1298. pattern> {
  1299. bits<4> Rt;
  1300. bits<4> Rt2;
  1301. bits<4> addr;
  1302. bits<9> imm;
  1303. let Inst{31-25} = 0b1110100;
  1304. let Inst{24} = P;
  1305. let Inst{23} = imm{8};
  1306. let Inst{22} = 1;
  1307. let Inst{21} = W;
  1308. let Inst{20} = isLoad;
  1309. let Inst{19-16} = addr;
  1310. let Inst{15-12} = Rt{3-0};
  1311. let Inst{11-8} = Rt2{3-0};
  1312. let Inst{7-0} = imm{7-0};
  1313. }
  1314. class T2sI<dag oops, dag iops, InstrItinClass itin,
  1315. string opc, string asm, list<dag> pattern>
  1316. : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
  1317. class T2XI<dag oops, dag iops, InstrItinClass itin,
  1318. string asm, list<dag> pattern>
  1319. : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
  1320. class T2JTI<dag oops, dag iops, InstrItinClass itin,
  1321. string asm, list<dag> pattern>
  1322. : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
  1323. // Move to/from coprocessor instructions
  1324. class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
  1325. list<dag> pattern>
  1326. : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
  1327. let Inst{31-28} = opc;
  1328. }
  1329. // Two-address instructions
  1330. class T2XIt<dag oops, dag iops, InstrItinClass itin,
  1331. string asm, string cstr, list<dag> pattern>
  1332. : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
  1333. // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
  1334. class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
  1335. dag oops, dag iops,
  1336. AddrMode am, IndexMode im, InstrItinClass itin,
  1337. string opc, string asm, string cstr, list<dag> pattern>
  1338. : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
  1339. let OutOperandList = oops;
  1340. let InOperandList = !con(iops, (ins pred:$p));
  1341. let AsmString = !strconcat(opc, "${p}", asm);
  1342. let Pattern = pattern;
  1343. list<Predicate> Predicates = [IsThumb2];
  1344. let DecoderNamespace = "Thumb2";
  1345. bits<4> Rt;
  1346. bits<13> addr;
  1347. let Inst{31-27} = 0b11111;
  1348. let Inst{26-25} = 0b00;
  1349. let Inst{24} = signed;
  1350. let Inst{23} = 0;
  1351. let Inst{22-21} = opcod;
  1352. let Inst{20} = load;
  1353. let Inst{19-16} = addr{12-9};
  1354. let Inst{15-12} = Rt{3-0};
  1355. let Inst{11} = 1;
  1356. // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
  1357. let Inst{10} = pre; // The P bit.
  1358. let Inst{9} = addr{8}; // Sign bit
  1359. let Inst{8} = 1; // The W bit.
  1360. let Inst{7-0} = addr{7-0};
  1361. let DecoderMethod = "DecodeT2LdStPre";
  1362. }
  1363. // T2Ipostldst - Thumb2 post-indexed load / store instructions.
  1364. class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
  1365. dag oops, dag iops,
  1366. AddrMode am, IndexMode im, InstrItinClass itin,
  1367. string opc, string asm, string cstr, list<dag> pattern>
  1368. : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
  1369. let OutOperandList = oops;
  1370. let InOperandList = !con(iops, (ins pred:$p));
  1371. let AsmString = !strconcat(opc, "${p}", asm);
  1372. let Pattern = pattern;
  1373. list<Predicate> Predicates = [IsThumb2];
  1374. let DecoderNamespace = "Thumb2";
  1375. bits<4> Rt;
  1376. bits<4> Rn;
  1377. bits<9> offset;
  1378. let Inst{31-27} = 0b11111;
  1379. let Inst{26-25} = 0b00;
  1380. let Inst{24} = signed;
  1381. let Inst{23} = 0;
  1382. let Inst{22-21} = opcod;
  1383. let Inst{20} = load;
  1384. let Inst{19-16} = Rn;
  1385. let Inst{15-12} = Rt{3-0};
  1386. let Inst{11} = 1;
  1387. // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
  1388. let Inst{10} = pre; // The P bit.
  1389. let Inst{9} = offset{8}; // Sign bit
  1390. let Inst{8} = 1; // The W bit.
  1391. let Inst{7-0} = offset{7-0};
  1392. let DecoderMethod = "DecodeT2LdStPre";
  1393. }
  1394. // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
  1395. class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
  1396. list<Predicate> Predicates = [IsThumb, IsThumb1Only];
  1397. }
  1398. // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
  1399. class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
  1400. list<Predicate> Predicates = [IsThumb2, HasV6T2];
  1401. }
  1402. // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
  1403. class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
  1404. list<Predicate> Predicates = [IsThumb2];
  1405. }
  1406. //===----------------------------------------------------------------------===//
  1407. //===----------------------------------------------------------------------===//
  1408. // ARM VFP Instruction templates.
  1409. //
  1410. // Almost all VFP instructions are predicable.
  1411. class VFPI<dag oops, dag iops, AddrMode am, int sz,
  1412. IndexMode im, Format f, InstrItinClass itin,
  1413. string opc, string asm, string cstr, list<dag> pattern>
  1414. : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
  1415. bits<4> p;
  1416. let Inst{31-28} = p;
  1417. let OutOperandList = oops;
  1418. let InOperandList = !con(iops, (ins pred:$p));
  1419. let AsmString = !strconcat(opc, "${p}", asm);
  1420. let Pattern = pattern;
  1421. let PostEncoderMethod = "VFPThumb2PostEncoder";
  1422. let DecoderNamespace = "VFP";
  1423. list<Predicate> Predicates = [HasVFP2];
  1424. }
  1425. // Special cases
  1426. class VFPXI<dag oops, dag iops, AddrMode am, int sz,
  1427. IndexMode im, Format f, InstrItinClass itin,
  1428. string asm, string cstr, list<dag> pattern>
  1429. : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
  1430. bits<4> p;
  1431. let Inst{31-28} = p;
  1432. let OutOperandList = oops;
  1433. let InOperandList = iops;
  1434. let AsmString = asm;
  1435. let Pattern = pattern;
  1436. let PostEncoderMethod = "VFPThumb2PostEncoder";
  1437. let DecoderNamespace = "VFP";
  1438. list<Predicate> Predicates = [HasVFP2];
  1439. }
  1440. class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
  1441. string opc, string asm, list<dag> pattern>
  1442. : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
  1443. opc, asm, "", pattern> {
  1444. let PostEncoderMethod = "VFPThumb2PostEncoder";
  1445. }
  1446. // ARM VFP addrmode5 loads and stores
  1447. class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
  1448. InstrItinClass itin,
  1449. string opc, string asm, list<dag> pattern>
  1450. : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
  1451. VFPLdStFrm, itin, opc, asm, "", pattern> {
  1452. // Instruction operands.
  1453. bits<5> Dd;
  1454. bits<13> addr;
  1455. // Encode instruction operands.
  1456. let Inst{23} = addr{8}; // U (add = (U == '1'))
  1457. let Inst{22} = Dd{4};
  1458. let Inst{19-16} = addr{12-9}; // Rn
  1459. let Inst{15-12} = Dd{3-0};
  1460. let Inst{7-0} = addr{7-0}; // imm8
  1461. let Inst{27-24} = opcod1;
  1462. let Inst{21-20} = opcod2;
  1463. let Inst{11-9} = 0b101;
  1464. let Inst{8} = 1; // Double precision
  1465. // Loads & stores operate on both NEON and VFP pipelines.
  1466. let D = VFPNeonDomain;
  1467. }
  1468. class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
  1469. InstrItinClass itin,
  1470. string opc, string asm, list<dag> pattern>
  1471. : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
  1472. VFPLdStFrm, itin, opc, asm, "", pattern> {
  1473. // Instruction operands.
  1474. bits<5> Sd;
  1475. bits<13> addr;
  1476. // Encode instruction operands.
  1477. let Inst{23} = addr{8}; // U (add = (U == '1'))
  1478. let Inst{22} = Sd{0};
  1479. let Inst{19-16} = addr{12-9}; // Rn
  1480. let Inst{15-12} = Sd{4-1};
  1481. let Inst{7-0} = addr{7-0}; // imm8
  1482. let Inst{27-24} = opcod1;
  1483. let Inst{21-20} = opcod2;
  1484. let Inst{11-9} = 0b101;
  1485. let Inst{8} = 0; // Single precision
  1486. // Loads & stores operate on both NEON and VFP pipelines.
  1487. let D = VFPNeonDomain;
  1488. }
  1489. class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
  1490. InstrItinClass itin,
  1491. string opc, string asm, list<dag> pattern>
  1492. : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
  1493. VFPLdStFrm, itin, opc, asm, "", pattern> {
  1494. list<Predicate> Predicates = [HasFullFP16];
  1495. // Instruction operands.
  1496. bits<5> Sd;
  1497. bits<13> addr;
  1498. // Encode instruction operands.
  1499. let Inst{23} = addr{8}; // U (add = (U == '1'))
  1500. let Inst{22} = Sd{0};
  1501. let Inst{19-16} = addr{12-9}; // Rn
  1502. let Inst{15-12} = Sd{4-1};
  1503. let Inst{7-0} = addr{7-0}; // imm8
  1504. let Inst{27-24} = opcod1;
  1505. let Inst{21-20} = opcod2;
  1506. let Inst{11-8} = 0b1001; // Half precision
  1507. // Loads & stores operate on both NEON and VFP pipelines.
  1508. let D = VFPNeonDomain;
  1509. let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
  1510. }
  1511. // VFP Load / store multiple pseudo instructions.
  1512. class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
  1513. list<dag> pattern>
  1514. : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
  1515. cstr, itin> {
  1516. let OutOperandList = oops;
  1517. let InOperandList = !con(iops, (ins pred:$p));
  1518. let Pattern = pattern;
  1519. list<Predicate> Predicates = [HasVFP2];
  1520. }
  1521. // Load / store multiple
  1522. // Unknown precision
  1523. class AXXI4<dag oops, dag iops, IndexMode im,
  1524. string asm, string cstr, list<dag> pattern>
  1525. : VFPXI<oops, iops, AddrMode4, 4, im,
  1526. VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
  1527. // Instruction operands.
  1528. bits<4> Rn;
  1529. bits<13> regs;
  1530. // Encode instruction operands.
  1531. let Inst{19-16} = Rn;
  1532. let Inst{22} = 0;
  1533. let Inst{15-12} = regs{11-8};
  1534. let Inst{7-1} = regs{7-1};
  1535. let Inst{27-25} = 0b110;
  1536. let Inst{11-8} = 0b1011;
  1537. let Inst{0} = 1;
  1538. }
  1539. // Double precision
  1540. class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
  1541. string asm, string cstr, list<dag> pattern>
  1542. : VFPXI<oops, iops, AddrMode4, 4, im,
  1543. VFPLdStMulFrm, itin, asm, cstr, pattern> {
  1544. // Instruction operands.
  1545. bits<4> Rn;
  1546. bits<13> regs;
  1547. // Encode instruction operands.
  1548. let Inst{19-16} = Rn;
  1549. let Inst{22} = regs{12};
  1550. let Inst{15-12} = regs{11-8};
  1551. let Inst{7-1} = regs{7-1};
  1552. let Inst{27-25} = 0b110;
  1553. let Inst{11-9} = 0b101;
  1554. let Inst{8} = 1; // Double precision
  1555. let Inst{0} = 0;
  1556. }
  1557. // Single Precision
  1558. class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
  1559. string asm, string cstr, list<dag> pattern>
  1560. : VFPXI<oops, iops, AddrMode4, 4, im,
  1561. VFPLdStMulFrm, itin, asm, cstr, pattern> {
  1562. // Instruction operands.
  1563. bits<4> Rn;
  1564. bits<13> regs;
  1565. // Encode instruction operands.
  1566. let Inst{19-16} = Rn;
  1567. let Inst{22} = regs{8};
  1568. let Inst{15-12} = regs{12-9};
  1569. let Inst{7-0} = regs{7-0};
  1570. let Inst{27-25} = 0b110;
  1571. let Inst{11-9} = 0b101;
  1572. let Inst{8} = 0; // Single precision
  1573. }
  1574. // Double precision, unary
  1575. class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1576. bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
  1577. string asm, list<dag> pattern>
  1578. : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
  1579. // Instruction operands.
  1580. bits<5> Dd;
  1581. bits<5> Dm;
  1582. // Encode instruction operands.
  1583. let Inst{3-0} = Dm{3-0};
  1584. let Inst{5} = Dm{4};
  1585. let Inst{15-12} = Dd{3-0};
  1586. let Inst{22} = Dd{4};
  1587. let Inst{27-23} = opcod1;
  1588. let Inst{21-20} = opcod2;
  1589. let Inst{19-16} = opcod3;
  1590. let Inst{11-9} = 0b101;
  1591. let Inst{8} = 1; // Double precision
  1592. let Inst{7-6} = opcod4;
  1593. let Inst{4} = opcod5;
  1594. let Predicates = [HasVFP2, HasDPVFP];
  1595. }
  1596. // Double precision, unary, not-predicated
  1597. class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1598. bit opcod5, dag oops, dag iops, InstrItinClass itin,
  1599. string asm, list<dag> pattern>
  1600. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
  1601. // Instruction operands.
  1602. bits<5> Dd;
  1603. bits<5> Dm;
  1604. let Inst{31-28} = 0b1111;
  1605. // Encode instruction operands.
  1606. let Inst{3-0} = Dm{3-0};
  1607. let Inst{5} = Dm{4};
  1608. let Inst{15-12} = Dd{3-0};
  1609. let Inst{22} = Dd{4};
  1610. let Inst{27-23} = opcod1;
  1611. let Inst{21-20} = opcod2;
  1612. let Inst{19-16} = opcod3;
  1613. let Inst{11-9} = 0b101;
  1614. let Inst{8} = 1; // Double precision
  1615. let Inst{7-6} = opcod4;
  1616. let Inst{4} = opcod5;
  1617. }
  1618. // Double precision, binary
  1619. class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
  1620. dag iops, InstrItinClass itin, string opc, string asm,
  1621. list<dag> pattern>
  1622. : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
  1623. // Instruction operands.
  1624. bits<5> Dd;
  1625. bits<5> Dn;
  1626. bits<5> Dm;
  1627. // Encode instruction operands.
  1628. let Inst{3-0} = Dm{3-0};
  1629. let Inst{5} = Dm{4};
  1630. let Inst{19-16} = Dn{3-0};
  1631. let Inst{7} = Dn{4};
  1632. let Inst{15-12} = Dd{3-0};
  1633. let Inst{22} = Dd{4};
  1634. let Inst{27-23} = opcod1;
  1635. let Inst{21-20} = opcod2;
  1636. let Inst{11-9} = 0b101;
  1637. let Inst{8} = 1; // Double precision
  1638. let Inst{6} = op6;
  1639. let Inst{4} = op4;
  1640. let Predicates = [HasVFP2, HasDPVFP];
  1641. }
  1642. // FP, binary, not predicated
  1643. class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
  1644. InstrItinClass itin, string asm, list<dag> pattern>
  1645. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
  1646. asm, "", pattern>
  1647. {
  1648. // Instruction operands.
  1649. bits<5> Dd;
  1650. bits<5> Dn;
  1651. bits<5> Dm;
  1652. let Inst{31-28} = 0b1111;
  1653. // Encode instruction operands.
  1654. let Inst{3-0} = Dm{3-0};
  1655. let Inst{5} = Dm{4};
  1656. let Inst{19-16} = Dn{3-0};
  1657. let Inst{7} = Dn{4};
  1658. let Inst{15-12} = Dd{3-0};
  1659. let Inst{22} = Dd{4};
  1660. let Inst{27-23} = opcod1;
  1661. let Inst{21-20} = opcod2;
  1662. let Inst{11-9} = 0b101;
  1663. let Inst{8} = 1; // double precision
  1664. let Inst{6} = opcod3;
  1665. let Inst{4} = 0;
  1666. let Predicates = [HasVFP2, HasDPVFP];
  1667. }
  1668. // Single precision, unary, predicated
  1669. class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1670. bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
  1671. string asm, list<dag> pattern>
  1672. : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
  1673. // Instruction operands.
  1674. bits<5> Sd;
  1675. bits<5> Sm;
  1676. // Encode instruction operands.
  1677. let Inst{3-0} = Sm{4-1};
  1678. let Inst{5} = Sm{0};
  1679. let Inst{15-12} = Sd{4-1};
  1680. let Inst{22} = Sd{0};
  1681. let Inst{27-23} = opcod1;
  1682. let Inst{21-20} = opcod2;
  1683. let Inst{19-16} = opcod3;
  1684. let Inst{11-9} = 0b101;
  1685. let Inst{8} = 0; // Single precision
  1686. let Inst{7-6} = opcod4;
  1687. let Inst{4} = opcod5;
  1688. }
  1689. // Single precision, unary, non-predicated
  1690. class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1691. bit opcod5, dag oops, dag iops, InstrItinClass itin,
  1692. string asm, list<dag> pattern>
  1693. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
  1694. VFPUnaryFrm, itin, asm, "", pattern> {
  1695. // Instruction operands.
  1696. bits<5> Sd;
  1697. bits<5> Sm;
  1698. let Inst{31-28} = 0b1111;
  1699. // Encode instruction operands.
  1700. let Inst{3-0} = Sm{4-1};
  1701. let Inst{5} = Sm{0};
  1702. let Inst{15-12} = Sd{4-1};
  1703. let Inst{22} = Sd{0};
  1704. let Inst{27-23} = opcod1;
  1705. let Inst{21-20} = opcod2;
  1706. let Inst{19-16} = opcod3;
  1707. let Inst{11-9} = 0b101;
  1708. let Inst{8} = 0; // Single precision
  1709. let Inst{7-6} = opcod4;
  1710. let Inst{4} = opcod5;
  1711. }
  1712. // Single precision unary, if no NEON. Same as ASuI except not available if
  1713. // NEON is enabled.
  1714. class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1715. bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
  1716. string asm, list<dag> pattern>
  1717. : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
  1718. pattern> {
  1719. list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
  1720. }
  1721. // Single precision, binary
  1722. class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
  1723. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1724. : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
  1725. // Instruction operands.
  1726. bits<5> Sd;
  1727. bits<5> Sn;
  1728. bits<5> Sm;
  1729. // Encode instruction operands.
  1730. let Inst{3-0} = Sm{4-1};
  1731. let Inst{5} = Sm{0};
  1732. let Inst{19-16} = Sn{4-1};
  1733. let Inst{7} = Sn{0};
  1734. let Inst{15-12} = Sd{4-1};
  1735. let Inst{22} = Sd{0};
  1736. let Inst{27-23} = opcod1;
  1737. let Inst{21-20} = opcod2;
  1738. let Inst{11-9} = 0b101;
  1739. let Inst{8} = 0; // Single precision
  1740. let Inst{6} = op6;
  1741. let Inst{4} = op4;
  1742. }
  1743. // Single precision, binary, not predicated
  1744. class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
  1745. InstrItinClass itin, string asm, list<dag> pattern>
  1746. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
  1747. VFPBinaryFrm, itin, asm, "", pattern>
  1748. {
  1749. // Instruction operands.
  1750. bits<5> Sd;
  1751. bits<5> Sn;
  1752. bits<5> Sm;
  1753. let Inst{31-28} = 0b1111;
  1754. // Encode instruction operands.
  1755. let Inst{3-0} = Sm{4-1};
  1756. let Inst{5} = Sm{0};
  1757. let Inst{19-16} = Sn{4-1};
  1758. let Inst{7} = Sn{0};
  1759. let Inst{15-12} = Sd{4-1};
  1760. let Inst{22} = Sd{0};
  1761. let Inst{27-23} = opcod1;
  1762. let Inst{21-20} = opcod2;
  1763. let Inst{11-9} = 0b101;
  1764. let Inst{8} = 0; // Single precision
  1765. let Inst{6} = opcod3;
  1766. let Inst{4} = 0;
  1767. }
  1768. // Single precision binary, if no NEON. Same as ASbI except not available if
  1769. // NEON is enabled.
  1770. class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
  1771. dag iops, InstrItinClass itin, string opc, string asm,
  1772. list<dag> pattern>
  1773. : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
  1774. list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
  1775. // Instruction operands.
  1776. bits<5> Sd;
  1777. bits<5> Sn;
  1778. bits<5> Sm;
  1779. // Encode instruction operands.
  1780. let Inst{3-0} = Sm{4-1};
  1781. let Inst{5} = Sm{0};
  1782. let Inst{19-16} = Sn{4-1};
  1783. let Inst{7} = Sn{0};
  1784. let Inst{15-12} = Sd{4-1};
  1785. let Inst{22} = Sd{0};
  1786. }
  1787. // Half precision, unary, predicated
  1788. class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1789. bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
  1790. string asm, list<dag> pattern>
  1791. : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
  1792. list<Predicate> Predicates = [HasFullFP16];
  1793. // Instruction operands.
  1794. bits<5> Sd;
  1795. bits<5> Sm;
  1796. // Encode instruction operands.
  1797. let Inst{3-0} = Sm{4-1};
  1798. let Inst{5} = Sm{0};
  1799. let Inst{15-12} = Sd{4-1};
  1800. let Inst{22} = Sd{0};
  1801. let Inst{27-23} = opcod1;
  1802. let Inst{21-20} = opcod2;
  1803. let Inst{19-16} = opcod3;
  1804. let Inst{11-8} = 0b1001; // Half precision
  1805. let Inst{7-6} = opcod4;
  1806. let Inst{4} = opcod5;
  1807. let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
  1808. }
  1809. // Half precision, unary, non-predicated
  1810. class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
  1811. bit opcod5, dag oops, dag iops, InstrItinClass itin,
  1812. string asm, list<dag> pattern>
  1813. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
  1814. VFPUnaryFrm, itin, asm, "", pattern> {
  1815. list<Predicate> Predicates = [HasFullFP16];
  1816. // Instruction operands.
  1817. bits<5> Sd;
  1818. bits<5> Sm;
  1819. let Inst{31-28} = 0b1111;
  1820. // Encode instruction operands.
  1821. let Inst{3-0} = Sm{4-1};
  1822. let Inst{5} = Sm{0};
  1823. let Inst{15-12} = Sd{4-1};
  1824. let Inst{22} = Sd{0};
  1825. let Inst{27-23} = opcod1;
  1826. let Inst{21-20} = opcod2;
  1827. let Inst{19-16} = opcod3;
  1828. let Inst{11-8} = 0b1001; // Half precision
  1829. let Inst{7-6} = opcod4;
  1830. let Inst{4} = opcod5;
  1831. let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
  1832. }
  1833. // Half precision, binary
  1834. class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
  1835. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1836. : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
  1837. list<Predicate> Predicates = [HasFullFP16];
  1838. // Instruction operands.
  1839. bits<5> Sd;
  1840. bits<5> Sn;
  1841. bits<5> Sm;
  1842. // Encode instruction operands.
  1843. let Inst{3-0} = Sm{4-1};
  1844. let Inst{5} = Sm{0};
  1845. let Inst{19-16} = Sn{4-1};
  1846. let Inst{7} = Sn{0};
  1847. let Inst{15-12} = Sd{4-1};
  1848. let Inst{22} = Sd{0};
  1849. let Inst{27-23} = opcod1;
  1850. let Inst{21-20} = opcod2;
  1851. let Inst{11-8} = 0b1001; // Half precision
  1852. let Inst{6} = op6;
  1853. let Inst{4} = op4;
  1854. let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
  1855. }
  1856. // Half precision, binary, not predicated
  1857. class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
  1858. InstrItinClass itin, string asm, list<dag> pattern>
  1859. : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
  1860. VFPBinaryFrm, itin, asm, "", pattern> {
  1861. list<Predicate> Predicates = [HasFullFP16];
  1862. // Instruction operands.
  1863. bits<5> Sd;
  1864. bits<5> Sn;
  1865. bits<5> Sm;
  1866. let Inst{31-28} = 0b1111;
  1867. // Encode instruction operands.
  1868. let Inst{3-0} = Sm{4-1};
  1869. let Inst{5} = Sm{0};
  1870. let Inst{19-16} = Sn{4-1};
  1871. let Inst{7} = Sn{0};
  1872. let Inst{15-12} = Sd{4-1};
  1873. let Inst{22} = Sd{0};
  1874. let Inst{27-23} = opcod1;
  1875. let Inst{21-20} = opcod2;
  1876. let Inst{11-8} = 0b1001; // Half precision
  1877. let Inst{6} = opcod3;
  1878. let Inst{4} = 0;
  1879. let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
  1880. }
  1881. // VFP conversion instructions
  1882. class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
  1883. dag oops, dag iops, InstrItinClass itin, string opc, string asm,
  1884. list<dag> pattern>
  1885. : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
  1886. let Inst{27-23} = opcod1;
  1887. let Inst{21-20} = opcod2;
  1888. let Inst{19-16} = opcod3;
  1889. let Inst{11-8} = opcod4;
  1890. let Inst{6} = 1;
  1891. let Inst{4} = 0;
  1892. }
  1893. // VFP conversion between floating-point and fixed-point
  1894. class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
  1895. dag oops, dag iops, InstrItinClass itin, string opc, string asm,
  1896. list<dag> pattern>
  1897. : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
  1898. bits<5> fbits;
  1899. // size (fixed-point number): sx == 0 ? 16 : 32
  1900. let Inst{7} = op5; // sx
  1901. let Inst{5} = fbits{0};
  1902. let Inst{3-0} = fbits{4-1};
  1903. }
  1904. // VFP conversion instructions, if no NEON
  1905. class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
  1906. dag oops, dag iops, InstrItinClass itin,
  1907. string opc, string asm, list<dag> pattern>
  1908. : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
  1909. pattern> {
  1910. list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
  1911. }
  1912. class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
  1913. InstrItinClass itin,
  1914. string opc, string asm, list<dag> pattern>
  1915. : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
  1916. let Inst{27-20} = opcod1;
  1917. let Inst{11-8} = opcod2;
  1918. let Inst{4} = 1;
  1919. }
  1920. class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
  1921. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1922. : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
  1923. class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
  1924. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1925. : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
  1926. class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
  1927. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1928. : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
  1929. class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
  1930. InstrItinClass itin, string opc, string asm, list<dag> pattern>
  1931. : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
  1932. //===----------------------------------------------------------------------===//
  1933. //===----------------------------------------------------------------------===//
  1934. // ARM NEON Instruction templates.
  1935. //
  1936. class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
  1937. InstrItinClass itin, string opc, string dt, string asm, string cstr,
  1938. list<dag> pattern>
  1939. : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
  1940. let OutOperandList = oops;
  1941. let InOperandList = !con(iops, (ins pred:$p));
  1942. let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
  1943. let Pattern = pattern;
  1944. list<Predicate> Predicates = [HasNEON];
  1945. let DecoderNamespace = "NEON";
  1946. }
  1947. // Same as NeonI except it does not have a "data type" specifier.
  1948. class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
  1949. InstrItinClass itin, string opc, string asm, string cstr,
  1950. list<dag> pattern>
  1951. : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
  1952. let OutOperandList = oops;
  1953. let InOperandList = !con(iops, (ins pred:$p));
  1954. let AsmString = !strconcat(opc, "${p}", "\t", asm);
  1955. let Pattern = pattern;
  1956. list<Predicate> Predicates = [HasNEON];
  1957. let DecoderNamespace = "NEON";
  1958. }
  1959. // Same as NeonI except it is not predicated
  1960. class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
  1961. InstrItinClass itin, string opc, string dt, string asm, string cstr,
  1962. list<dag> pattern>
  1963. : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
  1964. let OutOperandList = oops;
  1965. let InOperandList = iops;
  1966. let AsmString = !strconcat(opc, ".", dt, "\t", asm);
  1967. let Pattern = pattern;
  1968. list<Predicate> Predicates = [HasNEON];
  1969. let DecoderNamespace = "NEON";
  1970. let Inst{31-28} = 0b1111;
  1971. }
  1972. class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
  1973. dag oops, dag iops, InstrItinClass itin,
  1974. string opc, string dt, string asm, string cstr, list<dag> pattern>
  1975. : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
  1976. cstr, pattern> {
  1977. let Inst{31-24} = 0b11110100;
  1978. let Inst{23} = op23;
  1979. let Inst{21-20} = op21_20;
  1980. let Inst{11-8} = op11_8;
  1981. let Inst{7-4} = op7_4;
  1982. let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
  1983. let DecoderNamespace = "NEONLoadStore";
  1984. bits<5> Vd;
  1985. bits<6> Rn;
  1986. bits<4> Rm;
  1987. let Inst{22} = Vd{4};
  1988. let Inst{15-12} = Vd{3-0};
  1989. let Inst{19-16} = Rn{3-0};
  1990. let Inst{3-0} = Rm{3-0};
  1991. }
  1992. class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
  1993. dag oops, dag iops, InstrItinClass itin,
  1994. string opc, string dt, string asm, string cstr, list<dag> pattern>
  1995. : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
  1996. dt, asm, cstr, pattern> {
  1997. bits<3> lane;
  1998. }
  1999. class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
  2000. : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
  2001. itin> {
  2002. let OutOperandList = oops;
  2003. let InOperandList = !con(iops, (ins pred:$p));
  2004. list<Predicate> Predicates = [HasNEON];
  2005. }
  2006. class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
  2007. list<dag> pattern>
  2008. : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
  2009. itin> {
  2010. let OutOperandList = oops;
  2011. let InOperandList = !con(iops, (ins pred:$p));
  2012. let Pattern = pattern;
  2013. list<Predicate> Predicates = [HasNEON];
  2014. }
  2015. class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
  2016. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2017. : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
  2018. pattern> {
  2019. let Inst{31-25} = 0b1111001;
  2020. let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
  2021. let DecoderNamespace = "NEONData";
  2022. }
  2023. class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
  2024. string opc, string asm, string cstr, list<dag> pattern>
  2025. : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
  2026. cstr, pattern> {
  2027. let Inst{31-25} = 0b1111001;
  2028. let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
  2029. let DecoderNamespace = "NEONData";
  2030. }
  2031. // NEON "one register and a modified immediate" format.
  2032. class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
  2033. bit op5, bit op4,
  2034. dag oops, dag iops, InstrItinClass itin,
  2035. string opc, string dt, string asm, string cstr,
  2036. list<dag> pattern>
  2037. : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
  2038. let Inst{23} = op23;
  2039. let Inst{21-19} = op21_19;
  2040. let Inst{11-8} = op11_8;
  2041. let Inst{7} = op7;
  2042. let Inst{6} = op6;
  2043. let Inst{5} = op5;
  2044. let Inst{4} = op4;
  2045. // Instruction operands.
  2046. bits<5> Vd;
  2047. bits<13> SIMM;
  2048. let Inst{15-12} = Vd{3-0};
  2049. let Inst{22} = Vd{4};
  2050. let Inst{24} = SIMM{7};
  2051. let Inst{18-16} = SIMM{6-4};
  2052. let Inst{3-0} = SIMM{3-0};
  2053. let DecoderMethod = "DecodeVMOVModImmInstruction";
  2054. }
  2055. // NEON 2 vector register format.
  2056. class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
  2057. bits<5> op11_7, bit op6, bit op4,
  2058. dag oops, dag iops, InstrItinClass itin,
  2059. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2060. : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
  2061. let Inst{24-23} = op24_23;
  2062. let Inst{21-20} = op21_20;
  2063. let Inst{19-18} = op19_18;
  2064. let Inst{17-16} = op17_16;
  2065. let Inst{11-7} = op11_7;
  2066. let Inst{6} = op6;
  2067. let Inst{4} = op4;
  2068. // Instruction operands.
  2069. bits<5> Vd;
  2070. bits<5> Vm;
  2071. let Inst{15-12} = Vd{3-0};
  2072. let Inst{22} = Vd{4};
  2073. let Inst{3-0} = Vm{3-0};
  2074. let Inst{5} = Vm{4};
  2075. }
  2076. // Same as N2V but not predicated.
  2077. class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
  2078. dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
  2079. string Dt, list<dag> pattern>
  2080. : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
  2081. OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
  2082. bits<5> Vd;
  2083. bits<5> Vm;
  2084. // Encode instruction operands
  2085. let Inst{22} = Vd{4};
  2086. let Inst{15-12} = Vd{3-0};
  2087. let Inst{5} = Vm{4};
  2088. let Inst{3-0} = Vm{3-0};
  2089. // Encode constant bits
  2090. let Inst{27-23} = 0b00111;
  2091. let Inst{21-20} = 0b11;
  2092. let Inst{19-18} = op19_18;
  2093. let Inst{17-16} = op17_16;
  2094. let Inst{11} = 0;
  2095. let Inst{10-8} = op10_8;
  2096. let Inst{7} = op7;
  2097. let Inst{6} = op6;
  2098. let Inst{4} = 0;
  2099. let DecoderNamespace = "NEON";
  2100. }
  2101. // Same as N2V except it doesn't have a datatype suffix.
  2102. class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
  2103. bits<5> op11_7, bit op6, bit op4,
  2104. dag oops, dag iops, InstrItinClass itin,
  2105. string opc, string asm, string cstr, list<dag> pattern>
  2106. : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
  2107. let Inst{24-23} = op24_23;
  2108. let Inst{21-20} = op21_20;
  2109. let Inst{19-18} = op19_18;
  2110. let Inst{17-16} = op17_16;
  2111. let Inst{11-7} = op11_7;
  2112. let Inst{6} = op6;
  2113. let Inst{4} = op4;
  2114. // Instruction operands.
  2115. bits<5> Vd;
  2116. bits<5> Vm;
  2117. let Inst{15-12} = Vd{3-0};
  2118. let Inst{22} = Vd{4};
  2119. let Inst{3-0} = Vm{3-0};
  2120. let Inst{5} = Vm{4};
  2121. }
  2122. // NEON 2 vector register with immediate.
  2123. class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
  2124. dag oops, dag iops, Format f, InstrItinClass itin,
  2125. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2126. : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
  2127. let Inst{24} = op24;
  2128. let Inst{23} = op23;
  2129. let Inst{11-8} = op11_8;
  2130. let Inst{7} = op7;
  2131. let Inst{6} = op6;
  2132. let Inst{4} = op4;
  2133. // Instruction operands.
  2134. bits<5> Vd;
  2135. bits<5> Vm;
  2136. bits<6> SIMM;
  2137. let Inst{15-12} = Vd{3-0};
  2138. let Inst{22} = Vd{4};
  2139. let Inst{3-0} = Vm{3-0};
  2140. let Inst{5} = Vm{4};
  2141. let Inst{21-16} = SIMM{5-0};
  2142. }
  2143. // NEON 3 vector register format.
  2144. class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
  2145. bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
  2146. string opc, string dt, string asm, string cstr,
  2147. list<dag> pattern>
  2148. : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
  2149. let Inst{24} = op24;
  2150. let Inst{23} = op23;
  2151. let Inst{21-20} = op21_20;
  2152. let Inst{11-8} = op11_8;
  2153. let Inst{6} = op6;
  2154. let Inst{4} = op4;
  2155. }
  2156. class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
  2157. dag oops, dag iops, Format f, InstrItinClass itin,
  2158. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2159. : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
  2160. oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
  2161. // Instruction operands.
  2162. bits<5> Vd;
  2163. bits<5> Vn;
  2164. bits<5> Vm;
  2165. let Inst{15-12} = Vd{3-0};
  2166. let Inst{22} = Vd{4};
  2167. let Inst{19-16} = Vn{3-0};
  2168. let Inst{7} = Vn{4};
  2169. let Inst{3-0} = Vm{3-0};
  2170. let Inst{5} = Vm{4};
  2171. }
  2172. class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
  2173. bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
  2174. string OpcodeStr, string Dt, list<dag> pattern>
  2175. : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
  2176. Dt, "$Vd, $Vn, $Vm", "", pattern> {
  2177. bits<5> Vd;
  2178. bits<5> Vn;
  2179. bits<5> Vm;
  2180. // Encode instruction operands
  2181. let Inst{22} = Vd{4};
  2182. let Inst{15-12} = Vd{3-0};
  2183. let Inst{19-16} = Vn{3-0};
  2184. let Inst{7} = Vn{4};
  2185. let Inst{5} = Vm{4};
  2186. let Inst{3-0} = Vm{3-0};
  2187. // Encode constant bits
  2188. let Inst{27-23} = op27_23;
  2189. let Inst{21-20} = op21_20;
  2190. let Inst{11-8} = op11_8;
  2191. let Inst{6} = op6;
  2192. let Inst{4} = op4;
  2193. }
  2194. class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
  2195. bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
  2196. string opc, string dt, string asm, string cstr,
  2197. list<dag> pattern>
  2198. : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
  2199. oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
  2200. // Instruction operands.
  2201. bits<5> Vd;
  2202. bits<5> Vn;
  2203. bits<5> Vm;
  2204. bit lane;
  2205. let Inst{15-12} = Vd{3-0};
  2206. let Inst{22} = Vd{4};
  2207. let Inst{19-16} = Vn{3-0};
  2208. let Inst{7} = Vn{4};
  2209. let Inst{3-0} = Vm{3-0};
  2210. let Inst{5} = lane;
  2211. }
  2212. class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
  2213. bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
  2214. string opc, string dt, string asm, string cstr,
  2215. list<dag> pattern>
  2216. : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
  2217. oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
  2218. // Instruction operands.
  2219. bits<5> Vd;
  2220. bits<5> Vn;
  2221. bits<5> Vm;
  2222. bits<2> lane;
  2223. let Inst{15-12} = Vd{3-0};
  2224. let Inst{22} = Vd{4};
  2225. let Inst{19-16} = Vn{3-0};
  2226. let Inst{7} = Vn{4};
  2227. let Inst{2-0} = Vm{2-0};
  2228. let Inst{5} = lane{1};
  2229. let Inst{3} = lane{0};
  2230. }
  2231. // Same as N3V except it doesn't have a data type suffix.
  2232. class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
  2233. bit op4,
  2234. dag oops, dag iops, Format f, InstrItinClass itin,
  2235. string opc, string asm, string cstr, list<dag> pattern>
  2236. : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
  2237. let Inst{24} = op24;
  2238. let Inst{23} = op23;
  2239. let Inst{21-20} = op21_20;
  2240. let Inst{11-8} = op11_8;
  2241. let Inst{6} = op6;
  2242. let Inst{4} = op4;
  2243. // Instruction operands.
  2244. bits<5> Vd;
  2245. bits<5> Vn;
  2246. bits<5> Vm;
  2247. let Inst{15-12} = Vd{3-0};
  2248. let Inst{22} = Vd{4};
  2249. let Inst{19-16} = Vn{3-0};
  2250. let Inst{7} = Vn{4};
  2251. let Inst{3-0} = Vm{3-0};
  2252. let Inst{5} = Vm{4};
  2253. }
  2254. // NEON VMOVs between scalar and core registers.
  2255. class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
  2256. dag oops, dag iops, Format f, InstrItinClass itin,
  2257. string opc, string dt, string asm, list<dag> pattern>
  2258. : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
  2259. "", itin> {
  2260. let Inst{27-20} = opcod1;
  2261. let Inst{11-8} = opcod2;
  2262. let Inst{6-5} = opcod3;
  2263. let Inst{4} = 1;
  2264. // A8.6.303, A8.6.328, A8.6.329
  2265. let Inst{3-0} = 0b0000;
  2266. let OutOperandList = oops;
  2267. let InOperandList = !con(iops, (ins pred:$p));
  2268. let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
  2269. let Pattern = pattern;
  2270. list<Predicate> Predicates = [HasNEON];
  2271. let PostEncoderMethod = "NEONThumb2DupPostEncoder";
  2272. let DecoderNamespace = "NEONDup";
  2273. bits<5> V;
  2274. bits<4> R;
  2275. bits<4> p;
  2276. bits<4> lane;
  2277. let Inst{31-28} = p{3-0};
  2278. let Inst{7} = V{4};
  2279. let Inst{19-16} = V{3-0};
  2280. let Inst{15-12} = R{3-0};
  2281. }
  2282. class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
  2283. dag oops, dag iops, InstrItinClass itin,
  2284. string opc, string dt, string asm, list<dag> pattern>
  2285. : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
  2286. opc, dt, asm, pattern>;
  2287. class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
  2288. dag oops, dag iops, InstrItinClass itin,
  2289. string opc, string dt, string asm, list<dag> pattern>
  2290. : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
  2291. opc, dt, asm, pattern>;
  2292. class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
  2293. dag oops, dag iops, InstrItinClass itin,
  2294. string opc, string dt, string asm, list<dag> pattern>
  2295. : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
  2296. opc, dt, asm, pattern>;
  2297. // Vector Duplicate Lane (from scalar to all elements)
  2298. class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
  2299. InstrItinClass itin, string opc, string dt, string asm,
  2300. list<dag> pattern>
  2301. : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
  2302. let Inst{24-23} = 0b11;
  2303. let Inst{21-20} = 0b11;
  2304. let Inst{19-16} = op19_16;
  2305. let Inst{11-7} = 0b11000;
  2306. let Inst{6} = op6;
  2307. let Inst{4} = 0;
  2308. bits<5> Vd;
  2309. bits<5> Vm;
  2310. let Inst{22} = Vd{4};
  2311. let Inst{15-12} = Vd{3-0};
  2312. let Inst{5} = Vm{4};
  2313. let Inst{3-0} = Vm{3-0};
  2314. }
  2315. // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
  2316. // for single-precision FP.
  2317. class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
  2318. list<Predicate> Predicates = [HasNEON,UseNEONForFP];
  2319. }
  2320. // VFP/NEON Instruction aliases for type suffices.
  2321. // Note: When EmitPriority == 1, the alias will be used for printing
  2322. class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
  2323. InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
  2324. // Note: When EmitPriority == 1, the alias will be used for printing
  2325. multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
  2326. def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
  2327. def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
  2328. def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
  2329. def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
  2330. }
  2331. // Note: When EmitPriority == 1, the alias will be used for printing
  2332. multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
  2333. let Predicates = [HasNEON] in {
  2334. def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
  2335. def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
  2336. def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
  2337. def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
  2338. }
  2339. }
  2340. // The same alias classes using AsmPseudo instead, for the more complex
  2341. // stuff in NEON that InstAlias can't quite handle.
  2342. // Note that we can't use anonymous defm references here like we can
  2343. // above, as we care about the ultimate instruction enum names generated, unlike
  2344. // for instalias defs.
  2345. class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
  2346. AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
  2347. // Extension of NEON 3-vector data processing instructions in coprocessor 8
  2348. // encoding space, introduced in ARMv8.3-A.
  2349. class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
  2350. dag oops, dag iops, InstrItinClass itin,
  2351. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2352. : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
  2353. dt, asm, cstr, pattern> {
  2354. bits<5> Vd;
  2355. bits<5> Vn;
  2356. bits<5> Vm;
  2357. let DecoderNamespace = "VFPV8";
  2358. // These have the same encodings in ARM and Thumb2
  2359. let PostEncoderMethod = "";
  2360. let Inst{31-25} = 0b1111110;
  2361. let Inst{24-23} = op24_23;
  2362. let Inst{22} = Vd{4};
  2363. let Inst{21-20} = op21_20;
  2364. let Inst{19-16} = Vn{3-0};
  2365. let Inst{15-12} = Vd{3-0};
  2366. let Inst{11-8} = 0b1000;
  2367. let Inst{7} = Vn{4};
  2368. let Inst{6} = op6;
  2369. let Inst{5} = Vm{4};
  2370. let Inst{4} = op4;
  2371. let Inst{3-0} = Vm{3-0};
  2372. }
  2373. // Extension of NEON 2-vector-and-scalar data processing instructions in
  2374. // coprocessor 8 encoding space, introduced in ARMv8.3-A.
  2375. class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
  2376. dag oops, dag iops, InstrItinClass itin,
  2377. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2378. : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
  2379. dt, asm, cstr, pattern> {
  2380. bits<5> Vd;
  2381. bits<5> Vn;
  2382. bits<5> Vm;
  2383. let DecoderNamespace = "VFPV8";
  2384. // These have the same encodings in ARM and Thumb2
  2385. let PostEncoderMethod = "";
  2386. let Inst{31-24} = 0b11111110;
  2387. let Inst{23} = op23;
  2388. let Inst{22} = Vd{4};
  2389. let Inst{21-20} = op21_20;
  2390. let Inst{19-16} = Vn{3-0};
  2391. let Inst{15-12} = Vd{3-0};
  2392. let Inst{11-8} = 0b1000;
  2393. let Inst{7} = Vn{4};
  2394. let Inst{6} = op6;
  2395. // Bit 5 set by sub-classes
  2396. let Inst{4} = op4;
  2397. let Inst{3-0} = Vm{3-0};
  2398. }
  2399. // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
  2400. // differently:
  2401. // if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
  2402. // if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
  2403. // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
  2404. class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
  2405. dag oops, dag iops, InstrItinClass itin,
  2406. string opc, string dt, string asm, string cstr, list<dag> pattern>
  2407. : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
  2408. bits<5> Vd;
  2409. bits<5> Vn;
  2410. bits<5> Vm;
  2411. let DecoderNamespace = "VFPV8";
  2412. // These have the same encodings in ARM and Thumb2
  2413. let PostEncoderMethod = "";
  2414. let Inst{31-25} = 0b1111110;
  2415. let Inst{24-23} = op24_23;
  2416. let Inst{22} = Vd{4};
  2417. let Inst{21-20} = op21_20;
  2418. let Inst{19-16} = Vn{4-1};
  2419. let Inst{15-12} = Vd{3-0};
  2420. let Inst{11-8} = 0b1000;
  2421. let Inst{7} = Vn{0};
  2422. let Inst{6} = op6;
  2423. let Inst{5} = Vm{0};
  2424. let Inst{4} = op4;
  2425. let Inst{3-0} = Vm{4-1};
  2426. }
  2427. // Operand types for complex instructions
  2428. class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
  2429. : AsmOperandClass {
  2430. let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
  2431. let DiagnosticString = "complex rotation must be " # Diag;
  2432. let Name = "ComplexRotation" # Type;
  2433. }
  2434. def complexrotateop : Operand<i32> {
  2435. let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
  2436. let PrintMethod = "printComplexRotationOp<90, 0>";
  2437. }
  2438. def complexrotateopodd : Operand<i32> {
  2439. let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
  2440. let PrintMethod = "printComplexRotationOp<180, 90>";
  2441. }
  2442. def MveSaturateOperand : AsmOperandClass {
  2443. let PredicateMethod = "isMveSaturateOp";
  2444. let DiagnosticString = "saturate operand must be 48 or 64";
  2445. let Name = "MveSaturate";
  2446. }
  2447. def saturateop : Operand<i32> {
  2448. let ParserMatchClass = MveSaturateOperand;
  2449. let PrintMethod = "printMveSaturateOp";
  2450. }
  2451. // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
  2452. def : TokenAlias<".s8", ".i8">;
  2453. def : TokenAlias<".u8", ".i8">;
  2454. def : TokenAlias<".s16", ".i16">;
  2455. def : TokenAlias<".u16", ".i16">;
  2456. def : TokenAlias<".s32", ".i32">;
  2457. def : TokenAlias<".u32", ".i32">;
  2458. def : TokenAlias<".s64", ".i64">;
  2459. def : TokenAlias<".u64", ".i64">;
  2460. def : TokenAlias<".i8", ".8">;
  2461. def : TokenAlias<".i16", ".16">;
  2462. def : TokenAlias<".i32", ".32">;
  2463. def : TokenAlias<".i64", ".64">;
  2464. def : TokenAlias<".p8", ".8">;
  2465. def : TokenAlias<".p16", ".16">;
  2466. def : TokenAlias<".f32", ".32">;
  2467. def : TokenAlias<".f64", ".64">;
  2468. def : TokenAlias<".f", ".f32">;
  2469. def : TokenAlias<".d", ".f64">;