[clang] AMDGPU: Add missing gfx* generic targets handling in clang (NVPTX, OpenMP runtime) (PR #94483)
Konstantin Zhuravlyov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 5 08:12:19 PDT 2024
https://github.com/kzhuravl created https://github.com/llvm/llvm-project/pull/94483
None
>From 7d64f16e9bdc6b9a195a332a49e5fb9954d5f7c1 Mon Sep 17 00:00:00 2001
From: Konstantin Zhuravlyov <kzhuravl_dev at outlook.com>
Date: Wed, 5 Jun 2024 11:10:41 -0400
Subject: [PATCH] AMDGPU: Add missing gfx* generic targets handling in clang
(NVPTX, OpenMP runtime)
---
clang/include/clang/Basic/Cuda.h | 5 +++++
clang/lib/Basic/Cuda.cpp | 5 +++++
clang/lib/Basic/Targets/NVPTX.cpp | 5 +++++
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 5 +++++
clang/test/Misc/target-invalid-cpu-note.c | 2 +-
5 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 2d67c4181d129..2e126cdbca000 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -121,6 +121,11 @@ enum class CudaArch {
GFX1151,
GFX1200,
GFX1201,
+ GFX9_GENERIC,
+ GFX10_1_GENERIC,
+ GFX10_3_GENERIC,
+ GFX11_GENERIC,
+ GFX12_GENERIC,
Generic, // A processor model named 'generic' if the target backend defines a
// public one.
LAST,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index e8ce15eb0decb..f8e02af599ba9 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -141,6 +141,11 @@ static const CudaArchToStringMap arch_names[] = {
GFX(1151), // gfx1151
GFX(1200), // gfx1200
GFX(1201), // gfx1201
+ {CudaArch::GFX9_GENERIC, "gfx9-generic", "compute_amdgcn"},
+ {CudaArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
+ {CudaArch::GFX10_3_GENERIC, "gfx10-3-generic", "compute_amdgcn"},
+ {CudaArch::GFX11_GENERIC, "gfx11-generic", "compute_amdgcn"},
+ {CudaArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
{CudaArch::Generic, "generic", ""},
// clang-format on
};
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index 8ad9e6e5f5891..d4249a617b45c 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -226,6 +226,11 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
case CudaArch::GFX1151:
case CudaArch::GFX1200:
case CudaArch::GFX1201:
+ case CudaArch::GFX9_GENERIC:
+ case CudaArch::GFX10_1_GENERIC:
+ case CudaArch::GFX10_3_GENERIC:
+ case CudaArch::GFX11_GENERIC:
+ case CudaArch::GFX12_GENERIC:
case CudaArch::Generic:
case CudaArch::LAST:
break;
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 28da8662f5f61..c4905f7f8b595 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3535,6 +3535,11 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
case CudaArch::GFX1151:
case CudaArch::GFX1200:
case CudaArch::GFX1201:
+ case CudaArch::GFX9_GENERIC:
+ case CudaArch::GFX10_1_GENERIC:
+ case CudaArch::GFX10_3_GENERIC:
+ case CudaArch::GFX11_GENERIC:
+ case CudaArch::GFX12_GENERIC:
case CudaArch::Generic:
case CudaArch::UNUSED:
case CudaArch::UNKNOWN:
diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c
index 6558fd753d1d1..d610f58b9c4ec 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -29,7 +29,7 @@
// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
// NVPTX: error: unknown target CPU 'not-a-cpu'
-// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, sm_87, sm_89, sm_90, sm_90a, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx941, gfx942, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036, gfx1100, gfx1101, gfx1102, gfx1103, gfx1150, gfx1151, gfx1200, gfx1201{{$}}
+// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, sm_87, sm_89, sm_90, sm_90a, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx941, gfx942, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036, gfx1100, gfx1101, gfx1102, gfx1103, gfx1150, gfx1151, gfx1200, gfx1201, gfx9-generic, gfx10-1-generic, gfx10-3-generic, gfx11-generic, gfx12-generic{{$}}
// RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
// R600: error: unknown target CPU 'not-a-cpu'
More information about the cfe-commits
mailing list