Fix undefined behavior in the Mips backend.
[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 MachineJumpTableInfo;
28 class MCContext;
29 class MCInst;
30 class MCStreamer;
31 class MCSymbol;
32
33 class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
34   const X86Subtarget *Subtarget;
35  public:
36   explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
37     : AsmPrinter(TM, Streamer) {
38     Subtarget = &TM.getSubtarget<X86Subtarget>();
39   }
40
41   virtual const char *getPassName() const {
42     return "X86 AT&T-Style Assembly Printer";
43   }
44   
45   const X86Subtarget &getSubtarget() const { return *Subtarget; }
46
47   virtual void EmitStartOfAsmFile(Module &M);
48
49   virtual void EmitEndOfAsmFile(Module &M);
50   
51   virtual void EmitInstruction(const MachineInstr *MI);
52   
53   void printSymbolOperand(const MachineOperand &MO, raw_ostream &O);
54
55   // These methods are used by the tablegen'erated instruction printer.
56   void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,
57                     const char *Modifier = 0);
58   void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
59
60   bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
61   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
62                        unsigned AsmVariant, const char *ExtraCode,
63                        raw_ostream &OS);
64   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
65                              unsigned AsmVariant, const char *ExtraCode,
66                              raw_ostream &OS);
67
68   void printMachineInstruction(const MachineInstr *MI);
69   void printSSECC(const MachineInstr *MI, unsigned Op, raw_ostream &O);
70   void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
71                          const char *Modifier=NULL);
72   void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
73                             const char *Modifier=NULL);
74
75   void printPICLabel(const MachineInstr *MI, unsigned Op, raw_ostream &O);
76
77   bool runOnMachineFunction(MachineFunction &F);
78   
79   void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
80
81   MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
82 };
83
84 } // end namespace llvm
85
86 #endif