AArch64InstPrinter.cpp 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  1. //==-- AArch64InstPrinter.cpp - Convert AArch64 MCInst to assembly syntax --==//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This class prints an AArch64 MCInst to a .s file.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "AArch64InstPrinter.h"
  13. #include "MCTargetDesc/AArch64AddressingModes.h"
  14. #include "Utils/AArch64BaseInfo.h"
  15. #include "llvm/ADT/STLExtras.h"
  16. #include "llvm/ADT/StringExtras.h"
  17. #include "llvm/ADT/StringRef.h"
  18. #include "llvm/MC/MCAsmInfo.h"
  19. #include "llvm/MC/MCExpr.h"
  20. #include "llvm/MC/MCInst.h"
  21. #include "llvm/MC/MCRegisterInfo.h"
  22. #include "llvm/MC/MCSubtargetInfo.h"
  23. #include "llvm/Support/Casting.h"
  24. #include "llvm/Support/ErrorHandling.h"
  25. #include "llvm/Support/Format.h"
  26. #include "llvm/Support/MathExtras.h"
  27. #include "llvm/Support/raw_ostream.h"
  28. #include <cassert>
  29. #include <cstdint>
  30. #include <string>
  31. using namespace llvm;
  32. #define DEBUG_TYPE "asm-printer"
  33. #define GET_INSTRUCTION_NAME
  34. #define PRINT_ALIAS_INSTR
  35. #include "AArch64GenAsmWriter.inc"
  36. #define GET_INSTRUCTION_NAME
  37. #define PRINT_ALIAS_INSTR
  38. #include "AArch64GenAsmWriter1.inc"
  39. AArch64InstPrinter::AArch64InstPrinter(const MCAsmInfo &MAI,
  40. const MCInstrInfo &MII,
  41. const MCRegisterInfo &MRI)
  42. : MCInstPrinter(MAI, MII, MRI) {}
  43. AArch64AppleInstPrinter::AArch64AppleInstPrinter(const MCAsmInfo &MAI,
  44. const MCInstrInfo &MII,
  45. const MCRegisterInfo &MRI)
  46. : AArch64InstPrinter(MAI, MII, MRI) {}
  47. bool AArch64InstPrinter::applyTargetSpecificCLOption(StringRef Opt) {
  48. if (Opt == "no-aliases") {
  49. PrintAliases = false;
  50. return true;
  51. }
  52. return false;
  53. }
  54. void AArch64InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
  55. // This is for .cfi directives.
  56. OS << getRegisterName(RegNo);
  57. }
  58. void AArch64InstPrinter::printInst(const MCInst *MI, uint64_t Address,
  59. StringRef Annot, const MCSubtargetInfo &STI,
  60. raw_ostream &O) {
  61. // Check for special encodings and print the canonical alias instead.
  62. unsigned Opcode = MI->getOpcode();
  63. if (Opcode == AArch64::SYSxt)
  64. if (printSysAlias(MI, STI, O)) {
  65. printAnnotation(O, Annot);
  66. return;
  67. }
  68. // SBFM/UBFM should print to a nicer aliased form if possible.
  69. if (Opcode == AArch64::SBFMXri || Opcode == AArch64::SBFMWri ||
  70. Opcode == AArch64::UBFMXri || Opcode == AArch64::UBFMWri) {
  71. const MCOperand &Op0 = MI->getOperand(0);
  72. const MCOperand &Op1 = MI->getOperand(1);
  73. const MCOperand &Op2 = MI->getOperand(2);
  74. const MCOperand &Op3 = MI->getOperand(3);
  75. bool IsSigned = (Opcode == AArch64::SBFMXri || Opcode == AArch64::SBFMWri);
  76. bool Is64Bit = (Opcode == AArch64::SBFMXri || Opcode == AArch64::UBFMXri);
  77. if (Op2.isImm() && Op2.getImm() == 0 && Op3.isImm()) {
  78. const char *AsmMnemonic = nullptr;
  79. switch (Op3.getImm()) {
  80. default:
  81. break;
  82. case 7:
  83. if (IsSigned)
  84. AsmMnemonic = "sxtb";
  85. else if (!Is64Bit)
  86. AsmMnemonic = "uxtb";
  87. break;
  88. case 15:
  89. if (IsSigned)
  90. AsmMnemonic = "sxth";
  91. else if (!Is64Bit)
  92. AsmMnemonic = "uxth";
  93. break;
  94. case 31:
  95. // *xtw is only valid for signed 64-bit operations.
  96. if (Is64Bit && IsSigned)
  97. AsmMnemonic = "sxtw";
  98. break;
  99. }
  100. if (AsmMnemonic) {
  101. O << '\t' << AsmMnemonic << '\t' << getRegisterName(Op0.getReg())
  102. << ", " << getRegisterName(getWRegFromXReg(Op1.getReg()));
  103. printAnnotation(O, Annot);
  104. return;
  105. }
  106. }
  107. // All immediate shifts are aliases, implemented using the Bitfield
  108. // instruction. In all cases the immediate shift amount shift must be in
  109. // the range 0 to (reg.size -1).
  110. if (Op2.isImm() && Op3.isImm()) {
  111. const char *AsmMnemonic = nullptr;
  112. int shift = 0;
  113. int64_t immr = Op2.getImm();
  114. int64_t imms = Op3.getImm();
  115. if (Opcode == AArch64::UBFMWri && imms != 0x1F && ((imms + 1) == immr)) {
  116. AsmMnemonic = "lsl";
  117. shift = 31 - imms;
  118. } else if (Opcode == AArch64::UBFMXri && imms != 0x3f &&
  119. ((imms + 1 == immr))) {
  120. AsmMnemonic = "lsl";
  121. shift = 63 - imms;
  122. } else if (Opcode == AArch64::UBFMWri && imms == 0x1f) {
  123. AsmMnemonic = "lsr";
  124. shift = immr;
  125. } else if (Opcode == AArch64::UBFMXri && imms == 0x3f) {
  126. AsmMnemonic = "lsr";
  127. shift = immr;
  128. } else if (Opcode == AArch64::SBFMWri && imms == 0x1f) {
  129. AsmMnemonic = "asr";
  130. shift = immr;
  131. } else if (Opcode == AArch64::SBFMXri && imms == 0x3f) {
  132. AsmMnemonic = "asr";
  133. shift = immr;
  134. }
  135. if (AsmMnemonic) {
  136. O << '\t' << AsmMnemonic << '\t' << getRegisterName(Op0.getReg())
  137. << ", " << getRegisterName(Op1.getReg()) << ", #" << shift;
  138. printAnnotation(O, Annot);
  139. return;
  140. }
  141. }
  142. // SBFIZ/UBFIZ aliases
  143. if (Op2.getImm() > Op3.getImm()) {
  144. O << '\t' << (IsSigned ? "sbfiz" : "ubfiz") << '\t'
  145. << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op1.getReg())
  146. << ", #" << (Is64Bit ? 64 : 32) - Op2.getImm() << ", #" << Op3.getImm() + 1;
  147. printAnnotation(O, Annot);
  148. return;
  149. }
  150. // Otherwise SBFX/UBFX is the preferred form
  151. O << '\t' << (IsSigned ? "sbfx" : "ubfx") << '\t'
  152. << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op1.getReg())
  153. << ", #" << Op2.getImm() << ", #" << Op3.getImm() - Op2.getImm() + 1;
  154. printAnnotation(O, Annot);
  155. return;
  156. }
  157. if (Opcode == AArch64::BFMXri || Opcode == AArch64::BFMWri) {
  158. const MCOperand &Op0 = MI->getOperand(0); // Op1 == Op0
  159. const MCOperand &Op2 = MI->getOperand(2);
  160. int ImmR = MI->getOperand(3).getImm();
  161. int ImmS = MI->getOperand(4).getImm();
  162. if ((Op2.getReg() == AArch64::WZR || Op2.getReg() == AArch64::XZR) &&
  163. (ImmR == 0 || ImmS < ImmR) &&
  164. STI.getFeatureBits()[AArch64::HasV8_2aOps]) {
  165. // BFC takes precedence over its entire range, sligtly differently to BFI.
  166. int BitWidth = Opcode == AArch64::BFMXri ? 64 : 32;
  167. int LSB = (BitWidth - ImmR) % BitWidth;
  168. int Width = ImmS + 1;
  169. O << "\tbfc\t" << getRegisterName(Op0.getReg())
  170. << ", #" << LSB << ", #" << Width;
  171. printAnnotation(O, Annot);
  172. return;
  173. } else if (ImmS < ImmR) {
  174. // BFI alias
  175. int BitWidth = Opcode == AArch64::BFMXri ? 64 : 32;
  176. int LSB = (BitWidth - ImmR) % BitWidth;
  177. int Width = ImmS + 1;
  178. O << "\tbfi\t" << getRegisterName(Op0.getReg()) << ", "
  179. << getRegisterName(Op2.getReg()) << ", #" << LSB << ", #" << Width;
  180. printAnnotation(O, Annot);
  181. return;
  182. }
  183. int LSB = ImmR;
  184. int Width = ImmS - ImmR + 1;
  185. // Otherwise BFXIL the preferred form
  186. O << "\tbfxil\t"
  187. << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op2.getReg())
  188. << ", #" << LSB << ", #" << Width;
  189. printAnnotation(O, Annot);
  190. return;
  191. }
  192. // Symbolic operands for MOVZ, MOVN and MOVK already imply a shift
  193. // (e.g. :gottprel_g1: is always going to be "lsl #16") so it should not be
  194. // printed.
  195. if ((Opcode == AArch64::MOVZXi || Opcode == AArch64::MOVZWi ||
  196. Opcode == AArch64::MOVNXi || Opcode == AArch64::MOVNWi) &&
  197. MI->getOperand(1).isExpr()) {
  198. if (Opcode == AArch64::MOVZXi || Opcode == AArch64::MOVZWi)
  199. O << "\tmovz\t";
  200. else
  201. O << "\tmovn\t";
  202. O << getRegisterName(MI->getOperand(0).getReg()) << ", #";
  203. MI->getOperand(1).getExpr()->print(O, &MAI);
  204. return;
  205. }
  206. if ((Opcode == AArch64::MOVKXi || Opcode == AArch64::MOVKWi) &&
  207. MI->getOperand(2).isExpr()) {
  208. O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #";
  209. MI->getOperand(2).getExpr()->print(O, &MAI);
  210. return;
  211. }
  212. // MOVZ, MOVN and "ORR wzr, #imm" instructions are aliases for MOV, but their
  213. // domains overlap so they need to be prioritized. The chain is "MOVZ lsl #0 >
  214. // MOVZ lsl #N > MOVN lsl #0 > MOVN lsl #N > ORR". The highest instruction
  215. // that can represent the move is the MOV alias, and the rest get printed
  216. // normally.
  217. if ((Opcode == AArch64::MOVZXi || Opcode == AArch64::MOVZWi) &&
  218. MI->getOperand(1).isImm() && MI->getOperand(2).isImm()) {
  219. int RegWidth = Opcode == AArch64::MOVZXi ? 64 : 32;
  220. int Shift = MI->getOperand(2).getImm();
  221. uint64_t Value = (uint64_t)MI->getOperand(1).getImm() << Shift;
  222. if (AArch64_AM::isMOVZMovAlias(Value, Shift,
  223. Opcode == AArch64::MOVZXi ? 64 : 32)) {
  224. O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"
  225. << formatImm(SignExtend64(Value, RegWidth));
  226. return;
  227. }
  228. }
  229. if ((Opcode == AArch64::MOVNXi || Opcode == AArch64::MOVNWi) &&
  230. MI->getOperand(1).isImm() && MI->getOperand(2).isImm()) {
  231. int RegWidth = Opcode == AArch64::MOVNXi ? 64 : 32;
  232. int Shift = MI->getOperand(2).getImm();
  233. uint64_t Value = ~((uint64_t)MI->getOperand(1).getImm() << Shift);
  234. if (RegWidth == 32)
  235. Value = Value & 0xffffffff;
  236. if (AArch64_AM::isMOVNMovAlias(Value, Shift, RegWidth)) {
  237. O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"
  238. << formatImm(SignExtend64(Value, RegWidth));
  239. return;
  240. }
  241. }
  242. if ((Opcode == AArch64::ORRXri || Opcode == AArch64::ORRWri) &&
  243. (MI->getOperand(1).getReg() == AArch64::XZR ||
  244. MI->getOperand(1).getReg() == AArch64::WZR) &&
  245. MI->getOperand(2).isImm()) {
  246. int RegWidth = Opcode == AArch64::ORRXri ? 64 : 32;
  247. uint64_t Value = AArch64_AM::decodeLogicalImmediate(
  248. MI->getOperand(2).getImm(), RegWidth);
  249. if (!AArch64_AM::isAnyMOVWMovAlias(Value, RegWidth)) {
  250. O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"
  251. << formatImm(SignExtend64(Value, RegWidth));
  252. return;
  253. }
  254. }
  255. if (Opcode == AArch64::CompilerBarrier) {
  256. O << '\t' << MAI.getCommentString() << " COMPILER BARRIER";
  257. printAnnotation(O, Annot);
  258. return;
  259. }
  260. if (Opcode == AArch64::SPACE) {
  261. O << '\t' << MAI.getCommentString() << " SPACE "
  262. << MI->getOperand(1).getImm();
  263. printAnnotation(O, Annot);
  264. return;
  265. }
  266. // Instruction TSB is specified as a one operand instruction, but 'csync' is
  267. // not encoded, so for printing it is treated as a special case here:
  268. if (Opcode == AArch64::TSB) {
  269. O << "\ttsb\tcsync";
  270. return;
  271. }
  272. if (!PrintAliases || !printAliasInstr(MI, Address, STI, O))
  273. printInstruction(MI, Address, STI, O);
  274. printAnnotation(O, Annot);
  275. if (atomicBarrierDroppedOnZero(Opcode) &&
  276. (MI->getOperand(0).getReg() == AArch64::XZR ||
  277. MI->getOperand(0).getReg() == AArch64::WZR)) {
  278. printAnnotation(O, "acquire semantics dropped since destination is zero");
  279. }
  280. }
  281. static bool isTblTbxInstruction(unsigned Opcode, StringRef &Layout,
  282. bool &IsTbx) {
  283. switch (Opcode) {
  284. case AArch64::TBXv8i8One:
  285. case AArch64::TBXv8i8Two:
  286. case AArch64::TBXv8i8Three:
  287. case AArch64::TBXv8i8Four:
  288. IsTbx = true;
  289. Layout = ".8b";
  290. return true;
  291. case AArch64::TBLv8i8One:
  292. case AArch64::TBLv8i8Two:
  293. case AArch64::TBLv8i8Three:
  294. case AArch64::TBLv8i8Four:
  295. IsTbx = false;
  296. Layout = ".8b";
  297. return true;
  298. case AArch64::TBXv16i8One:
  299. case AArch64::TBXv16i8Two:
  300. case AArch64::TBXv16i8Three:
  301. case AArch64::TBXv16i8Four:
  302. IsTbx = true;
  303. Layout = ".16b";
  304. return true;
  305. case AArch64::TBLv16i8One:
  306. case AArch64::TBLv16i8Two:
  307. case AArch64::TBLv16i8Three:
  308. case AArch64::TBLv16i8Four:
  309. IsTbx = false;
  310. Layout = ".16b";
  311. return true;
  312. default:
  313. return false;
  314. }
  315. }
  316. struct LdStNInstrDesc {
  317. unsigned Opcode;
  318. const char *Mnemonic;
  319. const char *Layout;
  320. int ListOperand;
  321. bool HasLane;
  322. int NaturalOffset;
  323. };
  324. static const LdStNInstrDesc LdStNInstInfo[] = {
  325. { AArch64::LD1i8, "ld1", ".b", 1, true, 0 },
  326. { AArch64::LD1i16, "ld1", ".h", 1, true, 0 },
  327. { AArch64::LD1i32, "ld1", ".s", 1, true, 0 },
  328. { AArch64::LD1i64, "ld1", ".d", 1, true, 0 },
  329. { AArch64::LD1i8_POST, "ld1", ".b", 2, true, 1 },
  330. { AArch64::LD1i16_POST, "ld1", ".h", 2, true, 2 },
  331. { AArch64::LD1i32_POST, "ld1", ".s", 2, true, 4 },
  332. { AArch64::LD1i64_POST, "ld1", ".d", 2, true, 8 },
  333. { AArch64::LD1Rv16b, "ld1r", ".16b", 0, false, 0 },
  334. { AArch64::LD1Rv8h, "ld1r", ".8h", 0, false, 0 },
  335. { AArch64::LD1Rv4s, "ld1r", ".4s", 0, false, 0 },
  336. { AArch64::LD1Rv2d, "ld1r", ".2d", 0, false, 0 },
  337. { AArch64::LD1Rv8b, "ld1r", ".8b", 0, false, 0 },
  338. { AArch64::LD1Rv4h, "ld1r", ".4h", 0, false, 0 },
  339. { AArch64::LD1Rv2s, "ld1r", ".2s", 0, false, 0 },
  340. { AArch64::LD1Rv1d, "ld1r", ".1d", 0, false, 0 },
  341. { AArch64::LD1Rv16b_POST, "ld1r", ".16b", 1, false, 1 },
  342. { AArch64::LD1Rv8h_POST, "ld1r", ".8h", 1, false, 2 },
  343. { AArch64::LD1Rv4s_POST, "ld1r", ".4s", 1, false, 4 },
  344. { AArch64::LD1Rv2d_POST, "ld1r", ".2d", 1, false, 8 },
  345. { AArch64::LD1Rv8b_POST, "ld1r", ".8b", 1, false, 1 },
  346. { AArch64::LD1Rv4h_POST, "ld1r", ".4h", 1, false, 2 },
  347. { AArch64::LD1Rv2s_POST, "ld1r", ".2s", 1, false, 4 },
  348. { AArch64::LD1Rv1d_POST, "ld1r", ".1d", 1, false, 8 },
  349. { AArch64::LD1Onev16b, "ld1", ".16b", 0, false, 0 },
  350. { AArch64::LD1Onev8h, "ld1", ".8h", 0, false, 0 },
  351. { AArch64::LD1Onev4s, "ld1", ".4s", 0, false, 0 },
  352. { AArch64::LD1Onev2d, "ld1", ".2d", 0, false, 0 },
  353. { AArch64::LD1Onev8b, "ld1", ".8b", 0, false, 0 },
  354. { AArch64::LD1Onev4h, "ld1", ".4h", 0, false, 0 },
  355. { AArch64::LD1Onev2s, "ld1", ".2s", 0, false, 0 },
  356. { AArch64::LD1Onev1d, "ld1", ".1d", 0, false, 0 },
  357. { AArch64::LD1Onev16b_POST, "ld1", ".16b", 1, false, 16 },
  358. { AArch64::LD1Onev8h_POST, "ld1", ".8h", 1, false, 16 },
  359. { AArch64::LD1Onev4s_POST, "ld1", ".4s", 1, false, 16 },
  360. { AArch64::LD1Onev2d_POST, "ld1", ".2d", 1, false, 16 },
  361. { AArch64::LD1Onev8b_POST, "ld1", ".8b", 1, false, 8 },
  362. { AArch64::LD1Onev4h_POST, "ld1", ".4h", 1, false, 8 },
  363. { AArch64::LD1Onev2s_POST, "ld1", ".2s", 1, false, 8 },
  364. { AArch64::LD1Onev1d_POST, "ld1", ".1d", 1, false, 8 },
  365. { AArch64::LD1Twov16b, "ld1", ".16b", 0, false, 0 },
  366. { AArch64::LD1Twov8h, "ld1", ".8h", 0, false, 0 },
  367. { AArch64::LD1Twov4s, "ld1", ".4s", 0, false, 0 },
  368. { AArch64::LD1Twov2d, "ld1", ".2d", 0, false, 0 },
  369. { AArch64::LD1Twov8b, "ld1", ".8b", 0, false, 0 },
  370. { AArch64::LD1Twov4h, "ld1", ".4h", 0, false, 0 },
  371. { AArch64::LD1Twov2s, "ld1", ".2s", 0, false, 0 },
  372. { AArch64::LD1Twov1d, "ld1", ".1d", 0, false, 0 },
  373. { AArch64::LD1Twov16b_POST, "ld1", ".16b", 1, false, 32 },
  374. { AArch64::LD1Twov8h_POST, "ld1", ".8h", 1, false, 32 },
  375. { AArch64::LD1Twov4s_POST, "ld1", ".4s", 1, false, 32 },
  376. { AArch64::LD1Twov2d_POST, "ld1", ".2d", 1, false, 32 },
  377. { AArch64::LD1Twov8b_POST, "ld1", ".8b", 1, false, 16 },
  378. { AArch64::LD1Twov4h_POST, "ld1", ".4h", 1, false, 16 },
  379. { AArch64::LD1Twov2s_POST, "ld1", ".2s", 1, false, 16 },
  380. { AArch64::LD1Twov1d_POST, "ld1", ".1d", 1, false, 16 },
  381. { AArch64::LD1Threev16b, "ld1", ".16b", 0, false, 0 },
  382. { AArch64::LD1Threev8h, "ld1", ".8h", 0, false, 0 },
  383. { AArch64::LD1Threev4s, "ld1", ".4s", 0, false, 0 },
  384. { AArch64::LD1Threev2d, "ld1", ".2d", 0, false, 0 },
  385. { AArch64::LD1Threev8b, "ld1", ".8b", 0, false, 0 },
  386. { AArch64::LD1Threev4h, "ld1", ".4h", 0, false, 0 },
  387. { AArch64::LD1Threev2s, "ld1", ".2s", 0, false, 0 },
  388. { AArch64::LD1Threev1d, "ld1", ".1d", 0, false, 0 },
  389. { AArch64::LD1Threev16b_POST, "ld1", ".16b", 1, false, 48 },
  390. { AArch64::LD1Threev8h_POST, "ld1", ".8h", 1, false, 48 },
  391. { AArch64::LD1Threev4s_POST, "ld1", ".4s", 1, false, 48 },
  392. { AArch64::LD1Threev2d_POST, "ld1", ".2d", 1, false, 48 },
  393. { AArch64::LD1Threev8b_POST, "ld1", ".8b", 1, false, 24 },
  394. { AArch64::LD1Threev4h_POST, "ld1", ".4h", 1, false, 24 },
  395. { AArch64::LD1Threev2s_POST, "ld1", ".2s", 1, false, 24 },
  396. { AArch64::LD1Threev1d_POST, "ld1", ".1d", 1, false, 24 },
  397. { AArch64::LD1Fourv16b, "ld1", ".16b", 0, false, 0 },
  398. { AArch64::LD1Fourv8h, "ld1", ".8h", 0, false, 0 },
  399. { AArch64::LD1Fourv4s, "ld1", ".4s", 0, false, 0 },
  400. { AArch64::LD1Fourv2d, "ld1", ".2d", 0, false, 0 },
  401. { AArch64::LD1Fourv8b, "ld1", ".8b", 0, false, 0 },
  402. { AArch64::LD1Fourv4h, "ld1", ".4h", 0, false, 0 },
  403. { AArch64::LD1Fourv2s, "ld1", ".2s", 0, false, 0 },
  404. { AArch64::LD1Fourv1d, "ld1", ".1d", 0, false, 0 },
  405. { AArch64::LD1Fourv16b_POST, "ld1", ".16b", 1, false, 64 },
  406. { AArch64::LD1Fourv8h_POST, "ld1", ".8h", 1, false, 64 },
  407. { AArch64::LD1Fourv4s_POST, "ld1", ".4s", 1, false, 64 },
  408. { AArch64::LD1Fourv2d_POST, "ld1", ".2d", 1, false, 64 },
  409. { AArch64::LD1Fourv8b_POST, "ld1", ".8b", 1, false, 32 },
  410. { AArch64::LD1Fourv4h_POST, "ld1", ".4h", 1, false, 32 },
  411. { AArch64::LD1Fourv2s_POST, "ld1", ".2s", 1, false, 32 },
  412. { AArch64::LD1Fourv1d_POST, "ld1", ".1d", 1, false, 32 },
  413. { AArch64::LD2i8, "ld2", ".b", 1, true, 0 },
  414. { AArch64::LD2i16, "ld2", ".h", 1, true, 0 },
  415. { AArch64::LD2i32, "ld2", ".s", 1, true, 0 },
  416. { AArch64::LD2i64, "ld2", ".d", 1, true, 0 },
  417. { AArch64::LD2i8_POST, "ld2", ".b", 2, true, 2 },
  418. { AArch64::LD2i16_POST, "ld2", ".h", 2, true, 4 },
  419. { AArch64::LD2i32_POST, "ld2", ".s", 2, true, 8 },
  420. { AArch64::LD2i64_POST, "ld2", ".d", 2, true, 16 },
  421. { AArch64::LD2Rv16b, "ld2r", ".16b", 0, false, 0 },
  422. { AArch64::LD2Rv8h, "ld2r", ".8h", 0, false, 0 },
  423. { AArch64::LD2Rv4s, "ld2r", ".4s", 0, false, 0 },
  424. { AArch64::LD2Rv2d, "ld2r", ".2d", 0, false, 0 },
  425. { AArch64::LD2Rv8b, "ld2r", ".8b", 0, false, 0 },
  426. { AArch64::LD2Rv4h, "ld2r", ".4h", 0, false, 0 },
  427. { AArch64::LD2Rv2s, "ld2r", ".2s", 0, false, 0 },
  428. { AArch64::LD2Rv1d, "ld2r", ".1d", 0, false, 0 },
  429. { AArch64::LD2Rv16b_POST, "ld2r", ".16b", 1, false, 2 },
  430. { AArch64::LD2Rv8h_POST, "ld2r", ".8h", 1, false, 4 },
  431. { AArch64::LD2Rv4s_POST, "ld2r", ".4s", 1, false, 8 },
  432. { AArch64::LD2Rv2d_POST, "ld2r", ".2d", 1, false, 16 },
  433. { AArch64::LD2Rv8b_POST, "ld2r", ".8b", 1, false, 2 },
  434. { AArch64::LD2Rv4h_POST, "ld2r", ".4h", 1, false, 4 },
  435. { AArch64::LD2Rv2s_POST, "ld2r", ".2s", 1, false, 8 },
  436. { AArch64::LD2Rv1d_POST, "ld2r", ".1d", 1, false, 16 },
  437. { AArch64::LD2Twov16b, "ld2", ".16b", 0, false, 0 },
  438. { AArch64::LD2Twov8h, "ld2", ".8h", 0, false, 0 },
  439. { AArch64::LD2Twov4s, "ld2", ".4s", 0, false, 0 },
  440. { AArch64::LD2Twov2d, "ld2", ".2d", 0, false, 0 },
  441. { AArch64::LD2Twov8b, "ld2", ".8b", 0, false, 0 },
  442. { AArch64::LD2Twov4h, "ld2", ".4h", 0, false, 0 },
  443. { AArch64::LD2Twov2s, "ld2", ".2s", 0, false, 0 },
  444. { AArch64::LD2Twov16b_POST, "ld2", ".16b", 1, false, 32 },
  445. { AArch64::LD2Twov8h_POST, "ld2", ".8h", 1, false, 32 },
  446. { AArch64::LD2Twov4s_POST, "ld2", ".4s", 1, false, 32 },
  447. { AArch64::LD2Twov2d_POST, "ld2", ".2d", 1, false, 32 },
  448. { AArch64::LD2Twov8b_POST, "ld2", ".8b", 1, false, 16 },
  449. { AArch64::LD2Twov4h_POST, "ld2", ".4h", 1, false, 16 },
  450. { AArch64::LD2Twov2s_POST, "ld2", ".2s", 1, false, 16 },
  451. { AArch64::LD3i8, "ld3", ".b", 1, true, 0 },
  452. { AArch64::LD3i16, "ld3", ".h", 1, true, 0 },
  453. { AArch64::LD3i32, "ld3", ".s", 1, true, 0 },
  454. { AArch64::LD3i64, "ld3", ".d", 1, true, 0 },
  455. { AArch64::LD3i8_POST, "ld3", ".b", 2, true, 3 },
  456. { AArch64::LD3i16_POST, "ld3", ".h", 2, true, 6 },
  457. { AArch64::LD3i32_POST, "ld3", ".s", 2, true, 12 },
  458. { AArch64::LD3i64_POST, "ld3", ".d", 2, true, 24 },
  459. { AArch64::LD3Rv16b, "ld3r", ".16b", 0, false, 0 },
  460. { AArch64::LD3Rv8h, "ld3r", ".8h", 0, false, 0 },
  461. { AArch64::LD3Rv4s, "ld3r", ".4s", 0, false, 0 },
  462. { AArch64::LD3Rv2d, "ld3r", ".2d", 0, false, 0 },
  463. { AArch64::LD3Rv8b, "ld3r", ".8b", 0, false, 0 },
  464. { AArch64::LD3Rv4h, "ld3r", ".4h", 0, false, 0 },
  465. { AArch64::LD3Rv2s, "ld3r", ".2s", 0, false, 0 },
  466. { AArch64::LD3Rv1d, "ld3r", ".1d", 0, false, 0 },
  467. { AArch64::LD3Rv16b_POST, "ld3r", ".16b", 1, false, 3 },
  468. { AArch64::LD3Rv8h_POST, "ld3r", ".8h", 1, false, 6 },
  469. { AArch64::LD3Rv4s_POST, "ld3r", ".4s", 1, false, 12 },
  470. { AArch64::LD3Rv2d_POST, "ld3r", ".2d", 1, false, 24 },
  471. { AArch64::LD3Rv8b_POST, "ld3r", ".8b", 1, false, 3 },
  472. { AArch64::LD3Rv4h_POST, "ld3r", ".4h", 1, false, 6 },
  473. { AArch64::LD3Rv2s_POST, "ld3r", ".2s", 1, false, 12 },
  474. { AArch64::LD3Rv1d_POST, "ld3r", ".1d", 1, false, 24 },
  475. { AArch64::LD3Threev16b, "ld3", ".16b", 0, false, 0 },
  476. { AArch64::LD3Threev8h, "ld3", ".8h", 0, false, 0 },
  477. { AArch64::LD3Threev4s, "ld3", ".4s", 0, false, 0 },
  478. { AArch64::LD3Threev2d, "ld3", ".2d", 0, false, 0 },
  479. { AArch64::LD3Threev8b, "ld3", ".8b", 0, false, 0 },
  480. { AArch64::LD3Threev4h, "ld3", ".4h", 0, false, 0 },
  481. { AArch64::LD3Threev2s, "ld3", ".2s", 0, false, 0 },
  482. { AArch64::LD3Threev16b_POST, "ld3", ".16b", 1, false, 48 },
  483. { AArch64::LD3Threev8h_POST, "ld3", ".8h", 1, false, 48 },
  484. { AArch64::LD3Threev4s_POST, "ld3", ".4s", 1, false, 48 },
  485. { AArch64::LD3Threev2d_POST, "ld3", ".2d", 1, false, 48 },
  486. { AArch64::LD3Threev8b_POST, "ld3", ".8b", 1, false, 24 },
  487. { AArch64::LD3Threev4h_POST, "ld3", ".4h", 1, false, 24 },
  488. { AArch64::LD3Threev2s_POST, "ld3", ".2s", 1, false, 24 },
  489. { AArch64::LD4i8, "ld4", ".b", 1, true, 0 },
  490. { AArch64::LD4i16, "ld4", ".h", 1, true, 0 },
  491. { AArch64::LD4i32, "ld4", ".s", 1, true, 0 },
  492. { AArch64::LD4i64, "ld4", ".d", 1, true, 0 },
  493. { AArch64::LD4i8_POST, "ld4", ".b", 2, true, 4 },
  494. { AArch64::LD4i16_POST, "ld4", ".h", 2, true, 8 },
  495. { AArch64::LD4i32_POST, "ld4", ".s", 2, true, 16 },
  496. { AArch64::LD4i64_POST, "ld4", ".d", 2, true, 32 },
  497. { AArch64::LD4Rv16b, "ld4r", ".16b", 0, false, 0 },
  498. { AArch64::LD4Rv8h, "ld4r", ".8h", 0, false, 0 },
  499. { AArch64::LD4Rv4s, "ld4r", ".4s", 0, false, 0 },
  500. { AArch64::LD4Rv2d, "ld4r", ".2d", 0, false, 0 },
  501. { AArch64::LD4Rv8b, "ld4r", ".8b", 0, false, 0 },
  502. { AArch64::LD4Rv4h, "ld4r", ".4h", 0, false, 0 },
  503. { AArch64::LD4Rv2s, "ld4r", ".2s", 0, false, 0 },
  504. { AArch64::LD4Rv1d, "ld4r", ".1d", 0, false, 0 },
  505. { AArch64::LD4Rv16b_POST, "ld4r", ".16b", 1, false, 4 },
  506. { AArch64::LD4Rv8h_POST, "ld4r", ".8h", 1, false, 8 },
  507. { AArch64::LD4Rv4s_POST, "ld4r", ".4s", 1, false, 16 },
  508. { AArch64::LD4Rv2d_POST, "ld4r", ".2d", 1, false, 32 },
  509. { AArch64::LD4Rv8b_POST, "ld4r", ".8b", 1, false, 4 },
  510. { AArch64::LD4Rv4h_POST, "ld4r", ".4h", 1, false, 8 },
  511. { AArch64::LD4Rv2s_POST, "ld4r", ".2s", 1, false, 16 },
  512. { AArch64::LD4Rv1d_POST, "ld4r", ".1d", 1, false, 32 },
  513. { AArch64::LD4Fourv16b, "ld4", ".16b", 0, false, 0 },
  514. { AArch64::LD4Fourv8h, "ld4", ".8h", 0, false, 0 },
  515. { AArch64::LD4Fourv4s, "ld4", ".4s", 0, false, 0 },
  516. { AArch64::LD4Fourv2d, "ld4", ".2d", 0, false, 0 },
  517. { AArch64::LD4Fourv8b, "ld4", ".8b", 0, false, 0 },
  518. { AArch64::LD4Fourv4h, "ld4", ".4h", 0, false, 0 },
  519. { AArch64::LD4Fourv2s, "ld4", ".2s", 0, false, 0 },
  520. { AArch64::LD4Fourv16b_POST, "ld4", ".16b", 1, false, 64 },
  521. { AArch64::LD4Fourv8h_POST, "ld4", ".8h", 1, false, 64 },
  522. { AArch64::LD4Fourv4s_POST, "ld4", ".4s", 1, false, 64 },
  523. { AArch64::LD4Fourv2d_POST, "ld4", ".2d", 1, false, 64 },
  524. { AArch64::LD4Fourv8b_POST, "ld4", ".8b", 1, false, 32 },
  525. { AArch64::LD4Fourv4h_POST, "ld4", ".4h", 1, false, 32 },
  526. { AArch64::LD4Fourv2s_POST, "ld4", ".2s", 1, false, 32 },
  527. { AArch64::ST1i8, "st1", ".b", 0, true, 0 },
  528. { AArch64::ST1i16, "st1", ".h", 0, true, 0 },
  529. { AArch64::ST1i32, "st1", ".s", 0, true, 0 },
  530. { AArch64::ST1i64, "st1", ".d", 0, true, 0 },
  531. { AArch64::ST1i8_POST, "st1", ".b", 1, true, 1 },
  532. { AArch64::ST1i16_POST, "st1", ".h", 1, true, 2 },
  533. { AArch64::ST1i32_POST, "st1", ".s", 1, true, 4 },
  534. { AArch64::ST1i64_POST, "st1", ".d", 1, true, 8 },
  535. { AArch64::ST1Onev16b, "st1", ".16b", 0, false, 0 },
  536. { AArch64::ST1Onev8h, "st1", ".8h", 0, false, 0 },
  537. { AArch64::ST1Onev4s, "st1", ".4s", 0, false, 0 },
  538. { AArch64::ST1Onev2d, "st1", ".2d", 0, false, 0 },
  539. { AArch64::ST1Onev8b, "st1", ".8b", 0, false, 0 },
  540. { AArch64::ST1Onev4h, "st1", ".4h", 0, false, 0 },
  541. { AArch64::ST1Onev2s, "st1", ".2s", 0, false, 0 },
  542. { AArch64::ST1Onev1d, "st1", ".1d", 0, false, 0 },
  543. { AArch64::ST1Onev16b_POST, "st1", ".16b", 1, false, 16 },
  544. { AArch64::ST1Onev8h_POST, "st1", ".8h", 1, false, 16 },
  545. { AArch64::ST1Onev4s_POST, "st1", ".4s", 1, false, 16 },
  546. { AArch64::ST1Onev2d_POST, "st1", ".2d", 1, false, 16 },
  547. { AArch64::ST1Onev8b_POST, "st1", ".8b", 1, false, 8 },
  548. { AArch64::ST1Onev4h_POST, "st1", ".4h", 1, false, 8 },
  549. { AArch64::ST1Onev2s_POST, "st1", ".2s", 1, false, 8 },
  550. { AArch64::ST1Onev1d_POST, "st1", ".1d", 1, false, 8 },
  551. { AArch64::ST1Twov16b, "st1", ".16b", 0, false, 0 },
  552. { AArch64::ST1Twov8h, "st1", ".8h", 0, false, 0 },
  553. { AArch64::ST1Twov4s, "st1", ".4s", 0, false, 0 },
  554. { AArch64::ST1Twov2d, "st1", ".2d", 0, false, 0 },
  555. { AArch64::ST1Twov8b, "st1", ".8b", 0, false, 0 },
  556. { AArch64::ST1Twov4h, "st1", ".4h", 0, false, 0 },
  557. { AArch64::ST1Twov2s, "st1", ".2s", 0, false, 0 },
  558. { AArch64::ST1Twov1d, "st1", ".1d", 0, false, 0 },
  559. { AArch64::ST1Twov16b_POST, "st1", ".16b", 1, false, 32 },
  560. { AArch64::ST1Twov8h_POST, "st1", ".8h", 1, false, 32 },
  561. { AArch64::ST1Twov4s_POST, "st1", ".4s", 1, false, 32 },
  562. { AArch64::ST1Twov2d_POST, "st1", ".2d", 1, false, 32 },
  563. { AArch64::ST1Twov8b_POST, "st1", ".8b", 1, false, 16 },
  564. { AArch64::ST1Twov4h_POST, "st1", ".4h", 1, false, 16 },
  565. { AArch64::ST1Twov2s_POST, "st1", ".2s", 1, false, 16 },
  566. { AArch64::ST1Twov1d_POST, "st1", ".1d", 1, false, 16 },
  567. { AArch64::ST1Threev16b, "st1", ".16b", 0, false, 0 },
  568. { AArch64::ST1Threev8h, "st1", ".8h", 0, false, 0 },
  569. { AArch64::ST1Threev4s, "st1", ".4s", 0, false, 0 },
  570. { AArch64::ST1Threev2d, "st1", ".2d", 0, false, 0 },
  571. { AArch64::ST1Threev8b, "st1", ".8b", 0, false, 0 },
  572. { AArch64::ST1Threev4h, "st1", ".4h", 0, false, 0 },
  573. { AArch64::ST1Threev2s, "st1", ".2s", 0, false, 0 },
  574. { AArch64::ST1Threev1d, "st1", ".1d", 0, false, 0 },
  575. { AArch64::ST1Threev16b_POST, "st1", ".16b", 1, false, 48 },
  576. { AArch64::ST1Threev8h_POST, "st1", ".8h", 1, false, 48 },
  577. { AArch64::ST1Threev4s_POST, "st1", ".4s", 1, false, 48 },
  578. { AArch64::ST1Threev2d_POST, "st1", ".2d", 1, false, 48 },
  579. { AArch64::ST1Threev8b_POST, "st1", ".8b", 1, false, 24 },
  580. { AArch64::ST1Threev4h_POST, "st1", ".4h", 1, false, 24 },
  581. { AArch64::ST1Threev2s_POST, "st1", ".2s", 1, false, 24 },
  582. { AArch64::ST1Threev1d_POST, "st1", ".1d", 1, false, 24 },
  583. { AArch64::ST1Fourv16b, "st1", ".16b", 0, false, 0 },
  584. { AArch64::ST1Fourv8h, "st1", ".8h", 0, false, 0 },
  585. { AArch64::ST1Fourv4s, "st1", ".4s", 0, false, 0 },
  586. { AArch64::ST1Fourv2d, "st1", ".2d", 0, false, 0 },
  587. { AArch64::ST1Fourv8b, "st1", ".8b", 0, false, 0 },
  588. { AArch64::ST1Fourv4h, "st1", ".4h", 0, false, 0 },
  589. { AArch64::ST1Fourv2s, "st1", ".2s", 0, false, 0 },
  590. { AArch64::ST1Fourv1d, "st1", ".1d", 0, false, 0 },
  591. { AArch64::ST1Fourv16b_POST, "st1", ".16b", 1, false, 64 },
  592. { AArch64::ST1Fourv8h_POST, "st1", ".8h", 1, false, 64 },
  593. { AArch64::ST1Fourv4s_POST, "st1", ".4s", 1, false, 64 },
  594. { AArch64::ST1Fourv2d_POST, "st1", ".2d", 1, false, 64 },
  595. { AArch64::ST1Fourv8b_POST, "st1", ".8b", 1, false, 32 },
  596. { AArch64::ST1Fourv4h_POST, "st1", ".4h", 1, false, 32 },
  597. { AArch64::ST1Fourv2s_POST, "st1", ".2s", 1, false, 32 },
  598. { AArch64::ST1Fourv1d_POST, "st1", ".1d", 1, false, 32 },
  599. { AArch64::ST2i8, "st2", ".b", 0, true, 0 },
  600. { AArch64::ST2i16, "st2", ".h", 0, true, 0 },
  601. { AArch64::ST2i32, "st2", ".s", 0, true, 0 },
  602. { AArch64::ST2i64, "st2", ".d", 0, true, 0 },
  603. { AArch64::ST2i8_POST, "st2", ".b", 1, true, 2 },
  604. { AArch64::ST2i16_POST, "st2", ".h", 1, true, 4 },
  605. { AArch64::ST2i32_POST, "st2", ".s", 1, true, 8 },
  606. { AArch64::ST2i64_POST, "st2", ".d", 1, true, 16 },
  607. { AArch64::ST2Twov16b, "st2", ".16b", 0, false, 0 },
  608. { AArch64::ST2Twov8h, "st2", ".8h", 0, false, 0 },
  609. { AArch64::ST2Twov4s, "st2", ".4s", 0, false, 0 },
  610. { AArch64::ST2Twov2d, "st2", ".2d", 0, false, 0 },
  611. { AArch64::ST2Twov8b, "st2", ".8b", 0, false, 0 },
  612. { AArch64::ST2Twov4h, "st2", ".4h", 0, false, 0 },
  613. { AArch64::ST2Twov2s, "st2", ".2s", 0, false, 0 },
  614. { AArch64::ST2Twov16b_POST, "st2", ".16b", 1, false, 32 },
  615. { AArch64::ST2Twov8h_POST, "st2", ".8h", 1, false, 32 },
  616. { AArch64::ST2Twov4s_POST, "st2", ".4s", 1, false, 32 },
  617. { AArch64::ST2Twov2d_POST, "st2", ".2d", 1, false, 32 },
  618. { AArch64::ST2Twov8b_POST, "st2", ".8b", 1, false, 16 },
  619. { AArch64::ST2Twov4h_POST, "st2", ".4h", 1, false, 16 },
  620. { AArch64::ST2Twov2s_POST, "st2", ".2s", 1, false, 16 },
  621. { AArch64::ST3i8, "st3", ".b", 0, true, 0 },
  622. { AArch64::ST3i16, "st3", ".h", 0, true, 0 },
  623. { AArch64::ST3i32, "st3", ".s", 0, true, 0 },
  624. { AArch64::ST3i64, "st3", ".d", 0, true, 0 },
  625. { AArch64::ST3i8_POST, "st3", ".b", 1, true, 3 },
  626. { AArch64::ST3i16_POST, "st3", ".h", 1, true, 6 },
  627. { AArch64::ST3i32_POST, "st3", ".s", 1, true, 12 },
  628. { AArch64::ST3i64_POST, "st3", ".d", 1, true, 24 },
  629. { AArch64::ST3Threev16b, "st3", ".16b", 0, false, 0 },
  630. { AArch64::ST3Threev8h, "st3", ".8h", 0, false, 0 },
  631. { AArch64::ST3Threev4s, "st3", ".4s", 0, false, 0 },
  632. { AArch64::ST3Threev2d, "st3", ".2d", 0, false, 0 },
  633. { AArch64::ST3Threev8b, "st3", ".8b", 0, false, 0 },
  634. { AArch64::ST3Threev4h, "st3", ".4h", 0, false, 0 },
  635. { AArch64::ST3Threev2s, "st3", ".2s", 0, false, 0 },
  636. { AArch64::ST3Threev16b_POST, "st3", ".16b", 1, false, 48 },
  637. { AArch64::ST3Threev8h_POST, "st3", ".8h", 1, false, 48 },
  638. { AArch64::ST3Threev4s_POST, "st3", ".4s", 1, false, 48 },
  639. { AArch64::ST3Threev2d_POST, "st3", ".2d", 1, false, 48 },
  640. { AArch64::ST3Threev8b_POST, "st3", ".8b", 1, false, 24 },
  641. { AArch64::ST3Threev4h_POST, "st3", ".4h", 1, false, 24 },
  642. { AArch64::ST3Threev2s_POST, "st3", ".2s", 1, false, 24 },
  643. { AArch64::ST4i8, "st4", ".b", 0, true, 0 },
  644. { AArch64::ST4i16, "st4", ".h", 0, true, 0 },
  645. { AArch64::ST4i32, "st4", ".s", 0, true, 0 },
  646. { AArch64::ST4i64, "st4", ".d", 0, true, 0 },
  647. { AArch64::ST4i8_POST, "st4", ".b", 1, true, 4 },
  648. { AArch64::ST4i16_POST, "st4", ".h", 1, true, 8 },
  649. { AArch64::ST4i32_POST, "st4", ".s", 1, true, 16 },
  650. { AArch64::ST4i64_POST, "st4", ".d", 1, true, 32 },
  651. { AArch64::ST4Fourv16b, "st4", ".16b", 0, false, 0 },
  652. { AArch64::ST4Fourv8h, "st4", ".8h", 0, false, 0 },
  653. { AArch64::ST4Fourv4s, "st4", ".4s", 0, false, 0 },
  654. { AArch64::ST4Fourv2d, "st4", ".2d", 0, false, 0 },
  655. { AArch64::ST4Fourv8b, "st4", ".8b", 0, false, 0 },
  656. { AArch64::ST4Fourv4h, "st4", ".4h", 0, false, 0 },
  657. { AArch64::ST4Fourv2s, "st4", ".2s", 0, false, 0 },
  658. { AArch64::ST4Fourv16b_POST, "st4", ".16b", 1, false, 64 },
  659. { AArch64::ST4Fourv8h_POST, "st4", ".8h", 1, false, 64 },
  660. { AArch64::ST4Fourv4s_POST, "st4", ".4s", 1, false, 64 },
  661. { AArch64::ST4Fourv2d_POST, "st4", ".2d", 1, false, 64 },
  662. { AArch64::ST4Fourv8b_POST, "st4", ".8b", 1, false, 32 },
  663. { AArch64::ST4Fourv4h_POST, "st4", ".4h", 1, false, 32 },
  664. { AArch64::ST4Fourv2s_POST, "st4", ".2s", 1, false, 32 },
  665. };
  666. static const LdStNInstrDesc *getLdStNInstrDesc(unsigned Opcode) {
  667. unsigned Idx;
  668. for (Idx = 0; Idx != array_lengthof(LdStNInstInfo); ++Idx)
  669. if (LdStNInstInfo[Idx].Opcode == Opcode)
  670. return &LdStNInstInfo[Idx];
  671. return nullptr;
  672. }
  673. void AArch64AppleInstPrinter::printInst(const MCInst *MI, uint64_t Address,
  674. StringRef Annot,
  675. const MCSubtargetInfo &STI,
  676. raw_ostream &O) {
  677. unsigned Opcode = MI->getOpcode();
  678. StringRef Layout;
  679. bool IsTbx;
  680. if (isTblTbxInstruction(MI->getOpcode(), Layout, IsTbx)) {
  681. O << "\t" << (IsTbx ? "tbx" : "tbl") << Layout << '\t'
  682. << getRegisterName(MI->getOperand(0).getReg(), AArch64::vreg) << ", ";
  683. unsigned ListOpNum = IsTbx ? 2 : 1;
  684. printVectorList(MI, ListOpNum, STI, O, "");
  685. O << ", "
  686. << getRegisterName(MI->getOperand(ListOpNum + 1).getReg(), AArch64::vreg);
  687. printAnnotation(O, Annot);
  688. return;
  689. }
  690. if (const LdStNInstrDesc *LdStDesc = getLdStNInstrDesc(Opcode)) {
  691. O << "\t" << LdStDesc->Mnemonic << LdStDesc->Layout << '\t';
  692. // Now onto the operands: first a vector list with possible lane
  693. // specifier. E.g. { v0 }[2]
  694. int OpNum = LdStDesc->ListOperand;
  695. printVectorList(MI, OpNum++, STI, O, "");
  696. if (LdStDesc->HasLane)
  697. O << '[' << MI->getOperand(OpNum++).getImm() << ']';
  698. // Next the address: [xN]
  699. unsigned AddrReg = MI->getOperand(OpNum++).getReg();
  700. O << ", [" << getRegisterName(AddrReg) << ']';
  701. // Finally, there might be a post-indexed offset.
  702. if (LdStDesc->NaturalOffset != 0) {
  703. unsigned Reg = MI->getOperand(OpNum++).getReg();
  704. if (Reg != AArch64::XZR)
  705. O << ", " << getRegisterName(Reg);
  706. else {
  707. assert(LdStDesc->NaturalOffset && "no offset on post-inc instruction?");
  708. O << ", #" << LdStDesc->NaturalOffset;
  709. }
  710. }
  711. printAnnotation(O, Annot);
  712. return;
  713. }
  714. AArch64InstPrinter::printInst(MI, Address, Annot, STI, O);
  715. }
  716. bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
  717. const MCSubtargetInfo &STI,
  718. raw_ostream &O) {
  719. #ifndef NDEBUG
  720. unsigned Opcode = MI->getOpcode();
  721. assert(Opcode == AArch64::SYSxt && "Invalid opcode for SYS alias!");
  722. #endif
  723. const MCOperand &Op1 = MI->getOperand(0);
  724. const MCOperand &Cn = MI->getOperand(1);
  725. const MCOperand &Cm = MI->getOperand(2);
  726. const MCOperand &Op2 = MI->getOperand(3);
  727. unsigned Op1Val = Op1.getImm();
  728. unsigned CnVal = Cn.getImm();
  729. unsigned CmVal = Cm.getImm();
  730. unsigned Op2Val = Op2.getImm();
  731. uint16_t Encoding = Op2Val;
  732. Encoding |= CmVal << 3;
  733. Encoding |= CnVal << 7;
  734. Encoding |= Op1Val << 11;
  735. bool NeedsReg;
  736. std::string Ins;
  737. std::string Name;
  738. if (CnVal == 7) {
  739. switch (CmVal) {
  740. default: return false;
  741. // Maybe IC, maybe Prediction Restriction
  742. case 1:
  743. switch (Op1Val) {
  744. default: return false;
  745. case 0: goto Search_IC;
  746. case 3: goto Search_PRCTX;
  747. }
  748. // Prediction Restriction aliases
  749. case 3: {
  750. Search_PRCTX:
  751. const AArch64PRCTX::PRCTX *PRCTX = AArch64PRCTX::lookupPRCTXByEncoding(Encoding >> 3);
  752. if (!PRCTX || !PRCTX->haveFeatures(STI.getFeatureBits()))
  753. return false;
  754. NeedsReg = PRCTX->NeedsReg;
  755. switch (Op2Val) {
  756. default: return false;
  757. case 4: Ins = "cfp\t"; break;
  758. case 5: Ins = "dvp\t"; break;
  759. case 7: Ins = "cpp\t"; break;
  760. }
  761. Name = std::string(PRCTX->Name);
  762. }
  763. break;
  764. // IC aliases
  765. case 5: {
  766. Search_IC:
  767. const AArch64IC::IC *IC = AArch64IC::lookupICByEncoding(Encoding);
  768. if (!IC || !IC->haveFeatures(STI.getFeatureBits()))
  769. return false;
  770. NeedsReg = IC->NeedsReg;
  771. Ins = "ic\t";
  772. Name = std::string(IC->Name);
  773. }
  774. break;
  775. // DC aliases
  776. case 4: case 6: case 10: case 11: case 12: case 13: case 14:
  777. {
  778. const AArch64DC::DC *DC = AArch64DC::lookupDCByEncoding(Encoding);
  779. if (!DC || !DC->haveFeatures(STI.getFeatureBits()))
  780. return false;
  781. NeedsReg = true;
  782. Ins = "dc\t";
  783. Name = std::string(DC->Name);
  784. }
  785. break;
  786. // AT aliases
  787. case 8: case 9: {
  788. const AArch64AT::AT *AT = AArch64AT::lookupATByEncoding(Encoding);
  789. if (!AT || !AT->haveFeatures(STI.getFeatureBits()))
  790. return false;
  791. NeedsReg = true;
  792. Ins = "at\t";
  793. Name = std::string(AT->Name);
  794. }
  795. break;
  796. }
  797. } else if (CnVal == 8 || CnVal == 9) {
  798. // TLBI aliases
  799. const AArch64TLBI::TLBI *TLBI = AArch64TLBI::lookupTLBIByEncoding(Encoding);
  800. if (!TLBI || !TLBI->haveFeatures(STI.getFeatureBits()))
  801. return false;
  802. NeedsReg = TLBI->NeedsReg;
  803. Ins = "tlbi\t";
  804. Name = std::string(TLBI->Name);
  805. }
  806. else
  807. return false;
  808. std::string Str = Ins + Name;
  809. std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower);
  810. O << '\t' << Str;
  811. if (NeedsReg)
  812. O << ", " << getRegisterName(MI->getOperand(4).getReg());
  813. return true;
  814. }
  815. template <int EltSize>
  816. void AArch64InstPrinter::printMatrix(const MCInst *MI, unsigned OpNum,
  817. const MCSubtargetInfo &STI,
  818. raw_ostream &O) {
  819. const MCOperand &RegOp = MI->getOperand(OpNum);
  820. assert(RegOp.isReg() && "Unexpected operand type!");
  821. O << getRegisterName(RegOp.getReg());
  822. switch (EltSize) {
  823. case 0:
  824. break;
  825. case 8:
  826. O << ".b";
  827. break;
  828. case 16:
  829. O << ".h";
  830. break;
  831. case 32:
  832. O << ".s";
  833. break;
  834. case 64:
  835. O << ".d";
  836. break;
  837. case 128:
  838. O << ".q";
  839. break;
  840. default:
  841. llvm_unreachable("Unsupported element size");
  842. }
  843. }
  844. template <bool IsVertical>
  845. void AArch64InstPrinter::printMatrixTileVector(const MCInst *MI, unsigned OpNum,
  846. const MCSubtargetInfo &STI,
  847. raw_ostream &O) {
  848. const MCOperand &RegOp = MI->getOperand(OpNum);
  849. assert(RegOp.isReg() && "Unexpected operand type!");
  850. StringRef RegName = getRegisterName(RegOp.getReg());
  851. // Insert the horizontal/vertical flag before the suffix.
  852. StringRef Base, Suffix;
  853. std::tie(Base, Suffix) = RegName.split('.');
  854. O << Base << (IsVertical ? "v" : "h") << '.' << Suffix;
  855. }
  856. void AArch64InstPrinter::printMatrixTile(const MCInst *MI, unsigned OpNum,
  857. const MCSubtargetInfo &STI,
  858. raw_ostream &O) {
  859. const MCOperand &RegOp = MI->getOperand(OpNum);
  860. assert(RegOp.isReg() && "Unexpected operand type!");
  861. O << getRegisterName(RegOp.getReg());
  862. }
  863. void AArch64InstPrinter::printSVCROp(const MCInst *MI, unsigned OpNum,
  864. const MCSubtargetInfo &STI,
  865. raw_ostream &O) {
  866. const MCOperand &MO = MI->getOperand(OpNum);
  867. assert(MO.isImm() && "Unexpected operand type!");
  868. unsigned svcrop = MO.getImm();
  869. const auto *SVCR = AArch64SVCR::lookupSVCRByEncoding(svcrop);
  870. assert(SVCR && "Unexpected SVCR operand!");
  871. O << SVCR->Name;
  872. }
  873. void AArch64InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
  874. const MCSubtargetInfo &STI,
  875. raw_ostream &O) {
  876. const MCOperand &Op = MI->getOperand(OpNo);
  877. if (Op.isReg()) {
  878. unsigned Reg = Op.getReg();
  879. O << getRegisterName(Reg);
  880. } else if (Op.isImm()) {
  881. printImm(MI, OpNo, STI, O);
  882. } else {
  883. assert(Op.isExpr() && "unknown operand kind in printOperand");
  884. Op.getExpr()->print(O, &MAI);
  885. }
  886. }
  887. void AArch64InstPrinter::printImm(const MCInst *MI, unsigned OpNo,
  888. const MCSubtargetInfo &STI,
  889. raw_ostream &O) {
  890. const MCOperand &Op = MI->getOperand(OpNo);
  891. O << "#" << formatImm(Op.getImm());
  892. }
  893. void AArch64InstPrinter::printImmHex(const MCInst *MI, unsigned OpNo,
  894. const MCSubtargetInfo &STI,
  895. raw_ostream &O) {
  896. const MCOperand &Op = MI->getOperand(OpNo);
  897. O << format("#%#llx", Op.getImm());
  898. }
  899. template<int Size>
  900. void AArch64InstPrinter::printSImm(const MCInst *MI, unsigned OpNo,
  901. const MCSubtargetInfo &STI,
  902. raw_ostream &O) {
  903. const MCOperand &Op = MI->getOperand(OpNo);
  904. if (Size == 8)
  905. O << "#" << formatImm((signed char)Op.getImm());
  906. else if (Size == 16)
  907. O << "#" << formatImm((signed short)Op.getImm());
  908. else
  909. O << "#" << formatImm(Op.getImm());
  910. }
  911. void AArch64InstPrinter::printPostIncOperand(const MCInst *MI, unsigned OpNo,
  912. unsigned Imm, raw_ostream &O) {
  913. const MCOperand &Op = MI->getOperand(OpNo);
  914. if (Op.isReg()) {
  915. unsigned Reg = Op.getReg();
  916. if (Reg == AArch64::XZR)
  917. O << "#" << Imm;
  918. else
  919. O << getRegisterName(Reg);
  920. } else
  921. llvm_unreachable("unknown operand kind in printPostIncOperand64");
  922. }
  923. void AArch64InstPrinter::printVRegOperand(const MCInst *MI, unsigned OpNo,
  924. const MCSubtargetInfo &STI,
  925. raw_ostream &O) {
  926. const MCOperand &Op = MI->getOperand(OpNo);
  927. assert(Op.isReg() && "Non-register vreg operand!");
  928. unsigned Reg = Op.getReg();
  929. O << getRegisterName(Reg, AArch64::vreg);
  930. }
  931. void AArch64InstPrinter::printSysCROperand(const MCInst *MI, unsigned OpNo,
  932. const MCSubtargetInfo &STI,
  933. raw_ostream &O) {
  934. const MCOperand &Op = MI->getOperand(OpNo);
  935. assert(Op.isImm() && "System instruction C[nm] operands must be immediates!");
  936. O << "c" << Op.getImm();
  937. }
  938. void AArch64InstPrinter::printAddSubImm(const MCInst *MI, unsigned OpNum,
  939. const MCSubtargetInfo &STI,
  940. raw_ostream &O) {
  941. const MCOperand &MO = MI->getOperand(OpNum);
  942. if (MO.isImm()) {
  943. unsigned Val = (MO.getImm() & 0xfff);
  944. assert(Val == MO.getImm() && "Add/sub immediate out of range!");
  945. unsigned Shift =
  946. AArch64_AM::getShiftValue(MI->getOperand(OpNum + 1).getImm());
  947. O << '#' << formatImm(Val);
  948. if (Shift != 0) {
  949. printShifter(MI, OpNum + 1, STI, O);
  950. if (CommentStream)
  951. *CommentStream << '=' << formatImm(Val << Shift) << '\n';
  952. }
  953. } else {
  954. assert(MO.isExpr() && "Unexpected operand type!");
  955. MO.getExpr()->print(O, &MAI);
  956. printShifter(MI, OpNum + 1, STI, O);
  957. }
  958. }
  959. template <typename T>
  960. void AArch64InstPrinter::printLogicalImm(const MCInst *MI, unsigned OpNum,
  961. const MCSubtargetInfo &STI,
  962. raw_ostream &O) {
  963. uint64_t Val = MI->getOperand(OpNum).getImm();
  964. O << "#0x";
  965. O.write_hex(AArch64_AM::decodeLogicalImmediate(Val, 8 * sizeof(T)));
  966. }
  967. void AArch64InstPrinter::printShifter(const MCInst *MI, unsigned OpNum,
  968. const MCSubtargetInfo &STI,
  969. raw_ostream &O) {
  970. unsigned Val = MI->getOperand(OpNum).getImm();
  971. // LSL #0 should not be printed.
  972. if (AArch64_AM::getShiftType(Val) == AArch64_AM::LSL &&
  973. AArch64_AM::getShiftValue(Val) == 0)
  974. return;
  975. O << ", " << AArch64_AM::getShiftExtendName(AArch64_AM::getShiftType(Val))
  976. << " #" << AArch64_AM::getShiftValue(Val);
  977. }
  978. void AArch64InstPrinter::printShiftedRegister(const MCInst *MI, unsigned OpNum,
  979. const MCSubtargetInfo &STI,
  980. raw_ostream &O) {
  981. O << getRegisterName(MI->getOperand(OpNum).getReg());
  982. printShifter(MI, OpNum + 1, STI, O);
  983. }
  984. void AArch64InstPrinter::printExtendedRegister(const MCInst *MI, unsigned OpNum,
  985. const MCSubtargetInfo &STI,
  986. raw_ostream &O) {
  987. O << getRegisterName(MI->getOperand(OpNum).getReg());
  988. printArithExtend(MI, OpNum + 1, STI, O);
  989. }
  990. void AArch64InstPrinter::printArithExtend(const MCInst *MI, unsigned OpNum,
  991. const MCSubtargetInfo &STI,
  992. raw_ostream &O) {
  993. unsigned Val = MI->getOperand(OpNum).getImm();
  994. AArch64_AM::ShiftExtendType ExtType = AArch64_AM::getArithExtendType(Val);
  995. unsigned ShiftVal = AArch64_AM::getArithShiftValue(Val);
  996. // If the destination or first source register operand is [W]SP, print
  997. // UXTW/UXTX as LSL, and if the shift amount is also zero, print nothing at
  998. // all.
  999. if (ExtType == AArch64_AM::UXTW || ExtType == AArch64_AM::UXTX) {
  1000. unsigned Dest = MI->getOperand(0).getReg();
  1001. unsigned Src1 = MI->getOperand(1).getReg();
  1002. if ( ((Dest == AArch64::SP || Src1 == AArch64::SP) &&
  1003. ExtType == AArch64_AM::UXTX) ||
  1004. ((Dest == AArch64::WSP || Src1 == AArch64::WSP) &&
  1005. ExtType == AArch64_AM::UXTW) ) {
  1006. if (ShiftVal != 0)
  1007. O << ", lsl #" << ShiftVal;
  1008. return;
  1009. }
  1010. }
  1011. O << ", " << AArch64_AM::getShiftExtendName(ExtType);
  1012. if (ShiftVal != 0)
  1013. O << " #" << ShiftVal;
  1014. }
  1015. static void printMemExtendImpl(bool SignExtend, bool DoShift,
  1016. unsigned Width, char SrcRegKind,
  1017. raw_ostream &O) {
  1018. // sxtw, sxtx, uxtw or lsl (== uxtx)
  1019. bool IsLSL = !SignExtend && SrcRegKind == 'x';
  1020. if (IsLSL)
  1021. O << "lsl";
  1022. else
  1023. O << (SignExtend ? 's' : 'u') << "xt" << SrcRegKind;
  1024. if (DoShift || IsLSL)
  1025. O << " #" << Log2_32(Width / 8);
  1026. }
  1027. void AArch64InstPrinter::printMemExtend(const MCInst *MI, unsigned OpNum,
  1028. raw_ostream &O, char SrcRegKind,
  1029. unsigned Width) {
  1030. bool SignExtend = MI->getOperand(OpNum).getImm();
  1031. bool DoShift = MI->getOperand(OpNum + 1).getImm();
  1032. printMemExtendImpl(SignExtend, DoShift, Width, SrcRegKind, O);
  1033. }
  1034. template <bool SignExtend, int ExtWidth, char SrcRegKind, char Suffix>
  1035. void AArch64InstPrinter::printRegWithShiftExtend(const MCInst *MI,
  1036. unsigned OpNum,
  1037. const MCSubtargetInfo &STI,
  1038. raw_ostream &O) {
  1039. printOperand(MI, OpNum, STI, O);
  1040. if (Suffix == 's' || Suffix == 'd')
  1041. O << '.' << Suffix;
  1042. else
  1043. assert(Suffix == 0 && "Unsupported suffix size");
  1044. bool DoShift = ExtWidth != 8;
  1045. if (SignExtend || DoShift || SrcRegKind == 'w') {
  1046. O << ", ";
  1047. printMemExtendImpl(SignExtend, DoShift, ExtWidth, SrcRegKind, O);
  1048. }
  1049. }
  1050. void AArch64InstPrinter::printCondCode(const MCInst *MI, unsigned OpNum,
  1051. const MCSubtargetInfo &STI,
  1052. raw_ostream &O) {
  1053. AArch64CC::CondCode CC = (AArch64CC::CondCode)MI->getOperand(OpNum).getImm();
  1054. O << AArch64CC::getCondCodeName(CC);
  1055. }
  1056. void AArch64InstPrinter::printInverseCondCode(const MCInst *MI, unsigned OpNum,
  1057. const MCSubtargetInfo &STI,
  1058. raw_ostream &O) {
  1059. AArch64CC::CondCode CC = (AArch64CC::CondCode)MI->getOperand(OpNum).getImm();
  1060. O << AArch64CC::getCondCodeName(AArch64CC::getInvertedCondCode(CC));
  1061. }
  1062. void AArch64InstPrinter::printAMNoIndex(const MCInst *MI, unsigned OpNum,
  1063. const MCSubtargetInfo &STI,
  1064. raw_ostream &O) {
  1065. O << '[' << getRegisterName(MI->getOperand(OpNum).getReg()) << ']';
  1066. }
  1067. template<int Scale>
  1068. void AArch64InstPrinter::printImmScale(const MCInst *MI, unsigned OpNum,
  1069. const MCSubtargetInfo &STI,
  1070. raw_ostream &O) {
  1071. O << '#' << formatImm(Scale * MI->getOperand(OpNum).getImm());
  1072. }
  1073. void AArch64InstPrinter::printUImm12Offset(const MCInst *MI, unsigned OpNum,
  1074. unsigned Scale, raw_ostream &O) {
  1075. const MCOperand MO = MI->getOperand(OpNum);
  1076. if (MO.isImm()) {
  1077. O << "#" << formatImm(MO.getImm() * Scale);
  1078. } else {
  1079. assert(MO.isExpr() && "Unexpected operand type!");
  1080. MO.getExpr()->print(O, &MAI);
  1081. }
  1082. }
  1083. void AArch64InstPrinter::printAMIndexedWB(const MCInst *MI, unsigned OpNum,
  1084. unsigned Scale, raw_ostream &O) {
  1085. const MCOperand MO1 = MI->getOperand(OpNum + 1);
  1086. O << '[' << getRegisterName(MI->getOperand(OpNum).getReg());
  1087. if (MO1.isImm()) {
  1088. O << ", #" << formatImm(MO1.getImm() * Scale);
  1089. } else {
  1090. assert(MO1.isExpr() && "Unexpected operand type!");
  1091. O << ", ";
  1092. MO1.getExpr()->print(O, &MAI);
  1093. }
  1094. O << ']';
  1095. }
  1096. template <bool IsSVEPrefetch>
  1097. void AArch64InstPrinter::printPrefetchOp(const MCInst *MI, unsigned OpNum,
  1098. const MCSubtargetInfo &STI,
  1099. raw_ostream &O) {
  1100. unsigned prfop = MI->getOperand(OpNum).getImm();
  1101. if (IsSVEPrefetch) {
  1102. if (auto PRFM = AArch64SVEPRFM::lookupSVEPRFMByEncoding(prfop)) {
  1103. O << PRFM->Name;
  1104. return;
  1105. }
  1106. } else if (auto PRFM = AArch64PRFM::lookupPRFMByEncoding(prfop)) {
  1107. O << PRFM->Name;
  1108. return;
  1109. }
  1110. O << '#' << formatImm(prfop);
  1111. }
  1112. void AArch64InstPrinter::printPSBHintOp(const MCInst *MI, unsigned OpNum,
  1113. const MCSubtargetInfo &STI,
  1114. raw_ostream &O) {
  1115. unsigned psbhintop = MI->getOperand(OpNum).getImm();
  1116. auto PSB = AArch64PSBHint::lookupPSBByEncoding(psbhintop);
  1117. if (PSB)
  1118. O << PSB->Name;
  1119. else
  1120. O << '#' << formatImm(psbhintop);
  1121. }
  1122. void AArch64InstPrinter::printBTIHintOp(const MCInst *MI, unsigned OpNum,
  1123. const MCSubtargetInfo &STI,
  1124. raw_ostream &O) {
  1125. unsigned btihintop = MI->getOperand(OpNum).getImm() ^ 32;
  1126. auto BTI = AArch64BTIHint::lookupBTIByEncoding(btihintop);
  1127. if (BTI)
  1128. O << BTI->Name;
  1129. else
  1130. O << '#' << formatImm(btihintop);
  1131. }
  1132. void AArch64InstPrinter::printFPImmOperand(const MCInst *MI, unsigned OpNum,
  1133. const MCSubtargetInfo &STI,
  1134. raw_ostream &O) {
  1135. const MCOperand &MO = MI->getOperand(OpNum);
  1136. float FPImm = MO.isDFPImm() ? bit_cast<double>(MO.getDFPImm())
  1137. : AArch64_AM::getFPImmFloat(MO.getImm());
  1138. // 8 decimal places are enough to perfectly represent permitted floats.
  1139. O << format("#%.8f", FPImm);
  1140. }
  1141. static unsigned getNextVectorRegister(unsigned Reg, unsigned Stride = 1) {
  1142. while (Stride--) {
  1143. switch (Reg) {
  1144. default:
  1145. llvm_unreachable("Vector register expected!");
  1146. case AArch64::Q0: Reg = AArch64::Q1; break;
  1147. case AArch64::Q1: Reg = AArch64::Q2; break;
  1148. case AArch64::Q2: Reg = AArch64::Q3; break;
  1149. case AArch64::Q3: Reg = AArch64::Q4; break;
  1150. case AArch64::Q4: Reg = AArch64::Q5; break;
  1151. case AArch64::Q5: Reg = AArch64::Q6; break;
  1152. case AArch64::Q6: Reg = AArch64::Q7; break;
  1153. case AArch64::Q7: Reg = AArch64::Q8; break;
  1154. case AArch64::Q8: Reg = AArch64::Q9; break;
  1155. case AArch64::Q9: Reg = AArch64::Q10; break;
  1156. case AArch64::Q10: Reg = AArch64::Q11; break;
  1157. case AArch64::Q11: Reg = AArch64::Q12; break;
  1158. case AArch64::Q12: Reg = AArch64::Q13; break;
  1159. case AArch64::Q13: Reg = AArch64::Q14; break;
  1160. case AArch64::Q14: Reg = AArch64::Q15; break;
  1161. case AArch64::Q15: Reg = AArch64::Q16; break;
  1162. case AArch64::Q16: Reg = AArch64::Q17; break;
  1163. case AArch64::Q17: Reg = AArch64::Q18; break;
  1164. case AArch64::Q18: Reg = AArch64::Q19; break;
  1165. case AArch64::Q19: Reg = AArch64::Q20; break;
  1166. case AArch64::Q20: Reg = AArch64::Q21; break;
  1167. case AArch64::Q21: Reg = AArch64::Q22; break;
  1168. case AArch64::Q22: Reg = AArch64::Q23; break;
  1169. case AArch64::Q23: Reg = AArch64::Q24; break;
  1170. case AArch64::Q24: Reg = AArch64::Q25; break;
  1171. case AArch64::Q25: Reg = AArch64::Q26; break;
  1172. case AArch64::Q26: Reg = AArch64::Q27; break;
  1173. case AArch64::Q27: Reg = AArch64::Q28; break;
  1174. case AArch64::Q28: Reg = AArch64::Q29; break;
  1175. case AArch64::Q29: Reg = AArch64::Q30; break;
  1176. case AArch64::Q30: Reg = AArch64::Q31; break;
  1177. // Vector lists can wrap around.
  1178. case AArch64::Q31:
  1179. Reg = AArch64::Q0;
  1180. break;
  1181. case AArch64::Z0: Reg = AArch64::Z1; break;
  1182. case AArch64::Z1: Reg = AArch64::Z2; break;
  1183. case AArch64::Z2: Reg = AArch64::Z3; break;
  1184. case AArch64::Z3: Reg = AArch64::Z4; break;
  1185. case AArch64::Z4: Reg = AArch64::Z5; break;
  1186. case AArch64::Z5: Reg = AArch64::Z6; break;
  1187. case AArch64::Z6: Reg = AArch64::Z7; break;
  1188. case AArch64::Z7: Reg = AArch64::Z8; break;
  1189. case AArch64::Z8: Reg = AArch64::Z9; break;
  1190. case AArch64::Z9: Reg = AArch64::Z10; break;
  1191. case AArch64::Z10: Reg = AArch64::Z11; break;
  1192. case AArch64::Z11: Reg = AArch64::Z12; break;
  1193. case AArch64::Z12: Reg = AArch64::Z13; break;
  1194. case AArch64::Z13: Reg = AArch64::Z14; break;
  1195. case AArch64::Z14: Reg = AArch64::Z15; break;
  1196. case AArch64::Z15: Reg = AArch64::Z16; break;
  1197. case AArch64::Z16: Reg = AArch64::Z17; break;
  1198. case AArch64::Z17: Reg = AArch64::Z18; break;
  1199. case AArch64::Z18: Reg = AArch64::Z19; break;
  1200. case AArch64::Z19: Reg = AArch64::Z20; break;
  1201. case AArch64::Z20: Reg = AArch64::Z21; break;
  1202. case AArch64::Z21: Reg = AArch64::Z22; break;
  1203. case AArch64::Z22: Reg = AArch64::Z23; break;
  1204. case AArch64::Z23: Reg = AArch64::Z24; break;
  1205. case AArch64::Z24: Reg = AArch64::Z25; break;
  1206. case AArch64::Z25: Reg = AArch64::Z26; break;
  1207. case AArch64::Z26: Reg = AArch64::Z27; break;
  1208. case AArch64::Z27: Reg = AArch64::Z28; break;
  1209. case AArch64::Z28: Reg = AArch64::Z29; break;
  1210. case AArch64::Z29: Reg = AArch64::Z30; break;
  1211. case AArch64::Z30: Reg = AArch64::Z31; break;
  1212. // Vector lists can wrap around.
  1213. case AArch64::Z31:
  1214. Reg = AArch64::Z0;
  1215. break;
  1216. }
  1217. }
  1218. return Reg;
  1219. }
  1220. template<unsigned size>
  1221. void AArch64InstPrinter::printGPRSeqPairsClassOperand(const MCInst *MI,
  1222. unsigned OpNum,
  1223. const MCSubtargetInfo &STI,
  1224. raw_ostream &O) {
  1225. static_assert(size == 64 || size == 32,
  1226. "Template parameter must be either 32 or 64");
  1227. unsigned Reg = MI->getOperand(OpNum).getReg();
  1228. unsigned Sube = (size == 32) ? AArch64::sube32 : AArch64::sube64;
  1229. unsigned Subo = (size == 32) ? AArch64::subo32 : AArch64::subo64;
  1230. unsigned Even = MRI.getSubReg(Reg, Sube);
  1231. unsigned Odd = MRI.getSubReg(Reg, Subo);
  1232. O << getRegisterName(Even) << ", " << getRegisterName(Odd);
  1233. }
  1234. static const unsigned MatrixZADRegisterTable[] = {
  1235. AArch64::ZAD0, AArch64::ZAD1, AArch64::ZAD2, AArch64::ZAD3,
  1236. AArch64::ZAD4, AArch64::ZAD5, AArch64::ZAD6, AArch64::ZAD7
  1237. };
  1238. void AArch64InstPrinter::printMatrixTileList(const MCInst *MI, unsigned OpNum,
  1239. const MCSubtargetInfo &STI,
  1240. raw_ostream &O) {
  1241. unsigned MaxRegs = 8;
  1242. unsigned RegMask = MI->getOperand(OpNum).getImm();
  1243. unsigned NumRegs = 0;
  1244. for (unsigned I = 0; I < MaxRegs; ++I)
  1245. if ((RegMask & (1 << I)) != 0)
  1246. ++NumRegs;
  1247. O << "{";
  1248. unsigned Printed = 0;
  1249. for (unsigned I = 0; I < MaxRegs; ++I) {
  1250. unsigned Reg = RegMask & (1 << I);
  1251. if (Reg == 0)
  1252. continue;
  1253. O << getRegisterName(MatrixZADRegisterTable[I]);
  1254. if (Printed + 1 != NumRegs)
  1255. O << ", ";
  1256. ++Printed;
  1257. }
  1258. O << "}";
  1259. }
  1260. void AArch64InstPrinter::printVectorList(const MCInst *MI, unsigned OpNum,
  1261. const MCSubtargetInfo &STI,
  1262. raw_ostream &O,
  1263. StringRef LayoutSuffix) {
  1264. unsigned Reg = MI->getOperand(OpNum).getReg();
  1265. O << "{ ";
  1266. // Work out how many registers there are in the list (if there is an actual
  1267. // list).
  1268. unsigned NumRegs = 1;
  1269. if (MRI.getRegClass(AArch64::DDRegClassID).contains(Reg) ||
  1270. MRI.getRegClass(AArch64::ZPR2RegClassID).contains(Reg) ||
  1271. MRI.getRegClass(AArch64::QQRegClassID).contains(Reg))
  1272. NumRegs = 2;
  1273. else if (MRI.getRegClass(AArch64::DDDRegClassID).contains(Reg) ||
  1274. MRI.getRegClass(AArch64::ZPR3RegClassID).contains(Reg) ||
  1275. MRI.getRegClass(AArch64::QQQRegClassID).contains(Reg))
  1276. NumRegs = 3;
  1277. else if (MRI.getRegClass(AArch64::DDDDRegClassID).contains(Reg) ||
  1278. MRI.getRegClass(AArch64::ZPR4RegClassID).contains(Reg) ||
  1279. MRI.getRegClass(AArch64::QQQQRegClassID).contains(Reg))
  1280. NumRegs = 4;
  1281. // Now forget about the list and find out what the first register is.
  1282. if (unsigned FirstReg = MRI.getSubReg(Reg, AArch64::dsub0))
  1283. Reg = FirstReg;
  1284. else if (unsigned FirstReg = MRI.getSubReg(Reg, AArch64::qsub0))
  1285. Reg = FirstReg;
  1286. else if (unsigned FirstReg = MRI.getSubReg(Reg, AArch64::zsub0))
  1287. Reg = FirstReg;
  1288. // If it's a D-reg, we need to promote it to the equivalent Q-reg before
  1289. // printing (otherwise getRegisterName fails).
  1290. if (MRI.getRegClass(AArch64::FPR64RegClassID).contains(Reg)) {
  1291. const MCRegisterClass &FPR128RC =
  1292. MRI.getRegClass(AArch64::FPR128RegClassID);
  1293. Reg = MRI.getMatchingSuperReg(Reg, AArch64::dsub, &FPR128RC);
  1294. }
  1295. for (unsigned i = 0; i < NumRegs; ++i, Reg = getNextVectorRegister(Reg)) {
  1296. if (MRI.getRegClass(AArch64::ZPRRegClassID).contains(Reg))
  1297. O << getRegisterName(Reg) << LayoutSuffix;
  1298. else
  1299. O << getRegisterName(Reg, AArch64::vreg) << LayoutSuffix;
  1300. if (i + 1 != NumRegs)
  1301. O << ", ";
  1302. }
  1303. O << " }";
  1304. }
  1305. void
  1306. AArch64InstPrinter::printImplicitlyTypedVectorList(const MCInst *MI,
  1307. unsigned OpNum,
  1308. const MCSubtargetInfo &STI,
  1309. raw_ostream &O) {
  1310. printVectorList(MI, OpNum, STI, O, "");
  1311. }
  1312. template <unsigned NumLanes, char LaneKind>
  1313. void AArch64InstPrinter::printTypedVectorList(const MCInst *MI, unsigned OpNum,
  1314. const MCSubtargetInfo &STI,
  1315. raw_ostream &O) {
  1316. std::string Suffix(".");
  1317. if (NumLanes)
  1318. Suffix += itostr(NumLanes) + LaneKind;
  1319. else
  1320. Suffix += LaneKind;
  1321. printVectorList(MI, OpNum, STI, O, Suffix);
  1322. }
  1323. void AArch64InstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum,
  1324. const MCSubtargetInfo &STI,
  1325. raw_ostream &O) {
  1326. O << "[" << MI->getOperand(OpNum).getImm() << "]";
  1327. }
  1328. void AArch64InstPrinter::printMatrixIndex(const MCInst *MI, unsigned OpNum,
  1329. const MCSubtargetInfo &STI,
  1330. raw_ostream &O) {
  1331. O << MI->getOperand(OpNum).getImm();
  1332. }
  1333. void AArch64InstPrinter::printAlignedLabel(const MCInst *MI, uint64_t Address,
  1334. unsigned OpNum,
  1335. const MCSubtargetInfo &STI,
  1336. raw_ostream &O) {
  1337. const MCOperand &Op = MI->getOperand(OpNum);
  1338. // If the label has already been resolved to an immediate offset (say, when
  1339. // we're running the disassembler), just print the immediate.
  1340. if (Op.isImm()) {
  1341. int64_t Offset = Op.getImm() * 4;
  1342. if (PrintBranchImmAsAddress)
  1343. O << formatHex(Address + Offset);
  1344. else
  1345. O << "#" << formatImm(Offset);
  1346. return;
  1347. }
  1348. // If the branch target is simply an address then print it in hex.
  1349. const MCConstantExpr *BranchTarget =
  1350. dyn_cast<MCConstantExpr>(MI->getOperand(OpNum).getExpr());
  1351. int64_t TargetAddress;
  1352. if (BranchTarget && BranchTarget->evaluateAsAbsolute(TargetAddress)) {
  1353. O << formatHex(TargetAddress);
  1354. } else {
  1355. // Otherwise, just print the expression.
  1356. MI->getOperand(OpNum).getExpr()->print(O, &MAI);
  1357. }
  1358. }
  1359. void AArch64InstPrinter::printAdrpLabel(const MCInst *MI, uint64_t Address,
  1360. unsigned OpNum,
  1361. const MCSubtargetInfo &STI,
  1362. raw_ostream &O) {
  1363. const MCOperand &Op = MI->getOperand(OpNum);
  1364. // If the label has already been resolved to an immediate offset (say, when
  1365. // we're running the disassembler), just print the immediate.
  1366. if (Op.isImm()) {
  1367. const int64_t Offset = Op.getImm() * 4096;
  1368. if (PrintBranchImmAsAddress)
  1369. O << formatHex((Address & -4096) + Offset);
  1370. else
  1371. O << "#" << Offset;
  1372. return;
  1373. }
  1374. // Otherwise, just print the expression.
  1375. MI->getOperand(OpNum).getExpr()->print(O, &MAI);
  1376. }
  1377. void AArch64InstPrinter::printBarrierOption(const MCInst *MI, unsigned OpNo,
  1378. const MCSubtargetInfo &STI,
  1379. raw_ostream &O) {
  1380. unsigned Val = MI->getOperand(OpNo).getImm();
  1381. unsigned Opcode = MI->getOpcode();
  1382. StringRef Name;
  1383. if (Opcode == AArch64::ISB) {
  1384. auto ISB = AArch64ISB::lookupISBByEncoding(Val);
  1385. Name = ISB ? ISB->Name : "";
  1386. } else if (Opcode == AArch64::TSB) {
  1387. auto TSB = AArch64TSB::lookupTSBByEncoding(Val);
  1388. Name = TSB ? TSB->Name : "";
  1389. } else {
  1390. auto DB = AArch64DB::lookupDBByEncoding(Val);
  1391. Name = DB ? DB->Name : "";
  1392. }
  1393. if (!Name.empty())
  1394. O << Name;
  1395. else
  1396. O << "#" << Val;
  1397. }
  1398. void AArch64InstPrinter::printBarriernXSOption(const MCInst *MI, unsigned OpNo,
  1399. const MCSubtargetInfo &STI,
  1400. raw_ostream &O) {
  1401. unsigned Val = MI->getOperand(OpNo).getImm();
  1402. assert(MI->getOpcode() == AArch64::DSBnXS);
  1403. StringRef Name;
  1404. auto DB = AArch64DBnXS::lookupDBnXSByEncoding(Val);
  1405. Name = DB ? DB->Name : "";
  1406. if (!Name.empty())
  1407. O << Name;
  1408. else
  1409. O << "#" << Val;
  1410. }
  1411. static bool isValidSysReg(const AArch64SysReg::SysReg *Reg, bool Read,
  1412. const MCSubtargetInfo &STI) {
  1413. return (Reg && (Read ? Reg->Readable : Reg->Writeable) &&
  1414. Reg->haveFeatures(STI.getFeatureBits()));
  1415. }
  1416. // Looks up a system register either by encoding or by name. Some system
  1417. // registers share the same encoding between different architectures,
  1418. // therefore a tablegen lookup by encoding will return an entry regardless
  1419. // of the register's predication on a specific subtarget feature. To work
  1420. // around this problem we keep an alternative name for such registers and
  1421. // look them up by that name if the first lookup was unsuccessful.
  1422. static const AArch64SysReg::SysReg *lookupSysReg(unsigned Val, bool Read,
  1423. const MCSubtargetInfo &STI) {
  1424. const AArch64SysReg::SysReg *Reg = AArch64SysReg::lookupSysRegByEncoding(Val);
  1425. if (Reg && !isValidSysReg(Reg, Read, STI))
  1426. Reg = AArch64SysReg::lookupSysRegByName(Reg->AltName);
  1427. return Reg;
  1428. }
  1429. void AArch64InstPrinter::printMRSSystemRegister(const MCInst *MI, unsigned OpNo,
  1430. const MCSubtargetInfo &STI,
  1431. raw_ostream &O) {
  1432. unsigned Val = MI->getOperand(OpNo).getImm();
  1433. // Horrible hack for the one register that has identical encodings but
  1434. // different names in MSR and MRS. Because of this, one of MRS and MSR is
  1435. // going to get the wrong entry
  1436. if (Val == AArch64SysReg::DBGDTRRX_EL0) {
  1437. O << "DBGDTRRX_EL0";
  1438. return;
  1439. }
  1440. // Horrible hack for two different registers having the same encoding.
  1441. if (Val == AArch64SysReg::TRCEXTINSELR) {
  1442. O << "TRCEXTINSELR";
  1443. return;
  1444. }
  1445. const AArch64SysReg::SysReg *Reg = lookupSysReg(Val, true /*Read*/, STI);
  1446. if (isValidSysReg(Reg, true /*Read*/, STI))
  1447. O << Reg->Name;
  1448. else
  1449. O << AArch64SysReg::genericRegisterString(Val);
  1450. }
  1451. void AArch64InstPrinter::printMSRSystemRegister(const MCInst *MI, unsigned OpNo,
  1452. const MCSubtargetInfo &STI,
  1453. raw_ostream &O) {
  1454. unsigned Val = MI->getOperand(OpNo).getImm();
  1455. // Horrible hack for the one register that has identical encodings but
  1456. // different names in MSR and MRS. Because of this, one of MRS and MSR is
  1457. // going to get the wrong entry
  1458. if (Val == AArch64SysReg::DBGDTRTX_EL0) {
  1459. O << "DBGDTRTX_EL0";
  1460. return;
  1461. }
  1462. // Horrible hack for two different registers having the same encoding.
  1463. if (Val == AArch64SysReg::TRCEXTINSELR) {
  1464. O << "TRCEXTINSELR";
  1465. return;
  1466. }
  1467. const AArch64SysReg::SysReg *Reg = lookupSysReg(Val, false /*Read*/, STI);
  1468. if (isValidSysReg(Reg, false /*Read*/, STI))
  1469. O << Reg->Name;
  1470. else
  1471. O << AArch64SysReg::genericRegisterString(Val);
  1472. }
  1473. void AArch64InstPrinter::printSystemPStateField(const MCInst *MI, unsigned OpNo,
  1474. const MCSubtargetInfo &STI,
  1475. raw_ostream &O) {
  1476. unsigned Val = MI->getOperand(OpNo).getImm();
  1477. auto PState = AArch64PState::lookupPStateByEncoding(Val);
  1478. if (PState && PState->haveFeatures(STI.getFeatureBits()))
  1479. O << PState->Name;
  1480. else
  1481. O << "#" << formatImm(Val);
  1482. }
  1483. void AArch64InstPrinter::printSIMDType10Operand(const MCInst *MI, unsigned OpNo,
  1484. const MCSubtargetInfo &STI,
  1485. raw_ostream &O) {
  1486. unsigned RawVal = MI->getOperand(OpNo).getImm();
  1487. uint64_t Val = AArch64_AM::decodeAdvSIMDModImmType10(RawVal);
  1488. O << format("#%#016llx", Val);
  1489. }
  1490. template<int64_t Angle, int64_t Remainder>
  1491. void AArch64InstPrinter::printComplexRotationOp(const MCInst *MI, unsigned OpNo,
  1492. const MCSubtargetInfo &STI,
  1493. raw_ostream &O) {
  1494. unsigned Val = MI->getOperand(OpNo).getImm();
  1495. O << "#" << (Val * Angle) + Remainder;
  1496. }
  1497. void AArch64InstPrinter::printSVEPattern(const MCInst *MI, unsigned OpNum,
  1498. const MCSubtargetInfo &STI,
  1499. raw_ostream &O) {
  1500. unsigned Val = MI->getOperand(OpNum).getImm();
  1501. if (auto Pat = AArch64SVEPredPattern::lookupSVEPREDPATByEncoding(Val))
  1502. O << Pat->Name;
  1503. else
  1504. O << '#' << formatImm(Val);
  1505. }
  1506. template <char suffix>
  1507. void AArch64InstPrinter::printSVERegOp(const MCInst *MI, unsigned OpNum,
  1508. const MCSubtargetInfo &STI,
  1509. raw_ostream &O) {
  1510. switch (suffix) {
  1511. case 0:
  1512. case 'b':
  1513. case 'h':
  1514. case 's':
  1515. case 'd':
  1516. case 'q':
  1517. break;
  1518. default: llvm_unreachable("Invalid kind specifier.");
  1519. }
  1520. unsigned Reg = MI->getOperand(OpNum).getReg();
  1521. O << getRegisterName(Reg);
  1522. if (suffix != 0)
  1523. O << '.' << suffix;
  1524. }
  1525. template <typename T>
  1526. void AArch64InstPrinter::printImmSVE(T Value, raw_ostream &O) {
  1527. std::make_unsigned_t<T> HexValue = Value;
  1528. if (getPrintImmHex())
  1529. O << '#' << formatHex((uint64_t)HexValue);
  1530. else
  1531. O << '#' << formatDec(Value);
  1532. if (CommentStream) {
  1533. // Do the opposite to that used for instruction operands.
  1534. if (getPrintImmHex())
  1535. *CommentStream << '=' << formatDec(HexValue) << '\n';
  1536. else
  1537. *CommentStream << '=' << formatHex((uint64_t)Value) << '\n';
  1538. }
  1539. }
  1540. template <typename T>
  1541. void AArch64InstPrinter::printImm8OptLsl(const MCInst *MI, unsigned OpNum,
  1542. const MCSubtargetInfo &STI,
  1543. raw_ostream &O) {
  1544. unsigned UnscaledVal = MI->getOperand(OpNum).getImm();
  1545. unsigned Shift = MI->getOperand(OpNum + 1).getImm();
  1546. assert(AArch64_AM::getShiftType(Shift) == AArch64_AM::LSL &&
  1547. "Unexepected shift type!");
  1548. // #0 lsl #8 is never pretty printed
  1549. if ((UnscaledVal == 0) && (AArch64_AM::getShiftValue(Shift) != 0)) {
  1550. O << '#' << formatImm(UnscaledVal);
  1551. printShifter(MI, OpNum + 1, STI, O);
  1552. return;
  1553. }
  1554. T Val;
  1555. if (std::is_signed<T>())
  1556. Val = (int8_t)UnscaledVal * (1 << AArch64_AM::getShiftValue(Shift));
  1557. else
  1558. Val = (uint8_t)UnscaledVal * (1 << AArch64_AM::getShiftValue(Shift));
  1559. printImmSVE(Val, O);
  1560. }
  1561. template <typename T>
  1562. void AArch64InstPrinter::printSVELogicalImm(const MCInst *MI, unsigned OpNum,
  1563. const MCSubtargetInfo &STI,
  1564. raw_ostream &O) {
  1565. typedef std::make_signed_t<T> SignedT;
  1566. typedef std::make_unsigned_t<T> UnsignedT;
  1567. uint64_t Val = MI->getOperand(OpNum).getImm();
  1568. UnsignedT PrintVal = AArch64_AM::decodeLogicalImmediate(Val, 64);
  1569. // Prefer the default format for 16bit values, hex otherwise.
  1570. if ((int16_t)PrintVal == (SignedT)PrintVal)
  1571. printImmSVE((T)PrintVal, O);
  1572. else if ((uint16_t)PrintVal == PrintVal)
  1573. printImmSVE(PrintVal, O);
  1574. else
  1575. O << '#' << formatHex((uint64_t)PrintVal);
  1576. }
  1577. template <int Width>
  1578. void AArch64InstPrinter::printZPRasFPR(const MCInst *MI, unsigned OpNum,
  1579. const MCSubtargetInfo &STI,
  1580. raw_ostream &O) {
  1581. unsigned Base;
  1582. switch (Width) {
  1583. case 8: Base = AArch64::B0; break;
  1584. case 16: Base = AArch64::H0; break;
  1585. case 32: Base = AArch64::S0; break;
  1586. case 64: Base = AArch64::D0; break;
  1587. case 128: Base = AArch64::Q0; break;
  1588. default:
  1589. llvm_unreachable("Unsupported width");
  1590. }
  1591. unsigned Reg = MI->getOperand(OpNum).getReg();
  1592. O << getRegisterName(Reg - AArch64::Z0 + Base);
  1593. }
  1594. template <unsigned ImmIs0, unsigned ImmIs1>
  1595. void AArch64InstPrinter::printExactFPImm(const MCInst *MI, unsigned OpNum,
  1596. const MCSubtargetInfo &STI,
  1597. raw_ostream &O) {
  1598. auto *Imm0Desc = AArch64ExactFPImm::lookupExactFPImmByEnum(ImmIs0);
  1599. auto *Imm1Desc = AArch64ExactFPImm::lookupExactFPImmByEnum(ImmIs1);
  1600. unsigned Val = MI->getOperand(OpNum).getImm();
  1601. O << "#" << (Val ? Imm1Desc->Repr : Imm0Desc->Repr);
  1602. }
  1603. void AArch64InstPrinter::printGPR64as32(const MCInst *MI, unsigned OpNum,
  1604. const MCSubtargetInfo &STI,
  1605. raw_ostream &O) {
  1606. unsigned Reg = MI->getOperand(OpNum).getReg();
  1607. O << getRegisterName(getWRegFromXReg(Reg));
  1608. }
  1609. void AArch64InstPrinter::printGPR64x8(const MCInst *MI, unsigned OpNum,
  1610. const MCSubtargetInfo &STI,
  1611. raw_ostream &O) {
  1612. unsigned Reg = MI->getOperand(OpNum).getReg();
  1613. O << getRegisterName(MRI.getSubReg(Reg, AArch64::x8sub_0));
  1614. }