@@ -18,6 +18,8 @@ https://github.com/intel/llvm/issues
18
18
- Pawel Jurek, Intel
19
19
- Thomas Raoux, Intel
20
20
- Nikita Kornev, Intel
21
+ - Dmitry Sidorov, Intel
22
+ - Alex Bezzubikov, Intel
21
23
22
24
== Notice
23
25
@@ -38,7 +40,7 @@ If you are interested in using this feature in your software product, please let
38
40
[width="40%",cols="25,25"]
39
41
|==================================
40
42
| Last Modified Date | {docdate}
41
- | Revision | H
43
+ | Revision | I
42
44
|==================================
43
45
44
46
== Dependencies
@@ -89,7 +91,7 @@ IndirectReferencesINTEL
89
91
Instructions added under the *FunctionPointersINTEL* capability:
90
92
91
93
----
92
- OpFunctionPointerINTEL
94
+ OpConstantFunctionPointerINTEL
93
95
OpFunctionPointerCallINTEL
94
96
----
95
97
@@ -122,13 +124,13 @@ CodeSectionINTEL
122
124
[cols="70%,30%"]
123
125
[grid="rows"]
124
126
|====
125
- |OpFunctionPointerINTEL | 5600
126
- |OpFunctionPointerCallINTEL | 5601
127
- |ReferencedIndirectlyINTEL | 5602
128
- |FunctionPointersINTEL | 5603
129
- |IndirectReferencesINTEL | 5604
130
- |CodeSectionINTEL | 5605
131
- |ArgumentAttributeINTEL | 6409
127
+ |OpConstantFunctionPointerINTEL | 5600
128
+ |OpFunctionPointerCallINTEL | 5601
129
+ |ReferencedIndirectlyINTEL | 5602
130
+ |FunctionPointersINTEL | 5603
131
+ |IndirectReferencesINTEL | 5604
132
+ |CodeSectionINTEL | 5605
133
+ |ArgumentAttributeINTEL | 6409
132
134
|====
133
135
134
136
== Modifications to the SPIR-V Specification, Version 1.4
@@ -143,23 +145,24 @@ Modify Section 2.2.2, Types, add the following at the end of the section: ::
143
145
[[FunctionPointer]]'Function Pointer': A pointer that results from the following
144
146
instruction:
145
147
146
- - *OpFunctionPointerINTEL *
148
+ - *OpConstantFunctionPointerINTEL *
147
149
148
150
Additionally, any *OpSelect*, *OpPhi*, *OpFunctionCall*, *OpPtrAccessChain*,
149
151
*OpLoad*, *OpAccessChain*, *OpInBoundAccessChain*, or *OpCopyObject* thas takes
150
152
a function pointer as an operand also produces a function pointer. An
151
153
*OpFunctionParameter* of pointer type is function pointer if any
152
154
*OpFunctionCall* to the function statically passes a function pointer as the
153
- value of the parameter. *OpConstantNull* returns function pointer if 'Result
154
- type' is function pointer.
155
+ value of the parameter. *OpCompositeExtract* and *OpConstantNull* return
156
+ function pointer if 'Result type' is function pointer.
155
157
156
158
Modify Section 2.9, Function Calling, add the following after the first sentence: ::
157
159
158
160
Functions can be called indirectly using function pointers: to do so, use
159
161
*OpFunctionPointerCallINTEL* with an operand that is the _<id>_ obtained using
160
- *OpFunctionPointerINTEL* of the *OpFunction* to call, and the _<id>s_ of the
161
- arguments to pass. All arguments are passed by value into the called function.
162
- This includes pointers, through which a callee object could be modified.
162
+ *OpConstantFunctionPointerINTEL* of the *OpFunction* to call, and the _<id>s_ of
163
+ the arguments to pass. All arguments are passed by value into the called
164
+ function. This includes pointers, through which a callee object could be
165
+ modified.
163
166
164
167
=== Storage Classes
165
168
@@ -226,16 +229,17 @@ Modify Section 3.32.6, Type-Declaration Instructions, change the third sentence
226
229
pointer type. *OpFunction* and *OpTypePointer* are only valid uses of
227
230
*OpTypeFunction*.
228
231
229
- Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
232
+ Modify Section 3.32.7, Constant-Creation Instructions, adding to the end of the list of instructions: ::
230
233
231
234
[cols="2*1,3*3",width="100%"]
232
235
|=====
233
- 4+|[[OpFunctionPointerINTEL ]]*OpFunctionPointerINTEL * +
236
+ 4+|[[OpConstantFunctionPointerINTEL ]]*OpConstantFunctionPointerINTEL * +
234
237
+
235
- Obtains address of the specified function. +
238
+ Obtains constant address of the specified function. +
236
239
+
237
- Result value can be used immediately in *OpFunctionPointerCallINTEL* or stored
238
- somewhere for further usage in *OpFunctionPointerCallINTEL*. +
240
+ Result value can be used immediately in *OpFunctionPointerCallINTEL*, inserted
241
+ into a composite constant or stored somewhere for further usage in
242
+ *OpFunctionPointerCallINTEL*. +
239
243
+
240
244
_Result Type_ must be an *OpTypePointer*. Its _Type_ operand must be the same
241
245
*OpTypeFunction* which was used as _Function Type_ operand of the _Function_
@@ -245,6 +249,8 @@ operand. Its _Storage Class_ operand must be *CodeSectionINTEL*
245
249
| 4 | 5600 | '<id>' 'Result Type' | '<id> Result ' | '<id>' 'Function'
246
250
|=====
247
251
252
+ Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
253
+
248
254
[cols="2*1,4*3",width="100%"]
249
255
|=====
250
256
5+|[[OpFunctionPointerCallINTEL]]*OpFunctionPointerCallINTEL* +
@@ -271,14 +277,17 @@ argument types must match the formal parameter types.
271
277
== Validation Rules
272
278
273
279
It is legal to use <<FunctionPointer, Function Pointer>> as 'Result Type' of
274
- *OpFunctionArgument*, *OpUndef* and *OpConstantNULL*.
280
+ *OpFunctionArgument*, *OpCompositeExtract*, * OpUndef* and *OpConstantNULL*.
275
281
276
282
It is legal to use <<FunctionPointer, Function Pointer>> as 'Return Type' of
277
283
*OpTypeFunction*.
278
284
279
285
It is legal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
280
286
argument of *OpConvertPtrToU* and as 'Result Type' of *OpConvertUToPtr*.
281
287
288
+ It is legal to use <<FunctionPointer, Function Pointer>> as 'Object'
289
+ argument of *OpCompositeInsert*.
290
+
282
291
It is illegal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
283
292
argument of *OpPtrCastToGeneric*.
284
293
@@ -327,6 +336,27 @@ be used for ones out of the box and we don't have much use-cases for it.
327
336
*UNRESOLVED*
328
337
--
329
338
339
+ . Should we prohibit heterogenous composites with function pointers? Maybe we should
340
+ distinct <<FunctionPointer, Function Pointer>> and Constant Function Pointer?
341
+ +
342
+ --
343
+ *RESOLVED*
344
+
345
+ In general, we should not since this extension is aimed to support the whole C++ function
346
+ pointers functionality in SPIR-V.
347
+ --
348
+
349
+ . Should we distinct const and non-const function pointers in rules for *OpCompositeInsert*?
350
+ We can only use a result of *OpConstantFunctionPointerINTEL* (which is a quite specific case of
351
+ <<FunctionPointer, Function Pointer>>, so we can't use the whole term in the rule)
352
+ in *OpConstantComposite*, but how should we specify that in this spec?
353
+ +
354
+ --
355
+ *RESOLVED*
356
+
357
+ Removed *OpFunctionPointerINTEL* instruction.
358
+ --
359
+
330
360
//. Issue.
331
361
//+
332
362
//--
@@ -356,4 +386,6 @@ be used for ones out of the box and we don't have much use-cases for it.
356
386
pointers. Updated validation rules. Misc updates.
357
387
|G|2019-07-19|Ben Ashbaugh|Assigned SPIR-V enums, added preview extension disclaimer text.
358
388
|H|2021-11-15|Nikita Kornev|Added new *ArgumentAttributeINTEL* decoration.
389
+ |I|2022-10-08|Dmitry Sidorov, Alex Bezzubikov, Alexey Sachkov|Replaced *OpFunctionPointerINTEL* with
390
+ *OpConstantFunctionPointerINTEL*
359
391
|========================================
0 commit comments