fix PrintAsmOperand and PrintAsmMemoryOperand to pass down
[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                          MCStreamer &Streamer)
40     : AsmPrinter(O, TM, Streamer) {
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   virtual void EmitStartOfAsmFile(Module &M);
58
59   virtual void EmitEndOfAsmFile(Module &M);
60   
61   virtual void EmitInstruction(const MachineInstr *MI);
62   
63   void printSymbolOperand(const MachineOperand &MO, raw_ostream &O);
64
65   // These methods are used by the tablegen'erated instruction printer.
66   void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,
67                     const char *Modifier = 0);
68   void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
69
70   bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
71   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
72                        unsigned AsmVariant, const char *ExtraCode,
73                        raw_ostream &OS);
74   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
75                              unsigned AsmVariant, const char *ExtraCode,
76                              raw_ostream &OS);
77
78   void printMachineInstruction(const MachineInstr *MI);
79   void printSSECC(const MachineInstr *MI, unsigned Op, raw_ostream &O);
80   void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
81                          const char *Modifier=NULL);
82   void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
83                             const char *Modifier=NULL);
84
85   void printPICLabel(const MachineInstr *MI, unsigned Op, raw_ostream &O);
86
87   void PrintPICBaseSymbol(raw_ostream &O) const;
88   
89   bool runOnMachineFunction(MachineFunction &F);
90 };
91
92 } // end namespace llvm
93
94 #endif