[clang] [llvm] [TargetParser] Add a list of Intel GPUs, and use it in offload-arch (PR #222072)

Nikita Kornev via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 06:52:46 PDT 2026


================
@@ -1,6 +1,7 @@
 set(OffloadArchTestSources
   OffloadArchTest.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/../../tools/offload-arch/AMDGPUArchByKFD.cpp
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../tools/offload-arch/LevelZeroArch.cpp
----------------
KornevNikita wrote:

...although I'm confused, it seems like the logic for llvm is different from clang, so I'd like to clarify (starting from the end):

> Also, in llvm/, unittests for tools are in unittests/tools/toolname. We should probably move this to clang/unittests/tools/offload-arch for consistency.

It seems like in clang all tool unittests are stored outside the `clang/unittests/tools/` directory (there is no such), e.g. IIUC `clang/unittests/Format` for `clang-format`. Should we anyway move `offload-arch` to `clang/unittests/tools/offload-arch`?

> Instead of randomly including tool source files in the unittest target, please do the standard thing of adding a tools/foo/lib target with the files you'd like to share and link the lib into the test.

It seems like there is no standard and different tools use different approaches. For example llvm-mca does the same: https://github.com/llvm/llvm-project/blob/main/llvm/unittests/tools/llvm-mca/CMakeLists.txt#L23
Anyways, is this something like what you suggest?
```
--- a/clang/tools/offload-arch/CMakeLists.txt
+++ b/clang/tools/offload-arch/CMakeLists.txt

-add_clang_tool(offload-arch OffloadArch.cpp NVPTXArch.cpp AMDGPUArchByKFD.cpp
-               AMDGPUArchByHIP.cpp LevelZeroArch.cpp)
+# Shared with the unit tests.
+add_llvm_library(clangOffloadArch
+  STATIC
+  BUILDTREE_ONLY
+  AMDGPUArchByHIP.cpp
+  AMDGPUArchByKFD.cpp
+  LevelZeroArch.cpp
+  PARTIAL_SOURCES_INTENDED
+  )
+
+add_clang_tool(offload-arch
+  PARTIAL_SOURCES_INTENDED
+  OffloadArch.cpp
+  NVPTXArch.cpp
+  )

--- a/clang/unittests/offload-arch/CMakeLists.txt
+++ b/clang/unittests/offload-arch/CMakeLists.txt
-set(OffloadArchTestSources
-  OffloadArchTest.cpp
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../tools/offload-arch/AMDGPUArchByKFD.cpp
-  ${CMAKE_CURRENT_SOURCE_DIR}/../../tools/offload-arch/LevelZeroArch.cpp
-  )
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
-  list(APPEND OffloadArchTestSources
-    ${CMAKE_CURRENT_SOURCE_DIR}/../../tools/offload-arch/AMDGPUArchByHIP.cpp)
-endif()
-
 add_distinct_clang_unittest(OffloadArchTests
-  ${OffloadArchTestSources}
-  CLANG_LIBS
-    clangBasic
+  OffloadArchTest.cpp
   LINK_LIBS
+    clangOffloadArch
     LLVMTestingSupport
   LLVM_COMPONENTS
     Support
-    TargetParser
```


https://github.com/llvm/llvm-project/pull/222072


More information about the llvm-commits mailing list