1 //===-- AArch64InstPrinter.h - Convert AArch64 MCInst to assembly syntax --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class prints an AArch64 MCInst to a .s file.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
15 #define LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
17 #include "MCTargetDesc/AArch64MCTargetDesc.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/MCInstPrinter.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
26 class AArch64InstPrinter : public MCInstPrinter {
28 AArch64InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
29 const MCRegisterInfo &MRI, const MCSubtargetInfo &STI);
31 void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
32 const MCSubtargetInfo &STI) override;
33 void printRegName(raw_ostream &OS, unsigned RegNo) const override;
35 // Autogenerated by tblgen.
36 virtual void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
38 virtual bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
40 virtual void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
41 unsigned PrintMethodIdx,
42 const MCSubtargetInfo &STI,
44 virtual StringRef getRegName(unsigned RegNo) const {
45 return getRegisterName(RegNo);
47 static const char *getRegisterName(unsigned RegNo,
48 unsigned AltIdx = AArch64::NoRegAltName);
51 bool printSysAlias(const MCInst *MI, raw_ostream &O);
53 void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
55 void printHexImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
57 void printPostIncOperand(const MCInst *MI, unsigned OpNo, unsigned Imm,
60 void printPostIncOperand(const MCInst *MI, unsigned OpNo,
61 const MCSubtargetInfo &STI, raw_ostream &O) {
62 printPostIncOperand(MI, OpNo, Amount, O);
65 void printVRegOperand(const MCInst *MI, unsigned OpNo,
66 const MCSubtargetInfo &STI, raw_ostream &O);
67 void printSysCROperand(const MCInst *MI, unsigned OpNo,
68 const MCSubtargetInfo &STI, raw_ostream &O);
69 void printAddSubImm(const MCInst *MI, unsigned OpNum,
70 const MCSubtargetInfo &STI, raw_ostream &O);
71 void printLogicalImm32(const MCInst *MI, unsigned OpNum,
72 const MCSubtargetInfo &STI, raw_ostream &O);
73 void printLogicalImm64(const MCInst *MI, unsigned OpNum,
74 const MCSubtargetInfo &STI, raw_ostream &O);
75 void printShifter(const MCInst *MI, unsigned OpNum,
76 const MCSubtargetInfo &STI, raw_ostream &O);
77 void printShiftedRegister(const MCInst *MI, unsigned OpNum,
78 const MCSubtargetInfo &STI, raw_ostream &O);
79 void printExtendedRegister(const MCInst *MI, unsigned OpNum,
80 const MCSubtargetInfo &STI, raw_ostream &O);
81 void printArithExtend(const MCInst *MI, unsigned OpNum,
82 const MCSubtargetInfo &STI, raw_ostream &O);
84 void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O,
85 char SrcRegKind, unsigned Width);
86 template <char SrcRegKind, unsigned Width>
87 void printMemExtend(const MCInst *MI, unsigned OpNum,
88 const MCSubtargetInfo &STI, raw_ostream &O) {
89 printMemExtend(MI, OpNum, O, SrcRegKind, Width);
92 void printCondCode(const MCInst *MI, unsigned OpNum,
93 const MCSubtargetInfo &STI, raw_ostream &O);
94 void printInverseCondCode(const MCInst *MI, unsigned OpNum,
95 const MCSubtargetInfo &STI, raw_ostream &O);
96 void printAlignedLabel(const MCInst *MI, unsigned OpNum,
97 const MCSubtargetInfo &STI, raw_ostream &O);
98 void printUImm12Offset(const MCInst *MI, unsigned OpNum, unsigned Scale,
100 void printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale,
104 void printUImm12Offset(const MCInst *MI, unsigned OpNum,
105 const MCSubtargetInfo &STI, raw_ostream &O) {
106 printUImm12Offset(MI, OpNum, Scale, O);
109 template <int BitWidth>
110 void printAMIndexedWB(const MCInst *MI, unsigned OpNum,
111 const MCSubtargetInfo &STI, raw_ostream &O) {
112 printAMIndexedWB(MI, OpNum, BitWidth / 8, O);
115 void printAMNoIndex(const MCInst *MI, unsigned OpNum,
116 const MCSubtargetInfo &STI, raw_ostream &O);
119 void printImmScale(const MCInst *MI, unsigned OpNum,
120 const MCSubtargetInfo &STI, raw_ostream &O);
122 void printPrefetchOp(const MCInst *MI, unsigned OpNum,
123 const MCSubtargetInfo &STI, raw_ostream &O);
125 void printFPImmOperand(const MCInst *MI, unsigned OpNum,
126 const MCSubtargetInfo &STI, raw_ostream &O);
128 void printVectorList(const MCInst *MI, unsigned OpNum,
129 const MCSubtargetInfo &STI, raw_ostream &O,
130 StringRef LayoutSuffix);
132 /// Print a list of vector registers where the type suffix is implicit
133 /// (i.e. attached to the instruction rather than the registers).
134 void printImplicitlyTypedVectorList(const MCInst *MI, unsigned OpNum,
135 const MCSubtargetInfo &STI,
138 template <unsigned NumLanes, char LaneKind>
139 void printTypedVectorList(const MCInst *MI, unsigned OpNum,
140 const MCSubtargetInfo &STI, raw_ostream &O);
142 void printVectorIndex(const MCInst *MI, unsigned OpNum,
143 const MCSubtargetInfo &STI, raw_ostream &O);
144 void printAdrpLabel(const MCInst *MI, unsigned OpNum,
145 const MCSubtargetInfo &STI, raw_ostream &O);
146 void printBarrierOption(const MCInst *MI, unsigned OpNum,
147 const MCSubtargetInfo &STI, raw_ostream &O);
148 void printMSRSystemRegister(const MCInst *MI, unsigned OpNum,
149 const MCSubtargetInfo &STI, raw_ostream &O);
150 void printMRSSystemRegister(const MCInst *MI, unsigned OpNum,
151 const MCSubtargetInfo &STI, raw_ostream &O);
152 void printSystemPStateField(const MCInst *MI, unsigned OpNum,
153 const MCSubtargetInfo &STI, raw_ostream &O);
154 void printSIMDType10Operand(const MCInst *MI, unsigned OpNum,
155 const MCSubtargetInfo &STI, raw_ostream &O);
158 class AArch64AppleInstPrinter : public AArch64InstPrinter {
160 AArch64AppleInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
161 const MCRegisterInfo &MRI,
162 const MCSubtargetInfo &STI);
164 void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
165 const MCSubtargetInfo &STI) override;
167 void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
168 raw_ostream &O) override;
169 bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
170 raw_ostream &O) override;
171 void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
172 unsigned PrintMethodIdx,
173 const MCSubtargetInfo &STI,
174 raw_ostream &O) override;
175 StringRef getRegName(unsigned RegNo) const override {
176 return getRegisterName(RegNo);
178 static const char *getRegisterName(unsigned RegNo,
179 unsigned AltIdx = AArch64::NoRegAltName);