LLVM API Documentation
00001 //===-- AArch64InstPrinter.h - Convert AArch64 MCInst to assembly syntax --===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This class prints an AArch64 MCInst to a .s file. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H 00015 #define LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H 00016 00017 #include "MCTargetDesc/AArch64MCTargetDesc.h" 00018 #include "llvm/ADT/StringRef.h" 00019 #include "llvm/MC/MCInstPrinter.h" 00020 #include "llvm/MC/MCSubtargetInfo.h" 00021 00022 namespace llvm { 00023 00024 class MCOperand; 00025 00026 class AArch64InstPrinter : public MCInstPrinter { 00027 public: 00028 AArch64InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 00029 const MCRegisterInfo &MRI, const MCSubtargetInfo &STI); 00030 00031 void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot) override; 00032 void printRegName(raw_ostream &OS, unsigned RegNo) const override; 00033 00034 // Autogenerated by tblgen. 00035 virtual void printInstruction(const MCInst *MI, raw_ostream &O); 00036 virtual bool printAliasInstr(const MCInst *MI, raw_ostream &O); 00037 virtual void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx, 00038 unsigned PrintMethodIdx, raw_ostream &O); 00039 virtual StringRef getRegName(unsigned RegNo) const { 00040 return getRegisterName(RegNo); 00041 } 00042 static const char *getRegisterName(unsigned RegNo, 00043 unsigned AltIdx = AArch64::NoRegAltName); 00044 00045 protected: 00046 bool printSysAlias(const MCInst *MI, raw_ostream &O); 00047 // Operand printers 00048 void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); 00049 void printHexImm(const MCInst *MI, unsigned OpNo, raw_ostream &O); 00050 void printPostIncOperand(const MCInst *MI, unsigned OpNo, unsigned Imm, 00051 raw_ostream &O); 00052 template<int Amount> 00053 void printPostIncOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { 00054 printPostIncOperand(MI, OpNo, Amount, O); 00055 } 00056 00057 void printVRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); 00058 void printSysCROperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); 00059 void printAddSubImm(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00060 void printLogicalImm32(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00061 void printLogicalImm64(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00062 void printShifter(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00063 void printShiftedRegister(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00064 void printExtendedRegister(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00065 void printArithExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00066 00067 void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O, 00068 char SrcRegKind, unsigned Width); 00069 template <char SrcRegKind, unsigned Width> 00070 void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O) { 00071 printMemExtend(MI, OpNum, O, SrcRegKind, Width); 00072 } 00073 00074 void printCondCode(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00075 void printInverseCondCode(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00076 void printAlignedLabel(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00077 void printUImm12Offset(const MCInst *MI, unsigned OpNum, unsigned Scale, 00078 raw_ostream &O); 00079 void printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale, 00080 raw_ostream &O); 00081 00082 template<int Scale> 00083 void printUImm12Offset(const MCInst *MI, unsigned OpNum, raw_ostream &O) { 00084 printUImm12Offset(MI, OpNum, Scale, O); 00085 } 00086 00087 template<int BitWidth> 00088 void printAMIndexedWB(const MCInst *MI, unsigned OpNum, raw_ostream &O) { 00089 printAMIndexedWB(MI, OpNum, BitWidth / 8, O); 00090 } 00091 00092 void printAMNoIndex(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00093 00094 template<int Scale> 00095 void printImmScale(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00096 00097 void printPrefetchOp(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00098 00099 void printFPImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00100 00101 void printVectorList(const MCInst *MI, unsigned OpNum, raw_ostream &O, 00102 StringRef LayoutSuffix); 00103 00104 /// Print a list of vector registers where the type suffix is implicit 00105 /// (i.e. attached to the instruction rather than the registers). 00106 void printImplicitlyTypedVectorList(const MCInst *MI, unsigned OpNum, 00107 raw_ostream &O); 00108 00109 template <unsigned NumLanes, char LaneKind> 00110 void printTypedVectorList(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00111 00112 void printVectorIndex(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00113 void printAdrpLabel(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00114 void printBarrierOption(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00115 void printMSRSystemRegister(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00116 void printMRSSystemRegister(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00117 void printSystemPStateField(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00118 void printSIMDType10Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O); 00119 }; 00120 00121 class AArch64AppleInstPrinter : public AArch64InstPrinter { 00122 public: 00123 AArch64AppleInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 00124 const MCRegisterInfo &MRI, const MCSubtargetInfo &STI); 00125 00126 void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot) override; 00127 00128 void printInstruction(const MCInst *MI, raw_ostream &O) override; 00129 bool printAliasInstr(const MCInst *MI, raw_ostream &O) override; 00130 void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx, 00131 unsigned PrintMethodIdx, 00132 raw_ostream &O) override; 00133 StringRef getRegName(unsigned RegNo) const override { 00134 return getRegisterName(RegNo); 00135 } 00136 static const char *getRegisterName(unsigned RegNo, 00137 unsigned AltIdx = AArch64::NoRegAltName); 00138 }; 00139 } 00140 00141 #endif