Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / Target / Mips / MipsAsmPrinter.h
blob0b55089385d79d4bc321ff249d5a7200bfd1fadd
1 //===- MipsAsmPrinter.h - Mips LLVM Assembly Printer -----------*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Mips Assembly printer class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
14 #define LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
16 #include "Mips16HardFloatInfo.h"
17 #include "MipsMCInstLower.h"
18 #include "MipsSubtarget.h"
19 #include "llvm/CodeGen/AsmPrinter.h"
20 #include "llvm/MC/MCStreamer.h"
21 #include "llvm/Support/Compiler.h"
22 #include <algorithm>
23 #include <map>
24 #include <memory>
26 namespace llvm {
28 class MCOperand;
29 class MCSubtargetInfo;
30 class MCSymbol;
31 class MachineBasicBlock;
32 class MachineConstantPool;
33 class MachineFunction;
34 class MachineInstr;
35 class MachineOperand;
36 class MipsFunctionInfo;
37 class MipsTargetStreamer;
38 class Module;
39 class raw_ostream;
40 class TargetMachine;
42 class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
43 MipsTargetStreamer &getTargetStreamer() const;
45 void EmitInstrWithMacroNoAT(const MachineInstr *MI);
47 //===------------------------------------------------------------------===//
48 // XRay implementation
49 //===------------------------------------------------------------------===//
51 public:
52 // XRay-specific lowering for Mips.
53 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
54 void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
55 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
57 private:
58 /// MCP - Keep a pointer to constantpool entries of the current
59 /// MachineFunction.
60 const MachineConstantPool *MCP = nullptr;
62 /// InConstantPool - Maintain state when emitting a sequence of constant
63 /// pool entries so we can properly mark them as data regions.
64 bool InConstantPool = false;
66 std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
67 StubsNeeded;
69 void EmitSled(const MachineInstr &MI, SledKind Kind);
71 // tblgen'erated function.
72 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
73 const MachineInstr *MI);
75 // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,
76 // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate
77 // for the target.
78 void emitPseudoIndirectBranch(MCStreamer &OutStreamer,
79 const MachineInstr *MI);
81 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
82 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
84 void emitInlineAsmStart() const override;
86 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
87 const MCSubtargetInfo *EndInfo) const override;
89 void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
91 void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
93 void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
94 unsigned Reg1, unsigned Reg2);
96 void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
97 unsigned Reg1, unsigned Reg2, unsigned Reg3);
99 void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
100 unsigned Reg1, unsigned Reg2, unsigned FPReg1,
101 unsigned FPReg2, bool LE);
103 void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
104 Mips16HardFloatInfo::FPParamVariant, bool LE,
105 bool ToFP);
107 void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
108 Mips16HardFloatInfo::FPReturnVariant, bool LE);
110 void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
112 void NaClAlignIndirectJumpTargets(MachineFunction &MF);
114 bool isLongBranchPseudo(int Opcode) const;
116 public:
117 const MipsSubtarget *Subtarget;
118 const MipsFunctionInfo *MipsFI;
119 MipsMCInstLower MCInstLowering;
121 explicit MipsAsmPrinter(TargetMachine &TM,
122 std::unique_ptr<MCStreamer> Streamer)
123 : AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*this) {}
125 StringRef getPassName() const override { return "Mips Assembly Printer"; }
127 bool runOnMachineFunction(MachineFunction &MF) override;
129 void emitConstantPool() override {
130 bool UsingConstantPools =
131 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
132 if (!UsingConstantPools)
133 AsmPrinter::emitConstantPool();
134 // we emit constant pools customly!
137 void emitInstruction(const MachineInstr *MI) override;
138 void printSavedRegsBitmask();
139 void emitFrameDirective();
140 const char *getCurrentABIString() const;
141 void emitFunctionEntryLabel() override;
142 void emitFunctionBodyStart() override;
143 void emitFunctionBodyEnd() override;
144 void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
145 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
146 const char *ExtraCode, raw_ostream &O) override;
147 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
148 const char *ExtraCode, raw_ostream &O) override;
149 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
150 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
151 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
152 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
153 const char *Modifier = nullptr);
154 void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
155 void emitStartOfAsmFile(Module &M) override;
156 void emitEndOfAsmFile(Module &M) override;
157 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
158 void emitDebugValue(const MCExpr *Value, unsigned Size) const override;
161 } // end namespace llvm
163 #endif // LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H