Skip to content

Commit eb43836

Browse files
committed
[TargetParser] Parse Amazon Linux triple and handle RuntimeLibcalls
This parses the "aarch64-amazon-linux" triple and updates RuntimeLibcalls to mark the sincos* functions as available on Amazon Linux. This allows these functions to be vectorized on Amazon Linux.
1 parent bf6986f commit eb43836

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ class Triple {
194194
SUSE,
195195
OpenEmbedded,
196196
Intel,
197-
LastVendorType = Intel
197+
Amazon,
198+
LastVendorType = Amazon
198199
};
199200
enum OSType {
200201
UnknownOS,
@@ -900,6 +901,11 @@ class Triple {
900901
return getArch() == Triple::arm || getArch() == Triple::armeb;
901902
}
902903

904+
/// Tests whether the target is Amazon Linux.
905+
bool isAmazonLinux() const {
906+
return getOS() == Triple::Linux && getVendor() == Triple::Amazon;
907+
}
908+
903909
/// Tests whether the target supports the EHABI exception
904910
/// handling standard.
905911
bool isTargetEHABICompatible() const {

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
173173
setLibcallName(RTLIB::EXP10_F64, "__exp10");
174174
}
175175

176-
if (TT.isGNUEnvironment() || TT.isOSFuchsia() ||
176+
if (TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAmazonLinux() ||
177177
(TT.isAndroid() && !TT.isAndroidVersionLT(9))) {
178178
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
179179
setLibcallName(RTLIB::SINCOS_F64, "sincos");

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
270270
case PC: return "pc";
271271
case SCEI: return "scei";
272272
case SUSE: return "suse";
273+
case Amazon:
274+
return "amazon";
273275
}
274276

275277
llvm_unreachable("Invalid VendorType!");
@@ -664,6 +666,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
664666
.Case("suse", Triple::SUSE)
665667
.Case("oe", Triple::OpenEmbedded)
666668
.Case("intel", Triple::Intel)
669+
.Case("amazon", Triple::Amazon)
667670
.Default(Triple::UnknownVendor);
668671
}
669672

llvm/test/CodeGen/AArch64/veclib-llvm.sincos.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter "(bl|ptrue)" --version 5
22
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
33
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
4+
; Check we expand to a vector library call on aarch64-amazon-linux:
5+
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
6+
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
47

58
define void @test_sincos_v4f32(<4 x float> %x, ptr noalias %out_sin, ptr noalias %out_cos) {
69
; SLEEF-LABEL: test_sincos_v4f32:

llvm/test/Transforms/LoopVectorize/AArch64/multiple-result-intrinsics.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|modf|extractvalue|store)" --version 5
22
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve < %s -S -o - -debug-only=loop-vectorize 2>%t.1 | FileCheck %s --check-prefix=CHECK
33
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.2 | FileCheck %s --check-prefix=CHECK-ARMPL
4+
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-amazon-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.3 | FileCheck %s --check-prefix=CHECK-ARMPL
45
; RUN: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
56
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
7+
; Check we vectorize the functions with the vector-library on aarch64-amazon-linux:
8+
; RUN: FileCheck --input-file=%t.3 --check-prefix=CHECK-COST-ARMPL %s
69
; REQUIRES: asserts
710

811
; CHECK-COST-LABEL: sincos_f32

llvm/unittests/TargetParser/TripleTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ TEST(TripleTest, ParsedIDs) {
125125
EXPECT_EQ(Triple::Hurd, T.getOS());
126126
EXPECT_EQ(Triple::GNU, T.getEnvironment());
127127

128+
T = Triple("aarch64-amazon-linux");
129+
EXPECT_EQ(Triple::aarch64, T.getArch());
130+
EXPECT_EQ(Triple::Amazon, T.getVendor());
131+
EXPECT_EQ(Triple::Linux, T.getOS());
132+
128133
T = Triple("arm-unknown-linux-android16");
129134
EXPECT_EQ(Triple::arm, T.getArch());
130135
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());

0 commit comments

Comments
 (0)