Skip to content

Commit a29c74f

Browse files
[SPIR-V][DOC] Update SPV_INTEL_function_pointers (#4883)
OpFunctionPointerINTEL was renamed to OpConstantFunctionPointerINTEL Signed-off-by: Dmitry Sidorov <[email protected]> Co-authored-by: Alexey Sachkov <[email protected]>
1 parent 0cc7540 commit a29c74f

File tree

1 file changed

+53
-21
lines changed

1 file changed

+53
-21
lines changed

sycl/doc/design/spirv-extensions/SPV_INTEL_function_pointers.asciidoc

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ https://github.com/intel/llvm/issues
1818
- Pawel Jurek, Intel
1919
- Thomas Raoux, Intel
2020
- Nikita Kornev, Intel
21+
- Dmitry Sidorov, Intel
22+
- Alex Bezzubikov, Intel
2123

2224
== Notice
2325

@@ -38,7 +40,7 @@ If you are interested in using this feature in your software product, please let
3840
[width="40%",cols="25,25"]
3941
|==================================
4042
| Last Modified Date | {docdate}
41-
| Revision | H
43+
| Revision | I
4244
|==================================
4345

4446
== Dependencies
@@ -89,7 +91,7 @@ IndirectReferencesINTEL
8991
Instructions added under the *FunctionPointersINTEL* capability:
9092

9193
----
92-
OpFunctionPointerINTEL
94+
OpConstantFunctionPointerINTEL
9395
OpFunctionPointerCallINTEL
9496
----
9597

@@ -122,13 +124,13 @@ CodeSectionINTEL
122124
[cols="70%,30%"]
123125
[grid="rows"]
124126
|====
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
132134
|====
133135

134136
== 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: ::
143145
[[FunctionPointer]]'Function Pointer': A pointer that results from the following
144146
instruction:
145147

146-
- *OpFunctionPointerINTEL*
148+
- *OpConstantFunctionPointerINTEL*
147149

148150
Additionally, any *OpSelect*, *OpPhi*, *OpFunctionCall*, *OpPtrAccessChain*,
149151
*OpLoad*, *OpAccessChain*, *OpInBoundAccessChain*, or *OpCopyObject* thas takes
150152
a function pointer as an operand also produces a function pointer. An
151153
*OpFunctionParameter* of pointer type is function pointer if any
152154
*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.
155157

156158
Modify Section 2.9, Function Calling, add the following after the first sentence: ::
157159

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

164167
=== Storage Classes
165168

@@ -226,16 +229,17 @@ Modify Section 3.32.6, Type-Declaration Instructions, change the third sentence
226229
pointer type. *OpFunction* and *OpTypePointer* are only valid uses of
227230
*OpTypeFunction*.
228231

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

231234
[cols="2*1,3*3",width="100%"]
232235
|=====
233-
4+|[[OpFunctionPointerINTEL]]*OpFunctionPointerINTEL* +
236+
4+|[[OpConstantFunctionPointerINTEL]]*OpConstantFunctionPointerINTEL* +
234237
+
235-
Obtains address of the specified function. +
238+
Obtains constant address of the specified function. +
236239
+
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*. +
239243
+
240244
_Result Type_ must be an *OpTypePointer*. Its _Type_ operand must be the same
241245
*OpTypeFunction* which was used as _Function Type_ operand of the _Function_
@@ -245,6 +249,8 @@ operand. Its _Storage Class_ operand must be *CodeSectionINTEL*
245249
| 4 | 5600 | '<id>' 'Result Type' | '<id> Result ' | '<id>' 'Function'
246250
|=====
247251

252+
Modify Section 3.32.9, Function Instructions, adding to the end of the list of instructions: ::
253+
248254
[cols="2*1,4*3",width="100%"]
249255
|=====
250256
5+|[[OpFunctionPointerCallINTEL]]*OpFunctionPointerCallINTEL* +
@@ -271,14 +277,17 @@ argument types must match the formal parameter types.
271277
== Validation Rules
272278

273279
It is legal to use <<FunctionPointer, Function Pointer>> as 'Result Type' of
274-
*OpFunctionArgument*, *OpUndef* and *OpConstantNULL*.
280+
*OpFunctionArgument*, *OpCompositeExtract*, *OpUndef* and *OpConstantNULL*.
275281

276282
It is legal to use <<FunctionPointer, Function Pointer>> as 'Return Type' of
277283
*OpTypeFunction*.
278284

279285
It is legal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
280286
argument of *OpConvertPtrToU* and as 'Result Type' of *OpConvertUToPtr*.
281287

288+
It is legal to use <<FunctionPointer, Function Pointer>> as 'Object'
289+
argument of *OpCompositeInsert*.
290+
282291
It is illegal to use <<FunctionPointer, Function Pointer>> as 'Pointer'
283292
argument of *OpPtrCastToGeneric*.
284293

@@ -327,6 +336,27 @@ be used for ones out of the box and we don't have much use-cases for it.
327336
*UNRESOLVED*
328337
--
329338

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+
330360
//. Issue.
331361
//+
332362
//--
@@ -356,4 +386,6 @@ be used for ones out of the box and we don't have much use-cases for it.
356386
pointers. Updated validation rules. Misc updates.
357387
|G|2019-07-19|Ben Ashbaugh|Assigned SPIR-V enums, added preview extension disclaimer text.
358388
|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*
359391
|========================================

0 commit comments

Comments
 (0)