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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MIPSTARGETSTREAMER_H
|
|
|
|
#define MIPSTARGETSTREAMER_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"
|
2014-07-08 18:11:38 +08:00
|
|
|
#include "MCTargetDesc/MipsABIFlagsSection.h"
|
2013-10-08 21:08:17 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
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();
|
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-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();
|
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();
|
2014-08-04 20:20:00 +08:00
|
|
|
virtual void emitDirectiveSetMips64R6();
|
2014-06-24 03:43:40 +08:00
|
|
|
virtual void emitDirectiveSetDsp();
|
2014-04-30 19:28:42 +08:00
|
|
|
|
|
|
|
// PIC support
|
2014-06-24 03:43:40 +08:00
|
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
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);
|
2014-07-10 21:38:23 +08:00
|
|
|
|
|
|
|
/// Emit a '.module fp=value' directive using the given values.
|
|
|
|
/// Updates the .MIPS.abiflags section
|
|
|
|
virtual void emitDirectiveModuleFP(MipsABIFlagsSection::FpABIKind Value,
|
|
|
|
bool Is32BitABI) {
|
|
|
|
ABIFlagsSection.setFpABI(Value, Is32BitABI);
|
2014-07-08 18:11:38 +08:00
|
|
|
}
|
2014-07-10 21:38:23 +08:00
|
|
|
|
|
|
|
/// Emit a '.module fp=value' directive using the current values of the
|
|
|
|
/// .MIPS.abiflags section.
|
|
|
|
void emitDirectiveModuleFP() {
|
|
|
|
emitDirectiveModuleFP(ABIFlagsSection.getFpABI(),
|
|
|
|
ABIFlagsSection.Is32BitABI);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI);
|
|
|
|
virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value){};
|
2014-07-08 16:59:22 +08:00
|
|
|
virtual void emitMipsAbiFlags(){};
|
|
|
|
void setCanHaveModuleDir(bool Can) { canHaveModuleDirective = Can; }
|
|
|
|
bool getCanHaveModuleDir() { return canHaveModuleDirective; }
|
|
|
|
|
|
|
|
// This method enables template classes to set internal abi flags
|
|
|
|
// structure values.
|
|
|
|
template <class PredicateLibrary>
|
|
|
|
void updateABIInfo(const PredicateLibrary &P) {
|
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; }
|
|
|
|
|
2014-07-08 16:59:22 +08:00
|
|
|
protected:
|
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:
|
|
|
|
bool canHaveModuleDirective;
|
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;
|
|
|
|
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;
|
|
|
|
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-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;
|
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;
|
2014-08-04 20:20:00 +08:00
|
|
|
void emitDirectiveSetMips64R6() override;
|
2014-04-29 15:58:02 +08:00
|
|
|
void emitDirectiveSetDsp() override;
|
2014-04-30 19:28:42 +08:00
|
|
|
|
|
|
|
// PIC support
|
|
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
2014-05-01 18:24:46 +08:00
|
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
|
|
const MCSymbol &Sym, bool IsReg) override;
|
2014-07-08 16:59:22 +08:00
|
|
|
|
|
|
|
// ABI Flags
|
2014-07-10 21:38:23 +08:00
|
|
|
void emitDirectiveModuleFP(MipsABIFlagsSection::FpABIKind Value,
|
|
|
|
bool Is32BitABI) override;
|
|
|
|
void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override;
|
|
|
|
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
|
2014-07-08 16:59:22 +08:00
|
|
|
void emitMipsAbiFlags() 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;
|
|
|
|
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
|
|
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
2014-05-01 18:24:46 +08:00
|
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
|
|
const MCSymbol &Sym, bool IsReg) override;
|
2014-04-30 19:28:42 +08:00
|
|
|
|
2014-07-08 16:59:22 +08:00
|
|
|
// ABI Flags
|
2014-07-10 21:38:23 +08:00
|
|
|
void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override;
|
2014-07-08 16:59:22 +08:00
|
|
|
void emitMipsAbiFlags() override;
|
|
|
|
|
2014-04-30 19:28:42 +08:00
|
|
|
protected:
|
|
|
|
bool isO32() const { return STI.getFeatureBits() & Mips::FeatureO32; }
|
|
|
|
bool isN32() const { return STI.getFeatureBits() & Mips::FeatureN32; }
|
|
|
|
bool isN64() const { return STI.getFeatureBits() & Mips::FeatureN64; }
|
2013-11-19 07:55:27 +08:00
|
|
|
};
|
2013-10-08 21:08:17 +08:00
|
|
|
}
|
|
|
|
#endif
|