[clang] c248d05 - [Clang] make SVE types known to device targets too (#99446)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 00:25:42 PDT 2024


Author: Emanuele Rocca
Date: 2024-07-19T08:25:38+01:00
New Revision: c248d05c6807baba34ff4fb254176e300922ea72

URL: https://github.com/llvm/llvm-project/commit/c248d05c6807baba34ff4fb254176e300922ea72
DIFF: https://github.com/llvm/llvm-project/commit/c248d05c6807baba34ff4fb254176e300922ea72.diff

LOG: [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 <sander.desmalen at arm.com>

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a8e599f7ebe04..98ce88eb6a9fd 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1384,7 +1384,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 46417964f0896..2e989f0ba6fe4 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -469,7 +469,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 4c4549af0b6d6..249618c3a9708 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
 


        


More information about the cfe-commits mailing list