From 41ca6917d80927cd13f3e605c2ae19e10145e170 Mon Sep 17 00:00:00 2001 From: Tim Renouf Date: Fri, 29 Sep 2017 09:48:12 +0000 Subject: [PATCH] [Triple] Add AMDPAL operating system type Summary: This operating system type represents the AMDGPU PAL runtime, and will be required by the AMDGPU backend in order to generate correct code for this runtime. Currently it generates the same code as not specifying an OS at all. That will change in future commits. Patch from Tim Corringham. Subscribers: arsenm, nhaehnle Differential Revision: https://reviews.llvm.org/D37380 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314500 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Triple.h | 3 ++- lib/Support/Triple.cpp | 2 ++ lib/Target/AMDGPU/AMDGPUSubtarget.h | 4 ++++ test/CodeGen/AMDGPU/amdpal.ll | 10 ++++++++++ unittests/ADT/TripleTest.cpp | 6 ++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/AMDGPU/amdpal.ll diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 4e1e218da78..f8fec5d0da7 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -179,7 +179,8 @@ public: WatchOS, // Apple watchOS Mesa3D, Contiki, - LastOSType = Contiki + AMDPAL, // AMD PAL Runtime + LastOSType = AMDPAL }; enum EnvironmentType { UnknownEnvironment, diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 8dc582ab95a..69c99ac907a 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -207,6 +207,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { case WatchOS: return "watchos"; case Mesa3D: return "mesa3d"; case Contiki: return "contiki"; + case AMDPAL: return "amdpal"; } llvm_unreachable("Invalid OSType"); @@ -499,6 +500,7 @@ static Triple::OSType parseOS(StringRef OSName) { .StartsWith("watchos", Triple::WatchOS) .StartsWith("mesa3d", Triple::Mesa3D) .StartsWith("contiki", Triple::Contiki) + .StartsWith("amdpal", Triple::AMDPAL) .Default(Triple::UnknownOS); } diff --git a/lib/Target/AMDGPU/AMDGPUSubtarget.h b/lib/Target/AMDGPU/AMDGPUSubtarget.h index 7e7a09648ed..0f725c181b7 100644 --- a/lib/Target/AMDGPU/AMDGPUSubtarget.h +++ b/lib/Target/AMDGPU/AMDGPUSubtarget.h @@ -214,6 +214,10 @@ public: TargetTriple.getEnvironmentName() == "amdgizcl"; } + bool isAmdPalOS() const { + return TargetTriple.getOS() == Triple::AMDPAL; + } + Generation getGeneration() const { return Gen; } diff --git a/test/CodeGen/AMDGPU/amdpal.ll b/test/CodeGen/AMDGPU/amdpal.ll new file mode 100644 index 00000000000..61205d0cdb8 --- /dev/null +++ b/test/CodeGen/AMDGPU/amdpal.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -mtriple=amdgcn--amdpal -mcpu=tahiti | FileCheck --check-prefix=PAL %s + +; PAL: .AMDGPU.config + +define amdgpu_kernel void @simple(i32 addrspace(1)* %out) { +entry: + store i32 0, i32 addrspace(1)* %out + ret void +} + diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index db11f426490..b78aee4f33d 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -272,6 +272,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::AMDHSA, T.getOS()); EXPECT_EQ(Triple::OpenCL, T.getEnvironment()); + T = Triple("amdgcn-amd-amdpal"); + EXPECT_EQ(Triple::amdgcn, T.getArch()); + EXPECT_EQ(Triple::AMD, T.getVendor()); + EXPECT_EQ(Triple::AMDPAL, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("riscv32-unknown-unknown"); EXPECT_EQ(Triple::riscv32, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); -- 2.40.0