[PATCH] [Clang] make SVE types known to device targets too (#99446)
authorEmanuele Rocca <emanuele.rocca@arm.com>
Fri, 19 Jul 2024 07:25:38 +0000 (09:25 +0200)
committerSylvestre Ledru <sylvestre@debian.org>
Fri, 13 Jun 2025 07:05:47 +0000 (09:05 +0200)
For the purpose of preprocessing and declarations in header files,
ensure clang accepts SVE types for both device and host targets.

Co-authored-by: Sander De Smalen <sander.desmalen@arm.com>
Gbp-Pq: Name llvm-toolchain-17-sve-types-aux-target.diff

clang/lib/AST/ASTContext.cpp
clang/lib/Sema/Sema.cpp
clang/test/PCH/aarch64-sve-types.c

index 76000156fece7c82626e3b7f8a37b046ea965308..d2e6d6dbf9f66b7b9c79e790a47e833aa61349ac 100644 (file)
@@ -1396,7 +1396,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
 #include "clang/Basic/OpenCLExtensionTypes.def"
   }
 
-  if (Target.hasAArch64SVETypes()) {
+  if (Target.hasAArch64SVETypes() ||
+      (AuxTarget && AuxTarget->hasAArch64SVETypes())) {
 #define SVE_TYPE(Name, Id, SingletonId) \
     InitBuiltinType(SingletonId, BuiltinType::Id);
 #include "clang/Basic/AArch64SVEACLETypes.def"
index 46ae6fba8344bb7519a82c20542e9c44139ab078..26b4f937023cb6389fa7a5183e6a2a35f9f4b07b 100644 (file)
@@ -423,7 +423,9 @@ void Sema::Initialize() {
 #include "clang/Basic/OpenCLExtensionTypes.def"
   }
 
-  if (Context.getTargetInfo().hasAArch64SVETypes()) {
+  if (Context.getTargetInfo().hasAArch64SVETypes() ||
+      (Context.getAuxTargetInfo() &&
+       Context.getAuxTargetInfo()->hasAArch64SVETypes())) {
 #define SVE_TYPE(Name, Id, SingletonId) \
     addImplicitTypedef(Name, Context.SingletonId);
 #include "clang/Basic/AArch64SVEACLETypes.def"
index d9be6daa127e74633a2b7a7ef4d08a4efb6bf60b..059ebdb91db30c561303f6eb3daa07145eedf980 100644 (file)
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-pch -o %t %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -include-pch %t \
 // RUN:   -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple aarch64-linux-gnu \
+// RUN:   -x hip-cpp-output -emit-pch -o %t %s
 
 // expected-no-diagnostics