[C++] Use 'nullptr'.
[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   void NaClAlignIndirectJumpTargets(MachineFunction &MF);
77
78 public:
79
80   const MipsSubtarget *Subtarget;
81   const MipsFunctionInfo *MipsFI;
82   MipsMCInstLower MCInstLowering;
83
84   explicit MipsAsmPrinter(TargetMachine &TM,  MCStreamer &Streamer)
85     : AsmPrinter(TM, Streamer), MCP(nullptr), InConstantPool(false),
86       MCInstLowering(*this) {
87     Subtarget = &TM.getSubtarget<MipsSubtarget>();
88   }
89
90   virtual const char *getPassName() const {
91     return "Mips Assembly Printer";
92   }
93
94   virtual bool runOnMachineFunction(MachineFunction &MF);
95
96   virtual void EmitConstantPool() override {
97     bool UsingConstantPools =
98       (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
99     if (!UsingConstantPools)
100       AsmPrinter::EmitConstantPool();
101     // we emit constant pools customly!
102   }
103
104   void EmitInstruction(const MachineInstr *MI);
105   void printSavedRegsBitmask();
106   void emitFrameDirective();
107   const char *getCurrentABIString() const;
108   virtual void EmitFunctionEntryLabel();
109   virtual void EmitFunctionBodyStart();
110   virtual void EmitFunctionBodyEnd();
111   virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
112                                                  MBB) const;
113   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
114                        unsigned AsmVariant, const char *ExtraCode,
115                        raw_ostream &O);
116   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
117                              unsigned AsmVariant, const char *ExtraCode,
118                              raw_ostream &O);
119   void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
120   void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
121   void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
122   void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
123   void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
124   void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
125                        const char *Modifier = nullptr);
126   void EmitStartOfAsmFile(Module &M);
127   void EmitEndOfAsmFile(Module &M);
128   void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
129 };
130 }
131
132 #endif
133