LLVM  5.0.0
MipsAsmPrinter.h
Go to the documentation of this file.
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 "MipsMachineFunction.h"
20 #include "MipsSubtarget.h"
22 #include "llvm/Support/Compiler.h"
24 
25 namespace llvm {
26 class MCStreamer;
27 class MachineInstr;
28 class MachineBasicBlock;
29 class MipsTargetStreamer;
30 class Module;
31 class raw_ostream;
32 
34  MipsTargetStreamer &getTargetStreamer() const;
35 
36  void EmitInstrWithMacroNoAT(const MachineInstr *MI);
37 
38  //===------------------------------------------------------------------===//
39  // XRay implementation
40  //===------------------------------------------------------------------===//
41 public:
42  // XRay-specific lowering for Mips.
43  void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
44  void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
45  void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
46  // Helper function that emits the XRay sleds we've collected for a particular
47  // function.
48  void EmitXRayTable();
49 
50 private:
51  void EmitSled(const MachineInstr &MI, SledKind Kind);
52 
53  // tblgen'erated function.
54  bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
55  const MachineInstr *MI);
56 
57  // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,
58  // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate
59  // for the target.
60  void emitPseudoIndirectBranch(MCStreamer &OutStreamer,
61  const MachineInstr *MI);
62 
63  // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
64  bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
65 
66  /// MCP - Keep a pointer to constantpool entries of the current
67  /// MachineFunction.
68  const MachineConstantPool *MCP;
69 
70  /// InConstantPool - Maintain state when emitting a sequence of constant
71  /// pool entries so we can properly mark them as data regions.
72  bool InConstantPool;
73 
74  std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
75  StubsNeeded;
76 
77  void emitInlineAsmStart() const override;
78 
79  void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
80  const MCSubtargetInfo *EndInfo) const override;
81 
82  void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
83 
84  void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
85 
86  void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
87  unsigned Reg1, unsigned Reg2);
88 
89  void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
90  unsigned Reg1, unsigned Reg2, unsigned Reg3);
91 
92  void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
93  unsigned Reg1, unsigned Reg2, unsigned FPReg1,
94  unsigned FPReg2, bool LE);
95 
96  void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
98  bool ToFP);
99 
100  void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
102 
103  void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
104 
105  void NaClAlignIndirectJumpTargets(MachineFunction &MF);
106 
107  bool isLongBranchPseudo(int Opcode) const;
108 
109 public:
110 
114 
116  std::unique_ptr<MCStreamer> Streamer)
117  : AsmPrinter(TM, std::move(Streamer)), MCP(nullptr),
118  InConstantPool(false), MCInstLowering(*this) {}
119 
120  StringRef getPassName() const override { return "Mips Assembly Printer"; }
121 
122  bool runOnMachineFunction(MachineFunction &MF) override;
123 
124  void EmitConstantPool() override {
125  bool UsingConstantPools =
126  (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
127  if (!UsingConstantPools)
129  // we emit constant pools customly!
130  }
131 
132  void EmitInstruction(const MachineInstr *MI) override;
133  void printSavedRegsBitmask();
134  void emitFrameDirective();
135  const char *getCurrentABIString() const;
136  void EmitFunctionEntryLabel() override;
137  void EmitFunctionBodyStart() override;
138  void EmitFunctionBodyEnd() override;
139  void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override;
140  bool isBlockOnlyReachableByFallthrough(
141  const MachineBasicBlock* MBB) const override;
142  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
143  unsigned AsmVariant, const char *ExtraCode,
144  raw_ostream &O) override;
145  bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
146  unsigned AsmVariant, const char *ExtraCode,
147  raw_ostream &O) override;
148  void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
149  void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
150  void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
151  void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
152  const char *Modifier = nullptr);
153  void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
154  void EmitStartOfAsmFile(Module &M) override;
155  void EmitEndOfAsmFile(Module &M) override;
156  void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
157  void EmitDebugThreadLocal(const MCExpr *Value, unsigned Size) const override;
158 };
159 }
160 
161 #endif
162 
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Reg
All possible values of the reg field in the ModR/M byte.
MipsMCInstLower - This class is used to lower an MachineInstr into an.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
void EmitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Function Alias Analysis false
Streaming machine code generation interface.
Definition: MCStreamer.h:167
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:76
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:105
MipsMCInstLower MCInstLowering
MipsAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineOperand class - Representation of each machine instruction operand.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Representation of each machine instruction.
Definition: MachineInstr.h:59
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
const MipsSubtarget * Subtarget
MCSubtargetInfo - Generic base class for all target subtargets.
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
const unsigned Kind
LLVM Value Representation.
Definition: Value.h:73
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
const MipsFunctionInfo * MipsFI
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35