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

Emanuele Rocca via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 01:16:52 PDT 2024


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 <emanuele.rocca at arm.com>
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 <sander.desmalen at arm.com>
---
 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"



More information about the cfe-commits mailing list