@@ -195,7 +195,7 @@ and the user says
195
195
196
196
#### Compiler
197
197
198
- ##### The SpecConstant pass changes
198
+ ##### The SpecConstants pass
199
199
200
200
The SpecConstants pass in the post-link will have the following IR as input
201
201
(` sret ` conversion is omitted for clarity):
@@ -248,8 +248,8 @@ Besides, the SPIR-V specification does not allow `SpecID` decoration for
248
248
composite spec constants, because its defined by its members instead.
249
249
250
250
` __spirv_SpecConstantComposite ` is a new SPIR-V intrinsic, which represents
251
- composite specialization constant. Its arguments are LLVM IR valures
252
- corresponding to elements of composite type of the constant.
251
+ composite specialization constant. Its arguments are LLVM IR values
252
+ corresponding to elements of the composite constant.
253
253
254
254
##### LLVM -> SPIR-V translation
255
255
@@ -263,7 +263,7 @@ Given the `__spirv_SpecConstantComposite` intrinsic calls produced by the
263
263
define dso_local spir_func void @get(%struct.A* sret %ret.ptr) local_unnamed_addr #0 {
264
264
; args are "ID" and "default value":
265
265
%1 = tail call spir_func i32 @_Z20__spirv_SpecConstantii(i32 42, i32 0)
266
- %2 = tail call spir_func i32 @_Z20__spirv_SpecConstantif(i32 43, float 0.000000e+00)
266
+ %2 = tail call spir_func float @_Z20__spirv_SpecConstantif(i32 43, float 0.000000e+00)
267
267
%ret = tail call spir_func %struct.A @_Z29__spirv_SpecConstantCompositeif(%1, %2)
268
268
store %struct.A %ret, %struct.A* %ret.ptr
269
269
ret void
@@ -274,11 +274,11 @@ the translator will generate `OpSpecConstant` and `OpSpecConstantComposite`
274
274
SPIR-V instructions with proper ` SpecId ` decorations:
275
275
276
276
```
277
- OpDecorate %i32 SpecId 42 ; ID
278
- OpDecorate %float SpecId 43 ; ID
279
- %i32 = OpSpecConstant %int.type 0 ; Default value
280
- %float = OpSpecConstant %float.type 0.0 ; Default value
281
- %struct = OpSpecConstantComposite %struct.type %i32 %float ; No ID, defined by its elements
277
+ OpDecorate %i32 SpecId 42 ; ID of the 1st member
278
+ OpDecorate %float SpecId 43 ; ID of the 2nd member
279
+ %i32 = OpSpecConstant %int.type 0 ; 1st member with default value
280
+ %float = OpSpecConstant %float.type 0.0 ; 2nd member with default value
281
+ %struct = OpSpecConstantComposite %struct.type %i32 %float ; Composite doens't need IDs or default value
282
282
%1 = OpTypeFunction %struct.type
283
283
284
284
%get = OpFunction %struct.type None %1
@@ -301,6 +301,15 @@ referenced by its symbolic ID. For example:
301
301
MyConst_mangled [10,0,4],[11,4,4],[12,8,4],[13,12,4],[14,16,4]
302
302
```
303
303
304
+ This tuple is needed, because at SYCL runtime level, composite constants are set
305
+ by user as a single entity and we have to break it down to its members and set a
306
+ value for each leaf as for a separate specialization constant. It contains the
307
+ following data:
308
+ - ID of composite constants leaf, i.e. ID of scalar spec constant
309
+ - Offset from the beginning of composite, which points to the location of a
310
+ scalar value within the composite
311
+ - Size of the scalar value
312
+
304
313
#### SYCL runtime
305
314
306
315
First, when the runtime loads a binary it gets access to specialization
0 commit comments