ARMInstrFormats.td 94 KB

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