1 //===-- X86AsmPrinter.h - Convert X86 LLVM code to assembly -----*- 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 // AT&T assembly code printer class. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef X86ASMPRINTER_H 15 #define X86ASMPRINTER_H 16 17 #include "X86.h" 18 #include "X86MachineFunctionInfo.h" 19 #include "X86TargetMachine.h" 20 #include "llvm/CodeGen/AsmPrinter.h" 21 #include "llvm/CodeGen/MachineModuleInfo.h" 22 #include "llvm/CodeGen/ValueTypes.h" 23 #include "llvm/Support/Compiler.h" 24 25 namespace llvm { 26 27 class MCStreamer; 28 29 class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter { 30 const X86Subtarget *Subtarget; 31 public: X86AsmPrinter(TargetMachine & TM,MCStreamer & Streamer)32 explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer) 33 : AsmPrinter(TM, Streamer) { 34 Subtarget = &TM.getSubtarget<X86Subtarget>(); 35 } 36 getPassName()37 virtual const char *getPassName() const { 38 return "X86 AT&T-Style Assembly Printer"; 39 } 40 getSubtarget()41 const X86Subtarget &getSubtarget() const { return *Subtarget; } 42 43 virtual void EmitStartOfAsmFile(Module &M); 44 45 virtual void EmitEndOfAsmFile(Module &M); 46 47 virtual void EmitInstruction(const MachineInstr *MI); 48 49 void printSymbolOperand(const MachineOperand &MO, raw_ostream &O); 50 51 // These methods are used by the tablegen'erated instruction printer. 52 void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O, 53 const char *Modifier = 0, unsigned AsmVariant = 0); 54 void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O); 55 56 bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O); 57 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, 58 unsigned AsmVariant, const char *ExtraCode, 59 raw_ostream &OS); 60 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, 61 unsigned AsmVariant, const char *ExtraCode, 62 raw_ostream &OS); 63 64 void printMachineInstruction(const MachineInstr *MI); 65 void printSSECC(const MachineInstr *MI, unsigned Op, raw_ostream &O); 66 void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O, 67 const char *Modifier=NULL); 68 void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O, 69 const char *Modifier=NULL); 70 71 void printPICLabel(const MachineInstr *MI, unsigned Op, raw_ostream &O); 72 73 bool runOnMachineFunction(MachineFunction &F); 74 75 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); 76 77 MachineLocation getDebugValueLocation(const MachineInstr *MI) const; 78 }; 79 80 } // end namespace llvm 81 82 #endif 83