f8dd6bc6ab3eb2e28899e967ae1e6c8be6554fc8
[oota-llvm.git] / lib / Target / X86 / X86IntelAsmPrinter.h
1 //===-- X86IntelAsmPrinter.h - Convert X86 LLVM code to Intel assembly ----===//
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 // Intel assembly code printer class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86INTELASMPRINTER_H
15 #define X86INTELASMPRINTER_H
16
17 #include "X86AsmPrinter.h"
18 #include "llvm/CodeGen/ValueTypes.h"
19 #include "llvm/Target/MRegisterInfo.h"
20
21 namespace llvm {
22
23 struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public X86SharedAsmPrinter {
24   X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
25                      const TargetAsmInfo *T)
26       : X86SharedAsmPrinter(O, TM, T) {
27   }
28
29   virtual const char *getPassName() const {
30     return "X86 Intel-Style Assembly Printer";
31   }
32
33   /// printInstruction - This method is automatically generated by tablegen
34   /// from the instruction set description.  This method returns true if the
35   /// machine instruction was sufficiently described to print it, otherwise it
36   /// returns false.
37   bool printInstruction(const MachineInstr *MI);
38
39   // This method is used by the tablegen'erated instruction printer.
40   void printOperand(const MachineInstr *MI, unsigned OpNo,
41                     const char *Modifier = 0) {
42     const MachineOperand &MO = MI->getOperand(OpNo);
43     if (MO.isRegister()) {
44       assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) && "Not physreg??");
45       O << TM.getRegisterInfo()->get(MO.getReg()).Name;
46     } else {
47       printOp(MO, Modifier);
48     }
49   }
50
51   void printi8mem(const MachineInstr *MI, unsigned OpNo) {
52     O << "BYTE PTR ";
53     printMemReference(MI, OpNo);
54   }
55   void printi16mem(const MachineInstr *MI, unsigned OpNo) {
56     O << "WORD PTR ";
57     printMemReference(MI, OpNo);
58   }
59   void printi32mem(const MachineInstr *MI, unsigned OpNo) {
60     O << "DWORD PTR ";
61     printMemReference(MI, OpNo);
62   }
63   void printi64mem(const MachineInstr *MI, unsigned OpNo) {
64     O << "QWORD PTR ";
65     printMemReference(MI, OpNo);
66   }
67   void printi128mem(const MachineInstr *MI, unsigned OpNo) {
68     O << "XMMWORD PTR ";
69     printMemReference(MI, OpNo);
70   }
71   void printf32mem(const MachineInstr *MI, unsigned OpNo) {
72     O << "DWORD PTR ";
73     printMemReference(MI, OpNo);
74   }
75   void printf64mem(const MachineInstr *MI, unsigned OpNo) {
76     O << "QWORD PTR ";
77     printMemReference(MI, OpNo);
78   }
79   void printf80mem(const MachineInstr *MI, unsigned OpNo) {
80     O << "XWORD PTR ";
81     printMemReference(MI, OpNo);
82   }
83   void printf128mem(const MachineInstr *MI, unsigned OpNo) {
84     O << "XMMWORD PTR ";
85     printMemReference(MI, OpNo);
86   }
87   void printlea64_32mem(const MachineInstr *MI, unsigned OpNo) {
88     O << "QWORD PTR ";
89     printMemReference(MI, OpNo, "subreg64");
90   }
91
92   bool printAsmMRegister(const MachineOperand &MO, const char Mode);
93   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
94                        unsigned AsmVariant, const char *ExtraCode);
95   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
96                              unsigned AsmVariant, const char *ExtraCode);
97   void printMachineInstruction(const MachineInstr *MI);
98   void printOp(const MachineOperand &MO, const char *Modifier = 0);
99   void printSSECC(const MachineInstr *MI, unsigned Op);
100   void printMemReference(const MachineInstr *MI, unsigned Op,
101                          const char *Modifier=NULL);
102   void printPICJumpTableSetLabel(unsigned uid,
103                                  const MachineBasicBlock *MBB) const;
104   void printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
105                                  const MachineBasicBlock *MBB) const {
106     AsmPrinter::printPICJumpTableSetLabel(uid, uid2, MBB);
107   }
108   void printPICLabel(const MachineInstr *MI, unsigned Op);
109   bool runOnMachineFunction(MachineFunction &F);
110   bool doInitialization(Module &M);
111   bool doFinalization(Module &M);
112   
113   /// getSectionForFunction - Return the section that we should emit the
114   /// specified function body into.
115   virtual std::string getSectionForFunction(const Function &F) const;
116
117   virtual void EmitString(const ConstantArray *CVA) const;
118 };
119
120 } // end namespace llvm
121
122 #endif