LLVM  4.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 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  StringRef getPassName() const override { return "Mips Assembly Printer"; }
107 
108  bool runOnMachineFunction(MachineFunction &MF) override;
109 
110  void EmitConstantPool() override {
111  bool UsingConstantPools =
112  (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
113  if (!UsingConstantPools)
115  // we emit constant pools customly!
116  }
117 
118  void EmitInstruction(const MachineInstr *MI) override;
119  void printSavedRegsBitmask();
120  void emitFrameDirective();
121  const char *getCurrentABIString() const;
122  void EmitFunctionEntryLabel() override;
123  void EmitFunctionBodyStart() override;
124  void EmitFunctionBodyEnd() override;
125  void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override;
126  bool isBlockOnlyReachableByFallthrough(
127  const MachineBasicBlock* MBB) const override;
128  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
129  unsigned AsmVariant, const char *ExtraCode,
130  raw_ostream &O) override;
131  bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
132  unsigned AsmVariant, const char *ExtraCode,
133  raw_ostream &O) override;
134  void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
135  void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
136  void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
137  void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
138  const char *Modifier = nullptr);
139  void printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O);
140  void EmitStartOfAsmFile(Module &M) override;
141  void EmitEndOfAsmFile(Module &M) override;
142  void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
143  void EmitDebugValue(const MCExpr *Value, unsigned Size) const override;
144 };
145 }
146 
147 #endif
148 
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:52
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:34
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.
MachineBasicBlock * MBB
Function Alias Analysis false
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:161
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:67
#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.
Representation of each machine instruction.
Definition: MachineInstr.h:52
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...
LLVM Value Representation.
Definition: Value.h:71
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.
const MipsFunctionInfo * MipsFI
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:33