LLVM 24.0.0git
MipsAsmPrinter.h
Go to the documentation of this file.
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.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
14#define LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
15
16#include "Mips16HardFloatInfo.h"
17#include "MipsMCInstLower.h"
18#include "MipsSubtarget.h"
20#include "llvm/MC/MCStreamer.h"
22#include <algorithm>
23#include <map>
24#include <memory>
25
26namespace llvm {
27
28class MCOperand;
29class MCSubtargetInfo;
30class MCSymbol;
33class MachineFunction;
34class MachineInstr;
35class MachineOperand;
38class Module;
39class raw_ostream;
40class TargetMachine;
41
43 MipsTargetStreamer &getTargetStreamer() const;
44
45 //===------------------------------------------------------------------===//
46 // XRay implementation
47 //===------------------------------------------------------------------===//
48
49public:
50 // XRay-specific lowering for Mips.
54
55private:
56 /// MCP - Keep a pointer to constantpool entries of the current
57 /// MachineFunction.
58 const MachineConstantPool *MCP = nullptr;
59
60 /// InConstantPool - Maintain state when emitting a sequence of constant
61 /// pool entries so we can properly mark them as data regions.
62 bool InConstantPool = false;
63
64 std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
65 StubsNeeded;
66
67 void EmitSled(const MachineInstr &MI, SledKind Kind);
68
69 // tblgen'erated function.
70 bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst);
71
72 // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,
73 // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate
74 // for the target.
75 void emitPseudoIndirectBranch(MCStreamer &OutStreamer,
76 const MachineInstr *MI);
77
78 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
79 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
80
81 void emitInlineAsmStart() const override;
82
83 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
84 const MCSubtargetInfo *EndInfo,
85 const MachineInstr *MI) override;
86
87 void emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
89 unsigned uid) const override;
90
91 void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
92
93 void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
94
95 void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
96 unsigned Reg1, unsigned Reg2);
97
98 void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
99 unsigned Reg1, unsigned Reg2, unsigned Reg3);
100
101 void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
102 unsigned Reg1, unsigned Reg2, unsigned FPReg1,
103 unsigned FPReg2, bool LE);
104
105 void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
107 bool ToFP);
108
109 void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
111
112 void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
113
114 bool isLongBranchPseudo(int Opcode) const;
115
116public:
117 static char ID;
118
122
124 std::unique_ptr<MCStreamer> Streamer)
125 : AsmPrinter(TM, std::move(Streamer), ID), MCInstLowering(*this) {}
126
127 StringRef getPassName() const override { return "Mips Assembly Printer"; }
128
129 bool runOnMachineFunction(MachineFunction &MF) override;
130
131 void emitConstantPool() override {
132 bool UsingConstantPools =
133 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
134 if (!UsingConstantPools)
136 // we emit constant pools customly!
137 }
138
139 void emitInstruction(const MachineInstr *MI) override;
140 void printSavedRegsBitmask();
141 void emitFrameDirective();
142 const char *getCurrentABIString() const;
143 void emitFunctionEntryLabel() override;
144 void emitFunctionBodyStart() override;
145 void emitFunctionBodyEnd() override;
146 void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
147 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
148 const char *ExtraCode, raw_ostream &O) override;
149 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
150 const char *ExtraCode, raw_ostream &O) override;
151 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
152 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
153 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
154 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
155 void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
156 void emitStartOfAsmFile(Module &M) override;
157 void emitEndOfAsmFile(Module &M) override;
158 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
159 void emitDebugValue(const MCExpr *Value, unsigned Size) const override;
160 void emitDirectiveRelocJalr(const MachineInstr &MI, MCContext &OutContext,
161 TargetMachine &TM, MCStreamer &OutStreamer,
162 const MipsSubtarget &Subtarget);
163};
164
165} // end namespace llvm
166
167#endif // LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
MachineBasicBlock & MBB
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
IRTranslator LLVM IR MI
Register Reg
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, const MachineFunction *MF, const Module *M, const MachineFrameInfo *MFI, const TargetInstrInfo *TII, LLVMContext &Ctx)
std::unique_ptr< MCStreamer > && Streamer
virtual void emitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:106
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MipsAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
void emitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI)
MipsMCInstLower MCInstLowering
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI)
const MipsSubtarget * Subtarget
const MipsFunctionInfo * MipsFI
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
MipsMCInstLower - This class is used to lower an MachineInstr into an MCInst.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878