Skip to content

Commit 78b9128

Browse files
authored
[LangRef] Document the difference between <abi> and <pref> (#147929)
Document how LLVM expects to use `<abi>` and `<pref>`, as well as the `pref >= abi` requirement.
1 parent 64c273a commit 78b9128

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

llvm/docs/LangRef.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,12 +3240,24 @@ as follows:
32403240
as :ref:`Non-Integral Pointer Type <nointptrtype>` s. The ``0``
32413241
address space cannot be specified as non-integral.
32423242

3243-
Unless explicitly stated otherwise, on every specification that specifies
3244-
an alignment, the value of the alignment must be in the range [1,2^16)
3245-
and must be a power of two times the width of a byte.
3246-
On every specification that takes a ``<abi>:<pref>``, specifying the
3247-
``<pref>`` alignment is optional. If omitted, the preceding ``:``
3248-
should be omitted too and ``<pref>`` will be equal to ``<abi>``.
3243+
``<abi>`` is a lower bound on what is required for a type to be considered
3244+
aligned. This is used in various places, such as:
3245+
3246+
- The alignment for loads and stores if none is explicitly given.
3247+
- The alignment used to compute struct layout.
3248+
- The alignment used to compute allocation sizes and thus ``getelementptr``
3249+
offsets.
3250+
- The alignment below which accesses are considered underaligned.
3251+
3252+
``<pref>`` allows providing a more optimal alignment that should be used when
3253+
possible, primarily for ``alloca`` and the alignment of global variables. It is
3254+
an optional value that must be greater than or equal to ``<abi>``. If omitted,
3255+
the preceding ``:`` should also be omitted and ``<pref>`` will be equal to
3256+
``<abi>``.
3257+
3258+
Unless explicitly stated otherwise, every alignment specification is provided in
3259+
bits and must be in the range [1,2^16). The value must be a power of two times
3260+
the width of a byte (i.e. ``align = 8 * 2^N``).
32493261

32503262
When constructing the data layout for a given target, LLVM starts with a
32513263
default set of specifications which are then (possibly) overridden by

0 commit comments

Comments
 (0)