Skip to content

Commit 78bb4d5

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 a905f4f commit 78bb4d5

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ class Triple {
194194
SUSE,
195195
OpenEmbedded,
196196
Intel,
197-
LastVendorType = Intel
197+
// Downstream change: #87 (sincos vectorization)
198+
Amazon,
199+
LastVendorType = Amazon
198200
};
199201
enum OSType {
200202
UnknownOS,
@@ -899,6 +901,12 @@ class Triple {
899901
return getArch() == Triple::arm || getArch() == Triple::armeb;
900902
}
901903

904+
// Downstream change: #87 (sincos vectorization)
905+
/// Tests whether the target is Amazon Linux.
906+
bool isAmazonLinux() const {
907+
return getOS() == Triple::Linux && getVendor() == Triple::Amazon;
908+
}
909+
902910
/// Tests whether the target supports the EHABI exception
903911
/// handling standard.
904912
bool isTargetEHABICompatible() const {

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
175175
setLibcallName(RTLIB::FPROUND_F32_F16, "__gnu_f2h_ieee");
176176
}
177177

178-
if (TT.isGNUEnvironment() || TT.isOSFuchsia() ||
178+
// Downstream change: #87 (sincos vectorization)
179+
if (TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAmazonLinux() ||
179180
(TT.isAndroid() && !TT.isAndroidVersionLT(9))) {
180181
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
181182
setLibcallName(RTLIB::SINCOS_F64, "sincos");

llvm/lib/TargetParser/Triple.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
270270
case PC: return "pc";
271271
case SCEI: return "scei";
272272
case SUSE: return "suse";
273+
case Amazon:
274+
// Downstream change: #87 (sincos vectorization)
275+
return "amazon";
273276
}
274277

275278
llvm_unreachable("Invalid VendorType!");
@@ -664,6 +667,8 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
664667
.Case("suse", Triple::SUSE)
665668
.Case("oe", Triple::OpenEmbedded)
666669
.Case("intel", Triple::Intel)
670+
// Downstream change: #87 (sincos vectorization)
671+
.Case("amazon", Triple::Amazon)
667672
.Default(Triple::UnknownVendor);
668673
}
669674

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/sincos.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|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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ TEST(TripleTest, ParsedIDs) {
125125
EXPECT_EQ(Triple::Hurd, T.getOS());
126126
EXPECT_EQ(Triple::GNU, T.getEnvironment());
127127

128+
// Downstream change: #87 (sincos vectorization)
129+
T = Triple("aarch64-amazon-linux");
130+
EXPECT_EQ(Triple::aarch64, T.getArch());
131+
EXPECT_EQ(Triple::Amazon, T.getVendor());
132+
EXPECT_EQ(Triple::Linux, T.getOS());
133+
128134
T = Triple("arm-unknown-linux-android16");
129135
EXPECT_EQ(Triple::arm, T.getArch());
130136
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());

0 commit comments

Comments
 (0)