Skip to content

[Downstream change][TargetParser] Parse Amazon Linux triple and handle RuntimeLibcalls #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/arm-software/20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion llvm/include/llvm/TargetParser/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ class Triple {
SUSE,
OpenEmbedded,
Intel,
LastVendorType = Intel
// Downstream change: #87 (sincos vectorization)
Amazon,
LastVendorType = Amazon
};
enum OSType {
UnknownOS,
Expand Down Expand Up @@ -899,6 +901,12 @@ class Triple {
return getArch() == Triple::arm || getArch() == Triple::armeb;
}

// Downstream change: #87 (sincos vectorization)
/// Tests whether the target is Amazon Linux.
bool isAmazonLinux() const {
return getOS() == Triple::Linux && getVendor() == Triple::Amazon;
}

/// Tests whether the target supports the EHABI exception
/// handling standard.
bool isTargetEHABICompatible() const {
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
setLibcallName(RTLIB::FPROUND_F32_F16, "__gnu_f2h_ieee");
}

if (TT.isGNUEnvironment() || TT.isOSFuchsia() ||
// Downstream change: #87 (sincos vectorization)
if (TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAmazonLinux() ||
(TT.isAndroid() && !TT.isAndroidVersionLT(9))) {
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
setLibcallName(RTLIB::SINCOS_F64, "sincos");
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/TargetParser/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
case PC: return "pc";
case SCEI: return "scei";
case SUSE: return "suse";
case Amazon:
// Downstream change: #87 (sincos vectorization)
return "amazon";
}

llvm_unreachable("Invalid VendorType!");
Expand Down Expand Up @@ -664,6 +667,8 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
.Case("suse", Triple::SUSE)
.Case("oe", Triple::OpenEmbedded)
.Case("intel", Triple::Intel)
// Downstream change: #87 (sincos vectorization)
.Case("amazon", Triple::Amazon)
.Default(Triple::UnknownVendor);
}

Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/AArch64/veclib-llvm.sincos.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter "(bl|ptrue)" --version 5
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
; Check we expand to a vector library call on aarch64-amazon-linux:
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL

define void @test_sincos_v4f32(<4 x float> %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; SLEEF-LABEL: test_sincos_v4f32:
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/Transforms/LoopVectorize/AArch64/sincos.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|extractvalue|store)" --version 5
; 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
; 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
; 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
; RUN: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
; Check we vectorize the functions with the vector-library on aarch64-amazon-linux:
; RUN: FileCheck --input-file=%t.3 --check-prefix=CHECK-COST-ARMPL %s
; REQUIRES: asserts

; CHECK-COST-LABEL: sincos_f32
Expand Down
6 changes: 6 additions & 0 deletions llvm/unittests/TargetParser/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Hurd, T.getOS());
EXPECT_EQ(Triple::GNU, T.getEnvironment());

// Downstream change: #87 (sincos vectorization)
T = Triple("aarch64-amazon-linux");
EXPECT_EQ(Triple::aarch64, T.getArch());
EXPECT_EQ(Triple::Amazon, T.getVendor());
EXPECT_EQ(Triple::Linux, T.getOS());

T = Triple("arm-unknown-linux-android16");
EXPECT_EQ(Triple::arm, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Expand Down