Skip to content

Commit a6c439f

Browse files
authored
add required alignment of types to the OpenCL SPIR-V Environment spec (#527)
1 parent b1bd301 commit a6c439f

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

OpenCL_C.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ write the `half` scalar or vector value to memory.
427427
--
428428

429429
The `char`, `unsigned char`, `short`, `unsigned short`, `int`, `unsigned int`,
430-
`long`, `unsigned long`, `float` and `double vector data types are supported.
430+
`long`, `unsigned long`, `float` and `double` vector data types are supported.
431431
footnote:[{fn-vector-types}]
432432
The vector data type is defined with the type name, i.e. `char`, `uchar`,
433433
`short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, or `double`

env/common_properties.asciidoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,20 @@ additional types in an entry point's parameter list.
393393
An *OpVariable* in a SPIR-V module with the *BuiltIn* decoration represents
394394
a built-in variable.
395395
All built-in variables must be in the *Input* storage class.
396+
397+
=== Alignment of Types
398+
399+
Objects of type *OpTypeInt*, *OpTypeFloat*, and *OpTypePointer* must be aligned
400+
in memory to the size of the type in bytes. Objects of type *OpTypeVector* with
401+
these component types must be aligned in memory to the size of the vector type
402+
in bytes. For 3-component vector types, the size of the vector type is four
403+
times the size the component type.
404+
405+
The compiler is responsible for aligning objects allocated by *OpVariable* to
406+
the appropriate alignment as required by the _Result Type_.
407+
408+
For *OpTypePointer* arguments to a function, the compiler may assume that the
409+
pointer is appropriately aligned as required by the _Type_ that the pointer
410+
points to.
411+
412+
Behavior of an unaligned load or store is undefined.

0 commit comments

Comments
 (0)