mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 20:29:30 +00:00
Summary: This directive is used for setting up $gp in the beginning of a function. It expands to three instructions if PIC is enabled: lui $gp, %hi(_gp_disp) addui $gp, $gp, %lo(_gp_disp) addu $gp, $gp, $reg _gp_disp is a special symbol that the linker sets to the distance between the lui instruction and the context pointer (_gp). Reviewers: dsanders Reviewed By: dsanders Differential Revision: http://reviews.llvm.org/D3480 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207637 91177308-0d34-0410-b5e6-96231b3b80d8
148 lines
5.2 KiB
C++
148 lines
5.2 KiB
C++
//===-- 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
|
|
|
|
#include "llvm/MC/MCELFStreamer.h"
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
namespace llvm {
|
|
class MipsTargetStreamer : public MCTargetStreamer {
|
|
virtual void anchor();
|
|
|
|
public:
|
|
MipsTargetStreamer(MCStreamer &S);
|
|
virtual void emitDirectiveSetMicroMips() = 0;
|
|
virtual void emitDirectiveSetNoMicroMips() = 0;
|
|
virtual void emitDirectiveSetMips16() = 0;
|
|
virtual void emitDirectiveSetNoMips16() = 0;
|
|
|
|
virtual void emitDirectiveSetReorder() = 0;
|
|
virtual void emitDirectiveSetNoReorder() = 0;
|
|
virtual void emitDirectiveSetMacro() = 0;
|
|
virtual void emitDirectiveSetNoMacro() = 0;
|
|
virtual void emitDirectiveSetAt() = 0;
|
|
virtual void emitDirectiveSetNoAt() = 0;
|
|
virtual void emitDirectiveEnd(StringRef Name) = 0;
|
|
|
|
virtual void emitDirectiveEnt(const MCSymbol &Symbol) = 0;
|
|
virtual void emitDirectiveAbiCalls() = 0;
|
|
virtual void emitDirectiveNaN2008() = 0;
|
|
virtual void emitDirectiveNaNLegacy() = 0;
|
|
virtual void emitDirectiveOptionPic0() = 0;
|
|
virtual void emitDirectiveOptionPic2() = 0;
|
|
virtual void emitFrame(unsigned StackReg, unsigned StackSize,
|
|
unsigned ReturnReg) = 0;
|
|
virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) = 0;
|
|
virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) = 0;
|
|
|
|
virtual void emitDirectiveSetMips32R2() = 0;
|
|
virtual void emitDirectiveSetMips64() = 0;
|
|
virtual void emitDirectiveSetMips64R2() = 0;
|
|
virtual void emitDirectiveSetDsp() = 0;
|
|
|
|
// PIC support
|
|
virtual void emitDirectiveCpload(unsigned RegNo) = 0;
|
|
};
|
|
|
|
// This part is for ascii assembly output
|
|
class MipsTargetAsmStreamer : public MipsTargetStreamer {
|
|
formatted_raw_ostream &OS;
|
|
|
|
public:
|
|
MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
|
|
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;
|
|
|
|
// PIC support
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
|
};
|
|
|
|
// This part is for ELF object output
|
|
class MipsTargetELFStreamer : public MipsTargetStreamer {
|
|
bool MicroMipsEnabled;
|
|
const MCSubtargetInfo &STI;
|
|
bool Pic;
|
|
|
|
public:
|
|
bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
|
|
MCELFStreamer &getStreamer();
|
|
MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
|
|
|
|
void emitLabel(MCSymbol *Symbol) override;
|
|
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
|
|
void finish() override;
|
|
|
|
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;
|
|
|
|
// PIC support
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
|
|
|
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; }
|
|
};
|
|
}
|
|
#endif
|