2013-10-08 13:08:17 +00:00
|
|
|
//===-- MipsTargetStreamer.h - Mips Target Streamer ------------*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H
|
|
|
|
#define LLVM_LIB_TARGET_MIPS_MIPSTARGETSTREAMER_H
|
2013-10-08 13:08:17 +00:00
|
|
|
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "MCTargetDesc/MipsABIFlagsSection.h"
|
2015-01-26 17:33:46 +00:00
|
|
|
#include "MCTargetDesc/MipsABIInfo.h"
|
2013-11-18 23:55:27 +00:00
|
|
|
#include "llvm/MC/MCELFStreamer.h"
|
2014-08-13 10:07:34 +00:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2013-10-08 13:08:17 +00:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2014-07-08 08:59:22 +00:00
|
|
|
|
2014-07-08 13:13:42 +00:00
|
|
|
struct MipsABIFlagsSection;
|
2014-07-08 08:59:22 +00:00
|
|
|
|
2013-10-08 13:08:17 +00:00
|
|
|
class MipsTargetStreamer : public MCTargetStreamer {
|
|
|
|
public:
|
2014-01-26 06:06:37 +00:00
|
|
|
MipsTargetStreamer(MCStreamer &S);
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetMicroMips();
|
|
|
|
virtual void emitDirectiveSetNoMicroMips();
|
|
|
|
virtual void emitDirectiveSetMips16();
|
|
|
|
virtual void emitDirectiveSetNoMips16();
|
2014-01-26 05:06:48 +00:00
|
|
|
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetReorder();
|
|
|
|
virtual void emitDirectiveSetNoReorder();
|
|
|
|
virtual void emitDirectiveSetMacro();
|
|
|
|
virtual void emitDirectiveSetNoMacro();
|
2014-08-07 12:03:36 +00:00
|
|
|
virtual void emitDirectiveSetMsa();
|
|
|
|
virtual void emitDirectiveSetNoMsa();
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetAt();
|
2015-02-13 10:30:57 +00:00
|
|
|
virtual void emitDirectiveSetAtWithArg(unsigned RegNo);
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetNoAt();
|
|
|
|
virtual void emitDirectiveEnd(StringRef Name);
|
2014-01-26 05:06:48 +00:00
|
|
|
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveEnt(const MCSymbol &Symbol);
|
|
|
|
virtual void emitDirectiveAbiCalls();
|
|
|
|
virtual void emitDirectiveNaN2008();
|
|
|
|
virtual void emitDirectiveNaNLegacy();
|
|
|
|
virtual void emitDirectiveOptionPic0();
|
|
|
|
virtual void emitDirectiveOptionPic2();
|
2015-04-16 09:53:47 +00:00
|
|
|
virtual void emitDirectiveInsn();
|
2014-01-27 03:53:56 +00:00
|
|
|
virtual void emitFrame(unsigned StackReg, unsigned StackSize,
|
2014-06-23 19:43:40 +00:00
|
|
|
unsigned ReturnReg);
|
|
|
|
virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff);
|
|
|
|
virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff);
|
2014-03-04 09:54:09 +00:00
|
|
|
|
2014-08-19 14:22:52 +00:00
|
|
|
virtual void emitDirectiveSetArch(StringRef Arch);
|
2014-09-09 12:52:14 +00:00
|
|
|
virtual void emitDirectiveSetMips0();
|
2014-08-04 12:20:00 +00:00
|
|
|
virtual void emitDirectiveSetMips1();
|
|
|
|
virtual void emitDirectiveSetMips2();
|
|
|
|
virtual void emitDirectiveSetMips3();
|
|
|
|
virtual void emitDirectiveSetMips4();
|
|
|
|
virtual void emitDirectiveSetMips5();
|
|
|
|
virtual void emitDirectiveSetMips32();
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetMips32R2();
|
2015-02-18 16:24:50 +00:00
|
|
|
virtual void emitDirectiveSetMips32R3();
|
|
|
|
virtual void emitDirectiveSetMips32R5();
|
2014-08-04 12:20:00 +00:00
|
|
|
virtual void emitDirectiveSetMips32R6();
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetMips64();
|
|
|
|
virtual void emitDirectiveSetMips64R2();
|
2015-02-18 16:24:50 +00:00
|
|
|
virtual void emitDirectiveSetMips64R3();
|
|
|
|
virtual void emitDirectiveSetMips64R5();
|
2014-08-04 12:20:00 +00:00
|
|
|
virtual void emitDirectiveSetMips64R6();
|
2014-06-23 19:43:40 +00:00
|
|
|
virtual void emitDirectiveSetDsp();
|
2014-09-17 09:01:54 +00:00
|
|
|
virtual void emitDirectiveSetNoDsp();
|
2014-09-09 10:15:38 +00:00
|
|
|
virtual void emitDirectiveSetPop();
|
|
|
|
virtual void emitDirectiveSetPush();
|
2015-06-02 09:48:04 +00:00
|
|
|
virtual void emitDirectiveSetSoftFloat();
|
|
|
|
virtual void emitDirectiveSetHardFloat();
|
2014-04-30 11:28:42 +00:00
|
|
|
|
|
|
|
// PIC support
|
2014-10-01 14:53:19 +00:00
|
|
|
virtual void emitDirectiveCpLoad(unsigned RegNo);
|
2014-05-01 10:24:46 +00:00
|
|
|
virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
2014-06-23 19:43:40 +00:00
|
|
|
const MCSymbol &Sym, bool IsReg);
|
2014-07-10 13:38:23 +00:00
|
|
|
|
2015-06-25 12:44:38 +00:00
|
|
|
// FP abiflags directives
|
|
|
|
virtual void emitDirectiveModuleFP();
|
2015-06-25 10:56:57 +00:00
|
|
|
virtual void emitDirectiveModuleOddSPReg();
|
2015-06-30 13:46:03 +00:00
|
|
|
virtual void emitDirectiveModuleSoftFloat();
|
|
|
|
virtual void emitDirectiveModuleHardFloat();
|
2015-03-06 12:15:12 +00:00
|
|
|
virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
|
2015-06-30 09:36:50 +00:00
|
|
|
virtual void emitDirectiveSetOddSPReg();
|
|
|
|
virtual void emitDirectiveSetNoOddSPReg();
|
2015-06-25 12:44:38 +00:00
|
|
|
|
2014-08-14 09:18:14 +00:00
|
|
|
void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
|
2015-03-06 12:15:12 +00:00
|
|
|
void reallowModuleDirective() { ModuleDirectiveAllowed = true; }
|
2014-08-14 09:18:14 +00:00
|
|
|
bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; }
|
2014-07-08 08:59:22 +00:00
|
|
|
|
|
|
|
// This method enables template classes to set internal abi flags
|
|
|
|
// structure values.
|
|
|
|
template <class PredicateLibrary>
|
|
|
|
void updateABIInfo(const PredicateLibrary &P) {
|
2015-01-26 17:33:46 +00:00
|
|
|
ABI = &P.getABI();
|
2014-07-08 10:11:38 +00:00
|
|
|
ABIFlagsSection.setAllFromPredicates(P);
|
2014-07-08 08:59:22 +00:00
|
|
|
}
|
|
|
|
|
2014-07-08 10:11:38 +00:00
|
|
|
MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; }
|
2015-01-26 17:33:46 +00:00
|
|
|
const MipsABIInfo &getABI() const {
|
|
|
|
assert(ABI && "ABI hasn't been set!");
|
|
|
|
return *ABI;
|
|
|
|
}
|
2014-07-08 10:11:38 +00:00
|
|
|
|
2014-07-08 08:59:22 +00:00
|
|
|
protected:
|
2015-01-26 17:33:46 +00:00
|
|
|
const MipsABIInfo *ABI;
|
2014-07-08 10:11:38 +00:00
|
|
|
MipsABIFlagsSection ABIFlagsSection;
|
2014-07-08 08:59:22 +00:00
|
|
|
|
2014-08-13 10:07:34 +00:00
|
|
|
bool GPRInfoSet;
|
|
|
|
unsigned GPRBitMask;
|
|
|
|
int GPROffset;
|
|
|
|
|
|
|
|
bool FPRInfoSet;
|
|
|
|
unsigned FPRBitMask;
|
|
|
|
int FPROffset;
|
|
|
|
|
|
|
|
bool FrameInfoSet;
|
|
|
|
int FrameOffset;
|
|
|
|
unsigned FrameReg;
|
|
|
|
unsigned ReturnReg;
|
|
|
|
|
2014-07-08 08:59:22 +00:00
|
|
|
private:
|
2014-08-14 09:18:14 +00:00
|
|
|
bool ModuleDirectiveAllowed;
|
2013-10-08 13:08:17 +00:00
|
|
|
};
|
2013-11-18 23:55:27 +00:00
|
|
|
|
|
|
|
// This part is for ascii assembly output
|
|
|
|
class MipsTargetAsmStreamer : public MipsTargetStreamer {
|
2013-11-19 20:53:28 +00:00
|
|
|
formatted_raw_ostream &OS;
|
|
|
|
|
2013-11-18 23:55:27 +00:00
|
|
|
public:
|
2014-01-26 06:06:37 +00:00
|
|
|
MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetMicroMips() override;
|
|
|
|
void emitDirectiveSetNoMicroMips() override;
|
|
|
|
void emitDirectiveSetMips16() override;
|
|
|
|
void emitDirectiveSetNoMips16() override;
|
|
|
|
|
|
|
|
void emitDirectiveSetReorder() override;
|
|
|
|
void emitDirectiveSetNoReorder() override;
|
|
|
|
void emitDirectiveSetMacro() override;
|
|
|
|
void emitDirectiveSetNoMacro() override;
|
2014-08-07 12:03:36 +00:00
|
|
|
void emitDirectiveSetMsa() override;
|
|
|
|
void emitDirectiveSetNoMsa() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetAt() override;
|
2015-02-13 10:30:57 +00:00
|
|
|
void emitDirectiveSetAtWithArg(unsigned RegNo) override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetNoAt() override;
|
|
|
|
void emitDirectiveEnd(StringRef Name) override;
|
|
|
|
|
|
|
|
void emitDirectiveEnt(const MCSymbol &Symbol) override;
|
|
|
|
void emitDirectiveAbiCalls() override;
|
|
|
|
void emitDirectiveNaN2008() override;
|
|
|
|
void emitDirectiveNaNLegacy() override;
|
|
|
|
void emitDirectiveOptionPic0() override;
|
|
|
|
void emitDirectiveOptionPic2() override;
|
2015-04-16 09:53:47 +00:00
|
|
|
void emitDirectiveInsn() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitFrame(unsigned StackReg, unsigned StackSize,
|
|
|
|
unsigned ReturnReg) override;
|
|
|
|
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override;
|
|
|
|
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override;
|
|
|
|
|
2014-08-19 14:22:52 +00:00
|
|
|
void emitDirectiveSetArch(StringRef Arch) override;
|
2014-09-09 12:52:14 +00:00
|
|
|
void emitDirectiveSetMips0() override;
|
2014-08-04 12:20:00 +00:00
|
|
|
void emitDirectiveSetMips1() override;
|
|
|
|
void emitDirectiveSetMips2() override;
|
|
|
|
void emitDirectiveSetMips3() override;
|
|
|
|
void emitDirectiveSetMips4() override;
|
|
|
|
void emitDirectiveSetMips5() override;
|
|
|
|
void emitDirectiveSetMips32() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetMips32R2() override;
|
2015-02-18 16:24:50 +00:00
|
|
|
void emitDirectiveSetMips32R3() override;
|
|
|
|
void emitDirectiveSetMips32R5() override;
|
2014-08-04 12:20:00 +00:00
|
|
|
void emitDirectiveSetMips32R6() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetMips64() override;
|
|
|
|
void emitDirectiveSetMips64R2() override;
|
2015-02-18 16:24:50 +00:00
|
|
|
void emitDirectiveSetMips64R3() override;
|
|
|
|
void emitDirectiveSetMips64R5() override;
|
2014-08-04 12:20:00 +00:00
|
|
|
void emitDirectiveSetMips64R6() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetDsp() override;
|
2014-09-17 09:01:54 +00:00
|
|
|
void emitDirectiveSetNoDsp() override;
|
2014-09-09 10:15:38 +00:00
|
|
|
void emitDirectiveSetPop() override;
|
|
|
|
void emitDirectiveSetPush() override;
|
2015-06-02 09:48:04 +00:00
|
|
|
void emitDirectiveSetSoftFloat() override;
|
|
|
|
void emitDirectiveSetHardFloat() override;
|
2014-04-30 11:28:42 +00:00
|
|
|
|
|
|
|
// PIC support
|
2014-10-01 14:53:19 +00:00
|
|
|
void emitDirectiveCpLoad(unsigned RegNo) override;
|
2014-05-01 10:24:46 +00:00
|
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
|
|
const MCSymbol &Sym, bool IsReg) override;
|
2014-07-08 08:59:22 +00:00
|
|
|
|
2015-06-25 12:44:38 +00:00
|
|
|
// FP abiflags directives
|
|
|
|
void emitDirectiveModuleFP() override;
|
2015-06-25 10:56:57 +00:00
|
|
|
void emitDirectiveModuleOddSPReg() override;
|
2015-06-30 13:46:03 +00:00
|
|
|
void emitDirectiveModuleSoftFloat() override;
|
|
|
|
void emitDirectiveModuleHardFloat() override;
|
2014-07-10 13:38:23 +00:00
|
|
|
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
|
2015-06-30 09:36:50 +00:00
|
|
|
void emitDirectiveSetOddSPReg() override;
|
|
|
|
void emitDirectiveSetNoOddSPReg() override;
|
2013-11-18 23:55:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This part is for ELF object output
|
|
|
|
class MipsTargetELFStreamer : public MipsTargetStreamer {
|
2014-01-14 04:25:13 +00:00
|
|
|
bool MicroMipsEnabled;
|
2014-01-31 23:10:26 +00:00
|
|
|
const MCSubtargetInfo &STI;
|
2014-03-26 13:40:29 +00:00
|
|
|
bool Pic;
|
2014-01-22 23:08:42 +00:00
|
|
|
|
2013-11-18 23:55:27 +00:00
|
|
|
public:
|
2014-01-14 04:25:13 +00:00
|
|
|
bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
|
2013-11-18 23:55:27 +00:00
|
|
|
MCELFStreamer &getStreamer();
|
2014-01-26 06:57:13 +00:00
|
|
|
MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
|
2014-01-14 04:25:13 +00:00
|
|
|
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitLabel(MCSymbol *Symbol) override;
|
|
|
|
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
|
2014-03-02 09:09:27 +00:00
|
|
|
void finish() override;
|
2014-01-14 04:25:13 +00:00
|
|
|
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitDirectiveSetMicroMips() override;
|
|
|
|
void emitDirectiveSetNoMicroMips() override;
|
|
|
|
void emitDirectiveSetMips16() override;
|
|
|
|
|
|
|
|
void emitDirectiveSetNoReorder() override;
|
|
|
|
void emitDirectiveEnd(StringRef Name) override;
|
|
|
|
|
|
|
|
void emitDirectiveEnt(const MCSymbol &Symbol) override;
|
|
|
|
void emitDirectiveAbiCalls() override;
|
|
|
|
void emitDirectiveNaN2008() override;
|
|
|
|
void emitDirectiveNaNLegacy() override;
|
|
|
|
void emitDirectiveOptionPic0() override;
|
|
|
|
void emitDirectiveOptionPic2() override;
|
2015-04-16 09:53:47 +00:00
|
|
|
void emitDirectiveInsn() override;
|
2014-04-29 07:58:02 +00:00
|
|
|
void emitFrame(unsigned StackReg, unsigned StackSize,
|
|
|
|
unsigned ReturnReg) override;
|
|
|
|
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override;
|
|
|
|
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override;
|
|
|
|
|
2014-04-30 11:28:42 +00:00
|
|
|
// PIC support
|
2014-10-01 14:53:19 +00:00
|
|
|
void emitDirectiveCpLoad(unsigned RegNo) override;
|
2014-05-01 10:24:46 +00:00
|
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
|
|
const MCSymbol &Sym, bool IsReg) override;
|
2014-04-30 11:28:42 +00:00
|
|
|
|
2015-03-13 11:40:01 +00:00
|
|
|
void emitMipsAbiFlags();
|
2013-11-18 23:55:27 +00:00
|
|
|
};
|
2015-06-23 09:49:53 +00:00
|
|
|
}
|
2013-10-08 13:08:17 +00:00
|
|
|
#endif
|