This patch has two main functions:
[oota-llvm.git] / lib / Target / Mips / MipsAsmPrinter.h
1 //===-- MipsAsmPrinter.h - Mips LLVM Assembly Printer ----------*- 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 // Mips Assembly printer class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef MIPSASMPRINTER_H
15 #define MIPSASMPRINTER_H
16
17 #include "Mips16HardFloatInfo.h"
18 #include "MipsMCInstLower.h"
19 #include "MipsMachineFunction.h"
20 #include "MipsSubtarget.h"
21 #include "llvm/CodeGen/AsmPrinter.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Target/TargetMachine.h"
24
25 namespace llvm {
26 class MCStreamer;
27 class MachineInstr;
28 class MachineBasicBlock;
29 class MipsTargetStreamer;
30 class Module;
31 class raw_ostream;
32
33 class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
34   MipsTargetStreamer &getTargetStreamer();
35
36   void EmitInstrWithMacroNoAT(const MachineInstr *MI);
37
38 private:
39   // tblgen'erated function.
40   bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
41                                    const MachineInstr *MI);
42
43   // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
44   bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
45
46   /// MCP - Keep a pointer to constantpool entries of the current
47   /// MachineFunction.
48   const MachineConstantPool *MCP;
49
50   /// InConstantPool - Maintain state when emitting a sequence of constant
51   /// pool entries so we can properly mark them as data regions.
52   bool InConstantPool;
53
54   std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
55   StubsNeeded;
56
57   void EmitJal(MCSymbol *Symbol);
58
59   void EmitInstrReg(unsigned Opcode, unsigned Reg);
60
61   void EmitInstrRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2);
62
63   void EmitInstrRegRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2,
64                           unsigned Reg3);
65
66   void EmitMovFPIntPair(unsigned MovOpc, unsigned Reg1, unsigned Reg2,
67                         unsigned FPReg1, unsigned FPReg2, bool LE);
68
69   void EmitSwapFPIntParams(Mips16HardFloatInfo::FPParamVariant, bool LE,
70                            bool ToFP);
71
72   void EmitSwapFPIntRetval(Mips16HardFloatInfo::FPReturnVariant, bool LE);
73
74   void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
75
76 public:
77
78   const MipsSubtarget *Subtarget;
79   const MipsFunctionInfo *MipsFI;
80   MipsMCInstLower MCInstLowering;
81
82   explicit MipsAsmPrinter(TargetMachine &TM,  MCStreamer &Streamer)
83     : AsmPrinter(TM, Streamer), MCP(0), InConstantPool(false),
84       MCInstLowering(*this) {
85     Subtarget = &TM.getSubtarget<MipsSubtarget>();
86   }
87
88   virtual const char *getPassName() const {
89     return "Mips Assembly Printer";
90   }
91
92   virtual bool runOnMachineFunction(MachineFunction &MF);
93
94   virtual void EmitConstantPool() LLVM_OVERRIDE {
95     bool UsingConstantPools =
96       (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
97     if (!UsingConstantPools)
98       AsmPrinter::EmitConstantPool();
99     // we emit constant pools customly!
100   }
101
102   void EmitInstruction(const MachineInstr *MI);
103   void printSavedRegsBitmask();
104   void emitFrameDirective();
105   const char *getCurrentABIString() const;
106   virtual void EmitFunctionEntryLabel();
107   virtual void EmitFunctionBodyStart();
108   virtual void EmitFunctionBodyEnd();
109   virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
110                                                  MBB) const;
111   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
112                        unsigned AsmVariant, const char *ExtraCode,
113                        raw_ostream &O);
114   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
115                              unsigned AsmVariant, const char *ExtraCode,
116                              raw_ostream &O);
117   void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
118   void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
119   void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
120   void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
121   void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
122   void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
123                        const char *Modifier = 0);
124   void EmitStartOfAsmFile(Module &M);
125   void EmitEndOfAsmFile(Module &M);
126   void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
127 };
128 }
129
130 #endif
131