forked from OSchip/llvm-project
Add support for musl-libc on ARM Linux.
Patch by Lei Zhang! llvm-svn: 273726
This commit is contained in:
parent
cd7f886e06
commit
a895a0cd01
|
@ -180,6 +180,8 @@ public:
|
|||
EABIHF,
|
||||
Android,
|
||||
Musl,
|
||||
MuslEABI,
|
||||
MuslEABIHF,
|
||||
|
||||
MSVC,
|
||||
Itanium,
|
||||
|
@ -571,6 +573,13 @@ public:
|
|||
/// Tests whether the target is Android
|
||||
bool isAndroid() const { return getEnvironment() == Triple::Android; }
|
||||
|
||||
/// Tests whether the environment is musl-libc
|
||||
bool isMusl() const {
|
||||
return getEnvironment() == Triple::Musl ||
|
||||
getEnvironment() == Triple::MuslEABI ||
|
||||
getEnvironment() == Triple::MuslEABIHF;
|
||||
}
|
||||
|
||||
/// Tests whether the target is NVPTX (32- or 64-bit).
|
||||
bool isNVPTX() const {
|
||||
return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
|
||||
|
|
|
@ -206,6 +206,8 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
|
|||
case EABIHF: return "eabihf";
|
||||
case Android: return "android";
|
||||
case Musl: return "musl";
|
||||
case MuslEABI: return "musleabi";
|
||||
case MuslEABIHF: return "musleabihf";
|
||||
case MSVC: return "msvc";
|
||||
case Itanium: return "itanium";
|
||||
case Cygnus: return "cygnus";
|
||||
|
@ -465,6 +467,8 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
|
|||
.StartsWith("code16", Triple::CODE16)
|
||||
.StartsWith("gnu", Triple::GNU)
|
||||
.StartsWith("android", Triple::Android)
|
||||
.StartsWith("musleabihf", Triple::MuslEABIHF)
|
||||
.StartsWith("musleabi", Triple::MuslEABI)
|
||||
.StartsWith("musl", Triple::Musl)
|
||||
.StartsWith("msvc", Triple::MSVC)
|
||||
.StartsWith("itanium", Triple::Itanium)
|
||||
|
@ -1454,6 +1458,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const {
|
|||
switch (getEnvironment()) {
|
||||
case llvm::Triple::EABIHF:
|
||||
case llvm::Triple::GNUEABIHF:
|
||||
case llvm::Triple::MuslEABIHF:
|
||||
return "arm1176jzf-s";
|
||||
default:
|
||||
return "arm7tdmi";
|
||||
|
|
|
@ -562,7 +562,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
|
|||
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
|
||||
|
||||
if (OptimizationGoals > 0 &&
|
||||
(Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI()))
|
||||
(Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
|
||||
Subtarget->isTargetMuslAEABI()))
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_optimization_goals, OptimizationGoals);
|
||||
OptimizationGoals = -1;
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
|
|||
// RTLIB
|
||||
if (Subtarget->isAAPCS_ABI() &&
|
||||
(Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
|
||||
Subtarget->isTargetAndroid())) {
|
||||
Subtarget->isTargetMuslAEABI() || Subtarget->isTargetAndroid())) {
|
||||
static const struct {
|
||||
const RTLIB::Libcall Op;
|
||||
const char * const Name;
|
||||
|
@ -793,7 +793,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
|
|||
setOperationAction(ISD::UREM, MVT::i32, Expand);
|
||||
// Register based DivRem for AEABI (RTABI 4.2)
|
||||
if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
|
||||
Subtarget->isTargetGNUAEABI()) {
|
||||
Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI()) {
|
||||
setOperationAction(ISD::SREM, MVT::i64, Custom);
|
||||
setOperationAction(ISD::UREM, MVT::i64, Custom);
|
||||
|
||||
|
@ -12048,7 +12048,7 @@ static TargetLowering::ArgListTy getDivRemArgList(
|
|||
|
||||
SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const {
|
||||
assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
|
||||
Subtarget->isTargetGNUAEABI()) &&
|
||||
Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI()) &&
|
||||
"Register-based DivRem lowering only");
|
||||
unsigned Opcode = Op->getOpcode();
|
||||
assert((Opcode == ISD::SDIVREM || Opcode == ISD::UDIVREM) &&
|
||||
|
|
|
@ -446,14 +446,21 @@ public:
|
|||
TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
|
||||
!isTargetDarwin() && !isTargetWindows();
|
||||
}
|
||||
bool isTargetMuslAEABI() const {
|
||||
return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
|
||||
TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
|
||||
!isTargetDarwin() && !isTargetWindows();
|
||||
}
|
||||
|
||||
// ARM Targets that support EHABI exception handling standard
|
||||
// Darwin uses SjLj. Other targets might need more checks.
|
||||
bool isTargetEHABICompatible() const {
|
||||
return (TargetTriple.getEnvironment() == Triple::EABI ||
|
||||
TargetTriple.getEnvironment() == Triple::GNUEABI ||
|
||||
TargetTriple.getEnvironment() == Triple::MuslEABI ||
|
||||
TargetTriple.getEnvironment() == Triple::EABIHF ||
|
||||
TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
|
||||
TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
|
||||
isTargetAndroid()) &&
|
||||
!isTargetDarwin() && !isTargetWindows();
|
||||
}
|
||||
|
@ -461,6 +468,7 @@ public:
|
|||
bool isTargetHardFloat() const {
|
||||
// FIXME: this is invalid for WindowsCE
|
||||
return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
|
||||
TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
|
||||
TargetTriple.getEnvironment() == Triple::EABIHF ||
|
||||
isTargetWindows() || isAAPCS16_ABI();
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ computeTargetABI(const Triple &TT, StringRef CPU,
|
|||
case llvm::Triple::Android:
|
||||
case llvm::Triple::GNUEABI:
|
||||
case llvm::Triple::GNUEABIHF:
|
||||
case llvm::Triple::MuslEABI:
|
||||
case llvm::Triple::MuslEABIHF:
|
||||
case llvm::Triple::EABIHF:
|
||||
case llvm::Triple::EABI:
|
||||
TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
|
||||
|
@ -208,7 +210,8 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT,
|
|||
// Default to triple-appropriate EABI
|
||||
if (Options.EABIVersion == EABI::Default ||
|
||||
Options.EABIVersion == EABI::Unknown) {
|
||||
if (Subtarget.isTargetGNUAEABI())
|
||||
// musl is compatible with glibc with regard to EABI version
|
||||
if (Subtarget.isTargetGNUAEABI() || Subtarget.isTargetMuslAEABI())
|
||||
this->Options.EABIVersion = EABI::GNU;
|
||||
else
|
||||
this->Options.EABIVersion = EABI::EABI5;
|
||||
|
|
|
@ -3,21 +3,29 @@
|
|||
; RUN: llc < %s -mtriple=arm-none-androideabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
|
||||
|
||||
%struct.my_s = type { [18 x i32] }
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
; RUN: llc -mtriple=armv7-linux-gnueabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
|
||||
; RUN: llc -mtriple=armv7-linux-musleabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
|
||||
; RUN: llc -mtriple=armv7-linux-eabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
|
||||
; RUN: llc -mtriple=armv7-linux-gnueabihf -float-abi=soft %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
|
||||
; RUN: llc -mtriple=armv7-linux-musleabihf -float-abi=soft %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
|
||||
; RUN: llc -mtriple=armv7-linux-gnueabi %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
|
||||
; RUN: llc -mtriple=armv7-linux-musleabi %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
|
||||
; RUN: llc -mtriple=armv7-linux-eabi -float-abi=hard %s -o - | FileCheck %s --check-prefix=CHECK-HARD
|
||||
; RUN: llc -mtriple=thumbv7-apple-ios6.0 %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
; All "eabi" (Bare, GNU and Android) must lower SREM/UREM to __aeabi_{u,i}divmod
|
||||
; RUN: llc -mtriple armv7-linux-androideabi %s -o - | FileCheck %s --check-prefix=EABI
|
||||
; RUN: llc -mtriple armv7-linux-gnueabi %s -o - | FileCheck %s --check-prefix=EABI
|
||||
; RUN: llc -mtriple armv7-linux-musleabi %s -o - | FileCheck %s --check-prefix=EABI
|
||||
; RUN: llc -mtriple armv7-apple-darwin %s -o - | FileCheck %s --check-prefix=DARWIN
|
||||
; FIXME: long-term, we will use "-apple-macho" and won't need this exception:
|
||||
; RUN: llc -mtriple armv7-apple-darwin-eabi %s -o - | FileCheck %s --check-prefix=DARWIN
|
||||
|
|
|
@ -34,6 +34,22 @@
|
|||
; RUN: -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
|
||||
|
||||
; RUN: llc -mtriple arm-unknown-linux-musleabi \
|
||||
; RUN: -disable-fp-elim -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-FP
|
||||
|
||||
; RUN: llc -mtriple arm-unknown-linux-musleabi \
|
||||
; RUN: -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-FP-ELIM
|
||||
|
||||
; RUN: llc -mtriple armv7-unknown-linux-musleabi \
|
||||
; RUN: -disable-fp-elim -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
|
||||
|
||||
; RUN: llc -mtriple armv7-unknown-linux-musleabi \
|
||||
; RUN: -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
|
||||
|
||||
; RUN: llc -mtriple arm-unknown-linux-androideabi \
|
||||
; RUN: -disable-fp-elim -filetype=asm -o - %s \
|
||||
; RUN: | FileCheck %s --check-prefix=CHECK-FP
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
; RUN: llc -mtriple=armv7a--none-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-EABI %s
|
||||
; RUN: llc -mtriple=armv7a--none-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
|
||||
; RUN: llc -mtriple=armv7a--none-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
|
||||
; RUN: llc -mtriple=armv8-eabihf < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARMV8 %s
|
||||
; RUN: llc -mtriple=thumbv7m-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s
|
||||
; RUN: llc -mtriple=thumbv7m-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
|
||||
; RUN: llc -mtriple=thumbv7m-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
|
||||
|
||||
;; +fp16 is special: it has f32->f16 (unlike v7), but not f64->f16 (unlike v8).
|
||||
;; This exposes unsafe-fp-math optimization opportunities; test that.
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
; RUN: llc < %s -mtriple=arm-none-androideabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI --check-prefix=CHECK
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
|
||||
; RUN: llc < %s -mtriple=arm-none-gnueabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
|
||||
; RUN: llc < %s -mtriple=arm-none-musleabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
|
||||
|
||||
define void @f1(i8* %dest, i8* %src) {
|
||||
entry:
|
||||
|
|
|
@ -141,6 +141,12 @@ TEST(TripleTest, ParsedIDs) {
|
|||
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
||||
EXPECT_EQ(Triple::EABI, T.getEnvironment());
|
||||
|
||||
T = Triple("arm-none-linux-musleabi");
|
||||
EXPECT_EQ(Triple::arm, T.getArch());
|
||||
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
||||
EXPECT_EQ(Triple::Linux, T.getOS());
|
||||
EXPECT_EQ(Triple::MuslEABI, T.getEnvironment());
|
||||
|
||||
T = Triple("armv6hl-none-linux-gnueabi");
|
||||
EXPECT_EQ(Triple::arm, T.getArch());
|
||||
EXPECT_EQ(Triple::Linux, T.getOS());
|
||||
|
|
Loading…
Reference in New Issue