ARMInstPrinter.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. //===- ARMInstPrinter.h - Convert ARM MCInst to assembly syntax -*- C++ -*-===//
  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 ARM MCInst to a .s file.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H
  13. #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H
  14. #include "MCTargetDesc/ARMMCTargetDesc.h"
  15. #include "llvm/MC/MCInstPrinter.h"
  16. namespace llvm {
  17. class ARMInstPrinter : public MCInstPrinter {
  18. public:
  19. ARMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
  20. const MCRegisterInfo &MRI);
  21. bool applyTargetSpecificCLOption(StringRef Opt) override;
  22. void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
  23. const MCSubtargetInfo &STI, raw_ostream &O) override;
  24. void printRegName(raw_ostream &OS, unsigned RegNo) const override;
  25. // Autogenerated by tblgen.
  26. std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
  27. void printInstruction(const MCInst *MI, uint64_t Address,
  28. const MCSubtargetInfo &STI, raw_ostream &O);
  29. virtual bool printAliasInstr(const MCInst *MI, uint64_t Address,
  30. const MCSubtargetInfo &STI, raw_ostream &O);
  31. virtual void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
  32. unsigned OpIdx, unsigned PrintMethodIdx,
  33. const MCSubtargetInfo &STI,
  34. raw_ostream &O);
  35. static const char *getRegisterName(unsigned RegNo,
  36. unsigned AltIdx = ARM::NoRegAltName);
  37. void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
  38. raw_ostream &O);
  39. void printOperand(const MCInst *MI, uint64_t Address, unsigned OpNum,
  40. const MCSubtargetInfo &STI, raw_ostream &O);
  41. void printSORegRegOperand(const MCInst *MI, unsigned OpNum,
  42. const MCSubtargetInfo &STI, raw_ostream &O);
  43. void printSORegImmOperand(const MCInst *MI, unsigned OpNum,
  44. const MCSubtargetInfo &STI, raw_ostream &O);
  45. void printAddrModeTBB(const MCInst *MI, unsigned OpNum,
  46. const MCSubtargetInfo &STI, raw_ostream &O);
  47. void printAddrModeTBH(const MCInst *MI, unsigned OpNum,
  48. const MCSubtargetInfo &STI, raw_ostream &O);
  49. void printAddrMode2Operand(const MCInst *MI, unsigned OpNum,
  50. const MCSubtargetInfo &STI, raw_ostream &O);
  51. void printAM2PostIndexOp(const MCInst *MI, unsigned OpNum,
  52. const MCSubtargetInfo &STI, raw_ostream &O);
  53. void printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned OpNum,
  54. const MCSubtargetInfo &STI, raw_ostream &O);
  55. void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum,
  56. const MCSubtargetInfo &STI, raw_ostream &O);
  57. template <bool AlwaysPrintImm0>
  58. void printAddrMode3Operand(const MCInst *MI, unsigned OpNum,
  59. const MCSubtargetInfo &STI, raw_ostream &O);
  60. void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum,
  61. const MCSubtargetInfo &STI, raw_ostream &O);
  62. void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O,
  63. bool AlwaysPrintImm0);
  64. void printPostIdxImm8Operand(const MCInst *MI, unsigned OpNum,
  65. const MCSubtargetInfo &STI, raw_ostream &O);
  66. void printPostIdxRegOperand(const MCInst *MI, unsigned OpNum,
  67. const MCSubtargetInfo &STI, raw_ostream &O);
  68. void printPostIdxImm8s4Operand(const MCInst *MI, unsigned OpNum,
  69. const MCSubtargetInfo &STI, raw_ostream &O);
  70. void printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
  71. const MCSubtargetInfo &STI, raw_ostream &O);
  72. template <bool AlwaysPrintImm0>
  73. void printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
  74. const MCSubtargetInfo &STI, raw_ostream &O);
  75. template <bool AlwaysPrintImm0>
  76. void printAddrMode5FP16Operand(const MCInst *MI, unsigned OpNum,
  77. const MCSubtargetInfo &STI, raw_ostream &O);
  78. void printAddrMode6Operand(const MCInst *MI, unsigned OpNum,
  79. const MCSubtargetInfo &STI, raw_ostream &O);
  80. void printAddrMode7Operand(const MCInst *MI, unsigned OpNum,
  81. const MCSubtargetInfo &STI, raw_ostream &O);
  82. void printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum,
  83. const MCSubtargetInfo &STI, raw_ostream &O);
  84. void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum,
  85. const MCSubtargetInfo &STI,
  86. raw_ostream &O);
  87. void printMemBOption(const MCInst *MI, unsigned OpNum,
  88. const MCSubtargetInfo &STI, raw_ostream &O);
  89. void printInstSyncBOption(const MCInst *MI, unsigned OpNum,
  90. const MCSubtargetInfo &STI, raw_ostream &O);
  91. void printTraceSyncBOption(const MCInst *MI, unsigned OpNum,
  92. const MCSubtargetInfo &STI, raw_ostream &O);
  93. void printShiftImmOperand(const MCInst *MI, unsigned OpNum,
  94. const MCSubtargetInfo &STI, raw_ostream &O);
  95. void printPKHLSLShiftImm(const MCInst *MI, unsigned OpNum,
  96. const MCSubtargetInfo &STI, raw_ostream &O);
  97. void printPKHASRShiftImm(const MCInst *MI, unsigned OpNum,
  98. const MCSubtargetInfo &STI, raw_ostream &O);
  99. template <unsigned scale>
  100. void printAdrLabelOperand(const MCInst *MI, unsigned OpNum,
  101. const MCSubtargetInfo &STI, raw_ostream &O);
  102. template <unsigned scale>
  103. void printAdrLabelOperand(const MCInst *MI, uint64_t /*Address*/,
  104. unsigned OpNum, const MCSubtargetInfo &STI,
  105. raw_ostream &O) {
  106. printAdrLabelOperand<scale>(MI, OpNum, STI, O);
  107. }
  108. void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum,
  109. const MCSubtargetInfo &STI, raw_ostream &O);
  110. void printThumbSRImm(const MCInst *MI, unsigned OpNum,
  111. const MCSubtargetInfo &STI, raw_ostream &O);
  112. void printThumbITMask(const MCInst *MI, unsigned OpNum,
  113. const MCSubtargetInfo &STI, raw_ostream &O);
  114. void printThumbAddrModeRROperand(const MCInst *MI, unsigned OpNum,
  115. const MCSubtargetInfo &STI, raw_ostream &O);
  116. void printThumbAddrModeImm5SOperand(const MCInst *MI, unsigned OpNum,
  117. const MCSubtargetInfo &STI,
  118. raw_ostream &O, unsigned Scale);
  119. void printThumbAddrModeImm5S1Operand(const MCInst *MI, unsigned OpNum,
  120. const MCSubtargetInfo &STI,
  121. raw_ostream &O);
  122. void printThumbAddrModeImm5S2Operand(const MCInst *MI, unsigned OpNum,
  123. const MCSubtargetInfo &STI,
  124. raw_ostream &O);
  125. void printThumbAddrModeImm5S4Operand(const MCInst *MI, unsigned OpNum,
  126. const MCSubtargetInfo &STI,
  127. raw_ostream &O);
  128. void printThumbAddrModeSPOperand(const MCInst *MI, unsigned OpNum,
  129. const MCSubtargetInfo &STI, raw_ostream &O);
  130. void printT2SOOperand(const MCInst *MI, unsigned OpNum,
  131. const MCSubtargetInfo &STI, raw_ostream &O);
  132. template <bool AlwaysPrintImm0>
  133. void printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
  134. const MCSubtargetInfo &STI, raw_ostream &O);
  135. template <bool AlwaysPrintImm0>
  136. void printT2AddrModeImm8Operand(const MCInst *MI, unsigned OpNum,
  137. const MCSubtargetInfo &STI, raw_ostream &O);
  138. template <bool AlwaysPrintImm0>
  139. void printT2AddrModeImm8s4Operand(const MCInst *MI, unsigned OpNum,
  140. const MCSubtargetInfo &STI, raw_ostream &O);
  141. void printT2AddrModeImm0_1020s4Operand(const MCInst *MI, unsigned OpNum,
  142. const MCSubtargetInfo &STI,
  143. raw_ostream &O);
  144. void printT2AddrModeImm8OffsetOperand(const MCInst *MI, unsigned OpNum,
  145. const MCSubtargetInfo &STI,
  146. raw_ostream &O);
  147. void printT2AddrModeImm8s4OffsetOperand(const MCInst *MI, unsigned OpNum,
  148. const MCSubtargetInfo &STI,
  149. raw_ostream &O);
  150. void printT2AddrModeSoRegOperand(const MCInst *MI, unsigned OpNum,
  151. const MCSubtargetInfo &STI, raw_ostream &O);
  152. void printSetendOperand(const MCInst *MI, unsigned OpNum,
  153. const MCSubtargetInfo &STI, raw_ostream &O);
  154. void printCPSIMod(const MCInst *MI, unsigned OpNum,
  155. const MCSubtargetInfo &STI, raw_ostream &O);
  156. void printCPSIFlag(const MCInst *MI, unsigned OpNum,
  157. const MCSubtargetInfo &STI, raw_ostream &O);
  158. void printMSRMaskOperand(const MCInst *MI, unsigned OpNum,
  159. const MCSubtargetInfo &STI, raw_ostream &O);
  160. void printBankedRegOperand(const MCInst *MI, unsigned OpNum,
  161. const MCSubtargetInfo &STI, raw_ostream &O);
  162. void printPredicateOperand(const MCInst *MI, unsigned OpNum,
  163. const MCSubtargetInfo &STI, raw_ostream &O);
  164. void printMandatoryPredicateOperand(const MCInst *MI, unsigned OpNum,
  165. const MCSubtargetInfo &STI,
  166. raw_ostream &O);
  167. void printMandatoryRestrictedPredicateOperand(const MCInst *MI,
  168. unsigned OpNum,
  169. const MCSubtargetInfo &STI,
  170. raw_ostream &O);
  171. void printMandatoryInvertedPredicateOperand(const MCInst *MI, unsigned OpNum,
  172. const MCSubtargetInfo &STI,
  173. raw_ostream &O);
  174. void printSBitModifierOperand(const MCInst *MI, unsigned OpNum,
  175. const MCSubtargetInfo &STI, raw_ostream &O);
  176. void printRegisterList(const MCInst *MI, unsigned OpNum,
  177. const MCSubtargetInfo &STI, raw_ostream &O);
  178. void printNoHashImmediate(const MCInst *MI, unsigned OpNum,
  179. const MCSubtargetInfo &STI, raw_ostream &O);
  180. void printPImmediate(const MCInst *MI, unsigned OpNum,
  181. const MCSubtargetInfo &STI, raw_ostream &O);
  182. void printCImmediate(const MCInst *MI, unsigned OpNum,
  183. const MCSubtargetInfo &STI, raw_ostream &O);
  184. void printCoprocOptionImm(const MCInst *MI, unsigned OpNum,
  185. const MCSubtargetInfo &STI, raw_ostream &O);
  186. void printFPImmOperand(const MCInst *MI, unsigned OpNum,
  187. const MCSubtargetInfo &STI, raw_ostream &O);
  188. void printVMOVModImmOperand(const MCInst *MI, unsigned OpNum,
  189. const MCSubtargetInfo &STI, raw_ostream &O);
  190. void printImmPlusOneOperand(const MCInst *MI, unsigned OpNum,
  191. const MCSubtargetInfo &STI, raw_ostream &O);
  192. void printRotImmOperand(const MCInst *MI, unsigned OpNum,
  193. const MCSubtargetInfo &STI, raw_ostream &O);
  194. void printModImmOperand(const MCInst *MI, unsigned OpNum,
  195. const MCSubtargetInfo &STI, raw_ostream &O);
  196. void printGPRPairOperand(const MCInst *MI, unsigned OpNum,
  197. const MCSubtargetInfo &STI, raw_ostream &O);
  198. void printPCLabel(const MCInst *MI, unsigned OpNum,
  199. const MCSubtargetInfo &STI, raw_ostream &O);
  200. void printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
  201. const MCSubtargetInfo &STI, raw_ostream &O);
  202. void printThumbLdrLabelOperand(const MCInst *MI, uint64_t /*Address*/,
  203. unsigned OpNum, const MCSubtargetInfo &STI,
  204. raw_ostream &O) {
  205. printThumbLdrLabelOperand(MI, OpNum, STI, O);
  206. }
  207. void printFBits16(const MCInst *MI, unsigned OpNum,
  208. const MCSubtargetInfo &STI, raw_ostream &O);
  209. void printFBits32(const MCInst *MI, unsigned OpNum,
  210. const MCSubtargetInfo &STI, raw_ostream &O);
  211. void printVectorIndex(const MCInst *MI, unsigned OpNum,
  212. const MCSubtargetInfo &STI, raw_ostream &O);
  213. void printVectorListOne(const MCInst *MI, unsigned OpNum,
  214. const MCSubtargetInfo &STI, raw_ostream &O);
  215. void printVectorListTwo(const MCInst *MI, unsigned OpNum,
  216. const MCSubtargetInfo &STI, raw_ostream &O);
  217. void printVectorListTwoSpaced(const MCInst *MI, unsigned OpNum,
  218. const MCSubtargetInfo &STI, raw_ostream &O);
  219. void printVectorListThree(const MCInst *MI, unsigned OpNum,
  220. const MCSubtargetInfo &STI, raw_ostream &O);
  221. void printVectorListFour(const MCInst *MI, unsigned OpNum,
  222. const MCSubtargetInfo &STI, raw_ostream &O);
  223. void printVectorListOneAllLanes(const MCInst *MI, unsigned OpNum,
  224. const MCSubtargetInfo &STI, raw_ostream &O);
  225. void printVectorListTwoAllLanes(const MCInst *MI, unsigned OpNum,
  226. const MCSubtargetInfo &STI, raw_ostream &O);
  227. void printVectorListThreeAllLanes(const MCInst *MI, unsigned OpNum,
  228. const MCSubtargetInfo &STI, raw_ostream &O);
  229. void printVectorListFourAllLanes(const MCInst *MI, unsigned OpNum,
  230. const MCSubtargetInfo &STI, raw_ostream &O);
  231. void printVectorListTwoSpacedAllLanes(const MCInst *MI, unsigned OpNum,
  232. const MCSubtargetInfo &STI,
  233. raw_ostream &O);
  234. void printVectorListThreeSpacedAllLanes(const MCInst *MI, unsigned OpNum,
  235. const MCSubtargetInfo &STI,
  236. raw_ostream &O);
  237. void printVectorListFourSpacedAllLanes(const MCInst *MI, unsigned OpNum,
  238. const MCSubtargetInfo &STI,
  239. raw_ostream &O);
  240. void printVectorListThreeSpaced(const MCInst *MI, unsigned OpNum,
  241. const MCSubtargetInfo &STI, raw_ostream &O);
  242. void printVectorListFourSpaced(const MCInst *MI, unsigned OpNum,
  243. const MCSubtargetInfo &STI, raw_ostream &O);
  244. template<unsigned NumRegs>
  245. void printMVEVectorList(const MCInst *MI, unsigned OpNum,
  246. const MCSubtargetInfo &STI, raw_ostream &O);
  247. template<int64_t Angle, int64_t Remainder>
  248. void printComplexRotationOp(const MCInst *MI, unsigned OpNum,
  249. const MCSubtargetInfo &STI, raw_ostream &O);
  250. // MVE
  251. void printVPTPredicateOperand(const MCInst *MI, unsigned OpNum,
  252. const MCSubtargetInfo &STI,
  253. raw_ostream &O);
  254. void printVPTMask(const MCInst *MI, unsigned OpNum,
  255. const MCSubtargetInfo &STI, raw_ostream &O);
  256. template<int shift>
  257. void printMveAddrModeRQOperand(const MCInst *MI, unsigned OpNum,
  258. const MCSubtargetInfo &STI, raw_ostream &O);
  259. void printMveSaturateOp(const MCInst *MI, unsigned OpNum,
  260. const MCSubtargetInfo &STI, raw_ostream &O);
  261. private:
  262. unsigned DefaultAltIdx = ARM::NoRegAltName;
  263. };
  264. } // end namespace llvm
  265. #endif // LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMINSTPRINTER_H