1 //===-- MipsAsmPrinter.h - Mips LLVM Assembly Printer ----------*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Mips Assembly printer class.
12 //===----------------------------------------------------------------------===//
14 #ifndef MIPSASMPRINTER_H
15 #define MIPSASMPRINTER_H
17 #include "Mips16HardFloatInfo.h"
18 #include "MipsMCInstLower.h"
19 #include "MipsMachineFunction.h"
20 #include "MipsSubtarget.h"
21 #include "llvm/CodeGen/AsmPrinter.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Target/TargetMachine.h"
28 class MachineBasicBlock;
29 class MipsTargetStreamer;
33 class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
34 MipsTargetStreamer &getTargetStreamer();
36 void EmitInstrWithMacroNoAT(const MachineInstr *MI);
39 // tblgen'erated function.
40 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
41 const MachineInstr *MI);
43 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
44 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
46 /// MCP - Keep a pointer to constantpool entries of the current
48 const MachineConstantPool *MCP;
50 /// InConstantPool - Maintain state when emitting a sequence of constant
51 /// pool entries so we can properly mark them as data regions.
54 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
57 void EmitJal(MCSymbol *Symbol);
59 void EmitInstrReg(unsigned Opcode, unsigned Reg);
61 void EmitInstrRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2);
63 void EmitInstrRegRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2,
66 void EmitMovFPIntPair(unsigned MovOpc, unsigned Reg1, unsigned Reg2,
67 unsigned FPReg1, unsigned FPReg2, bool LE);
69 void EmitSwapFPIntParams(Mips16HardFloatInfo::FPParamVariant, bool LE,
72 void EmitSwapFPIntRetval(Mips16HardFloatInfo::FPReturnVariant, bool LE);
74 void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
76 void NaClAlignIndirectJumpTargets(MachineFunction &MF);
78 bool isLongBranchPseudo(int Opcode) const;
82 const MipsSubtarget *Subtarget;
83 const MipsFunctionInfo *MipsFI;
84 MipsMCInstLower MCInstLowering;
86 explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
87 : AsmPrinter(TM, Streamer), MCP(nullptr), InConstantPool(false),
88 MCInstLowering(*this) {
89 Subtarget = &TM.getSubtarget<MipsSubtarget>();
92 const char *getPassName() const override {
93 return "Mips Assembly Printer";
96 bool runOnMachineFunction(MachineFunction &MF) override;
98 void EmitConstantPool() override {
99 bool UsingConstantPools =
100 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
101 if (!UsingConstantPools)
102 AsmPrinter::EmitConstantPool();
103 // we emit constant pools customly!
106 void EmitInstruction(const MachineInstr *MI) override;
107 void printSavedRegsBitmask();
108 void emitFrameDirective();
109 const char *getCurrentABIString() const;
110 void EmitFunctionEntryLabel() override;
111 void EmitFunctionBodyStart() override;
112 void EmitFunctionBodyEnd() override;
113 bool isBlockOnlyReachableByFallthrough(
114 const MachineBasicBlock* MBB) const override;
115 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
116 unsigned AsmVariant, const char *ExtraCode,
117 raw_ostream &O) override;
118 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
119 unsigned AsmVariant, const char *ExtraCode,
120 raw_ostream &O) override;
121 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
122 void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
123 void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
124 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
125 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
126 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
127 const char *Modifier = nullptr);
128 void EmitStartOfAsmFile(Module &M) override;
129 void EmitEndOfAsmFile(Module &M) override;
130 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);