mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-17 03:30:28 +00:00
24a071b8c5
Summary: When -mno-odd-spreg is in effect, 32-bit floating point values are not permitted in odd FPU registers. The option also prohibits 32-bit and 64-bit floating point comparison results from being written to odd registers. This option has three purposes: * It allows support for certain MIPS implementations such as loongson-3a that do not allow the use of odd registers for single precision arithmetic. * When using -mfpxx, -mno-odd-spreg is the default and this allows us to statically check that code is compliant with the O32 FPXX ABI since mtc1/mfc1 instructions to/from odd registers are guaranteed not to appear for any reason. Once this has been established, the user can then re-enable -modd-spreg to regain the use of all 32 single-precision registers. * When using -mfp64 and -mno-odd-spreg together, an O32 extension named O32 FP64A is used as the ABI. This is intended to provide almost all functionality of an FR=1 processor but can also be executed on a FR=0 core with the assistance of a hardware compatibility mode which emulates FR=0 behaviour on an FR=1 processor. * Added '.module oddspreg' and '.module nooddspreg' each of which update the .MIPS.abiflags section appropriately * Moved setFpABI() call inside emitDirectiveModuleFP() so that the caller doesn't have to remember to do it. * MipsABIFlags now calculates the flags1 and flags2 member on demand rather than trying to maintain them in the same format they will be emitted in. There is one portion of the -mfp64 and -mno-odd-spreg combination that is not implemented yet. Moves to/from odd-numbered double-precision registers must not use mtc1. I will fix this in a follow-up. Differential Revision: http://reviews.llvm.org/D4383 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212717 91177308-0d34-0410-b5e6-96231b3b80d8
202 lines
7.2 KiB
C++
202 lines
7.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"
|
|
#include "MCTargetDesc/MipsABIFlagsSection.h"
|
|
|
|
namespace llvm {
|
|
|
|
struct MipsABIFlagsSection;
|
|
|
|
class MipsTargetStreamer : public MCTargetStreamer {
|
|
public:
|
|
MipsTargetStreamer(MCStreamer &S);
|
|
virtual void emitDirectiveSetMicroMips();
|
|
virtual void emitDirectiveSetNoMicroMips();
|
|
virtual void emitDirectiveSetMips16();
|
|
virtual void emitDirectiveSetNoMips16();
|
|
|
|
virtual void emitDirectiveSetReorder();
|
|
virtual void emitDirectiveSetNoReorder();
|
|
virtual void emitDirectiveSetMacro();
|
|
virtual void emitDirectiveSetNoMacro();
|
|
virtual void emitDirectiveSetAt();
|
|
virtual void emitDirectiveSetNoAt();
|
|
virtual void emitDirectiveEnd(StringRef Name);
|
|
|
|
virtual void emitDirectiveEnt(const MCSymbol &Symbol);
|
|
virtual void emitDirectiveAbiCalls();
|
|
virtual void emitDirectiveNaN2008();
|
|
virtual void emitDirectiveNaNLegacy();
|
|
virtual void emitDirectiveOptionPic0();
|
|
virtual void emitDirectiveOptionPic2();
|
|
virtual void emitFrame(unsigned StackReg, unsigned StackSize,
|
|
unsigned ReturnReg);
|
|
virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff);
|
|
virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff);
|
|
|
|
virtual void emitDirectiveSetMips32R2();
|
|
virtual void emitDirectiveSetMips64();
|
|
virtual void emitDirectiveSetMips64R2();
|
|
virtual void emitDirectiveSetDsp();
|
|
|
|
// PIC support
|
|
virtual void emitDirectiveCpload(unsigned RegNo);
|
|
virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
const MCSymbol &Sym, bool IsReg);
|
|
|
|
/// 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);
|
|
}
|
|
|
|
/// 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){};
|
|
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) {
|
|
ABIFlagsSection.setAllFromPredicates(P);
|
|
}
|
|
|
|
MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; }
|
|
|
|
protected:
|
|
MipsABIFlagsSection ABIFlagsSection;
|
|
|
|
private:
|
|
bool canHaveModuleDirective;
|
|
};
|
|
|
|
// 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);
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
const MCSymbol &Sym, bool IsReg) override;
|
|
|
|
// ABI Flags
|
|
void emitDirectiveModuleFP(MipsABIFlagsSection::FpABIKind Value,
|
|
bool Is32BitABI) override;
|
|
void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override;
|
|
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
|
|
void emitMipsAbiFlags() override;
|
|
};
|
|
|
|
// 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);
|
|
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
|
|
const MCSymbol &Sym, bool IsReg) override;
|
|
|
|
// ABI Flags
|
|
void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI) override;
|
|
void emitMipsAbiFlags() override;
|
|
|
|
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
|