LLVM  3.7.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 private:
39  // tblgen'erated function.
40  bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
41  const MachineInstr *MI);
42 
43  // Emit PseudoReturn, PseudoReturn64, PseudoIndirectBranch,
44  // and PseudoIndirectBranch64 as a JR, JR_MM, JALR, or JALR64 as appropriate
45  // for the target.
46  void emitPseudoIndirectBranch(MCStreamer &OutStreamer,
47  const MachineInstr *MI);
48 
49  // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
50  bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
51 
52  /// MCP - Keep a pointer to constantpool entries of the current
53  /// MachineFunction.
54  const MachineConstantPool *MCP;
55 
56  /// InConstantPool - Maintain state when emitting a sequence of constant
57  /// pool entries so we can properly mark them as data regions.
58  bool InConstantPool;
59 
60  std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
61  StubsNeeded;
62 
63  void emitInlineAsmStart() const override;
64 
65  void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
66  const MCSubtargetInfo *EndInfo) const override;
67 
68  void EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol);
69 
70  void EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, unsigned Reg);
71 
72  void EmitInstrRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
73  unsigned Reg1, unsigned Reg2);
74 
75  void EmitInstrRegRegReg(const MCSubtargetInfo &STI, unsigned Opcode,
76  unsigned Reg1, unsigned Reg2, unsigned Reg3);
77 
78  void EmitMovFPIntPair(const MCSubtargetInfo &STI, unsigned MovOpc,
79  unsigned Reg1, unsigned Reg2, unsigned FPReg1,
80  unsigned FPReg2, bool LE);
81 
82  void EmitSwapFPIntParams(const MCSubtargetInfo &STI,
84  bool ToFP);
85 
86  void EmitSwapFPIntRetval(const MCSubtargetInfo &STI,
88 
89  void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
90 
91  void NaClAlignIndirectJumpTargets(MachineFunction &MF);
92 
93  bool isLongBranchPseudo(int Opcode) const;
94 
95 public:
96 
100 
102  std::unique_ptr<MCStreamer> Streamer)
103  : AsmPrinter(TM, std::move(Streamer)), MCP(nullptr),
104  InConstantPool(false), MCInstLowering(*this) {}
105 
106  const char *getPassName() const override {
107  return "Mips Assembly Printer";
108  }
109 
110  bool runOnMachineFunction(MachineFunction &MF) override;
111 
112  void EmitConstantPool() override {
113  bool UsingConstantPools =
114  (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
115  if (!UsingConstantPools)
117  // we emit constant pools customly!
118  }
119 
120  void EmitInstruction(const MachineInstr *MI) override;
121  void printSavedRegsBitmask();
122  void emitFrameDirective();
123  const char *getCurrentABIString() const;
124  void EmitFunctionEntryLabel() override;
125  void EmitFunctionBodyStart() override;
126  void EmitFunctionBodyEnd() override;
127  void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override;
128  bool isBlockOnlyReachableByFallthrough(
129  const MachineBasicBlock* MBB) const override;
130  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
131  unsigned AsmVariant, const char *ExtraCode,
132  raw_ostream &O) override;
133  bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
134  unsigned AsmVariant, const char *ExtraCode,
135  raw_ostream &O) override;
136  void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
137  void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
138  void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
139  void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
140  void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
141  void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
142  const char *Modifier = nullptr);
143  void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
144  void EmitStartOfAsmFile(Module &M) override;
145  void EmitEndOfAsmFile(Module &M) override;
146  void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
147 };
148 }
149 
150 #endif
151 
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:39
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const char * getPassName() const override
getPassName - Return a nice clean name for a pass.
virtual void EmitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Reg
All possible values of the reg field in the ModR/M byte.
MipsMCInstLower - This class is used to lower an MachineInstr into an.
#define false
Definition: ConvertUTF.c:65
static void printOperand(raw_ostream &OS, uint8_t Opcode, unsigned OperandIdx, uint64_t Operand, uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor)
Print Opcode's operand number OperandIdx which has value Operand.
void EmitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
Streaming machine code generation interface.
Definition: MCStreamer.h:157
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:110
MipsMCInstLower MCInstLowering
MipsAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineOperand class - Representation of each machine instruction operand.
Representation of each machine instruction.
Definition: MachineInstr.h:51
const MipsSubtarget * Subtarget
MCSubtargetInfo - Generic base class for all target subtargets.
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Primary interface to the complete machine description for the target machine.
const MipsFunctionInfo * MipsFI
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:33