61eb14e036d0d286df34d032f50a38acb7507d62
[oota-llvm.git] / lib / Target / X86 / X86AsmPrinter.h
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:
32   explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
33     : AsmPrinter(TM, Streamer) {
34     Subtarget = &TM.getSubtarget<X86Subtarget>();
35   }
36
37   virtual const char *getPassName() const LLVM_OVERRIDE {
38     return "X86 AT&T-Style Assembly Printer";
39   }
40
41   const X86Subtarget &getSubtarget() const { return *Subtarget; }
42
43   virtual void EmitStartOfAsmFile(Module &M) LLVM_OVERRIDE;
44
45   virtual void EmitEndOfAsmFile(Module &M) LLVM_OVERRIDE;
46
47   virtual void EmitInstruction(const MachineInstr *MI) LLVM_OVERRIDE;
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 printPCRelImm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
55
56   bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
57   virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
58                                unsigned AsmVariant, const char *ExtraCode,
59                                raw_ostream &OS) LLVM_OVERRIDE;
60   virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
61                                      unsigned AsmVariant, const char *ExtraCode,
62                                      raw_ostream &OS) LLVM_OVERRIDE;
63
64   void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
65                          const char *Modifier=NULL);
66   void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
67                             const char *Modifier=NULL);
68
69   void printIntelMemReference(const MachineInstr *MI, unsigned Op,
70                               raw_ostream &O, const char *Modifier=NULL,
71                               unsigned AsmVariant = 1);
72
73   virtual bool runOnMachineFunction(MachineFunction &F) LLVM_OVERRIDE;
74
75   void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
76
77   virtual MachineLocation
78     getDebugValueLocation(const MachineInstr *MI) const LLVM_OVERRIDE;
79 };
80
81 } // end namespace llvm
82
83 #endif