Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3240,12 +3240,15 @@ as follows:
as :ref:`Non-Integral Pointer Type <nointptrtype>` s. The ``0``
address space cannot be specified as non-integral.

``<abi>`` provides a minimum allowed alignment for a type, and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"minimum allowed alignment" isn't really accurate in that you can use lower alignments, they'll just be considered unaligned.

The ABI alignment is used in various places:

  • The default alignment for loads and stores when no explicit alignment is given in textual IR.
  • The alignment used to compute struct layout.
  • The alignment used to compute allocation sizes and thus getelementptr offsets.
  • The alignment below which accesses are considered underaligned.
  • ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update to mention this. Are there any more specific cases of pref that should be mentioned?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"pref" align is primarily used for allocas and global variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to mention this

``<pref>`` allows providing a more optimal alignment that should be used
when possible. ``<pref>`` is an optional value that must be greater than
or equal to ``<abi>``. If omitted, the preceding ``:`` should also be
omitted and ``<pref>`` will be equal to ``<abi>``.

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

When constructing the data layout for a given target, LLVM starts with a
default set of specifications which are then (possibly) overridden by
Expand All @@ -3261,8 +3264,8 @@ specifications are given in this list:
- ``i8:8:8`` - i8 is 8-bit (byte) aligned as mandated
- ``i16:16:16`` - i16 is 16-bit aligned
- ``i32:32:32`` - i32 is 32-bit aligned
- ``i64:32:64`` - i64 has ABI alignment of 32-bits but preferred
alignment of 64-bits
- ``i64:32:64`` - i64 has a required alignment of 32-bits but should be
aligned to 64-bits if possible.
- ``f16:16:16`` - half is 16-bit aligned
- ``f32:32:32`` - float is 32-bit aligned
- ``f64:64:64`` - double is 64-bit aligned
Expand Down
Loading