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"
|
2013-10-08 21:08:17 +08:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
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();
|
|
|
|
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-06-24 03:43:40 +08:00
|
|
|
virtual void emitDirectiveSetMips32R2();
|
|
|
|
virtual void emitDirectiveSetMips64();
|
|
|
|
virtual void emitDirectiveSetMips64R2();
|
|
|
|
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);
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
void emitDirectiveSetMips32R2() override;
|
|
|
|
void emitDirectiveSetMips64() override;
|
|
|
|
void emitDirectiveSetMips64R2() override;
|
|
|
|
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;
|
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 emitDirectiveSetNoMips16() override;
|
|
|
|
|
|
|
|
void emitDirectiveSetReorder() override;
|
|
|
|
void emitDirectiveSetNoReorder() override;
|
|
|
|
void emitDirectiveSetMacro() override;
|
|
|
|
void emitDirectiveSetNoMacro() override;
|
|
|
|
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;
|
|
|
|
|
|
|
|
void emitDirectiveSetMips32R2() override;
|
|
|
|
void emitDirectiveSetMips64() override;
|
|
|
|
void emitDirectiveSetMips64R2() override;
|
|
|
|
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-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
|