[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>
Mon, 23 Sep 2024 11:23:31 +0000 (13:23 +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 cc5de9a6295ebf46f537813202274fd8bb7f5060..b86003bf2aecb3508ef77a55c50150b1154230f2 100644 (file)
@@ -1353,7 +1353,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 2d4e6d1d058cd7df30708b75460ecb187d3e511e..db79f59af3b1500b67b00c406b05bc53f2a55235 100644 (file)
@@ -424,7 +424,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 4c4549af0b6d646f1a62165716f4687f4ad75cb7..249618c3a9708445bc49bcda96562a6aa148eeec 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