Skip to content

Commit 1f40bb4

Browse files
committed
Add clang patch to enable BFloat16 for SPIR/SPIR-V
1 parent c694388 commit 1f40bb4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From e3aa87e0aaad941c35709c8dc7a479b2a5251cfe Mon Sep 17 00:00:00 2001
2+
From: Wenju He <[email protected]>
3+
Date: Fri, 21 Nov 2025 05:43:57 +0100
4+
Subject: [PATCH] [Clang] Enable BFloat16 for SPIR/SPIR-V
5+
6+
---
7+
clang/lib/Basic/Targets/SPIR.h | 6 +++---
8+
1 file changed, 3 insertions(+), 3 deletions(-)
9+
10+
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
11+
index c0849b69dcdb..78a1c0e78107 100644
12+
--- a/clang/lib/Basic/Targets/SPIR.h
13+
+++ b/clang/lib/Basic/Targets/SPIR.h
14+
@@ -103,6 +103,9 @@ protected:
15+
UseAddrSpaceMapMangling = true;
16+
HasLegalHalfType = true;
17+
HasFloat16 = true;
18+
+ HasBFloat16 = true;
19+
+ BFloat16Width = BFloat16Align = 16;
20+
+ BFloat16Format = &llvm::APFloat::BFloat();
21+
// Define available target features
22+
// These must be defined in sorted order!
23+
NoAsmVariants = true;
24+
@@ -389,9 +392,6 @@ public:
25+
resetDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
26+
"v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
27+
28+
- BFloat16Width = BFloat16Align = 16;
29+
- BFloat16Format = &llvm::APFloat::BFloat();
30+
-
31+
HasLegalHalfType = true;
32+
HasFloat16 = true;
33+
HalfArgsAndReturns = true;
34+
--
35+
2.39.1
36+

0 commit comments

Comments
 (0)