Skip to content

Commit 3c11c7f

Browse files
emasdesmalen-arm
andcommitted
[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 <[email protected]>
1 parent 3fae555 commit 3c11c7f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
13841384
#include "clang/Basic/OpenCLExtensionTypes.def"
13851385
}
13861386

1387-
if (Target.hasAArch64SVETypes()) {
1387+
if (Target.hasAArch64SVETypes() ||
1388+
(AuxTarget && AuxTarget->hasAArch64SVETypes())) {
13881389
#define SVE_TYPE(Name, Id, SingletonId) \
13891390
InitBuiltinType(SingletonId, BuiltinType::Id);
13901391
#include "clang/Basic/AArch64SVEACLETypes.def"

clang/lib/Sema/Sema.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ void Sema::Initialize() {
469469
#include "clang/Basic/OpenCLExtensionTypes.def"
470470
}
471471

472-
if (Context.getTargetInfo().hasAArch64SVETypes()) {
472+
if (Context.getTargetInfo().hasAArch64SVETypes() ||
473+
(Context.getAuxTargetInfo() &&
474+
Context.getAuxTargetInfo()->hasAArch64SVETypes())) {
473475
#define SVE_TYPE(Name, Id, SingletonId) \
474476
addImplicitTypedef(Name, Context.SingletonId);
475477
#include "clang/Basic/AArch64SVEACLETypes.def"

clang/test/PCH/aarch64-sve-types.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-pch -o %t %s
22
// RUN: %clang_cc1 -triple aarch64-linux-gnu -include-pch %t \
33
// RUN: -fsyntax-only -verify %s
4+
// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple aarch64-linux-gnu \
5+
// RUN: -x hip-cpp-output -emit-pch -o %t %s
46

57
// expected-no-diagnostics
68

0 commit comments

Comments
 (0)