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 "MipsMCInstLower.h"
18 #include "MipsMachineFunction.h"
19 #include "MipsSubtarget.h"
20 #include "llvm/CodeGen/AsmPrinter.h"
21 #include "llvm/Support/Compiler.h"
22 #include "llvm/Target/TargetMachine.h"
27 class MachineBasicBlock;
28 class MipsTargetStreamer;
32 class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
33 MipsTargetStreamer &getTargetStreamer();
35 void EmitInstrWithMacroNoAT(const MachineInstr *MI);
38 // tblgen'erated function.
39 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
40 const MachineInstr *MI);
42 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
43 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
45 /// MCP - Keep a pointer to constantpool entries of the current
47 const MachineConstantPool *MCP;
49 /// InConstantPool - Maintain state when emitting a sequence of constant
50 /// pool entries so we can properly mark them as data regions.
56 const MipsSubtarget *Subtarget;
57 const MipsFunctionInfo *MipsFI;
58 MipsMCInstLower MCInstLowering;
60 explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
61 : AsmPrinter(TM, Streamer), MCP(0), InConstantPool(false),
62 MCInstLowering(*this) {
63 Subtarget = &TM.getSubtarget<MipsSubtarget>();
66 virtual const char *getPassName() const {
67 return "Mips Assembly Printer";
70 virtual bool runOnMachineFunction(MachineFunction &MF);
72 virtual void EmitConstantPool() LLVM_OVERRIDE {
73 bool UsingConstantPools =
74 (Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
75 if (!UsingConstantPools)
76 AsmPrinter::EmitConstantPool();
77 // we emit constant pools customly!
80 void EmitInstruction(const MachineInstr *MI);
81 void printSavedRegsBitmask(raw_ostream &O);
82 void printHex32(unsigned int Value, raw_ostream &O);
83 void emitFrameDirective();
84 const char *getCurrentABIString() const;
85 virtual void EmitFunctionEntryLabel();
86 virtual void EmitFunctionBodyStart();
87 virtual void EmitFunctionBodyEnd();
88 virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
90 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
91 unsigned AsmVariant, const char *ExtraCode,
93 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
94 unsigned AsmVariant, const char *ExtraCode,
96 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
97 void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
98 void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
99 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
100 void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
101 void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
102 const char *Modifier = 0);
103 void EmitStartOfAsmFile(Module &M);
104 void EmitEndOfAsmFile(Module &M);
105 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);