Name Strings
SPV_INTEL_variable_length_array
Contact
To report problems with this extension, please open a new issue at:
Contributors
-
Alexey Sotkin, Intel
-
Ben Ashbaugh, Intel
-
Vyacheslav Zakharin, Intel
-
Michael Kinsner, Intel
-
Dmitry Sidorov, Intel
-
Viktoria Maksimova, Intel
-
Victor Lomuller, Codeplay
Notice
Copyright (c) 2025 Intel Corporation. All rights reserved.
Status
-
Complete
Version
Last Modified Date |
2025-03-14 |
Revision |
3 |
Dependencies
This extension is written against the SPIR-V Specification, Version 1.6 Revision 5.
This extension interacts with SPV_KHR_untyped_pointers extension.
This extension requires SPIR-V 1.0.
Overview
This extension allows to allocate local arrays whose number of elements is unknown at compile time. This is useful for implementing high-level language features like C99 variable length arrays.
Extension Name
To use this extension within a SPIR-V module, the appropriate OpExtension must be present in the module:
OpExtension "SPV_INTEL_variable_length_array"
Modifications to the SPIR-V Specification, Version 1.6
Capabilities
Modify Section 3.31, Capability, adding rows to the Capability table:
Capability | Implicitly Declares | |
---|---|---|
5817 |
VariableLengthArrayINTEL |
|
6243 |
UntypedVariableLengthArrayINTEL |
VariableLengthArrayINTEL, UntypedPointersKHR |
Instructions
Modify Section 3.56.8. Memory Instructions, adding to the end of the list of instructions:
Validation Rules
-
In control flow graph every OpVariableLengthArrayINTEL and OpUntypedVariableLengthArrayINTEL must be dominated by at least one OpSaveMemoryINTEL.
Issues
-
Can OpVariableLengthArrayINTEL be used without OpSaveMemoryINTEL and OpRestoreMemoryINTEL?
RESOLVED: It will result in undefined behavior.
-
Should we mention that the memory should be automatically deallocated when the control flow reaches the end of the (Function?) scope?
RESOLVED: reuse OpVariable definition.
-
Should we restrict usage of the instructions declared in this extension to uniform(convergent) control flow only?
RESOLVED: no, as each invocation owns its own Function memory.
-
Should zero-length VLA allocation return nullptr?
RESOLVED: No. Yet accessing such allocation is undefined behavior.
-
Should we clarify order of OpRestoreMemoryINTEL instructions when they are postdominating several OpSaveMemoryINTEL instructions?
RESOLVED: If the order of deallocations is not reversed to the order of OpSaveMemoryINTEL instructions, then the behavior is undefined.
Revision History
Rev | Date | Author | Changes |
---|---|---|---|
1 |
2020-08-31 |
Alexey Sotkin |
Initial revision |
2 |
2025-01-28 |
Dmitry Sidorov |
Add untyped capability |
3 |
2025-03-14 |
Dmitry Sidorov |
Add notes about UB in case of multiple deallocations |