xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric //===-- MipsTargetStreamer.h - Mips Target Streamer ------------*- C++ -*--===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric 
9*700637cbSDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H
10*700637cbSDimitry Andric #define LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H
11*700637cbSDimitry Andric 
12*700637cbSDimitry Andric #include "MCTargetDesc/MipsABIFlagsSection.h"
13*700637cbSDimitry Andric #include "MCTargetDesc/MipsABIInfo.h"
14*700637cbSDimitry Andric #include "llvm/ADT/STLExtras.h"
15*700637cbSDimitry Andric #include "llvm/MC/MCELFStreamer.h"
16*700637cbSDimitry Andric #include "llvm/MC/MCRegisterInfo.h"
17*700637cbSDimitry Andric #include "llvm/MC/MCStreamer.h"
18*700637cbSDimitry Andric 
19*700637cbSDimitry Andric namespace llvm {
20*700637cbSDimitry Andric 
21*700637cbSDimitry Andric class formatted_raw_ostream;
22*700637cbSDimitry Andric 
23*700637cbSDimitry Andric class MipsTargetStreamer : public MCTargetStreamer {
24*700637cbSDimitry Andric public:
25*700637cbSDimitry Andric   MipsTargetStreamer(MCStreamer &S);
26*700637cbSDimitry Andric 
27*700637cbSDimitry Andric   virtual void emitGPRel32Value(const MCExpr *);
28*700637cbSDimitry Andric   virtual void emitGPRel64Value(const MCExpr *);
29*700637cbSDimitry Andric   virtual void emitDTPRel32Value(const MCExpr *);
30*700637cbSDimitry Andric   virtual void emitDTPRel64Value(const MCExpr *);
31*700637cbSDimitry Andric   virtual void emitTPRel32Value(const MCExpr *);
32*700637cbSDimitry Andric   virtual void emitTPRel64Value(const MCExpr *);
33*700637cbSDimitry Andric 
setPic(bool Value)34*700637cbSDimitry Andric   virtual void setPic(bool Value) {}
35*700637cbSDimitry Andric 
36*700637cbSDimitry Andric   virtual void emitDirectiveSetMicroMips();
37*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMicroMips();
38*700637cbSDimitry Andric   virtual void setUsesMicroMips();
39*700637cbSDimitry Andric   virtual void emitDirectiveSetMips16();
40*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMips16();
41*700637cbSDimitry Andric 
42*700637cbSDimitry Andric   virtual void emitDirectiveSetReorder();
43*700637cbSDimitry Andric   virtual void emitDirectiveSetNoReorder();
44*700637cbSDimitry Andric   virtual void emitDirectiveSetMacro();
45*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMacro();
46*700637cbSDimitry Andric   virtual void emitDirectiveSetMsa();
47*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMsa();
48*700637cbSDimitry Andric   virtual void emitDirectiveSetMt();
49*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMt();
50*700637cbSDimitry Andric   virtual void emitDirectiveSetCRC();
51*700637cbSDimitry Andric   virtual void emitDirectiveSetNoCRC();
52*700637cbSDimitry Andric   virtual void emitDirectiveSetVirt();
53*700637cbSDimitry Andric   virtual void emitDirectiveSetNoVirt();
54*700637cbSDimitry Andric   virtual void emitDirectiveSetGINV();
55*700637cbSDimitry Andric   virtual void emitDirectiveSetNoGINV();
56*700637cbSDimitry Andric   virtual void emitDirectiveSetAt();
57*700637cbSDimitry Andric   virtual void emitDirectiveSetAtWithArg(unsigned RegNo);
58*700637cbSDimitry Andric   virtual void emitDirectiveSetNoAt();
59*700637cbSDimitry Andric   virtual void emitDirectiveEnd(StringRef Name);
60*700637cbSDimitry Andric 
61*700637cbSDimitry Andric   virtual void emitDirectiveEnt(const MCSymbol &Symbol);
62*700637cbSDimitry Andric   virtual void emitDirectiveAbiCalls();
63*700637cbSDimitry Andric   virtual void emitDirectiveNaN2008();
64*700637cbSDimitry Andric   virtual void emitDirectiveNaNLegacy();
65*700637cbSDimitry Andric   virtual void emitDirectiveOptionPic0();
66*700637cbSDimitry Andric   virtual void emitDirectiveOptionPic2();
67*700637cbSDimitry Andric   virtual void emitDirectiveInsn();
68*700637cbSDimitry Andric   virtual void emitFrame(MCRegister StackReg, unsigned StackSize,
69*700637cbSDimitry Andric                          MCRegister ReturnReg);
70*700637cbSDimitry Andric   virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff);
71*700637cbSDimitry Andric   virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff);
72*700637cbSDimitry Andric 
73*700637cbSDimitry Andric   virtual void emitDirectiveSetArch(StringRef Arch);
74*700637cbSDimitry Andric   virtual void emitDirectiveSetMips0();
75*700637cbSDimitry Andric   virtual void emitDirectiveSetMips1();
76*700637cbSDimitry Andric   virtual void emitDirectiveSetMips2();
77*700637cbSDimitry Andric   virtual void emitDirectiveSetMips3();
78*700637cbSDimitry Andric   virtual void emitDirectiveSetMips4();
79*700637cbSDimitry Andric   virtual void emitDirectiveSetMips5();
80*700637cbSDimitry Andric   virtual void emitDirectiveSetMips32();
81*700637cbSDimitry Andric   virtual void emitDirectiveSetMips32R2();
82*700637cbSDimitry Andric   virtual void emitDirectiveSetMips32R3();
83*700637cbSDimitry Andric   virtual void emitDirectiveSetMips32R5();
84*700637cbSDimitry Andric   virtual void emitDirectiveSetMips32R6();
85*700637cbSDimitry Andric   virtual void emitDirectiveSetMips64();
86*700637cbSDimitry Andric   virtual void emitDirectiveSetMips64R2();
87*700637cbSDimitry Andric   virtual void emitDirectiveSetMips64R3();
88*700637cbSDimitry Andric   virtual void emitDirectiveSetMips64R5();
89*700637cbSDimitry Andric   virtual void emitDirectiveSetMips64R6();
90*700637cbSDimitry Andric   virtual void emitDirectiveSetDsp();
91*700637cbSDimitry Andric   virtual void emitDirectiveSetDspr2();
92*700637cbSDimitry Andric   virtual void emitDirectiveSetNoDsp();
93*700637cbSDimitry Andric   virtual void emitDirectiveSetMips3D();
94*700637cbSDimitry Andric   virtual void emitDirectiveSetNoMips3D();
95*700637cbSDimitry Andric   virtual void emitDirectiveSetPop();
96*700637cbSDimitry Andric   virtual void emitDirectiveSetPush();
97*700637cbSDimitry Andric   virtual void emitDirectiveSetSoftFloat();
98*700637cbSDimitry Andric   virtual void emitDirectiveSetHardFloat();
99*700637cbSDimitry Andric 
100*700637cbSDimitry Andric   // PIC support
101*700637cbSDimitry Andric   virtual void emitDirectiveCpAdd(unsigned RegNo);
102*700637cbSDimitry Andric   virtual void emitDirectiveCpLoad(unsigned RegNo);
103*700637cbSDimitry Andric   virtual void emitDirectiveCpLocal(unsigned RegNo);
104*700637cbSDimitry Andric   virtual bool emitDirectiveCpRestore(int Offset,
105*700637cbSDimitry Andric                                       function_ref<unsigned()> GetATReg,
106*700637cbSDimitry Andric                                       SMLoc IDLoc, const MCSubtargetInfo *STI);
107*700637cbSDimitry Andric   virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
108*700637cbSDimitry Andric                                     const MCSymbol &Sym, bool IsReg);
109*700637cbSDimitry Andric   virtual void emitDirectiveCpreturn(unsigned SaveLocation,
110*700637cbSDimitry Andric                                      bool SaveLocationIsRegister);
111*700637cbSDimitry Andric 
112*700637cbSDimitry Andric   // FP abiflags directives
113*700637cbSDimitry Andric   virtual void emitDirectiveModuleFP();
114*700637cbSDimitry Andric   virtual void emitDirectiveModuleOddSPReg();
115*700637cbSDimitry Andric   virtual void emitDirectiveModuleSoftFloat();
116*700637cbSDimitry Andric   virtual void emitDirectiveModuleHardFloat();
117*700637cbSDimitry Andric   virtual void emitDirectiveModuleMT();
118*700637cbSDimitry Andric   virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
119*700637cbSDimitry Andric   virtual void emitDirectiveSetOddSPReg();
120*700637cbSDimitry Andric   virtual void emitDirectiveSetNoOddSPReg();
121*700637cbSDimitry Andric   virtual void emitDirectiveModuleCRC();
122*700637cbSDimitry Andric   virtual void emitDirectiveModuleNoCRC();
123*700637cbSDimitry Andric   virtual void emitDirectiveModuleVirt();
124*700637cbSDimitry Andric   virtual void emitDirectiveModuleNoVirt();
125*700637cbSDimitry Andric   virtual void emitDirectiveModuleGINV();
126*700637cbSDimitry Andric   virtual void emitDirectiveModuleNoGINV();
127*700637cbSDimitry Andric 
128*700637cbSDimitry Andric   void emitR(unsigned Opcode, MCRegister Reg0, SMLoc IDLoc,
129*700637cbSDimitry Andric              const MCSubtargetInfo *STI);
130*700637cbSDimitry Andric   void emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2, SMLoc IDLoc,
131*700637cbSDimitry Andric               const MCSubtargetInfo *STI);
132*700637cbSDimitry Andric   void emitRX(unsigned Opcode, MCRegister Reg0, MCOperand Op1, SMLoc IDLoc,
133*700637cbSDimitry Andric               const MCSubtargetInfo *STI);
134*700637cbSDimitry Andric   void emitRI(unsigned Opcode, MCRegister Reg0, int32_t Imm, SMLoc IDLoc,
135*700637cbSDimitry Andric               const MCSubtargetInfo *STI);
136*700637cbSDimitry Andric   void emitRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, SMLoc IDLoc,
137*700637cbSDimitry Andric               const MCSubtargetInfo *STI);
138*700637cbSDimitry Andric   void emitRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCOperand Op2,
139*700637cbSDimitry Andric                SMLoc IDLoc, const MCSubtargetInfo *STI);
140*700637cbSDimitry Andric   void emitRRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1,
141*700637cbSDimitry Andric                MCRegister Reg2, SMLoc IDLoc, const MCSubtargetInfo *STI);
142*700637cbSDimitry Andric   void emitRRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1,
143*700637cbSDimitry Andric                 MCRegister Reg2, MCOperand Op3, SMLoc IDLoc,
144*700637cbSDimitry Andric                 const MCSubtargetInfo *STI);
145*700637cbSDimitry Andric   void emitRRI(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, int16_t Imm,
146*700637cbSDimitry Andric                SMLoc IDLoc, const MCSubtargetInfo *STI);
147*700637cbSDimitry Andric   void emitRRIII(unsigned Opcode, MCRegister Reg0, MCRegister Reg1,
148*700637cbSDimitry Andric                  int16_t Imm0, int16_t Imm1, int16_t Imm2, SMLoc IDLoc,
149*700637cbSDimitry Andric                  const MCSubtargetInfo *STI);
150*700637cbSDimitry Andric   void emitAddu(MCRegister DstReg, MCRegister SrcReg, MCRegister TrgReg,
151*700637cbSDimitry Andric                 bool Is64Bit, const MCSubtargetInfo *STI);
152*700637cbSDimitry Andric   void emitDSLL(MCRegister DstReg, MCRegister SrcReg, int16_t ShiftAmount,
153*700637cbSDimitry Andric                 SMLoc IDLoc, const MCSubtargetInfo *STI);
154*700637cbSDimitry Andric   void emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc,
155*700637cbSDimitry Andric                           const MCSubtargetInfo *STI);
156*700637cbSDimitry Andric   void emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI);
157*700637cbSDimitry Andric 
158*700637cbSDimitry Andric   /// Emit a store instruction with an offset. If the offset is out of range
159*700637cbSDimitry Andric   /// then it will be synthesized using the assembler temporary.
160*700637cbSDimitry Andric   ///
161*700637cbSDimitry Andric   /// GetATReg() is a callback that can be used to obtain the current assembler
162*700637cbSDimitry Andric   /// temporary and is only called when the assembler temporary is required. It
163*700637cbSDimitry Andric   /// must handle the case where no assembler temporary is available (typically
164*700637cbSDimitry Andric   /// by reporting an error).
165*700637cbSDimitry Andric   void emitStoreWithImmOffset(unsigned Opcode, MCRegister SrcReg,
166*700637cbSDimitry Andric                               MCRegister BaseReg, int64_t Offset,
167*700637cbSDimitry Andric                               function_ref<unsigned()> GetATReg, SMLoc IDLoc,
168*700637cbSDimitry Andric                               const MCSubtargetInfo *STI);
169*700637cbSDimitry Andric   void emitLoadWithImmOffset(unsigned Opcode, MCRegister DstReg,
170*700637cbSDimitry Andric                              MCRegister BaseReg, int64_t Offset,
171*700637cbSDimitry Andric                              MCRegister TmpReg, SMLoc IDLoc,
172*700637cbSDimitry Andric                              const MCSubtargetInfo *STI);
173*700637cbSDimitry Andric   void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI);
174*700637cbSDimitry Andric 
forbidModuleDirective()175*700637cbSDimitry Andric   void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
reallowModuleDirective()176*700637cbSDimitry Andric   void reallowModuleDirective() { ModuleDirectiveAllowed = true; }
isModuleDirectiveAllowed()177*700637cbSDimitry Andric   bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; }
178*700637cbSDimitry Andric 
179*700637cbSDimitry Andric   // This method enables template classes to set internal abi flags
180*700637cbSDimitry Andric   // structure values.
181*700637cbSDimitry Andric   template <class PredicateLibrary>
updateABIInfo(const PredicateLibrary & P)182*700637cbSDimitry Andric   void updateABIInfo(const PredicateLibrary &P) {
183*700637cbSDimitry Andric     ABI = P.getABI();
184*700637cbSDimitry Andric     ABIFlagsSection.setAllFromPredicates(P);
185*700637cbSDimitry Andric   }
186*700637cbSDimitry Andric 
getABIFlagsSection()187*700637cbSDimitry Andric   MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; }
getABI()188*700637cbSDimitry Andric   const MipsABIInfo &getABI() const {
189*700637cbSDimitry Andric     assert(ABI && "ABI hasn't been set!");
190*700637cbSDimitry Andric     return *ABI;
191*700637cbSDimitry Andric   }
192*700637cbSDimitry Andric 
193*700637cbSDimitry Andric protected:
194*700637cbSDimitry Andric   std::optional<MipsABIInfo> ABI;
195*700637cbSDimitry Andric   MipsABIFlagsSection ABIFlagsSection;
196*700637cbSDimitry Andric 
197*700637cbSDimitry Andric   bool GPRInfoSet;
198*700637cbSDimitry Andric   unsigned GPRBitMask;
199*700637cbSDimitry Andric   int GPROffset;
200*700637cbSDimitry Andric 
201*700637cbSDimitry Andric   bool FPRInfoSet;
202*700637cbSDimitry Andric   unsigned FPRBitMask;
203*700637cbSDimitry Andric   int FPROffset;
204*700637cbSDimitry Andric 
205*700637cbSDimitry Andric   bool FrameInfoSet;
206*700637cbSDimitry Andric   int FrameOffset;
207*700637cbSDimitry Andric   unsigned FrameReg;
208*700637cbSDimitry Andric   unsigned GPReg;
209*700637cbSDimitry Andric   unsigned ReturnReg;
210*700637cbSDimitry Andric 
211*700637cbSDimitry Andric private:
212*700637cbSDimitry Andric   bool ModuleDirectiveAllowed;
213*700637cbSDimitry Andric };
214*700637cbSDimitry Andric 
215*700637cbSDimitry Andric // This part is for ascii assembly output
216*700637cbSDimitry Andric class MipsTargetAsmStreamer : public MipsTargetStreamer {
217*700637cbSDimitry Andric   formatted_raw_ostream &OS;
218*700637cbSDimitry Andric 
219*700637cbSDimitry Andric public:
220*700637cbSDimitry Andric   MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
221*700637cbSDimitry Andric 
222*700637cbSDimitry Andric   void emitGPRel32Value(const MCExpr *) override;
223*700637cbSDimitry Andric   void emitGPRel64Value(const MCExpr *) override;
224*700637cbSDimitry Andric   void emitDTPRel32Value(const MCExpr *) override;
225*700637cbSDimitry Andric   void emitDTPRel64Value(const MCExpr *) override;
226*700637cbSDimitry Andric   void emitTPRel32Value(const MCExpr *) override;
227*700637cbSDimitry Andric   void emitTPRel64Value(const MCExpr *) override;
228*700637cbSDimitry Andric 
229*700637cbSDimitry Andric   void emitDirectiveSetMicroMips() override;
230*700637cbSDimitry Andric   void emitDirectiveSetNoMicroMips() override;
231*700637cbSDimitry Andric   void emitDirectiveSetMips16() override;
232*700637cbSDimitry Andric   void emitDirectiveSetNoMips16() override;
233*700637cbSDimitry Andric 
234*700637cbSDimitry Andric   void emitDirectiveSetReorder() override;
235*700637cbSDimitry Andric   void emitDirectiveSetNoReorder() override;
236*700637cbSDimitry Andric   void emitDirectiveSetMacro() override;
237*700637cbSDimitry Andric   void emitDirectiveSetNoMacro() override;
238*700637cbSDimitry Andric   void emitDirectiveSetMsa() override;
239*700637cbSDimitry Andric   void emitDirectiveSetNoMsa() override;
240*700637cbSDimitry Andric   void emitDirectiveSetMt() override;
241*700637cbSDimitry Andric   void emitDirectiveSetNoMt() override;
242*700637cbSDimitry Andric   void emitDirectiveSetCRC() override;
243*700637cbSDimitry Andric   void emitDirectiveSetNoCRC() override;
244*700637cbSDimitry Andric   void emitDirectiveSetVirt() override;
245*700637cbSDimitry Andric   void emitDirectiveSetNoVirt() override;
246*700637cbSDimitry Andric   void emitDirectiveSetGINV() override;
247*700637cbSDimitry Andric   void emitDirectiveSetNoGINV() override;
248*700637cbSDimitry Andric   void emitDirectiveSetAt() override;
249*700637cbSDimitry Andric   void emitDirectiveSetAtWithArg(unsigned RegNo) override;
250*700637cbSDimitry Andric   void emitDirectiveSetNoAt() override;
251*700637cbSDimitry Andric   void emitDirectiveEnd(StringRef Name) override;
252*700637cbSDimitry Andric 
253*700637cbSDimitry Andric   void emitDirectiveEnt(const MCSymbol &Symbol) override;
254*700637cbSDimitry Andric   void emitDirectiveAbiCalls() override;
255*700637cbSDimitry Andric   void emitDirectiveNaN2008() override;
256*700637cbSDimitry Andric   void emitDirectiveNaNLegacy() override;
257*700637cbSDimitry Andric   void emitDirectiveOptionPic0() override;
258*700637cbSDimitry Andric   void emitDirectiveOptionPic2() override;
259*700637cbSDimitry Andric   void emitDirectiveInsn() override;
260*700637cbSDimitry Andric   void emitFrame(MCRegister StackReg, unsigned StackSize,
261*700637cbSDimitry Andric                  MCRegister ReturnReg) override;
262*700637cbSDimitry Andric   void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override;
263*700637cbSDimitry Andric   void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override;
264*700637cbSDimitry Andric 
265*700637cbSDimitry Andric   void emitDirectiveSetArch(StringRef Arch) override;
266*700637cbSDimitry Andric   void emitDirectiveSetMips0() override;
267*700637cbSDimitry Andric   void emitDirectiveSetMips1() override;
268*700637cbSDimitry Andric   void emitDirectiveSetMips2() override;
269*700637cbSDimitry Andric   void emitDirectiveSetMips3() override;
270*700637cbSDimitry Andric   void emitDirectiveSetMips4() override;
271*700637cbSDimitry Andric   void emitDirectiveSetMips5() override;
272*700637cbSDimitry Andric   void emitDirectiveSetMips32() override;
273*700637cbSDimitry Andric   void emitDirectiveSetMips32R2() override;
274*700637cbSDimitry Andric   void emitDirectiveSetMips32R3() override;
275*700637cbSDimitry Andric   void emitDirectiveSetMips32R5() override;
276*700637cbSDimitry Andric   void emitDirectiveSetMips32R6() override;
277*700637cbSDimitry Andric   void emitDirectiveSetMips64() override;
278*700637cbSDimitry Andric   void emitDirectiveSetMips64R2() override;
279*700637cbSDimitry Andric   void emitDirectiveSetMips64R3() override;
280*700637cbSDimitry Andric   void emitDirectiveSetMips64R5() override;
281*700637cbSDimitry Andric   void emitDirectiveSetMips64R6() override;
282*700637cbSDimitry Andric   void emitDirectiveSetDsp() override;
283*700637cbSDimitry Andric   void emitDirectiveSetDspr2() override;
284*700637cbSDimitry Andric   void emitDirectiveSetNoDsp() override;
285*700637cbSDimitry Andric   void emitDirectiveSetMips3D() override;
286*700637cbSDimitry Andric   void emitDirectiveSetNoMips3D() override;
287*700637cbSDimitry Andric   void emitDirectiveSetPop() override;
288*700637cbSDimitry Andric   void emitDirectiveSetPush() override;
289*700637cbSDimitry Andric   void emitDirectiveSetSoftFloat() override;
290*700637cbSDimitry Andric   void emitDirectiveSetHardFloat() override;
291*700637cbSDimitry Andric 
292*700637cbSDimitry Andric   // PIC support
293*700637cbSDimitry Andric   void emitDirectiveCpAdd(unsigned RegNo) override;
294*700637cbSDimitry Andric   void emitDirectiveCpLoad(unsigned RegNo) override;
295*700637cbSDimitry Andric   void emitDirectiveCpLocal(unsigned RegNo) override;
296*700637cbSDimitry Andric 
297*700637cbSDimitry Andric   /// Emit a .cprestore directive.  If the offset is out of range then it will
298*700637cbSDimitry Andric   /// be synthesized using the assembler temporary.
299*700637cbSDimitry Andric   ///
300*700637cbSDimitry Andric   /// GetATReg() is a callback that can be used to obtain the current assembler
301*700637cbSDimitry Andric   /// temporary and is only called when the assembler temporary is required. It
302*700637cbSDimitry Andric   /// must handle the case where no assembler temporary is available (typically
303*700637cbSDimitry Andric   /// by reporting an error).
304*700637cbSDimitry Andric   bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> GetATReg,
305*700637cbSDimitry Andric                               SMLoc IDLoc, const MCSubtargetInfo *STI) override;
306*700637cbSDimitry Andric   void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
307*700637cbSDimitry Andric                             const MCSymbol &Sym, bool IsReg) override;
308*700637cbSDimitry Andric   void emitDirectiveCpreturn(unsigned SaveLocation,
309*700637cbSDimitry Andric                              bool SaveLocationIsRegister) override;
310*700637cbSDimitry Andric 
311*700637cbSDimitry Andric   // FP abiflags directives
312*700637cbSDimitry Andric   void emitDirectiveModuleFP() override;
313*700637cbSDimitry Andric   void emitDirectiveModuleOddSPReg() override;
314*700637cbSDimitry Andric   void emitDirectiveModuleSoftFloat() override;
315*700637cbSDimitry Andric   void emitDirectiveModuleHardFloat() override;
316*700637cbSDimitry Andric   void emitDirectiveModuleMT() override;
317*700637cbSDimitry Andric   void emitDirectiveModuleCRC() override;
318*700637cbSDimitry Andric   void emitDirectiveModuleNoCRC() override;
319*700637cbSDimitry Andric   void emitDirectiveModuleVirt() override;
320*700637cbSDimitry Andric   void emitDirectiveModuleNoVirt() override;
321*700637cbSDimitry Andric   void emitDirectiveModuleGINV() override;
322*700637cbSDimitry Andric   void emitDirectiveModuleNoGINV() override;
323*700637cbSDimitry Andric   void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
324*700637cbSDimitry Andric   void emitDirectiveSetOddSPReg() override;
325*700637cbSDimitry Andric   void emitDirectiveSetNoOddSPReg() override;
326*700637cbSDimitry Andric };
327*700637cbSDimitry Andric 
328*700637cbSDimitry Andric // This part is for ELF object output
329*700637cbSDimitry Andric class MipsTargetELFStreamer : public MipsTargetStreamer {
330*700637cbSDimitry Andric   bool MicroMipsEnabled;
331*700637cbSDimitry Andric   const MCSubtargetInfo &STI;
332*700637cbSDimitry Andric   bool Pic;
333*700637cbSDimitry Andric 
334*700637cbSDimitry Andric public:
isMicroMipsEnabled()335*700637cbSDimitry Andric   bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
336*700637cbSDimitry Andric   MCELFStreamer &getStreamer();
337*700637cbSDimitry Andric   MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
338*700637cbSDimitry Andric 
setPic(bool Value)339*700637cbSDimitry Andric   void setPic(bool Value) override { Pic = Value; }
340*700637cbSDimitry Andric 
341*700637cbSDimitry Andric   void emitLabel(MCSymbol *Symbol) override;
342*700637cbSDimitry Andric   void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
343*700637cbSDimitry Andric   void finish() override;
344*700637cbSDimitry Andric 
345*700637cbSDimitry Andric   void emitGPRel32Value(const MCExpr *) override;
346*700637cbSDimitry Andric   void emitGPRel64Value(const MCExpr *) override;
347*700637cbSDimitry Andric   void emitDTPRel32Value(const MCExpr *) override;
348*700637cbSDimitry Andric   void emitDTPRel64Value(const MCExpr *) override;
349*700637cbSDimitry Andric   void emitTPRel32Value(const MCExpr *) override;
350*700637cbSDimitry Andric   void emitTPRel64Value(const MCExpr *) override;
351*700637cbSDimitry Andric 
352*700637cbSDimitry Andric   void emitDirectiveSetMicroMips() override;
353*700637cbSDimitry Andric   void emitDirectiveSetNoMicroMips() override;
354*700637cbSDimitry Andric   void setUsesMicroMips() override;
355*700637cbSDimitry Andric   void emitDirectiveSetMips16() override;
356*700637cbSDimitry Andric 
357*700637cbSDimitry Andric   void emitDirectiveSetNoReorder() override;
358*700637cbSDimitry Andric   void emitDirectiveEnd(StringRef Name) override;
359*700637cbSDimitry Andric 
360*700637cbSDimitry Andric   void emitDirectiveEnt(const MCSymbol &Symbol) override;
361*700637cbSDimitry Andric   void emitDirectiveAbiCalls() override;
362*700637cbSDimitry Andric   void emitDirectiveNaN2008() override;
363*700637cbSDimitry Andric   void emitDirectiveNaNLegacy() override;
364*700637cbSDimitry Andric   void emitDirectiveOptionPic0() override;
365*700637cbSDimitry Andric   void emitDirectiveOptionPic2() override;
366*700637cbSDimitry Andric   void emitDirectiveInsn() override;
367*700637cbSDimitry Andric   void emitFrame(MCRegister StackReg, unsigned StackSize,
368*700637cbSDimitry Andric                  MCRegister ReturnReg) override;
369*700637cbSDimitry Andric   void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override;
370*700637cbSDimitry Andric   void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override;
371*700637cbSDimitry Andric 
372*700637cbSDimitry Andric   // PIC support
373*700637cbSDimitry Andric   void emitDirectiveCpAdd(unsigned RegNo) override;
374*700637cbSDimitry Andric   void emitDirectiveCpLoad(unsigned RegNo) override;
375*700637cbSDimitry Andric   void emitDirectiveCpLocal(unsigned RegNo) override;
376*700637cbSDimitry Andric   bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> GetATReg,
377*700637cbSDimitry Andric                               SMLoc IDLoc, const MCSubtargetInfo *STI) override;
378*700637cbSDimitry Andric   void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
379*700637cbSDimitry Andric                             const MCSymbol &Sym, bool IsReg) override;
380*700637cbSDimitry Andric   void emitDirectiveCpreturn(unsigned SaveLocation,
381*700637cbSDimitry Andric                              bool SaveLocationIsRegister) override;
382*700637cbSDimitry Andric 
383*700637cbSDimitry Andric   void emitMipsAbiFlags();
384*700637cbSDimitry Andric };
385*700637cbSDimitry Andric }
386*700637cbSDimitry Andric #endif
387