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 *);
78 const MipsSubtarget *Subtarget;
79 const MipsFunctionInfo *MipsFI;
80 MipsMCInstLower MCInstLowering;
82 explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
83 : AsmPrinter(TM, Streamer), MCP(0), InConstantPool(false),
84 MCInstLowering(*this) {
85 Subtarget = &TM.getSubtarget<MipsSubtarget>();
88 virtual const char *getPassName() const {
89 return "Mips Assembly Printer";
92 virtual bool runOnMachineFunction(MachineFunction &MF);
94 virtual void EmitConstantPool() LLVM_OVERRIDE {
95 bool UsingConstantPools =
96 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
97 if (!UsingConstantPools)
98 AsmPrinter::EmitConstantPool();
99 // we emit constant pools customly!
102 void EmitInstruction(const MachineInstr *MI);
103 void printSavedRegsBitmask();
104 void emitFrameDirective();
105 const char *getCurrentABIString() const;
106 virtual void EmitFunctionEntryLabel();
107 virtual void EmitFunctionBodyStart();
108 virtual void EmitFunctionBodyEnd();
109 virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
111 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
112 unsigned AsmVariant, const char *ExtraCode,
114 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
115 unsigned AsmVariant, const char *ExtraCode,
117 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
118 void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
119 void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
120 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
121 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
122 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
123 const char *Modifier = 0);
124 void EmitStartOfAsmFile(Module &M);
125 void EmitEndOfAsmFile(Module &M);
126 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);