1 // AArch64AsmPrinter.h - Print machine code to an AArch64 .s file -*- C++ -*-=// 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 file defines the AArch64 assembly printer class. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_AARCH64ASMPRINTER_H 15 #define LLVM_AARCH64ASMPRINTER_H 16 17 #include "AArch64.h" 18 #include "AArch64TargetMachine.h" 19 #include "llvm/CodeGen/AsmPrinter.h" 20 #include "llvm/MC/MCStreamer.h" 21 #include "llvm/Support/Compiler.h" 22 23 namespace llvm { 24 25 class MCOperand; 26 27 class LLVM_LIBRARY_VISIBILITY AArch64AsmPrinter : public AsmPrinter { 28 29 /// Subtarget - Keep a pointer to the AArch64Subtarget around so that we can 30 /// make the right decision when printing asm code for different targets. 31 const AArch64Subtarget *Subtarget; 32 33 // emitPseudoExpansionLowering - tblgen'erated. 34 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, 35 const MachineInstr *MI); 36 37 public: 38 explicit AArch64AsmPrinter(TargetMachine &TM, MCStreamer &Streamer) 39 : AsmPrinter(TM, Streamer) { 40 Subtarget = &TM.getSubtarget<AArch64Subtarget>(); 41 } 42 43 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const; 44 45 MCOperand lowerSymbolOperand(const MachineOperand &MO, 46 const MCSymbol *Sym) const; 47 48 void EmitInstruction(const MachineInstr *MI); 49 void EmitEndOfAsmFile(Module &M); 50 51 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, 52 unsigned AsmVariant, const char *ExtraCode, 53 raw_ostream &O); 54 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, 55 unsigned AsmVariant, const char *ExtraCode, 56 raw_ostream &O); 57 58 /// printSymbolicAddress - Given some kind of reasonably bare symbolic 59 /// reference, print out the appropriate asm string to represent it. If 60 /// appropriate, a relocation-specifier will be produced, composed of a 61 /// general class derived from the MO parameter and an instruction-specific 62 /// suffix, provided in Suffix. E.g. ":got_lo12:" if a Suffix of "lo12" is 63 /// given. 64 bool printSymbolicAddress(const MachineOperand &MO, 65 bool PrintImmediatePrefix, 66 StringRef Suffix, raw_ostream &O); 67 68 virtual const char *getPassName() const { 69 return "AArch64 Assembly Printer"; 70 } 71 72 virtual bool runOnMachineFunction(MachineFunction &MF); 73 }; 74 } // end namespace llvm 75 76 #endif 77