1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[mips] Fix MIPS N32 ABI triples support

Add support mips64(el)-linux-gnuabin32 triples, and set them to N32.
Debian architecture name mipsn32/mipsn32el are also added. Set
UseIntegratedAssembler for N32 if we can detect it.

Patch by YunQiang Su.

Differential revision: https://reviews.llvm.org/D51408

llvm-svn: 342416
This commit is contained in:
Simon Atanasyan 2018-09-17 21:21:57 +00:00
parent 210ae53b0e
commit eb4a85b34a
7 changed files with 79 additions and 7 deletions

View File

@ -56,9 +56,9 @@ public:
bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
hexagon, // Hexagon: hexagon
mips, // MIPS: mips, mipsallegrex
mipsel, // MIPSEL: mipsel, mipsallegrexel
mips64, // MIPS64: mips64
mips64el, // MIPS64EL: mips64el
mipsel, // MIPSEL: mipsel, mipsallegrexe
mips64, // MIPS64: mips64, mipsn32
mips64el, // MIPS64EL: mips64el, mipsn32el
msp430, // MSP430: msp430
nios2, // NIOSII: nios2
ppc, // PPC: powerpc

View File

@ -401,8 +401,8 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("msp430", Triple::msp430)
.Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
.Cases("mipsel", "mipsallegrexel", Triple::mipsel)
.Cases("mips64", "mips64eb", Triple::mips64)
.Case("mips64el", Triple::mips64el)
.Cases("mips64", "mips64eb", "mipsn32", Triple::mips64)
.Cases("mips64el", "mipsn32el", Triple::mips64el)
.Case("nios2", Triple::nios2)
.Case("r600", Triple::r600)
.Case("amdgcn", Triple::amdgcn)
@ -711,6 +711,14 @@ Triple::Triple(const Twine &Str)
ObjectFormat = parseFormat(Components[3]);
}
}
} else {
Environment = StringSwitch<Triple::EnvironmentType>(Components[0])
.StartsWith("mipsn32", Triple::GNUABIN32)
.StartsWith("mips64", Triple::GNUABI64)
.StartsWith("mipsisa64", Triple::GNUABI64)
.StartsWith("mipsisa32", Triple::GNU)
.Cases("mips", "mipsel", Triple::GNU)
.Default(UnknownEnvironment);
}
}
if (ObjectFormat == UnknownObjectFormat)

View File

@ -55,6 +55,8 @@ MipsABIInfo MipsABIInfo::computeTargetABI(const Triple &TT, StringRef CPU,
return MipsABIInfo::N32();
if (Options.getABIName().startswith("n64"))
return MipsABIInfo::N64();
if (TT.getEnvironment() == llvm::Triple::GNUABIN32)
return MipsABIInfo::N32();
assert(Options.getABIName().empty() && "Unknown ABI option for MIPS");
if (TT.isMIPS64())

View File

@ -13,6 +13,7 @@
//
#include "MCTargetDesc/MipsAsmBackend.h"
#include "MCTargetDesc/MipsABIInfo.h"
#include "MCTargetDesc/MipsFixupKinds.h"
#include "MCTargetDesc/MipsMCExpr.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
@ -572,6 +573,6 @@ MCAsmBackend *llvm::createMipsAsmBackend(const Target &T,
const MCSubtargetInfo &STI,
const MCRegisterInfo &MRI,
const MCTargetOptions &Options) {
return new MipsAsmBackend(T, MRI, STI.getTargetTriple(), STI.getCPU(),
Options.ABIName == "n32");
MipsABIInfo ABI = MipsABIInfo::computeTargetABI(STI.getTargetTriple(), STI.getCPU(), Options);
return new MipsAsmBackend(T, MRI, STI.getTargetTriple(), STI.getCPU(), ABI.IsN32());
}

View File

@ -59,6 +59,10 @@ MipsMCAsmInfo::MipsMCAsmInfo(const Triple &TheTriple) {
if (TheTriple.getEnvironment() == Triple::GNUABI64)
UseIntegratedAssembler = true;
// Enable IAS by default for Debian mipsn32/mipsn32el.
if (TheTriple.getEnvironment() == Triple::GNUABIN32)
UseIntegratedAssembler = true;
// Enable IAS by default for Android mips64el that uses N64 ABI.
if (TheTriple.getArch() == Triple::mips64el && TheTriple.isAndroid())
UseIntegratedAssembler = true;

View File

@ -2,6 +2,10 @@
// RUN: llvm-mc -filetype=obj -triple=mips64-linux-gnu -mcpu=mips3 \
// RUN: -target-abi=n32 %s -o - | llvm-readobj -r | FileCheck %s
// RUN: llvm-mc -filetype=obj -triple=mips64-linux-gnuabin32 -mcpu=mips3 \
// RUN: %s -o - | llvm-readobj -r | FileCheck %s
// RUN: llvm-mc -filetype=obj -triple=mipsn32 -mcpu=mips3 \
// RUN: %s -o - | llvm-readobj -r | FileCheck %s
// CHECK: Relocations [
// CHECK-NEXT: Section (3) .rela.text {

View File

@ -366,6 +366,59 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
T = Triple("mips64el");
EXPECT_EQ(Triple::mips64el, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
T = Triple("mips64-unknown-linux-gnuabi64");
EXPECT_EQ(Triple::mips64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
T = Triple("mips64");
EXPECT_EQ(Triple::mips64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
T = Triple("mips64el-unknown-linux-gnuabin32");
EXPECT_EQ(Triple::mips64el, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
T = Triple("mipsn32el");
EXPECT_EQ(Triple::mips64el, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
T = Triple("mips64-unknown-linux-gnuabin32");
EXPECT_EQ(Triple::mips64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
T = Triple("mipsn32");
EXPECT_EQ(Triple::mips64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
T = Triple("mipsel-unknown-linux-gnu");
EXPECT_EQ(Triple::mipsel, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNU, T.getEnvironment());
T = Triple("mipsel");
EXPECT_EQ(Triple::mipsel, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNU, T.getEnvironment());
T = Triple("mips-unknown-linux-gnu");
EXPECT_EQ(Triple::mips, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNU, T.getEnvironment());
T = Triple("mips");
EXPECT_EQ(Triple::mips, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::GNU, T.getEnvironment());
T = Triple("arm-oe-linux-gnueabi");
EXPECT_EQ(Triple::arm, T.getArch());