llvm.org GIT mirror llvm / ab8ffad
Add support for musl-libc on ARM Linux. Patch by Lei Zhang! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273726 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 3 years ago
13 changed file(s) with 69 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
179179 EABIHF,
180180 Android,
181181 Musl,
182 MuslEABI,
183 MuslEABIHF,
182184
183185 MSVC,
184186 Itanium,
570572 /// Tests whether the target is Android
571573 bool isAndroid() const { return getEnvironment() == Triple::Android; }
572574
575 /// Tests whether the environment is musl-libc
576 bool isMusl() const {
577 return getEnvironment() == Triple::Musl ||
578 getEnvironment() == Triple::MuslEABI ||
579 getEnvironment() == Triple::MuslEABIHF;
580 }
581
573582 /// Tests whether the target is NVPTX (32- or 64-bit).
574583 bool isNVPTX() const {
575584 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
205205 case EABIHF: return "eabihf";
206206 case Android: return "android";
207207 case Musl: return "musl";
208 case MuslEABI: return "musleabi";
209 case MuslEABIHF: return "musleabihf";
208210 case MSVC: return "msvc";
209211 case Itanium: return "itanium";
210212 case Cygnus: return "cygnus";
464466 .StartsWith("code16", Triple::CODE16)
465467 .StartsWith("gnu", Triple::GNU)
466468 .StartsWith("android", Triple::Android)
469 .StartsWith("musleabihf", Triple::MuslEABIHF)
470 .StartsWith("musleabi", Triple::MuslEABI)
467471 .StartsWith("musl", Triple::Musl)
468472 .StartsWith("msvc", Triple::MSVC)
469473 .StartsWith("itanium", Triple::Itanium)
14531457 switch (getEnvironment()) {
14541458 case llvm::Triple::EABIHF:
14551459 case llvm::Triple::GNUEABIHF:
1460 case llvm::Triple::MuslEABIHF:
14561461 return "arm1176jzf-s";
14571462 default:
14581463 return "arm7tdmi";
561561 ARMTargetStreamer &ATS = static_cast(TS);
562562
563563 if (OptimizationGoals > 0 &&
564 (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI()))
564 (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
565 Subtarget->isTargetMuslAEABI()))
565566 ATS.emitAttribute(ARMBuildAttrs::ABI_optimization_goals, OptimizationGoals);
566567 OptimizationGoals = -1;
567568
254254 // RTLIB
255255 if (Subtarget->isAAPCS_ABI() &&
256256 (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
257 Subtarget->isTargetAndroid())) {
257 Subtarget->isTargetMuslAEABI() || Subtarget->isTargetAndroid())) {
258258 static const struct {
259259 const RTLIB::Libcall Op;
260260 const char * const Name;
792792 setOperationAction(ISD::UREM, MVT::i32, Expand);
793793 // Register based DivRem for AEABI (RTABI 4.2)
794794 if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
795 Subtarget->isTargetGNUAEABI()) {
795 Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI()) {
796796 setOperationAction(ISD::SREM, MVT::i64, Custom);
797797 setOperationAction(ISD::UREM, MVT::i64, Custom);
798798
1204712047
1204812048 SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const {
1204912049 assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
12050 Subtarget->isTargetGNUAEABI()) &&
12050 Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI()) &&
1205112051 "Register-based DivRem lowering only");
1205212052 unsigned Opcode = Op->getOpcode();
1205312053 assert((Opcode == ISD::SDIVREM || Opcode == ISD::UDIVREM) &&
445445 TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
446446 !isTargetDarwin() && !isTargetWindows();
447447 }
448 bool isTargetMuslAEABI() const {
449 return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
450 TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
451 !isTargetDarwin() && !isTargetWindows();
452 }
448453
449454 // ARM Targets that support EHABI exception handling standard
450455 // Darwin uses SjLj. Other targets might need more checks.
451456 bool isTargetEHABICompatible() const {
452457 return (TargetTriple.getEnvironment() == Triple::EABI ||
453458 TargetTriple.getEnvironment() == Triple::GNUEABI ||
459 TargetTriple.getEnvironment() == Triple::MuslEABI ||
454460 TargetTriple.getEnvironment() == Triple::EABIHF ||
455461 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
462 TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
456463 isTargetAndroid()) &&
457464 !isTargetDarwin() && !isTargetWindows();
458465 }
460467 bool isTargetHardFloat() const {
461468 // FIXME: this is invalid for WindowsCE
462469 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
470 TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
463471 TargetTriple.getEnvironment() == Triple::EABIHF ||
464472 isTargetWindows() || isAAPCS16_ABI();
465473 }
9999 case llvm::Triple::Android:
100100 case llvm::Triple::GNUEABI:
101101 case llvm::Triple::GNUEABIHF:
102 case llvm::Triple::MuslEABI:
103 case llvm::Triple::MuslEABIHF:
102104 case llvm::Triple::EABIHF:
103105 case llvm::Triple::EABI:
104106 TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
207209 // Default to triple-appropriate EABI
208210 if (Options.EABIVersion == EABI::Default ||
209211 Options.EABIVersion == EABI::Unknown) {
210 if (Subtarget.isTargetGNUAEABI())
212 // musl is compatible with glibc with regard to EABI version
213 if (Subtarget.isTargetGNUAEABI() || Subtarget.isTargetMuslAEABI())
211214 this->Options.EABIVersion = EABI::GNU;
212215 else
213216 this->Options.EABIVersion = EABI::EABI5;
22 ; RUN: llc < %s -mtriple=arm-none-androideabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
33 ; RUN: llc < %s -mtriple=arm-none-gnueabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
44 ; RUN: llc < %s -mtriple=arm-none-gnueabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
5 ; RUN: llc < %s -mtriple=arm-none-musleabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
6 ; RUN: llc < %s -mtriple=arm-none-musleabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
57 ; RUN: llc < %s -mtriple=arm-none-eabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
68 ; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
79 ; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
810 ; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
911 ; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
12 ; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
13 ; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=gnu -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI
1014 ; RUN: llc < %s -mtriple=arm-none-eabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1115 ; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1216 ; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1317 ; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1418 ; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
19 ; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
20 ; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=4 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1521 ; RUN: llc < %s -mtriple=arm-none-eabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1622 ; RUN: llc < %s -mtriple=arm-none-eabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1723 ; RUN: llc < %s -mtriple=arm-none-androideabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1824 ; RUN: llc < %s -mtriple=arm-none-gnueabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
1925 ; RUN: llc < %s -mtriple=arm-none-gnueabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
26 ; RUN: llc < %s -mtriple=arm-none-musleabi -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
27 ; RUN: llc < %s -mtriple=arm-none-musleabihf -meabi=5 -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI
2028
2129 %struct.my_s = type { [18 x i32] }
2230
0 ; RUN: llc -mtriple=armv7-linux-gnueabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
1 ; RUN: llc -mtriple=armv7-linux-musleabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
12 ; RUN: llc -mtriple=armv7-linux-eabihf %s -o - | FileCheck %s --check-prefix=CHECK-HARD
23 ; RUN: llc -mtriple=armv7-linux-gnueabihf -float-abi=soft %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
4 ; RUN: llc -mtriple=armv7-linux-musleabihf -float-abi=soft %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
35 ; RUN: llc -mtriple=armv7-linux-gnueabi %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
6 ; RUN: llc -mtriple=armv7-linux-musleabi %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
47 ; RUN: llc -mtriple=armv7-linux-eabi -float-abi=hard %s -o - | FileCheck %s --check-prefix=CHECK-HARD
58 ; RUN: llc -mtriple=thumbv7-apple-ios6.0 %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
69
22 ; All "eabi" (Bare, GNU and Android) must lower SREM/UREM to __aeabi_{u,i}divmod
33 ; RUN: llc -mtriple armv7-linux-androideabi %s -o - | FileCheck %s --check-prefix=EABI
44 ; RUN: llc -mtriple armv7-linux-gnueabi %s -o - | FileCheck %s --check-prefix=EABI
5 ; RUN: llc -mtriple armv7-linux-musleabi %s -o - | FileCheck %s --check-prefix=EABI
56 ; RUN: llc -mtriple armv7-apple-darwin %s -o - | FileCheck %s --check-prefix=DARWIN
67 ; FIXME: long-term, we will use "-apple-macho" and won't need this exception:
78 ; RUN: llc -mtriple armv7-apple-darwin-eabi %s -o - | FileCheck %s --check-prefix=DARWIN
3030 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
3131
3232 ; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
33 ; RUN: -filetype=asm -o - %s \
34 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
35
36 ; RUN: llc -mtriple arm-unknown-linux-musleabi \
37 ; RUN: -disable-fp-elim -filetype=asm -o - %s \
38 ; RUN: | FileCheck %s --check-prefix=CHECK-FP
39
40 ; RUN: llc -mtriple arm-unknown-linux-musleabi \
41 ; RUN: -filetype=asm -o - %s \
42 ; RUN: | FileCheck %s --check-prefix=CHECK-FP-ELIM
43
44 ; RUN: llc -mtriple armv7-unknown-linux-musleabi \
45 ; RUN: -disable-fp-elim -filetype=asm -o - %s \
46 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
47
48 ; RUN: llc -mtriple armv7-unknown-linux-musleabi \
3349 ; RUN: -filetype=asm -o - %s \
3450 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
3551
0 ; RUN: llc -mtriple=armv7a--none-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-EABI %s
11 ; RUN: llc -mtriple=armv7a--none-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
2 ; RUN: llc -mtriple=armv7a--none-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-HARDFLOAT-GNU %s
23 ; RUN: llc -mtriple=armv8-eabihf < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARMV8 %s
34 ; RUN: llc -mtriple=thumbv7m-eabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-EABI %s
45 ; RUN: llc -mtriple=thumbv7m-gnueabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
6 ; RUN: llc -mtriple=thumbv7m-musleabi < %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-SOFTFLOAT-GNU %s
57
68 ;; +fp16 is special: it has f32->f16 (unlike v7), but not f64->f16 (unlike v8).
79 ;; This exposes unsafe-fp-math optimization opportunities; test that.
44 ; RUN: llc < %s -mtriple=arm-none-androideabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-EABI --check-prefix=CHECK
55 ; RUN: llc < %s -mtriple=arm-none-gnueabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
66 ; RUN: llc < %s -mtriple=arm-none-gnueabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
7 ; RUN: llc < %s -mtriple=arm-none-musleabi -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
8 ; RUN: llc < %s -mtriple=arm-none-musleabihf -disable-post-ra -o - | FileCheck %s --check-prefix=CHECK-GNUEABI --check-prefix=CHECK
79
810 define void @f1(i8* %dest, i8* %src) {
911 entry:
139139 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
140140 EXPECT_EQ(Triple::UnknownOS, T.getOS());
141141 EXPECT_EQ(Triple::EABI, T.getEnvironment());
142
143 T = Triple("arm-none-linux-musleabi");
144 EXPECT_EQ(Triple::arm, T.getArch());
145 EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
146 EXPECT_EQ(Triple::Linux, T.getOS());
147 EXPECT_EQ(Triple::MuslEABI, T.getEnvironment());
142148
143149 T = Triple("armv6hl-none-linux-gnueabi");
144150 EXPECT_EQ(Triple::arm, T.getArch());