mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
Rewrite the Mips16HardFloat pass to avoid using the Subtarget.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225231 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bce877c84c
commit
1abeb77588
@ -247,12 +247,12 @@ static void swapFPIntParams
|
||||
// Having called needsFPHelperFromSig
|
||||
//
|
||||
static void assureFPCallStub(Function &F, Module *M,
|
||||
const MipsSubtarget &Subtarget) {
|
||||
const MipsTargetMachine &TM) {
|
||||
// for now we only need them for static relocation
|
||||
if (Subtarget.getRelocationModel() == Reloc::PIC_)
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return;
|
||||
LLVMContext &Context = M->getContext();
|
||||
bool LE = Subtarget.isLittle();
|
||||
bool LE = TM.isLittleEndian();
|
||||
std::string Name = F.getName();
|
||||
std::string SectionName = ".mips16.call.fp." + Name;
|
||||
std::string StubName = "__call_stub_fp_" + Name;
|
||||
@ -362,8 +362,8 @@ static bool isIntrinsicInline(Function *F) {
|
||||
// Returns of float, double and complex need to be handled with a helper
|
||||
// function.
|
||||
//
|
||||
static bool fixupFPReturnAndCall
|
||||
(Function &F, Module *M, const MipsSubtarget &Subtarget) {
|
||||
static bool fixupFPReturnAndCall(Function &F, Module *M,
|
||||
const MipsTargetMachine &TM) {
|
||||
bool Modified = false;
|
||||
LLVMContext &C = M->getContext();
|
||||
Type *MyVoid = Type::getVoidTy(C);
|
||||
@ -426,9 +426,9 @@ static bool fixupFPReturnAndCall
|
||||
Modified=true;
|
||||
F.addFnAttr("saveS2");
|
||||
}
|
||||
if (Subtarget.getRelocationModel() != Reloc::PIC_ ) {
|
||||
if (TM.getRelocationModel() != Reloc::PIC_ ) {
|
||||
if (needsFPHelperFromSig(*F_)) {
|
||||
assureFPCallStub(*F_, M, Subtarget);
|
||||
assureFPCallStub(*F_, M, TM);
|
||||
Modified=true;
|
||||
}
|
||||
}
|
||||
@ -439,9 +439,9 @@ static bool fixupFPReturnAndCall
|
||||
}
|
||||
|
||||
static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
|
||||
const MipsSubtarget &Subtarget ) {
|
||||
bool PicMode = Subtarget.getRelocationModel() == Reloc::PIC_;
|
||||
bool LE = Subtarget.isLittle();
|
||||
const MipsTargetMachine &TM) {
|
||||
bool PicMode = TM.getRelocationModel() == Reloc::PIC_;
|
||||
bool LE = TM.isLittleEndian();
|
||||
LLVMContext &Context = M->getContext();
|
||||
std::string Name = F->getName();
|
||||
std::string SectionName = ".mips16.fn." + Name;
|
||||
@ -520,11 +520,11 @@ bool Mips16HardFloat::runOnModule(Module &M) {
|
||||
}
|
||||
if (F->isDeclaration() || F->hasFnAttribute("mips16_fp_stub") ||
|
||||
F->hasFnAttribute("nomips16")) continue;
|
||||
Modified |= fixupFPReturnAndCall(*F, &M, Subtarget);
|
||||
Modified |= fixupFPReturnAndCall(*F, &M, TM);
|
||||
FPParamVariant V = whichFPParamVariantNeeded(*F);
|
||||
if (V != NoSig) {
|
||||
Modified = true;
|
||||
createFPFnStub(F, &M, V, Subtarget);
|
||||
createFPFnStub(F, &M, V, TM);
|
||||
}
|
||||
}
|
||||
return Modified;
|
||||
|
@ -25,26 +25,16 @@ using namespace llvm;
|
||||
namespace llvm {
|
||||
|
||||
class Mips16HardFloat : public ModulePass {
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID),
|
||||
TM(TM_), Subtarget(TM.getSubtarget<MipsSubtarget>()) {
|
||||
}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "MIPS16 Hard Float Pass";
|
||||
}
|
||||
Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID), TM(TM_) {}
|
||||
|
||||
const char *getPassName() const override { return "MIPS16 Hard Float Pass"; }
|
||||
bool runOnModule(Module &M) override;
|
||||
|
||||
protected:
|
||||
/// Keep a pointer to the MipsSubtarget around so that we can make the right
|
||||
/// decision when generating code for different targets.
|
||||
const TargetMachine &TM;
|
||||
const MipsSubtarget &Subtarget;
|
||||
|
||||
const MipsTargetMachine &TM;
|
||||
};
|
||||
|
||||
ModulePass *createMips16HardFloat(MipsTargetMachine &TM);
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
Subtarget(&TM.getSubtarget<MipsSubtarget>()) {
|
||||
MFI = funcInfo.MF->getInfo<MipsFunctionInfo>();
|
||||
Context = &funcInfo.Fn->getContext();
|
||||
TargetSupported = ((Subtarget->getRelocationModel() == Reloc::PIC_) &&
|
||||
TargetSupported = ((TM.getRelocationModel() == Reloc::PIC_) &&
|
||||
((Subtarget->hasMips32r2() || Subtarget->hasMips32()) &&
|
||||
(Subtarget->isABI_O32())));
|
||||
UnsupportedFPMode = Subtarget->isFP64bit();
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
}
|
||||
|
||||
bool isLittleEndian() const { return isLittle; }
|
||||
};
|
||||
|
||||
/// MipsebTargetMachine - Mips32/64 big endian target machine.
|
||||
|
Loading…
Reference in New Issue
Block a user