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