From: Emanuele Rocca Date: Fri, 19 Jul 2024 07:25:38 +0000 (+0200) Subject: [PATCH] [Clang] make SVE types known to device targets too (#99446) X-Git-Tag: archive/raspbian/1%17.0.6-21+rpi1^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=46b9e6a5c08ab81ab1128725b98d1506bcddc7c0;p=llvm-toolchain-17.git [PATCH] [Clang] make SVE types known to device targets too (#99446) 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 Gbp-Pq: Name llvm-toolchain-17-sve-types-aux-target.diff --- diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 76000156fe..d2e6d6dbf9 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -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" diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 46ae6fba83..26b4f93702 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -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" diff --git a/clang/test/PCH/aarch64-sve-types.c b/clang/test/PCH/aarch64-sve-types.c index d9be6daa12..059ebdb91d 100644 --- a/clang/test/PCH/aarch64-sve-types.c +++ b/clang/test/PCH/aarch64-sve-types.c @@ -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