Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
//===---- Mips16HardFloat.cpp for Mips16 Hard Float --------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a pass needed for Mips16 Hard Float
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-03-23 18:07:13 +00:00
|
|
|
#include "MipsTargetMachine.h"
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "llvm/IR/Value.h"
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2015-03-23 18:07:13 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2013-08-11 21:30:27 +00:00
|
|
|
#include <algorithm>
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
#include <string>
|
2015-03-14 09:02:23 +00:00
|
|
|
|
2015-03-09 15:50:58 +00:00
|
|
|
using namespace llvm;
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
|
2014-04-22 02:41:26 +00:00
|
|
|
#define DEBUG_TYPE "mips16-hard-float"
|
|
|
|
|
2013-05-14 02:00:24 +00:00
|
|
|
namespace {
|
2015-03-14 09:02:23 +00:00
|
|
|
class Mips16HardFloat : public ModulePass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
2013-05-14 02:00:24 +00:00
|
|
|
|
2015-03-14 09:02:23 +00:00
|
|
|
Mips16HardFloat(MipsTargetMachine &TM_) : ModulePass(ID), TM(TM_) {}
|
2013-05-14 02:00:24 +00:00
|
|
|
|
2015-03-14 09:02:23 +00:00
|
|
|
const char *getPassName() const override {
|
|
|
|
return "MIPS16 Hard Float Pass";
|
|
|
|
}
|
2013-05-14 02:00:24 +00:00
|
|
|
|
2015-03-14 09:02:23 +00:00
|
|
|
bool runOnModule(Module &M) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const MipsTargetMachine &TM;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InlineAsmHelper {
|
|
|
|
LLVMContext &C;
|
|
|
|
BasicBlock *BB;
|
|
|
|
public:
|
|
|
|
InlineAsmHelper(LLVMContext &C_, BasicBlock *BB_) :
|
|
|
|
C(C_), BB(BB_) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Out(StringRef AsmString) {
|
|
|
|
std::vector<llvm::Type *> AsmArgTypes;
|
|
|
|
std::vector<llvm::Value*> AsmArgs;
|
|
|
|
|
|
|
|
llvm::FunctionType *AsmFTy = llvm::FunctionType::get(Type::getVoidTy(C),
|
|
|
|
AsmArgTypes, false);
|
|
|
|
llvm::InlineAsm *IA = llvm::InlineAsm::get(AsmFTy, AsmString, "", true,
|
|
|
|
/* IsAlignStack */ false,
|
|
|
|
llvm::InlineAsm::AD_ATT);
|
|
|
|
CallInst::Create(IA, AsmArgs, "", BB);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
char Mips16HardFloat::ID = 0;
|
2015-06-23 09:49:53 +00:00
|
|
|
}
|
2015-03-14 09:02:23 +00:00
|
|
|
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
//
|
|
|
|
// Return types that matter for hard float are:
|
|
|
|
// float, double, complex float, and complex double
|
|
|
|
//
|
|
|
|
enum FPReturnVariant {
|
|
|
|
FRet, DRet, CFRet, CDRet, NoFPRet
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Determine which FP return type this function has
|
|
|
|
//
|
|
|
|
static FPReturnVariant whichFPReturnVariant(Type *T) {
|
|
|
|
switch (T->getTypeID()) {
|
|
|
|
case Type::FloatTyID:
|
|
|
|
return FRet;
|
|
|
|
case Type::DoubleTyID:
|
|
|
|
return DRet;
|
|
|
|
case Type::StructTyID:
|
|
|
|
if (T->getStructNumElements() != 2)
|
|
|
|
break;
|
|
|
|
if ((T->getContainedType(0)->isFloatTy()) &&
|
|
|
|
(T->getContainedType(1)->isFloatTy()))
|
|
|
|
return CFRet;
|
|
|
|
if ((T->getContainedType(0)->isDoubleTy()) &&
|
|
|
|
(T->getContainedType(1)->isDoubleTy()))
|
|
|
|
return CDRet;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NoFPRet;
|
|
|
|
}
|
|
|
|
|
2013-05-14 02:00:24 +00:00
|
|
|
//
|
|
|
|
// Parameter type that matter are float, (float, float), (float, double),
|
|
|
|
// double, (double, double), (double, float)
|
|
|
|
//
|
|
|
|
enum FPParamVariant {
|
|
|
|
FSig, FFSig, FDSig,
|
|
|
|
DSig, DDSig, DFSig, NoSig
|
|
|
|
};
|
|
|
|
|
|
|
|
// which floating point parameter signature variant we are dealing with
|
|
|
|
//
|
|
|
|
typedef Type::TypeID TypeID;
|
|
|
|
const Type::TypeID FloatTyID = Type::FloatTyID;
|
|
|
|
const Type::TypeID DoubleTyID = Type::DoubleTyID;
|
|
|
|
|
|
|
|
static FPParamVariant whichFPParamVariantNeeded(Function &F) {
|
|
|
|
switch (F.arg_size()) {
|
|
|
|
case 0:
|
|
|
|
return NoSig;
|
|
|
|
case 1:{
|
|
|
|
TypeID ArgTypeID = F.getFunctionType()->getParamType(0)->getTypeID();
|
|
|
|
switch (ArgTypeID) {
|
|
|
|
case FloatTyID:
|
|
|
|
return FSig;
|
|
|
|
case DoubleTyID:
|
|
|
|
return DSig;
|
|
|
|
default:
|
|
|
|
return NoSig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TypeID ArgTypeID0 = F.getFunctionType()->getParamType(0)->getTypeID();
|
|
|
|
TypeID ArgTypeID1 = F.getFunctionType()->getParamType(1)->getTypeID();
|
|
|
|
switch(ArgTypeID0) {
|
|
|
|
case FloatTyID: {
|
|
|
|
switch (ArgTypeID1) {
|
|
|
|
case FloatTyID:
|
|
|
|
return FFSig;
|
|
|
|
case DoubleTyID:
|
|
|
|
return FDSig;
|
|
|
|
default:
|
|
|
|
return FSig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case DoubleTyID: {
|
|
|
|
switch (ArgTypeID1) {
|
|
|
|
case FloatTyID:
|
|
|
|
return DFSig;
|
|
|
|
case DoubleTyID:
|
|
|
|
return DDSig;
|
|
|
|
default:
|
|
|
|
return DSig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return NoSig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
llvm_unreachable("can't get here");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Figure out if we need float point based on the function parameters.
|
|
|
|
// We need to move variables in and/or out of floating point
|
|
|
|
// registers because of the ABI
|
|
|
|
//
|
|
|
|
static bool needsFPStubFromParams(Function &F) {
|
|
|
|
if (F.arg_size() >=1) {
|
|
|
|
Type *ArgType = F.getFunctionType()->getParamType(0);
|
|
|
|
switch (ArgType->getTypeID()) {
|
2015-03-14 09:02:23 +00:00
|
|
|
case Type::FloatTyID:
|
|
|
|
case Type::DoubleTyID:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-14 02:00:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool needsFPReturnHelper(Function &F) {
|
|
|
|
Type* RetType = F.getReturnType();
|
|
|
|
return whichFPReturnVariant(RetType) != NoFPRet;
|
|
|
|
}
|
|
|
|
|
2013-12-18 23:57:48 +00:00
|
|
|
static bool needsFPReturnHelper(const FunctionType &FT) {
|
|
|
|
Type* RetType = FT.getReturnType();
|
|
|
|
return whichFPReturnVariant(RetType) != NoFPRet;
|
|
|
|
}
|
|
|
|
|
2013-05-14 02:00:24 +00:00
|
|
|
static bool needsFPHelperFromSig(Function &F) {
|
|
|
|
return needsFPStubFromParams(F) || needsFPReturnHelper(F);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// We swap between FP and Integer registers to allow Mips16 and Mips32 to
|
|
|
|
// interoperate
|
|
|
|
//
|
2015-03-14 09:02:23 +00:00
|
|
|
static void swapFPIntParams(FPParamVariant PV, Module *M, InlineAsmHelper &IAH,
|
|
|
|
bool LE, bool ToFP) {
|
2013-05-14 02:00:24 +00:00
|
|
|
//LLVMContext &Context = M->getContext();
|
|
|
|
std::string MI = ToFP? "mtc1 ": "mfc1 ";
|
|
|
|
switch (PV) {
|
|
|
|
case FSig:
|
|
|
|
IAH.Out(MI + "$$4,$$f12");
|
|
|
|
break;
|
|
|
|
case FFSig:
|
|
|
|
IAH.Out(MI +"$$4,$$f12");
|
|
|
|
IAH.Out(MI + "$$5,$$f14");
|
|
|
|
break;
|
|
|
|
case FDSig:
|
|
|
|
IAH.Out(MI + "$$4,$$f12");
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out(MI + "$$6,$$f14");
|
|
|
|
IAH.Out(MI + "$$7,$$f15");
|
|
|
|
} else {
|
|
|
|
IAH.Out(MI + "$$7,$$f14");
|
|
|
|
IAH.Out(MI + "$$6,$$f15");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DSig:
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out(MI + "$$4,$$f12");
|
|
|
|
IAH.Out(MI + "$$5,$$f13");
|
|
|
|
} else {
|
|
|
|
IAH.Out(MI + "$$5,$$f12");
|
|
|
|
IAH.Out(MI + "$$4,$$f13");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DDSig:
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out(MI + "$$4,$$f12");
|
|
|
|
IAH.Out(MI + "$$5,$$f13");
|
|
|
|
IAH.Out(MI + "$$6,$$f14");
|
|
|
|
IAH.Out(MI + "$$7,$$f15");
|
|
|
|
} else {
|
|
|
|
IAH.Out(MI + "$$5,$$f12");
|
|
|
|
IAH.Out(MI + "$$4,$$f13");
|
|
|
|
IAH.Out(MI + "$$7,$$f14");
|
|
|
|
IAH.Out(MI + "$$6,$$f15");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DFSig:
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out(MI + "$$4,$$f12");
|
|
|
|
IAH.Out(MI + "$$5,$$f13");
|
|
|
|
} else {
|
|
|
|
IAH.Out(MI + "$$5,$$f12");
|
|
|
|
IAH.Out(MI + "$$4,$$f13");
|
|
|
|
}
|
|
|
|
IAH.Out(MI + "$$6,$$f14");
|
|
|
|
break;
|
|
|
|
case NoSig:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-03-14 09:02:23 +00:00
|
|
|
|
2013-05-14 02:00:24 +00:00
|
|
|
//
|
|
|
|
// Make sure that we know we already need a stub for this function.
|
|
|
|
// Having called needsFPHelperFromSig
|
|
|
|
//
|
2014-02-14 19:16:39 +00:00
|
|
|
static void assureFPCallStub(Function &F, Module *M,
|
2015-01-06 01:12:30 +00:00
|
|
|
const MipsTargetMachine &TM) {
|
2013-05-14 02:00:24 +00:00
|
|
|
// for now we only need them for static relocation
|
2015-01-06 01:12:30 +00:00
|
|
|
if (TM.getRelocationModel() == Reloc::PIC_)
|
2013-05-14 02:00:24 +00:00
|
|
|
return;
|
|
|
|
LLVMContext &Context = M->getContext();
|
2015-01-06 01:12:30 +00:00
|
|
|
bool LE = TM.isLittleEndian();
|
2013-05-14 02:00:24 +00:00
|
|
|
std::string Name = F.getName();
|
|
|
|
std::string SectionName = ".mips16.call.fp." + Name;
|
2013-08-01 02:26:31 +00:00
|
|
|
std::string StubName = "__call_stub_fp_" + Name;
|
2013-05-14 02:00:24 +00:00
|
|
|
//
|
|
|
|
// see if we already have the stub
|
|
|
|
//
|
|
|
|
Function *FStub = M->getFunction(StubName);
|
|
|
|
if (FStub && !FStub->isDeclaration()) return;
|
|
|
|
FStub = Function::Create(F.getFunctionType(),
|
|
|
|
Function::InternalLinkage, StubName, M);
|
|
|
|
FStub->addFnAttr("mips16_fp_stub");
|
|
|
|
FStub->addFnAttr(llvm::Attribute::Naked);
|
2013-08-01 02:26:31 +00:00
|
|
|
FStub->addFnAttr(llvm::Attribute::NoInline);
|
2013-05-14 02:00:24 +00:00
|
|
|
FStub->addFnAttr(llvm::Attribute::NoUnwind);
|
|
|
|
FStub->addFnAttr("nomips16");
|
|
|
|
FStub->setSection(SectionName);
|
|
|
|
BasicBlock *BB = BasicBlock::Create(Context, "entry", FStub);
|
|
|
|
InlineAsmHelper IAH(Context, BB);
|
2013-08-01 02:26:31 +00:00
|
|
|
IAH.Out(".set reorder");
|
2013-05-14 02:00:24 +00:00
|
|
|
FPReturnVariant RV = whichFPReturnVariant(FStub->getReturnType());
|
|
|
|
FPParamVariant PV = whichFPParamVariantNeeded(F);
|
|
|
|
swapFPIntParams(PV, M, IAH, LE, true);
|
|
|
|
if (RV != NoFPRet) {
|
|
|
|
IAH.Out("move $$18, $$31");
|
|
|
|
IAH.Out("jal " + Name);
|
|
|
|
} else {
|
|
|
|
IAH.Out("lui $$25,%hi(" + Name + ")");
|
|
|
|
IAH.Out("addiu $$25,$$25,%lo(" + Name + ")" );
|
|
|
|
}
|
|
|
|
switch (RV) {
|
|
|
|
case FRet:
|
|
|
|
IAH.Out("mfc1 $$2,$$f0");
|
|
|
|
break;
|
|
|
|
case DRet:
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out("mfc1 $$2,$$f0");
|
|
|
|
IAH.Out("mfc1 $$3,$$f1");
|
|
|
|
} else {
|
|
|
|
IAH.Out("mfc1 $$3,$$f0");
|
|
|
|
IAH.Out("mfc1 $$2,$$f1");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CFRet:
|
|
|
|
if (LE) {
|
2015-03-14 09:02:23 +00:00
|
|
|
IAH.Out("mfc1 $$2,$$f0");
|
|
|
|
IAH.Out("mfc1 $$3,$$f2");
|
2013-05-14 02:00:24 +00:00
|
|
|
} else {
|
|
|
|
IAH.Out("mfc1 $$3,$$f0");
|
|
|
|
IAH.Out("mfc1 $$3,$$f2");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CDRet:
|
|
|
|
if (LE) {
|
|
|
|
IAH.Out("mfc1 $$4,$$f2");
|
|
|
|
IAH.Out("mfc1 $$5,$$f3");
|
|
|
|
IAH.Out("mfc1 $$2,$$f0");
|
|
|
|
IAH.Out("mfc1 $$3,$$f1");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
IAH.Out("mfc1 $$5,$$f2");
|
|
|
|
IAH.Out("mfc1 $$4,$$f3");
|
|
|
|
IAH.Out("mfc1 $$3,$$f0");
|
|
|
|
IAH.Out("mfc1 $$2,$$f1");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NoFPRet:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (RV != NoFPRet)
|
|
|
|
IAH.Out("jr $$18");
|
|
|
|
else
|
|
|
|
IAH.Out("jr $$25");
|
|
|
|
new UnreachableInst(Context, BB);
|
|
|
|
}
|
|
|
|
|
2013-08-11 21:30:27 +00:00
|
|
|
//
|
2013-09-01 04:12:59 +00:00
|
|
|
// Functions that are llvm intrinsics and don't need helpers.
|
2013-08-11 21:30:27 +00:00
|
|
|
//
|
2015-03-14 09:02:23 +00:00
|
|
|
static const char *IntrinsicInline[] = {
|
|
|
|
"fabs", "fabsf",
|
|
|
|
"llvm.ceil.f32", "llvm.ceil.f64",
|
|
|
|
"llvm.copysign.f32", "llvm.copysign.f64",
|
|
|
|
"llvm.cos.f32", "llvm.cos.f64",
|
|
|
|
"llvm.exp.f32", "llvm.exp.f64",
|
|
|
|
"llvm.exp2.f32", "llvm.exp2.f64",
|
|
|
|
"llvm.fabs.f32", "llvm.fabs.f64",
|
|
|
|
"llvm.floor.f32", "llvm.floor.f64",
|
|
|
|
"llvm.fma.f32", "llvm.fma.f64",
|
|
|
|
"llvm.log.f32", "llvm.log.f64",
|
|
|
|
"llvm.log10.f32", "llvm.log10.f64",
|
|
|
|
"llvm.nearbyint.f32", "llvm.nearbyint.f64",
|
|
|
|
"llvm.pow.f32", "llvm.pow.f64",
|
|
|
|
"llvm.powi.f32", "llvm.powi.f64",
|
|
|
|
"llvm.rint.f32", "llvm.rint.f64",
|
|
|
|
"llvm.round.f32", "llvm.round.f64",
|
|
|
|
"llvm.sin.f32", "llvm.sin.f64",
|
|
|
|
"llvm.sqrt.f32", "llvm.sqrt.f64",
|
|
|
|
"llvm.trunc.f32", "llvm.trunc.f64",
|
|
|
|
};
|
2013-08-11 21:30:27 +00:00
|
|
|
|
2013-08-12 09:37:29 +00:00
|
|
|
static bool isIntrinsicInline(Function *F) {
|
2014-04-12 16:15:53 +00:00
|
|
|
return std::binary_search(std::begin(IntrinsicInline),
|
|
|
|
std::end(IntrinsicInline), F->getName());
|
2013-08-11 21:30:27 +00:00
|
|
|
}
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
//
|
|
|
|
// Returns of float, double and complex need to be handled with a helper
|
2013-05-16 02:17:42 +00:00
|
|
|
// function.
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
//
|
2015-01-06 01:12:30 +00:00
|
|
|
static bool fixupFPReturnAndCall(Function &F, Module *M,
|
|
|
|
const MipsTargetMachine &TM) {
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
bool Modified = false;
|
|
|
|
LLVMContext &C = M->getContext();
|
|
|
|
Type *MyVoid = Type::getVoidTy(C);
|
|
|
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
|
|
|
for (BasicBlock::iterator I = BB->begin(), E = BB->end();
|
|
|
|
I != E; ++I) {
|
|
|
|
Instruction &Inst = *I;
|
|
|
|
if (const ReturnInst *RI = dyn_cast<ReturnInst>(I)) {
|
|
|
|
Value *RVal = RI->getReturnValue();
|
|
|
|
if (!RVal) continue;
|
|
|
|
//
|
|
|
|
// If there is a return value and it needs a helper function,
|
|
|
|
// figure out which one and add a call before the actual
|
|
|
|
// return to this helper. The purpose of the helper is to move
|
|
|
|
// floating point values from their soft float return mapping to
|
|
|
|
// where they would have been mapped to in floating point registers.
|
|
|
|
//
|
|
|
|
Type *T = RVal->getType();
|
|
|
|
FPReturnVariant RV = whichFPReturnVariant(T);
|
|
|
|
if (RV == NoFPRet) continue;
|
2015-03-14 09:02:23 +00:00
|
|
|
static const char* Helper[NoFPRet] = {
|
|
|
|
"__mips16_ret_sf", "__mips16_ret_df", "__mips16_ret_sc",
|
|
|
|
"__mips16_ret_dc"
|
|
|
|
};
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
const char *Name = Helper[RV];
|
|
|
|
AttributeSet A;
|
|
|
|
Value *Params[] = {RVal};
|
|
|
|
Modified = true;
|
|
|
|
//
|
|
|
|
// These helper functions have a different calling ABI so
|
|
|
|
// this __Mips16RetHelper indicates that so that later
|
|
|
|
// during call setup, the proper call lowering to the helper
|
|
|
|
// functions will take place.
|
|
|
|
//
|
|
|
|
A = A.addAttribute(C, AttributeSet::FunctionIndex,
|
|
|
|
"__Mips16RetHelper");
|
|
|
|
A = A.addAttribute(C, AttributeSet::FunctionIndex,
|
|
|
|
Attribute::ReadNone);
|
2013-08-01 02:26:31 +00:00
|
|
|
A = A.addAttribute(C, AttributeSet::FunctionIndex,
|
|
|
|
Attribute::NoInline);
|
2014-11-20 23:51:47 +00:00
|
|
|
Value *F = (M->getOrInsertFunction(Name, A, MyVoid, T, nullptr));
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
CallInst::Create(F, Params, "", &Inst );
|
2013-05-14 02:00:24 +00:00
|
|
|
} else if (const CallInst *CI = dyn_cast<CallInst>(I)) {
|
2015-03-14 09:02:23 +00:00
|
|
|
const Value* V = CI->getCalledValue();
|
|
|
|
const Type* T = nullptr;
|
|
|
|
if (V) T = V->getType();
|
|
|
|
const PointerType *PFT=nullptr;
|
|
|
|
if (T) PFT = dyn_cast<PointerType>(T);
|
|
|
|
const FunctionType *FT=nullptr;
|
|
|
|
if (PFT) FT = dyn_cast<FunctionType>(PFT->getElementType());
|
|
|
|
Function *F_ = CI->getCalledFunction();
|
|
|
|
if (FT && needsFPReturnHelper(*FT) &&
|
|
|
|
!(F_ && isIntrinsicInline(F_))) {
|
|
|
|
Modified=true;
|
|
|
|
F.addFnAttr("saveS2");
|
|
|
|
}
|
|
|
|
if (F_ && !isIntrinsicInline(F_)) {
|
|
|
|
// pic mode calls are handled by already defined
|
|
|
|
// helper functions
|
|
|
|
if (needsFPReturnHelper(*F_)) {
|
2013-12-18 23:57:48 +00:00
|
|
|
Modified=true;
|
|
|
|
F.addFnAttr("saveS2");
|
|
|
|
}
|
2015-03-14 09:02:23 +00:00
|
|
|
if (TM.getRelocationModel() != Reloc::PIC_ ) {
|
|
|
|
if (needsFPHelperFromSig(*F_)) {
|
|
|
|
assureFPCallStub(*F_, M, TM);
|
2013-05-14 02:00:24 +00:00
|
|
|
Modified=true;
|
|
|
|
}
|
|
|
|
}
|
2015-03-14 09:02:23 +00:00
|
|
|
}
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Modified;
|
|
|
|
}
|
|
|
|
|
2013-05-16 02:17:42 +00:00
|
|
|
static void createFPFnStub(Function *F, Module *M, FPParamVariant PV,
|
2015-01-06 01:12:30 +00:00
|
|
|
const MipsTargetMachine &TM) {
|
|
|
|
bool PicMode = TM.getRelocationModel() == Reloc::PIC_;
|
|
|
|
bool LE = TM.isLittleEndian();
|
2013-05-16 02:17:42 +00:00
|
|
|
LLVMContext &Context = M->getContext();
|
|
|
|
std::string Name = F->getName();
|
|
|
|
std::string SectionName = ".mips16.fn." + Name;
|
|
|
|
std::string StubName = "__fn_stub_" + Name;
|
2013-09-25 20:58:50 +00:00
|
|
|
std::string LocalName = "$$__fn_local_" + Name;
|
2013-05-16 02:17:42 +00:00
|
|
|
Function *FStub = Function::Create
|
|
|
|
(F->getFunctionType(),
|
2013-08-01 02:26:31 +00:00
|
|
|
Function::InternalLinkage, StubName, M);
|
2013-05-16 02:17:42 +00:00
|
|
|
FStub->addFnAttr("mips16_fp_stub");
|
|
|
|
FStub->addFnAttr(llvm::Attribute::Naked);
|
|
|
|
FStub->addFnAttr(llvm::Attribute::NoUnwind);
|
2013-08-01 02:26:31 +00:00
|
|
|
FStub->addFnAttr(llvm::Attribute::NoInline);
|
2013-05-16 02:17:42 +00:00
|
|
|
FStub->addFnAttr("nomips16");
|
|
|
|
FStub->setSection(SectionName);
|
|
|
|
BasicBlock *BB = BasicBlock::Create(Context, "entry", FStub);
|
|
|
|
InlineAsmHelper IAH(Context, BB);
|
|
|
|
if (PicMode) {
|
|
|
|
IAH.Out(".set noreorder");
|
2013-09-25 20:58:50 +00:00
|
|
|
IAH.Out(".cpload $$25");
|
2013-05-16 02:17:42 +00:00
|
|
|
IAH.Out(".set reorder");
|
|
|
|
IAH.Out(".reloc 0,R_MIPS_NONE," + Name);
|
|
|
|
IAH.Out("la $$25," + LocalName);
|
|
|
|
}
|
2013-09-21 01:37:52 +00:00
|
|
|
else {
|
2013-09-25 20:58:50 +00:00
|
|
|
IAH.Out("la $$25," + Name);
|
2013-09-21 01:37:52 +00:00
|
|
|
}
|
2013-05-16 02:17:42 +00:00
|
|
|
swapFPIntParams(PV, M, IAH, LE, false);
|
|
|
|
IAH.Out("jr $$25");
|
|
|
|
IAH.Out(LocalName + " = " + Name);
|
|
|
|
new UnreachableInst(FStub->getContext(), BB);
|
|
|
|
}
|
|
|
|
|
2013-08-30 19:40:56 +00:00
|
|
|
//
|
|
|
|
// remove the use-soft-float attribute
|
|
|
|
//
|
|
|
|
static void removeUseSoftFloat(Function &F) {
|
|
|
|
AttributeSet A;
|
|
|
|
DEBUG(errs() << "removing -use-soft-float\n");
|
|
|
|
A = A.addAttribute(F.getContext(), AttributeSet::FunctionIndex,
|
|
|
|
"use-soft-float", "false");
|
|
|
|
F.removeAttributes(AttributeSet::FunctionIndex, A);
|
|
|
|
if (F.hasFnAttribute("use-soft-float")) {
|
|
|
|
DEBUG(errs() << "still has -use-soft-float\n");
|
|
|
|
}
|
|
|
|
F.addAttributes(AttributeSet::FunctionIndex, A);
|
|
|
|
}
|
|
|
|
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// This pass only makes sense when the underlying chip has floating point but
|
|
|
|
// we are compiling as mips16.
|
|
|
|
// For all mips16 functions (that are not stubs we have already generated), or
|
|
|
|
// declared via attributes as nomips16, we must:
|
|
|
|
// 1) fixup all returns of float, double, single and double complex
|
|
|
|
// by calling a helper function before the actual return.
|
2014-02-14 19:16:39 +00:00
|
|
|
// 2) generate helper functions (stubs) that can be called by mips32
|
|
|
|
// functions that will move parameters passed normally passed in
|
|
|
|
// floating point
|
2013-05-16 02:17:42 +00:00
|
|
|
// registers the soft float equivalents.
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
// 3) in the case of static relocation, generate helper functions so that
|
|
|
|
// mips16 functions can call extern functions of unknown type (mips16 or
|
2013-05-16 02:17:42 +00:00
|
|
|
// mips32).
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
// 4) TBD. For pic, calls to extern functions of unknown type are handled by
|
|
|
|
// predefined helper functions in libc but this work is currently done
|
|
|
|
// during call lowering but it should be moved here in the future.
|
|
|
|
//
|
|
|
|
bool Mips16HardFloat::runOnModule(Module &M) {
|
|
|
|
DEBUG(errs() << "Run on Module Mips16HardFloat\n");
|
|
|
|
bool Modified = false;
|
|
|
|
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
|
2013-08-30 19:40:56 +00:00
|
|
|
if (F->hasFnAttribute("nomips16") &&
|
|
|
|
F->hasFnAttribute("use-soft-float")) {
|
|
|
|
removeUseSoftFloat(*F);
|
|
|
|
continue;
|
|
|
|
}
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
if (F->isDeclaration() || F->hasFnAttribute("mips16_fp_stub") ||
|
|
|
|
F->hasFnAttribute("nomips16")) continue;
|
2015-01-06 01:12:30 +00:00
|
|
|
Modified |= fixupFPReturnAndCall(*F, &M, TM);
|
2013-05-16 02:17:42 +00:00
|
|
|
FPParamVariant V = whichFPParamVariantNeeded(*F);
|
|
|
|
if (V != NoSig) {
|
|
|
|
Modified = true;
|
2015-01-06 01:12:30 +00:00
|
|
|
createFPFnStub(F, &M, V, TM);
|
2013-05-16 02:17:42 +00:00
|
|
|
}
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
}
|
|
|
|
return Modified;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-14 09:02:23 +00:00
|
|
|
ModulePass *llvm::createMips16HardFloatPass(MipsTargetMachine &TM) {
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181641 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-10 22:25:39 +00:00
|
|
|
return new Mips16HardFloat(TM);
|
|
|
|
}
|