@@ -17,6 +17,7 @@ https://github.com/intel/llvm/issues
17
17
- Ben Ashbaugh, Intel
18
18
- Pawel Jurek, Intel
19
19
- Thomas Raoux, Intel
20
+ - Alex Bezzubikov, Intel
20
21
21
22
== Notice
22
23
@@ -37,7 +38,7 @@ If you are interested in using this feature in your software product, please let
37
38
[width="40%",cols="25,25"]
38
39
|==================================
39
40
| Last Modified Date | {docdate}
40
- | Revision | G
41
+ | Revision | H
41
42
|==================================
42
43
43
44
== Dependencies
@@ -86,7 +87,7 @@ IndirectReferencesINTEL
86
87
Instructions added under the *FunctionPointersINTEL* capability:
87
88
88
89
----
89
- OpFunctionPointerINTEL
90
+ OpConstFunctionPointerINTEL
90
91
OpFunctionPointerCallINTEL
91
92
----
92
93
@@ -113,7 +114,7 @@ CodeSectionINTEL
113
114
[cols="70%,30%"]
114
115
[grid="rows"]
115
116
|====
116
- |OpFunctionPointerINTEL | 5600
117
+ |OpConstFunctionPointerINTEL | 5600
117
118
|OpFunctionPointerCallINTEL | 5601
118
119
|ReferencedIndirectlyINTEL | 5602
119
120
|FunctionPointersINTEL | 5603
@@ -133,23 +134,24 @@ Modify Section 2.2.2, Types, add the following at the end of the section: ::
133
134
[[FunctionPointer]]'Function Pointer': A pointer that results from the following
134
135
instruction:
135
136
136
- - *OpFunctionPointerINTEL *
137
+ - *OpConstFunctionPointerINTEL *
137
138
138
139
Additionally, any *OpSelect*, *OpPhi*, *OpFunctionCall*, *OpPtrAccessChain*,
139
140
*OpLoad*, *OpAccessChain*, *OpInBoundAccessChain*, or *OpCopyObject* thas takes
140
141
a function pointer as an operand also produces a function pointer. An
141
142
*OpFunctionParameter* of pointer type is function pointer if any
142
143
*OpFunctionCall* to the function statically passes a function pointer as the
143
- value of the parameter. *OpConstantNull* returns function pointer if 'Result
144
- type' is function pointer.
144
+ value of the parameter. *OpCompositeExtract* and * OpConstantNull* return function pointer
145
+ if 'Result type' is function pointer.
145
146
146
147
Modify Section 2.9, Function Calling, add the following after the first sentence: ::
147
148
148
149
Functions can be called indirectly using function pointers: to do so, use
149
150
*OpFunctionPointerCallINTEL* with an operand that is the _<id>_ obtained using
150
- *OpFunctionPointerINTEL* of the *OpFunction* to call, and the _<id>s_ of the
151
- arguments to pass. All arguments are passed by value into the called function.
152
- This includes pointers, through which a callee object could be modified.
151
+ *OpConstFunctionPointerINTEL* of the *OpFunction* to call,
152
+ and the _<id>s_ of the arguments to pass. All arguments are passed by value
153
+ into the called function. This includes pointers, through which a callee object
154
+ could be modified.
153
155
154
156
=== Storage Classes
155
157
@@ -207,16 +209,17 @@ Modify Section 3.32.6, Type-Declaration Instructions, change the third sentence
207
209
pointer type. *OpFunction* and *OpTypePointer* are only valid uses of
208
210
*OpTypeFunction*.
209
211
210
- Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
212
+ Modify Section 3.32.7, Constant-Creation Instructions, adding to the end of the list of instructions: ::
211
213
212
214
[cols="2*1,3*3",width="100%"]
213
215
|=====
214
- 4+|[[OpFunctionPointerINTEL ]]*OpFunctionPointerINTEL * +
216
+ 4+|[[OpConstFunctionPointerINTEL ]]*OpConstFunctionPointerINTEL * +
215
217
+
216
- Obtains address of the specified function. +
218
+ Obtains constant address of the specified function. +
217
219
+
218
- Result value can be used immediately in *OpFunctionPointerCallINTEL* or stored
219
- somewhere for further usage in *OpFunctionPointerCallINTEL*. +
220
+ Result value can be used in *OpFunctionPointerCallINTEL* or inserted into
221
+ a composite constant or stored somewhere for further usage
222
+ in *OpFunctionPointerCallINTEL*. +
220
223
+
221
224
_Result Type_ must be an *OpTypePointer*. Its _Type_ operand must be the same
222
225
*OpTypeFunction* which was used as _Function Type_ operand of the _Function_
@@ -226,6 +229,8 @@ operand. Its _Storage Class_ operand must be *CodeSectionINTEL*
226
229
| 4 | 5600 | '<id>' 'Result Type' | '<id> Result ' | '<id>' 'Function'
227
230
|=====
228
231
232
+ Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
233
+
229
234
[cols="2*1,4*3",width="100%"]
230
235
|=====
231
236
5+|[[OpFunctionPointerCallINTEL]]*OpFunctionPointerCallINTEL* +
@@ -252,14 +257,17 @@ argument types must match the formal parameter types.
252
257
== Validation Rules
253
258
254
259
It is legal to use <<FunctionPointer, Function Pointer>> as 'Result Type' of
255
- *OpFunctionArgument*, *OpUndef* and *OpConstantNULL*.
260
+ *OpFunctionArgument*, *OpCompositeExtract*, * OpUndef* and *OpConstantNULL*.
256
261
257
262
It is legal to use <<FunctionPointer, Function Pointer>> as 'Return Type' of
258
263
*OpTypeFunction*.
259
264
260
265
It is legal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
261
266
argument of *OpConvertPtrToU* and as 'Result Type' of *OpConvertUToPtr*.
262
267
268
+ It is legal to use <<FunctionPointer, Function Pointer>> as 'Object'
269
+ argument of *OpCompositeInsert*.
270
+
263
271
It is illegal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
264
272
argument of *OpPtrCastToGeneric*.
265
273
@@ -308,6 +316,28 @@ be used for ones out of the box and we don't have much use-cases for it.
308
316
*UNRESOLVED*
309
317
--
310
318
319
+ . Should we prohibit heterogenous composites with function pointers? Maybe we should
320
+ distinct <<FunctionPointer, Function Pointer>> and Constant Function Pointer?
321
+ +
322
+ --
323
+ *RESOLVED*
324
+
325
+ In general, we should not since this extension is aimed to support the whole C++ function
326
+ pointers functionality in SPIR-V.
327
+ --
328
+
329
+ . Should we distinct const and non-const function pointers in rules for *OpCompositeInsert*?
330
+ We can only use a result of *OpConstFunctionPointerINTEL* (which is a quite specific case of
331
+ <<FunctionPointer, Function Pointer>>, so we can't use the whole term in the rule)
332
+ in *OpConstantComposite*, but how should we specify that in this spec?
333
+ +
334
+ --
335
+ *RESOLVED*
336
+
337
+ Removed *OpFunctionPointerINTEL* instruction.
338
+ --
339
+
340
+
311
341
//. Issue.
312
342
//+
313
343
//--
@@ -336,4 +366,6 @@ be used for ones out of the box and we don't have much use-cases for it.
336
366
|F|2019-06-21|Alexey Sachkov|Added new storage class dedicated for function
337
367
pointers. Updated validation rules. Misc updates.
338
368
|G|2019-07-19|Ben Ashbaugh|Assigned SPIR-V enums, added preview extension disclaimer text.
369
+ |H|2020-07-30|Alex Bezzubikov|Replaced *OpFunctionPointerINTEL* with
370
+ *OpConstFunctionPointerINTEL*
339
371
|========================================
0 commit comments