Move getJTISymbol from MachineJumpTableInfo to MachineFunction,
[oota-llvm.git] / lib / Target / X86 / AsmPrinter / 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/ADT/StringSet.h"
21 #include "llvm/CodeGen/AsmPrinter.h"
22 #include "llvm/CodeGen/DwarfWriter.h"
23 #include "llvm/CodeGen/MachineModuleInfo.h"
24 #include "llvm/CodeGen/ValueTypes.h"
25 #include "llvm/Support/Compiler.h"
26
27 namespace llvm {
28
29 class MachineJumpTableInfo;
30 class MCContext;
31 class MCInst;
32 class MCStreamer;
33 class MCSymbol;
34
35 class VISIBILITY_HIDDEN X86AsmPrinter : public AsmPrinter {
36   const X86Subtarget *Subtarget;
37  public:
38   explicit X86AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
39                             const MCAsmInfo *T, bool V)
40     : AsmPrinter(O, TM, T, V) {
41     Subtarget = &TM.getSubtarget<X86Subtarget>();
42   }
43
44   virtual const char *getPassName() const {
45     return "X86 AT&T-Style Assembly Printer";
46   }
47   
48   const X86Subtarget &getSubtarget() const { return *Subtarget; }
49
50   void getAnalysisUsage(AnalysisUsage &AU) const {
51     AU.setPreservesAll();
52     AU.addRequired<MachineModuleInfo>();
53     AU.addRequired<DwarfWriter>();
54     AsmPrinter::getAnalysisUsage(AU);
55   }
56
57   
58   virtual void EmitEndOfAsmFile(Module &M);
59   
60   void printInstructionThroughMCStreamer(const MachineInstr *MI);
61
62
63   void printMCInst(const MCInst *MI);
64
65   void printSymbolOperand(const MachineOperand &MO);
66   
67   
68
69   // These methods are used by the tablegen'erated instruction printer.
70   void printOperand(const MachineInstr *MI, unsigned OpNo,
71                     const char *Modifier = 0);
72   void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo);
73
74   void printopaquemem(const MachineInstr *MI, unsigned OpNo) {
75     printMemReference(MI, OpNo);
76   }
77
78   void printi8mem(const MachineInstr *MI, unsigned OpNo) {
79     printMemReference(MI, OpNo);
80   }
81   void printi16mem(const MachineInstr *MI, unsigned OpNo) {
82     printMemReference(MI, OpNo);
83   }
84   void printi32mem(const MachineInstr *MI, unsigned OpNo) {
85     printMemReference(MI, OpNo);
86   }
87   void printi64mem(const MachineInstr *MI, unsigned OpNo) {
88     printMemReference(MI, OpNo);
89   }
90   void printi128mem(const MachineInstr *MI, unsigned OpNo) {
91     printMemReference(MI, OpNo);
92   }
93   void printf32mem(const MachineInstr *MI, unsigned OpNo) {
94     printMemReference(MI, OpNo);
95   }
96   void printf64mem(const MachineInstr *MI, unsigned OpNo) {
97     printMemReference(MI, OpNo);
98   }
99   void printf80mem(const MachineInstr *MI, unsigned OpNo) {
100     printMemReference(MI, OpNo);
101   }
102   void printf128mem(const MachineInstr *MI, unsigned OpNo) {
103     printMemReference(MI, OpNo);
104   }
105   void printlea32mem(const MachineInstr *MI, unsigned OpNo) {
106     printLeaMemReference(MI, OpNo);
107   }
108   void printlea64mem(const MachineInstr *MI, unsigned OpNo) {
109     printLeaMemReference(MI, OpNo);
110   }
111   void printlea64_32mem(const MachineInstr *MI, unsigned OpNo) {
112     printLeaMemReference(MI, OpNo, "subreg64");
113   }
114
115   bool printAsmMRegister(const MachineOperand &MO, char Mode);
116   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
117                        unsigned AsmVariant, const char *ExtraCode);
118   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
119                              unsigned AsmVariant, const char *ExtraCode);
120
121   void printMachineInstruction(const MachineInstr *MI);
122   void printSSECC(const MachineInstr *MI, unsigned Op);
123   void printMemReference(const MachineInstr *MI, unsigned Op,
124                          const char *Modifier=NULL);
125   void printLeaMemReference(const MachineInstr *MI, unsigned Op,
126                             const char *Modifier=NULL);
127
128   void printPICLabel(const MachineInstr *MI, unsigned Op);
129
130   void PrintPICBaseSymbol() const;
131   
132   bool runOnMachineFunction(MachineFunction &F);
133
134   void emitFunctionHeader(const MachineFunction &MF);
135
136 };
137
138 } // end namespace llvm
139
140 #endif