Skip to content

Commit 4477198

Browse files
committed
[SPIR-V] Update SPV_INTEL_function_pointers extension
Replace OpFunctionPointerINTEL with a constant one
1 parent d5a7f20 commit 4477198

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

sycl/doc/extensions/SPIRV/SPV_INTEL_function_pointers.asciidoc

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ https://github.com/intel/llvm/issues
1717
- Ben Ashbaugh, Intel
1818
- Pawel Jurek, Intel
1919
- Thomas Raoux, Intel
20+
- Alex Bezzubikov, Intel
2021

2122
== Notice
2223

@@ -37,7 +38,7 @@ If you are interested in using this feature in your software product, please let
3738
[width="40%",cols="25,25"]
3839
|==================================
3940
| Last Modified Date | {docdate}
40-
| Revision | G
41+
| Revision | H
4142
|==================================
4243

4344
== Dependencies
@@ -86,7 +87,7 @@ IndirectReferencesINTEL
8687
Instructions added under the *FunctionPointersINTEL* capability:
8788

8889
----
89-
OpFunctionPointerINTEL
90+
OpConstFunctionPointerINTEL
9091
OpFunctionPointerCallINTEL
9192
----
9293

@@ -113,7 +114,7 @@ CodeSectionINTEL
113114
[cols="70%,30%"]
114115
[grid="rows"]
115116
|====
116-
|OpFunctionPointerINTEL | 5600
117+
|OpConstFunctionPointerINTEL| 5600
117118
|OpFunctionPointerCallINTEL | 5601
118119
|ReferencedIndirectlyINTEL | 5602
119120
|FunctionPointersINTEL | 5603
@@ -133,23 +134,24 @@ Modify Section 2.2.2, Types, add the following at the end of the section: ::
133134
[[FunctionPointer]]'Function Pointer': A pointer that results from the following
134135
instruction:
135136

136-
- *OpFunctionPointerINTEL*
137+
- *OpConstFunctionPointerINTEL*
137138

138139
Additionally, any *OpSelect*, *OpPhi*, *OpFunctionCall*, *OpPtrAccessChain*,
139140
*OpLoad*, *OpAccessChain*, *OpInBoundAccessChain*, or *OpCopyObject* thas takes
140141
a function pointer as an operand also produces a function pointer. An
141142
*OpFunctionParameter* of pointer type is function pointer if any
142143
*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.
145146

146147
Modify Section 2.9, Function Calling, add the following after the first sentence: ::
147148

148149
Functions can be called indirectly using function pointers: to do so, use
149150
*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.
153155

154156
=== Storage Classes
155157

@@ -207,16 +209,17 @@ Modify Section 3.32.6, Type-Declaration Instructions, change the third sentence
207209
pointer type. *OpFunction* and *OpTypePointer* are only valid uses of
208210
*OpTypeFunction*.
209211

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: ::
211213

212214
[cols="2*1,3*3",width="100%"]
213215
|=====
214-
4+|[[OpFunctionPointerINTEL]]*OpFunctionPointerINTEL* +
216+
4+|[[OpConstFunctionPointerINTEL]]*OpConstFunctionPointerINTEL* +
215217
+
216-
Obtains address of the specified function. +
218+
Obtains constant address of the specified function. +
217219
+
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*. +
220223
+
221224
_Result Type_ must be an *OpTypePointer*. Its _Type_ operand must be the same
222225
*OpTypeFunction* which was used as _Function Type_ operand of the _Function_
@@ -226,6 +229,8 @@ operand. Its _Storage Class_ operand must be *CodeSectionINTEL*
226229
| 4 | 5600 | '<id>' 'Result Type' | '<id> Result ' | '<id>' 'Function'
227230
|=====
228231

232+
Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
233+
229234
[cols="2*1,4*3",width="100%"]
230235
|=====
231236
5+|[[OpFunctionPointerCallINTEL]]*OpFunctionPointerCallINTEL* +
@@ -252,14 +257,17 @@ argument types must match the formal parameter types.
252257
== Validation Rules
253258

254259
It is legal to use <<FunctionPointer, Function Pointer>> as 'Result Type' of
255-
*OpFunctionArgument*, *OpUndef* and *OpConstantNULL*.
260+
*OpFunctionArgument*, *OpCompositeExtract*, *OpUndef* and *OpConstantNULL*.
256261

257262
It is legal to use <<FunctionPointer, Function Pointer>> as 'Return Type' of
258263
*OpTypeFunction*.
259264

260265
It is legal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
261266
argument of *OpConvertPtrToU* and as 'Result Type' of *OpConvertUToPtr*.
262267

268+
It is legal to use <<FunctionPointer, Function Pointer>> as 'Object'
269+
argument of *OpCompositeInsert*.
270+
263271
It is illegal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
264272
argument of *OpPtrCastToGeneric*.
265273

@@ -308,6 +316,28 @@ be used for ones out of the box and we don't have much use-cases for it.
308316
*UNRESOLVED*
309317
--
310318

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+
311341
//. Issue.
312342
//+
313343
//--
@@ -336,4 +366,6 @@ be used for ones out of the box and we don't have much use-cases for it.
336366
|F|2019-06-21|Alexey Sachkov|Added new storage class dedicated for function
337367
pointers. Updated validation rules. Misc updates.
338368
|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*
339371
|========================================

0 commit comments

Comments
 (0)