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

2024-07-18 Thread Emanuele Rocca via cfe-commits

https://github.com/ema created https://github.com/llvm/llvm-project/pull/99446

For the purpose of preprocessing and declarations in header files, ensure clang 
accepts SVE types for both device and host targets.

>From 2f7b2bbd9d2db29534dc354cfa9ada5c29c26b3f Mon Sep 17 00:00:00 2001
From: Emanuele Rocca 
Date: Wed, 17 Jul 2024 16:03:27 +0200
Subject: [PATCH] [Clang] make SVE types known to device targets too

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 
---
 clang/lib/AST/ASTContext.cpp | 3 ++-
 clang/lib/Sema/Sema.cpp  | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index ccbb4baad68af..c87b8deca9da6 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 d6228718d53ae..733090a68c990 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"

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-07-18 Thread Emanuele Rocca via cfe-commits

https://github.com/ema updated https://github.com/llvm/llvm-project/pull/99446

>From 3c11c7fb055c114084577fb51fb87f928a0cc31c Mon Sep 17 00:00:00 2001
From: Emanuele Rocca 
Date: Wed, 17 Jul 2024 16:03:27 +0200
Subject: [PATCH] [Clang] make SVE types known to device targets too

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 
---
 clang/lib/AST/ASTContext.cpp   | 3 ++-
 clang/lib/Sema/Sema.cpp| 4 +++-
 clang/test/PCH/aarch64-sve-types.c | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index ccbb4baad68af..c87b8deca9da6 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 d6228718d53ae..733090a68c990 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
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits