LLVM  8.0.1
AArch64InstPrinter.h
Go to the documentation of this file.
1 //===-- AArch64InstPrinter.h - Convert AArch64 MCInst to assembly syntax --===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class prints an AArch64 MCInst to a .s file.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
15 #define LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
16 
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/MCInstPrinter.h"
20 #include "../Utils/AArch64BaseInfo.h"
21 
22 namespace llvm {
23 
25 public:
27  const MCRegisterInfo &MRI);
28 
29  void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
30  const MCSubtargetInfo &STI) override;
31  void printRegName(raw_ostream &OS, unsigned RegNo) const override;
32 
33  // Autogenerated by tblgen.
34  virtual void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
35  raw_ostream &O);
36  virtual bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
37  raw_ostream &O);
38  virtual void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
39  unsigned PrintMethodIdx,
40  const MCSubtargetInfo &STI,
41  raw_ostream &O);
42 
43  virtual StringRef getRegName(unsigned RegNo) const {
44  return getRegisterName(RegNo);
45  }
46 
47  static const char *getRegisterName(unsigned RegNo,
48  unsigned AltIdx = AArch64::NoRegAltName);
49 
50 protected:
51  bool printSysAlias(const MCInst *MI, const MCSubtargetInfo &STI,
52  raw_ostream &O);
53  // Operand printers
54  void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
55  raw_ostream &O);
56  void printImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
57  raw_ostream &O);
58  void printImmHex(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
59  raw_ostream &O);
60  template <typename T> void printImmSVE(T Value, raw_ostream &O);
61  void printPostIncOperand(const MCInst *MI, unsigned OpNo, unsigned Imm,
62  raw_ostream &O);
63  template <int Amount>
64  void printPostIncOperand(const MCInst *MI, unsigned OpNo,
65  const MCSubtargetInfo &STI, raw_ostream &O) {
66  printPostIncOperand(MI, OpNo, Amount, O);
67  }
68 
69  void printVRegOperand(const MCInst *MI, unsigned OpNo,
70  const MCSubtargetInfo &STI, raw_ostream &O);
71  void printSysCROperand(const MCInst *MI, unsigned OpNo,
72  const MCSubtargetInfo &STI, raw_ostream &O);
73  void printAddSubImm(const MCInst *MI, unsigned OpNum,
74  const MCSubtargetInfo &STI, raw_ostream &O);
75  template <typename T>
76  void printLogicalImm(const MCInst *MI, unsigned OpNum,
77  const MCSubtargetInfo &STI, raw_ostream &O);
78  void printShifter(const MCInst *MI, unsigned OpNum,
79  const MCSubtargetInfo &STI, raw_ostream &O);
80  void printShiftedRegister(const MCInst *MI, unsigned OpNum,
81  const MCSubtargetInfo &STI, raw_ostream &O);
82  void printExtendedRegister(const MCInst *MI, unsigned OpNum,
83  const MCSubtargetInfo &STI, raw_ostream &O);
84  void printArithExtend(const MCInst *MI, unsigned OpNum,
85  const MCSubtargetInfo &STI, raw_ostream &O);
86 
87  void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O,
88  char SrcRegKind, unsigned Width);
89  template <char SrcRegKind, unsigned Width>
90  void printMemExtend(const MCInst *MI, unsigned OpNum,
91  const MCSubtargetInfo &STI, raw_ostream &O) {
92  printMemExtend(MI, OpNum, O, SrcRegKind, Width);
93  }
94  template <bool SignedExtend, int ExtWidth, char SrcRegKind, char Suffix>
95  void printRegWithShiftExtend(const MCInst *MI, unsigned OpNum,
96  const MCSubtargetInfo &STI, raw_ostream &O);
97  void printCondCode(const MCInst *MI, unsigned OpNum,
98  const MCSubtargetInfo &STI, raw_ostream &O);
99  void printInverseCondCode(const MCInst *MI, unsigned OpNum,
100  const MCSubtargetInfo &STI, raw_ostream &O);
101  void printAlignedLabel(const MCInst *MI, unsigned OpNum,
102  const MCSubtargetInfo &STI, raw_ostream &O);
103  void printUImm12Offset(const MCInst *MI, unsigned OpNum, unsigned Scale,
104  raw_ostream &O);
105  void printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale,
106  raw_ostream &O);
107 
108  template <int Scale>
109  void printUImm12Offset(const MCInst *MI, unsigned OpNum,
110  const MCSubtargetInfo &STI, raw_ostream &O) {
111  printUImm12Offset(MI, OpNum, Scale, O);
112  }
113 
114  template <int BitWidth>
115  void printAMIndexedWB(const MCInst *MI, unsigned OpNum,
116  const MCSubtargetInfo &STI, raw_ostream &O) {
117  printAMIndexedWB(MI, OpNum, BitWidth / 8, O);
118  }
119 
120  void printAMNoIndex(const MCInst *MI, unsigned OpNum,
121  const MCSubtargetInfo &STI, raw_ostream &O);
122 
123  template <int Scale>
124  void printImmScale(const MCInst *MI, unsigned OpNum,
125  const MCSubtargetInfo &STI, raw_ostream &O);
126 
127  template <bool IsSVEPrefetch = false>
128  void printPrefetchOp(const MCInst *MI, unsigned OpNum,
129  const MCSubtargetInfo &STI, raw_ostream &O);
130 
131  void printPSBHintOp(const MCInst *MI, unsigned OpNum,
132  const MCSubtargetInfo &STI, raw_ostream &O);
133 
134  void printBTIHintOp(const MCInst *MI, unsigned OpNum,
135  const MCSubtargetInfo &STI, raw_ostream &O);
136 
137  void printFPImmOperand(const MCInst *MI, unsigned OpNum,
138  const MCSubtargetInfo &STI, raw_ostream &O);
139 
140  void printVectorList(const MCInst *MI, unsigned OpNum,
141  const MCSubtargetInfo &STI, raw_ostream &O,
142  StringRef LayoutSuffix);
143 
144  /// Print a list of vector registers where the type suffix is implicit
145  /// (i.e. attached to the instruction rather than the registers).
146  void printImplicitlyTypedVectorList(const MCInst *MI, unsigned OpNum,
147  const MCSubtargetInfo &STI,
148  raw_ostream &O);
149 
150  template <unsigned NumLanes, char LaneKind>
151  void printTypedVectorList(const MCInst *MI, unsigned OpNum,
152  const MCSubtargetInfo &STI, raw_ostream &O);
153 
154  void printVectorIndex(const MCInst *MI, unsigned OpNum,
155  const MCSubtargetInfo &STI, raw_ostream &O);
156  void printAdrpLabel(const MCInst *MI, unsigned OpNum,
157  const MCSubtargetInfo &STI, raw_ostream &O);
158  void printBarrierOption(const MCInst *MI, unsigned OpNum,
159  const MCSubtargetInfo &STI, raw_ostream &O);
160  void printMSRSystemRegister(const MCInst *MI, unsigned OpNum,
161  const MCSubtargetInfo &STI, raw_ostream &O);
162  void printMRSSystemRegister(const MCInst *MI, unsigned OpNum,
163  const MCSubtargetInfo &STI, raw_ostream &O);
164  void printSystemPStateField(const MCInst *MI, unsigned OpNum,
165  const MCSubtargetInfo &STI, raw_ostream &O);
166  void printSIMDType10Operand(const MCInst *MI, unsigned OpNum,
167  const MCSubtargetInfo &STI, raw_ostream &O);
168  template<int64_t Angle, int64_t Remainder>
169  void printComplexRotationOp(const MCInst *MI, unsigned OpNo,
170  const MCSubtargetInfo &STI, raw_ostream &O);
171  template<unsigned size>
172  void printGPRSeqPairsClassOperand(const MCInst *MI, unsigned OpNum,
173  const MCSubtargetInfo &STI,
174  raw_ostream &O);
175  template <typename T>
176  void printImm8OptLsl(const MCInst *MI, unsigned OpNum,
177  const MCSubtargetInfo &STI, raw_ostream &O);
178  template <typename T>
179  void printSVELogicalImm(const MCInst *MI, unsigned OpNum,
180  const MCSubtargetInfo &STI, raw_ostream &O);
181  void printSVEPattern(const MCInst *MI, unsigned OpNum,
182  const MCSubtargetInfo &STI, raw_ostream &O);
183  template <char = 0>
184  void printSVERegOp(const MCInst *MI, unsigned OpNum,
185  const MCSubtargetInfo &STI, raw_ostream &O);
186  void printGPR64as32(const MCInst *MI, unsigned OpNum,
187  const MCSubtargetInfo &STI, raw_ostream &O);
188  template <int Width>
189  void printZPRasFPR(const MCInst *MI, unsigned OpNum,
190  const MCSubtargetInfo &STI, raw_ostream &O);
191  template <unsigned ImmIs0, unsigned ImmIs1>
192  void printExactFPImm(const MCInst *MI, unsigned OpNum,
193  const MCSubtargetInfo &STI, raw_ostream &O);
194 };
195 
197 public:
199  const MCRegisterInfo &MRI);
200 
201  void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
202  const MCSubtargetInfo &STI) override;
203 
204  void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
205  raw_ostream &O) override;
206  bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
207  raw_ostream &O) override;
208  void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
209  unsigned PrintMethodIdx,
210  const MCSubtargetInfo &STI,
211  raw_ostream &O) override;
212 
213  StringRef getRegName(unsigned RegNo) const override {
214  return getRegisterName(RegNo);
215  }
216 
217  static const char *getRegisterName(unsigned RegNo,
218  unsigned AltIdx = AArch64::NoRegAltName);
219 };
220 
221 } // end namespace llvm
222 
223 #endif // LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
void printImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale, raw_ostream &O)
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
void printShifter(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printVectorIndex(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
static const char * getRegisterName(unsigned RegNo, unsigned AltIdx=AArch64::NoRegAltName)
void printSysCROperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void printSystemPStateField(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printMemExtend(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printImmHex(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printFPImmOperand(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printGPRSeqPairsClassOperand(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O, char SrcRegKind, unsigned Width)
void printSVELogicalImm(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printUImm12Offset(const MCInst *MI, unsigned OpNum, unsigned Scale, raw_ostream &O)
StringRef getRegName(unsigned RegNo) const override
void printImplicitlyTypedVectorList(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
Print a list of vector registers where the type suffix is implicit (i.e.
void printAMIndexedWB(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printSVERegOp(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printPrefetchOp(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printVRegOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printGPR64as32(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printInverseCondCode(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
AArch64InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
void printAlignedLabel(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printImm8OptLsl(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
void printImmSVE(T Value, raw_ostream &O)
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void printLogicalImm(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
virtual StringRef getRegName(unsigned RegNo) const
void printPSBHintOp(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printBTIHintOp(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
virtual void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx, unsigned PrintMethodIdx, const MCSubtargetInfo &STI, raw_ostream &O)
void printSIMDType10Operand(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printArithExtend(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printMSRSystemRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printAdrpLabel(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printPostIncOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printPostIncOperand(const MCInst *MI, unsigned OpNo, unsigned Imm, raw_ostream &O)
void printBarrierOption(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printSVEPattern(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printAMNoIndex(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printZPRasFPR(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printMRSSystemRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printComplexRotationOp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printTypedVectorList(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printShiftedRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
virtual void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI, raw_ostream &O)
const MCAsmInfo & MAI
Definition: MCInstPrinter.h:46
void printExtendedRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printExactFPImm(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printVectorList(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O, StringRef LayoutSuffix)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:40
void printAddSubImm(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
virtual bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI, raw_ostream &O)
void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegWithShiftExtend(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
Generic base class for all target subtargets.
const MCInstrInfo & MII
Definition: MCInstPrinter.h:47
LLVM Value Representation.
Definition: Value.h:73
void printUImm12Offset(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
void printImmScale(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool printSysAlias(const MCInst *MI, const MCSubtargetInfo &STI, raw_ostream &O)
const MCRegisterInfo & MRI
Definition: MCInstPrinter.h:48
void printCondCode(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O)