2012-02-17 01:23:50 +00:00
|
|
|
//===-- MipsAsmPrinter.h - Mips LLVM Assembly Printer ----------*- C++ -*--===//
|
2011-07-07 20:10:52 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Mips Assembly printer class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MIPSASMPRINTER_H
|
|
|
|
#define MIPSASMPRINTER_H
|
|
|
|
|
2014-02-14 19:16:39 +00:00
|
|
|
#include "Mips16HardFloatInfo.h"
|
2012-03-28 00:22:50 +00:00
|
|
|
#include "MipsMCInstLower.h"
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "MipsMachineFunction.h"
|
2011-07-07 20:10:52 +00:00
|
|
|
#include "MipsSubtarget.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MCStreamer;
|
|
|
|
class MachineInstr;
|
|
|
|
class MachineBasicBlock;
|
2013-10-08 13:08:17 +00:00
|
|
|
class MipsTargetStreamer;
|
2011-07-07 20:10:52 +00:00
|
|
|
class Module;
|
2012-03-17 18:46:09 +00:00
|
|
|
class raw_ostream;
|
2011-07-07 20:10:52 +00:00
|
|
|
|
|
|
|
class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public AsmPrinter {
|
2013-10-08 13:08:17 +00:00
|
|
|
MipsTargetStreamer &getTargetStreamer();
|
2011-11-23 22:19:28 +00:00
|
|
|
|
2012-03-28 00:22:50 +00:00
|
|
|
void EmitInstrWithMacroNoAT(const MachineInstr *MI);
|
|
|
|
|
2012-09-27 01:59:07 +00:00
|
|
|
private:
|
|
|
|
// tblgen'erated function.
|
|
|
|
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
|
|
|
const MachineInstr *MI);
|
|
|
|
|
|
|
|
// lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
|
|
|
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
|
|
|
|
2013-10-27 21:57:36 +00:00
|
|
|
/// MCP - Keep a pointer to constantpool entries of the current
|
|
|
|
/// MachineFunction.
|
|
|
|
const MachineConstantPool *MCP;
|
|
|
|
|
|
|
|
/// InConstantPool - Maintain state when emitting a sequence of constant
|
|
|
|
/// pool entries so we can properly mark them as data regions.
|
|
|
|
bool InConstantPool;
|
|
|
|
|
2014-02-14 19:16:39 +00:00
|
|
|
std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
|
|
|
|
StubsNeeded;
|
|
|
|
|
|
|
|
void EmitJal(MCSymbol *Symbol);
|
|
|
|
|
|
|
|
void EmitInstrReg(unsigned Opcode, unsigned Reg);
|
|
|
|
|
|
|
|
void EmitInstrRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2);
|
|
|
|
|
|
|
|
void EmitInstrRegRegReg(unsigned Opcode, unsigned Reg1, unsigned Reg2,
|
|
|
|
unsigned Reg3);
|
|
|
|
|
|
|
|
void EmitMovFPIntPair(unsigned MovOpc, unsigned Reg1, unsigned Reg2,
|
|
|
|
unsigned FPReg1, unsigned FPReg2, bool LE);
|
|
|
|
|
|
|
|
void EmitSwapFPIntParams(Mips16HardFloatInfo::FPParamVariant, bool LE,
|
|
|
|
bool ToFP);
|
|
|
|
|
|
|
|
void EmitSwapFPIntRetval(Mips16HardFloatInfo::FPReturnVariant, bool LE);
|
|
|
|
|
|
|
|
void EmitFPCallStub(const char *, const Mips16HardFloatInfo::FuncSignature *);
|
2013-10-27 21:57:36 +00:00
|
|
|
|
2014-02-28 10:00:38 +00:00
|
|
|
void NaClAlignIndirectJumpTargets(MachineFunction &MF);
|
|
|
|
|
2011-07-07 20:10:52 +00:00
|
|
|
public:
|
2011-11-23 22:19:28 +00:00
|
|
|
|
|
|
|
const MipsSubtarget *Subtarget;
|
2012-03-28 00:22:50 +00:00
|
|
|
const MipsFunctionInfo *MipsFI;
|
|
|
|
MipsMCInstLower MCInstLowering;
|
2011-11-23 22:19:28 +00:00
|
|
|
|
2011-07-07 20:10:52 +00:00
|
|
|
explicit MipsAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
2014-04-28 04:05:08 +00:00
|
|
|
: AsmPrinter(TM, Streamer), MCP(nullptr), InConstantPool(false),
|
2013-10-27 21:57:36 +00:00
|
|
|
MCInstLowering(*this) {
|
2011-07-07 20:10:52 +00:00
|
|
|
Subtarget = &TM.getSubtarget<MipsSubtarget>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "Mips Assembly Printer";
|
|
|
|
}
|
|
|
|
|
2012-03-28 00:22:50 +00:00
|
|
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
|
|
|
|
2014-03-02 09:09:27 +00:00
|
|
|
virtual void EmitConstantPool() override {
|
2013-11-26 20:38:40 +00:00
|
|
|
bool UsingConstantPools =
|
|
|
|
(Subtarget->inMips16Mode() && Subtarget->useConstantIslands());
|
2013-10-27 21:57:36 +00:00
|
|
|
if (!UsingConstantPools)
|
|
|
|
AsmPrinter::EmitConstantPool();
|
|
|
|
// we emit constant pools customly!
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:10:52 +00:00
|
|
|
void EmitInstruction(const MachineInstr *MI);
|
2014-01-27 04:33:11 +00:00
|
|
|
void printSavedRegsBitmask();
|
2011-07-07 20:10:52 +00:00
|
|
|
void emitFrameDirective();
|
|
|
|
const char *getCurrentABIString() const;
|
|
|
|
virtual void EmitFunctionEntryLabel();
|
|
|
|
virtual void EmitFunctionBodyStart();
|
|
|
|
virtual void EmitFunctionBodyEnd();
|
|
|
|
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
|
|
|
|
MBB) const;
|
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O);
|
|
|
|
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode,
|
|
|
|
raw_ostream &O);
|
|
|
|
void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
|
|
|
|
void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O);
|
2013-11-12 10:45:18 +00:00
|
|
|
void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O);
|
2011-07-07 20:54:20 +00:00
|
|
|
void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O);
|
|
|
|
void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O);
|
2011-07-07 20:10:52 +00:00
|
|
|
void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O,
|
2014-04-28 04:05:08 +00:00
|
|
|
const char *Modifier = nullptr);
|
2011-07-07 20:10:52 +00:00
|
|
|
void EmitStartOfAsmFile(Module &M);
|
2014-02-14 19:16:39 +00:00
|
|
|
void EmitEndOfAsmFile(Module &M);
|
2011-07-07 20:10:52 +00:00
|
|
|
void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|