/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/Mips/MipsAsmPrinter.h
Line | Count | Source (jump to first uncovered line) |
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 LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H |
15 | | #define LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H |
16 | | |
17 | | #include "Mips16HardFloatInfo.h" |
18 | | #include "MipsMCInstLower.h" |
19 | | #include "MipsSubtarget.h" |
20 | | #include "llvm/CodeGen/AsmPrinter.h" |
21 | | #include "llvm/MC/MCStreamer.h" |
22 | | #include "llvm/Support/Compiler.h" |
23 | | #include <algorithm> |
24 | | #include <map> |
25 | | #include <memory> |
26 | | |
27 | | namespace llvm { |
28 | | |
29 | | class MCOperand; |
30 | | class MCSubtargetInfo; |
31 | | class MCSymbol; |
32 | | class MachineBasicBlock; |
33 | | class MachineConstantPool; |
34 | | class MachineFunction; |
35 | | class MachineInstr; |
36 | | class MachineOperand; |
37 | | class MipsFunctionInfo; |
38 | | class MipsTargetStreamer; |
39 | | class Module; |
40 | | class raw_ostream; |
41 | | class TargetMachine; |
42 | | |
43 | | class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter { |
44 | | MipsTargetStreamer &getTargetStreamer() const; |
45 | | |
46 | | void EmitInstrWithMacroNoAT(const MachineInstr *MI); |
47 | | |
48 | | //===------------------------------------------------------------------===// |
49 | | // XRay implementation |
50 | | //===------------------------------------------------------------------===// |
51 | | |
52 | | public: |
53 | | // XRay-specific lowering for Mips. |
54 | | void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI); |
55 | | void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI); |
56 | | void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI); |
57 | | // Helper function that emits the XRay sleds we've collected for a particular |
58 | | // function. |
59 | | void EmitXRayTable(); |
60 | | |
61 | | private: |
62 | | /// MCP - Keep a pointer to constantpool entries of the current |
63 | | /// MachineFunction. |
64 | | const MachineConstantPool *MCP = nullptr; |
65 | | |
66 | | /// InConstantPool - Maintain state when emitting a sequence of constant |
67 | | /// pool entries so we can properly mark them as data regions. |
68 | | bool InConstantPool = false; |
69 | | |
70 | | std::map<const char *, const Mips16HardFloatInfo::FuncSignature *> |
71 | | StubsNeeded; |
72 | | |
73 | | void EmitSled(const MachineInstr &MI, SledKind Kind); |
74 | | |
75 | | // tblgen'erated function. |
76 | | bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, |
77 | | const MachineInstr *MI); |
78 | | |
79 | | // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch, |
80 | | // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate |
81 | | // for the target. |
82 | | void emitPseudoIndirectBranch(MCStreamer &OutStreamer, |
83 | | const MachineInstr *MI); |
84 | | |
85 | | // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. |
86 | | bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); |
87 | | |
88 | | void emitInlineAsmStart() const override; |
89 | | |
90 | | void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, |
91 | | const MCSubtargetInfo *EndInfo) const override; |
92 | | |
93 | | void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol); |
94 | | |
95 | | void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg); |
96 | | |
97 | | void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode, |
98 | | unsigned Reg1, unsigned Reg2); |
99 | | |
100 | | void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode, |
101 | | unsigned Reg1, unsigned Reg2, unsigned Reg3); |
102 | | |
103 | | void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc, |
104 | | unsigned Reg1, unsigned Reg2, unsigned FPReg1, |
105 | | unsigned FPReg2, bool LE); |
106 | | |
107 | | void EmitSwapFPIntParams(const MCSubtargetInfo &STI, |
108 | | Mips16HardFloatInfo::FPParamVariant, bool LE, |
109 | | bool ToFP); |
110 | | |
111 | | void EmitSwapFPIntRetval(const MCSubtargetInfo &STI, |
112 | | Mips16HardFloatInfo::FPReturnVariant, bool LE); |
113 | | |
114 | | void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *); |
115 | | |
116 | | void NaClAlignIndirectJumpTargets(MachineFunction &MF); |
117 | | |
118 | | bool isLongBranchPseudo(int Opcode) const; |
119 | | |
120 | | public: |
121 | | const MipsSubtarget *Subtarget; |
122 | | const MipsFunctionInfo *MipsFI; |
123 | | MipsMCInstLower MCInstLowering; |
124 | | |
125 | | explicit MipsAsmPrinter(TargetMachine &TM, |
126 | | std::unique_ptr<MCStreamer> Streamer) |
127 | 1.70k | : AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*this) {} |
128 | | |
129 | 0 | StringRef getPassName() const override { return "Mips Assembly Printer"; } |
130 | | |
131 | | bool runOnMachineFunction(MachineFunction &MF) override; |
132 | | |
133 | 12.3k | void EmitConstantPool() override { |
134 | 12.3k | bool UsingConstantPools = |
135 | 377 | (Subtarget->inMips16Mode() && Subtarget->useConstantIslands()); |
136 | 12.3k | if (!UsingConstantPools) |
137 | 11.9k | AsmPrinter::EmitConstantPool(); |
138 | 12.3k | // we emit constant pools customly! |
139 | 12.3k | } |
140 | | |
141 | | void EmitInstruction(const MachineInstr *MI) override; |
142 | | void printSavedRegsBitmask(); |
143 | | void emitFrameDirective(); |
144 | | const char *getCurrentABIString() const; |
145 | | void EmitFunctionEntryLabel() override; |
146 | | void EmitFunctionBodyStart() override; |
147 | | void EmitFunctionBodyEnd() override; |
148 | | void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override; |
149 | | bool isBlockOnlyReachableByFallthrough( |
150 | | const MachineBasicBlock* MBB) const override; |
151 | | bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
152 | | unsigned AsmVariant, const char *ExtraCode, |
153 | | raw_ostream &O) override; |
154 | | bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, |
155 | | unsigned AsmVariant, const char *ExtraCode, |
156 | | raw_ostream &O) override; |
157 | | void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O); |
158 | | void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O); |
159 | | void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O); |
160 | | void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O, |
161 | | const char *Modifier = nullptr); |
162 | | void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O); |
163 | | void EmitStartOfAsmFile(Module &M) override; |
164 | | void EmitEndOfAsmFile(Module &M) override; |
165 | | void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); |
166 | | void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const override; |
167 | | }; |
168 | | |
169 | | } // end namespace llvm |
170 | | |
171 | | #endif // LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H |