Skip to content

Commit eb70253

Browse files
authored
[LangRef/DataLayout] Spell out requirements for alignment values (llvm#104705)
For 'p' the added wording matches the implementation. For 'i', 'f', 'v' the implementation also allows 0 for `<pref>` component, making 'i16:16:0' valid, for example. 'Fi0', 'Fn0' and 'S0' are also currently accepted. This is likely unintentional. There are no tests in the codebase that rely on this behavior, so the added wording prohibits zero alignments for these specifications. For 'a', the implementation currently allows 0 for both `<abi>` and `<pref>` components. The added wording prohibits specifying zero for `<pref>` with the same justification as above. Zero `<abi>` is used in tests, and the example at the end of the section suggests that this is valid, so that's left unchanged. This effectively prohibits zero alignments everywhere except for the `<abi>` component of aggregate specification.
1 parent 48441cb commit eb70253

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

llvm/docs/LangRef.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,8 +3109,7 @@ as follows:
31093109
``S<size>``
31103110
Specifies the natural alignment of the stack in bits. Alignment
31113111
promotion of stack variables is limited to the natural stack
3112-
alignment to avoid dynamic stack realignment. The stack alignment
3113-
must be a multiple of 8-bits. If omitted, the natural stack
3112+
alignment to avoid dynamic stack realignment. If omitted, the natural stack
31143113
alignment defaults to "unspecified", which does not prevent any
31153114
alignment promotions.
31163115
``P<address space>``
@@ -3136,8 +3135,8 @@ as follows:
31363135
Defaults to the default address space of 0.
31373136
``p[n]:<size>:<abi>[:<pref>][:<idx>]``
31383137
This specifies the *size* of a pointer and its ``<abi>`` and
3139-
``<pref>``\erred alignments for address space ``n``. ``<pref>`` is optional
3140-
and defaults to ``<abi>``. The fourth parameter ``<idx>`` is the size of the
3138+
``<pref>``\erred alignments for address space ``n``.
3139+
The fourth parameter ``<idx>`` is the size of the
31413140
index that used for address calculation, which must be less than or equal
31423141
to the pointer size. If not
31433142
specified, the default index size is equal to the pointer size. All sizes
@@ -3147,23 +3146,21 @@ as follows:
31473146
``i<size>:<abi>[:<pref>]``
31483147
This specifies the alignment for an integer type of a given bit
31493148
``<size>``. The value of ``<size>`` must be in the range [1,2^24).
3150-
``<pref>`` is optional and defaults to ``<abi>``.
31513149
For ``i8``, the ``<abi>`` value must equal 8,
31523150
that is, ``i8`` must be naturally aligned.
31533151
``v<size>:<abi>[:<pref>]``
31543152
This specifies the alignment for a vector type of a given bit
31553153
``<size>``. The value of ``<size>`` must be in the range [1,2^24).
3156-
``<pref>`` is optional and defaults to ``<abi>``.
31573154
``f<size>:<abi>[:<pref>]``
31583155
This specifies the alignment for a floating-point type of a given bit
31593156
``<size>``. Only values of ``<size>`` that are supported by the target
31603157
will work. 32 (float) and 64 (double) are supported on all targets; 80
31613158
or 128 (different flavors of long double) are also supported on some
31623159
targets. The value of ``<size>`` must be in the range [1,2^24).
3163-
``<pref>`` is optional and defaults to ``<abi>``.
31643160
``a:<abi>[:<pref>]``
31653161
This specifies the alignment for an object of aggregate type.
3166-
``<pref>`` is optional and defaults to ``<abi>``.
3162+
In addition to the usual requirements for alignment values,
3163+
the value of ``<abi>`` can also be zero, which means one byte alignment.
31673164
``F<type><abi>``
31683165
This specifies the alignment for function pointers.
31693166
The options for ``<type>`` are:
@@ -3202,6 +3199,9 @@ as follows:
32023199
as :ref:`Non-Integral Pointer Type <nointptrtype>` s. The ``0``
32033200
address space cannot be specified as non-integral.
32043201

3202+
Unless explicitly stated otherwise, on every specification that specifies
3203+
an alignment, the value of the alignment must be in the range [1,2^16)
3204+
and must be a power of two times the width of a byte.
32053205
On every specification that takes a ``<abi>:<pref>``, specifying the
32063206
``<pref>`` alignment is optional. If omitted, the preceding ``:``
32073207
should be omitted too and ``<pref>`` will be equal to ``<abi>``.

0 commit comments

Comments
 (0)