LLVM  13.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"
21 #include "llvm/Support/Compiler.h"
22 #include <algorithm>
23 #include <map>
24 #include <memory>
25 
26 namespace llvm {
27 
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;
41 
43  MipsTargetStreamer &getTargetStreamer() const;
44 
45  void EmitInstrWithMacroNoAT(const MachineInstr *MI);
46 
47  //===------------------------------------------------------------------===//
48  // XRay implementation
49  //===------------------------------------------------------------------===//
50 
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);
56 
57 private:
58  /// MCP - Keep a pointer to constantpool entries of the current
59  /// MachineFunction.
60  const MachineConstantPool *MCP = nullptr;
61 
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;
65 
66  std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
67  StubsNeeded;
68 
69  void EmitSled(const MachineInstr &MI, SledKind Kind);
70 
71  // tblgen'erated function.
72  bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
73  const MachineInstr *MI);
74 
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);
80 
81  // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
82  bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
83 
84  void emitInlineAsmStart() const override;
85 
86  void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
87  const MCSubtargetInfo *EndInfo) const override;
88 
89  void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
90 
91  void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
92 
93  void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
94  unsigned Reg1, unsigned Reg2);
95 
96  void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
97  unsigned Reg1, unsigned Reg2, unsigned Reg3);
98 
99  void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
100  unsigned Reg1, unsigned Reg2, unsigned FPReg1,
101  unsigned FPReg2, bool LE);
102 
103  void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
105  bool ToFP);
106 
107  void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
109 
110  void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
111 
112  void NaClAlignIndirectJumpTargets(MachineFunction &MF);
113 
114  bool isLongBranchPseudo(int Opcode) const;
115 
116 public:
120 
122  std::unique_ptr<MCStreamer> Streamer)
123  : AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*this) {}
124 
125  StringRef getPassName() const override { return "Mips Assembly Printer"; }
126 
127  bool runOnMachineFunction(MachineFunction &MF) override;
128 
129  void emitConstantPool() override {
130  bool UsingConstantPools =
131  (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
132  if (!UsingConstantPools)
134  // we emit constant pools customly!
135  }
136 
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 isBlockOnlyReachableByFallthrough(
146  const MachineBasicBlock* MBB) const 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  const char *Modifier = nullptr);
156  void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
157  void emitStartOfAsmFile(Module &M) override;
158  void emitEndOfAsmFile(Module &M) override;
159  void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
160  void emitDebugValue(const MCExpr *Value, unsigned Size) const override;
161 };
162 
163 } // end namespace llvm
164 
165 #endif // LLVM_LIB_TARGET_MIPS_MIPSASMPRINTER_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::EngineKind::Kind
Kind
Definition: ExecutionEngine.h:524
AsmPrinter.h
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:100
llvm
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::Mips16HardFloatInfo::FPParamVariant
FPParamVariant
Definition: Mips16HardFloatInfo.h:31
llvm::MipsAsmPrinter::MipsFI
const MipsFunctionInfo * MipsFI
Definition: MipsAsmPrinter.h:118
printOperand
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
Definition: SelectionDAGDumper.cpp:944
llvm::AsmPrinter::SledKind
SledKind
Definition: AsmPrinter.h:279
llvm::MipsAsmPrinter::MCInstLowering
MipsMCInstLower MCInstLowering
Definition: MipsAsmPrinter.h:119
llvm::MipsSubtarget::useConstantIslands
static bool useConstantIslands()
Definition: MipsSubtarget.cpp:266
llvm::MipsFunctionInfo
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
Definition: MipsMachineFunction.h:25
llvm::MipsAsmPrinter::MipsAsmPrinter
MipsAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
Definition: MipsAsmPrinter.h:121
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
llvm::MipsSubtarget::inMips16Mode
bool inMips16Mode() const
Definition: MipsSubtarget.h:300
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::Mips16HardFloatInfo::FuncSignature
Definition: Mips16HardFloatInfo.h:33
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::AArch64CC::LE
@ LE
Definition: AArch64BaseInfo.h:249
llvm::MipsAsmPrinter
Definition: MipsAsmPrinter.h:42
llvm::MipsAsmPrinter::Subtarget
const MipsSubtarget * Subtarget
Definition: MipsAsmPrinter.h:117
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::Mips16HardFloatInfo::FPReturnVariant
FPReturnVariant
Definition: Mips16HardFloatInfo.h:25
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:128
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::MipsMCInstLower
MipsMCInstLower - This class is used to lower an MachineInstr into an MCInst.
Definition: MipsMCInstLower.h:27
llvm::MachineConstantPool
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Definition: MachineConstantPool.h:117
printMemOperand
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, const MachineFunction *MF, const Module *M, const MachineFrameInfo *MFI, const TargetInstrInfo *TII, LLVMContext &Ctx)
Definition: SelectionDAGDumper.cpp:511
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::move
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:1563
llvm::MipsAsmPrinter::getPassName
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition: MipsAsmPrinter.h:125
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
Compiler.h
LLVM_LIBRARY_VISIBILITY
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library,...
Definition: Compiler.h:131
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::MipsSubtarget
Definition: MipsSubtarget.h:39
MipsMCInstLower.h
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
std
Definition: BitVector.h:955
llvm::MipsTargetStreamer
Definition: MipsTargetStreamer.h:24
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::MipsAsmPrinter::emitConstantPool
void emitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Definition: MipsAsmPrinter.h:129
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
Mips16HardFloatInfo.h
MCStreamer.h
MipsSubtarget.h
llvm::MCOperand
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::AsmPrinter::emitConstantPool
virtual void emitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Definition: AsmPrinter.cpp:1942
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:165