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