Skip to content

Commit a827fb0

Browse files
aelovikov-intelsvenvh
authored andcommitted
Support SYCL 2020 namespace (::sycl) for SYCL Half/BFloat16 types
In SYCL 2020 the "::cl::sycl" has been changed to "::sycl". Update SYCL half type support to account for that.
1 parent c5b29f2 commit a827fb0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ bool isSYCLHalfType(llvm::Type *Ty) {
288288
return false;
289289
StringRef Name = ST->getName();
290290
Name.consume_front("class.");
291-
if ((Name.startswith("cl::sycl::") ||
291+
if ((Name.startswith("sycl::") || Name.startswith("cl::sycl::") ||
292292
Name.startswith("__sycl_internal::")) &&
293293
Name.endswith("::half")) {
294294
return true;
@@ -303,7 +303,7 @@ bool isSYCLBfloat16Type(llvm::Type *Ty) {
303303
return false;
304304
StringRef Name = ST->getName();
305305
Name.consume_front("class.");
306-
if ((Name.startswith("cl::sycl::") ||
306+
if ((Name.startswith("sycl::") || Name.startswith("cl::sycl::") ||
307307
Name.startswith("__sycl_internal::")) &&
308308
Name.endswith("::bfloat16")) {
309309
return true;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -spirv-ext=+SPV_INTEL_joint_matrix -o %t.spv
3+
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s
4+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
5+
target triple = "spir64-unknown-unknown"
6+
7+
; Ensure that ::sycl::_V1.*{half|bfloat16} are parsed as SYCL types.
8+
9+
; CHECK-DAG: TypeFloat [[#HalfTy:]] 16
10+
; CHECK-DAG: TypeInt [[#BFloat16Ty:]] 16
11+
12+
%"class.sycl::_V1::anything::half" = type { half }
13+
%"class.sycl::_V1::anything::bfloat16" = type { i16 }
14+
15+
%"struct.__spv::__spirv_JointMatrixINTEL.half" = type { [2 x [2 x [1 x [4 x %"class.sycl::_V1::anything::half"]]]]* }
16+
%"struct.__spv::__spirv_JointMatrixINTEL.bfloat16" = type { [2 x [2 x [1 x [4 x %"class.sycl::_V1::anything::bfloat16"]]]]* }
17+
18+
define spir_func void @foo(%"struct.__spv::__spirv_JointMatrixINTEL.half" *) {
19+
ret void
20+
}
21+
22+
define spir_func void @bar(%"struct.__spv::__spirv_JointMatrixINTEL.bfloat16" *) {
23+
ret void
24+
}

0 commit comments

Comments
 (0)