Skip to content

Commit 0a65094

Browse files
authored
[SYCL] Add SPIR-V atomic builtins declarations to clang/lib/Sema/SPIRVBuiltins.td (#17471)
Change scope and memory semantics type from Enum from int, similar as in PR #17438. volatile/const is removed from function parameter pointer type, to align with SVP-IR and clang/lib/Sema/SPIRVBuiltins.td.
1 parent e296856 commit 0a65094

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1341
-1418
lines changed

clang/lib/Sema/SPIRVBuiltins.td

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,14 @@ def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoS
398398
// All integer to unsigned
399399
def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
400400
// Signed integer
401+
def SGenType1 : GenericType<"SGenType1", TLSignedInts, Vec1>;
401402
def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>;
402403
// Unsigned integer
404+
def UGenType1 : GenericType<"UGenType1", TLUnsignedInts, Vec1>;
403405
def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
404406
def UInt4 : GenericType<"UInt4", TypeList<[UInt]>, Vec4>;
405407
// Float
408+
def FGenType1 : GenericType<"FGenType1", TLFloat, Vec1>;
406409
def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
407410
// (u)int, (u)long, and all floats
408411
def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats, Vec1>;
@@ -1020,6 +1023,70 @@ foreach name = ["SubgroupBlockWriteINTEL"] in {
10201023
}
10211024
}
10221025

1026+
// 3.56.18. Atomic Instructions
1027+
1028+
foreach AS = [GlobalAS, LocalAS, PrivateAS, GenericAS] in {
1029+
def : SPVBuiltin<
1030+
"AtomicLoad", [AGenType1, PointerType<AGenType1, AS>, Int, Int],
1031+
Attr.Convergent>;
1032+
1033+
def : SPVBuiltin<"AtomicStore",
1034+
[Void, PointerType<AGenType1, AS>, Int, Int, AGenType1],
1035+
Attr.Convergent>;
1036+
1037+
def : SPVBuiltin<"AtomicExchange",
1038+
[AGenType1, PointerType<AGenType1, AS>, Int, Int, AGenType1],
1039+
Attr.Convergent>;
1040+
1041+
foreach name = ["AtomicCompareExchange", "AtomicCompareExchangeWeak"] in {
1042+
def : SPVBuiltin<name,
1043+
[AIGenType1, PointerType<AIGenType1, AS>, Int, Int, Int,
1044+
AIGenType1, AIGenType1],
1045+
Attr.Convergent>;
1046+
}
1047+
1048+
foreach name = ["AtomicIIncrement", "AtomicIDecrement"] in {
1049+
def : SPVBuiltin<name, [AIGenType1, PointerType<AIGenType1, AS>, Int, Int],
1050+
Attr.Convergent>;
1051+
}
1052+
1053+
foreach name = ["AtomicSMin", "AtomicSMax"] in {
1054+
def : SPVBuiltin<name,
1055+
[SGenType1, PointerType<SGenType1, AS>, Int, Int,
1056+
SGenType1],
1057+
Attr.Convergent>;
1058+
}
1059+
1060+
foreach name = ["AtomicUMin", "AtomicUMax"] in {
1061+
def : SPVBuiltin<name,
1062+
[UGenType1, PointerType<UGenType1, AS>, Int, Int,
1063+
UGenType1],
1064+
Attr.Convergent>;
1065+
}
1066+
1067+
foreach name = ["AtomicIAdd", "AtomicISub", "AtomicAnd", "AtomicOr",
1068+
"AtomicXor"] in {
1069+
def : SPVBuiltin<name,
1070+
[AIGenType1, PointerType<AIGenType1, AS>, Int, Int,
1071+
AIGenType1],
1072+
Attr.Convergent>;
1073+
}
1074+
1075+
def : SPVBuiltin<
1076+
"AtomicFlagTestAndSet", [Bool, PointerType<Int, AS>, Int, Int],
1077+
Attr.Convergent>;
1078+
1079+
def : SPVBuiltin<"AtomicFlagClear", [Void, PointerType<Int, AS>, Int, Int],
1080+
Attr.Convergent>;
1081+
1082+
foreach name = ["AtomicFMaxEXT", "AtomicFMinEXT", "AtomicFAddEXT"] in {
1083+
def : SPVBuiltin<name,
1084+
[FGenType1, PointerType<FGenType1, AS>, Int, Int,
1085+
FGenType1],
1086+
Attr.Convergent>;
1087+
}
1088+
}
1089+
10231090
// 3.56.24. Non-Uniform Instructions
10241091

