2014-11-03 00:09:29 +08:00
|
|
|
//===---- MipsABIInfo.cpp - Information about MIPS ABI's ------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MipsABIInfo.h"
|
|
|
|
#include "MipsRegisterInfo.h"
|
2015-01-27 01:33:46 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
#include "llvm/MC/MCTargetOptions.h"
|
2014-11-03 00:09:29 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
static const MCPhysReg O32IntRegs[4] = {Mips::A0, Mips::A1, Mips::A2, Mips::A3};
|
|
|
|
|
|
|
|
static const MCPhysReg Mips64IntRegs[8] = {
|
|
|
|
Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64,
|
|
|
|
Mips::T0_64, Mips::T1_64, Mips::T2_64, Mips::T3_64};
|
|
|
|
}
|
|
|
|
|
|
|
|
const ArrayRef<MCPhysReg> MipsABIInfo::GetByValArgRegs() const {
|
|
|
|
if (IsO32())
|
|
|
|
return makeArrayRef(O32IntRegs);
|
|
|
|
if (IsN32() || IsN64())
|
|
|
|
return makeArrayRef(Mips64IntRegs);
|
|
|
|
llvm_unreachable("Unhandled ABI");
|
|
|
|
}
|
2014-11-07 20:21:37 +08:00
|
|
|
|
|
|
|
const ArrayRef<MCPhysReg> MipsABIInfo::GetVarArgRegs() const {
|
|
|
|
if (IsO32())
|
|
|
|
return makeArrayRef(O32IntRegs);
|
|
|
|
if (IsN32() || IsN64())
|
|
|
|
return makeArrayRef(Mips64IntRegs);
|
|
|
|
llvm_unreachable("Unhandled ABI");
|
|
|
|
}
|
2014-11-07 23:03:53 +08:00
|
|
|
|
|
|
|
unsigned MipsABIInfo::GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const {
|
|
|
|
if (IsO32())
|
|
|
|
return CC != CallingConv::Fast ? 16 : 0;
|
|
|
|
if (IsN32() || IsN64() || IsEABI())
|
|
|
|
return 0;
|
|
|
|
llvm_unreachable("Unhandled ABI");
|
|
|
|
}
|
2015-01-27 01:33:46 +08:00
|
|
|
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
MipsABIInfo MipsABIInfo::computeTargetABI(const TargetTuple &TT, StringRef CPU,
|
2015-01-27 01:33:46 +08:00
|
|
|
const MCTargetOptions &Options) {
|
|
|
|
if (Options.getABIName().startswith("o32"))
|
|
|
|
return MipsABIInfo::O32();
|
|
|
|
else if (Options.getABIName().startswith("n32"))
|
|
|
|
return MipsABIInfo::N32();
|
|
|
|
else if (Options.getABIName().startswith("n64"))
|
|
|
|
return MipsABIInfo::N64();
|
|
|
|
else if (Options.getABIName().startswith("eabi"))
|
|
|
|
return MipsABIInfo::EABI();
|
|
|
|
else if (!Options.getABIName().empty())
|
|
|
|
llvm_unreachable("Unknown ABI option for MIPS");
|
|
|
|
|
|
|
|
// FIXME: This shares code with the selectMipsCPU routine that's
|
|
|
|
// used and not shared in a couple of other places. This needs unifying
|
|
|
|
// at some level.
|
|
|
|
if (CPU.empty() || CPU == "generic") {
|
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).
For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.
This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.
This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.
Reviewers: rengolin
Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D10969
llvm-svn: 247692
2015-09-15 22:08:28 +08:00
|
|
|
if (TT.getArch() == TargetTuple::mips ||
|
|
|
|
TT.getArch() == TargetTuple::mipsel)
|
2015-01-27 01:33:46 +08:00
|
|
|
CPU = "mips32";
|
|
|
|
else
|
|
|
|
CPU = "mips64";
|
|
|
|
}
|
|
|
|
|
|
|
|
return StringSwitch<MipsABIInfo>(CPU)
|
|
|
|
.Case("mips1", MipsABIInfo::O32())
|
|
|
|
.Case("mips2", MipsABIInfo::O32())
|
|
|
|
.Case("mips32", MipsABIInfo::O32())
|
|
|
|
.Case("mips32r2", MipsABIInfo::O32())
|
2015-02-19 00:24:50 +08:00
|
|
|
.Case("mips32r3", MipsABIInfo::O32())
|
|
|
|
.Case("mips32r5", MipsABIInfo::O32())
|
2015-01-27 01:33:46 +08:00
|
|
|
.Case("mips32r6", MipsABIInfo::O32())
|
|
|
|
.Case("mips16", MipsABIInfo::O32())
|
|
|
|
.Case("mips3", MipsABIInfo::N64())
|
|
|
|
.Case("mips4", MipsABIInfo::N64())
|
|
|
|
.Case("mips5", MipsABIInfo::N64())
|
|
|
|
.Case("mips64", MipsABIInfo::N64())
|
|
|
|
.Case("mips64r2", MipsABIInfo::N64())
|
2015-02-19 00:24:50 +08:00
|
|
|
.Case("mips64r3", MipsABIInfo::N64())
|
|
|
|
.Case("mips64r5", MipsABIInfo::N64())
|
2015-01-27 01:33:46 +08:00
|
|
|
.Case("mips64r6", MipsABIInfo::N64())
|
|
|
|
.Case("octeon", MipsABIInfo::N64())
|
|
|
|
.Default(MipsABIInfo::Unknown());
|
|
|
|
}
|
2015-04-17 17:50:21 +08:00
|
|
|
|
|
|
|
unsigned MipsABIInfo::GetStackPtr() const {
|
|
|
|
return ArePtrs64bit() ? Mips::SP_64 : Mips::SP;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned MipsABIInfo::GetFramePtr() const {
|
|
|
|
return ArePtrs64bit() ? Mips::FP_64 : Mips::FP;
|
|
|
|
}
|
|
|
|
|
2015-06-02 21:14:46 +08:00
|
|
|
unsigned MipsABIInfo::GetBasePtr() const {
|
|
|
|
return ArePtrs64bit() ? Mips::S7_64 : Mips::S7;
|
|
|
|
}
|
|
|
|
|
2015-04-17 17:50:21 +08:00
|
|
|
unsigned MipsABIInfo::GetNullPtr() const {
|
|
|
|
return ArePtrs64bit() ? Mips::ZERO_64 : Mips::ZERO;
|
|
|
|
}
|
|
|
|
|
2015-08-17 18:11:55 +08:00
|
|
|
unsigned MipsABIInfo::GetZeroReg() const {
|
|
|
|
return AreGprs64bit() ? Mips::ZERO_64 : Mips::ZERO;
|
|
|
|
}
|
|
|
|
|
2015-04-17 17:50:21 +08:00
|
|
|
unsigned MipsABIInfo::GetPtrAdduOp() const {
|
|
|
|
return ArePtrs64bit() ? Mips::DADDu : Mips::ADDu;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned MipsABIInfo::GetPtrAddiuOp() const {
|
|
|
|
return ArePtrs64bit() ? Mips::DADDiu : Mips::ADDiu;
|
|
|
|
}
|
|
|
|
|
2015-08-11 16:56:25 +08:00
|
|
|
unsigned MipsABIInfo::GetGPRMoveOp() const {
|
|
|
|
return ArePtrs64bit() ? Mips::OR64 : Mips::OR;
|
|
|
|
}
|
|
|
|
|
2015-04-17 17:50:21 +08:00
|
|
|
unsigned MipsABIInfo::GetEhDataReg(unsigned I) const {
|
|
|
|
static const unsigned EhDataReg[] = {
|
|
|
|
Mips::A0, Mips::A1, Mips::A2, Mips::A3
|
|
|
|
};
|
|
|
|
static const unsigned EhDataReg64[] = {
|
|
|
|
Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64
|
|
|
|
};
|
|
|
|
|
|
|
|
return IsN64() ? EhDataReg64[I] : EhDataReg[I];
|
|
|
|
}
|
|
|
|
|