[libclc] [libclc] Parse triples to be more permissive (PR #193976)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 24 07:01:45 PDT 2026


================
@@ -6,6 +6,66 @@ macro(libclc_configure_source_list variable path)
   set(${variable} ${${variable}} PARENT_SCOPE)
 endmacro()
 
+# Validates the triple and extracts the OS and architecture components.
+macro(libclc_configure_triple triple arch os)
+  # Validate the target triple by its components.
+  string(REPLACE "-" ";" TRIPLE ${triple})
+  list(GET TRIPLE 0 ARCH)
+  list(LENGTH TRIPLE triple_len)
+
+  set(VENDOR "")
+  set(OS "")
+  set(ENV "")
+  if(triple_len GREATER 1)
+    list(GET TRIPLE 1 VENDOR)
+  endif()
+  if(triple_len GREATER 2)
+    list(GET TRIPLE 2 OS)
+  endif()
+  if(triple_len GREATER 3)
+    list(GET TRIPLE 3 ENV)
+  endif()
+
+  set(libclc_known_arches nvptx64 amdgcn spirv spirv64 clspv clspv64)
+  if(NOT ARCH IN_LIST libclc_known_arches)
+    message(FATAL_ERROR "libclc target '${LIBCLC_TARGET}' has unknown "
+      "architecture '${ARCH}'\n"
+      "Valid architectures are: ${libclc_known_arches}\n")
+  endif()
+
+  if(ARCH STREQUAL "amdgcn")
----------------
arsenm wrote:

This will soon be replaced by "amdgpu<SubArchSuffix>", and I want multiple sub arches covered in the same build. 

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


More information about the cfe-commits mailing list