10251092
foreach name = ["GroupNonUniformElect"] in {
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
// RUN: %clang_cc1 -triple spir64 -fdeclare-spirv-builtins -emit-llvm %s -o - | FileCheck %s
2+
3+
#define AS_GLOBAL __attribute__((opencl_global))
4+
#define AS_LOCAL __attribute__((opencl_local))
5+
#define AS_PRIVATE __attribute__((opencl_private))
6+
#define AS_GENERIC __attribute__((opencl_generic))
7+
8+
void test_flag(int AS_GLOBAL *a, int AS_LOCAL *b, int AS_PRIVATE *c,
9+
int AS_GENERIC *d) {
10+
__spirv_AtomicFlagTestAndSet(a, 1, 16);
11+
__spirv_AtomicFlagTestAndSet(b, 2, 8);
12+
__spirv_AtomicFlagTestAndSet(c, 4, 4);
13+
__spirv_AtomicFlagTestAndSet(d, 2, 0);
14+
15+
__spirv_AtomicFlagClear(a, 1, 16);
16+
__spirv_AtomicFlagClear(b, 2, 4);
17+
__spirv_AtomicFlagClear(c, 4, 0);
18+
__spirv_AtomicFlagClear(d, 2, 0);
19+
}
20+
21+
template <class T>
22+
void test_signed(T AS_GLOBAL *a, T AS_LOCAL *b, T AS_PRIVATE *c,
23+
T AS_GENERIC *d) {
24+
__spirv_AtomicLoad(a, 1, 16);
25+
__spirv_AtomicLoad(b, 2, 8);
26+
__spirv_AtomicLoad(c, 4, 4);
27+
__spirv_AtomicLoad(d, 2, 0);
28+
29+
__spirv_AtomicStore(a, 1, 16, (T)0);
30+
__spirv_AtomicStore(b, 2, 8, (T)0);
31+
__spirv_AtomicStore(c, 4, 4, (T)0);
32+
__spirv_AtomicStore(d, 2, 0, (T)0);
33+
34+
__spirv_AtomicExchange(a, 1, 16, (T)0);
35+
__spirv_AtomicExchange(b, 2, 8, (T)0);
36+
__spirv_AtomicExchange(c, 4, 4, (T)0);
37+
__spirv_AtomicExchange(d, 2, 0, (T)0);
38+
39+
__spirv_AtomicCompareExchange(a, 1, 16, 0, (T)1, (T)0);
40+
__spirv_AtomicCompareExchange(b, 2, 8, 0, (T)1, (T)0);
41+
__spirv_AtomicCompareExchange(c, 4, 4, 0, (T)1, (T)0);
42+
__spirv_AtomicCompareExchange(d, 2, 0, 0, (T)1, (T)0);
43+
44+
__spirv_AtomicCompareExchangeWeak(a, 1, 16, 0, (T)1, (T)0);
45+
__spirv_AtomicCompareExchangeWeak(b, 2, 8, 0, (T)1, (T)0);
46+
__spirv_AtomicCompareExchangeWeak(c, 4, 4, 0, (T)1, (T)0);
47+
__spirv_AtomicCompareExchangeWeak(d, 2, 0, 0, (T)1, (T)0);
48+
49+
__spirv_AtomicIIncrement(a, 1, 16);
50+
__spirv_AtomicIIncrement(b, 2, 8);
51+
__spirv_AtomicIIncrement(c, 4, 4);
52+
__spirv_AtomicIIncrement(d, 2, 0);
53+
54+
__spirv_AtomicIDecrement(a, 1, 16);
55+
__spirv_AtomicIDecrement(b, 2, 8);
56+
__spirv_AtomicIDecrement(c, 4, 4);
57+
__spirv_AtomicIDecrement(d, 2, 0);
58+
59+
__spirv_AtomicSMin(a, 1, 16, (T)0);
60+
__spirv_AtomicSMin(b, 2, 8, (T)0);
61+
__spirv_AtomicSMin(c, 4, 4, (T)0);
62+
__spirv_AtomicSMin(d, 2, 0, (T)0);
63+
64+
__spirv_AtomicSMax(a, 1, 16, (T)0);
65+
__spirv_AtomicSMax(b, 2, 8, (T)0);
66+
__spirv_AtomicSMax(c, 4, 4, (T)0);
67+
__spirv_AtomicSMax(d, 2, 0, (T)0);
68+
69+
__spirv_AtomicIAdd(a, 1, 16, (T)0);
70+
__spirv_AtomicIAdd(b, 2, 8, (T)0);
71+
__spirv_AtomicIAdd(c, 4, 4, (T)0);
72+
__spirv_AtomicIAdd(d, 2, 0, (T)0);
73+
74+
__spirv_AtomicISub(a, 1, 16, (T)0);
75+
__spirv_AtomicISub(b, 2, 8, (T)0);
76+
__spirv_AtomicISub(c, 4, 4, (T)0);
77+
__spirv_AtomicISub(d, 2, 0, (T)0);
78+
79+
__spirv_AtomicAnd(a, 1, 16, (T)0);
80+
__spirv_AtomicAnd(b, 2, 8, (T)0);
81+
__spirv_AtomicAnd(c, 4, 4, (T)0);
82+
__spirv_AtomicAnd(d, 2, 0, (T)0);
83+
84+
__spirv_AtomicOr(a, 1, 16, (T)0);
85+
__spirv_AtomicOr(b, 2, 8, (T)0);
86+
__spirv_AtomicOr(c, 4, 4, (T)0);
87+
__spirv_AtomicOr(d, 2, 0, (T)0);
88+
89+
__spirv_AtomicXor(a, 1, 16, (T)0);
90+
__spirv_AtomicXor(b, 2, 8, (T)0);
91+
__spirv_AtomicXor(c, 4, 4, (T)0);
92+
__spirv_AtomicXor(d, 2, 0, (T)0);
93+
}
94+
95+
template <class T>
96+
void test_unsigned(T AS_GLOBAL *a, T AS_LOCAL *b, T AS_PRIVATE *c,
97+
T AS_GENERIC *d) {
98+
99+
__spirv_AtomicUMin(a, 1, 16, (T)0);
100+
__spirv_AtomicUMin(b, 2, 8, (T)0);
101+
__spirv_AtomicUMin(c, 4, 4, (T)0);
102+
__spirv_AtomicUMin(d, 2, 0, (T)0);
103+
104+
__spirv_AtomicUMax(a, 1, 16, (T)0);
105+
__spirv_AtomicUMax(b, 2, 8, (T)0);
106+
__spirv_AtomicUMax(c, 4, 4, (T)0);
107+
__spirv_AtomicUMax(d, 2, 0, (T)0);
108+
}
109+
110+
template <class T>
111+
void test_float(T AS_GLOBAL *a, T AS_LOCAL *b, T AS_PRIVATE *c,
112+
T AS_GENERIC *d) {
113+
__spirv_AtomicFMaxEXT(a, 1, 16, (T)0);
114+
__spirv_AtomicFMaxEXT(b, 2, 8, (T)0);
115+
__spirv_AtomicFMaxEXT(c, 4, 4, (T)0);
116+
__spirv_AtomicFMaxEXT(d, 2, 0, (T)0);
117+
118+
__spirv_AtomicFMinEXT(a, 1, 16, (T)0);
119+
__spirv_AtomicFMinEXT(b, 2, 8, (T)0);
120+
__spirv_AtomicFMinEXT(c, 4, 4, (T)0);
121+
__spirv_AtomicFMinEXT(d, 2, 0, (T)0);
122+
123+
__spirv_AtomicFAddEXT(a, 1, 16, (T)0);
124+
__spirv_AtomicFAddEXT(b, 2, 8, (T)0);
125+
__spirv_AtomicFAddEXT(c, 4, 4, (T)0);
126+
__spirv_AtomicFAddEXT(d, 2, 0, (T)0);
127+
}
128+
129+
void foo() {
130+
int AS_GLOBAL *a;
131+
int AS_LOCAL *b;
132+
int AS_PRIVATE *c;
133+
int AS_GENERIC *d;
134+
test_flag(a, b, c, d);
135+
136+
test_signed<int>(a, b, c, d);
137+
138+
unsigned int AS_GLOBAL *ua;
139+
unsigned int AS_LOCAL *ub;
140+
unsigned int AS_PRIVATE *uc;
141+
unsigned int AS_GENERIC *ud;
142+
test_unsigned<unsigned int>(ua, ub, uc, ud);
143+
144+
float AS_GLOBAL *fa;
145+
float AS_LOCAL *fb;
146+
float AS_PRIVATE *fc;
147+
float AS_GENERIC *fd;
148+
test_float<float>(fa, fb, fc, fd);
149+
}
150+
151+
// CHECK: call spir_func noundef zeroext i1 @_Z28__spirv_AtomicFlagTestAndSetPU3AS1iii(
152+
// CHECK: call spir_func noundef zeroext i1 @_Z28__spirv_AtomicFlagTestAndSetPU3AS3iii(
153+
// CHECK: call spir_func noundef zeroext i1 @_Z28__spirv_AtomicFlagTestAndSetPiii(
154+
// CHECK: call spir_func noundef zeroext i1 @_Z28__spirv_AtomicFlagTestAndSetPU3AS4iii(
155+
// CHECK: call spir_func void @_Z23__spirv_AtomicFlagClearPU3AS1iii(
156+
// CHECK: call spir_func void @_Z23__spirv_AtomicFlagClearPU3AS3iii(
157+
// CHECK: call spir_func void @_Z23__spirv_AtomicFlagClearPiii(
158+
// CHECK: call spir_func void @_Z23__spirv_AtomicFlagClearPU3AS4iii(
159+
160+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicLoadPU3AS1iii(
161+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicLoadPU3AS3iii(
162+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicLoadPiii(
163+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicLoadPU3AS4iii(
164+
// CHECK: call spir_func void @_Z19__spirv_AtomicStorePU3AS1iiii(
165+
// CHECK: call spir_func void @_Z19__spirv_AtomicStorePU3AS3iiii(
166+
// CHECK: call spir_func void @_Z19__spirv_AtomicStorePiiii(
167+
// CHECK: call spir_func void @_Z19__spirv_AtomicStorePU3AS4iiii(
168+
// CHECK: call spir_func noundef i32 @_Z22__spirv_AtomicExchangePU3AS1iiii(
169+
// CHECK: call spir_func noundef i32 @_Z22__spirv_AtomicExchangePU3AS3iiii(
170+
// CHECK: call spir_func noundef i32 @_Z22__spirv_AtomicExchangePiiii(
171+
// CHECK: call spir_func noundef i32 @_Z22__spirv_AtomicExchangePU3AS4iiii(
172+
// CHECK: call spir_func noundef i32 @_Z29__spirv_AtomicCompareExchangePU3AS1iiiiii(
173+
// CHECK: call spir_func noundef i32 @_Z29__spirv_AtomicCompareExchangePU3AS3iiiiii(
174+
// CHECK: call spir_func noundef i32 @_Z29__spirv_AtomicCompareExchangePiiiiii(
175+
// CHECK: call spir_func noundef i32 @_Z29__spirv_AtomicCompareExchangePU3AS4iiiiii(
176+
// CHECK: call spir_func noundef i32 @_Z33__spirv_AtomicCompareExchangeWeakPU3AS1iiiiii(
177+
// CHECK: call spir_func noundef i32 @_Z33__spirv_AtomicCompareExchangeWeakPU3AS3iiiiii(
178+
// CHECK: call spir_func noundef i32 @_Z33__spirv_AtomicCompareExchangeWeakPiiiiii(
179+
// CHECK: call spir_func noundef i32 @_Z33__spirv_AtomicCompareExchangeWeakPU3AS4iiiiii(
180+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIIncrementPU3AS1iii(
181+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIIncrementPU3AS3iii(
182+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIIncrementPiii(
183+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIIncrementPU3AS4iii(
184+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIDecrementPU3AS1iii(
185+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIDecrementPU3AS3iii(
186+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIDecrementPiii(
187+
// CHECK: call spir_func noundef i32 @_Z24__spirv_AtomicIDecrementPU3AS4iii(
188+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMinPU3AS1iiii(
189+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMinPU3AS3iiii(
190+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMinPiiii(
191+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMinPU3AS4iiii(
192+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMaxPU3AS1iiii(
193+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMaxPU3AS3iiii(
194+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMaxPiiii(
195+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicSMaxPU3AS4iiii(
196+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicIAddPU3AS1iiii(
197+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicIAddPU3AS3iiii(
198+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicIAddPiiii(
199+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicIAddPU3AS4iiii(
200+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicISubPU3AS1iiii(
201+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicISubPU3AS3iiii(
202+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicISubPiiii(
203+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicISubPU3AS4iiii(
204+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicAndPU3AS1iiii(
205+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicAndPU3AS3iiii(
206+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicAndPiiii(
207+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicAndPU3AS4iiii(
208+
// CHECK: call spir_func noundef i32 @_Z16__spirv_AtomicOrPU3AS1iiii(
209+
// CHECK: call spir_func noundef i32 @_Z16__spirv_AtomicOrPU3AS3iiii(
210+
// CHECK: call spir_func noundef i32 @_Z16__spirv_AtomicOrPiiii(
211+
// CHECK: call spir_func noundef i32 @_Z16__spirv_AtomicOrPU3AS4iiii(
212+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicXorPU3AS1iiii(
213+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicXorPU3AS3iiii(
214+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicXorPiiii(
215+
// CHECK: call spir_func noundef i32 @_Z17__spirv_AtomicXorPU3AS4iiii(
216+
217+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMinPU3AS1jiij(
218+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMinPU3AS3jiij(
219+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMinPjiij(
220+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMinPU3AS4jiij(
221+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMaxPU3AS1jiij(
222+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMaxPU3AS3jiij(
223+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMaxPjiij(
224+
// CHECK: call spir_func noundef i32 @_Z18__spirv_AtomicUMaxPU3AS4jiij(
225+
226+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMaxEXTPU3AS1fiif(
227+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMaxEXTPU3AS3fiif(
228+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMaxEXTPfiif(
229+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMaxEXTPU3AS4fiif(
230+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMinEXTPU3AS1fiif(
231+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMinEXTPU3AS3fiif(
232+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMinEXTPfiif(
233+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFMinEXTPU3AS4fiif(
234+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFAddEXTPU3AS1fiif(
235+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFAddEXTPU3AS3fiif(
236+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFAddEXTPfiif(
237+
// CHECK: call spir_func noundef float @_Z21__spirv_AtomicFAddEXTPU3AS4fiif(
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#include <clc/clc.h>
22
#include <libspirv/spirv.h>
33

4-
#define IMPL(TYPE, TYPE_MANGLED, AS, AS_MANGLED) \
5-
_CLC_OVERLOAD _CLC_DEF TYPE atomic_add(volatile AS TYPE *p, TYPE val) { \
6-
/* TODO: Stop manually mangling this name. Need C++ namespaces to get the \
7-
* exact mangling. */ \
8-
return _Z18__spirv_AtomicIAddPU3##AS_MANGLED##TYPE_MANGLED##N5__spv5Scope4FlagENS1_19MemorySemanticsMask4FlagE##TYPE_MANGLED( \
9-
p, Device, SequentiallyConsistent, val); \
4+
#define IMPL(TYPE, AS) \
5+
_CLC_OVERLOAD _CLC_DEF TYPE atomic_add(volatile AS TYPE *p, TYPE val) { \
6+
return __spirv_AtomicIAdd((AS TYPE *)p, Device, SequentiallyConsistent, \
7+
val); \
108
}
119

12-
IMPL(int, i, global, AS1)
13-
IMPL(unsigned int, j, global, AS1)
14-
IMPL(int, i, local, AS3)
15-
IMPL(unsigned int, j, local, AS3)
10+
IMPL(int, global)
11+
IMPL(unsigned int, global)
12+
IMPL(int, local)
13+
IMPL(unsigned int, local)
1614
#undef IMPL
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#include <clc/clc.h>
22
#include <libspirv/spirv.h>
33

4-
#define IMPL(TYPE, TYPE_MANGLED, AS, AS_MANGLED) \
5-
_CLC_OVERLOAD _CLC_DEF TYPE atomic_and(volatile AS TYPE *p, TYPE val) { \
6-
/* TODO: Stop manually mangling this name. Need C++ namespaces to get the \
7-
* exact mangling. */ \
8-
return _Z17__spirv_AtomicAndPU3##AS_MANGLED##TYPE_MANGLED##N5__spv5Scope4FlagENS1_19MemorySemanticsMask4FlagE##TYPE_MANGLED( \
9-
p, Device, SequentiallyConsistent, val); \
4+
#define IMPL(TYPE, AS) \
5+
_CLC_OVERLOAD _CLC_DEF TYPE atomic_and(volatile AS TYPE *p, TYPE val) { \
6+
return __spirv_AtomicAnd((AS TYPE *)p, Device, SequentiallyConsistent, \
7+
val); \
108
}
119

12-
IMPL(int, i, global, AS1)
13-
IMPL(unsigned int, j, global, AS1)
14-
IMPL(int, i, local, AS3)
15-
IMPL(unsigned int, j, local, AS3)
10+
IMPL(int, global)
11+
IMPL(unsigned int, global)
12+
IMPL(int, local)
13+
IMPL(unsigned int, local)
1614
#undef IMPL

0 commit comments

Comments
 (0)