[llvm-branch-commits] [llvm] [docs] Rewrite LangRef.md as Markdown (PR #201975)
Reid Kleckner via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jun 22 17:00:36 PDT 2026
https://github.com/rnk updated https://github.com/llvm/llvm-project/pull/201975
>From 97394f0c21e7156a81cfafcffb50c6deca45b790 Mon Sep 17 00:00:00 2001
From: Reid Kleckner <rkleckner at nvidia.com>
Date: Mon, 22 Jun 2026 16:33:19 -0700
Subject: [PATCH 1/2] [docs] Rewrite LangRef.md as Markdown
---
llvm/docs/LangRef.md | 32287 +++++++++++++++++++----------------------
1 file changed, 14740 insertions(+), 17547 deletions(-)
diff --git a/llvm/docs/LangRef.md b/llvm/docs/LangRef.md
index 287341d787b64..5ea1a8bf5f638 100644
--- a/llvm/docs/LangRef.md
+++ b/llvm/docs/LangRef.md
@@ -1,13 +1,11 @@
-==============================
-LLVM Language Reference Manual
-==============================
+# LLVM Language Reference Manual
-.. contents::
- :local:
- :depth: 3
+```{contents}
+:local:
+:depth: 3
+```
-Abstract
-========
+## Abstract
This document is a reference manual for the LLVM assembly language. LLVM
is a Static Single Assignment (SSA) based representation that provides
@@ -16,8 +14,7 @@ representing 'all' high-level languages cleanly. It is the common code
representation used throughout all phases of the LLVM compilation
strategy.
-Introduction
-============
+## Introduction
The LLVM code representation is designed to be used in three different
forms: as an in-memory compiler IR, as an on-disk bitcode representation
@@ -40,53 +37,50 @@ can be proven that a C automatic variable is never accessed outside of
the current function, allowing it to be promoted to a simple SSA value
instead of a memory location.
-.. _wellformed:
+(wellformed)=
-Well-Formedness
----------------
+### Well-Formedness
It is important to note that this document describes 'well formed' LLVM
assembly language. There is a difference between what the parser accepts
and what is considered 'well formed'. For example, the following
instruction is syntactically okay, but not well formed:
-.. code-block:: llvm
+```llvm
+%x = add i32 1, %x
+```
- %x = add i32 1, %x
-
-because the definition of ``%x`` does not dominate all of its uses. The
+because the definition of `%x` does not dominate all of its uses. The
LLVM infrastructure provides a verification pass that may be used to
verify that an LLVM module is well formed. This pass is automatically
run by the parser after parsing input assembly and by the optimizer
before it outputs bitcode. The violations pointed out by the verifier
pass indicate bugs in transformation passes or input to the parser.
-Syntax
-======
+## Syntax
-.. _identifiers:
+(identifiers)=
-Identifiers
------------
+### Identifiers
LLVM identifiers come in two basic types: global and local. Global
-identifiers (functions, global variables) begin with the ``'@'``
+identifiers (functions, global variables) begin with the `'@'`
character. Local identifiers (register names, types) begin with the
-``'%'`` character. Additionally, there are three different formats for
+`'%'` character. Additionally, there are three different formats for
identifiers, for different purposes:
-#. Named values are represented as a string of characters with their
- prefix. For example, ``%foo``, ``@DivisionByZero``,
- ``%a.really.long.identifier``. The actual regular expression used is
- '``[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*``'. Identifiers that require other
+1. Named values are represented as a string of characters with their
+ prefix. For example, `%foo`, `@DivisionByZero`,
+ `%a.really.long.identifier`. The actual regular expression used is
+ '`[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*`'. Identifiers that require other
characters in their names can be surrounded with quotes. Special
- characters may be escaped using ``"\xx"`` where ``xx`` is the ASCII
+ characters may be escaped using `"\xx"` where `xx` is the ASCII
code for the character in hexadecimal. In this way, any character can
- be used in a name value, even quotes themselves. The ``"\01"`` prefix
+ be used in a name value, even quotes themselves. The `"\01"` prefix
can be used on global values to suppress mangling.
-#. Unnamed values are represented as an unsigned numeric value with
- their prefix. For example, ``%12``, ``@2``, ``%44``.
-#. Constants, which are described in the section Constants_ below.
+1. Unnamed values are represented as an unsigned numeric value with
+ their prefix. For example, `%12`, `@2`, `%44`.
+1. Constants, which are described in the section {ref}`Constants <constants>` below.
LLVM requires that values start with a prefix for two reasons: Compilers
don't need to worry about name clashes with reserved words, and the set
@@ -96,43 +90,43 @@ with a temporary variable without having to avoid symbol table
conflicts.
Reserved words in LLVM are very similar to reserved words in other
-languages. There are keywords for different opcodes ('``add``',
-'``bitcast``', '``ret``', etc...), for primitive type names ('``void``',
-'``i32``', etc...), and others. These reserved words cannot conflict
+languages. There are keywords for different opcodes ('`add`',
+'`bitcast`', '`ret`', etc...), for primitive type names ('`void`',
+'`i32`', etc...), and others. These reserved words cannot conflict
with variable names, because none of them start with a prefix character
-(``'%'`` or ``'@'``).
+(`'%'` or `'@'`).
Here is an example of LLVM code to multiply the integer variable
-'``%X``' by 8:
+'`%X`' by 8:
The easy way:
-.. code-block:: llvm
-
- %result = mul i32 %X, 8
+```llvm
+%result = mul i32 %X, 8
+```
After strength reduction:
-.. code-block:: llvm
-
- %result = shl i32 %X, 3
+```llvm
+%result = shl i32 %X, 3
+```
And the hard way:
-.. code-block:: llvm
-
- %0 = add i32 %X, %X ; yields i32:%0
- %1 = add i32 %0, %0 ; yields i32:%1
- %result = add i32 %1, %1
+```llvm
+%0 = add i32 %X, %X ; yields i32:%0
+%1 = add i32 %0, %0 ; yields i32:%1
+%result = add i32 %1, %1
+```
-This last way of multiplying ``%X`` by 8 illustrates several important
+This last way of multiplying `%X` by 8 illustrates several important
lexical features of LLVM:
-#. Comments are delimited with a '``;``' and go until the end of line.
- Alternatively, comments can start with ``/*`` and terminate with ``*/``.
-#. Unnamed temporaries are created when the result of a computation is
+1. Comments are delimited with a '`;`' and go until the end of line.
+ Alternatively, comments can start with `/*` and terminate with `*/`.
+1. Unnamed temporaries are created when the result of a computation is
not assigned to a named value.
-#. By default, unnamed temporaries are numbered sequentially (using a
+1. By default, unnamed temporaries are numbered sequentially (using a
per-function incrementing counter, starting with 0). However, when explicitly
specifying temporary numbers, it is allowed to skip over numbers.
@@ -144,26 +138,25 @@ It also shows a convention that we follow in this document. When
demonstrating instructions, we will follow an instruction with a comment
that defines the type and name of value produced.
-.. _string_constants:
+(string_constants)=
-String constants
-----------------
+### String constants
-Strings in LLVM programs are delimited by ``"`` characters. Within a
-string, all bytes are treated literally with the exception of ``\``
-characters, which start escapes, and the first ``"`` character, which
+Strings in LLVM programs are delimited by `"` characters. Within a
+string, all bytes are treated literally with the exception of `\`
+characters, which start escapes, and the first `"` character, which
ends the string.
There are two kinds of escapes.
-* ``\\`` represents a single ``\`` character.
+* `\\` represents a single `\` character.
-* ``\`` followed by two hexadecimal characters (0-9, a-f, or A-F)
- represents the byte with the given value (e.g., ``\00`` represents a
+* `\` followed by two hexadecimal characters (0-9, a-f, or A-F)
+ represents the byte with the given value (e.g., `\00` represents a
null byte).
-To represent a ``"`` character, use ``\22``. (``\"`` will end the string
-with a trailing ``\``.)
+To represent a `"` character, use `\22`. (`\"` will end the string
+with a trailing `\`.)
Newlines do not terminate string constants; strings can span multiple
lines.
@@ -172,177 +165,182 @@ The interpretation of string constants (e.g., their character encoding)
depends on context.
-High Level Structure
-====================
+## High Level Structure
-Module Structure
-----------------
+### Module Structure
-LLVM programs are composed of ``Module``'s, each of which is a
+LLVM programs are composed of `Module`'s, each of which is a
translation unit of the input programs. Each module consists of
functions, global variables, and symbol table entries. Modules may be
combined together with the LLVM linker, which merges function (and
global variable) definitions, resolves forward declarations, and merges
symbol table entries. Here is an example of the "hello world" module:
-.. code-block:: llvm
+```llvm
+; Declare the string constant as a global constant.
+ at .str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
- ; Declare the string constant as a global constant.
- @.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
+; External declaration of the puts function
+declare i32 @puts(ptr captures(none)) nounwind
- ; External declaration of the puts function
- declare i32 @puts(ptr captures(none)) nounwind
+; Definition of main function
+define i32 @main() {
+ ; Call puts function to write out the string to stdout.
+ call i32 @puts(ptr @.str)
+ ret i32 0
+}
- ; Definition of main function
- define i32 @main() {
- ; Call puts function to write out the string to stdout.
- call i32 @puts(ptr @.str)
- ret i32 0
- }
+; Named metadata
+!0 = !{i32 42, null, !"string"}
+!foo = !{!0}
+```
- ; Named metadata
- !0 = !{i32 42, null, !"string"}
- !foo = !{!0}
-
-This example is made up of a :ref:`global variable <globalvars>` named
-"``.str``", an external declaration of the "``puts``" function, a
-:ref:`function definition <functionstructure>` for "``main``" and
-:ref:`named metadata <namedmetadatastructure>` "``foo``".
+This example is made up of a {ref}`global variable <globalvars>` named
+"`.str`", an external declaration of the "`puts`" function, a
+{ref}`function definition <functionstructure>` for "`main`" and
+{ref}`named metadata <namedmetadatastructure>` "`foo`".
In general, a module is made up of a list of global values (where both
functions and global variables are global values). Global values are
represented by a pointer to a memory location (in this case, a pointer
to an array of char, and a pointer to a function), and have one of the
-following :ref:`linkage types <linkage>`.
+following {ref}`linkage types <linkage>`.
-.. _linkage:
+(linkage)=
-Linkage Types
--------------
+### Linkage Types
All Global Variables and Functions have one of the following types of
linkage:
-``private``
- Global values with "``private``" linkage are only directly
+`private`
+: Global values with "`private`" linkage are only directly
accessible by objects in the current module. In particular, linking
code into a module with a private global value may cause the
private to be renamed as necessary to avoid collisions. Because the
symbol is private to the module, all references can be updated. This
doesn't show up in any symbol table in the object file.
-``internal``
- Similar to private, but the value shows as a local symbol
- (``STB_LOCAL`` in the case of ELF) in the object file. This
- corresponds to the notion of the '``static``' keyword in C.
-``available_externally``
- Globals with "``available_externally``" linkage are never emitted into
+
+`internal`
+: Similar to private, but the value shows as a local symbol
+ (`STB_LOCAL` in the case of ELF) in the object file. This
+ corresponds to the notion of the '`static`' keyword in C.
+
+`available_externally`
+: Globals with "`available_externally`" linkage are never emitted into
the object file corresponding to the LLVM module. From the linker's
- perspective, an ``available_externally`` global is equivalent to
+ perspective, an `available_externally` global is equivalent to
an external declaration. They exist to allow inlining and other
optimizations to take place given knowledge of the definition of the
global, which is known to be somewhere outside the module. Globals
- with ``available_externally`` linkage are allowed to be discarded at
+ with `available_externally` linkage are allowed to be discarded at
will, and allow inlining and other optimizations. This linkage type is
only allowed on definitions, not declarations.
-``linkonce``
- Globals with "``linkonce``" linkage are merged with other globals of
+
+`linkonce`
+: Globals with "`linkonce`" linkage are merged with other globals of
the same name when linkage occurs. This can be used to implement
some forms of inline functions, templates, or other code which must
be generated in each translation unit that uses it, but where the
body may be overridden with a more definitive definition later.
- Unreferenced ``linkonce`` globals are allowed to be discarded. Note
- that ``linkonce`` linkage does not actually allow the optimizer to
+ Unreferenced `linkonce` globals are allowed to be discarded. Note
+ that `linkonce` linkage does not actually allow the optimizer to
inline the body of this function into callers because it doesn't
know if this definition of the function is the definitive definition
within the program or whether it will be overridden by a stronger
definition. To enable inlining and other optimizations, use
- "``linkonce_odr``" linkage.
-``weak``
- "``weak``" linkage has the same merging semantics as ``linkonce``
- linkage, except that unreferenced globals with ``weak`` linkage may
+ "`linkonce_odr`" linkage.
+
+`weak`
+: "`weak`" linkage has the same merging semantics as `linkonce`
+ linkage, except that unreferenced globals with `weak` linkage may
not be discarded. This is used for globals that are declared "weak"
in C source code.
-``common``
- "``common``" linkage is most similar to "``weak``" linkage, but they
- are used for tentative definitions in C, such as "``int X;``" at
- global scope. Symbols with "``common``" linkage are merged in the
- same way as ``weak symbols``, and they may not be deleted if
- unreferenced. ``common`` symbols may not have an explicit section,
+
+`common`
+: "`common`" linkage is most similar to "`weak`" linkage, but they
+ are used for tentative definitions in C, such as "`int X;`" at
+ global scope. Symbols with "`common`" linkage are merged in the
+ same way as `weak symbols`, and they may not be deleted if
+ unreferenced. `common` symbols may not have an explicit section,
must have a zero initializer, and may not be marked
- ':ref:`constant <globalvars>`'. Functions and aliases may not have
+ '{ref}`constant <globalvars>`'. Functions and aliases may not have
common linkage.
-.. _linkage_appending:
+(linkage_appending)=
-``appending``
- "``appending``" linkage may only be applied to global variables of
+`appending`
+: "`appending`" linkage may only be applied to global variables of
pointer to array type. When two global variables with appending
linkage are linked together, the two global arrays are appended
together. This is the LLVM, typesafe, equivalent of having the
system linker append together "sections" with identical names when
- ``.o`` files are linked.
+ `.o` files are linked.
- Unfortunately this doesn't correspond to any feature in ``.o`` files, so it
- can only be used for variables like ``llvm.global_ctors`` which llvm
+ Unfortunately this doesn't correspond to any feature in `.o` files, so it
+ can only be used for variables like `llvm.global_ctors` which llvm
interprets specially.
-``extern_weak``
- The semantics of this linkage follow the ELF object file model: the
+`extern_weak`
+: The semantics of this linkage follow the ELF object file model: the
symbol is weak until linked, if not linked, the symbol becomes null
instead of being an undefined reference.
-``linkonce_odr``, ``weak_odr``
- The ``odr`` suffix indicates that all globals defined with the given name
+
+`linkonce_odr`, `weak_odr`
+: The `odr` suffix indicates that all globals defined with the given name
are equivalent, along the lines of the C++ "one definition rule" ("ODR").
Informally, this means we can inline functions and fold loads of constants.
- Formally, use the following definition: when an ``odr`` function is
+ Formally, use the following definition: when an `odr` function is
called, one of the definitions is non-deterministically chosen to run. For
- ``odr`` variables, if any byte in the value is not equal in all
- initializers, that byte is a :ref:`poison value <poisonvalues>`. For
+ `odr` variables, if any byte in the value is not equal in all
+ initializers, that byte is a {ref}`poison value <poisonvalues>`. For
aliases and ifuncs, apply the rule for the underlying function or variable.
- These linkage types are otherwise the same as their non-``odr`` versions.
-``external``
- If none of the above identifiers are used, the global is externally
+ These linkage types are otherwise the same as their non-`odr` versions.
+
+`external`
+: If none of the above identifiers are used, the global is externally
visible, meaning that it participates in linkage and can be used to
resolve external symbol references.
It is illegal for a global variable or function *declaration* to have any
-linkage type other than ``external`` or ``extern_weak``.
+linkage type other than `external` or `extern_weak`.
-.. _callingconv:
+(callingconv)=
-Calling Conventions
--------------------
+### Calling Conventions
-LLVM :ref:`functions <functionstructure>`, :ref:`calls <i_call>` and
-:ref:`invokes <i_invoke>` can all have an optional calling convention
+LLVM {ref}`functions <functionstructure>`, {ref}`calls <i_call>` and
+{ref}`invokes <i_invoke>` can all have an optional calling convention
specified for the call. The calling convention of any pair of dynamic
caller/callee must match, or the behavior of the program is undefined.
The following calling conventions are supported by LLVM, and more may be
added in the future:
-"``ccc``" - The C calling convention
- This calling convention (the default if no other calling convention
+"`ccc`" - The C calling convention
+: This calling convention (the default if no other calling convention
is specified) matches the target C calling conventions. This calling
convention supports varargs function calls and tolerates some
mismatch in the declared prototype and implemented declaration of
the function (as does normal C).
-"``fastcc``" - The fast calling convention
- This calling convention attempts to make calls as fast as possible
+
+"`fastcc`" - The fast calling convention
+: This calling convention attempts to make calls as fast as possible
(e.g., by passing things in registers). This calling convention
allows the target to use whatever tricks it wants to produce fast
code for the target, without having to conform to an externally
specified ABI (Application Binary Interface). Targets may use different
implementations according to different features. In this case, a
- TTI interface ``useFastCCForInternalCall`` must return false when
+ TTI interface `useFastCCForInternalCall` must return false when
any caller functions and the callee belong to different implementations.
- `Tail calls can only be optimized when this, the tailcc, the GHC or the
- HiPE convention is used. <CodeGenerator.html#tail-call-optimization>`_
+ {ref}`Tail calls <tail call section>` can only be optimized when this, the tailcc, the GHC or the
+ HiPE convention is used.
This calling convention does not support varargs and requires the prototype
of all callees to exactly match the prototype of the function definition.
-"``coldcc``" - The cold calling convention
- This calling convention attempts to make code in the caller as
+
+"`coldcc`" - The cold calling convention
+: This calling convention attempts to make code in the caller as
efficient as possible under the assumption that the call is not
commonly executed. As such, these calls often preserve all registers
so that the call does not break any live ranges in the caller side.
@@ -350,9 +348,10 @@ added in the future:
prototype of all callees to exactly match the prototype of the
function definition. Furthermore the inliner doesn't consider such function
calls for inlining.
-"``ghccc``" - GHC convention
- This calling convention has been implemented specifically for use by
- the `Glasgow Haskell Compiler (GHC) <http://www.haskell.org/ghc>`_.
+
+"`ghccc`" - GHC convention
+: This calling convention has been implemented specifically for use by
+ the [Glasgow Haskell Compiler (GHC)](http://www.haskell.org/ghc).
It passes everything in registers, going to extremes to achieve this
by disabling callee save registers. This calling convention should
not be used lightly but only for specific situations such as an
@@ -372,33 +371,34 @@ added in the future:
32-bit floating-point parameters, and 4 64-bit floating-point
parameters.
- This calling convention supports `tail call
- optimization <CodeGenerator.html#tail-call-optimization>`_ but requires
+ This calling convention supports {ref}`tail call optimization <tail call section>` but requires
both the caller and callee to use it.
-"``cc 11``" - The HiPE calling convention
- This calling convention has been implemented specifically for use by
- the `High-Performance Erlang
- (HiPE) <http://www.it.uu.se/research/group/hipe/>`_ compiler, *the*
- native code compiler of the `Ericsson's Open Source Erlang/OTP
- system <http://www.erlang.org/download.shtml>`_. It uses more
+
+"`cc 11`" - The HiPE calling convention
+: This calling convention has been implemented specifically for use by
+ the [High-Performance Erlang
+ (HiPE)](http://www.it.uu.se/research/group/hipe/) compiler, *the*
+ native code compiler of the [Ericsson's Open Source Erlang/OTP
+ system](http://www.erlang.org/download.shtml). It uses more
registers for argument passing than the ordinary C calling
convention and defines no callee-saved registers. The calling
- convention properly supports `tail call
- optimization <CodeGenerator.html#tail-call-optimization>`_ but requires
+ convention properly supports {ref}`tail call optimization <tail call section>` but requires
that both the caller and the callee use it. It uses a *register pinning*
mechanism, similar to GHC's convention, for keeping frequently
accessed runtime components pinned to specific hardware registers.
At the moment only X86 supports this convention (both 32 and 64
bit).
-"``anyregcc``" - Dynamic calling convention for code patching
- This is a special convention that supports patching an arbitrary code
+
+"`anyregcc`" - Dynamic calling convention for code patching
+: This is a special convention that supports patching an arbitrary code
sequence in place of a call site. This convention forces the call
arguments into registers but allows them to be dynamically
allocated. This can currently only be used with calls to
- ``llvm.experimental.patchpoint`` because only this intrinsic records
- the location of its arguments in a side table. See :doc:`StackMaps`.
-"``preserve_mostcc``" - The `PreserveMost` calling convention
- This calling convention attempts to make the code in the caller as
+ `llvm.experimental.patchpoint` because only this intrinsic records
+ the location of its arguments in a side table. See {doc}`StackMaps`.
+
+"`preserve_mostcc`" - The `PreserveMost` calling convention
+: This calling convention attempts to make the code in the caller as
unintrusive as possible. This convention behaves identically to the `C`
calling convention on how arguments and return values are passed, but it
uses a different set of caller/callee-saved registers. This alleviates the
@@ -414,7 +414,7 @@ added in the future:
be saved by the caller, but on Windows, xmm6-xmm15 are preserved.
- On AArch64 the callee preserves all general purpose registers, except
- X0-X8 and X16-X18. Not allowed with ``nest``.
+ X0-X8 and X16-X18. Not allowed with `nest`.
- On RISC-V the callee preserves x5-x31 except x6, x7 and x28 registers.
@@ -439,8 +439,9 @@ added in the future:
by other runtimes in the future too. The current implementation only
supports X86-64, but the intention is to support more architectures in the
future.
-"``preserve_allcc``" - The `PreserveAll` calling convention
- This calling convention attempts to make the code in the caller even less
+
+"`preserve_allcc`" - The `PreserveAll` calling convention
+: This calling convention attempts to make the code in the caller even less
intrusive than the `PreserveMost` calling convention. This calling
convention also behaves identically to the `C` calling convention on how
arguments and return values are passed, but it uses a different set of
@@ -456,7 +457,7 @@ added in the future:
- On AArch64 the callee preserves all general purpose registers, except
X0-X8 and X16-X18. Furthermore it also preserves lower 128 bits of V8-V31
- SIMD floating point registers. Not allowed with ``nest``.
+ SIMD floating point registers. Not allowed with `nest`.
The idea behind this convention is to support calls to runtime functions
that don't need to call out to any other functions.
@@ -464,15 +465,17 @@ added in the future:
This calling convention, like the `PreserveMost` calling convention, will be
used by a future version of the Objective-C runtime and should be considered
experimental at this time.
-"``preserve_nonecc``" - The `PreserveNone` calling convention
- This calling convention doesn't preserve any general registers. So all
+
+"`preserve_nonecc`" - The `PreserveNone` calling convention
+: This calling convention doesn't preserve any general registers. So all
general registers are caller saved registers. It also uses all general
registers to pass arguments. This attribute doesn't impact non-general
purpose registers (e.g., floating point registers, on X86 XMMs/YMMs).
Non-general purpose registers still follow the standard C calling
convention. Currently it is for x86_64, AArch64 and LoongArch only.
-"``cxx_fast_tlscc``" - The `CXX_FAST_TLS` calling convention for access functions
- Clang generates an access function to access C++-style Thread Local Storage
+
+"`cxx_fast_tlscc`" - The `CXX_FAST_TLS` calling convention for access functions
+: Clang generates an access function to access C++-style Thread Local Storage
(TLS). The access function generally has an entry block, an exit block and an
initialization block that is run at the first time. The entry and exit blocks
can access a few TLS IR variables, each access will be lowered to a
@@ -491,24 +494,28 @@ added in the future:
- On X86-64 the callee preserves all general purpose registers, except for
RDI and RAX.
-"``tailcc``" - Tail callable calling convention
- This calling convention ensures that calls in tail position will always be
+
+"`tailcc`" - Tail callable calling convention
+: This calling convention ensures that calls in tail position will always be
tail call optimized. This calling convention is equivalent to fastcc,
except for an additional guarantee that tail calls will be produced
- whenever possible. `Tail calls can only be optimized when this, the fastcc,
- the GHC or the HiPE convention is used. <CodeGenerator.html#tail-call-optimization>`_
+ whenever possible. {ref}`Tail calls <tail call section>` can only be optimized when this, the fastcc,
+ the GHC or the HiPE convention is used.
This calling convention does not support varargs and requires the prototype of
all callees to exactly match the prototype of the function definition.
-"``swiftcc``" - This calling convention is used for Swift language.
- - On X86-64 RCX and R8 are available for additional integer returns, and
+
+"`swiftcc`" - This calling convention is used for Swift language.
+: - On X86-64 RCX and R8 are available for additional integer returns, and
XMM2 and XMM3 are available for additional FP/vector returns.
- On iOS platforms, we use AAPCS-VFP calling convention.
-"``swifttailcc``"
- This calling convention is like ``swiftcc`` in most respects, but also the
+
+"`swifttailcc`"
+: This calling convention is like `swiftcc` in most respects, but also the
callee pops the argument area of the stack so that mandatory tail calls are
- possible as in ``tailcc``.
-"``cfguard_checkcc``" - Windows Control Flow Guard (Check mechanism)
- This calling convention is used for the Control Flow Guard check function,
+ possible as in `tailcc`.
+
+"`cfguard_checkcc`" - Windows Control Flow Guard (Check mechanism)
+: This calling convention is used for the Control Flow Guard check function,
calls to which can be inserted before indirect calls to check that the call
target is a valid function address. The check function has no return value,
but it will trigger an OS-level error if the address is not a valid target.
@@ -518,8 +525,9 @@ added in the future:
- On X86 the target address is passed in ECX.
- On ARM the target address is passed in R0.
- On AArch64 the target address is passed in X15.
-"``cc <n>``" - Numbered convention
- Any calling convention may be specified by number, allowing
+
+"`cc <n>`" - Numbered convention
+: Any calling convention may be specified by number, allowing
target-specific calling conventions to be used. Target-specific
calling conventions start at 64.
@@ -527,16 +535,15 @@ More calling conventions can be added/defined on an as-needed basis, to
support Pascal conventions or any other well-known target-independent
convention.
-.. _visibilitystyles:
+(visibilitystyles)=
-Visibility Styles
------------------
+### Visibility Styles
All Global Variables and Functions have one of the following visibility
styles:
-"``default``" - Default style
- On targets that use the ELF object file format, default visibility
+"`default`" - Default style
+: On targets that use the ELF object file format, default visibility
means that the declaration is visible to other modules and, in
shared libraries, means that the declared entity may be overridden.
On Darwin, default visibility means that the declaration is visible
@@ -545,69 +552,72 @@ styles:
(i.e "exported") to other modules depends primarily on export lists
provided to the linker. Default visibility corresponds to "external
linkage" in the language.
-"``hidden``" - Hidden style
- Two declarations of an object with hidden visibility refer to the
+
+"`hidden`" - Hidden style
+: Two declarations of an object with hidden visibility refer to the
same object if they are in the same shared object. Usually, hidden
visibility indicates that the symbol will not be placed into the
dynamic symbol table, so no other module (executable or shared
library) can reference it directly.
-"``protected``" - Protected style
- On ELF, protected visibility indicates that the symbol will be
+
+"`protected`" - Protected style
+: On ELF, protected visibility indicates that the symbol will be
placed in the dynamic symbol table, but that references within the
defining module will bind to the local symbol. That is, the symbol
cannot be overridden by another module.
-A symbol with ``internal`` or ``private`` linkage must have ``default``
+A symbol with `internal` or `private` linkage must have `default`
visibility.
-.. _dllstorageclass:
+(dllstorageclass)=
-DLL Storage Classes
--------------------
+### DLL Storage Classes
All Global Variables, Functions and Aliases can have one of the following
DLL storage classes:
-``dllimport``
- "``dllimport``" causes the compiler to reference a function or variable via
+`dllimport`
+: "`dllimport`" causes the compiler to reference a function or variable via
a global pointer to a pointer that is set up by the DLL exporting the
symbol. On Microsoft Windows targets, the pointer name is formed by
- combining ``__imp_`` and the function or variable name.
-``dllexport``
- On Microsoft Windows targets, "``dllexport``" causes the compiler to provide
+ combining `__imp_` and the function or variable name.
+
+`dllexport`
+: On Microsoft Windows targets, "`dllexport`" causes the compiler to provide
a global pointer to a pointer in a DLL, so that it can be referenced with the
- ``dllimport`` attribute. The pointer name is formed by combining ``__imp_``
- and the function or variable name. On XCOFF targets, ``dllexport`` indicates
+ `dllimport` attribute. The pointer name is formed by combining `__imp_`
+ and the function or variable name. On XCOFF targets, `dllexport` indicates
that the symbol will be made visible to other modules using "exported"
visibility and thus placed by the linker in the loader section symbol table.
Since this storage class exists for defining a DLL interface, the compiler,
assembler and linker know it is externally referenced and must refrain from
deleting the symbol.
-A symbol with ``internal`` or ``private`` linkage cannot have a DLL storage
+A symbol with `internal` or `private` linkage cannot have a DLL storage
class.
-.. _tls_model:
+(tls_model)=
-Thread Local Storage Models
----------------------------
+### Thread Local Storage Models
-A variable may be defined as ``thread_local``, which means that it will
+A variable may be defined as `thread_local`, which means that it will
not be shared by threads (each thread will have a separate copy of the
variable). Not all targets support thread-local variables. Optionally, a
TLS model may be specified:
-``localdynamic``
- For variables that are only used within the current shared library.
-``initialexec``
- For variables in modules that will not be loaded dynamically.
-``localexec``
- For variables defined in the executable and only used within it.
+`localdynamic`
+: For variables that are only used within the current shared library.
+
+`initialexec`
+: For variables in modules that will not be loaded dynamically.
+
+`localexec`
+: For variables defined in the executable and only used within it.
If no explicit model is given, the "general dynamic" model is used.
-The models correspond to the ELF TLS models; see `ELF Handling For
-Thread-Local Storage <http://people.redhat.com/drepper/tls.pdf>`_ for
+The models correspond to the ELF TLS models; see [ELF Handling For
+Thread-Local Storage](http://people.redhat.com/drepper/tls.pdf) for
more information on under which circumstances the different models may
be used. The target may choose a different TLS model if the specified
model is not supported, or if a better choice of model can be made.
@@ -615,50 +625,46 @@ model is not supported, or if a better choice of model can be made.
A model can also be specified in an alias, but then it only governs how
the alias is accessed. It will not have any effect on the aliasee.
-For platforms without linker support of ELF TLS model, the ``-femulated-tls``
+For platforms without linker support of ELF TLS model, the `-femulated-tls`
flag can be used to generate GCC-compatible emulated TLS code.
-.. _runtime_preemption_model:
+(runtime_preemption_model)=
-Runtime Preemption Specifiers
------------------------------
+### Runtime Preemption Specifiers
Global variables, functions and aliases may have an optional runtime preemption
specifier. If a preemption specifier isn't given explicitly, then a
-symbol is assumed to be ``dso_preemptable``.
+symbol is assumed to be `dso_preemptable`.
-``dso_preemptable``
- Indicates that the function or variable may be replaced by a symbol from
+`dso_preemptable`
+: Indicates that the function or variable may be replaced by a symbol from
outside the linkage unit at runtime.
-``dso_local``
- The compiler may assume that a function or variable marked as ``dso_local``
+`dso_local`
+: The compiler may assume that a function or variable marked as `dso_local`
will resolve to a symbol within the same linkage unit. Direct access will
be generated even if the definition is not within this compilation unit.
-.. _namedtypes:
+(namedtypes)=
-Structure Types
----------------
+### Structure Types
-LLVM IR allows you to specify both "identified" and "literal" :ref:`structure
-types <t_struct>`. Literal types are uniqued structurally, but identified types
-are never uniqued. An :ref:`opaque structural type <t_opaque>` can also be used
+LLVM IR allows you to specify both "identified" and "literal" {ref}`structure types <t_struct>`. Literal types are uniqued structurally, but identified types
+are never uniqued. An {ref}`opaque structural type <t_opaque>` can also be used
to forward declare a type that is not yet available.
An example of an identified structure specification is:
-.. code-block:: llvm
-
- %mytype = type { %mytype*, i32 }
+```llvm
+%mytype = type { %mytype*, i32 }
+```
Prior to the LLVM 3.0 release, identified types were structurally uniqued. Only
literal types are uniqued in recent versions of LLVM.
-.. _nointptrtype:
+(nointptrtype)=
-Non-Integral Pointer Type
--------------------------
+### Non-Integral Pointer Type
Note: non-integral pointer types are a work in progress, and they should be
considered experimental at this time.
@@ -676,14 +682,13 @@ Non-integral pointers have at least one of the following three properties:
* the pointer representation has external state
These properties (or combinations thereof) can be applied to pointers via the
-:ref:`datalayout string<langref_datalayout>`.
+{ref}`datalayout string<langref_datalayout>`.
The exact implications of these properties are target-specific. The following
subsections describe the IR semantics and restrictions to optimization passes
for each of these properties.
-Pointers with non-address bits
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Pointers with non-address bits
Pointers in this address space have a bitwise representation that not only
has address bits, but also some other target-specific metadata.
@@ -699,8 +704,7 @@ same number of metadata bits, but unlike the AMDGPU buffer descriptors they have
external state in addition to non-address bits.
-Unstable pointer representation
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Unstable pointer representation
Pointers in this address space have an *unspecified* bitwise representation
(i.e., not backed by a fixed integer). The bitwise pattern of such pointers is
@@ -708,7 +712,7 @@ allowed to change in a target-specific way. For example, this could be a pointer
type used with copying garbage collection where the garbage collector could
update the pointer at any time in the collection sweep.
-``inttoptr`` and ``ptrtoint`` instructions have the same semantics as for
+`inttoptr` and `ptrtoint` instructions have the same semantics as for
integral (i.e., normal) pointers in that they convert integers to and from
corresponding pointer types, but there are additional implications to be aware
of.
@@ -721,10 +725,10 @@ defined manner.
If the frontend wishes to observe a *particular* value following a cast, the
generated IR must fence with the underlying environment in an implementation
-defined manner. (In practice, this tends to require ``noinline`` routines for
+defined manner. (In practice, this tends to require `noinline` routines for
such operations.)
-From the perspective of the optimizer, ``inttoptr`` and ``ptrtoint`` for
+From the perspective of the optimizer, `inttoptr` and `ptrtoint` for
"unstable" pointer types are analogous to ones on integral types with one
key exception: the optimizer may not, in general, insert new dynamic
occurrences of such casts. If a new cast is inserted, the optimizer would
@@ -732,16 +736,15 @@ need to either ensure that a) all possible values are valid, or b)
appropriate fencing is inserted. Since the appropriate fencing is
implementation defined, the optimizer can't do the latter. The former is
challenging as many commonly expected properties, such as
-``ptrtoint(v)-ptrtoint(v) == 0``, don't hold for "unstable" pointer types.
+`ptrtoint(v)-ptrtoint(v) == 0`, don't hold for "unstable" pointer types.
Similar restrictions apply to intrinsics that might examine the pointer bits,
-such as :ref:`llvm.ptrmask<int_ptrmask>`.
+such as {ref}`llvm.ptrmask<int_ptrmask>`.
The alignment information provided by the frontend for an "unstable" pointer
(typically using attributes or metadata) must be valid for every possible
representation of the pointer.
-Pointers with external state
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Pointers with external state
A further special case of non-integral pointers is ones that include external
state (such as bounds information or a type tag) with a target-defined size.
@@ -752,49 +755,48 @@ Another example would be a fat-pointer scheme where pointers remain plain
integers, but the associated bounds are stored in an out-of-band table.
Unless also marked as "unstable", the bit-wise representation of pointers with
-external state is stable and ``ptrtoint(x)`` always yields a deterministic
+external state is stable and `ptrtoint(x)` always yields a deterministic
value. This means transformation passes are still permitted to insert new
-``ptrtoint`` instructions.
+`ptrtoint` instructions.
The following restrictions apply to IR level optimization passes:
-The ``inttoptr`` instruction does not recreate the external state and therefore
+The `inttoptr` instruction does not recreate the external state and therefore
it is target dependent whether it can be used to create a dereferenceable
-pointer. In general passes should assume that the result of such an ``inttoptr``
-is not dereferenceable. For example, on CHERI targets an ``inttoptr`` will
+pointer. In general passes should assume that the result of such an `inttoptr`
+is not dereferenceable. For example, on CHERI targets an `inttoptr` will
yield a capability with the external state (the validity tag bit) set to zero,
which will cause any dereference to trap.
-The ``ptrtoint`` instruction also only returns the "in-band" state and omits
+The `ptrtoint` instruction also only returns the "in-band" state and omits
all external state.
-When a ``store ptr addrspace(N) %p, ptr @dst`` of such a non-integral pointer
+When a `store ptr addrspace(N) %p, ptr @dst` of such a non-integral pointer
is performed, the external metadata is also stored to an implementation-defined
-location. Similarly, a ``%val = load ptr addrspace(N), ptr @dst`` will fetch the
-external metadata and make it available for all uses of ``%val``.
-Similarly, the ``llvm.memcpy`` and ``llvm.memmove`` intrinsics also transfer the
+location. Similarly, a `%val = load ptr addrspace(N), ptr @dst` will fetch the
+external metadata and make it available for all uses of `%val`.
+Similarly, the `llvm.memcpy` and `llvm.memmove` intrinsics also transfer the
external state. This is essential to allow frontends to efficiently emit copies
of structures containing such pointers, since expanding all these copies as
individual loads and stores would affect compilation speed and inhibit
optimizations.
Notionally, these external bits are part of the pointer, but since
-``inttoptr`` / ``ptrtoint``` only operate on the "in-band" bits of the pointer
+`inttoptr` / `ptrtoint` only operate on the "in-band" bits of the pointer
and the external bits are not explicitly exposed, they are not included in the
-size specified in the :ref:`datalayout string<langref_datalayout>`.
+size specified in the {ref}`datalayout string<langref_datalayout>`.
When a pointer type has external state, all roundtrips via memory must
be performed as loads and stores of the correct type since stores of other
types may not propagate the external data.
Therefore it is not legal to convert an existing load/store (or a
-``llvm.memcpy`` / ``llvm.memmove`` intrinsic) of pointer types with external
+`llvm.memcpy` / `llvm.memmove` intrinsic) of pointer types with external
state to a load/store of an integer or byte type with the same bitwidth, as that
may drop the external state.
-.. _globalvars:
+(globalvars)=
-Global Variables
-----------------
+### Global Variables
Global variables define regions of memory allocated at compilation time
instead of run-time.
@@ -804,18 +806,18 @@ Global variable definitions must be initialized with a sized value.
Global variables in other translation units can also be declared, in which
case they don't have an initializer.
-Global variables can optionally specify a :ref:`linkage type <linkage>`.
+Global variables can optionally specify a {ref}`linkage type <linkage>`.
Either global variable definitions or declarations may have an explicit section
to be placed in and may have an optional explicit alignment specified. If there
is a mismatch between the explicit or inferred section information for the
variable declaration and its definition, the resulting behavior is undefined.
-A variable may be defined as a global ``constant``, which indicates that
+A variable may be defined as a global `constant`, which indicates that
the contents of the variable will **never** be modified (enabling better
optimization, allowing the global data to be placed in the read-only
section of an executable, etc). Note that variables that need runtime
-initialization cannot be marked ``constant`` as there is a store to the
+initialization cannot be marked `constant` as there is a store to the
variable.
LLVM explicitly allows *declarations* of global variables to be marked
@@ -828,29 +830,29 @@ units that do not include the definition.
As SSA values, global variables define pointer values that are in scope
for (i.e., they dominate) all basic blocks in the program. Global variables
always define a pointer to their "content" type because they describe a
-region of memory, and all :ref:`allocated object<allocatedobjects>` in LLVM are
+region of memory, and all {ref}`allocated object<allocatedobjects>` in LLVM are
accessed through pointers.
-Global variables can be marked with ``unnamed_addr`` which indicates that
+Global variables can be marked with `unnamed_addr` which indicates that
the address is not significant, only the content. Constants marked like
this can be merged with other constants if they have the same initializer,
and can also be duplicated. Note that a constant with significant address
-*can* be merged with a ``unnamed_addr`` constant, the result being a
+*can* be merged with a `unnamed_addr` constant, the result being a
constant whose address is significant.
-.. warning::
-
- Constant duplication currently makes it unsound to compare pointers
- if either may be ``unnamed_addr``, because each reference to the
- global in the IR may return a different pointer, and optimization
- passes may create additional references. Optimization passes can also
- create pointer comparisons with the expectation that the comparison
- will return true if the object is the same, which theoretically can
- make any usage of ``unnamed_addr`` unsound, but in practice it is
- unlikely that input IR that does not explicitly compare pointers
- will be affected by this issue.
-
-If the ``local_unnamed_addr`` attribute is given, the address is known to
+```{warning}
+Constant duplication currently makes it unsound to compare pointers
+if either may be `unnamed_addr`, because each reference to the
+global in the IR may return a different pointer, and optimization
+passes may create additional references. Optimization passes can also
+create pointer comparisons with the expectation that the comparison
+will return true if the object is the same, which theoretically can
+make any usage of `unnamed_addr` unsound, but in practice it is
+unlikely that input IR that does not explicitly compare pointers
+will be affected by this issue.
+```
+
+If the `local_unnamed_addr` attribute is given, the address is known to
not be significant within the module.
A global variable may be declared to reside in a target-specific
@@ -882,8 +884,8 @@ variables defined within the module are not modified from their
initial values before the start of the global initializer. This is
true even for variables potentially accessible from outside the
module, including those with external linkage or appearing in
-``@llvm.used`` or dllexported variables. This assumption may be suppressed
-by marking the variable with ``externally_initialized``.
+`@llvm.used` or dllexported variables. This assumption may be suppressed
+by marking the variable with `externally_initialized`.
An explicit alignment may be specified for a global, which must be a
power of 2. If not present, or if the alignment is set to zero, the
@@ -894,148 +896,153 @@ to over-align the global if the global has an assigned section. In this
case, the extra alignment could be observable: for example, code could
assume that the globals are densely packed in their section and try to
iterate over them as an array, alignment padding would break this
-iteration. For TLS variables, the module flag ``MaxTLSAlign``, if present,
+iteration. For TLS variables, the module flag `MaxTLSAlign`, if present,
limits the alignment to the given value. Optimizers are not allowed to
impose a stronger alignment on these variables. The maximum alignment
-is ``1 << 32``.
+is `1 << 32`.
For global variable declarations, as well as definitions that may be
-replaced at link time (``linkonce``, ``weak``, ``extern_weak`` and ``common``
+replaced at link time (`linkonce`, `weak`, `extern_weak` and `common`
linkage types), the allocation size and alignment of the definition it resolves
to must be greater than or equal to that of the declaration or replaceable
definition, otherwise the behavior is undefined.
-Globals can also have a :ref:`DLL storage class <dllstorageclass>`,
-an optional :ref:`runtime preemption specifier <runtime_preemption_model>`,
-an optional :ref:`global attributes <glattrs>` and
-an optional list of attached :ref:`metadata <metadata>`.
+Globals can also have a {ref}`DLL storage class <dllstorageclass>`,
+an optional {ref}`runtime preemption specifier <runtime_preemption_model>`,
+an optional {ref}`global attributes <glattrs>` and
+an optional list of attached {ref}`metadata <metadata>`.
Variables and aliases can have a
-:ref:`Thread Local Storage Model <tls_model>`.
+{ref}`Thread Local Storage Model <tls_model>`.
-Globals cannot be or contain :ref:`Scalable vectors <t_vector>` because their
+Globals cannot be or contain {ref}`Scalable vectors <t_vector>` because their
size is unknown at compile time. They are allowed in structs to facilitate
intrinsics returning multiple values. Generally, structs containing scalable
vectors are not considered "sized" and cannot be used in loads, stores, allocas,
or GEPs. The only exception to this rule is for structs that contain scalable
-vectors of the same type (e.g., ``{<vscale x 2 x i32>, <vscale x 2 x i32>}``
-contains the same type while ``{<vscale x 2 x i32>, <vscale x 2 x i64>}``
+vectors of the same type (e.g., `{<vscale x 2 x i32>, <vscale x 2 x i32>}`
+contains the same type while `{<vscale x 2 x i32>, <vscale x 2 x i64>}`
doesn't). These kinds of structs (we may call them homogeneous scalable vector
structs) are considered sized and can be used in loads, stores, allocas, but
not GEPs.
-Globals with ``toc-data`` attribute set are stored in TOC of XCOFF. Their
+Globals with `toc-data` attribute set are stored in TOC of XCOFF. Their
alignments are not larger than that of a TOC entry. Optimizations should not
increase their alignments to mitigate TOC overflow.
-Syntax::
-
- @<GlobalVarName> = [Linkage] [PreemptionSpecifier] [Visibility]
- [DLLStorageClass] [ThreadLocal]
- [(unnamed_addr|local_unnamed_addr)] [AddrSpace]
- [ExternallyInitialized]
- <global | constant> <Type> [<InitializerConstant>]
- [, section "name"] [, partition "name"]
- [, comdat [($name)]] [, align <Alignment>]
- [, code_model "model"]
- [, no_sanitize_address] [, no_sanitize_hwaddress]
- [, sanitize_address_dyninit] [, sanitize_memtag]
- (, !name !N)*
+Syntax:
+```
+@<GlobalVarName> = [Linkage] [PreemptionSpecifier] [Visibility]
+ [DLLStorageClass] [ThreadLocal]
+ [(unnamed_addr|local_unnamed_addr)] [AddrSpace]
+ [ExternallyInitialized]
+ <global | constant> <Type> [<InitializerConstant>]
+ [, section "name"] [, partition "name"]
+ [, comdat [($name)]] [, align <Alignment>]
+ [, code_model "model"]
+ [, no_sanitize_address] [, no_sanitize_hwaddress]
+ [, sanitize_address_dyninit] [, sanitize_memtag]
+ (, !name !N)*
+```
For example, the following defines a global in a numbered address space
with an initializer, section, and alignment:
-.. code-block:: llvm
-
- @G = addrspace(5) constant float 1.0, section "foo", align 4
+```llvm
+ at G = addrspace(5) constant float 1.0, section "foo", align 4
+```
The following example just declares a global variable
-.. code-block:: llvm
-
- @G = external global i32
+```llvm
+ at G = external global i32
+```
The following example defines a global variable with the
-``large`` code model:
+`large` code model:
-.. code-block:: llvm
-
- @G = internal global i32 0, code_model "large"
+```llvm
+ at G = internal global i32 0, code_model "large"
+```
The following example defines a thread-local global with the
-``initialexec`` TLS model:
-
-.. code-block:: llvm
+`initialexec` TLS model:
- @G = thread_local(initialexec) global i32 0, align 4
+```llvm
+ at G = thread_local(initialexec) global i32 0, align 4
+```
-.. _functionstructure:
+(functionstructure)=
-Functions
----------
+### Functions
-LLVM function definitions consist of the "``define``" keyword, an
-optional :ref:`linkage type <linkage>`, an optional :ref:`runtime preemption
-specifier <runtime_preemption_model>`, an optional :ref:`visibility
-style <visibility>`, an optional :ref:`DLL storage class <dllstorageclass>`,
-an optional :ref:`calling convention <callingconv>`,
-an optional ``unnamed_addr`` attribute, a return type, an optional
-:ref:`parameter attribute <paramattrs>` for the return type, a function
-name, a (possibly empty) argument list (each with optional :ref:`parameter
-attributes <paramattrs>`), optional :ref:`function attributes <fnattrs>`,
+LLVM function definitions consist of the "`define`" keyword, an
+optional {ref}`linkage type <linkage>`, an optional {ref}`runtime preemption
+specifier <runtime_preemption_model>`, an optional {ref}`visibility
+style <visibility>`, an optional {ref}`DLL storage class <dllstorageclass>`,
+an optional {ref}`calling convention <callingconv>`,
+an optional `unnamed_addr` attribute, a return type, an optional
+{ref}`parameter attribute <paramattrs>` for the return type, a function
+name, a (possibly empty) argument list (each with optional {ref}`parameter
+attributes <paramattrs>`), optional {ref}`function attributes <fnattrs>`,
an optional address space, an optional section, an optional partition,
an optional minimum alignment,
an optional preferred alignment,
-an optional :ref:`comdat <langref_comdats>`,
-an optional :ref:`garbage collector name <gc>`, an optional :ref:`prefix <prefixdata>`,
-an optional :ref:`prologue <prologuedata>`,
-an optional :ref:`personality <personalityfn>`,
-an optional list of attached :ref:`metadata <metadata>`,
+an optional {ref}`comdat <langref_comdats>`,
+an optional {ref}`garbage collector name <gc>`, an optional {ref}`prefix <prefixdata>`,
+an optional {ref}`prologue <prologuedata>`,
+an optional {ref}`personality <personalityfn>`,
+an optional list of attached {ref}`metadata <metadata>`,
an opening curly brace, a list of basic blocks, and a closing curly brace.
-Syntax::
-
- define [linkage] [PreemptionSpecifier] [visibility] [DLLStorageClass]
- [cconv] [ret attrs]
- <ResultType> @<FunctionName> ([argument list])
- [(unnamed_addr|local_unnamed_addr)] [AddrSpace] [fn Attrs]
- [section "name"] [partition "name"] [comdat [($name)]] [align N]
- [prefalign(N)] [gc] [prefix Constant] [prologue Constant]
- [personality Constant] (!name !N)* { ... }
+Syntax:
+```
+define [linkage] [PreemptionSpecifier] [visibility] [DLLStorageClass]
+ [cconv] [ret attrs]
+ <ResultType> @<FunctionName> ([argument list])
+ [(unnamed_addr|local_unnamed_addr)] [AddrSpace] [fn Attrs]
+ [section "name"] [partition "name"] [comdat [($name)]] [align N]
+ [prefalign(N)] [gc] [prefix Constant] [prologue Constant]
+ [personality Constant] (!name !N)* { ... }
+```
The argument list is a comma-separated sequence of arguments where each
argument is of the following form:
-Syntax::
+Syntax:
- <type> [parameter Attrs] [name]
+```
+<type> [parameter Attrs] [name]
+```
-LLVM function declarations consist of the "``declare``" keyword, an
-optional :ref:`linkage type <linkage>`, an optional :ref:`visibility style
-<visibility>`, an optional :ref:`DLL storage class <dllstorageclass>`, an
-optional :ref:`calling convention <callingconv>`, an optional ``unnamed_addr``
-or ``local_unnamed_addr`` attribute, an optional address space, a return type,
-an optional :ref:`parameter attribute <paramattrs>` for the return type, a function name, a possibly
-empty list of arguments, an optional alignment, an optional :ref:`garbage
-collector name <gc>`, an optional :ref:`prefix <prefixdata>`, and an optional
-:ref:`prologue <prologuedata>`.
+LLVM function declarations consist of the "`declare`" keyword, an
+optional {ref}`linkage type <linkage>`, an optional {ref}`visibility style
+<visibility>`, an optional {ref}`DLL storage class <dllstorageclass>`, an
+optional {ref}`calling convention <callingconv>`, an optional `unnamed_addr`
+or `local_unnamed_addr` attribute, an optional address space, a return type,
+an optional {ref}`parameter attribute <paramattrs>` for the return type, a function name, a possibly
+empty list of arguments, an optional alignment, an optional {ref}`garbage
+collector name <gc>`, an optional {ref}`prefix <prefixdata>`, and an optional
+{ref}`prologue <prologuedata>`.
-Syntax::
+Syntax:
- declare [linkage] [visibility] [DLLStorageClass]
- [cconv] [ret attrs]
- <ResultType> @<FunctionName> ([argument list])
- [(unnamed_addr|local_unnamed_addr)] [align N] [gc]
- [prefix Constant] [prologue Constant]
+```
+declare [linkage] [visibility] [DLLStorageClass]
+ [cconv] [ret attrs]
+ <ResultType> @<FunctionName> ([argument list])
+ [(unnamed_addr|local_unnamed_addr)] [align N] [gc]
+ [prefix Constant] [prologue Constant]
+```
A function definition contains a list of basic blocks, forming the CFG (Control
Flow Graph) for the function. Each basic block may optionally start with a label
(giving the basic block a symbol table entry), contains a list of instructions
-and :ref:`debug records <debugrecords>`,
-and ends with a :ref:`terminator <terminators>` instruction (such as a branch or
+and {ref}`debug records <debugrecords>`,
+and ends with a {ref}`terminator <terminators>` instruction (such as a branch or
function return). If an explicit label name is not provided, a block is assigned
an implicit numbered label, using the next value from the same counter as used
-for unnamed temporaries (:ref:`see above<identifiers>`). For example, if a
+for unnamed temporaries ({ref}`see above<identifiers>`). For example, if a
function entry block does not have an explicit label, it will be assigned label
"%0", then the first unnamed temporary in that block will be "%1", etc. If a
numeric label is explicitly specified, it must match the numeric label that
@@ -1045,20 +1052,20 @@ The first basic block in a function is special in two ways: it is
immediately executed on entrance to the function, and it is not allowed
to have predecessor basic blocks (i.e., there can not be any branches to
the entry block of a function). Because the block can have no
-predecessors, it also cannot have any :ref:`PHI nodes <i_phi>`.
+predecessors, it also cannot have any {ref}`PHI nodes <i_phi>`.
LLVM allows an explicit section to be specified for functions. If the
target supports it, it will emit functions to the section specified.
Additionally, the function can be placed in a COMDAT.
-An explicit minimum alignment (``align``) may be specified for a
+An explicit minimum alignment (`align`) may be specified for a
function. If not present, or if the alignment is set to zero, the
alignment of the function is set according to the preferred alignment
rules described below. If an explicit minimum alignment is specified, the
function is forced to have at least that much alignment. All alignments
must be a power of 2.
-An explicit preferred alignment (``prefalign``) may also be specified for
+An explicit preferred alignment (`prefalign`) may also be specified for
a function (definitions only, and must be a power of 2). If a function
does not have a preferred alignment attribute, the preferred alignment
is determined in a target-specific way. The preferred alignment, if
@@ -1066,19 +1073,18 @@ provided, is treated as a hint; the final alignment of the function will
generally be set to a value somewhere between the minimum alignment and
the preferred alignment.
-If the ``unnamed_addr`` attribute is given, the address is known to not
+If the `unnamed_addr` attribute is given, the address is known to not
be significant and two identical functions can be merged.
-If the ``local_unnamed_addr`` attribute is given, the address is known to
+If the `local_unnamed_addr` attribute is given, the address is known to
not be significant within the module.
If an explicit address space is not given, it will default to the program
-address space from the :ref:`datalayout string<langref_datalayout>`.
+address space from the {ref}`datalayout string<langref_datalayout>`.
-.. _langref_aliases:
+(langref_aliases)=
-Aliases
--------
+### Aliases
Aliases, unlike function or variables, don't create any new data. They
are just a new symbol and metadata for an existing position.
@@ -1086,26 +1092,28 @@ are just a new symbol and metadata for an existing position.
Aliases have a name and an aliasee that is either a global value or a
constant expression.
-Aliases may have an optional :ref:`linkage type <linkage>`, an optional
-:ref:`runtime preemption specifier <runtime_preemption_model>`, an optional
-:ref:`visibility style <visibility>`, an optional :ref:`DLL storage class
-<dllstorageclass>` and an optional :ref:`tls model <tls_model>`.
+Aliases may have an optional {ref}`linkage type <linkage>`, an optional
+{ref}`runtime preemption specifier <runtime_preemption_model>`, an optional
+{ref}`visibility style <visibility>`, an optional {ref}`DLL storage class
+<dllstorageclass>` and an optional {ref}`tls model <tls_model>`.
-Syntax::
+Syntax:
- @<Name> = [Linkage] [PreemptionSpecifier] [Visibility] [DLLStorageClass] [ThreadLocal] [(unnamed_addr|local_unnamed_addr)] alias <AliaseeTy>, <AliaseeTy>* @<Aliasee>
- [, partition "name"]
+```
+@<Name> = [Linkage] [PreemptionSpecifier] [Visibility] [DLLStorageClass] [ThreadLocal] [(unnamed_addr|local_unnamed_addr)] alias <AliaseeTy>, <AliaseeTy>* @<Aliasee>
+ [, partition "name"]
+```
-The linkage must be one of ``private``, ``internal``, ``linkonce``, ``weak``,
-``linkonce_odr``, ``weak_odr``, ``external``, ``available_externally``. Note
+The linkage must be one of `private`, `internal`, `linkonce`, `weak`,
+`linkonce_odr`, `weak_odr`, `external`, `available_externally`. Note
that some system linkers might not correctly handle dropping a weak symbol that
is aliased.
-Aliases that are not ``unnamed_addr`` are guaranteed to have the same address as
-the aliasee expression. ``unnamed_addr`` ones are only guaranteed to point
+Aliases that are not `unnamed_addr` are guaranteed to have the same address as
+the aliasee expression. `unnamed_addr` ones are only guaranteed to point
to the same content.
-If the ``local_unnamed_addr`` attribute is given, the address is known to
+If the `local_unnamed_addr` attribute is given, the address is known to
not be significant within the module.
Since aliases are only a second name, some restrictions apply, of which
@@ -1118,8 +1126,8 @@ some can only be checked when producing an object file:
intermediate alias being overridden cannot be represented in an
object file.
-* If the alias has the ``available_externally`` linkage, the aliasee must be an
- ``available_externally`` global value; otherwise the aliasee can be an
+* If the alias has the `available_externally` linkage, the aliasee must be an
+ `available_externally` global value; otherwise the aliasee can be an
expression but no global value in the expression can be a declaration, since
that would require a relocation, which is not possible.
@@ -1128,32 +1136,32 @@ some can only be checked when producing an object file:
the aliasee, since the behavior may be different. The alias may be used as a
name guaranteed to point to the content in the current module.
-.. _langref_ifunc:
+(langref_ifunc)=
-IFuncs
--------
+### IFuncs
IFuncs, like aliases, don't create any new data or func. They are just a new
symbol that is resolved at runtime by calling a resolver function.
On ELF platforms, IFuncs are resolved by the dynamic linker at load time. On
-Mach-O platforms, they are lowered in terms of ``.symbol_resolver`` functions,
+Mach-O platforms, they are lowered in terms of `.symbol_resolver` functions,
which lazily resolve the callee the first time they are called.
-IFunc may have an optional :ref:`linkage type <linkage>`, an optional
-:ref:`visibility style <visibility>`, an option partition, and an optional
-list of attached :ref:`metadata <metadata>`.
+IFunc may have an optional {ref}`linkage type <linkage>`, an optional
+{ref}`visibility style <visibility>`, an option partition, and an optional
+list of attached {ref}`metadata <metadata>`.
-Syntax::
- @<Name> = [Linkage] [PreemptionSpecifier] [Visibility] ifunc <IFuncTy>, <ResolverTy>* @<Resolver>
- [, partition "name"] (, !name !N)*
+Syntax:
+```
+@<Name> = [Linkage] [PreemptionSpecifier] [Visibility] ifunc <IFuncTy>, <ResolverTy>* @<Resolver>
+ [, partition "name"] (, !name !N)*
+```
-.. _langref_comdats:
+(langref_comdats)=
-Comdats
--------
+### Comdats
Comdat IR provides access to object file COMDAT/section group functionality
which represents interrelated sections.
@@ -1166,59 +1174,64 @@ Discarding the whole comdat is allowed but discarding a subset is not.
A global object may be a member of at most one comdat. Aliases are placed in the
same COMDAT that their aliasee computes to, if any.
-Syntax::
-
- $<Name> = comdat SelectionKind
+Syntax:
+```
+$<Name> = comdat SelectionKind
+```
-For selection kinds other than ``nodeduplicate``, only one of the duplicate
+For selection kinds other than `nodeduplicate`, only one of the duplicate
comdats may be retained by the linker and the members of the remaining comdats
must be discarded. The following selection kinds are supported:
-``any``
- The linker may choose any COMDAT key, the choice is arbitrary.
-``exactmatch``
- The linker may choose any COMDAT key but the sections must contain the
+`any`
+: The linker may choose any COMDAT key, the choice is arbitrary.
+
+`exactmatch`
+: The linker may choose any COMDAT key but the sections must contain the
same data.
-``largest``
- The linker will choose the section containing the largest COMDAT key.
-``nodeduplicate``
- No deduplication is performed.
-``samesize``
- The linker may choose any COMDAT key but the sections must contain the
+
+`largest`
+: The linker will choose the section containing the largest COMDAT key.
+
+`nodeduplicate`
+: No deduplication is performed.
+
+`samesize`
+: The linker may choose any COMDAT key but the sections must contain the
same amount of data.
- XCOFF and Mach-O don't support COMDATs.
-- COFF supports all selection kinds. Non-``nodeduplicate`` selection kinds need
+- COFF supports all selection kinds. Non-`nodeduplicate` selection kinds need
a non-local linkage COMDAT symbol.
-- ELF supports ``any`` and ``nodeduplicate``.
-- WebAssembly only supports ``any``.
+- ELF supports `any` and `nodeduplicate`.
+- WebAssembly only supports `any`.
Here is an example of a COFF COMDAT where a function will only be selected if
the COMDAT key's section is the largest:
-.. code-block:: text
+```text
+$foo = comdat largest
+ at foo = global i32 2, comdat($foo)
- $foo = comdat largest
- @foo = global i32 2, comdat($foo)
-
- define void @bar() comdat($foo) {
- ret void
- }
+define void @bar() comdat($foo) {
+ ret void
+}
+```
In a COFF object file, this will create a COMDAT section with selection kind
-``IMAGE_COMDAT_SELECT_LARGEST`` containing the contents of the ``@foo`` symbol
+`IMAGE_COMDAT_SELECT_LARGEST` containing the contents of the `@foo` symbol
and another COMDAT section with selection kind
-``IMAGE_COMDAT_SELECT_ASSOCIATIVE`` which is associated with the first COMDAT
-section and contains the contents of the ``@bar`` symbol.
+`IMAGE_COMDAT_SELECT_ASSOCIATIVE` which is associated with the first COMDAT
+section and contains the contents of the `@bar` symbol.
-As a syntactic sugar the ``$name`` can be omitted if the name is the same as
+As a syntactic sugar the `$name` can be omitted if the name is the same as
the global name:
-.. code-block:: llvm
-
- $foo = comdat any
- @foo = global i32 2, comdat
- @bar = global i32 3, comdat($foo)
+```llvm
+$foo = comdat any
+ at foo = global i32 2, comdat
+ at bar = global i32 3, comdat($foo)
+```
There are some restrictions on the properties of the global object.
It, or an alias to it, must have the same name as the COMDAT group when
@@ -1232,12 +1245,12 @@ if a collision occurs in the symbol table.
The combined use of COMDATS and section attributes may yield surprising results.
For example:
-.. code-block:: llvm
-
- $foo = comdat any
- $bar = comdat any
- @g1 = global i32 42, section "sec", comdat($foo)
- @g2 = global i32 42, section "sec", comdat($bar)
+```llvm
+$foo = comdat any
+$bar = comdat any
+ at g1 = global i32 42, section "sec", comdat($foo)
+ at g2 = global i32 42, section "sec", comdat($bar)
+```
From the object file perspective, this requires the creation of two sections
with the same name. This is necessary because both globals belong to different
@@ -1250,33 +1263,32 @@ COMDAT IR. This arises when the code generator is configured to emit globals
in individual sections (e.g., when `-data-sections` or `-function-sections`
is supplied to `llc`).
-.. _namedmetadatastructure:
+(namedmetadatastructure)=
-Named Metadata
---------------
+### Named Metadata
-Named metadata is a collection of metadata. :ref:`Metadata
+Named metadata is a collection of metadata. {ref}`Metadata
nodes <metadata>` (but not metadata strings) are the only valid
operands for a named metadata.
-#. Named metadata are represented as a string of characters with the
+1. Named metadata are represented as a string of characters with the
metadata prefix. The rules for metadata names are the same as for
- identifiers, but quoted names are not allowed. ``"\xx"`` type escapes
+ identifiers, but quoted names are not allowed. `"\xx"` type escapes
are still valid, which allows any character to be part of a name.
-Syntax::
-
- ; Some unnamed metadata nodes, which are referenced by the named metadata.
- !0 = !{!"zero"}
- !1 = !{!"one"}
- !2 = !{!"two"}
- ; A named metadata.
- !name = !{!0, !1, !2}
+Syntax:
+```
+; Some unnamed metadata nodes, which are referenced by the named metadata.
+!0 = !{!"zero"}
+!1 = !{!"one"}
+!2 = !{!"two"}
+; A named metadata.
+!name = !{!0, !1, !2}
+```
-.. _paramattrs:
+(paramattrs)=
-Parameter Attributes
---------------------
+### Parameter Attributes
The return type and each parameter of a function type may have a set of
*parameter attributes* associated with them. Parameter attributes are
@@ -1290,26 +1302,26 @@ Parameter attributes are either simple keywords or strings that follow the
specified type. Multiple parameter attributes, when required, are separated by
spaces. For example:
-.. code-block:: llvm
-
- ; On function declarations/definitions:
- declare i32 @printf(ptr noalias captures(none), ...)
- declare i32 @atoi(i8 zeroext)
- declare signext i8 @returns_signed_char()
- define void @baz(i32 "amdgpu-flat-work-group-size"="1,256" %x)
+```llvm
+; On function declarations/definitions:
+declare i32 @printf(ptr noalias captures(none), ...)
+declare i32 @atoi(i8 zeroext)
+declare signext i8 @returns_signed_char()
+define void @baz(i32 "amdgpu-flat-work-group-size"="1,256" %x)
- ; On call-sites:
- call i32 @atoi(i8 zeroext %x)
- call signext i8 @returns_signed_char()
+; On call-sites:
+call i32 @atoi(i8 zeroext %x)
+call signext i8 @returns_signed_char()
+```
-Note that any attributes for the function result (``nonnull``,
-``signext``) come before the result type.
+Note that any attributes for the function result (`nonnull`,
+`signext`) come before the result type.
Parameter attributes can be broadly separated into two kinds: ABI attributes
-that affect how values are passed to/from functions, like ``zeroext``,
-``inreg``, ``byval``, or ``sret``. And optimization attributes, which provide
-additional optimization guarantees, like ``noalias``, ``nonnull`` and
-``dereferenceable``.
+that affect how values are passed to/from functions, like `zeroext`,
+`inreg`, `byval`, or `sret`. And optimization attributes, which provide
+additional optimization guarantees, like `noalias`, `nonnull` and
+`dereferenceable`.
ABI attributes must be specified *both* at the function declaration/definition
and call-site, otherwise the behavior may be undefined. ABI attributes cannot
@@ -1323,129 +1335,131 @@ correctness on the kind of extension to be explicitly specified.
Currently, only the following parameter attributes are defined:
-``zeroext``
- This indicates to the code generator that the parameter or return
+`zeroext`
+: This indicates to the code generator that the parameter or return
value should be zero-extended to the extent required by the target's
ABI by the caller (for a parameter) or the callee (for a return value).
-``signext``
- This indicates to the code generator that the parameter or return
+
+`signext`
+: This indicates to the code generator that the parameter or return
value should be sign-extended to the extent required by the target's
ABI (which is usually 32-bits) by the caller (for a parameter) or
the callee (for a return value).
-``noext``
- This indicates to the code generator that the parameter or return
+
+`noext`
+: This indicates to the code generator that the parameter or return
value has the high bits undefined, as for a struct in a register, and
therefore does not need to be sign or zero extended. This is the same
as default behavior and is only actually used (by some targets) to
validate that one of the attributes is always present.
-``inreg``
- This indicates that this parameter or return value should be treated
+
+`inreg`
+: This indicates that this parameter or return value should be treated
in a special target-dependent fashion while emitting code for
a function call or return (usually, by putting it in a register as
opposed to memory, though some targets use it to distinguish between
two different kinds of registers). Use of this attribute is
target-specific.
-``byval(<ty>)``
- This indicates that the pointer parameter should really be passed by
+
+`byval(<ty>)`
+: This indicates that the pointer parameter should really be passed by
value to the function. The attribute implies that a hidden copy of
the pointee is made between the caller and the callee, so the callee
is unable to modify the value in the caller. This attribute is only
valid on LLVM pointer arguments. It is generally used to pass
structs and arrays by value, but is also valid on pointers to
scalars. The copy is considered to belong to the caller not the
- callee (for example, ``readonly`` functions should not write to
- ``byval`` parameters). This is not a valid attribute for return
+ callee (for example, `readonly` functions should not write to
+ `byval` parameters). This is not a valid attribute for return
values.
The byval type argument indicates the in-memory value type.
The byval attribute also supports specifying an alignment with the
- ``align`` attribute. It indicates the alignment of the stack slot to
+ `align` attribute. It indicates the alignment of the stack slot to
form and the known alignment of the pointer specified to the call
site. If the alignment is not specified, then the code generator
makes a target-specific assumption.
-.. _attr_byref:
+(attr_byref)=
-``byref(<ty>)``
-
- The ``byref`` argument attribute allows specifying the pointee
- memory type of an argument. This is similar to ``byval``, but does
+`byref(<ty>)`
+: The `byref` argument attribute allows specifying the pointee
+ memory type of an argument. This is similar to `byval`, but does
not imply a copy is made anywhere, or that the argument is passed
on the stack. This implies the pointer is dereferenceable up to
the storage size of the type.
It is not generally permissible to introduce a write to a
- ``byref`` pointer. The pointer may have any address space and may
+ `byref` pointer. The pointer may have any address space and may
be read only.
This is not a valid attribute for return values.
- The alignment for a ``byref`` parameter can be explicitly
- specified by combining it with the ``align`` attribute, similar to
- ``byval``. If the alignment is not specified, then the code generator
+ The alignment for a `byref` parameter can be explicitly
+ specified by combining it with the `align` attribute, similar to
+ `byval`. If the alignment is not specified, then the code generator
makes a target-specific assumption.
This is intended for representing ABI constraints, and is not
intended to be inferred for optimization use.
-.. _attr_preallocated:
+(attr_preallocated)=
-``preallocated(<ty>)``
- This indicates that the pointer parameter should really be passed by
+`preallocated(<ty>)`
+: This indicates that the pointer parameter should really be passed by
value to the function, and that the pointer parameter's pointee has
already been initialized before the call instruction. This attribute
is only valid on LLVM pointer arguments. The argument must be the value
returned by the appropriate
- :ref:`llvm.call.preallocated.arg<int_call_preallocated_arg>` on non
- ``musttail`` calls, or the corresponding caller parameter in ``musttail``
+ {ref}`llvm.call.preallocated.arg<int_call_preallocated_arg>` on non
+ `musttail` calls, or the corresponding caller parameter in `musttail`
calls, although it is ignored during codegen.
- A non ``musttail`` function call with a ``preallocated`` attribute in
- any parameter must have a ``"preallocated"`` operand bundle. A ``musttail``
- function call cannot have a ``"preallocated"`` operand bundle.
+ A non `musttail` function call with a `preallocated` attribute in
+ any parameter must have a `"preallocated"` operand bundle. A `musttail`
+ function call cannot have a `"preallocated"` operand bundle.
The preallocated attribute requires a type argument.
The preallocated attribute also supports specifying an alignment with the
- ``align`` attribute. It indicates the alignment of the stack slot to
+ `align` attribute. It indicates the alignment of the stack slot to
form and the known alignment of the pointer specified to the call
site. If the alignment is not specified, then the code generator
makes a target-specific assumption.
-.. _attr_inalloca:
-
-``inalloca(<ty>)``
+(attr_inalloca)=
- The ``inalloca`` argument attribute allows the caller to take the
- address of outgoing stack arguments. An ``inalloca`` argument must
- be a pointer to stack memory produced by an ``alloca`` instruction.
+`inalloca(<ty>)`
+: The `inalloca` argument attribute allows the caller to take the
+ address of outgoing stack arguments. An `inalloca` argument must
+ be a pointer to stack memory produced by an `alloca` instruction.
The alloca, or argument allocation, must also be tagged with the
- inalloca keyword. Only the last argument may have the ``inalloca``
+ inalloca keyword. Only the last argument may have the `inalloca`
attribute, and that argument is guaranteed to be passed in memory.
An argument allocation may be used by a call at most once because
- the call may deallocate it. The ``inalloca`` attribute cannot be
+ the call may deallocate it. The `inalloca` attribute cannot be
used in conjunction with other attributes that affect argument
- storage, like ``inreg``, ``nest``, ``sret``, or ``byval``. The
- ``inalloca`` attribute also disables LLVM's implicit lowering of
+ storage, like `inreg`, `nest`, `sret`, or `byval`. The
+ `inalloca` attribute also disables LLVM's implicit lowering of
large aggregate return values, which means that frontend authors
- must lower them with ``sret`` pointers.
+ must lower them with `sret` pointers.
When the call site is reached, the argument allocation must have
been the most recent stack allocation that is still live, or the
behavior is undefined. It is possible to allocate additional stack
space after an argument allocation and before its call site, but it
- must be cleared off with :ref:`llvm.stackrestore
+ must be cleared off with {ref}`llvm.stackrestore
<int_stackrestore>`.
- The ``inalloca`` attribute requires a type argument.
+ The `inalloca` attribute requires a type argument.
- See :doc:`InAlloca` for more information on how to use this
+ See {doc}`InAlloca` for more information on how to use this
attribute.
-``sret(<ty>)``
- This indicates that the pointer parameter specifies the address of a
+`sret(<ty>)`
+: This indicates that the pointer parameter specifies the address of a
structure that is the return value of the function in the source
program. This pointer must be guaranteed by the caller to be valid:
loads and stores to the structure may be assumed by the callee not
@@ -1453,18 +1467,17 @@ Currently, only the following parameter attributes are defined:
The sret type argument specifies the in-memory type.
- A function that accepts an ``sret`` argument must return ``void``.
- A return value may not be ``sret``.
+ A function that accepts an `sret` argument must return `void`.
+ A return value may not be `sret`.
-.. _attr_elementtype:
+(attr_elementtype)=
-``elementtype(<ty>)``
+`elementtype(<ty>)`
+: The `elementtype` argument attribute can be used to specify a pointer
+ element type in a way that is compatible with {doc}`opaque pointers
+ <OpaquePointers>`.
- The ``elementtype`` argument attribute can be used to specify a pointer
- element type in a way that is compatible with `opaque pointers
- <OpaquePointers.html>`__.
-
- The ``elementtype`` attribute by itself does not carry any specific
+ The `elementtype` attribute by itself does not carry any specific
semantics. However, certain intrinsics may require this attribute to be
present and assign it particular semantics. This will be documented on
individual intrinsics.
@@ -1472,29 +1485,29 @@ Currently, only the following parameter attributes are defined:
The attribute may only be applied to pointer typed arguments or return
values of intrinsic calls. It cannot be applied to non-intrinsic calls,
and cannot be applied to parameters on function declarations.
- For non-opaque pointers, the type passed to ``elementtype`` must match
+ For non-opaque pointers, the type passed to `elementtype` must match
the pointer element type.
-.. _attr_align:
+(attr_align)=
-``align <n>`` or ``align(<n>)``
- This indicates that the pointer value or vector of pointers has the
+`align <n>` or `align(<n>)`
+: This indicates that the pointer value or vector of pointers has the
specified alignment. If applied to a vector of pointers, *all* pointers
(elements) have the specified alignment. If the pointer value does not have
- the specified alignment, :ref:`poison value <poisonvalues>` is returned or
- passed instead. The ``align`` attribute should be combined with the
- ``noundef`` attribute to ensure a pointer is aligned, or otherwise the
- behavior is undefined. Note that ``align 1`` has no effect on non-byval,
+ the specified alignment, {ref}`poison value <poisonvalues>` is returned or
+ passed instead. The `align` attribute should be combined with the
+ `noundef` attribute to ensure a pointer is aligned, or otherwise the
+ behavior is undefined. Note that `align 1` has no effect on non-byval,
non-preallocated arguments.
Note that this attribute has additional semantics when combined with the
- ``byval`` or ``preallocated`` attribute, which are documented there.
+ `byval` or `preallocated` attribute, which are documented there.
-.. _noalias:
+(noalias)=
-``noalias``
- This indicates that memory locations accessed via pointer values
- :ref:`based <pointeraliasing>` on the argument or return value are not also
+`noalias`
+: This indicates that memory locations accessed via pointer values
+ {ref}`based <pointeraliasing>` on the argument or return value are not also
accessed, during the execution of the function, via pointer values not
*based* on the argument or return value. This guarantee only holds for
memory locations that are *modified*, by any means, during the execution of
@@ -1503,62 +1516,62 @@ Currently, only the following parameter attributes are defined:
also has additional semantics, as described below. Both the caller and the
callee share the responsibility of ensuring that these requirements are
met. For further details, please see the discussion of the NoAlias response
- in :ref:`alias analysis <Must, May, or No>`.
+ in {ref}`alias analysis <Must, May, or No>`.
- Note that this definition of ``noalias`` is intentionally similar
- to the definition of ``restrict`` in C99 for function arguments.
+ Note that this definition of `noalias` is intentionally similar
+ to the definition of `restrict` in C99 for function arguments.
- For function return values, C99's ``restrict`` is not meaningful,
- while LLVM's ``noalias`` is. Furthermore, the semantics of the ``noalias``
+ For function return values, C99's `restrict` is not meaningful,
+ while LLVM's `noalias` is. Furthermore, the semantics of the `noalias`
attribute on return values are stronger than the semantics of the attribute
- when used on function arguments. On function return values, the ``noalias``
+ when used on function arguments. On function return values, the `noalias`
attribute indicates that the function acts like a system memory allocation
function, returning a pointer to allocated storage disjoint from the
storage for any other object accessible to the caller.
-.. _captures_attr:
+(captures_attr)=
-``captures(...)``
- This attribute restricts the ways in which the callee may capture the
+`captures(...)`
+: This attribute restricts the ways in which the callee may capture the
pointer. This is not a valid attribute for return values. This attribute
applies only to the particular copy of the pointer passed in this argument.
- The arguments of ``captures`` are a list of captured pointer components,
- which may be ``none``, or a combination of:
+ The arguments of `captures` are a list of captured pointer components,
+ which may be `none`, or a combination of:
- - ``address``: The integral address of the pointer.
- - ``address_is_null`` (subset of ``address``): Whether the address is null.
- - ``provenance``: The ability to access the pointer for both read and write
+ - `address`: The integral address of the pointer.
+ - `address_is_null` (subset of `address`): Whether the address is null.
+ - `provenance`: The ability to access the pointer for both read and write
after the function returns.
- - ``read_provenance`` (subset of ``provenance``): The ability to access the
+ - `read_provenance` (subset of `provenance`): The ability to access the
pointer only for reads after the function returns.
Additionally, it is possible to specify that some components are only
- captured in certain locations. Currently only the return value (``ret``)
+ captured in certain locations. Currently only the return value (`ret`)
and other (default) locations are supported.
- The :ref:`pointer capture section <pointercapture>` discusses these semantics
+ The {ref}`pointer capture section <pointercapture>` discusses these semantics
in more detail.
Some examples of how to use the attribute:
- - ``captures(none)``: Pointer not captured.
- - ``captures(address, provenance)``: Equivalent to omitting the attribute.
- - ``captures(address)``: Address may be captured, but not provenance.
- - ``captures(address_is_null)``: Only captures whether the address is null.
- - ``captures(address, read_provenance)``: Both address and provenance
+ - `captures(none)`: Pointer not captured.
+ - `captures(address, provenance)`: Equivalent to omitting the attribute.
+ - `captures(address)`: Address may be captured, but not provenance.
+ - `captures(address_is_null)`: Only captures whether the address is null.
+ - `captures(address, read_provenance)`: Both address and provenance
captured, but only for read-only access.
- - ``captures(ret: address, provenance)``: Pointer captured through return
+ - `captures(ret: address, provenance)`: Pointer captured through return
value only.
- - ``captures(address_is_null, ret: address, provenance)``: The whole pointer
+ - `captures(address_is_null, ret: address, provenance)`: The whole pointer
is captured through the return value, and additionally whether the pointer
is null is captured in some other way.
-``nofree``
- This indicates that a pointer based on this argument cannot be freed during
+`nofree`
+: This indicates that a pointer based on this argument cannot be freed during
the execution of the function.
- More formally, a ``nofree`` argument provides the callee with a new pointer
+ More formally, a `nofree` argument provides the callee with a new pointer
with the same address and a derived provenance, where the derived
provenance has the same permissions as the original, except that the
underlying object cannot be freed until the function returns (or unwinds),
@@ -1570,194 +1583,212 @@ Currently, only the following parameter attributes are defined:
This is not a valid attribute for return values.
-.. _nest:
+(nest)=
-``nest``
- This indicates that the pointer parameter can be excised using the
- :ref:`trampoline intrinsics <int_trampoline>`. This is not a valid
+`nest`
+: This indicates that the pointer parameter can be excised using the
+ {ref}`trampoline intrinsics <int_trampoline>`. This is not a valid
attribute for return values and can only be applied to one parameter.
-``returned``
- This indicates that the function always returns the argument as its return
+`returned`
+: This indicates that the function always returns the argument as its return
value. This is a hint to the optimizer and code generator used when
generating the caller, allowing value propagation, tail call optimization,
and omission of register saves and restores in some cases; it is not
checked or enforced when generating the callee. The parameter and the
function return type must be valid operands for the
- :ref:`bitcast instruction <i_bitcast>`. This is not a valid attribute for
+ {ref}`bitcast instruction <i_bitcast>`. This is not a valid attribute for
return values and can only be applied to one parameter.
-.. _attr_nonnull:
+(attr_nonnull)=
-``nonnull``
- This indicates that the parameter or return pointer is not null. This
+`nonnull`
+: This indicates that the parameter or return pointer is not null. This
attribute may only be applied to pointer-typed parameters. This is not
checked or enforced by LLVM; if the parameter or return pointer is null,
- :ref:`poison value <poisonvalues>` is returned or passed instead.
- The ``nonnull`` attribute only refers to the address bits of the pointers.
+ {ref}`poison value <poisonvalues>` is returned or passed instead.
+ The `nonnull` attribute only refers to the address bits of the pointers.
If all the address bits are zero, the result will be a poison value, even
if the pointer has non-zero non-address bits or non-zero external state.
- The ``nonnull`` attribute should be combined with the ``noundef`` attribute
+ The `nonnull` attribute should be combined with the `noundef` attribute
to ensure a pointer is not null or otherwise the behavior is undefined.
-.. _attr_dereferenceable:
+(attr_dereferenceable)=
-``dereferenceable(<n>)``
- This indicates that the parameter or return pointer is dereferenceable. This
+`dereferenceable(<n>)`
+: This indicates that the parameter or return pointer is dereferenceable. This
attribute may only be applied to pointer-typed parameters. A pointer that
is dereferenceable can be loaded from speculatively without a risk of
trapping. The number of bytes known to be dereferenceable must be provided
- in parentheses. The ``nonnull`` attribute does not imply dereferenceability
+ in parentheses. The `nonnull` attribute does not imply dereferenceability
(consider a pointer to one element past the end of an array), however
- ``dereferenceable(<n>)`` does imply ``nonnull`` in ``addrspace(0)``
+ `dereferenceable(<n>)` does imply `nonnull` in `addrspace(0)`
(which is the default address space), except if the
- ``null_pointer_is_valid`` function attribute is present.
- ``n`` should be a positive number. The pointer should be well defined,
- otherwise it is undefined behavior. This means ``dereferenceable(<n>)``
- implies ``noundef``.
+ `null_pointer_is_valid` function attribute is present.
+ `n` should be a positive number. The pointer should be well defined,
+ otherwise it is undefined behavior. This means `dereferenceable(<n>)`
+ implies `noundef`.
-.. _attr_dereferenceable_or_null:
+(attr_dereferenceable_or_null)=
-``dereferenceable_or_null(<n>)``
- This indicates that the parameter or return value isn't both
- non-null and non-dereferenceable (up to ``<n>`` bytes) at the same
+`dereferenceable_or_null(<n>)`
+: This indicates that the parameter or return value isn't both
+ non-null and non-dereferenceable (up to `<n>` bytes) at the same
time. All non-null pointers tagged with
- ``dereferenceable_or_null(<n>)`` are ``dereferenceable(<n>)``.
- For address space 0 ``dereferenceable_or_null(<n>)`` implies that
- a pointer is exactly one of ``dereferenceable(<n>)`` or ``null``,
- and in other address spaces ``dereferenceable_or_null(<n>)``
- implies that a pointer is at least one of ``dereferenceable(<n>)``
- or ``null`` (i.e., it may be both ``null`` and
- ``dereferenceable(<n>)``). This attribute may only be applied to
+ `dereferenceable_or_null(<n>)` are `dereferenceable(<n>)`.
+ For address space 0 `dereferenceable_or_null(<n>)` implies that
+ a pointer is exactly one of `dereferenceable(<n>)` or `null`,
+ and in other address spaces `dereferenceable_or_null(<n>)`
+ implies that a pointer is at least one of `dereferenceable(<n>)`
+ or `null` (i.e., it may be both `null` and
+ `dereferenceable(<n>)`). This attribute may only be applied to
pointer-typed parameters.
-``swiftself``
- This indicates that the parameter is the self/context parameter. This is not
+`swiftself`
+: This indicates that the parameter is the self/context parameter. This is not
a valid attribute for return values and can only be applied to one
parameter.
-.. _swiftasync:
+(swiftasync)=
-``swiftasync``
- This indicates that the parameter is the asynchronous context parameter and
+`swiftasync`
+: This indicates that the parameter is the asynchronous context parameter and
triggers the creation of a target-specific extended frame record to store
this pointer. This is not a valid attribute for return values and can only
be applied to one parameter.
-``swifterror``
- This attribute is motivated to model and optimize Swift error handling. It
+`swifterror`
+: This attribute is motivated to model and optimize Swift error handling. It
can be applied to a parameter with pointer-to-pointer type or a
pointer-sized alloca. At the call site, the actual argument that corresponds
- to a ``swifterror`` parameter has to come from a ``swifterror`` alloca or
- the ``swifterror`` parameter of the caller. A ``swifterror`` value (either
+ to a `swifterror` parameter has to come from a `swifterror` alloca or
+ the `swifterror` parameter of the caller. A `swifterror` value (either
the parameter or the alloca) can only be loaded and stored from, or used as
- a ``swifterror`` argument. This is not a valid attribute for return values
+ a `swifterror` argument. This is not a valid attribute for return values
and can only be applied to one parameter.
These constraints allow the calling convention to optimize access to
- ``swifterror`` variables by associating them with a specific register at
+ `swifterror` variables by associating them with a specific register at
call boundaries rather than placing them in memory. Since this does change
- the calling convention, a function which uses the ``swifterror`` attribute
+ the calling convention, a function which uses the `swifterror` attribute
on a parameter is not ABI-compatible with one which does not.
- These constraints also allow LLVM to assume that a ``swifterror`` argument
+ These constraints also allow LLVM to assume that a `swifterror` argument
does not alias any other memory visible within a function and that a
- ``swifterror`` alloca passed as an argument does not escape.
+ `swifterror` alloca passed as an argument does not escape.
-``immarg``
- This indicates the parameter is required to be an immediate
+`immarg`
+: This indicates the parameter is required to be an immediate
value. This must be a trivial immediate integer or floating-point
constant. Undef or constant expressions are not valid. This is
only valid on intrinsic declarations and cannot be applied to a
call site or arbitrary function.
-.. _attr_noundef:
+(attr_noundef)=
-``noundef``
- This attribute applies to parameters and return values. If the value
+`noundef`
+: This attribute applies to parameters and return values. If the value
representation contains any undefined or poison bits, the behavior is
undefined. Note that this does not refer to padding introduced by the
type's storage representation.
- If memory sanitizer is enabled, ``noundef`` becomes an ABI attribute and
+ If memory sanitizer is enabled, `noundef` becomes an ABI attribute and
must match between the call-site and the function definition.
-.. _nofpclass:
+(nofpclass)=
-``nofpclass(<test mask>)``
- This attribute applies to parameters and return values with
+`nofpclass(<test mask>)`
+: This attribute applies to parameters and return values with
floating-point and vector of floating-point types, as well as
- :ref:`supported aggregates <fastmath_return_types>` of such types
- (matching the supported types for :ref:`fast-math flags <fastmath>`).
+ {ref}`supported aggregates <fastmath_return_types>` of such types
+ (matching the supported types for {ref}`fast-math flags <fastmath>`).
The test mask has the same format as the second argument to the
- :ref:`llvm.is.fpclass <llvm.is.fpclass>`, and indicates which classes
+ {ref}`llvm.is.fpclass <llvm.is.fpclass>`, and indicates which classes
of floating-point values are not permitted for the value. For example,
a bitmask of 3 indicates the parameter may not be a NaN.
If the value is a floating-point class indicated by the
- ``nofpclass`` test mask, a :ref:`poison value <poisonvalues>` is
+ `nofpclass` test mask, a {ref}`poison value <poisonvalues>` is
passed or returned instead.
-.. code-block:: text
- :caption: The following invariants hold
-
- @llvm.is.fpclass(nofpclass(test_mask) %x, test_mask) => false
- @llvm.is.fpclass(nofpclass(test_mask) %x, ~test_mask) => true
- nofpclass(all) => poison
-..
-
- In textual IR, various string names are supported for readability
- and can be combined. For example ``nofpclass(nan pinf nzero)``
- evaluates to a mask of 547.
-
- This does not depend on the floating-point environment. For
- example, a function parameter marked ``nofpclass(zero)`` indicates
- no zero inputs. If this is applied to an argument in a function
- marked with :ref:`denormal_fpenv <denormal_fpenv>`
- indicating zero treatment of input denormals, it does not imply the
- value cannot be a denormal value which would compare equal to 0.
-
-.. table:: Recognized test mask names
-
- +-------+----------------------+---------------+
- | Name | floating-point class | Bitmask value |
- +=======+======================+===============+
- | nan | Any NaN | 3 |
- +-------+----------------------+---------------+
- | inf | +/- infinity | 516 |
- +-------+----------------------+---------------+
- | norm | +/- normal | 264 |
- +-------+----------------------+---------------+
- | sub | +/- subnormal | 144 |
- +-------+----------------------+---------------+
- | zero | +/- 0 | 96 |
- +-------+----------------------+---------------+
- | all | All values | 1023 |
- +-------+----------------------+---------------+
- | snan | Signaling NaN | 1 |
- +-------+----------------------+---------------+
- | qnan | Quiet NaN | 2 |
- +-------+----------------------+---------------+
- | ninf | Negative infinity | 4 |
- +-------+----------------------+---------------+
- | nnorm | Negative normal | 8 |
- +-------+----------------------+---------------+
- | nsub | Negative subnormal | 16 |
- +-------+----------------------+---------------+
- | nzero | Negative zero | 32 |
- +-------+----------------------+---------------+
- | pzero | Positive zero | 64 |
- +-------+----------------------+---------------+
- | psub | Positive subnormal | 128 |
- +-------+----------------------+---------------+
- | pnorm | Positive normal | 256 |
- +-------+----------------------+---------------+
- | pinf | Positive infinity | 512 |
- +-------+----------------------+---------------+
-
-
-``alignstack(<n>)``
- This indicates the alignment that should be considered by the backend when
+ ```{code-block} text
+ :caption: The following invariants hold
+
+ @llvm.is.fpclass(nofpclass(test_mask) %x, test_mask) => false
+ @llvm.is.fpclass(nofpclass(test_mask) %x, ~test_mask) => true
+ nofpclass(all) => poison
+ ```
+
+
+ In textual IR, various string names are supported for readability
+ and can be combined. For example `nofpclass(nan pinf nzero)`
+ evaluates to a mask of 547.
+
+ This does not depend on the floating-point environment. For
+ example, a function parameter marked `nofpclass(zero)` indicates
+ no zero inputs. If this is applied to an argument in a function
+ marked with {ref}`denormal_fpenv <denormal_fpenv>`
+ indicating zero treatment of input denormals, it does not imply the
+ value cannot be a denormal value which would compare equal to 0.
+
+ ```{list-table} Recognized test mask names
+ :header-rows: 1
+
+ * - Name
+ - floating-point class
+ - Bitmask value
+ * - nan
+ - Any NaN
+ - 3
+ * - inf
+ - +/- infinity
+ - 516
+ * - norm
+ - +/- normal
+ - 264
+ * - sub
+ - +/- subnormal
+ - 144
+ * - zero
+ - +/- 0
+ - 96
+ * - all
+ - All values
+ - 1023
+ * - snan
+ - Signaling NaN
+ - 1
+ * - qnan
+ - Quiet NaN
+ - 2
+ * - ninf
+ - Negative infinity
+ - 4
+ * - nnorm
+ - Negative normal
+ - 8
+ * - nsub
+ - Negative subnormal
+ - 16
+ * - nzero
+ - Negative zero
+ - 32
+ * - pzero
+ - Positive zero
+ - 64
+ * - psub
+ - Positive subnormal
+ - 128
+ * - pnorm
+ - Positive normal
+ - 256
+ * - pinf
+ - Positive infinity
+ - 512
+ ```
+
+`alignstack(<n>)`
+: This indicates the alignment that should be considered by the backend when
assigning this parameter or return value to a stack slot during calling
convention lowering. The enforcement of the specified alignment is
target-dependent, as target-specific calling convention rules may override
@@ -1765,74 +1796,74 @@ Currently, only the following parameter attributes are defined:
alignment information that is not mapped to base types in the backend (for
example, over-alignment specification through language attributes).
-``allocalign``
- The function parameter marked with this attribute is the alignment in bytes of the
+`allocalign`
+: The function parameter marked with this attribute is the alignment in bytes of the
newly allocated block returned by this function. The returned value must either have
the specified alignment or be the null pointer. The return value MAY be more aligned
than the requested alignment, but not less aligned. Invalid (e.g., non-power-of-2)
alignments are permitted for the allocalign parameter, so long as the returned pointer
is null. This attribute may only be applied to integer parameters.
-``allocptr``
- The function parameter marked with this attribute is the pointer
+`allocptr`
+: The function parameter marked with this attribute is the pointer
that will be manipulated by the allocator. For a realloc-like
function the pointer will be invalidated upon success (but the
same address may be returned), for a free-like function the
pointer will always be invalidated.
-``readnone``
- This attribute indicates that the function does not dereference that
+`readnone`
+: This attribute indicates that the function does not dereference that
pointer argument, even though it may read or write the memory that the
pointer points to if accessed through other pointers.
If a function reads from or writes to a readnone pointer argument, the
behavior is undefined.
-``readonly``
- This attribute indicates that the function does not write through this
+`readonly`
+: This attribute indicates that the function does not write through this
pointer argument, even though it may write to the memory that the pointer
points to.
If a function writes to a readonly pointer argument, the behavior is
undefined.
-``writeonly``
- This attribute indicates that the function may write to, but does not read
+`writeonly`
+: This attribute indicates that the function may write to, but does not read
through this pointer argument (even though it may read from the memory that
the pointer points to).
- This attribute is understood in the same way as the ``memory(write)``
+ This attribute is understood in the same way as the `memory(write)`
attribute. That is, the pointer may still be read as long as the read is
- not observable outside the function. See the ``memory`` documentation for
+ not observable outside the function. See the `memory` documentation for
precise semantics.
-``writable``
- This attribute is only meaningful in conjunction with ``dereferenceable(N)``
- or another attribute that implies the first ``N`` bytes of the pointer
+`writable`
+: This attribute is only meaningful in conjunction with `dereferenceable(N)`
+ or another attribute that implies the first `N` bytes of the pointer
argument are dereferenceable.
- In that case, the attribute indicates that the first ``N`` bytes will be
+ In that case, the attribute indicates that the first `N` bytes will be
(non-atomically) loaded and stored back on entry to the function.
This implies that it's possible to introduce spurious stores on entry to
the function without introducing traps or data races. This does not
necessarily hold throughout the whole function, as the pointer may escape
to a different thread during the execution of the function. See also the
- :ref:`atomic optimization guide <Optimization outside atomic>`
+ {ref}`atomic optimization guide <Optimization outside atomic>`
The "other attributes" that imply dereferenceability are
- ``dereferenceable_or_null`` (if the pointer is non-null) and the
- ``sret``, ``byval``, ``byref``, ``inalloca``, ``preallocated`` family of
+ `dereferenceable_or_null` (if the pointer is non-null) and the
+ `sret`, `byval`, `byref`, `inalloca`, `preallocated` family of
attributes. Note that not all of these combinations are useful, e.g.
- ``byval`` arguments are known to be writable even without this attribute.
+ `byval` arguments are known to be writable even without this attribute.
- The ``writable`` attribute cannot be combined with ``readnone``,
- ``readonly`` or a ``memory`` attribute that does not contain
- ``argmem: write``.
+ The `writable` attribute cannot be combined with `readnone`,
+ `readonly` or a `memory` attribute that does not contain
+ `argmem: write`.
-``initializes((Lo1, Hi1), ...)``
- This attribute indicates that the function initializes the ranges of the
- pointer parameter's memory ``[%p+LoN, %p+HiN)``. Colloquially, this means
+`initializes((Lo1, Hi1), ...)`
+: This attribute indicates that the function initializes the ranges of the
+ pointer parameter's memory `[%p+LoN, %p+HiN)`. Colloquially, this means
that all bytes in the specified range are written before the function
returns, and not read prior to the initializing write. If the function
unwinds, the write may not happen.
@@ -1855,22 +1886,22 @@ Currently, only the following parameter attributes are defined:
parameter. Other arbitrary accesses to the same memory via other pointers
are allowed.
- The ``writable`` or ``dereferenceable`` attribute do not imply the
- ``initializes`` attribute. The ``initializes`` attribute does not imply
- ``writeonly`` since ``initializes`` allows reading from the pointer
+ The `writable` or `dereferenceable` attribute do not imply the
+ `initializes` attribute. The `initializes` attribute does not imply
+ `writeonly` since `initializes` allows reading from the pointer
after writing.
This attribute is a list of constant ranges in ascending order with no
- overlapping or consecutive list elements. ``LoN/HiN`` are 64-bit integers,
+ overlapping or consecutive list elements. `LoN/HiN` are 64-bit integers,
and negative values are allowed in case the argument points partway into
an allocation. An empty list is not allowed.
- On a ``byval`` argument, ``initializes`` refers to the given parts of the
- callee copy being overwritten. A ``byval`` callee can never initialize the
- original caller memory passed to the ``byval`` argument.
+ On a `byval` argument, `initializes` refers to the given parts of the
+ callee copy being overwritten. A `byval` callee can never initialize the
+ original caller memory passed to the `byval` argument.
-``dead_on_unwind``
- At a high level, this attribute indicates that the pointer argument is dead
+`dead_on_unwind`
+: At a high level, this attribute indicates that the pointer argument is dead
if the call unwinds, in the sense that the caller will not depend on the
contents of the memory. Stores that would only be visible on the unwind
path can be elided.
@@ -1878,13 +1909,13 @@ Currently, only the following parameter attributes are defined:
More precisely, the behavior is as-if any memory written through the
pointer during the execution of the function is overwritten with a poison
value on unwind. This includes memory written by the implicit write implied
- by the ``writable`` attribute. The caller is allowed to access the affected
+ by the `writable` attribute. The caller is allowed to access the affected
memory, but all loads that are not preceded by a store will return poison.
This attribute cannot be applied to return values.
-``dead_on_return`` or ``dead_on_return(<n>)``
- This attribute indicates that the memory pointed to by the argument is dead
+`dead_on_return` or `dead_on_return(<n>)`
+: This attribute indicates that the memory pointed to by the argument is dead
upon function return, both upon normal return and if the calls unwinds, meaning
that the caller will not depend on its contents. Stores that would be observable
either on the return path or on the unwind path may be elided. A number of
@@ -1900,52 +1931,50 @@ Currently, only the following parameter attributes are defined:
function return.
This attribute does not imply aliasing properties. For pointer arguments that
- do not alias other memory locations, ``noalias`` attribute may be used in
- conjunction. Conversely, this attribute always implies ``dead_on_unwind``. When
- a byte count is specified, ``dead_on_unwind`` is implied only for that range.
+ do not alias other memory locations, `noalias` attribute may be used in
+ conjunction. Conversely, this attribute always implies `dead_on_unwind`. When
+ a byte count is specified, `dead_on_unwind` is implied only for that range.
This attribute cannot be applied to return values.
-``range(<ty> <a>, <b>)``
- This attribute expresses the possible range of the parameter or return value.
+`range(<ty> <a>, <b>)`
+: This attribute expresses the possible range of the parameter or return value.
If the value is not in the specified range, it is converted to poison.
- The arguments passed to ``range`` have the following properties:
+ The arguments passed to `range` have the following properties:
- The type must match the scalar type of the parameter or return value.
- - The pair ``a,b`` represents the range ``[a,b)``.
- - Both ``a`` and ``b`` are constants.
+ - The pair `a,b` represents the range `[a,b)`.
+ - Both `a` and `b` are constants.
- The range is allowed to wrap.
- - The empty range is represented using ``0,0``.
- - Otherwise, ``a`` and ``b`` are not allowed to be equal.
+ - The empty range is represented using `0,0`.
+ - Otherwise, `a` and `b` are not allowed to be equal.
This attribute may only be applied to parameters or return values with integer
or vector of integer types.
For vector-typed parameters, the range is applied element-wise.
-.. _gc:
+(gc)=
-Garbage Collector Strategy Names
---------------------------------
+### Garbage Collector Strategy Names
Each function may specify a garbage collector strategy name, which is simply a
string:
-.. code-block:: llvm
+```llvm
+define void @f() gc "name" { ... }
+```
- define void @f() gc "name" { ... }
-
-The supported values of *name* include those :ref:`built in to LLVM
+The supported values of *name* include those {ref}`built in to LLVM
<builtin-gc-strategies>` and any provided by loaded plugins. Specifying a GC
strategy will cause the compiler to alter its output in order to support the
named garbage collection algorithm. Note that LLVM itself does not contain a
garbage collector, this functionality is restricted to generating machine code
which can interoperate with a collector provided externally.
-.. _prefixdata:
+(prefixdata)=
-Prefix Data
------------
+### Prefix Data
Prefix data is data associated with a function which the code
generator will emit immediately before the function's entrypoint.
@@ -1958,18 +1987,18 @@ To access the data for a given function, a program may bitcast the
function pointer to a pointer to the constant's type and dereference
index -1. This implies that the IR symbol points just past the end of
the prefix data. For instance, take the example of a function annotated
-with a single ``i32``,
-
-.. code-block:: llvm
+with a single `i32`,
- define void @f() prefix i32 123 { ... }
+```llvm
+define void @f() prefix i32 123 { ... }
+```
The prefix data can be referenced as,
-.. code-block:: llvm
-
- %a = getelementptr inbounds i32, ptr @f, i32 -1
- %b = load i32, ptr %a
+```llvm
+%a = getelementptr inbounds i32, ptr @f, i32 -1
+%b = load i32, ptr %a
+```
Prefix data is laid out as if it were an initializer for a global variable
of the prefix data's type. The function will be placed such that the
@@ -1980,15 +2009,14 @@ function's entrypoint is desired, padding must be added to the prefix
data.
A function may have prefix data but no body. This has similar semantics
-to the ``available_externally`` linkage in that the data may be used by the
+to the `available_externally` linkage in that the data may be used by the
optimizers but will not be emitted in the object file.
-.. _prologuedata:
+(prologuedata)=
-Prologue Data
--------------
+### Prologue Data
-The ``prologue`` attribute allows arbitrary code (encoded as bytes) to
+The `prologue` attribute allows arbitrary code (encoded as bytes) to
be inserted prior to the function body. This can be used for enabling
function hot-patching and instrumentation.
@@ -2001,69 +2029,66 @@ the inliner and other passes to reason about the semantics of the function
definition without needing to reason about the prologue data. Obviously this
makes the format of the prologue data highly target dependent.
-A trivial example of valid prologue data for the x86 architecture is ``i8 144``,
-which encodes the ``nop`` instruction:
-
-.. code-block:: text
+A trivial example of valid prologue data for the x86 architecture is `i8 144`,
+which encodes the `nop` instruction:
- define void @f() prologue i8 144 { ... }
+```text
+define void @f() prologue i8 144 { ... }
+```
Generally prologue data can be formed by encoding a relative branch instruction
which skips the metadata, as in this example of valid prologue data for the
-x86_64 architecture, where the first two bytes encode ``jmp .+10``:
+x86_64 architecture, where the first two bytes encode `jmp .+10`:
-.. code-block:: text
+```text
+%0 = type <{ i8, i8, ptr }>
- %0 = type <{ i8, i8, ptr }>
-
- define void @f() prologue %0 <{ i8 235, i8 8, ptr @md}> { ... }
+define void @f() prologue %0 <{ i8 235, i8 8, ptr @md}> { ... }
+```
A function may have prologue data but no body. This has similar semantics
-to the ``available_externally`` linkage in that the data may be used by the
+to the `available_externally` linkage in that the data may be used by the
optimizers but will not be emitted in the object file.
-.. _personalityfn:
+(personalityfn)=
-Personality Function
---------------------
+### Personality Function
-The ``personality`` attribute permits functions to specify what function
+The `personality` attribute permits functions to specify what function
to use for exception handling.
-.. _attrgrp:
+(attrgrp)=
-Attribute Groups
-----------------
+### Attribute Groups
Attribute groups are groups of attributes that are referenced by objects within
-the IR. They are important for keeping ``.ll`` files readable, because a lot of
+the IR. They are important for keeping `.ll` files readable, because a lot of
functions will use the same set of attributes. In the degenerate case of a
-``.ll`` file that corresponds to a single ``.c`` file, the single attribute
+`.ll` file that corresponds to a single `.c` file, the single attribute
group will capture the important command line flags used to build that file.
An attribute group is a module-level object. To use an attribute group, an
-object references the attribute group's ID (e.g., ``#37``). An object may refer
+object references the attribute group's ID (e.g., `#37`). An object may refer
to more than one attribute group. In that situation, the attributes from the
different groups are merged.
Here is an example of attribute groups for a function that should always be
inlined, has a stack alignment of 4, and which shouldn't use SSE instructions:
-.. code-block:: llvm
-
- ; Target-independent attributes:
- attributes #0 = { alwaysinline alignstack=4 }
+```llvm
+; Target-independent attributes:
+attributes #0 = { alwaysinline alignstack=4 }
- ; Target-dependent attributes:
- attributes #1 = { "no-sse" }
+; Target-dependent attributes:
+attributes #1 = { "no-sse" }
- ; Function @f has attributes: alwaysinline, alignstack=4, and "no-sse".
- define void @f() #0 #1 { ... }
+; Function @f has attributes: alwaysinline, alignstack=4, and "no-sse".
+define void @f() #0 #1 { ... }
+```
-.. _fnattrs:
+(fnattrs)=
-Function Attributes
--------------------
+### Function Attributes
Function attributes are set to communicate additional information about
a function. Function attributes are considered to be part of the
@@ -2074,39 +2099,41 @@ Function attributes are simple keywords or strings that follow the specified
type. Multiple attributes, when required, are separated by spaces.
For example:
-.. code-block:: llvm
+```llvm
+define void @f() noinline { ... }
+define void @f() alwaysinline { ... }
+define void @f() alwaysinline optsize { ... }
+define void @f() optsize { ... }
+define void @f() "no-sse" { ... }
+```
- define void @f() noinline { ... }
- define void @f() alwaysinline { ... }
- define void @f() alwaysinline optsize { ... }
- define void @f() optsize { ... }
- define void @f() "no-sse" { ... }
-
-``alignstack(<n>)``
- This attribute indicates that, when emitting the prologue and
+`alignstack(<n>)`
+: This attribute indicates that, when emitting the prologue and
epilogue, the backend should forcibly align the stack pointer.
Specify the desired alignment, which must be a power of two, in
parentheses.
-``"alloc-family"="FAMILY"``
- This indicates which "family" an allocator function is part of. To avoid
+
+`"alloc-family"="FAMILY"`
+: This indicates which "family" an allocator function is part of. To avoid
collisions, the family name should match the mangled name of the primary
allocator function, that is "malloc" for malloc/calloc/realloc/free,
- "_Znwm" for ``::operator::new`` and ``::operator::delete``, and
- "_ZnwmSt11align_val_t" for aligned ``::operator::new`` and
- ``::operator::delete``. Matching malloc/realloc/free calls within a family
+ "_Znwm" for `::operator::new` and `::operator::delete`, and
+ "_ZnwmSt11align_val_t" for aligned `::operator::new` and
+ `::operator::delete`. Matching malloc/realloc/free calls within a family
can be optimized, but mismatched ones will be left alone.
-``allockind("KIND")``
- Describes the behavior of an allocation function. The KIND string contains
+
+`allockind("KIND")`
+: Describes the behavior of an allocation function. The KIND string contains
comma-separated entries from the following options:
* "alloc": the function returns a new block of memory or null.
* "realloc": the function returns a new block of memory or null. If the
result is non-null the memory contents from the start of the block up to
the smaller of the original allocation size and the new allocation size
- will match that of the ``allocptr`` argument and the ``allocptr``
+ will match that of the `allocptr` argument and the `allocptr`
argument is invalidated, even if the function returns the same address.
- * "free": the function frees the block of memory specified by ``allocptr``.
- Functions marked as "free" ``allockind`` must return void.
+ * "free": the function frees the block of memory specified by `allocptr`.
+ Functions marked as "free" `allockind` must return void.
* "uninitialized": Any newly-allocated memory (either a new block from
a "alloc" function or the enlarged capacity from a "realloc" function)
will be uninitialized.
@@ -2114,13 +2141,13 @@ For example:
function or the enlarged capacity from a "realloc" function) will be
zeroed.
* "aligned": the function returns memory aligned according to the
- ``allocalign`` parameter.
+ `allocalign` parameter.
The first three options are mutually exclusive, and the remaining options
describe more details of how the function behaves. The remaining options
are invalid for "free"-type functions.
- Calls to functions annotated with ``allockind`` are subject to allocation
+ Calls to functions annotated with `allockind` are subject to allocation
elision: Calls to allocator functions can be removed, and the allocation
served from a "virtual" allocator instead. Notably, this is allowed even if
the allocator calls have side-effects. In other words, for each allocation
@@ -2129,168 +2156,181 @@ For example:
If multiple allocation functions operate on the same allocation,
allocation elision is only allowed for pairs of "alloc" and "free" with the
- same ``"alloc-family"`` attribute. For this purpose, a "realloc" call may
+ same `"alloc-family"` attribute. For this purpose, a "realloc" call may
be decomposed into "alloc" and "free" operations, as long as at least one
of them will be elided.
-``"alloc-variant-zeroed"="FUNCTION"``
- This attribute indicates that another function is equivalent to an allocator function,
+
+`"alloc-variant-zeroed"="FUNCTION"`
+: This attribute indicates that another function is equivalent to an allocator function,
but returns zeroed memory. The function must have "zeroed" allocation behavior,
- the same ``alloc-family``, and take exactly the same arguments.
-``allocsize(<EltSizeParam>[, <NumEltsParam>])``
- This attribute indicates that the annotated function will always return at
+ the same `alloc-family`, and take exactly the same arguments.
+
+`allocsize(<EltSizeParam>[, <NumEltsParam>])`
+: This attribute indicates that the annotated function will always return at
least a given number of bytes (or null). Its arguments are zero-indexed
parameter numbers; if one argument is provided, then it's assumed that at
- least ``CallSite.Args[EltSizeParam]`` bytes will be available at the
+ least `CallSite.Args[EltSizeParam]` bytes will be available at the
returned pointer. If two are provided, then it's assumed that
- ``CallSite.Args[EltSizeParam] * CallSite.Args[NumEltsParam]`` bytes are
+ `CallSite.Args[EltSizeParam] * CallSite.Args[NumEltsParam]` bytes are
available. The referenced parameters must be integer types. No assumptions
are made about the contents of the returned block of memory.
-``alwaysinline``
- This attribute indicates that the inliner should attempt to inline
+
+`alwaysinline`
+: This attribute indicates that the inliner should attempt to inline
this function into callers whenever possible, ignoring any active
inlining size threshold for this caller.
-``builtin``
- This indicates that the callee function at a call site should be
+
+`builtin`
+: This indicates that the callee function at a call site should be
recognized as a built-in function, even though the function's declaration
- uses the ``nobuiltin`` attribute. This is only valid at call sites for
- direct calls to functions that are declared with the ``nobuiltin``
+ uses the `nobuiltin` attribute. This is only valid at call sites for
+ direct calls to functions that are declared with the `nobuiltin`
attribute.
-.. _attr_cold:
+(attr_cold)=
-``cold``
- This attribute indicates that this function is rarely called. When
+`cold`
+: This attribute indicates that this function is rarely called. When
computing edge weights, basic blocks post-dominated by a cold
function call are also considered to be cold and, thus, given a low
weight.
-.. _attr_convergent:
+(attr_convergent)=
-``convergent``
- This attribute indicates that this function is convergent.
+`convergent`
+: This attribute indicates that this function is convergent.
When it appears on a call/invoke, the convergent attribute
indicates that we should treat the call as though we’re calling a
convergent function. This is particularly useful on indirect
calls; without this we may treat such calls as though the target
is non-convergent.
- See :doc:`ConvergentOperations` for further details.
+ See {doc}`ConvergentOperations` for further details.
- It is an error to call :ref:`llvm.experimental.convergence.entry
+ It is an error to call {ref}`llvm.experimental.convergence.entry
<llvm.experimental.convergence.entry>` from a function that
does not have this attribute.
-``disable_sanitizer_instrumentation``
- When instrumenting code with sanitizers, it can be important to skip certain
+
+`disable_sanitizer_instrumentation`
+: When instrumenting code with sanitizers, it can be important to skip certain
functions to ensure no instrumentation is applied to them.
- This attribute is not always similar to absent ``sanitize_<name>``
+ This attribute is not always similar to absent `sanitize_<name>`
attributes: depending on the specific sanitizer, code can be inserted into
- functions regardless of the ``sanitize_<name>`` attribute to prevent false
+ functions regardless of the `sanitize_<name>` attribute to prevent false
positive reports.
- ``disable_sanitizer_instrumentation`` disables all kinds of instrumentation,
- taking precedence over the ``sanitize_<name>`` attributes and other compiler
+ `disable_sanitizer_instrumentation` disables all kinds of instrumentation,
+ taking precedence over the `sanitize_<name>` attributes and other compiler
flags.
-``"dontcall-error"``
- This attribute denotes that an error diagnostic should be emitted when a
+
+`"dontcall-error"`
+: This attribute denotes that an error diagnostic should be emitted when a
call of a function with this attribute is not eliminated via optimization.
- Front ends can provide optional ``srcloc`` metadata nodes on call sites of
+ Front ends can provide optional `srcloc` metadata nodes on call sites of
such callees to attach information about where in the source language such a
call came from. A string value can be provided as a note.
-``"dontcall-warn"``
- This attribute denotes that a warning diagnostic should be emitted when a
+
+`"dontcall-warn"`
+: This attribute denotes that a warning diagnostic should be emitted when a
call of a function with this attribute is not eliminated via optimization.
- Front ends can provide optional ``srcloc`` metadata nodes on call sites of
+ Front ends can provide optional `srcloc` metadata nodes on call sites of
such callees to attach information about where in the source language such a
call came from. A string value can be provided as a note.
-``fn_ret_thunk_extern``
- This attribute tells the code generator that returns from functions should
+
+`fn_ret_thunk_extern`
+: This attribute tells the code generator that returns from functions should
be replaced with jumps to externally-defined architecture-specific symbols.
- For X86, this symbol's identifier is ``__x86_return_thunk``.
-``"frame-pointer"``
- This attribute tells the code generator whether the function
+ For X86, this symbol's identifier is `__x86_return_thunk`.
+
+`"frame-pointer"`
+: This attribute tells the code generator whether the function
should keep the frame pointer. The code generator may emit the frame pointer
even if this attribute says the frame pointer can be eliminated.
The allowed string values are:
- * ``"none"`` (default) - the frame pointer can be eliminated, and its
- register can be used for other purposes.
- * ``"reserved"`` - the frame pointer register must either be updated to
- point to a valid frame record for the current function, or not be
- modified.
- * ``"non-leaf"`` - the frame pointer should be kept if the function calls
- other functions.
- * ``"all"`` - the frame pointer should be kept.
-``hot``
- This attribute indicates that this function is a hot spot of the program
+ * `"none"` (default) - the frame pointer can be eliminated, and its
+ register can be used for other purposes.
+ * `"reserved"` - the frame pointer register must either be updated to
+ point to a valid frame record for the current function, or not be
+ modified.
+ * `"non-leaf"` - the frame pointer should be kept if the function calls
+ other functions.
+ * `"all"` - the frame pointer should be kept.
+
+`hot`
+: This attribute indicates that this function is a hot spot of the program
execution. The function will be optimized more aggressively and will be
placed into a special subsection of the text section to improve locality.
When profile feedback is enabled, this attribute takes precedence over
- the profile information. By marking a function ``hot``, users can work
+ the profile information. By marking a function `hot`, users can work
around the cases where the training input does not have good coverage
on all the hot functions.
-``inlinehint``
- This attribute indicates that the source code contained a hint that
+
+`inlinehint`
+: This attribute indicates that the source code contained a hint that
inlining this function is desirable (such as the "inline" keyword in
C/C++). It is just a hint; it imposes no requirements on the
inliner.
-``jumptable``
- This attribute indicates that the function should be added to a
+
+`jumptable`
+: This attribute indicates that the function should be added to a
jump-instruction table at code-generation time, and that all address-taken
references to this function should be replaced with a reference to the
appropriate jump-instruction-table function pointer. Note that this creates
a new pointer for the original function, which means that code that depends
on function-pointer identity can break. So, any function annotated with
- ``jumptable`` must also be ``unnamed_addr``.
-``memory(...)``
- This attribute specifies the possible memory effects of the call-site or
- function. It allows specifying the possible access kinds (``none``,
- ``read``, ``write``, or ``readwrite``) for the possible memory location
- kinds (``argmem``, ``inaccessiblemem``, ``errnomem``, ``target_mem0``,
- ``target_mem1``, as well as a default).
+ `jumptable` must also be `unnamed_addr`.
+
+`memory(...)`
+: This attribute specifies the possible memory effects of the call-site or
+ function. It allows specifying the possible access kinds (`none`,
+ `read`, `write`, or `readwrite`) for the possible memory location
+ kinds (`argmem`, `inaccessiblemem`, `errnomem`, `target_mem0`,
+ `target_mem1`, as well as a default).
It is best understood by example:
- - ``memory(none)``: Does not access any memory.
- - ``memory(read)``: May read (but not write) any memory.
- - ``memory(write)``: May write (but not read) any memory.
- - ``memory(readwrite)``: May read or write any memory.
- - ``memory(argmem: read)``: May only read argument memory.
- - ``memory(argmem: read, inaccessiblemem: write)``: May only read argument
+ - `memory(none)`: Does not access any memory.
+ - `memory(read)`: May read (but not write) any memory.
+ - `memory(write)`: May write (but not read) any memory.
+ - `memory(readwrite)`: May read or write any memory.
+ - `memory(argmem: read)`: May only read argument memory.
+ - `memory(argmem: read, inaccessiblemem: write)`: May only read argument
memory and only write inaccessible memory.
- - ``memory(argmem: read, errnomem: write)``: May only read argument memory
+ - `memory(argmem: read, errnomem: write)`: May only read argument memory
and only write errno.
- - ``memory(read, argmem: readwrite)``: May read any memory (default mode)
+ - `memory(read, argmem: readwrite)`: May read any memory (default mode)
and additionally write argument memory.
- - ``memory(readwrite, argmem: none)``: May access any memory apart from
+ - `memory(readwrite, argmem: none)`: May access any memory apart from
argument memory.
The supported access kinds are:
- - ``readwrite``: Any kind of access to the location is allowed.
- - ``read``: The location is only read. Writing to the location is immediate
+ - `readwrite`: Any kind of access to the location is allowed.
+ - `read`: The location is only read. Writing to the location is immediate
undefined behavior. This includes the case where the location is read from
and then the same value is written back.
- - ``write``: Only writes to the location are observable outside the function
+ - `write`: Only writes to the location are observable outside the function
call. However, the function may still internally read the location after
writing it, as this is not observable. Reading the location prior to
writing it results in a poison value.
- - ``none``: No reads or writes to the location are observed outside the
+ - `none`: No reads or writes to the location are observed outside the
function. It is always valid to read and write allocas, and to read global
- constants, even if ``memory(none)`` is used, as these effects are not
+ constants, even if `memory(none)` is used, as these effects are not
externally observable.
The supported memory location kinds are:
- - ``argmem``: This refers to accesses that are based on pointer arguments
+ - `argmem`: This refers to accesses that are based on pointer arguments
to the function.
- - ``inaccessiblemem``: This refers to accesses to memory which is not
+ - `inaccessiblemem`: This refers to accesses to memory which is not
accessible by the current module (before return from the function -- an
allocator function may return newly accessible memory while only
accessing inaccessible memory itself). Inaccessible memory is often used
to model control dependencies of intrinsics.
- - ``errnomem``: This refers to accesses to the ``errno`` variable.
- - ``target_mem#`` : These refer to target specific state that cannot be
+ - `errnomem`: This refers to accesses to the `errno` variable.
+ - `target_mem#` : These refer to target specific state that cannot be
accessed by any other means. # is a number between 0 and 1 inclusive.
Note: The target_mem locations are experimental and intended for internal
testing only. They must not be used in production code.
@@ -2300,83 +2340,93 @@ For example:
don't currently have a dedicated location kind (e.g., accesses to globals
or captured pointers).
- If the ``memory`` attribute is not specified, then ``memory(readwrite)``
+ If the `memory` attribute is not specified, then `memory(readwrite)`
is implied (all memory effects are possible).
The memory effects of a call can be computed as
- ``CallSiteEffects & (FunctionEffects | OperandBundleEffects)``. Thus, the
+ `CallSiteEffects & (FunctionEffects | OperandBundleEffects)`. Thus, the
call-site annotation takes precedence over the potential effects described
by either the function annotation or the operand bundles.
-``minsize``
- This attribute suggests that optimization passes and code generator
+
+`minsize`
+: This attribute suggests that optimization passes and code generator
passes make choices that keep the code size of this function as small
as possible and perform optimizations that may sacrifice runtime
performance in order to minimize the size of the generated code.
- This attribute is incompatible with the ``optdebug`` and ``optnone``
+ This attribute is incompatible with the `optdebug` and `optnone`
attributes.
-``naked``
- This attribute disables prologue / epilogue emission for the
+
+`naked`
+: This attribute disables prologue / epilogue emission for the
function. This can have very system-specific consequences. The arguments of
- a ``naked`` function can not be referenced through IR values.
-``"no-inline-line-tables"``
- When this attribute is set to true, the inliner discards source locations
+ a `naked` function can not be referenced through IR values.
+
+`"no-inline-line-tables"`
+: When this attribute is set to true, the inliner discards source locations
when inlining code and instead uses the source location of the call site.
Breakpoints set on code that was inlined into the current function will
not fire during the execution of the inlined call sites. If the debugger
stops inside an inlined call site, it will appear to be stopped at the
outermost inlined call site.
-``no-jump-tables``
- When this attribute is set to true, the jump tables and lookup tables that
+
+`no-jump-tables`
+: When this attribute is set to true, the jump tables and lookup tables that
can be generated from a switch case lowering are disabled.
-``nobuiltin``
- This indicates that the callee function at a call site is not recognized as
+
+`nobuiltin`
+: This indicates that the callee function at a call site is not recognized as
a built-in function. LLVM will retain the original call and not replace it
with equivalent code based on the semantics of the built-in function, unless
- the call site uses the ``builtin`` attribute. This is valid at call sites
+ the call site uses the `builtin` attribute. This is valid at call sites
and on function declarations and definitions.
-``nocallback``
- This attribute indicates that the function is only allowed to jump back into
+
+`nocallback`
+: This attribute indicates that the function is only allowed to jump back into
the caller's module by a return or an exception, and is not allowed to jump back
by invoking a callback function, a direct, possibly transitive, external
- function call, use of ``longjmp``, or other means. It is a compiler hint that
+ function call, use of `longjmp`, or other means. It is a compiler hint that
is used at the module level to improve dataflow analysis, dropped during linking,
and has no effect on functions defined in the current module.
-``nodivergencesource``
- A call to this function is not a source of divergence. In uniformity
+
+`nodivergencesource`
+: A call to this function is not a source of divergence. In uniformity
analysis, a *source of divergence* is an instruction that generates
divergence even if its inputs are uniform. A call with no further information
would normally be considered a source of divergence; setting this attribute
on a function means that a call to it is not a source of divergence.
-``noduplicate``
- This attribute indicates that calls to the function cannot be
- duplicated. A call to a ``noduplicate`` function may be moved
+
+`noduplicate`
+: This attribute indicates that calls to the function cannot be
+ duplicated. A call to a `noduplicate` function may be moved
within its parent function, but may not be duplicated within
its parent function.
- A function containing a ``noduplicate`` call may still
+ A function containing a `noduplicate` call may still
be an inlining candidate, provided that the call is not
duplicated by inlining. That implies that the function has
internal linkage and only has one call site, so the original
call is dead after inlining.
-``nofree``
- This function attribute indicates that the function does not free any memory
+
+`nofree`
+: This function attribute indicates that the function does not free any memory
allocation which existed before the call, either through direct calls to
- a memory-deallocation function like ``free``, or through synchronization.
+ a memory-deallocation function like `free`, or through synchronization.
Freeing through synchronization here means that a deallocation
*happens-before* the function exit but does not *happens-before* the
function entry.
As a result, pointers that are known to be dereferenceable prior to a call
- to a function with the ``nofree`` attribute are still known to be
+ to a function with the `nofree` attribute are still known to be
dereferenceable after the call.
- A ``nofree`` function is explicitly allowed to free memory which it
+ A `nofree` function is explicitly allowed to free memory which it
allocated or arrange for another thread to free such memory on its behalf.
- As a result, perhaps surprisingly, a ``nofree`` function can return a
+ As a result, perhaps surprisingly, a `nofree` function can return a
pointer to a previously deallocated
- :ref:`allocated object<allocatedobjects>`.
-``noimplicitfloat``
- Disallows implicit floating-point code. This inhibits optimizations that
+ {ref}`allocated object<allocatedobjects>`.
+
+`noimplicitfloat`
+: Disallows implicit floating-point code. This inhibits optimizations that
use floating-point code and floating-point registers for operations that are
not nominally floating-point. LLVM instructions that perform floating-point
operations or require access to floating-point registers may still cause
@@ -2386,67 +2436,77 @@ For example:
scalar code such as vectorization or memcpy/memset optimization. This
includes integer vectors. Vector instructions present in IR may still cause
vector code to be generated.
-``noinline``
- This attribute indicates that the inliner should never inline this
+
+`noinline`
+: This attribute indicates that the inliner should never inline this
function in any situation. This attribute may not be used together
- with the ``alwaysinline`` attribute.
-``nomerge``
- This attribute indicates that calls to this function should never be merged
+ with the `alwaysinline` attribute.
+
+`nomerge`
+: This attribute indicates that calls to this function should never be merged
during optimization. For example, it will prevent tail merging otherwise
identical code sequences that raise an exception or terminate the program.
Tail merging normally reduces the precision of source location information,
making stack traces less useful for debugging. This attribute gives the
user control over the tradeoff between code size and debug information
precision.
-``nonlazybind``
- This attribute suppresses lazy symbol binding for the function. This
+
+`nonlazybind`
+: This attribute suppresses lazy symbol binding for the function. This
may make calls to the function faster, at the cost of extra program
startup time if the function is not called during program startup.
-``noprofile``
- This function attribute prevents instrumentation-based profiling, used for
+
+`noprofile`
+: This function attribute prevents instrumentation-based profiling, used for
coverage or profile based optimization, from being added to a function. It
also blocks inlining if the caller and callee have different values of this
attribute.
-``skipprofile``
- This function attribute prevents instrumentation-based profiling, used for
+
+`skipprofile`
+: This function attribute prevents instrumentation-based profiling, used for
coverage or profile based optimization, from being added to a function. This
attribute does not restrict inlining, so instrumented instructions could end
up in this function.
-``noredzone``
- This attribute indicates that the code generator should not use a
+
+`noredzone`
+: This attribute indicates that the code generator should not use a
red zone, even if the target-specific ABI normally permits it.
-``indirect-tls-seg-refs``
- This attribute indicates that the code generator should not use
+
+`indirect-tls-seg-refs`
+: This attribute indicates that the code generator should not use
direct TLS access through segment registers, even if the
target-specific ABI normally permits it.
-``noreturn``
- This function attribute indicates that the function never returns
+
+`noreturn`
+: This function attribute indicates that the function never returns
normally, hence through a return instruction. This produces undefined
behavior at runtime if the function ever does dynamically return. Annotated
- functions may still raise an exception, i.a., ``nounwind`` is not implied.
-``norecurse``
- This function attribute indicates that the function is not recursive and
+ functions may still raise an exception, i.a., `nounwind` is not implied.
+
+`norecurse`
+: This function attribute indicates that the function is not recursive and
does not participate in recursion. This means that the function never
occurs inside a cycle in the dynamic call graph.
For example:
-.. code-block:: text
-
- fn -> other_fn -> fn ; fn is not norecurse
- other_fn -> fn -> other_fn ; fn is not norecurse
- fn -> other_fn -> other_fn ; fn is norecurse
+```text
+fn -> other_fn -> fn ; fn is not norecurse
+other_fn -> fn -> other_fn ; fn is not norecurse
+fn -> other_fn -> other_fn ; fn is norecurse
+```
-.. _langref_willreturn:
+(langref_willreturn)=
-``willreturn``
- This function attribute indicates that a call of this function will
+`willreturn`
+: This function attribute indicates that a call of this function will
either exhibit undefined behavior or comes back and continues execution
at a point in the existing call stack that includes the current invocation.
- Annotated functions may still raise an exception, i.a., ``nounwind`` is not implied.
+ Annotated functions may still raise an exception, i.a., `nounwind` is not implied.
If an invocation of an annotated function does not return control back
to a point in the call stack, the behavior is undefined.
-``nosync``
- This function attribute indicates that the function does not introduce any
+
+`nosync`
+: This function attribute indicates that the function does not introduce any
*synchronizes-with* edges in the sense of the memory model.
In particular, synchronization is considered possible in the presence of
@@ -2460,167 +2520,193 @@ For example:
If a `nosync` function does ever synchronize with another thread,
the behavior is undefined.
-``nounwind``
- This function attribute indicates that the function never raises an
+
+`nounwind`
+: This function attribute indicates that the function never raises an
exception. If the function does raise an exception, its runtime
behavior is undefined. However, functions marked nounwind may still
trap or generate asynchronous exceptions. Exception handling schemes
that are recognized by LLVM to handle asynchronous exceptions, such
as SEH, will still provide their implementation defined semantics.
-``nosanitize_bounds``
- This attribute indicates that bounds checking sanitizer instrumentation
+
+`nosanitize_bounds`
+: This attribute indicates that bounds checking sanitizer instrumentation
is disabled for this function.
-``nosanitize_coverage``
- This attribute indicates that SanitizerCoverage instrumentation is disabled
+
+`nosanitize_coverage`
+: This attribute indicates that SanitizerCoverage instrumentation is disabled
for this function.
-``null_pointer_is_valid``
- If ``null_pointer_is_valid`` is set, then the ``null`` address
+
+`null_pointer_is_valid`
+: If `null_pointer_is_valid` is set, then the `null` address
in address-space 0 is considered to be a valid address for memory loads and
stores. Any analysis or optimization should not treat dereferencing a
- pointer to ``null`` as undefined behavior in this function.
- Note: Comparing the address of a global variable to ``null`` may still
+ pointer to `null` as undefined behavior in this function.
+ Note: Comparing the address of a global variable to `null` may still
evaluate to false because of a limitation in querying this attribute inside
constant expressions.
-``optdebug``
- This attribute suggests that optimization passes and code generator passes
+
+`optdebug`
+: This attribute suggests that optimization passes and code generator passes
should make choices that try to preserve debug info without significantly
degrading runtime performance.
- This attribute is incompatible with the ``minsize``, ``optsize``, and
- ``optnone`` attributes.
-``optforfuzzing``
- This attribute indicates that this function should be optimized
+ This attribute is incompatible with the `minsize`, `optsize`, and
+ `optnone` attributes.
+
+`optforfuzzing`
+: This attribute indicates that this function should be optimized
for maximum fuzzing signal.
-``optnone``
- This function attribute indicates that most optimization passes will skip
+
+`optnone`
+: This function attribute indicates that most optimization passes will skip
this function, with the exception of interprocedural optimization passes.
Code generation defaults to the "fast" instruction selector.
- This attribute cannot be used together with the ``alwaysinline``
+ This attribute cannot be used together with the `alwaysinline`
attribute; this attribute is also incompatible
- with the ``minsize``, ``optsize``, and ``optdebug`` attributes.
+ with the `minsize`, `optsize`, and `optdebug` attributes.
- This attribute requires the ``noinline`` attribute to be specified on
+ This attribute requires the `noinline` attribute to be specified on
the function as well, so the function is never inlined into any caller.
- Only functions with the ``alwaysinline`` attribute are valid
+ Only functions with the `alwaysinline` attribute are valid
candidates for inlining into the body of this function.
-``optsize``
- This attribute suggests that optimization passes and code generator
+
+`optsize`
+: This attribute suggests that optimization passes and code generator
passes make choices that keep the code size of this function low,
and otherwise do optimizations specifically to reduce code size as
long as they do not significantly impact runtime performance.
- This attribute is incompatible with the ``optdebug`` and ``optnone``
+ This attribute is incompatible with the `optdebug` and `optnone`
attributes.
-``"patchable-function"``
- This attribute tells the code generator that the code
+
+`"patchable-function"`
+: This attribute tells the code generator that the code
generated for this function needs to follow certain conventions that
make it possible for a runtime function to patch over it later.
The exact effect of this attribute depends on its string value,
for which there currently is one legal possibility:
- * ``"prologue-short-redirect"`` - This style of patchable
- function is intended to support patching a function prologue to
- redirect control away from the function in a thread-safe
- manner. It guarantees that the first instruction of the
- function will be large enough to accommodate a short jump
- instruction, and will be sufficiently aligned to allow being
- fully changed via an atomic compare-and-swap instruction.
- While the first requirement can be satisfied by inserting large
- enough NOP, LLVM can and will try to re-purpose an existing
- instruction (i.e., one that would have to be emitted anyway) as
- the patchable instruction larger than a short jump.
-
- ``"prologue-short-redirect"`` is currently only supported on
- x86-64.
+ * `"prologue-short-redirect"` - This style of patchable
+ function is intended to support patching a function prologue to
+ redirect control away from the function in a thread-safe
+ manner. It guarantees that the first instruction of the
+ function will be large enough to accommodate a short jump
+ instruction, and will be sufficiently aligned to allow being
+ fully changed via an atomic compare-and-swap instruction.
+ While the first requirement can be satisfied by inserting large
+ enough NOP, LLVM can and will try to re-purpose an existing
+ instruction (i.e., one that would have to be emitted anyway) as
+ the patchable instruction larger than a short jump.
+
+ `"prologue-short-redirect"` is currently only supported on
+ x86-64.
This attribute by itself does not imply restrictions on
inter-procedural optimizations. All of the semantic effects the
patching may have to be separately conveyed via the linkage type.
-``"patchable-function-prefix"``
- This attribute specifies the number of target-specific NOP instructions
+
+`"patchable-function-prefix"`
+: This attribute specifies the number of target-specific NOP instructions
emitted before the function entry label.
-``"patchable-function-entry"``
- This attribute specifies the number of target-specific NOP instructions
+
+`"patchable-function-entry"`
+: This attribute specifies the number of target-specific NOP instructions
emitted after the function entry label. These NOPs are emitted before the
function prologue.
-``"patchable-function-entry-section"``
- This attribute specifies the section used to record the start of the
+
+`"patchable-function-entry-section"`
+: This attribute specifies the section used to record the start of the
patchable function entry area when such a section is emitted. If omitted,
- the default section name is ``__patchable_function_entries``.
-``"probe-stack"``
- This attribute indicates that the function will trigger a guard region
+ the default section name is `__patchable_function_entries`.
+
+`"probe-stack"`
+: This attribute indicates that the function will trigger a guard region
in the end of the stack. It ensures that accesses to the stack must be
no further apart than the size of the guard region to a previous
access of the stack. It takes one required string value, the name of
the stack probing function that will be called.
- If a function that has a ``"probe-stack"`` attribute is inlined into
- a function with another ``"probe-stack"`` attribute, the resulting
- function has the ``"probe-stack"`` attribute of the caller. If a
- function that has a ``"probe-stack"`` attribute is inlined into a
- function that has no ``"probe-stack"`` attribute at all, the resulting
- function has the ``"probe-stack"`` attribute of the callee.
-``"stack-probe-size"``
- This attribute controls the behavior of stack probes: either
- the ``"probe-stack"`` attribute, or ABI-required stack probes, if any.
+ If a function that has a `"probe-stack"` attribute is inlined into
+ a function with another `"probe-stack"` attribute, the resulting
+ function has the `"probe-stack"` attribute of the caller. If a
+ function that has a `"probe-stack"` attribute is inlined into a
+ function that has no `"probe-stack"` attribute at all, the resulting
+ function has the `"probe-stack"` attribute of the callee.
+
+`"stack-probe-size"`
+: This attribute controls the behavior of stack probes: either
+ the `"probe-stack"` attribute, or ABI-required stack probes, if any.
It defines the size of the guard region. It ensures that if the function
may use more stack space than the size of the guard region, a stack probing
sequence will be emitted. It takes one required integer value, which
is 4096 by default.
- If a function that has a ``"stack-probe-size"`` attribute is inlined into
- a function with another ``"stack-probe-size"`` attribute, the resulting
- function has the ``"stack-probe-size"`` attribute that has the lower
- numeric value. If a function that has a ``"stack-probe-size"`` attribute is
- inlined into a function that has no ``"stack-probe-size"`` attribute
- at all, the resulting function has the ``"stack-probe-size"`` attribute
+ If a function that has a `"stack-probe-size"` attribute is inlined into
+ a function with another `"stack-probe-size"` attribute, the resulting
+ function has the `"stack-probe-size"` attribute that has the lower
+ numeric value. If a function that has a `"stack-probe-size"` attribute is
+ inlined into a function that has no `"stack-probe-size"` attribute
+ at all, the resulting function has the `"stack-probe-size"` attribute
of the callee.
-``"no-stack-arg-probe"``
- This attribute disables ABI-required stack probes, if any.
-``returns_twice``
- This attribute indicates that this function can return twice. The C
- ``setjmp`` is an example of such a function. The compiler disables
+
+`"no-stack-arg-probe"`
+: This attribute disables ABI-required stack probes, if any.
+
+`returns_twice`
+: This attribute indicates that this function can return twice. The C
+ `setjmp` is an example of such a function. The compiler disables
some optimizations (like tail calls) in the caller of these
functions.
-``safestack``
- This attribute indicates that
- `SafeStack <https://clang.llvm.org/docs/SafeStack.html>`_
+
+`safestack`
+: This attribute indicates that
+ [SafeStack](https://clang.llvm.org/docs/SafeStack.html)
protection is enabled for this function.
- If a function that has a ``safestack`` attribute is inlined into a
- function that doesn't have a ``safestack`` attribute or which has an
- ``ssp``, ``sspstrong`` or ``sspreq`` attribute, then the resulting
- function will have a ``safestack`` attribute.
-``sanitize_address``
- This attribute indicates that AddressSanitizer checks
+ If a function that has a `safestack` attribute is inlined into a
+ function that doesn't have a `safestack` attribute or which has an
+ `ssp`, `sspstrong` or `sspreq` attribute, then the resulting
+ function will have a `safestack` attribute.
+
+`sanitize_address`
+: This attribute indicates that AddressSanitizer checks
(dynamic address safety analysis) are enabled for this function.
-``sanitize_memory``
- This attribute indicates that MemorySanitizer checks (dynamic detection
+
+`sanitize_memory`
+: This attribute indicates that MemorySanitizer checks (dynamic detection
of accesses to uninitialized memory) are enabled for this function.
-``sanitize_thread``
- This attribute indicates that ThreadSanitizer checks
+
+`sanitize_thread`
+: This attribute indicates that ThreadSanitizer checks
(dynamic thread safety analysis) are enabled for this function.
-``sanitize_hwaddress``
- This attribute indicates that HWAddressSanitizer checks
+
+`sanitize_hwaddress`
+: This attribute indicates that HWAddressSanitizer checks
(dynamic address safety analysis based on tagged pointers) are enabled for
this function.
-``sanitize_memtag``
- This attribute indicates that MemTagSanitizer checks
+
+`sanitize_memtag`
+: This attribute indicates that MemTagSanitizer checks
(dynamic address safety analysis based on Armv8 MTE) are enabled for
this function.
-``sanitize_realtime``
- This attribute indicates that RealtimeSanitizer checks
+
+`sanitize_realtime`
+: This attribute indicates that RealtimeSanitizer checks
(realtime safety analysis - no allocations, syscalls or exceptions) are enabled
for this function.
-``sanitize_realtime_blocking``
- This attribute indicates that RealtimeSanitizer should error immediately
+
+`sanitize_realtime_blocking`
+: This attribute indicates that RealtimeSanitizer should error immediately
if the attributed function is called during invocation of a function
- attributed with ``sanitize_realtime``.
- This attribute is incompatible with the ``sanitize_realtime`` attribute.
-``sanitize_alloc_token``
- This attribute indicates that implicit allocation token instrumentation
+ attributed with `sanitize_realtime`.
+ This attribute is incompatible with the `sanitize_realtime` attribute.
+
+`sanitize_alloc_token`
+: This attribute indicates that implicit allocation token instrumentation
is enabled for this function.
-``speculative_load_hardening``
- This attribute indicates that
- `Speculative Load Hardening <https://llvm.org/docs/SpeculativeLoadHardening.html>`_
+
+`speculative_load_hardening`
+: This attribute indicates that
+ [Speculative Load Hardening](https://llvm.org/docs/SpeculativeLoadHardening.html)
should be enabled for the function body.
Speculative Load Hardening is a best-effort mitigation against
@@ -2636,10 +2722,11 @@ For example:
to provide a maximally conservative model where the code in a function
annotated with this attribute will always (even after inlining) end up
hardened.
-``speculatable``
- This function attribute indicates that the function does not have any
+
+`speculatable`
+: This function attribute indicates that the function does not have any
effects besides calculating its result and does not have undefined behavior.
- Note that ``speculatable`` is not enough to conclude that along any
+ Note that `speculatable` is not enough to conclude that along any
particular execution path the number of calls to this function will not be
externally observable. This attribute is only valid on functions
and declarations, not on individual call sites. If a function is
@@ -2647,27 +2734,27 @@ For example:
undefined behavior, the undefined behavior may be observed even
if the call site is dead code.
-``ssp``
- This attribute indicates that the function should emit a stack
+`ssp`
+: This attribute indicates that the function should emit a stack
smashing protector. It is in the form of a "canary" --- a random value
placed on the stack before the local variables that's checked upon
return from the function to see if it has been overwritten. A
heuristic is used to determine if a function needs stack protectors
or not. The heuristic used will enable protectors for functions with:
- - Character arrays larger than ``ssp-buffer-size`` (default 8).
- - Aggregates containing character arrays larger than ``ssp-buffer-size``.
+ - Character arrays larger than `ssp-buffer-size` (default 8).
+ - Aggregates containing character arrays larger than `ssp-buffer-size`.
- Calls to alloca() with variable sizes or constant sizes greater than
- ``ssp-buffer-size``.
+ `ssp-buffer-size`.
Variables that are identified as requiring a protector will be arranged
on the stack such that they are adjacent to the stack protector guard.
- If a function with an ``ssp`` attribute is inlined into a calling function,
+ If a function with an `ssp` attribute is inlined into a calling function,
the attribute is not carried over to the calling function.
-``sspstrong``
- This attribute indicates that the function should emit a stack smashing
+`sspstrong`
+: This attribute indicates that the function should emit a stack smashing
protector. This attribute causes a strong heuristic to be used when
determining if a function needs stack protectors. The strong heuristic
will enable protectors for functions with:
@@ -2681,71 +2768,71 @@ For example:
on the stack such that they are adjacent to the stack protector guard.
The specific layout rules are:
- #. Large arrays and structures containing large arrays
- (``>= ssp-buffer-size``) are closest to the stack protector.
- #. Small arrays and structures containing small arrays
- (``< ssp-buffer-size``) are 2nd closest to the protector.
- #. Variables that have had their address taken are 3rd closest to the
+ 1. Large arrays and structures containing large arrays
+ (`>= ssp-buffer-size`) are closest to the stack protector.
+ 1. Small arrays and structures containing small arrays
+ (`< ssp-buffer-size`) are 2nd closest to the protector.
+ 1. Variables that have had their address taken are 3rd closest to the
protector.
- This overrides the ``ssp`` function attribute.
+ This overrides the `ssp` function attribute.
- If a function with an ``sspstrong`` attribute is inlined into a calling
- function which has an ``ssp`` attribute, the calling function's attribute
- will be upgraded to ``sspstrong``.
+ If a function with an `sspstrong` attribute is inlined into a calling
+ function which has an `ssp` attribute, the calling function's attribute
+ will be upgraded to `sspstrong`.
-``sspreq``
- This attribute indicates that the function should *always* emit a stack
- smashing protector. This overrides the ``ssp`` and ``sspstrong`` function
+`sspreq`
+: This attribute indicates that the function should *always* emit a stack
+ smashing protector. This overrides the `ssp` and `sspstrong` function
attributes.
Variables that are identified as requiring a protector will be arranged
on the stack such that they are adjacent to the stack protector guard.
The specific layout rules are:
- #. Large arrays and structures containing large arrays
- (``>= ssp-buffer-size``) are closest to the stack protector.
- #. Small arrays and structures containing small arrays
- (``< ssp-buffer-size``) are 2nd closest to the protector.
- #. Variables that have had their address taken are 3rd closest to the
+ 1. Large arrays and structures containing large arrays
+ (`>= ssp-buffer-size`) are closest to the stack protector.
+ 1. Small arrays and structures containing small arrays
+ (`< ssp-buffer-size`) are 2nd closest to the protector.
+ 1. Variables that have had their address taken are 3rd closest to the
protector.
- If a function with an ``sspreq`` attribute is inlined into a calling
- function which has an ``ssp`` or ``sspstrong`` attribute, the calling
- function's attribute will be upgraded to ``sspreq``.
+ If a function with an `sspreq` attribute is inlined into a calling
+ function which has an `ssp` or `sspstrong` attribute, the calling
+ function's attribute will be upgraded to `sspreq`.
-.. _strictfp:
+(strictfp)=
-``strictfp``
- This attribute indicates that the function was called from a scope that
+`strictfp`
+: This attribute indicates that the function was called from a scope that
requires strict floating-point semantics. LLVM will not attempt any
optimizations that require assumptions about the floating-point rounding
mode or that might alter the state of floating-point status flags that
might otherwise be set or cleared by calling this function. LLVM will
not introduce any new floating-point instructions that may trap.
-.. _denormal_fpenv:
+(denormal_fpenv)=
-``denormal_fpenv``
- This indicates the denormal (subnormal) handling that may be
+`denormal_fpenv`
+: This indicates the denormal (subnormal) handling that may be
assumed for the default floating-point environment. The base form
- is a ``|`` separated pair. The elements may be one of ``ieee``,
- ``preservesign``, ``positivezero``, or ``dynamic``. The first
+ is a `|` separated pair. The elements may be one of `ieee`,
+ `preservesign`, `positivezero`, or `dynamic`. The first
entry indicates the flushing mode for the result of floating point
operations. The second indicates the handling of denormal inputs
to floating point instructions. For compatibility with older
bitcode, if the second value is omitted, both input and output
modes will assume the same mode.
- If this is attribute is not specified, the default is ``ieee|ieee``.
+ If this is attribute is not specified, the default is `ieee|ieee`.
- If the output mode is ``preservesign``, or ``positivezero``,
+ If the output mode is `preservesign`, or `positivezero`,
denormal outputs may be flushed to zero by standard floating-point
operations. It is not mandated that flushing to zero occurs, but if
a denormal output is flushed to zero, it must respect the sign
mode. Not all targets support all modes.
- If the mode is ``dynamic``, the behavior is derived from the
+ If the mode is `dynamic`, the behavior is derived from the
dynamic state of the floating-point environment. Transformations
which depend on the behavior of denormal values should not be
performed.
@@ -2756,146 +2843,154 @@ For example:
the floating point mode appropriately before function entry.
This may optionally specify a second pair, prefixed with
- ``float:``. This provides an override for the behavior of 32-bit
+ `float:`. This provides an override for the behavior of 32-bit
float type (or vectors of 32-bit floats).
- If the input mode is ``preservesign``, or ``positivezero``,
+ If the input mode is `preservesign`, or `positivezero`,
a floating-point operation must treat any input denormal value as
zero. In some situations, if an instruction does not respect this
mode, the input may need to be converted to 0 as if by
- ``@llvm.canonicalize`` during lowering for correctness.
+ `@llvm.canonicalize` during lowering for correctness.
This may optionally specify a second pair, prefixed with
- ``float:``. This provides an override for the behavior of 32-bit
+ `float:`. This provides an override for the behavior of 32-bit
float type. (or vectors of 32-bit floats). If this is present,
this overrides the base handling of the default mode. Not all
targets support separately setting the denormal mode per type, and
no attempt is made to diagnose unsupported uses. Currently this
attribute is respected by the AMDGPU and NVPTX backends.
-:Examples:
- ``denormal_fpenv(preservesign)``
- ``denormal_fpenv(float: preservesign)``
- ``denormal_fpenv(dynamic, float: preservesign|ieee)``
- ``denormal_fpenv(ieee|ieee, float: preservesign|preservesign)``
- ``denormal_fpenv(ieee|dynamic, float: preservesign|ieee)``
+ **Examples:**
-``"thunk"``
- This attribute indicates that the function will delegate to some other
+ - `denormal_fpenv(preservesign)`
+ - `denormal_fpenv(float: preservesign)`
+ - `denormal_fpenv(dynamic, float: preservesign|ieee)`
+ - `denormal_fpenv(ieee|ieee, float: preservesign|preservesign)`
+ - `denormal_fpenv(ieee|dynamic, float: preservesign|ieee)`
+
+`"thunk"`
+: This attribute indicates that the function will delegate to some other
function with a tail call. The prototype of a thunk should not be used for
optimization purposes. The caller is expected to cast the thunk prototype to
match the thunk target prototype.
-``uwtable[(sync|async)]``
- This attribute indicates that the ABI being targeted requires that
+
+`uwtable[(sync|async)]`
+: This attribute indicates that the ABI being targeted requires that
an unwind table entry be produced for this function even if we can
show that no exceptions pass by it. This is normally the case for
the ELF x86-64 abi, but it can be disabled for some compilation
units. The optional parameter describes what kind of unwind tables
- to generate: ``sync`` for normal unwind tables, ``async`` for asynchronous
+ to generate: `sync` for normal unwind tables, `async` for asynchronous
(instruction precise) unwind tables. Without the parameter, the attribute
- ``uwtable`` is equivalent to ``uwtable(async)``.
-``nocf_check``
- This attribute indicates that no control-flow check will be performed on
+ `uwtable` is equivalent to `uwtable(async)`.
+
+`nocf_check`
+: This attribute indicates that no control-flow check will be performed on
the attributed entity. It disables -fcf-protection=<> for a specific
entity to fine grain the HW control flow protection mechanism. The flag
is target independent and currently appertains to a function or function
pointer.
-``shadowcallstack``
- This attribute indicates that the ShadowCallStack checks are enabled for
+
+`shadowcallstack`
+: This attribute indicates that the ShadowCallStack checks are enabled for
the function. The instrumentation checks that the return address for the
function has not changed between the function prologue and epilogue. It is
currently x86_64-specific.
-.. _langref_mustprogress:
+(langref_mustprogress)=
-``mustprogress``
- This attribute indicates that the function is required to return, unwind,
+`mustprogress`
+: This attribute indicates that the function is required to return, unwind,
or interact with the environment in an observable way e.g., via a volatile
- memory access, I/O, or other synchronization. The ``mustprogress``
+ memory access, I/O, or other synchronization. The `mustprogress`
attribute is intended to model the requirements of the first section of
[intro.progress] of the C++ Standard. As a consequence, a loop in a
- function with the ``mustprogress`` attribute can be assumed to terminate if
+ function with the `mustprogress` attribute can be assumed to terminate if
it does not interact with the environment in an observable way, and
- terminating loops without side-effects can be removed. If a ``mustprogress``
+ terminating loops without side-effects can be removed. If a `mustprogress`
function does not satisfy this contract, the behavior is undefined. If a
- ``mustprogress`` function calls a function not marked ``mustprogress``,
+ `mustprogress` function calls a function not marked `mustprogress`,
and that function never returns, the program is well-defined even if there
- isn't any other observable progress. Note that ``willreturn`` implies
- ``mustprogress``.
-``"warn-stack-size"="<threshold>"``
- This attribute sets a threshold to emit diagnostics once the frame size is
+ isn't any other observable progress. Note that `willreturn` implies
+ `mustprogress`.
+
+`"warn-stack-size"="<threshold>"`
+: This attribute sets a threshold to emit diagnostics once the frame size is
known should the frame size exceed the specified value. It takes one
required integer value, which should be a non-negative integer, and less
than `UINT_MAX`. It's unspecified which threshold will be used when
duplicate definitions are linked together with differing values.
-``vscale_range(<min>[, <max>])``
- This function attribute indicates `vscale` is a power-of-two within a
+
+`vscale_range(<min>[, <max>])`
+: This function attribute indicates `vscale` is a power-of-two within a
specified range. `min` must be a power-of-two that is greater than 0. When
specified, `max` must be a power-of-two greater-than-or-equal to `min` or 0
to signify an unbounded maximum. The syntax `vscale_range(<val>)` can be
used to set both `min` and `max` to the same value. Functions that don't
include this attribute make no assumptions about the range of `vscale`.
-``nooutline``
- This attribute indicates that outlining passes should not modify the
+
+`nooutline`
+: This attribute indicates that outlining passes should not modify the
function.
-``nocreateundeforpoison``
- This attribute indicates that the result of the function (prior to
+
+`nocreateundeforpoison`
+: This attribute indicates that the result of the function (prior to
application of return attributes/metadata) will not be undef or poison if
all arguments are not undef and not poison. Otherwise, it is undefined
behavior.
-``"modular-format"="<type>,<string_idx>,<first_arg_idx>,<modular_impl_fn>,<impl_name>,<aspects...>"``
- This attribute indicates that the implementation is modular on a particular
+`"modular-format"="<type>,<string_idx>,<first_arg_idx>,<modular_impl_fn>,<impl_name>,<aspects...>"`
+: This attribute indicates that the implementation is modular on a particular
format string argument. If the compiler can determine that not all aspects
of the implementation are needed, it can report which aspects were needed
and redirect the call to a modular implementation function instead.
The compiler reports that an implementation aspect is needed by issuing a
- relocation for the symbol `<impl_name>_<aspect>``. This arranges for code
+ relocation for the symbol `<impl_name>_<aspect>`. This arranges for code
and data needed to support the aspect of the implementation to be brought
into the link to satisfy weak references in the modular implemenation
function.
The first three arguments have the same semantics as the arguments to the C
- ``format`` attribute.
+ `format` attribute.
The following aspects are currently supported:
- - ``fixed``: The call has a C ISO 18037 fixed-point argument.
- - ``float``: The call has a floating-point argument.
+ - `fixed`: The call has a C ISO 18037 fixed-point argument.
+ - `float`: The call has a floating point argument
-Call Site Attributes
-----------------------
+### Call Site Attributes
In addition to function attributes the following call site only
attributes are supported:
-``vector-function-abi-variant``
- This attribute can be attached to a :ref:`call <i_call>` to list
+`vector-function-abi-variant`
+: This attribute can be attached to a {ref}`call <i_call>` to list
the vector functions associated to the function. Notice that the
- attribute cannot be attached to a :ref:`invoke <i_invoke>` or a
- :ref:`callbr <i_callbr>` instruction. The attribute consists of a
+ attribute cannot be attached to a {ref}`invoke <i_invoke>` or a
+ {ref}`callbr <i_callbr>` instruction. The attribute consists of a
comma separated list of mangled names. The order of the list does
not imply preference (it is logically a set). The compiler is free
to pick any listed vector function of its choosing.
- The syntax for the mangled names is as follows:::
-
- _ZGV<isa><mask><vlen><parameters>_<scalar_name>[(<vector_redirection>)]
+ The syntax for the mangled names is as follows:
+ ```
+ _ZGV<isa><mask><vlen><parameters>_<scalar_name>[(<vector_redirection>)]
+ ```
When present, the attribute informs the compiler that the function
- ``<scalar_name>`` has a corresponding vector variant that can be
- used to perform the concurrent invocation of ``<scalar_name>`` on
+ `<scalar_name>` has a corresponding vector variant that can be
+ used to perform the concurrent invocation of `<scalar_name>` on
vectors. The shape of the vector function is described by the
- tokens between the prefix ``_ZGV`` and the ``<scalar_name>``
+ tokens between the prefix `_ZGV` and the `<scalar_name>`
token. The standard name of the vector function is
- ``_ZGV<isa><mask><vlen><parameters>_<scalar_name>``. When present,
- the optional token ``(<vector_redirection>)`` informs the compiler
+ `_ZGV<isa><mask><vlen><parameters>_<scalar_name>`. When present,
+ the optional token `(<vector_redirection>)` informs the compiler
that a custom name is provided in addition to the standard one
- (custom names can be provided for example via the use of ``declare
- variant`` in OpenMP 5.0). The declaration of the variant must be
+ (custom names can be provided for example via the use of `declare
+ variant` in OpenMP 5.0). The declaration of the variant must be
present in the IR Module. The signature of the vector variant is
determined by the rules of the Vector Function ABI (VFABI)
specifications of the target. For Arm and X86, the VFABI can be
@@ -2905,67 +3000,70 @@ attributes are supported:
For X86 and Arm targets, the values of the tokens in the standard
name are those that are defined in the VFABI. LLVM has an internal
- ``<isa>`` token that can be used to create scalar-to-vector
+ `<isa>` token that can be used to create scalar-to-vector
mappings for functions that are not directly associated to any of
the target ISAs (for example, some of the mappings stored in the
- TargetLibraryInfo). Valid values for the ``<isa>`` token are:::
-
- <isa>:= b | c | d | e -> X86 SSE, AVX, AVX2, AVX512
- | n | s -> Armv8 Advanced SIMD, SVE
- | __LLVM__ -> Internal LLVM Vector ISA
+ TargetLibraryInfo). Valid values for the `<isa>` token are:
+ ```
+ <isa>:= b | c | d | e -> X86 SSE, AVX, AVX2, AVX512
+ | n | s -> Armv8 Advanced SIMD, SVE
+ | __LLVM__ -> Internal LLVM Vector ISA
+ ```
For all targets currently supported (x86, Arm and Internal LLVM),
- the remaining tokens can have the following values:::
-
- <mask>:= M | N -> mask | no mask
-
- <vlen>:= number -> number of lanes
- | x -> VLA (Vector Length Agnostic)
-
- <parameters>:= v -> vector
- | l | l <number> -> linear
- | R | R <number> -> linear with ref modifier
- | L | L <number> -> linear with val modifier
- | U | U <number> -> linear with uval modifier
- | ls <pos> -> runtime linear
- | Rs <pos> -> runtime linear with ref modifier
- | Ls <pos> -> runtime linear with val modifier
- | Us <pos> -> runtime linear with uval modifier
- | u -> uniform
-
- <scalar_name>:= name of the scalar function
-
- <vector_redirection>:= optional, custom name of the vector function
-
-``preallocated(<ty>)``
- This attribute is required on calls to ``llvm.call.preallocated.arg``
+ the remaining tokens can have the following values:
+ ```
+ <mask>:= M | N -> mask | no mask
+
+ <vlen>:= number -> number of lanes
+ | x -> VLA (Vector Length Agnostic)
+
+ <parameters>:= v -> vector
+ | l | l <number> -> linear
+ | R | R <number> -> linear with ref modifier
+ | L | L <number> -> linear with val modifier
+ | U | U <number> -> linear with uval modifier
+ | ls <pos> -> runtime linear
+ | Rs <pos> -> runtime linear with ref modifier
+ | Ls <pos> -> runtime linear with val modifier
+ | Us <pos> -> runtime linear with uval modifier
+ | u -> uniform
+
+ <scalar_name>:= name of the scalar function
+
+ <vector_redirection>:= optional, custom name of the vector function
+ ```
+
+`preallocated(<ty>)`
+: This attribute is required on calls to `llvm.call.preallocated.arg`
and cannot be used on any other call. See
- :ref:`llvm.call.preallocated.arg<int_call_preallocated_arg>` for more
+ {ref}`llvm.call.preallocated.arg<int_call_preallocated_arg>` for more
details.
-.. _glattrs:
+(glattrs)=
-Global Attributes
------------------
+### Global Attributes
Attributes may be set to communicate additional information about a global variable.
-Unlike :ref:`function attributes <fnattrs>`, attributes on a global variable
-are grouped into a single :ref:`attribute group <attrgrp>`.
+Unlike {ref}`function attributes <fnattrs>`, attributes on a global variable
+are grouped into a single {ref}`attribute group <attrgrp>`.
-``no_sanitize_address``
- This attribute indicates that the global variable should not have
+`no_sanitize_address`
+: This attribute indicates that the global variable should not have
AddressSanitizer instrumentation applied to it, because it was annotated
with `__attribute__((no_sanitize("address")))`,
`__attribute__((disable_sanitizer_instrumentation))`, or included in the
`-fsanitize-ignorelist` file.
-``no_sanitize_hwaddress``
- This attribute indicates that the global variable should not have
+
+`no_sanitize_hwaddress`
+: This attribute indicates that the global variable should not have
HWAddressSanitizer instrumentation applied to it, because it was annotated
with `__attribute__((no_sanitize("hwaddress")))`,
`__attribute__((disable_sanitizer_instrumentation))`, or included in the
`-fsanitize-ignorelist` file.
-``sanitize_memtag``
- This attribute indicates that the global variable should have AArch64 memory
+
+`sanitize_memtag`
+: This attribute indicates that the global variable should have AArch64 memory
tags (MTE) instrumentation applied to it. This attribute causes the
suppression of certain optimizations, like GlobalMerge, as well as ensuring
extra directives are emitted in the assembly and extra bits of metadata are
@@ -2977,33 +3075,34 @@ are grouped into a single :ref:`attribute group <attrgrp>`.
`-fsanitize-ignorelist` file. The AArch64 Globals Tagging pass may remove
this attribute when it's not possible to tag the global (e.g., it's a TLS
variable).
-``sanitize_address_dyninit``
- This attribute indicates that the global variable, when instrumented with
+
+`sanitize_address_dyninit`
+: This attribute indicates that the global variable, when instrumented with
AddressSanitizer, should be checked for ODR violations. This attribute is
applied to global variables that are dynamically initialized according to
C++ rules.
-.. _opbundles:
+(opbundles)=
-Operand Bundles
----------------
+### Operand Bundles
Operand bundles are tagged sets of SSA values or metadata strings that can be
-associated with certain LLVM instructions (currently only ``call`` s and
-``invoke`` s). In a way they are like metadata, but dropping them is
+associated with certain LLVM instructions (currently only `call` s and
+`invoke` s). In a way they are like metadata, but dropping them is
incorrect and will change program semantics.
-Syntax::
-
- operand bundle set ::= '[' operand bundle (, operand bundle )* ']'
- operand bundle ::= tag '(' [ bundle operand ] (, bundle operand )* ')'
- bundle operand ::= SSA value | metadata string
- tag ::= string constant
+Syntax:
+```
+operand bundle set ::= '[' operand bundle (, operand bundle )* ']'
+operand bundle ::= tag '(' [ bundle operand ] (, bundle operand )* ')'
+bundle operand ::= SSA value | metadata string
+tag ::= string constant
+```
Operand bundles are **not** part of a function's signature, and a
given function may be called from multiple places with different kinds
of operand bundles. This reflects the fact that the operand bundles
-are conceptually a part of the ``call`` (or ``invoke``), not the
+are conceptually a part of the `call` (or `invoke`), not the
callee being dispatched to.
Operand bundles are a generic mechanism intended to support
@@ -3020,7 +3119,7 @@ operand bundle to not miscompile programs containing it.
ways before control is transferred to the callee or invokee.
- Calls and invokes with operand bundles have unknown read / write
effect on the heap on entry and exit (even if the call target specifies
- a ``memory`` attribute), unless they're overridden with
+ a `memory` attribute), unless they're overridden with
callsite specific attributes.
- An operand bundle at a call site cannot change the implementation
of the called function. Inter-procedural optimizations work as
@@ -3028,22 +3127,21 @@ operand bundle to not miscompile programs containing it.
More specific types of operand bundles are described below.
-.. _deopt_opbundles:
+(deopt_opbundles)=
-Deoptimization Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Deoptimization Operand Bundles
-Deoptimization operand bundles are characterized by the ``"deopt"``
+Deoptimization operand bundles are characterized by the `"deopt"`
operand bundle tag. These operand bundles represent an alternate
"safe" continuation for the call site they're attached to, and can be
used by a suitable runtime to deoptimize the compiled frame at the
-specified call site. There can be at most one ``"deopt"`` operand
+specified call site. There can be at most one `"deopt"` operand
bundle attached to a call site. Exact details of deoptimization are
out of scope for the language reference, but it usually involves
rewriting a compiled frame into a set of interpreted frames.
From the compiler's perspective, deoptimization operand bundles make
-the call sites they're attached to at least ``readonly``. They read
+the call sites they're attached to at least `readonly`. They read
through all of their pointer typed operands (even if they're not
otherwise escaped) and the entire visible heap. Deoptimization
operand bundles do not capture their operands except during
@@ -3057,32 +3155,32 @@ through a call site with a deoptimization operand bundle needs to
appropriately compose the "safe" deoptimization continuation. The
inliner does this by prepending the parent's deoptimization
continuation to every deoptimization continuation in the inlined body.
-E.g. inlining ``@f`` into ``@g`` in the following example
-
-.. code-block:: llvm
-
- define void @f() {
- call void @x() ;; no deopt state
- call void @y() [ "deopt"(i32 10) ]
- call void @y() [ "deopt"(i32 10), "unknown"(ptr null) ]
- ret void
- }
-
- define void @g() {
- call void @f() [ "deopt"(i32 20) ]
- ret void
- }
+E.g. inlining `@f` into `@g` in the following example
+
+```llvm
+define void @f() {
+ call void @x() ;; no deopt state
+ call void @y() [ "deopt"(i32 10) ]
+ call void @y() [ "deopt"(i32 10), "unknown"(ptr null) ]
+ ret void
+}
+
+define void @g() {
+ call void @f() [ "deopt"(i32 20) ]
+ ret void
+}
+```
will result in
-.. code-block:: llvm
-
- define void @g() {
- call void @x() ;; still no deopt state
- call void @y() [ "deopt"(i32 20, i32 10) ]
- call void @y() [ "deopt"(i32 20, i32 10), "unknown"(ptr null) ]
- ret void
- }
+```llvm
+define void @g() {
+ call void @x() ;; still no deopt state
+ call void @y() [ "deopt"(i32 20, i32 10) ]
+ call void @y() [ "deopt"(i32 20, i32 10), "unknown"(ptr null) ]
+ ret void
+}
+```
It is the frontend's responsibility to structure or encode the
deoptimization state in a way that syntactically prepending the
@@ -3090,123 +3188,120 @@ caller's deoptimization state to the callee's deoptimization state is
semantically equivalent to composing the caller's deoptimization
continuation after the callee's deoptimization continuation.
-.. _ob_funclet:
+(ob_funclet)=
-Funclet Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^
+#### Funclet Operand Bundles
-Funclet operand bundles are characterized by the ``"funclet"``
+Funclet operand bundles are characterized by the `"funclet"`
operand bundle tag. These operand bundles indicate that a call site
is within a particular funclet. There can be at most one
-``"funclet"`` operand bundle attached to a call site and it must have
+`"funclet"` operand bundle attached to a call site and it must have
exactly one bundle operand.
If any funclet EH pads have been "entered" but not "exited" (per the
-`description in the EH doc\ <ExceptionHandling.html#wineh-constraints>`_),
-it is undefined behavior to execute a ``call`` or ``invoke`` which:
+{ref}`description in the EH doc <wineh-constraints>`),
+it is undefined behavior to execute a `call` or `invoke` which:
-* does not have a ``"funclet"`` bundle and is not a ``call`` to a nounwind
+* does not have a `"funclet"` bundle and is not a `call` to a nounwind
intrinsic, or
-* has a ``"funclet"`` bundle whose operand is not the most-recently-entered
+* has a `"funclet"` bundle whose operand is not the most-recently-entered
not-yet-exited funclet EH pad.
Similarly, if no funclet EH pads have been entered-but-not-yet-exited,
-executing a ``call`` or ``invoke`` with a ``"funclet"`` bundle is undefined behavior.
+executing a `call` or `invoke` with a `"funclet"` bundle is undefined behavior.
-GC Transition Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### GC Transition Operand Bundles
GC transition operand bundles are characterized by the
-``"gc-transition"`` operand bundle tag. These operand bundles mark a
+`"gc-transition"` operand bundle tag. These operand bundles mark a
call as a transition between a function with one GC strategy to a
function with a different GC strategy. If coordinating the transition
between GC strategies requires additional code generation at the call
site, these bundles may contain any values that are needed by the
-generated code. For more details, see :ref:`GC Transitions
+generated code. For more details, see {ref}`GC Transitions
<gc_transition_args>`.
The bundle contains an arbitrary list of Values which need to be passed
to GC transition code. They will be lowered and passed as operands to
-the appropriate ``GC_TRANSITION`` nodes in the selection DAG. It is assumed
+the appropriate `GC_TRANSITION` nodes in the selection DAG. It is assumed
that these arguments must be available before and after (but not
necessarily during) the execution of the callee.
-.. _assume_opbundles:
+(assume_opbundles)=
-Assume Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^
+#### Assume Operand Bundles
-Operand bundles on an :ref:`llvm.assume <int_assume>` allow representing
+Operand bundles on an {ref}`llvm.assume <int_assume>` allow representing
assumptions that hold at the location of the assume. Operand bundles enable
assumptions that are either hard or impossible to represent as a boolean
-argument of an :ref:`llvm.assume <int_assume>`.
+argument of an {ref}`llvm.assume <int_assume>`.
-Assumes with operand bundles must have ``i1 true`` as the condition operand.
+Assumes with operand bundles must have `i1 true` as the condition operand.
-Just like for the argument of :ref:`llvm.assume <int_assume>`, if any of the
+Just like for the argument of {ref}`llvm.assume <int_assume>`, if any of the
provided guarantees are violated at runtime the behavior is undefined.
While attributes expect constant arguments, assume operand bundles may be
provided a dynamic value, for example:
-.. code-block:: llvm
-
- call void @llvm.assume(i1 true) ["align"(ptr %val, i32 %align)]
+```llvm
+call void @llvm.assume(i1 true) ["align"(ptr %val, i32 %align)]
+```
The following attributes are currently accepted:
-``"align"(ptr %p, i64 %align)``, ``"align"(ptr %p, i64 %align, i64 %offset)``
- Equivalent to :ref:`align(%align) <attr_align>` on ``%p``, or ``%p - %offset``
- if the ``%offset`` argument exists, except that ``%align`` may be a
- non-power-of-two alignment (including a zero alignment). If ``%align`` is not
- a power of two the pointer value must be all-zero. Otherwise the behavior is
- undefined.
+`"align"(ptr %p, i64 %align)`, `"align"(ptr %p, i64 %align, i64 %offset)`
+: Equivalent to {ref}`align(%align) <attr_align>` on `%p`, or `%p - %offset`
+ if the `%offset` argument exists, except that `%align` may be a
+ non-power-of-two alignment (including a zero alignment). If `%align` is not
+ a power of two, the pointer value must be all-zero. Otherwise the behavior is
+ undefined.
-``"cold"()``
- Equivalent to :ref:`cold <attr_cold>`.
+`"cold"()`
+: Equivalent to {ref}`cold <attr_cold>`.
-``"dereferenceable"(ptr %p, i64 %size)``
- Equivalent to :ref:`dereferenceable(%size) <attr_dereferenceable>` on ``%p``,
- except that ``%size`` may also be zero, in which case the bundle doesn't
- imply ``nonnull``.
+`"dereferenceable"(ptr %p, i64 %size)`
+: Equivalent to {ref}`dereferenceable(%size) <attr_dereferenceable>` on
+ `%p`, except that `%size` may also be zero, in which case the bundle
+ doesn't imply `nonnull`.
-``"dereferenceable_or_null"(ptr %p, i64 %size)``
- Equivalent to :ref:`dereferenceable_or_null(%size)
- <attr_dereferenceable_or_null>` on ``%p``, except that ``%size`` may also be
- zero.
+`"dereferenceable_or_null"(ptr %p, i64 %size)`
+: Equivalent to {ref}`dereferenceable_or_null(%size)
+ <attr_dereferenceable_or_null>` on `%p`, except that `%size` may also be
+ zero.
-``"ignore"(...)``
- Doesn't imply anything and is ignored. This is used to drop an assume where
- the ``llvm.assume`` call cannot be replaced or dropped.
+`"ignore"(...)`
+: Doesn't imply anything and is ignored. This is used to drop an assume where
+ the `llvm.assume` call cannot be replaced or dropped.
-``"nonnull"(ptr %p)``
- Equivalent to :ref:`nonnull <attr_nonnull>` on ``%p``.
+`"nonnull"(ptr %p)`
+: Equivalent to {ref}`nonnull <attr_nonnull>` on `%p`.
-``"noundef"(any_type %v)``
- Equivalent to :ref:`noundef <attr_noundef>` on ``%v``.
+`"noundef"(any_type %v)`
+: Equivalent to {ref}`noundef <attr_noundef>` on `%v`.
-``"separate_storage"(ptr %p1, ptr %p2)``
- This indicates that no pointer :ref:`based <pointeraliasing>` on one of its
- arguments can alias any pointer based on the other.
+`"separate_storage"(ptr %p1, ptr %p2)`
+: This indicates that no pointer {ref}`based <pointeraliasing>` on one of its
+ arguments can alias any pointer based on the other.
For example:
-.. code-block:: llvm
-
- call void @llvm.assume(i1 true) ["align"(ptr %val, i32 8)]
+```llvm
+call void @llvm.assume(i1 true) ["align"(ptr %val, i32 8)]
+```
allows the optimizer to assume that at location of call to
-:ref:`llvm.assume <int_assume>` ``%val`` has an alignment of at least 8.
+{ref}`llvm.assume <int_assume>` `%val` has an alignment of at least 8.
-.. code-block:: llvm
+```llvm
+call void @llvm.assume(i1 true) ["cold"(), "nonnull"(ptr %val)]
+```
- call void @llvm.assume(i1 true) ["cold"(), "nonnull"(ptr %val)]
-
-allows the optimizer to assume that the :ref:`llvm.assume <int_assume>`
-call location is cold and that ``%val`` may not be null.
+allows the optimizer to assume that the {ref}`llvm.assume <int_assume>`
+call location is cold and that `%val` may not be null.
Even if the assumed property can be encoded as a boolean value, like
-``nonnull``, using operand bundles to express the property can still have
+`nonnull`, using operand bundles to express the property can still have
benefits:
* Attributes that can be expressed via operand bundles are directly the
@@ -3215,158 +3310,149 @@ benefits:
the property (e.g., `icmp ne ptr %p, null` for `nonnull`) and for the
optimizer to deduce the property from that instruction sequence.
* Expressing the property using operand bundles makes it easy to identify the
- use of the value as a use in an :ref:`llvm.assume <int_assume>`. This then
+ use of the value as a use in an {ref}`llvm.assume <int_assume>`. This then
simplifies and improves heuristics, e.g., for use "use-sensitive"
optimizations.
-.. _ob_preallocated:
+(ob_preallocated)=
-Preallocated Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Preallocated Operand Bundles
-Preallocated operand bundles are characterized by the ``"preallocated"``
+Preallocated operand bundles are characterized by the `"preallocated"`
operand bundle tag. These operand bundles allow separation of the allocation
of the call argument memory from the call site. This is necessary to pass
non-trivially copyable objects by value in a way that is compatible with MSVC
-on some targets. There can be at most one ``"preallocated"`` operand bundle
+on some targets. There can be at most one `"preallocated"` operand bundle
attached to a call site and it must have exactly one bundle operand, which is
-a token generated by ``@llvm.call.preallocated.setup``. A call with this
+a token generated by `@llvm.call.preallocated.setup`. A call with this
operand bundle should not adjust the stack before entering the function, as
-that will have been done by one of the ``@llvm.call.preallocated.*`` intrinsics.
-
-.. code-block:: llvm
+that will have been done by one of the `@llvm.call.preallocated.*` intrinsics.
- %foo = type { i64, i32 }
+```llvm
+%foo = type { i64, i32 }
- ...
+...
- %t = call token @llvm.call.preallocated.setup(i32 1)
- %a = call ptr @llvm.call.preallocated.arg(token %t, i32 0) preallocated(%foo)
- ; initialize %b
- call void @bar(i32 42, ptr preallocated(%foo) %a) ["preallocated"(token %t)]
+%t = call token @llvm.call.preallocated.setup(i32 1)
+%a = call ptr @llvm.call.preallocated.arg(token %t, i32 0) preallocated(%foo)
+; initialize %b
+call void @bar(i32 42, ptr preallocated(%foo) %a) ["preallocated"(token %t)]
+```
-.. _ob_gc_live:
+(ob_gc_live)=
-GC Live Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### GC Live Operand Bundles
-A "gc-live" operand bundle is only valid on a :ref:`gc.statepoint <gc_statepoint>`
+A "gc-live" operand bundle is only valid on a {ref}`gc.statepoint <gc_statepoint>`
intrinsic. The operand bundle must contain every pointer to a garbage collected
object which potentially needs to be updated by the garbage collector.
When lowered, any relocated value will be recorded in the corresponding
-:ref:`stackmap entry <statepoint-stackmap-format>`. See the intrinsic description
+{ref}`stackmap entry <statepoint-stackmap-format>`. See the intrinsic description
for further details.
-ObjC ARC Attached Call Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### ObjC ARC Attached Call Operand Bundles
-A ``"clang.arc.attachedcall"`` operand bundle on a call indicates the call is
+A `"clang.arc.attachedcall"` operand bundle on a call indicates the call is
implicitly followed by a marker instruction and a call to an ObjC runtime
function that uses the result of the call. The operand bundle takes a mandatory
-pointer to the runtime function (``@objc_retainAutoreleasedReturnValue`` or
-``@objc_unsafeClaimAutoreleasedReturnValue``).
+pointer to the runtime function (`@objc_retainAutoreleasedReturnValue` or
+`@objc_unsafeClaimAutoreleasedReturnValue`).
The return value of a call with this bundle is used by a call to
-``@llvm.objc.clang.arc.noop.use`` unless the called function's return type is
+`@llvm.objc.clang.arc.noop.use` unless the called function's return type is
void, in which case the operand bundle is ignored.
-.. code-block:: llvm
-
- ; The marker instruction and a runtime function call are inserted after the call
- ; to @foo.
- call ptr @foo() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
- call ptr @foo() [ "clang.arc.attachedcall"(ptr @objc_unsafeClaimAutoreleasedReturnValue) ]
+```llvm
+; The marker instruction and a runtime function call are inserted after the call
+; to @foo.
+call ptr @foo() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
+call ptr @foo() [ "clang.arc.attachedcall"(ptr @objc_unsafeClaimAutoreleasedReturnValue) ]
+```
The operand bundle is needed to ensure the call is immediately followed by the
marker instruction and the ObjC runtime call in the final output.
-.. _ob_ptrauth:
+(ob_ptrauth)=
-Pointer Authentication Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Pointer Authentication Operand Bundles
Pointer Authentication operand bundles are characterized by the
-``"ptrauth"`` operand bundle tag. They are described in the
-`Pointer Authentication <PointerAuth.html#operand-bundle>`__ document.
+`"ptrauth"` operand bundle tag. They are described in the
+[Pointer Authentication](PointerAuth.md#operand-bundle) document.
-.. _ob_kcfi:
+(ob_kcfi)=
-KCFI Operand Bundles
-^^^^^^^^^^^^^^^^^^^^
+#### KCFI Operand Bundles
-A ``"kcfi"`` operand bundle on an indirect call indicates that the call will
+A `"kcfi"` operand bundle on an indirect call indicates that the call will
be preceded by a runtime type check, which validates that the call target is
-prefixed with a :ref:`type identifier<md_kcfi_type>` that matches the operand
+prefixed with a {ref}`type identifier<md_kcfi_type>` that matches the operand
bundle attribute. For example:
-.. code-block:: llvm
-
- call void %0() ["kcfi"(i32 1234)]
+```llvm
+call void %0() ["kcfi"(i32 1234)]
+```
Clang emits KCFI operand bundles and the necessary metadata with
-``-fsanitize=kcfi``.
+`-fsanitize=kcfi`.
-.. _convergencectrl:
+(convergencectrl)=
-Convergence Control Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Convergence Control Operand Bundles
-A "convergencectrl" operand bundle is only valid on a ``convergent`` operation.
+A "convergencectrl" operand bundle is only valid on a `convergent` operation.
When present, the operand bundle must contain exactly one value of token type.
-See the :doc:`ConvergentOperations` document for details.
+See the {doc}`ConvergentOperations` document for details.
-.. _deactivationsymbol:
+(deactivationsymbol)=
-Deactivation Symbol Operand Bundles
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Deactivation Symbol Operand Bundles
-A ``"deactivation-symbol"`` operand bundle is valid on the following
+A `"deactivation-symbol"` operand bundle is valid on the following
instructions (AArch64 only):
-- Call to a normal function with ``notail`` attribute and a first argument and
- return value of type ``ptr``.
-- Call to ``llvm.ptrauth.sign`` or ``llvm.ptrauth.auth`` intrinsics.
+- Call to a normal function with `notail` attribute and a first argument and
+ return value of type `ptr`.
+- Call to `llvm.ptrauth.sign` or `llvm.ptrauth.auth` intrinsics.
This operand bundle specifies that if the deactivation symbol is defined
to a valid value for the target, the marked instruction will return the
value of its first argument instead of calling the specified function
-or intrinsic. This is achieved with ``PATCHINST`` relocations on the
+or intrinsic. This is achieved with `PATCHINST` relocations on the
target instructions (see the AArch64 psABI for details).
-.. _moduleasm:
+(moduleasm)=
-Module-Level Inline Assembly
-----------------------------
+### Module-Level Inline Assembly
Modules may contain "module-level inline asm" blocks, which corresponds
to the GCC "file scope inline asm" blocks. These blocks are internally
concatenated by LLVM and treated as a single unit, but may be separated
-in the ``.ll`` file if desired. The syntax is very simple:
+in the `.ll` file if desired. The syntax is very simple:
-.. code-block:: llvm
-
- module asm "inline asm code goes here"
- module asm "more can go here"
+```llvm
+module asm "inline asm code goes here"
+module asm "more can go here"
+```
The strings can contain any character by escaping non-printable
characters. The escape sequence used is simply "\\xx" where "xx" is the
two digit hex code for the number.
Note that the assembly string *must* be parseable by LLVM's integrated assembler
-(unless it is disabled), even when emitting a ``.s`` file.
+(unless it is disabled), even when emitting a `.s` file.
-.. _langref_datalayout:
+(langref_datalayout)=
-Data Layout
------------
+### Data Layout
A module may specify a target-specific data layout string that specifies
how data is to be laid out in memory. The syntax for the data layout is
simply:
-.. code-block:: llvm
-
- target datalayout = "layout specification"
+```llvm
+target datalayout = "layout specification"
+```
The *layout specification* consists of a list of specifications
separated by the minus sign character ('-'). Each specification starts
@@ -3374,32 +3460,35 @@ with a letter and may include other information after the letter to
define some aspect of the data layout. The specifications accepted are
as follows:
-``E``
- Specifies that the target lays out data in big-endian form. That is,
+`E`
+: Specifies that the target lays out data in big-endian form. That is,
the bits with the most significance have the lowest address
location.
-``e``
- Specifies that the target lays out data in little-endian form. That
+
+`e`
+: Specifies that the target lays out data in little-endian form. That
is, the bits with the least significance have the lowest address
location.
-``S<size>``
- Specifies the natural alignment of the stack in bits. Alignment
+
+`S<size>`
+: Specifies the natural alignment of the stack in bits. Alignment
promotion of stack variables is limited to the natural stack
alignment to avoid dynamic stack realignment. If omitted, the natural stack
alignment defaults to "unspecified", which does not prevent any
alignment promotions.
-``P<address space>``
- Specifies the address space that corresponds to program memory.
+
+`P<address space>`
+: Specifies the address space that corresponds to program memory.
Harvard architectures can use this to specify what space LLVM
should place things such as functions into. If omitted, the
program memory space defaults to the default address space of 0,
which corresponds to a Von Neumann architecture that has code
and data in the same space.
-.. _globals_addrspace:
+(globals_addrspace)=
-``G<address space>``
- Specifies the address space to be used by default when creating global
+`G<address space>`
+: Specifies the address space to be used by default when creating global
variables. If omitted, the globals address space defaults to the default
address space 0.
Note: variable declarations without an address space are always created in
@@ -3407,148 +3496,158 @@ as follows:
when creating globals without additional contextual information (e.g., in
LLVM passes).
-.. _alloca_addrspace:
+(alloca_addrspace)=
-``A<address space>``
- Specifies the address space of objects created by '``alloca``'.
+`A<address space>`
+: Specifies the address space of objects created by '`alloca`'.
Defaults to the default address space of 0.
-``p[<flags>][<as>][(<name>)]:<size>:<abi>[:<pref>[:<idx>]]``
- This specifies the properties of a pointer in address space ``as``.
- The ``<size>`` parameter specifies the size of the bitwise representation.
- For :ref:`non-integral pointers <nointptrtype>` the representation size may
+
+`p[<flags>][<as>][(<name>)]:<size>:<abi>[:<pref>[:<idx>]]`
+: This specifies the properties of a pointer in address space `as`.
+ The `<size>` parameter specifies the size of the bitwise representation.
+ For {ref}`non-integral pointers <nointptrtype>` the representation size may
be larger than the address width of the underlying address space (e.g., to
accommodate additional metadata).
- The alignment requirements are specified via the ``<abi>`` and
- ``<pref>``\erred alignments parameters.
- The fourth parameter ``<idx>`` is the size of the index that used for
- address calculations such as :ref:`getelementptr <i_getelementptr>`.
+ The alignment requirements are specified via the `<abi>` and
+ `<pref>`erred alignments parameters.
+ The fourth parameter `<idx>` is the size of the index that used for
+ address calculations such as {ref}`getelementptr <i_getelementptr>`.
It must be less than or equal to the pointer size. If not specified, the
default index size is equal to the pointer size.
The index size also specifies the width of addresses in this address space.
All sizes are in bits.
- The address space, ``<as>``, is optional, and if not specified, denotes the
- default address space 0. The value of ``<as>`` must be in the range [1,2^24).
- The optional ``<flags>`` are used to specify properties of pointers in this
- address space: the character ``u`` marks pointers as having an unstable
- representation, and ``e`` marks pointers having external state. See
- :ref:`Non-Integral Pointer Types <nointptrtype>`. Additionally, the
- null pointer bit representation can be specified: ``z`` indicates it is
- all-zeros, and ``o`` indicates it is all-ones. At most one of ``z`` or
- ``o`` may be specified. If neither ``z`` nor ``o`` is specified, the null
- pointer bit representation defaults to all-zeros. The ``<name>`` is an
- optional name of that address space, surrounded by ``(`` and ``)``. If the
+ The address space, `<as>`, is optional, and if not specified, denotes the
+ default address space 0. The value of `<as>` must be in the range [1,2^24).
+ The optional `<flags>` are used to specify properties of pointers in this
+ address space: the character `u` marks pointers as having an unstable
+ representation, and `e` marks pointers having external state. See
+ {ref}`Non-Integral Pointer Types <nointptrtype>`. Additionally, the
+ null pointer bit representation can be specified: `z` indicates it is
+ all-zeros, and `o` indicates it is all-ones. At most one of `z` or
+ `o` may be specified. If neither `z` nor `o` is specified, the null
+ pointer bit representation defaults to all-zeros. The `<name>` is an
+ optional name of that address space, surrounded by `(` and `)`. If the
name is specified, it must be unique to that address space and cannot be
- ``A``, ``G``, or ``P`` which are pre-defined names used to denote alloca,
+ `A`, `G`, or `P` which are pre-defined names used to denote alloca,
global, and program address space respectively.
-``i<size>:<abi>[:<pref>]``
- This specifies the alignment for an integer type of a given bit
- ``<size>``. The value of ``<size>`` must be in the range [1,2^24).
- For ``i8``, the ``<abi>`` value must equal 8,
- that is, ``i8`` must be naturally aligned.
-``v<size>:<abi>[:<pref>]``
- This specifies the alignment for a vector type of a given bit
- ``<size>``. The value of ``<size>`` must be in the range [1,2^24).
-``ve``
- Specifies that vectors are element-aligned by default, rather than having
+
+`i<size>:<abi>[:<pref>]`
+: This specifies the alignment for an integer type of a given bit
+ `<size>`. The value of `<size>` must be in the range [1,2^24).
+ For `i8`, the `<abi>` value must equal 8,
+ that is, `i8` must be naturally aligned.
+
+`v<size>:<abi>[:<pref>]`
+: This specifies the alignment for a vector type of a given bit
+ `<size>`. The value of `<size>` must be in the range [1,2^24).
+
+`ve`
+: Specifies that vectors are element-aligned by default, rather than having
natural alignment.
-``f<size>:<abi>[:<pref>]``
- This specifies the alignment for a floating-point type of a given bit
- ``<size>``. Only values of ``<size>`` that are supported by the target
+
+`f<size>:<abi>[:<pref>]`
+: This specifies the alignment for a floating-point type of a given bit
+ `<size>`. Only values of `<size>` that are supported by the target
will work. 32 (float) and 64 (double) are supported on all targets; 80
or 128 (different flavors of long double) are also supported on some
- targets. The value of ``<size>`` must be in the range [1,2^24).
-``a:<abi>[:<pref>]``
- This specifies the alignment for an object of aggregate type.
+ targets. The value of `<size>` must be in the range [1,2^24).
+
+`a:<abi>[:<pref>]`
+: This specifies the alignment for an object of aggregate type.
In addition to the usual requirements for alignment values,
- the value of ``<abi>`` can also be zero, which means one byte alignment.
-``F<type><abi>``
- This specifies the alignment for function pointers.
- The options for ``<type>`` are:
-
- * ``i``: The alignment of function pointers is independent of the alignment
- of functions, and is a multiple of ``<abi>``.
- * ``n``: The alignment of function pointers is a multiple of the explicit
- alignment specified on the function, and is a multiple of ``<abi>``.
-``m:<mangling>``
- If present, specifies that llvm names are mangled in the output. Symbols
- prefixed with the mangling escape character ``\01`` are passed through
+ the value of `<abi>` can also be zero, which means one byte alignment.
+
+`F<type><abi>`
+: This specifies the alignment for function pointers.
+ The options for `<type>` are:
+
+ * `i`: The alignment of function pointers is independent of the alignment
+ of functions, and is a multiple of `<abi>`.
+ * `n`: The alignment of function pointers is a multiple of the explicit
+ alignment specified on the function, and is a multiple of `<abi>`.
+
+`m:<mangling>`
+: If present, specifies that llvm names are mangled in the output. Symbols
+ prefixed with the mangling escape character `\01` are passed through
directly to the assembler without the escape character. The mangling style
options are
- * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
- * ``l``: GOFF mangling: Private symbols get a ``@`` prefix.
- * ``m``: Mips mangling: Private symbols get a ``$`` prefix.
- * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
- symbols get a ``_`` prefix.
- * ``x``: Windows x86 COFF mangling: Private symbols get the usual prefix.
- Regular C symbols get a ``_`` prefix. Functions with ``__stdcall``,
- ``__fastcall``, and ``__vectorcall`` have custom mangling that appends
- ``@N`` where N is the number of bytes used to pass parameters. C++ symbols
- starting with ``?`` are not mangled in any way.
- * ``w``: Windows COFF mangling: Similar to ``x``, except that normal C
- symbols do not receive a ``_`` prefix.
- * ``a``: XCOFF mangling: Private symbols get a ``L..`` prefix.
-``n<size1>:<size2>:<size3>...``
- This specifies a set of native integer widths for the target CPU in
- bits. For example, it might contain ``n32`` for 32-bit PowerPC,
- ``n32:64`` for PowerPC 64, or ``n8:16:32:64`` for X86-64. Elements of
+ * `e`: ELF mangling: Private symbols get a `.L` prefix.
+ * `l`: GOFF mangling: Private symbols get a `@` prefix.
+ * `m`: Mips mangling: Private symbols get a `$` prefix.
+ * `o`: Mach-O mangling: Private symbols get `L` prefix. Other
+ symbols get a `_` prefix.
+ * `x`: Windows x86 COFF mangling: Private symbols get the usual prefix.
+ Regular C symbols get a `_` prefix. Functions with `__stdcall`,
+ `__fastcall`, and `__vectorcall` have custom mangling that appends
+ `@N` where N is the number of bytes used to pass parameters. C++ symbols
+ starting with `?` are not mangled in any way.
+ * `w`: Windows COFF mangling: Similar to `x`, except that normal C
+ symbols do not receive a `_` prefix.
+ * `a`: XCOFF mangling: Private symbols get a `L..` prefix.
+
+`n<size1>:<size2>:<size3>...`
+: This specifies a set of native integer widths for the target CPU in
+ bits. For example, it might contain `n32` for 32-bit PowerPC,
+ `n32:64` for PowerPC 64, or `n8:16:32:64` for X86-64. Elements of
this set are considered to support most general arithmetic operations
efficiently.
-``ni:<address space0>:<address space1>:<address space2>...``
- This marks pointer types with the specified address spaces
- as :ref:`unstable <nointptrtype>`.
- The ``0`` address space cannot be specified as non-integral.
- It is only supported for backwards compatibility, the flags of the ``p``
+
+`ni:<address space0>:<address space1>:<address space2>...`
+: This marks pointer types with the specified address spaces
+ as {ref}`unstable <nointptrtype>`.
+ The `0` address space cannot be specified as non-integral.
+ It is only supported for backwards compatibility, the flags of the `p`
specifier should be used instead for new code.
-``<abi>`` is a lower bound on what is required for a type to be considered
+`<abi>` is a lower bound on what is required for a type to be considered
aligned. This is used in various places, such as:
- The alignment for loads and stores if none is explicitly given.
- The alignment used to compute struct layout.
-- The alignment used to compute allocation sizes and thus ``getelementptr``
+- The alignment used to compute allocation sizes and thus `getelementptr`
offsets.
- The alignment below which accesses are considered underaligned.
-``<pref>`` allows providing a more optimal alignment that should be used when
-possible, primarily for ``alloca`` and the alignment of global variables. It 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>``.
+`<pref>` allows providing a more optimal alignment that should be used when
+possible, primarily for `alloca` and the alignment of global variables. It 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, every alignment specification is provided in
bits and must be in the range [1,2^16). The value must be a power of two times
-the width of a byte (i.e., ``align = 8 * 2^N``).
+the width of a byte (i.e., `align = 8 * 2^N`).
When constructing the data layout for a given target, LLVM starts with a
default set of specifications which are then (possibly) overridden by
-the specifications in the ``datalayout`` keyword. The default
+the specifications in the `datalayout` keyword. The default
specifications are given in this list:
-- ``e`` - little endian
-- ``p:64:64:64`` - 64-bit pointers with 64-bit alignment.
-- ``p[n]:64:64:64`` - Other address spaces are assumed to be the
+- `e` - little endian
+- `p:64:64:64` - 64-bit pointers with 64-bit alignment.
+- `p[n]:64:64:64` - Other address spaces are assumed to be the
same as the default address space.
-- ``S0`` - natural stack alignment is unspecified
-- ``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
+- `S0` - natural stack alignment is unspecified
+- `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
-- ``f16:16:16`` - half is 16-bit aligned
-- ``f32:32:32`` - float is 32-bit aligned
-- ``f64:64:64`` - double is 64-bit aligned
-- ``f128:128:128`` - quad is 128-bit aligned
-- ``v64:64:64`` - 64-bit vector is 64-bit aligned
-- ``v128:128:128`` - 128-bit vector is 128-bit aligned
-- ``a:0:64`` - aggregates are 64-bit aligned
+- `f16:16:16` - half is 16-bit aligned
+- `f32:32:32` - float is 32-bit aligned
+- `f64:64:64` - double is 64-bit aligned
+- `f128:128:128` - quad is 128-bit aligned
+- `v64:64:64` - 64-bit vector is 64-bit aligned
+- `v128:128:128` - 128-bit vector is 128-bit aligned
+- `a:0:64` - aggregates are 64-bit aligned
When LLVM is determining the alignment for a given type, it uses the
following rules:
-#. If the type sought is an exact match for one of the specifications,
+1. If the type sought is an exact match for one of the specifications,
that specification is used.
-#. If no match is found, and the type sought is an integer type, then
+1. If no match is found, and the type sought is an integer type, then
the smallest integer type that is larger than the bitwidth of the
sought type is used. If none of the specifications are larger than
the bitwidth then the largest integer type is used. For example,
@@ -3570,41 +3669,39 @@ generate a Data Layout and the optimization phases will operate
accordingly and introduce target specificity into the IR with respect to
these default specifications.
-.. _langref_triple:
+(langref_triple)=
-Target Triple
--------------
+### Target Triple
A module may specify a target triple string that describes the target
host. The syntax for the target triple is simply:
-.. code-block:: llvm
-
- target triple = "x86_64-apple-macosx10.7.0"
+```llvm
+target triple = "x86_64-apple-macosx10.7.0"
+```
The *target triple* string consists of a series of identifiers delimited
by the minus sign character ('-'). The canonical forms are:
-::
-
- ARCHITECTURE-VENDOR-OPERATING_SYSTEM
- ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
+```
+ARCHITECTURE-VENDOR-OPERATING_SYSTEM
+ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
+```
This information is passed along to the backend so that it generates
code for the proper architecture. It's possible to override this on the
-command line with the ``-mtriple`` command-line option.
+command line with the `-mtriple` command-line option.
-.. _allocatedobjects:
+(allocatedobjects)=
-Allocated Objects
------------------
+### Allocated Objects
An allocated object, memory object, or simply object, is a region of a memory
-space that is reserved by a memory allocation such as :ref:`alloca <i_alloca>`,
+space that is reserved by a memory allocation such as {ref}`alloca <i_alloca>`,
heap allocation calls, and global variable definitions. Once it is allocated,
the bytes stored in the region can only be read or written through a pointer
-that is :ref:`based on <pointeraliasing>` the allocation value. If a pointer
+that is {ref}`based on <pointeraliasing>` the allocation value. If a pointer
that is not based on the object tries to read or write to the object, it is
undefined behavior.
@@ -3617,42 +3714,40 @@ behavior is undefined:
largest signed integer that fits into the index type.
Allocated objects that are created with operations recognized by LLVM (such as
-:ref:`alloca <i_alloca>`, heap allocation functions marked as such, and global
-variables) may *not* change their size. (``realloc``-style operations do not
+{ref}`alloca <i_alloca>`, heap allocation functions marked as such, and global
+variables) may *not* change their size. (`realloc`-style operations do not
change the size of an existing allocated object; instead, they create a new
allocated object. Even if the object is at the same location as the old one, old
pointers cannot be used to access this new object.) However, allocated objects
can also be created by means not recognized by LLVM, e.g., by directly calling
-``mmap``. Those allocated objects are allowed to grow to the right (i.e.,
+`mmap`. Those allocated objects are allowed to grow to the right (i.e.,
keeping the same base address, but increasing their size) while maintaining the
validity of existing pointers, as long as they always satisfy the properties
described above. Currently, allocated objects are not permitted to grow to the
left or to shrink, nor can they have holes.
-.. _objectlifetime:
+(objectlifetime)=
-Object Lifetime
-----------------------
+### Object Lifetime
-A lifetime of an :ref:`allocated object<allocatedobjects>` is a property that
+A lifetime of an {ref}`allocated object<allocatedobjects>` is a property that
decides its accessibility. Unless stated otherwise, an allocated object is alive
since its allocation, and dead after its deallocation. It is undefined behavior
to access an allocated object that isn't alive, but operations that don't
-dereference it such as :ref:`getelementptr <i_getelementptr>`,
-:ref:`ptrtoint <i_ptrtoint>` and :ref:`icmp <i_icmp>` return a valid result.
+dereference it such as {ref}`getelementptr <i_getelementptr>`,
+{ref}`ptrtoint <i_ptrtoint>` and {ref}`icmp <i_icmp>` return a valid result.
This explains code motion of these instructions across operations that impact
the object's lifetime. A stack object's lifetime can be explicitly specified
-using :ref:`llvm.lifetime.start <int_lifestart>` and
-:ref:`llvm.lifetime.end <int_lifeend>` intrinsic function calls.
+using {ref}`llvm.lifetime.start <int_lifestart>` and
+{ref}`llvm.lifetime.end <int_lifeend>` intrinsic function calls.
As an exception to the above, loading from a stack object outside its lifetime
is not undefined behavior and returns a poison value instead. Storing to it is
still undefined behavior.
-.. _pointeraliasing:
+(pointeraliasing)=
-Pointer Aliasing Rules
-----------------------
+### Pointer Aliasing Rules
Any memory access must be done through a pointer value associated with
an address range of the memory access, otherwise the behavior is
@@ -3667,7 +3762,7 @@ to the following rules:
address range of the allocated storage.
- A null pointer in the default address-space is associated with no
address.
-- An :ref:`undef value <undefvalues>` in *any* address-space is
+- An {ref}`undef value <undefvalues>` in *any* address-space is
associated with no address.
- An integer constant other than zero or a pointer value returned from
a function not defined within LLVM may be associated with address
@@ -3678,14 +3773,14 @@ to the following rules:
A pointer value is *based* on another pointer value according to the
following rules:
-- A pointer value formed from a scalar ``getelementptr`` operation is *based* on
- the pointer-typed operand of the ``getelementptr``.
-- The pointer in lane *l* of the result of a vector ``getelementptr`` operation
+- A pointer value formed from a scalar `getelementptr` operation is *based* on
+ the pointer-typed operand of the `getelementptr`.
+- The pointer in lane *l* of the result of a vector `getelementptr` operation
is *based* on the pointer in lane *l* of the vector-of-pointers-typed operand
- of the ``getelementptr``.
-- The result value of a ``bitcast`` is *based* on the operand of the
- ``bitcast``.
-- A pointer value formed by an ``inttoptr`` is *based* on all pointer
+ of the `getelementptr`.
+- The result value of a `bitcast` is *based* on the operand of the
+ `bitcast`.
+- A pointer value formed by an `inttoptr` is *based* on all pointer
values that contribute (directly or indirectly) to the computation of
the pointer's value.
- The "*based* on" relationship is transitive.
@@ -3694,38 +3789,36 @@ Note that this definition of *"based"* is intentionally similar to the
definition of *"based"* in C99, though it is slightly weaker.
LLVM IR does not associate types with memory. The result type of a
-``load`` merely indicates the size and alignment of the memory from
+`load` merely indicates the size and alignment of the memory from
which to load, as well as the interpretation of the value. The first
-operand type of a ``store`` similarly only indicates the size and
+operand type of a `store` similarly only indicates the size and
alignment of the store.
Consequently, type-based alias analysis, aka TBAA, aka
-``-fstrict-aliasing``, is not applicable to general unadorned LLVM IR.
-:ref:`Metadata <metadata>` may be used to encode additional information
+`-fstrict-aliasing`, is not applicable to general unadorned LLVM IR.
+{ref}`Metadata <metadata>` may be used to encode additional information
which specialized optimization passes may use to implement type-based
alias analysis.
-.. _pointercapture:
+(pointercapture)=
-Pointer Capture
----------------
+### Pointer Capture
Given a function call and a pointer that is passed as an argument or stored in
memory before the call, the call may capture two components of the pointer:
- * The address of the pointer, which is its integral value. This also includes
- parts of the address or any information about the address, including the
- fact that it does not equal one specific value. We further distinguish
- whether only the fact that the address is/isn't null is captured.
- * The provenance of the pointer, which is the ability to perform memory
- accesses through the pointer, in the sense of the :ref:`pointer aliasing
- rules <pointeraliasing>`. We further distinguish whether only read accesses
- are allowed, or both reads and writes.
+- The address of the pointer, which is its integral value. This also includes
+ parts of the address or any information about the address, including the
+ fact that it does not equal one specific value. We further distinguish
+ whether only the fact that the address is/isn't null is captured.
+- The provenance of the pointer, which is the ability to perform memory
+ accesses through the pointer, in the sense of the {ref}`pointer aliasing
+ rules <pointeraliasing>`. We further distinguish whether only read accesses
+ are allowed, or both reads and writes.
These two cases are discussed in more detail in the following.
-Provenance capture
-^^^^^^^^^^^^^^^^^^
+#### Provenance capture
If an argument does not capture the provenance of the pointer, accesses that are
based on the argument and are performed after the function returns (or unwinds)
@@ -3741,138 +3834,134 @@ only allow read accesses.
This means that the following code is well-defined in isolation:
-.. code-block:: llvm
-
- define void @f(ptr captures(address) %a, ptr %b) {
- store ptr %a, ptr %b
- ret void
- }
+```llvm
+define void @f(ptr captures(address) %a, ptr %b) {
+ store ptr %a, ptr %b
+ ret void
+}
+```
Even though the pointer is stored in another location that persists past the
return of the function, this does not cause undefined behavior by itself. It
depends on whether/how the pointer will be used in the future.
-.. code-block:: llvm
-
- call void @f(ptr captures(address) %a, ptr %b)
- %a2 = load ptr, ptr %b ; This is still well-defined
- load i64, ptr %a2 ; This causes undefined behavior
+```llvm
+call void @f(ptr captures(address) %a, ptr %b)
+%a2 = load ptr, ptr %b ; This is still well-defined
+load i64, ptr %a2 ; This causes undefined behavior
+```
In this example, the persisted pointer is accessed after the return of the
function, which causes undefined behavior.
-.. code-block:: llvm
-
- call void @f(ptr captures(address, read_provenance) %a, ptr %b)
- %a2 = load ptr, ptr %b
- load i64, ptr %a2 ; This is still well-defined
- store i64 0, ptr %a2 ; This causes undefined behavior
+```llvm
+call void @f(ptr captures(address, read_provenance) %a, ptr %b)
+%a2 = load ptr, ptr %b
+load i64, ptr %a2 ; This is still well-defined
+store i64 0, ptr %a2 ; This causes undefined behavior
+```
-In this example, we additionally declare that ``read_provenance`` is captured.
-This means that the ``load`` after the function return is still well-defined,
+In this example, we additionally declare that `read_provenance` is captured.
+This means that the `load` after the function return is still well-defined,
while the store causes undefined behavior.
-Address capture
-^^^^^^^^^^^^^^^
+#### Address capture
The address of the pointer is considered to be captured if the function can
exhibit different observable behavior based on the address of the pointer.
-For example, the following function captures the address of ``%a``, because
+For example, the following function captures the address of `%a`, because
it will return a different value if the address has a specific value:
-.. code-block:: llvm
+```llvm
+ at glb = global i8 0
- @glb = global i8 0
-
- define i1 @f(ptr %a) {
- %c = icmp eq ptr %a, @glb
- ret i1 %c
- }
+define i1 @f(ptr %a) {
+ %c = icmp eq ptr %a, @glb
+ ret i1 %c
+}
+```
The function does not capture the provenance of the pointer, because the
-``icmp`` instruction only operates on the pointer address.
+`icmp` instruction only operates on the pointer address.
Even if the function contains a comparison on the pointer address, this does
not necessarily mean that it captures the address:
-.. code-block:: llvm
-
- define void @my_memmove(
- ptr captures(none) %dst, ptr captures(none) %src, i64 %size
- ) {
- %cmp = icmp ult ptr %dst, %src
- br i1 %cmp, label %perform_forward_copy, label %perform_backward_copy
+```llvm
+define void @my_memmove(
+ ptr captures(none) %dst, ptr captures(none) %src, i64 %size
+) {
+ %cmp = icmp ult ptr %dst, %src
+ br i1 %cmp, label %perform_forward_copy, label %perform_backward_copy
- ; ...
- }
+ ; ...
+}
+```
While the implementation differs based on the addresses of the arguments, the
observable behavior stays the same in both branches. A common case where this
occurs are runtime aliasing checks for loop versioning.
-Location specific capture
-^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Location specific capture
We can further say that the capture only occurs through a specific location.
In the following example, the pointer (both address and provenance) is captured
through the return value only:
-.. code-block:: llvm
-
- define ptr @f(ptr %a) {
- %gep = getelementptr i8, ptr %a, i64 4
- ret ptr %gep
- }
+```llvm
+define ptr @f(ptr %a) {
+ %gep = getelementptr i8, ptr %a, i64 4
+ ret ptr %gep
+}
+```
However, we always consider direct inspection of the pointer address
-(e.g., using ``ptrtoint``) to be location-independent. The following example
-is *not* considered a return-only capture, even though the ``ptrtoint``
+(e.g., using `ptrtoint`) to be location-independent. The following example
+is *not* considered a return-only capture, even though the `ptrtoint`
ultimately only contributes to the return value:
-.. code-block:: llvm
-
- @lookup = constant [4 x i8] [i8 0, i8 1, i8 2, i8 3]
+```llvm
+ at lookup = constant [4 x i8] [i8 0, i8 1, i8 2, i8 3]
- define ptr @f(ptr %a) {
- %a.addr = ptrtoint ptr %a to i64
- %mask = and i64 %a.addr, 3
- %gep = getelementptr i8, ptr @lookup, i64 %mask
- ret ptr %gep
- }
+define ptr @f(ptr %a) {
+ %a.addr = ptrtoint ptr %a to i64
+ %mask = and i64 %a.addr, 3
+ %gep = getelementptr i8, ptr @lookup, i64 %mask
+ ret ptr %gep
+}
+```
This definition is chosen to allow capture analysis to continue with the return
value in the usual fashion.
-Inference
-^^^^^^^^^
+#### Inference
The definitions given above are permissive to facilitate frontend-driven
annotations based on language semantics. As inference generally cannot know
how pointers will be used after the function returns, it needs to make
conservative assumptions. Here is an example set of rules that could be used
-to infer ``captures``:
+to infer `captures`:
* Volatile memory accesses capture the address of the pointer.
* getelementptr, bitcast, addrspacecast, select, phi: Do not capture anything.
* load, va_arg: Do not capture anything (unless volatile).
* icmp, ptrtoaddr: Captures only address.
* ptrtoint: Captures address and provenance.
- * call/invoke: Depends on ``captures`` on arguments. The callee is never
+ * call/invoke: Depends on `captures` on arguments. The callee is never
captured.
* store, atomicrmw, cmpxchg: Capture the address and provenance of the value
operand. Do not capture the pointer operand (unless volatile).
* Other (including insertvalue and insertelement): Conservatively assume
address and provenance are captured.
-.. _volatile:
+(volatile)=
-Volatile Memory Accesses
-------------------------
+### Volatile Memory Accesses
-Certain memory accesses, such as :ref:`load <i_load>`'s,
-:ref:`store <i_store>`'s, and :ref:`llvm.memcpy <int_memcpy>`'s may be
-marked ``volatile``. The optimizers must not change the number of
+Certain memory accesses, such as {ref}`load <i_load>`'s,
+{ref}`store <i_store>`'s, and {ref}`llvm.memcpy <int_memcpy>`'s may be
+marked `volatile`. The optimizers must not change the number of
volatile operations or change their order of execution relative to other
volatile operations. The optimizers *may* change the order of volatile
operations relative to non-volatile operations. This is not Java's
@@ -3901,42 +3990,41 @@ pointer.
Volatile operations are permitted to trap. The compiler may not assume
that execution will continue after a volatile operation.
-IR-level volatile loads and stores cannot safely be optimized into ``llvm.memcpy``
-or ``llvm.memmove`` intrinsics even when those intrinsics are flagged volatile.
+IR-level volatile loads and stores cannot safely be optimized into `llvm.memcpy`
+or `llvm.memmove` intrinsics even when those intrinsics are flagged volatile.
Likewise, the backend should never split or merge target-legal volatile
load/store instructions. Similarly, IR-level volatile loads and stores cannot
change from integer to floating-point or vice versa.
-.. admonition:: Rationale
+```{admonition} Rationale
+Platforms may rely on volatile loads and stores of natively supported
+data width to be executed as single instruction. For example, in C
+this holds for an l-value of volatile primitive type with native
+hardware support, but not necessarily for aggregate types. The
+frontend upholds these expectations, which are intentionally
+unspecified in the IR. The rules above ensure that IR transformations
+do not violate the frontend's contract with the language.
+```
- Platforms may rely on volatile loads and stores of natively supported
- data width to be executed as single instruction. For example, in C
- this holds for an l-value of volatile primitive type with native
- hardware support, but not necessarily for aggregate types. The
- frontend upholds these expectations, which are intentionally
- unspecified in the IR. The rules above ensure that IR transformations
- do not violate the frontend's contract with the language.
+(memmodel)=
-.. _memmodel:
-
-Memory Model for Concurrent Operations
---------------------------------------
+### Memory Model for Concurrent Operations
The LLVM IR does not define any way to start parallel threads of
execution or to register signal handlers. Nonetheless, there are
platform-specific ways to create them, and we define LLVM IR's behavior
in their presence. This model is inspired by the C++ memory model.
-For a more informal introduction to this model, see the :doc:`Atomics`.
+For a more informal introduction to this model, see the {doc}`Atomics`.
We define a *happens-before* partial order as the least partial order
that
- Is a superset of single-thread program order, and
-- When ``a`` *synchronizes-with* ``b``, includes an edge from ``a`` to
- ``b``. *Synchronizes-with* pairs are introduced by platform-specific
+- When `a` *synchronizes-with* `b`, includes an edge from `a` to
+ `b`. *Synchronizes-with* pairs are introduced by platform-specific
techniques, like pthread locks, thread creation, thread joining,
- etc., and by atomic instructions. (See also :ref:`Atomic Memory Ordering
+ etc., and by atomic instructions. (See also {ref}`Atomic Memory Ordering
Constraints <ordering>`).
Note that program order does not introduce *happens-before* edges
@@ -3948,36 +4036,36 @@ loads/read-modify-writes, etc.) R reads a series of bytes written by
stores/read-modify-writes, memcpy, etc.). For the purposes of this
section, initialized globals are considered to have a write of the
initializer which is atomic and happens before any other read or write
-of the memory in question. For each byte of a read R, R\ :sub:`byte`
+of the memory in question. For each byte of a read R, R{sub}`byte`
may see any write to the same byte, except:
-- If write\ :sub:`1` happens before write\ :sub:`2`, and
- write\ :sub:`2` happens before R\ :sub:`byte`, then
- R\ :sub:`byte` does not see write\ :sub:`1`.
-- If R\ :sub:`byte` happens before write\ :sub:`3`, then
- R\ :sub:`byte` does not see write\ :sub:`3`.
+- If write{sub}`1` happens before write{sub}`2`, and
+ write{sub}`2` happens before R{sub}`byte`, then
+ R{sub}`byte` does not see write{sub}`1`.
+- If R{sub}`byte` happens before write{sub}`3`, then
+ R{sub}`byte` does not see write{sub}`3`.
-Given that definition, R\ :sub:`byte` is defined as follows:
+Given that definition, R{sub}`byte` is defined as follows:
- If R is volatile, the result is target-dependent. (Volatile is
- supposed to give guarantees which can support ``sig_atomic_t`` in
+ supposed to give guarantees which can support `sig_atomic_t` in
C/C++, and may be used for accesses to addresses that do not behave
like normal memory. It does not generally provide cross-thread
synchronization.)
- Otherwise, if there is no write to the same byte that happens before
- R\ :sub:`byte`, R\ :sub:`byte` returns ``undef`` for that byte.
-- Otherwise, if R\ :sub:`byte` may see exactly one write,
- R\ :sub:`byte` returns the value written by that write.
-- Otherwise, if R is atomic, and all the writes R\ :sub:`byte` may
- see are atomic, it chooses one of the values written. See the :ref:`Atomic
+ R{sub}`byte`, R{sub}`byte` returns `undef` for that byte.
+- Otherwise, if R{sub}`byte` may see exactly one write,
+ R{sub}`byte` returns the value written by that write.
+- Otherwise, if R is atomic, and all the writes R{sub}`byte` may
+ see are atomic, it chooses one of the values written. See the {ref}`Atomic
Memory Ordering Constraints <ordering>` section for additional
constraints on how the choice is made. Targets may impose additional
- requirements on R and the writes it may see based on their ``syncscope``.
-- Otherwise R\ :sub:`byte` returns ``undef``.
+ requirements on R and the writes it may see based on their `syncscope`.
+- Otherwise R{sub}`byte` returns `undef`.
R returns the value composed of the series of bytes it read. This
-implies that some bytes within the value may be ``undef`` **without**
-the entire value being ``undef``. Note that this only defines the
+implies that some bytes within the value may be `undef` **without**
+the entire value being `undef`. Note that this only defines the
semantics of the operation; it doesn't mean that targets will emit more
than one instruction to read the series of bytes.
@@ -3989,106 +4077,109 @@ which might not otherwise be stored is not allowed in general.
from an address, introducing a store can change a load that may see
exactly one write into a load that may see multiple writes.)
-.. _ordering:
+(ordering)=
-Atomic Memory Ordering Constraints
-----------------------------------
+### Atomic Memory Ordering Constraints
-Atomic instructions (:ref:`cmpxchg <i_cmpxchg>`,
-:ref:`atomicrmw <i_atomicrmw>`, :ref:`fence <i_fence>`,
-:ref:`atomic load <i_load>`, and :ref:`atomic store <i_store>`) take
+Atomic instructions ({ref}`cmpxchg <i_cmpxchg>`,
+{ref}`atomicrmw <i_atomicrmw>`, {ref}`fence <i_fence>`,
+{ref}`atomic load <i_load>`, and {ref}`atomic store <i_store>`) take
ordering parameters that determine which other atomic instructions on
the same address they *synchronize with*. These semantics implement
the Java or C++ memory models; if these descriptions aren't precise
enough, check those specs (see spec references in the
-:doc:`atomics guide <Atomics>`). :ref:`fence <i_fence>` instructions
+{doc}`atomics guide <Atomics>`). {ref}`fence <i_fence>` instructions
treat these orderings somewhat differently since they don't take an
address. See that instruction's documentation for details.
For a simpler introduction to the ordering constraints, see the
-:doc:`Atomics`.
+{doc}`Atomics`.
-``unordered``
- The set of values that can be read is governed by the happens-before
+`unordered`
+: The set of values that can be read is governed by the happens-before
partial order. A value cannot be read unless some operation wrote
it. This is intended to provide a guarantee strong enough to model
Java's non-volatile shared variables. This ordering cannot be
specified for read-modify-write operations; it is not strong enough
to make them atomic in any interesting way.
-``monotonic``
- In addition to the guarantees of ``unordered``, there is a single
- total order for modifications by ``monotonic`` operations on each
+
+`monotonic`
+: In addition to the guarantees of `unordered`, there is a single
+ total order for modifications by `monotonic` operations on each
address. All modification orders must be compatible with the
happens-before order. There is no guarantee that the modification
orders can be combined to a global total order for the whole program
(and this often will not be possible). If the read in an atomic
- read-modify-write operation M (:ref:`cmpxchg <i_cmpxchg>` and
- :ref:`atomicrmw <i_atomicrmw>`) reads from a ``monotonic`` (or
+ read-modify-write operation M ({ref}`cmpxchg <i_cmpxchg>` and
+ {ref}`atomicrmw <i_atomicrmw>`) reads from a `monotonic` (or
stronger) write W, W must be immediately before M in the address's
modification order. If one atomic read happens before another atomic
- read of the same address and both are at least ``monotonic``, the
+ read of the same address and both are at least `monotonic`, the
later read must not see an earlier value in the address's
- modification order. This disallows reordering of ``monotonic`` (or
+ modification order. This disallows reordering of `monotonic` (or
stronger) operations on the same address. If an address is written
- ``monotonic``-ally by one thread, and other threads ``monotonic``-ally
+ `monotonic`-ally by one thread, and other threads `monotonic`-ally
read that address repeatedly, the other threads must eventually see
- the write. This corresponds to the C/C++ ``memory_order_relaxed``.
-``acquire``
- In addition to the guarantees of ``monotonic``, a
- *synchronizes-with* edge may be formed with a ``release`` operation.
- This is intended to model C/C++'s ``memory_order_acquire``.
-``release``
- In addition to the guarantees of ``monotonic``, if this operation
- writes a value which is subsequently read by an ``acquire``
+ the write. This corresponds to the C/C++ `memory_order_relaxed`.
+
+`acquire`
+: In addition to the guarantees of `monotonic`, a
+ *synchronizes-with* edge may be formed with a `release` operation.
+ This is intended to model C/C++'s `memory_order_acquire`.
+
+`release`
+: In addition to the guarantees of `monotonic`, if this operation
+ writes a value which is subsequently read by an `acquire`
operation, it *synchronizes-with* that operation. Furthermore,
- this occurs even if the value written by a ``release`` operation
+ this occurs even if the value written by a `release` operation
has been modified by a read-modify-write operation before being
read. (Such a set of operations comprises a *release
sequence*). This corresponds to the C/C++
- ``memory_order_release``.
-``acq_rel`` (acquire+release)
- Acts as both an ``acquire`` and ``release`` operation on its
- address. This corresponds to the C/C++ ``memory_order_acq_rel``.
-``seq_cst`` (sequentially consistent)
- In addition to the guarantees of ``acq_rel`` (``acquire`` for an
- operation that only reads, ``release`` for an operation that only
+ `memory_order_release`.
+
+`acq_rel` (acquire+release)
+: Acts as both an `acquire` and `release` operation on its
+ address. This corresponds to the C/C++ `memory_order_acq_rel`.
+
+`seq_cst` (sequentially consistent)
+: In addition to the guarantees of `acq_rel` (`acquire` for an
+ operation that only reads, `release` for an operation that only
writes), there is a global total order on all
sequentially-consistent operations on all addresses. If an address
is only accessed through sequentially-consistent operations, each
sequentially-consistent read of that address sees the last preceding
write to the same address in this global order. This corresponds to
- the C/C++ ``memory_order_seq_cst`` and Java ``volatile``.
+ the C/C++ `memory_order_seq_cst` and Java `volatile`.
Note: this global total order is *not* guaranteed to be fully
consistent with the *happens-before* partial order if
- non-``seq_cst`` accesses are involved. See the C++ standard
- `[atomics.order] <https://wg21.link/atomics.order>`_ section
+ non-`seq_cst` accesses are involved. See the C++ standard
+ [[atomics.order]](https://wg21.link/atomics.order) section
for more details on the exact guarantees.
-.. _syncscope:
+(syncscope)=
-If an atomic operation is marked ``syncscope("singlethread")``, it only
+If an atomic operation is marked `syncscope("singlethread")`, it only
*synchronizes with* other operations running in the same thread (for
-example, in signal handlers) and it is related in the seq\_cst order and
+example, in signal handlers) and it is related in the `seq_cst` order and
the monotonic modification order with other operations in the same
thread.
-If an atomic operation is marked ``syncscope("<target-scope>")``, where
-``<target-scope>`` is a target-specific synchronization scope, then it
+If an atomic operation is marked `syncscope("<target-scope>")`, where
+`<target-scope>` is a target-specific synchronization scope, then it
is target-dependent if it *synchronizes with* other operations and
-if it is related with other operations in the seq\_cst order and the
+if it is related with other operations in the `seq_cst` order and the
monotonic modification order.
Otherwise, an atomic operation that is not marked
-``syncscope("singlethread")`` or ``syncscope("<target-scope>")``
-*synchronizes with* and is related in the seq\_cst order and the
+`syncscope("singlethread")` or `syncscope("<target-scope>")`
+*synchronizes with* and is related in the `seq_cst` order and the
monotonic modification order with other operations that are not marked
-``syncscope("singlethread")`` or ``syncscope("<target-scope>")``.
+`syncscope("singlethread")` or `syncscope("<target-scope>")`.
-.. _floatenv:
+(floatenv)=
-Floating-Point Environment
---------------------------
+### Floating-Point Environment
The default LLVM floating-point environment assumes that traps are disabled and
status flags are not observable. Therefore, floating-point math operations do
@@ -4096,31 +4187,30 @@ not have side effects and may be speculated freely. Results assume the
round-to-nearest rounding mode, and subnormals are assumed to be preserved.
Running LLVM code in an environment where these assumptions are not met
-typically leads to undefined behavior. The ``strictfp`` and
-:ref:`denormal_fpenv <denormal_fpenv>` attributes as well as
-:ref:`Constrained Floating-Point Intrinsics <constrainedfp>` can be
+typically leads to undefined behavior. The `strictfp` and
+{ref}`denormal_fpenv <denormal_fpenv>` attributes as well as
+{ref}`Constrained Floating-Point Intrinsics <constrainedfp>` can be
used to weaken LLVM's assumptions and ensure defined behavior in
non-default floating-point environments; see their respective
documentation for details.
-.. _floatnan:
+(floatnan)=
-Behavior of Floating-Point NaN values
--------------------------------------
+### Behavior of Floating-Point NaN values
A floating-point NaN value consists of a sign bit, a quiet/signaling bit, and a
payload (which makes up the rest of the mantissa except for the quiet/signaling
-bit). LLVM assumes that the quiet/signaling bit being set to ``1`` indicates a
-quiet NaN (QNaN), and a value of ``0`` indicates a signaling NaN (SNaN). In the
+bit). LLVM assumes that the quiet/signaling bit being set to `1` indicates a
+quiet NaN (QNaN), and a value of `0` indicates a signaling NaN (SNaN). In the
following we will hence just call it the "quiet bit".
The representation bits of a floating-point value do not mutate arbitrarily; in
particular, if there is no floating-point operation being performed, NaN signs,
quiet bits, and payloads are preserved.
-For the purpose of this section, ``bitcast`` as well as the following operations
-are not "floating-point math operations": ``fneg``, ``llvm.fabs``, and
-``llvm.copysign``. These operations act directly on the underlying bit
+For the purpose of this section, `bitcast` as well as the following operations
+are not "floating-point math operations": `fneg`, `llvm.fabs`, and
+`llvm.copysign`. These operations act directly on the underlying bit
representation and never change anything except possibly for the sign bit.
Floating-point math operations that return a NaN are an exception from the
@@ -4153,7 +4243,7 @@ Floating-point math operations are allowed to treat all NaNs as if they were
quiet NaNs. For example, "pow(1.0, SNaN)" may be simplified to 1.0.
Code that requires different behavior than this should use the
-:ref:`Constrained Floating-Point Intrinsics <constrainedfp>`.
+{ref}`Constrained Floating-Point Intrinsics <constrainedfp>`.
In particular, constrained intrinsics rule out the "Unchanged NaN propagation"
case; they are guaranteed to return a QNaN.
@@ -4164,29 +4254,26 @@ specification on some architectures:
back when performing floating-point math operations; this can lead to results
with different precision than expected and it can alter NaN values. Since
optimizations can make contradicting assumptions, this can lead to arbitrary
- miscompilations. See `issue #44218
- <https://github.com/llvm/llvm-project/issues/44218>`_.
+ miscompilations. See [issue #44218](https://github.com/llvm/llvm-project/issues/44218).
- x86-32 (even with SSE2 enabled) may implicitly perform such a conversion on
- values returned from a function for some calling conventions. See `issue
- #66803 <https://github.com/llvm/llvm-project/issues/66803>`_.
+ values returned from a function for some calling conventions. See [issue
+ #66803](https://github.com/llvm/llvm-project/issues/66803).
- Older MIPS versions use the opposite polarity for the quiet/signaling bit, and
- LLVM does not correctly represent this. See `issue #60796
- <https://github.com/llvm/llvm-project/issues/60796>`_.
+ LLVM does not correctly represent this. See [issue #60796](https://github.com/llvm/llvm-project/issues/60796).
-.. _floatsem:
+(floatsem)=
-Floating-Point Semantics
-------------------------
+### Floating-Point Semantics
This section defines the semantics for core floating-point operations on types
-that use a format specified by IEEE 754. These types are: ``half``, ``float``,
-``double``, and ``fp128``, which correspond to the binary16, binary32, binary64,
+that use a format specified by IEEE 754. These types are: `half`, `float`,
+`double`, and `fp128`, which correspond to the binary16, binary32, binary64,
and binary128 formats, respectively. The "core" operations are those defined in
section 5 of IEEE 754, which all have corresponding LLVM operations.
The value returned by those operations matches that of the corresponding
-IEEE 754 operation executed in the :ref:`default LLVM floating-point environment
-<floatenv>`, except that the behavior of NaN results is instead :ref:`as
+IEEE 754 operation executed in the {ref}`default LLVM floating-point environment
+<floatenv>`, except that the behavior of NaN results is instead {ref}`as
specified here <floatnan>`. In particular, such a floating-point instruction
returning a non-NaN value is guaranteed to always return the same bit-identical
result on all machines and optimization levels.
@@ -4197,60 +4284,58 @@ can rely on these operations providing correctly rounded results as described in
the standard.
(Note that this is only about the value returned by these operations; see the
-:ref:`floating-point environment section <floatenv>` regarding flags and
+{ref}`floating-point environment section <floatenv>` regarding flags and
exceptions.)
Various flags, attributes, and metadata can alter the behavior of these
operations and thus make them not bit-identical across machines and optimization
-levels any more: most notably, the :ref:`fast-math flags <fastmath>` as well as
-the :ref:`strictfp <strictfp>` and :ref:`denormal_fpenv <denormal_fpenv>`
-attributes and :ref:`!fpmath metadata <fpmath-metadata>`. See their
+levels any more: most notably, the {ref}`fast-math flags <fastmath>` as well as
+the {ref}`strictfp <strictfp>` and {ref}`denormal_fpenv <denormal_fpenv>`
+attributes and {ref}`!fpmath metadata <fpmath-metadata>`. See their
corresponding documentation for details.
-.. _fastmath:
+(fastmath)=
-Fast-Math Flags
----------------
+### Fast-Math Flags
-LLVM IR floating-point operations (:ref:`fneg <i_fneg>`, :ref:`fadd <i_fadd>`,
-:ref:`fsub <i_fsub>`, :ref:`fmul <i_fmul>`, :ref:`fdiv <i_fdiv>`,
-:ref:`frem <i_frem>`, :ref:`fcmp <i_fcmp>`, :ref:`fptrunc <i_fptrunc>`,
-:ref:`fpext <i_fpext>`), :ref::`uitofp <i_uitofp>`, :ref::`sitofp <i_sitofp>`,
-and :ref:`phi <i_phi>`, :ref:`select <i_select>`, or :ref:`call <i_call>`
+LLVM IR floating-point operations ({ref}`fneg <i_fneg>`, {ref}`fadd <i_fadd>`,
+{ref}`fsub <i_fsub>`, {ref}`fmul <i_fmul>`, {ref}`fdiv <i_fdiv>`,
+{ref}`frem <i_frem>`, {ref}`fcmp <i_fcmp>`, {ref}`fptrunc <i_fptrunc>`,
+{ref}`fpext <i_fpext>`), {ref}`uitofp <i_uitofp>`, {ref}`sitofp <i_sitofp>`,
+and {ref}`phi <i_phi>`, {ref}`select <i_select>`, or {ref}`call <i_call>`
instructions that return floating-point types may use the following flags to
enable otherwise unsafe floating-point transformations.
-``fast``
- This flag is a shorthand for specifying all fast-math flags at once, and
+`fast`
+: This flag is a shorthand for specifying all fast-math flags at once, and
imparts no additional semantics from using all of them.
-``nnan``
- No NaNs - Allow optimizations to assume the arguments and result are not
+`nnan`
+: No NaNs - Allow optimizations to assume the arguments and result are not
NaN. If an argument is a nan, or the result would be a nan, it produces
- a :ref:`poison value <poisonvalues>` instead.
+ a {ref}`poison value <poisonvalues>` instead.
-``ninf``
- No Infs - Allow optimizations to assume the arguments and result are not
+`ninf`
+: No Infs - Allow optimizations to assume the arguments and result are not
+/-Inf. If an argument is +/-Inf, or the result would be +/-Inf, it
- produces a :ref:`poison value <poisonvalues>` instead.
+ produces a {ref}`poison value <poisonvalues>` instead.
-``nsz``
- No Signed Zeros - Unless otherwise mentioned, the sign bit of 0.0 or -0.0
+`nsz`
+: No Signed Zeros - Unless otherwise mentioned, the sign bit of 0.0 or -0.0
input operands can be non-deterministically flipped. This does not imply
that -0.0 is poison and/or guaranteed to not exist in the operation.
-Note: For :ref:`phi <i_phi>`, :ref:`select <i_select>`, and :ref:`call <i_call>`
+Note: For {ref}`phi <i_phi>`, {ref}`select <i_select>`, and {ref}`call <i_call>`
instructions, the following return types are considered to be floating-point
types:
-.. _fastmath_return_types:
+(fastmath_return_types)=
- Floating-point scalar or vector types
- Array types (nested to any depth) of floating-point scalar or vector types
- Homogeneous literal struct types of floating-point scalar or vector types
-Rewrite-based flags
-^^^^^^^^^^^^^^^^^^^
+#### Rewrite-based flags
The following flags have rewrite-based semantics. These flags allow expressions,
potentially containing multiple non-consecutive instructions, to be rewritten
@@ -4259,67 +4344,66 @@ expression, it is necessary that all of the instructions have the necessary
rewrite-based flag present on them, and the rewritten instructions will
generally have the intersection of the flags present on the input instruction.
-In the following example, the floating-point expression in the body of ``@orig``
-has ``contract`` and ``reassoc`` in common, and thus if it is rewritten into the
-expression in the body of ``@target``, all of the new instructions get those two
-flags and only those flags as a result. Since the ``arcp`` is present on only
+In the following example, the floating-point expression in the body of `@orig`
+has `contract` and `reassoc` in common, and thus if it is rewritten into the
+expression in the body of `@target`, all of the new instructions get those two
+flags and only those flags as a result. Since the `arcp` is present on only
one of the instructions in the expression, it is not present in the transformed
expression. Furthermore, this reassociation here is only legal because both the
-instructions had the ``reassoc`` flag; if only one had it, it would not be legal
+instructions had the `reassoc` flag; if only one had it, it would not be legal
to make the transformation.
-.. code-block:: llvm
+```llvm
+define double @orig(double %a, double %b, double %c) {
+ %t1 = fmul contract reassoc double %a, %b
+ %val = fmul contract reassoc arcp double %t1, %c
+ ret double %val
+}
- define double @orig(double %a, double %b, double %c) {
- %t1 = fmul contract reassoc double %a, %b
- %val = fmul contract reassoc arcp double %t1, %c
- ret double %val
- }
-
- define double @target(double %a, double %b, double %c) {
- %t1 = fmul contract reassoc double %b, %c
- %val = fmul contract reassoc double %a, %t1
- ret double %val
- }
+define double @target(double %a, double %b, double %c) {
+ %t1 = fmul contract reassoc double %b, %c
+ %val = fmul contract reassoc double %a, %t1
+ ret double %val
+}
+```
These rules do not apply to the other fast-math flags. Whether or not a flag
-like ``nnan`` is present on any or all of the rewritten instructions is based
+like `nnan` is present on any or all of the rewritten instructions is based
on whether or not it is possible for said instruction to have a NaN input or
output, given the original flags.
-``arcp``
- Allows division to be treated as a multiplication by a reciprocal.
- Specifically, this permits ``a / b`` to be considered equivalent to
- ``a * (1.0 / b)`` (which may subsequently be susceptible to code motion),
- and it also permits ``a / (b / c)`` to be considered equivalent to
- ``a * (c / b)``. Both of these rewrites can be applied in either direction:
- ``a * (c / b)`` can be rewritten into ``a / (b / c)``.
+`arcp`
+: Allows division to be treated as a multiplication by a reciprocal.
+ Specifically, this permits `a / b` to be considered equivalent to
+ `a * (1.0 / b)` (which may subsequently be susceptible to code motion),
+ and it also permits `a / (b / c)` to be considered equivalent to
+ `a * (c / b)`. Both of these rewrites can be applied in either direction:
+ `a * (c / b)` can be rewritten into `a / (b / c)`.
-``contract``
- Allow floating-point contraction (e.g., fusing a multiply followed by an
+`contract`
+: Allow floating-point contraction (e.g., fusing a multiply followed by an
addition into a fused multiply-and-add). This does not enable reassociation
- to form arbitrary contractions. For example, ``(a*b) + (c*d) + e`` can not
- be transformed into ``(a*b) + ((c*d) + e)`` to create two fma operations.
+ to form arbitrary contractions. For example, `(a*b) + (c*d) + e` can not
+ be transformed into `(a*b) + ((c*d) + e)` to create two fma operations.
-.. _fastmath_afn:
+(fastmath_afn)=
-``afn``
- Approximate functions - Allow substitution of approximate calculations for
+`afn`
+: Approximate functions - Allow substitution of approximate calculations for
functions (sin, log, sqrt, etc). See floating-point intrinsic definitions
for places where this can apply to LLVM's intrinsic math functions.
-``reassoc``
- Allow algebraically equivalent transformations for floating-point
+`reassoc`
+: Allow algebraically equivalent transformations for floating-point
instructions such as reassociation transformations. This may dramatically
change results in floating-point.
-.. _uselistorder:
+(uselistorder)=
-Use-list Order Directives
--------------------------
+### Use-list Order Directives
Use-list directives encode the in-memory order of each use-list, allowing the
-order to be recreated. ``<order-indexes>`` is a comma-separated list of
+order to be recreated. `<order-indexes>` is a comma-separated list of
indexes that are assigned to the referenced value's uses. The referenced
value's use-list is immediately sorted by these indexes.
@@ -4327,36 +4411,35 @@ Use-list directives may appear at function scope or global scope. They are not
instructions, and have no effect on the semantics of the IR. When they're at
function scope, they must appear after the terminator of the final basic block.
-:Syntax:
-
-::
+**Syntax:**
- uselistorder <ty> <value>, { <order-indexes> }
+```
+uselistorder <ty> <value>, { <order-indexes> }
+```
-:Examples:
+**Examples:**
-::
+```
+define void @foo(i32 %arg1, i32 %arg2) {
+entry:
+ ; ... instructions ...
+bb:
+ ; ... instructions ...
- define void @foo(i32 %arg1, i32 %arg2) {
- entry:
- ; ... instructions ...
- bb:
- ; ... instructions ...
+ ; At function scope.
+ uselistorder i32 %arg1, { 1, 0, 2 }
+ uselistorder label %bb, { 1, 0 }
+}
- ; At function scope.
- uselistorder i32 %arg1, { 1, 0, 2 }
- uselistorder label %bb, { 1, 0 }
- }
+; At global scope.
+uselistorder ptr @global, { 1, 2, 0 }
+uselistorder i32 7, { 1, 0 }
+uselistorder i32 (i32) @bar, { 1, 0 }
+```
- ; At global scope.
- uselistorder ptr @global, { 1, 2, 0 }
- uselistorder i32 7, { 1, 0 }
- uselistorder i32 (i32) @bar, { 1, 0 }
+(source_filename)=
-.. _source_filename:
-
-Source Filename
----------------
+### Source Filename
The *source filename* string is set to the original module identifier,
which will be the name of the compiled source file when compiling from
@@ -4369,14 +4452,13 @@ source file name to the local function name.
The syntax for the source file name is simply:
-.. code-block:: text
-
- source_filename = "/path/to/source.c"
+```text
+source_filename = "/path/to/source.c"
+```
-.. _typesystem:
+(typesystem)=
-Type System
-===========
+## Type System
The LLVM type system is one of the most important features of the
intermediate representation. Being typed enables a number of
@@ -4386,223 +4468,220 @@ transformation. A strong type system makes it easier to read the
generated code and enables novel analyses and transformations that are
not feasible to perform on normal three address code representations.
-.. _t_void:
+(t_void)=
-Void Type
----------
+### Void Type
-:Overview:
+**Overview:**
The void type does not represent any value and has no size.
-:Syntax:
+**Syntax:**
-::
+```
+void
+```
- void
+(t_function)=
+### Function Type
-.. _t_function:
-
-Function Type
--------------
-
-:Overview:
+**Overview:**
The function type can be thought of as a function signature. It consists of a
return type and a list of formal parameter types. The return type of a function
-type is a void type or first class type --- except for :ref:`label <t_label>`
-and :ref:`metadata <t_metadata>` types.
+type is a void type or first class type --- except for {ref}`label <t_label>`
+and {ref}`metadata <t_metadata>` types.
-:Syntax:
+**Syntax:**
-::
+```
+<returntype> (<parameter list>)
+```
- <returntype> (<parameter list>)
-
-...where '``<parameter list>``' is a comma-separated list of type
-specifiers. Optionally, the parameter list may include a type ``...``, which
+...where '`<parameter list>`' is a comma-separated list of type
+specifiers. Optionally, the parameter list may include a type `...`, which
indicates that the function takes a variable number of arguments. Variable
-argument functions can access their arguments with the :ref:`variable argument
-handling intrinsic <int_varargs>` functions. '``<returntype>``' is any type
-except :ref:`label <t_label>` and :ref:`metadata <t_metadata>`.
+argument functions can access their arguments with the {ref}`variable argument
+handling intrinsic <int_varargs>` functions. '`<returntype>`' is any type
+except {ref}`label <t_label>` and {ref}`metadata <t_metadata>`.
+
+**Examples:**
-:Examples:
+```{list-table}
+:header-rows: 0
-+---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``i32 (i32)`` | function taking an ``i32``, returning an ``i32`` |
-+---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``i32 (ptr, ...)`` | A vararg function that takes at least one :ref:`pointer <t_pointer>` argument and returns an integer. This is the signature for ``printf`` in LLVM. |
-+---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``{i32, i32} (i32)`` | A function taking an ``i32``, returning a :ref:`structure <t_struct>` containing two ``i32`` values |
-+---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+* - `i32 (i32)`
+ - function taking an `i32`, returning an `i32`
+* - `i32 (ptr, ...)`
+ - A vararg function that takes at least one {ref}`pointer <t_pointer>` argument and returns an integer. This is the signature for `printf` in LLVM.
+* - `{i32, i32} (i32)`
+ - A function taking an `i32`, returning a {ref}`structure <t_struct>` containing two `i32` values
+```
-.. _t_opaque:
+(t_opaque)=
-Opaque Structure Types
-----------------------
+### Opaque Structure Types
-:Overview:
+**Overview:**
Opaque structure types are used to represent structure types that
do not have a body specified. This corresponds (for example) to the C
-notion of a forward declared structure. They can be named (``%X``) or
-unnamed (``%52``).
+notion of a forward declared structure. They can be named (`%X`) or
+unnamed (`%52`).
It is not possible to create SSA values with an opaque structure type. In
practice, this largely limits their use to the value type of external globals.
-:Syntax:
+**Syntax:**
-::
+```
+%X = type opaque
+%52 = type opaque
- %X = type opaque
- %52 = type opaque
+ at g = external global %X
+```
- @g = external global %X
+(t_firstclass)=
-.. _t_firstclass:
+### First Class Types
-First Class Types
------------------
-
-The :ref:`first class <t_firstclass>` types are perhaps the most important.
+The {ref}`first class <t_firstclass>` types are perhaps the most important.
Values of these types are the only ones which can be produced by
instructions.
-.. _t_single_value:
+(t_single_value)=
-Single Value Types
-^^^^^^^^^^^^^^^^^^
+#### Single Value Types
These are the types that are valid in registers from CodeGen's perspective.
-.. _t_integer:
+(t_integer)=
-Integer Type
-""""""""""""
+##### Integer Type
-:Overview:
+**Overview:**
The integer type is a very simple type that simply specifies an
arbitrary bit width for the integer type desired. Any bit width from 1
-bit to 2\ :sup:`23`\ (about 8 million) can be specified.
-
-:Syntax:
+bit to 2{sup}`23` (about 8 million) can be specified.
-::
+**Syntax:**
- iN
+```
+iN
+```
-The number of bits the integer will occupy is specified by the ``N``
+The number of bits the integer will occupy is specified by the `N`
value.
-Examples:
-*********
+###### Examples:
+
+```{list-table}
+:header-rows: 0
-+----------------+------------------------------------------------+
-| ``i1`` | a single-bit integer. |
-+----------------+------------------------------------------------+
-| ``i32`` | a 32-bit integer. |
-+----------------+------------------------------------------------+
-| ``i1942652`` | a really big integer of over 1 million bits. |
-+----------------+------------------------------------------------+
+* - `i1`
+ - a single-bit integer.
+* - `i32`
+ - a 32-bit integer.
+* - `i1942652`
+ - a really big integer of over 1 million bits.
+```
-.. _t_byte:
+(t_byte)=
-Byte Type
-"""""""""
+##### Byte Type
-:Overview:
+**Overview:**
The byte type represents raw memory data in SSA registers. It should be used
when it cannot be determined whether a value holds a pointer or another type at
run time, or if the value contains uninitialized or poison data. Frontends are
expected to use a byte type when:
-#. Lowering memory operations like `memcpy` and `memmove` to load/store pairs
+1. Lowering memory operations like `memcpy` and `memmove` to load/store pairs
without knowing the underlying type being copied.
-#. Working with union types that can hold a pointer alongside a non-pointer
+1. Working with union types that can hold a pointer alongside a non-pointer
type.
-#. Working with possibly uninitialized data.
+1. Working with possibly uninitialized data.
Otherwise, when known, the specific type should be used. Each bit can be:
* An integer bit (0 or 1)
* Part of a pointer value
-* ``poison``
+* `poison`
-Any bit width from 1 bit to 2\ :sup:`23`\ (about 8 million) can be specified.
+Any bit width from 1 bit to 2{sup}`23` (about 8 million) can be specified.
The per-bit semantics described above (poison and conditional pointer
provenance preservation) are mid-end only. At the IR-to-MIR boundary both
-SelectionDAG and GlobalISel lower ``bN`` as the equi-sized integer scalar
-(``iN``/``sN``); backend passes do not see the byte type and do not preserve
+SelectionDAG and GlobalISel lower `bN` as the equi-sized integer scalar
+(`iN`/`sN`); backend passes do not see the byte type and do not preserve
its bit-level semantics.
-:Syntax:
+**Syntax:**
-::
+```
+bN
+```
- bN
+The number of bits the byte occupies is specified by the `N` value.
-The number of bits the byte occupies is specified by the ``N`` value.
+###### Examples:
-Examples:
-*********
-
-+----------------+------------------------------------------------+
-| ``b1`` | a single-bit byte value. |
-+----------------+------------------------------------------------+
-| ``b32`` | a 32-bit byte value. |
-+----------------+------------------------------------------------+
-| ``b128`` | a 128-bit byte value. |
-+----------------+------------------------------------------------+
+```{list-table}
+:header-rows: 0
-.. _t_floating:
+* - `b1`
+ - a single-bit byte value.
+* - `b32`
+ - a 32-bit byte value.
+* - `b128`
+ - a 128-bit byte value.
+```
-Floating-Point Types
-""""""""""""""""""""
+(t_floating)=
-.. list-table::
- :header-rows: 1
+##### Floating-Point Types
- * - Type
- - Description
+```{list-table}
+:header-rows: 1
+* - Type
+ - Description
- * - ``half``
- - 16-bit floating-point value (IEEE 754 binary16)
+* - `half`
+ - 16-bit floating-point value (IEEE 754 binary16)
- * - ``bfloat``
- - 16-bit "brain" floating-point value (7-bit significand). Provides the
- same number of exponent bits as ``float``, so that it matches its dynamic
- range, but with greatly reduced precision. Used in Intel's AVX-512 BF16
- extensions and Arm's ARMv8.6-A extensions, among others.
+* - `bfloat`
+ - 16-bit "brain" floating-point value (7-bit significand). Provides the
+ same number of exponent bits as `float`, so that it matches its dynamic
+ range, but with greatly reduced precision. Used in Intel's AVX-512 BF16
+ extensions and Arm's ARMv8.6-A extensions, among others.
- * - ``float``
- - 32-bit floating-point value (IEEE 754 binary32)
+* - `float`
+ - 32-bit floating-point value (IEEE 754 binary32)
- * - ``double``
- - 64-bit floating-point value (IEEE 754 binary64)
+* - `double`
+ - 64-bit floating-point value (IEEE 754 binary64)
- * - ``fp128``
- - 128-bit floating-point value (IEEE 754 binary128)
+* - `fp128`
+ - 128-bit floating-point value (IEEE 754 binary128)
- * - ``x86_fp80``
- - 80-bit floating-point value (X87)
+* - `x86_fp80`
+ - 80-bit floating-point value (X87)
- * - ``ppc_fp128``
- - 128-bit floating-point value (two 64-bits)
+* - `ppc_fp128`
+ - 128-bit floating-point value (two 64-bits)
+```
-X86_amx Type
-""""""""""""
+##### X86_amx Type
-:Overview:
+**Overview:**
The x86_amx type represents a value held in an AMX tile register on an x86
machine. The operations allowed on it are quite limited. Only a few intrinsics
@@ -4610,36 +4689,33 @@ are allowed: stride load and store, zero and dot product. No instruction is
allowed for this type. There are no arguments, arrays, pointers, vectors
or constants of this type.
-:Syntax:
+**Syntax:**
-::
+```
+x86_amx
+```
- x86_amx
+(t_pointer)=
+##### Pointer Type
+**Overview:**
-.. _t_pointer:
-
-Pointer Type
-""""""""""""
-
-:Overview:
-
-The pointer type ``ptr`` is used to specify memory locations. Pointers are
+The pointer type `ptr` is used to specify memory locations. Pointers are
commonly used to reference objects in memory.
Pointer types may have an optional address space attribute defining
the numbered address space where the pointed-to object resides. For
-example, ``ptr addrspace(5)`` is a pointer to address space 5.
-In addition to integer constants, ``addrspace`` can also reference one of the
-address spaces defined in the :ref:`datalayout string<langref_datalayout>`.
-``addrspace("A")`` will use the alloca address space, ``addrspace("G")``
-the default globals address space and ``addrspace("P")`` the program address
+example, `ptr addrspace(5)` is a pointer to address space 5.
+In addition to integer constants, `addrspace` can also reference one of the
+address spaces defined in the {ref}`datalayout string<langref_datalayout>`.
+`addrspace("A")` will use the alloca address space, `addrspace("G")`
+the default globals address space and `addrspace("P")` the program address
space.
The representation of pointers can be different for each address space and does
not necessarily need to be a plain integer address (e.g., for
-:ref:`non-integral pointers <nointptrtype>`). In addition to a representation
+{ref}`non-integral pointers <nointptrtype>`). In addition to a representation
bits size, pointers in each address space also have an index size which defines
the bitwidth of indexing operations as well as the size of `integer addresses`
in this address space. For example, CHERI capabilities are twice the size of the
@@ -4653,44 +4729,43 @@ The semantics of non-zero address spaces are target-specific. Memory
access through a non-dereferenceable pointer is undefined behavior in
any address space. Pointers with the bit-value 0 are only assumed to
be non-dereferenceable in address space 0, unless the function is
-marked with the ``null_pointer_is_valid`` attribute. However, *volatile*
+marked with the `null_pointer_is_valid` attribute. However, *volatile*
access to any non-dereferenceable address may have defined behavior
(according to the target), and in this case the attribute is not needed
even for address 0.
If an object can be proven accessible through a pointer with a
different address space, the access may be modified to use that
-address space. Exceptions apply if the operation is ``volatile``.
+address space. Exceptions apply if the operation is `volatile`.
Prior to LLVM 15, pointer types also specified a pointee type, such as
-``i8*``, ``[4 x i32]*`` or ``i32 (i32*)*``. In LLVM 15, such "typed
+`i8*`, `[4 x i32]*` or `i32 (i32*)*`. In LLVM 15, such "typed
pointers" are still supported under non-default options. See the
-`opaque pointers document <OpaquePointers.html>`__ for more information.
+{doc}`opaque pointers document <OpaquePointers>` for more information.
-.. _t_target_type:
+(t_target_type)=
-Target Extension Type
-"""""""""""""""""""""
+##### Target Extension Type
-:Overview:
+**Overview:**
Target extension types represent types that must be preserved through
optimization, but are otherwise generally opaque to the compiler. They may be
-used as function parameters or arguments, and in :ref:`phi <i_phi>` or
-:ref:`select <i_select>` instructions. Some types may be also used in
-:ref:`alloca <i_alloca>` instructions or as global values, and correspondingly
-it is legal to use :ref:`load <i_load>` and :ref:`store <i_store>` instructions
+used as function parameters or arguments, and in {ref}`phi <i_phi>` or
+{ref}`select <i_select>` instructions. Some types may be also used in
+{ref}`alloca <i_alloca>` instructions or as global values, and correspondingly
+it is legal to use {ref}`load <i_load>` and {ref}`store <i_store>` instructions
on them. Full semantics for these types are defined by the target.
-The only constants that target extension types may have are ``zeroinitializer``,
-``undef``, and ``poison``. Other possible values for target extension types may
+The only constants that target extension types may have are `zeroinitializer`,
+`undef`, and `poison`. Other possible values for target extension types may
arise from target-specific intrinsics and functions.
These types cannot be converted to other types. As such, it is not legal to use
-them in :ref:`bitcast <i_bitcast>` instructions (as a source or target type),
-nor is it legal to use them in :ref:`ptrtoint <i_ptrtoint>` or
-:ref:`inttoptr <i_inttoptr>` instructions. Similarly, they are not legal to use
-in an :ref:`icmp <i_icmp>` instruction.
+them in {ref}`bitcast <i_bitcast>` instructions (as a source or target type),
+nor is it legal to use them in {ref}`ptrtoint <i_ptrtoint>` or
+{ref}`inttoptr <i_inttoptr>` instructions. Similarly, they are not legal to use
+in an {ref}`icmp <i_icmp>` instruction.
Target extension types have a name and optional type or integer parameters. The
meanings of name and parameters are defined by the target. When being defined in
@@ -4699,27 +4774,25 @@ LLVM IR, all of the type parameters must precede all of the integer parameters.
Specific target extension types are registered with LLVM as having specific
properties. These properties can be used to restrict the type from appearing in
certain contexts, such as being the type of a global variable or having a
-``zeroinitializer`` constant be valid. A complete list of type properties may be
-found in the documentation for ``llvm::TargetExtType::Property`` (`doxygen
-<https://llvm.org/doxygen/classllvm_1_1TargetExtType.html>`_).
-
-:Syntax:
+`zeroinitializer` constant be valid. A complete list of type properties may be
+found in the documentation for `llvm::TargetExtType::Property`
+([doxygen](https://llvm.org/doxygen/classllvm_1_1TargetExtType.html)).
-.. code-block:: llvm
+**Syntax:**
- target("label")
- target("label", void)
- target("label", void, i32)
- target("label", 0, 1, 2)
- target("label", void, i32, 0, 1, 2)
+```llvm
+target("label")
+target("label", void)
+target("label", void, i32)
+target("label", 0, 1, 2)
+target("label", void, i32, 0, 1, 2)
+```
+(t_vector)=
-.. _t_vector:
+##### Vector Type
-Vector Type
-"""""""""""
-
-:Overview:
+**Overview:**
A vector type is a simple derived type that represents a vector of
elements. Vector types are used when multiple primitive data are
@@ -4727,15 +4800,15 @@ operated in parallel using a single instruction (SIMD). A vector type
requires a size (number of elements), an underlying primitive data type,
and a scalable property to represent vectors where the exact hardware
vector length is unknown at compile time. Vector types are considered
-:ref:`first class <t_firstclass>`.
+{ref}`first class <t_firstclass>`.
-:Memory Layout:
+**Memory Layout:**
In general vector elements are laid out in memory in the same way as
-:ref:`array types <t_array>`. Such an analogy works fine as long as the vector
+{ref}`array types <t_array>`. Such an analogy works fine as long as the vector
elements are byte sized. However, when the elements of the vector aren't byte
sized it gets a bit more complicated. One way to describe the layout is by
-describing what happens when a vector such as <N x iM> is bitcasted to an
+describing what happens when a vector such as `<N x iM>` is bitcasted to an
integer type with N*M bits, and then following the rules for storing such an
integer to memory.
@@ -4745,57 +4818,57 @@ inserted in the integer depends on endianness. For little endian element zero
is put in the least significant bits of the integer, and for big endian
element zero is put in the most significant bits.
-Using a vector such as ``<i4 1, i4 2, i4 3, i4 5>`` as an example, together
+Using a vector such as `<i4 1, i4 2, i4 3, i4 5>` as an example, together
with the analogy that we can replace a vector store by a bitcast followed by
an integer store, we get this for big endian:
-.. code-block:: llvm
-
- %val = bitcast <4 x i4> <i4 1, i4 2, i4 3, i4 5> to i16
+```llvm
+%val = bitcast <4 x i4> <i4 1, i4 2, i4 3, i4 5> to i16
- ; Bitcasting from a vector to an integral type can be seen as
- ; concatenating the values:
- ; %val now has the hexadecimal value 0x1235.
+; Bitcasting from a vector to an integral type can be seen as
+; concatenating the values:
+; %val now has the hexadecimal value 0x1235.
- store i16 %val, ptr %ptr
+store i16 %val, ptr %ptr
- ; In memory the content will be (8-bit addressing):
- ;
- ; [%ptr + 0]: 00010010 (0x12)
- ; [%ptr + 1]: 00110101 (0x35)
+; In memory the content will be (8-bit addressing):
+;
+; [%ptr + 0]: 00010010 (0x12)
+; [%ptr + 1]: 00110101 (0x35)
+```
The same example for little endian:
-.. code-block:: llvm
+```llvm
+%val = bitcast <4 x i4> <i4 1, i4 2, i4 3, i4 5> to i16
- %val = bitcast <4 x i4> <i4 1, i4 2, i4 3, i4 5> to i16
+; Bitcasting from a vector to an integral type can be seen as
+; concatenating the values:
+; %val now has the hexadecimal value 0x5321.
- ; Bitcasting from a vector to an integral type can be seen as
- ; concatenating the values:
- ; %val now has the hexadecimal value 0x5321.
+store i16 %val, ptr %ptr
- store i16 %val, ptr %ptr
+; In memory the content will be (8-bit addressing):
+;
+; [%ptr + 0]: 00100001 (0x21)
+; [%ptr + 1]: 01010011 (0x53)
+```
- ; In memory the content will be (8-bit addressing):
- ;
- ; [%ptr + 0]: 00100001 (0x21)
- ; [%ptr + 1]: 01010011 (0x53)
-
-When ``<N*M>`` isn't evenly divisible by the byte size the exact memory layout
+When `<N*M>` isn't evenly divisible by the byte size the exact memory layout
is unspecified (just like it is for an integral type of the same size). This
is because different targets could put the padding at different positions when
the type size is smaller than the type's store size.
-:Syntax:
-
-::
+**Syntax:**
- < <# elements> x <elementtype> > ; Fixed-length vector
- < vscale x <# elements> x <elementtype> > ; Scalable vector
+```
+< <# elements> x <elementtype> > ; Fixed-length vector
+< vscale x <# elements> x <elementtype> > ; Scalable vector
+```
The number of elements is a constant integer value larger than 0;
elementtype may be any integer, floating-point, pointer type, or a sized
-target extension type that has the ``CanBeVectorElement`` property. Vectors
+target extension type that has the `CanBeVectorElement` property. Vectors
of size zero are not allowed. For scalable vectors, the total number of
elements is a constant multiple (called vscale) of the specified number
of elements; vscale is a positive power-of-two integer that is unknown at
@@ -4803,143 +4876,144 @@ compile time and the same hardware-dependent constant for all scalable vectors
at run time. The size of a specific scalable vector type is thus constant within
IR, even if the exact size in bytes cannot be determined until run time.
-:Examples:
+**Examples:**
-+------------------------+----------------------------------------------------+
-| ``<4 x i32>`` | Vector of 4 32-bit integer values. |
-+------------------------+----------------------------------------------------+
-| ``<8 x float>`` | Vector of 8 32-bit floating-point values. |
-+------------------------+----------------------------------------------------+
-| ``<2 x i64>`` | Vector of 2 64-bit integer values. |
-+------------------------+----------------------------------------------------+
-| ``<4 x ptr>`` | Vector of 4 pointers |
-+------------------------+----------------------------------------------------+
-| ``<vscale x 4 x i32>`` | Vector with a multiple of 4 32-bit integer values. |
-+------------------------+----------------------------------------------------+
+```{list-table}
+:header-rows: 0
-.. _t_label:
+* - `<4 x i32>`
+ - Vector of 4 32-bit integer values.
+* - `<8 x float>`
+ - Vector of 8 32-bit floating-point values.
+* - `<2 x i64>`
+ - Vector of 2 64-bit integer values.
+* - `<4 x ptr>`
+ - Vector of 4 pointers
+* - `<vscale x 4 x i32>`
+ - Vector with a multiple of 4 32-bit integer values.
+```
-Label Type
-^^^^^^^^^^
+(t_label)=
-:Overview:
+#### Label Type
-The label type represents code labels.
+**Overview:**
-:Syntax:
+The label type represents code labels.
-::
+**Syntax:**
- label
+```
+label
+```
-.. _t_token:
+(t_token)=
-Token Type
-^^^^^^^^^^
+#### Token Type
-:Overview:
+**Overview:**
The token type is used when a value is associated with an instruction
but all uses of the value must not attempt to introspect or obscure it.
-As such, it is not appropriate to have a :ref:`phi <i_phi>` or
-:ref:`select <i_select>` of type token.
-
-:Syntax:
-
-::
+As such, it is not appropriate to have a {ref}`phi <i_phi>` or
+{ref}`select <i_select>` of type token.
- token
+**Syntax:**
+```
+token
+```
+(t_metadata)=
-.. _t_metadata:
+#### Metadata Type
-Metadata Type
-^^^^^^^^^^^^^
-
-:Overview:
+**Overview:**
The metadata type represents embedded metadata. No derived types may be
-created from metadata except for :ref:`function <t_function>` arguments.
-
-:Syntax:
+created from metadata except for {ref}`function <t_function>` arguments.
-::
+**Syntax:**
- metadata
+```
+metadata
+```
-.. _t_aggregate:
+(t_aggregate)=
-Aggregate Types
-^^^^^^^^^^^^^^^
+#### Aggregate Types
Aggregate Types are a subset of derived types that can contain multiple
-member types. :ref:`Arrays <t_array>` and :ref:`structs <t_struct>` are
-aggregate types. :ref:`Vectors <t_vector>` are not considered to be
+member types. {ref}`Arrays <t_array>` and {ref}`structs <t_struct>` are
+aggregate types. {ref}`Vectors <t_vector>` are not considered to be
aggregate types.
-.. _t_array:
+(t_array)=
-Array Type
-""""""""""
+##### Array Type
-:Overview:
+**Overview:**
The array type is a very simple derived type that arranges elements
sequentially in memory. The array type requires a size (number of
elements) and an underlying data type.
-:Syntax:
+**Syntax:**
-::
+```
+[<# elements> x <elementtype>]
+```
- [<# elements> x <elementtype>]
-
-The number of elements is a constant integer value; ``elementtype`` may
+The number of elements is a constant integer value; `elementtype` may
be any type with a size.
-:Examples:
+**Examples:**
+
+```{list-table}
+:header-rows: 0
-+------------------+--------------------------------------+
-| ``[40 x i32]`` | Array of 40 32-bit integer values. |
-+------------------+--------------------------------------+
-| ``[41 x i32]`` | Array of 41 32-bit integer values. |
-+------------------+--------------------------------------+
-| ``[4 x i8]`` | Array of 4 8-bit integer values. |
-+------------------+--------------------------------------+
+* - `[40 x i32]`
+ - Array of 40 32-bit integer values.
+* - `[41 x i32]`
+ - Array of 41 32-bit integer values.
+* - `[4 x i8]`
+ - Array of 4 8-bit integer values.
+```
Here are some examples of multidimensional arrays:
-+-----------------------------+----------------------------------------------------------+
-| ``[3 x [4 x i32]]`` | 3x4 array of 32-bit integer values. |
-+-----------------------------+----------------------------------------------------------+
-| ``[12 x [10 x float]]`` | 12x10 array of single precision floating-point values. |
-+-----------------------------+----------------------------------------------------------+
-| ``[2 x [3 x [4 x i16]]]`` | 2x3x4 array of 16-bit integer values. |
-+-----------------------------+----------------------------------------------------------+
+```{list-table}
+:header-rows: 0
+
+* - `[3 x [4 x i32]]`
+ - 3x4 array of 32-bit integer values.
+* - `[12 x [10 x float]]`
+ - 12x10 array of single precision floating-point values.
+* - `[2 x [3 x [4 x i16]]]`
+ - 2x3x4 array of 16-bit integer values.
+```
There is no restriction on indexing beyond the end of the array implied
by a static type (though there are restrictions on indexing beyond the
-bounds of an :ref:`allocated object<allocatedobjects>` in some cases). This
+bounds of an {ref}`allocated object<allocatedobjects>` in some cases). This
means that single-dimension 'variable sized array' addressing can be implemented
in LLVM with a zero length array type. An implementation of 'pascal style
-arrays' in LLVM could use the type "``{ i32, [0 x float]}``", for example.
+arrays' in LLVM could use the type "`{ i32, [0 x float]}`", for example.
-.. _t_struct:
+(t_struct)=
-Structure Type
-""""""""""""""
+##### Structure Type
-:Overview:
+**Overview:**
The structure type is used to represent a collection of data members
together in memory. The elements of a structure may be any type that has
a size.
-Structures in memory are accessed using '``load``' and '``store``' by
-getting a pointer to a field with the '``getelementptr``' instruction.
-Structures in registers are accessed using the '``extractvalue``' and
-'``insertvalue``' instructions.
+Structures in memory are accessed using '`load`' and '`store`' by
+getting a pointer to a field with the '`getelementptr`' instruction.
+Structures in registers are accessed using the '`extractvalue`' and
+'`insertvalue`' instructions.
Structures may optionally be "packed" structures, which indicate that
the alignment of the struct is one byte, and that there is no padding
@@ -4948,61 +5022,65 @@ is inserted as defined by the DataLayout string in the module, which is
required to match what the underlying code generator expects.
Structures can either be "literal" or "identified". A literal structure
-is defined inline with other types (e.g., ``[2 x {i32, i32}]``) whereas
+is defined inline with other types (e.g., `[2 x {i32, i32}]`) whereas
identified types are always defined at the top level with a name.
Literal types are uniqued by their contents and can never be recursive
or opaque since there is no way to write one. Identified types can be
opaqued and are never uniqued. Identified types must not be recursive.
-:Syntax:
+**Syntax:**
-::
+```
+%T1 = type { <type list> } ; Identified normal struct type
+%T2 = type <{ <type list> }> ; Identified packed struct type
+```
- %T1 = type { <type list> } ; Identified normal struct type
- %T2 = type <{ <type list> }> ; Identified packed struct type
+**Examples:**
-:Examples:
+```{list-table}
+:header-rows: 0
-+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``{ i32, i32, i32 }`` | A triple of three ``i32`` values (this is a "homogeneous" struct as all element types are the same) |
-+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``{ float, ptr }`` | A pair, where the first element is a ``float`` and the second element is a :ref:`pointer <t_pointer>`. |
-+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| ``<{ i8, i32 }>`` | A packed struct known to be 5 bytes in size. |
-+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+* - `{ i32, i32, i32 }`
+ - A triple of three `i32` values (this is a "homogeneous" struct as all element types are the same)
+* - `{ float, ptr }`
+ - A pair, where the first element is a `float` and the second element is a {ref}`pointer <t_pointer>`.
+* - `<{ i8, i32 }>`
+ - A packed struct known to be 5 bytes in size.
+```
-.. _constants:
+(constants)=
-Constants
-=========
+## Constants
LLVM has several different basic types of constants. This section
describes them all and their syntax.
-Simple Constants
-----------------
+### Simple Constants
**Boolean constants**
- The two strings '``true``' and '``false``' are both valid constants
- of the ``i1`` type.
+: The two strings '`true`' and '`false`' are both valid constants
+ of the `i1` type.
+
**Integer constants**
- Standard integers (such as '4') are constants of the :ref:`integer
- <t_integer>` type. They can be either decimal or
+: Standard integers (such as '4') are constants of the {ref}`integer
+<t_integer>` type. They can be either decimal or
hexadecimal. Decimal integers can be prefixed with - to represent
- negative integers, e.g., '``-1234``'. Hexadecimal integers must be
+ negative integers, e.g., '`-1234`'. Hexadecimal integers must be
prefixed with either u or s to indicate whether they are unsigned
- or signed respectively. e.g '``u0x8000``' gives 32768, whilst
- '``s0x8000``' gives -32768.
+ or signed respectively. e.g '`u0x8000`' gives 32768, whilst
+ '`s0x8000`' gives -32768.
Note that hexadecimal integers are sign extended from the number
of active bits, i.e., the bit width minus the number of leading
- zeros. So '``s0x0001``' of type '``i16``' will be -1, not 1.
+ zeros. So '`s0x0001`' of type '`i16`' will be -1, not 1.
+
**Byte constants**
- Byte constants are used to initialize global variables of the :ref:`byte
- <t_byte>` type. These are strictly equivalent to integer constants:
- ``store b8 42, ptr %p`` is equivalent to ``store i8 42, ptr %p``.
+: Byte constants are used to initialize global variables of the {ref}`byte
+<t_byte>` type. These are strictly equivalent to integer constants:
+ `store b8 42, ptr %p` is equivalent to `store i8 42, ptr %p`.
+
**Floating-point constants**
- Floating-point constants use standard decimal notation (e.g.
+: Floating-point constants use standard decimal notation (e.g.
123.421), exponential notation (e.g. 1.23421e+2), standard hexadecimal
notation (e.g., 0x1.3effp-43), one of several special values, or a
precise bitstring for the underlying value. When converting decimal and
@@ -5010,280 +5088,288 @@ Simple Constants
using the default rounding mode (round to nearest, half to even). String
conversions that underflow to 0 or overflow to infinity are not permitted.
Floating-point constants must have a
- :ref:`floating-point <t_floating>` type.
+ {ref}`floating-point <t_floating>` type.
+
**Null pointer constants**
- The identifier '``null``' is recognized as a null pointer constant
- and must be of :ref:`pointer type <t_pointer>`.
+: The identifier '`null`' is recognized as a null pointer constant
+ and must be of {ref}`pointer type <t_pointer>`.
+
**Token constants**
- The identifier '``none``' is recognized as an empty token constant
- and must be of :ref:`token type <t_token>`.
+: The identifier '`none`' is recognized as an empty token constant
+ and must be of {ref}`token type <t_token>`.
Floating-point constants support the following kinds of strings:
- +----------------+---------------------------------------------------+
- | Syntax | Description |
- +================+===================================================+
- | ``+4.5e-13`` | Common decimal literal. Signs are optional, as is |
- | | the exponent portion. The decimal point is |
- | | required, as is one or more leading digits before |
- | | the decimal point. |
- +----------------+---------------------------------------------------+
- | ``-0x1.fp13`` | Common hexadecimal literal. Signs are optional. |
- | | The decimal point is required, as is the exponent |
- | | portion of the literal (after the ``p``). |
- +----------------+---------------------------------------------------+
- | ``+inf``, | Positive or negative infinity. The sign is |
- | ``-inf`` | required. |
- +----------------+---------------------------------------------------+
- | ``+qnan``, | Positive or negative preferred quiet NaN, i.e., |
- | ``-qnan`` | the quiet bit is set, and all other payload bits |
- | | are 0. The sign is required. |
- +----------------+---------------------------------------------------+
- | ``+nan(0x1)`` | qNaN value with a particular payload, specified |
- | | as hexadecimal (not including the quiet bit as |
- | | part of the payload). The sign is required. |
- +----------------+---------------------------------------------------+
- | ``+snan(0x1)`` | sNaN value with a particular payload, specified |
- | | as hexadecimal (not including the quiet bit as |
- | | part of the payload). The sign is required. |
- +----------------+---------------------------------------------------+
- | ``f0x3c00`` | Value of the floating-point number if bitcast to |
- | | an integer. The number must have exactly as many |
- | | hexadecimal digits as is necessary for the size |
- | | of the floating-point number. |
- +----------------+---------------------------------------------------+
+ ```{list-table}
+ :header-rows: 1
+
+ * - Syntax
+ - Description
+ * - `+4.5e-13`
+ - Common decimal literal. Signs are optional, as is
+ the exponent portion. The decimal point is
+ required, as is one or more leading digits before
+ the decimal point.
+ * - `-0x1.fp13`
+ - Common hexadecimal literal. Signs are optional.
+ The decimal point is required, as is the exponent
+ portion of the literal (after the `p`).
+ * - `+inf`,
+ `-inf`
+ - Positive or negative infinity. The sign is
+ required.
+ * - `+qnan`,
+ `-qnan`
+ - Positive or negative preferred quiet NaN, i.e.,
+ the quiet bit is set, and all other payload bits
+ are 0. The sign is required.
+ * - `+nan(0x1)`
+ - qNaN value with a particular payload, specified
+ as hexadecimal (not including the quiet bit as
+ part of the payload). The sign is required.
+ * - `+snan(0x1)`
+ - sNaN value with a particular payload, specified
+ as hexadecimal (not including the quiet bit as
+ part of the payload). The sign is required.
+ * - `f0x3c00`
+ - Value of the floating-point number if bitcast to
+ an integer. The number must have exactly as many
+ hexadecimal digits as is necessary for the size
+ of the floating-point number.
+ ```
There is a legacy syntax for hexadecimal floating-point literals that will be
removed in the future. In this format, constants are represented as their
-underlying integer representation as in the ``f0x3c00`` syntax, but instead
-use slightly different prefixes. ``float`` and ``double`` use ``0x`` followed
-by 16 hexadecimal digits representing the equivalent ``double`` value bitcast
-to an integer type. ``bfloat`` uses ``0xR`` followed by 4 hexadecimal digits.
-``half`` uses ``0xH`` followed by 4 hexadecimal digits. ``x86_fp80`` uses
-``0xK`` followed by 20 hexadecimal digits. ``ppc_fp128`` uses ``0xM``
-followed by 32 hexadecimal digits. ``fp128`` uses ``0xL`` followed by 32
+underlying integer representation as in the `f0x3c00` syntax, but instead
+use slightly different prefixes. `float` and `double` use `0x` followed
+by 16 hexadecimal digits representing the equivalent `double` value bitcast
+to an integer type. `bfloat` uses `0xR` followed by 4 hexadecimal digits.
+`half` uses `0xH` followed by 4 hexadecimal digits. `x86_fp80` uses
+`0xK` followed by 20 hexadecimal digits. `ppc_fp128` uses `0xM`
+followed by 32 hexadecimal digits. `fp128` uses `0xL` followed by 32
hexadecimal digits. For the last two types only, the bits are not fully
written in big-endian order but rather with the low 64 bits written in
big-endian then the high 64 bits written in big-endian.
There are no constants of type x86_amx.
-.. _complexconstants:
+(complexconstants)=
-Complex Constants
------------------
+### Complex Constants
Complex constants are a (potentially recursive) combination of simple
constants and smaller complex constants.
**Structure constants**
- Structure constants are represented with notation similar to
+: Structure constants are represented with notation similar to
structure type definitions (a comma separated list of elements,
- surrounded by braces (``{}``)). For example:
- "``{ i32 4, float 17.0, ptr @G }``", where "``@G``" is declared as
- "``@G = external global i32``". Structure constants must have
- :ref:`structure type <t_struct>`, and the number and types of elements
+ surrounded by braces (`{}`)). For example:
+ "`{ i32 4, float 17.0, ptr @G }`", where "`@G`" is declared as
+ "`@G = external global i32`". Structure constants must have
+ {ref}`structure type <t_struct>`, and the number and types of elements
must match those specified by the type.
+
**Array constants**
- Array constants are represented with notation similar to array type
+: Array constants are represented with notation similar to array type
definitions (a comma separated list of elements, surrounded by
- square brackets (``[]``)). For example:
- "``[ i32 42, i32 11, i32 74 ]``". Array constants must have
- :ref:`array type <t_array>`, and the number and types of elements must
+ square brackets (`[]`)). For example:
+ "`[ i32 42, i32 11, i32 74 ]`". Array constants must have
+ {ref}`array type <t_array>`, and the number and types of elements must
match those specified by the type. As a special case, character array
- constants may also be represented as a double-quoted string using the ``c``
- prefix. For example: "``c"Hello World\0A\00"``".
+ constants may also be represented as a double-quoted string using the `c`
+ prefix. For example: "`c"Hello World\0A\00"`".
+
**Vector constants**
- Vector constants are represented with notation similar to vector
+: Vector constants are represented with notation similar to vector
type definitions (a comma separated list of elements, surrounded by
- less-than/greater-than's (``<>``)). For example:
- "``< i32 42, i32 11, i32 74, i32 100 >``". Vector constants
- must have :ref:`vector type <t_vector>`, and the number and types of
+ less-than/greater-than's (`<>`)). For example:
+ "`< i32 42, i32 11, i32 74, i32 100 >`". Vector constants
+ must have {ref}`vector type <t_vector>`, and the number and types of
elements must match those specified by the type.
When creating a vector whose elements have the same constant value, the
- preferred syntax is ``splat (<Ty> Val)``. For example: "``splat (i32 11)``".
- These vector constants must have :ref:`vector type <t_vector>` with an
- element type that matches the ``splat`` operand.
+ preferred syntax is `splat (<Ty> Val)`. For example: "`splat (i32 11)`".
+ These vector constants must have {ref}`vector type <t_vector>` with an
+ element type that matches the `splat` operand.
+
**Zero initialization**
- The string '``zeroinitializer``' can be used to zero initialize a
+: The string '`zeroinitializer`' can be used to zero initialize a
value to zero of *any* type, including scalar and
- :ref:`aggregate <t_aggregate>` types. This is often used to avoid
+ {ref}`aggregate <t_aggregate>` types. This is often used to avoid
having to print large zero initializers (e.g., for large arrays) and
is always exactly equivalent to using explicit zero initializers.
+
**Metadata node**
- A metadata node is a constant tuple without types. For example:
- "``!{!0, !{!2, !0}, !"test"}``". Metadata can reference constant values,
- for example: "``!{!0, i32 0, ptr @global, ptr @function, !"str"}``".
+: A metadata node is a constant tuple without types. For example:
+ "`!{!0, !{!2, !0}, !"test"}`". Metadata can reference constant values,
+ for example: "`!{!0, i32 0, ptr @global, ptr @function, !"str"}`".
Unlike other typed constants that are meant to be interpreted as part of
the instruction stream, metadata is a place to attach additional
information such as debug info.
-Global Variable and Function Addresses
---------------------------------------
+### Global Variable and Function Addresses
-The addresses of :ref:`global variables <globalvars>` and
-:ref:`functions <functionstructure>` are always implicitly valid
+The addresses of {ref}`global variables <globalvars>` and
+{ref}`functions <functionstructure>` are always implicitly valid
(link-time) constants. These constants are explicitly referenced when
-the :ref:`identifier for the global <identifiers>` is used and always have
-:ref:`pointer <t_pointer>` type. For example, the following is a legal LLVM
+the {ref}`identifier for the global <identifiers>` is used and always have
+{ref}`pointer <t_pointer>` type. For example, the following is a legal LLVM
file:
-.. code-block:: llvm
-
- @X = global i32 17
- @Y = global i32 42
- @Z = global [2 x ptr] [ ptr @X, ptr @Y ]
+```llvm
+ at X = global i32 17
+ at Y = global i32 42
+ at Z = global [2 x ptr] [ ptr @X, ptr @Y ]
+```
-.. _undefvalues:
+(undefvalues)=
-Undefined Values
-----------------
+### Undefined Values
-The string '``undef``' can be used anywhere a constant is expected, and
+The string '`undef`' can be used anywhere a constant is expected, and
indicates that the user of the value may receive an unspecified
-bit-pattern. Undefined values may be of any type (other than '``label``'
-or '``void``') and be used anywhere a constant is permitted.
+bit-pattern. Undefined values may be of any type (other than '`label`'
+or '`void`') and be used anywhere a constant is permitted.
-.. note::
-
- A '``poison``' value (described in the next section) should be used instead of
- '``undef``' whenever possible. Poison values are stronger than undef, and
- enable more optimizations. Just the existence of '``undef``' blocks certain
- optimizations (see the examples below).
+```{note}
+A '`poison`' value (described in the next section) should be used instead of
+'`undef`' whenever possible. Poison values are stronger than undef, and
+enable more optimizations. Just the existence of '`undef`' blocks certain
+optimizations (see the examples below).
+```
Undefined values are useful because they indicate to the compiler that
the program is well defined no matter what value is used. This gives the
compiler more freedom to optimize. Here are some examples of
(potentially surprising) transformations that are valid (in pseudo IR):
-.. code-block:: llvm
-
- %A = add %X, undef
- %B = sub %X, undef
- %C = xor %X, undef
- Safe:
- %A = undef
- %B = undef
- %C = undef
+```llvm
+ %A = add %X, undef
+ %B = sub %X, undef
+ %C = xor %X, undef
+Safe:
+ %A = undef
+ %B = undef
+ %C = undef
+```
This is safe because all of the output bits are affected by the undef
bits. Any output bit can have a zero or one depending on the input bits.
-.. code-block:: llvm
-
- %A = or %X, undef
- %B = and %X, undef
- Safe:
- %A = -1
- %B = 0
- Safe:
- %A = %X ;; By choosing undef as 0
- %B = %X ;; By choosing undef as -1
- Unsafe:
- %A = undef
- %B = undef
+```llvm
+ %A = or %X, undef
+ %B = and %X, undef
+Safe:
+ %A = -1
+ %B = 0
+Safe:
+ %A = %X ;; By choosing undef as 0
+ %B = %X ;; By choosing undef as -1
+Unsafe:
+ %A = undef
+ %B = undef
+```
These logical operations have bits that are not always affected by the
-input. For example, if ``%X`` has a zero bit, then the output of the
-'``and``' operation will always be a zero for that bit, no matter what
-the corresponding bit from the '``undef``' is. As such, it is unsafe to
-optimize or assume that the result of the '``and``' is '``undef``'.
-However, it is safe to assume that all bits of the '``undef``' could be
-0, and optimize the '``and``' to 0. Likewise, it is safe to assume that
-all the bits of the '``undef``' operand to the '``or``' could be set,
-allowing the '``or``' to be folded to -1.
-
-.. code-block:: llvm
-
- %A = select undef, %X, %Y
- %B = select undef, 42, %Y
- %C = select %X, %Y, undef
- Safe:
- %A = %X (or %Y)
- %B = 42 (or %Y)
- %C = %Y (if %Y is provably not poison; unsafe otherwise)
- Unsafe:
- %A = undef
- %B = undef
- %C = undef
-
-This set of examples shows that undefined '``select``'
+input. For example, if `%X` has a zero bit, then the output of the
+'`and`' operation will always be a zero for that bit, no matter what
+the corresponding bit from the '`undef`' is. As such, it is unsafe to
+optimize or assume that the result of the '`and`' is '`undef`'.
+However, it is safe to assume that all bits of the '`undef`' could be
+0, and optimize the '`and`' to 0. Likewise, it is safe to assume that
+all the bits of the '`undef`' operand to the '`or`' could be set,
+allowing the '`or`' to be folded to -1.
+
+```llvm
+ %A = select undef, %X, %Y
+ %B = select undef, 42, %Y
+ %C = select %X, %Y, undef
+Safe:
+ %A = %X (or %Y)
+ %B = 42 (or %Y)
+ %C = %Y (if %Y is provably not poison; unsafe otherwise)
+Unsafe:
+ %A = undef
+ %B = undef
+ %C = undef
+```
+
+This set of examples shows that undefined '`select`'
conditions can go *either way*, but they have to come from one
-of the two operands. In the ``%A`` example, if ``%X`` and ``%Y`` were
-both known to have a clear low bit, then ``%A`` would have to have a
-cleared low bit. However, in the ``%C`` example, the optimizer is
-allowed to assume that the '``undef``' operand could be the same as
-``%Y`` if ``%Y`` is provably not '``poison``', allowing the whole '``select``'
-to be eliminated. This is because '``poison``' is stronger than '``undef``'.
-
-.. code-block:: llvm
-
- %A = xor undef, undef
-
- %B = undef
- %C = xor %B, %B
-
- %D = undef
- %E = icmp slt %D, 4
- %F = icmp sge %D, 4
-
- Safe:
- %A = undef
- %B = undef
- %C = undef
- %D = undef
- %E = undef
- %F = undef
-
-This example points out that two '``undef``' operands are not
+of the two operands. In the `%A` example, if `%X` and `%Y` were
+both known to have a clear low bit, then `%A` would have to have a
+cleared low bit. However, in the `%C` example, the optimizer is
+allowed to assume that the '`undef`' operand could be the same as
+`%Y` if `%Y` is provably not '`poison`', allowing the whole '`select`'
+to be eliminated. This is because '`poison`' is stronger than '`undef`'.
+
+```llvm
+ %A = xor undef, undef
+
+ %B = undef
+ %C = xor %B, %B
+
+ %D = undef
+ %E = icmp slt %D, 4
+ %F = icmp sge %D, 4
+
+Safe:
+ %A = undef
+ %B = undef
+ %C = undef
+ %D = undef
+ %E = undef
+ %F = undef
+```
+
+This example points out that two '`undef`' operands are not
necessarily the same. This can be surprising to people (and also matches
-C semantics) where they assume that "``X^X``" is always zero, even if
-``X`` is undefined. This isn't true for a number of reasons, but the
-short answer is that an '``undef``' "variable" can arbitrarily change
+C semantics) where they assume that "`X^X`" is always zero, even if
+`X` is undefined. This isn't true for a number of reasons, but the
+short answer is that an '`undef`' "variable" can arbitrarily change
its value over its "live range". This is true because the variable
doesn't actually *have a live range*. Instead, the value is logically
read from arbitrary registers that happen to be around when needed, so
-the value is not necessarily consistent over time. In fact, ``%A`` and
-``%C`` need to have the same semantics or the core LLVM "replace all
+the value is not necessarily consistent over time. In fact, `%A` and
+`%C` need to have the same semantics or the core LLVM "replace all
uses with" concept would not hold.
To ensure all uses of a given register observe the same value (even if
-'``undef``'), the :ref:`freeze instruction <i_freeze>` can be used.
-
-.. code-block:: llvm
+'`undef`'), the {ref}`freeze instruction <i_freeze>` can be used.
- %A = sdiv undef, %X
- %B = sdiv %X, undef
- Safe:
- %A = 0
- b: unreachable
+```llvm
+ %A = sdiv undef, %X
+ %B = sdiv %X, undef
+Safe:
+ %A = 0
+b: unreachable
+```
These examples show the crucial difference between an *undefined value*
-and *undefined behavior*. An undefined value (like '``undef``') is
-allowed to have an arbitrary bit-pattern. This means that the ``%A``
-operation can be constant folded to '``0``', because the '``undef``'
+and *undefined behavior*. An undefined value (like '`undef`') is
+allowed to have an arbitrary bit-pattern. This means that the `%A`
+operation can be constant folded to '`0`', because the '`undef`'
could be zero, and zero divided by any value is zero.
However, in the second example, we can make a more aggressive
-assumption: because the ``undef`` is allowed to be an arbitrary value,
+assumption: because the `undef` is allowed to be an arbitrary value,
we are allowed to assume that it could be zero. Since a divide by zero
has *undefined behavior*, we are allowed to assume that the operation
does not execute at all. This allows us to delete the divide and all
code after it. Because the undefined operation "can't happen", the
optimizer can assume that it occurs in dead code.
-.. code-block:: text
-
- a: store undef -> %X
- b: store %X -> undef
- Safe:
- a: <deleted> (if the stored value in %X is provably not poison)
- b: unreachable
+```text
+a: store undef -> %X
+b: store %X -> undef
+Safe:
+a: <deleted> (if the stored value in %X is provably not poison)
+b: unreachable
+```
A store *of* an undefined value can be assumed to not have any effect;
we can assume that the value is overwritten with bits that happen to
match what was already there. This argument is only valid if the stored value
-is provably not ``poison``. However, a store *to* an undefined
+is provably not `poison`. However, a store *to* an undefined
location could clobber arbitrary memory, therefore, it has undefined
behavior.
@@ -5293,93 +5379,89 @@ predicates, such as Correlated Value Propagation and Global Value Numbering.
In case of switch instruction, the branch condition should be frozen, otherwise
it is undefined behavior.
-.. code-block:: llvm
-
- Unsafe:
- br undef, BB1, BB2 ; UB
-
- %X = and i32 undef, 255
- switch %X, label %ret [ .. ] ; UB
-
- store undef, ptr %ptr
- %X = load ptr %ptr ; %X is undef
- switch i8 %X, label %ret [ .. ] ; UB
+```llvm
+Unsafe:
+ br undef, BB1, BB2 ; UB
- Safe:
- %X = or i8 undef, 255 ; always 255
- switch i8 %X, label %ret [ .. ] ; Well-defined
+ %X = and i32 undef, 255
+ switch %X, label %ret [ .. ] ; UB
- %X = freeze i1 undef
- br %X, BB1, BB2 ; Well-defined (non-deterministic jump)
+ store undef, ptr %ptr
+ %X = load ptr %ptr ; %X is undef
+ switch i8 %X, label %ret [ .. ] ; UB
+Safe:
+ %X = or i8 undef, 255 ; always 255
+ switch i8 %X, label %ret [ .. ] ; Well-defined
+ %X = freeze i1 undef
+ br %X, BB1, BB2 ; Well-defined (non-deterministic jump)
+```
-.. _poisonvalues:
+(poisonvalues)=
-Poison Values
--------------
+### Poison Values
A poison value is a result of an erroneous operation.
In order to facilitate speculative execution, many instructions do not
invoke immediate undefined behavior when provided with illegal operands,
and return a poison value instead.
-The string '``poison``' can be used anywhere a constant is expected, and
-operations such as :ref:`add <i_add>` with the ``nsw`` flag can produce
+The string '`poison`' can be used anywhere a constant is expected, and
+operations such as {ref}`add <i_add>` with the `nsw` flag can produce
a poison value.
-Most instructions return '``poison``' when one of their arguments is
-'``poison``'. A notable exception is the :ref:`select instruction <i_select>`.
+Most instructions return '`poison`' when one of their arguments is
+'`poison`'. A notable exception is the {ref}`select instruction <i_select>`.
Propagation of poison can be stopped with the
-:ref:`freeze instruction <i_freeze>`.
+{ref}`freeze instruction <i_freeze>`.
It is correct to replace a poison value with an
-:ref:`undef value <undefvalues>` or any value of the type.
+{ref}`undef value <undefvalues>` or any value of the type.
This means that immediate undefined behavior occurs if a poison value is
used as an instruction operand that has any values that trigger undefined
behavior. Notably this includes (but is not limited to):
-- The pointer operand of a :ref:`load <i_load>`, :ref:`store <i_store>` or
+- The pointer operand of a {ref}`load <i_load>`, {ref}`store <i_store>` or
any other pointer dereferencing instruction (independent of address
space).
-- The divisor operand of a ``udiv``, ``sdiv``, ``urem`` or ``srem``
+- The divisor operand of a `udiv`, `sdiv`, `urem` or `srem`
instruction.
-- The condition operand of a :ref:`br <i_br>` instruction.
-- The callee operand of a :ref:`call <i_call>` or :ref:`invoke <i_invoke>`
+- The condition operand of a {ref}`br <i_br>` instruction.
+- The callee operand of a {ref}`call <i_call>` or {ref}`invoke <i_invoke>`
instruction.
-- The parameter operand of a :ref:`call <i_call>` or :ref:`invoke <i_invoke>`
- instruction, when the function or invoking call site has a ``noundef``
+- The parameter operand of a {ref}`call <i_call>` or {ref}`invoke <i_invoke>`
+ instruction, when the function or invoking call site has a `noundef`
attribute in the corresponding position.
-- The operand of a :ref:`ret <i_ret>` instruction if the function or invoking
+- The operand of a {ref}`ret <i_ret>` instruction if the function or invoking
call site has a `noundef` attribute in the return value position.
Here are some examples:
-.. code-block:: llvm
+```llvm
+entry:
+ %poison = sub nuw i32 0, 1 ; Results in a poison value.
+ %poison2 = sub i32 poison, 1 ; Also results in a poison value.
+ %still_poison = and i32 %poison, 0 ; 0, but also poison.
+ %poison_yet_again = getelementptr i32, ptr @h, i32 %still_poison
+ store i32 0, ptr %poison_yet_again ; Undefined behavior due to
+ ; store to poison.
- entry:
- %poison = sub nuw i32 0, 1 ; Results in a poison value.
- %poison2 = sub i32 poison, 1 ; Also results in a poison value.
- %still_poison = and i32 %poison, 0 ; 0, but also poison.
- %poison_yet_again = getelementptr i32, ptr @h, i32 %still_poison
- store i32 0, ptr %poison_yet_again ; Undefined behavior due to
- ; store to poison.
+ store i32 %poison, ptr @g ; Poison value stored to memory.
+ %poison3 = load i32, ptr @g ; Poison value loaded back from memory.
- store i32 %poison, ptr @g ; Poison value stored to memory.
- %poison3 = load i32, ptr @g ; Poison value loaded back from memory.
+ %poison4 = load i16, ptr @g ; Returns a poison value.
+ %poison5 = load i64, ptr @g ; Returns a poison value.
- %poison4 = load i16, ptr @g ; Returns a poison value.
- %poison5 = load i64, ptr @g ; Returns a poison value.
+ %cmp = icmp slt i32 %poison, 0 ; Returns a poison value.
+ br i1 %cmp, label %end, label %end ; undefined behavior
- %cmp = icmp slt i32 %poison, 0 ; Returns a poison value.
- br i1 %cmp, label %end, label %end ; undefined behavior
+end:
+```
- end:
+(welldefinedvalues)=
-.. _welldefinedvalues:
-
-Well-Defined Values
--------------------
+### Well-Defined Values
Given a program execution, a value is *well defined* if the value does not
have an undef bit and is not poison in the execution.
@@ -5387,188 +5469,192 @@ An aggregate value or vector is well defined if its elements are well defined.
The padding of an aggregate isn't considered, since it isn't visible
without storing it into memory and loading it with a different type.
-A constant of a :ref:`single value <t_single_value>`, non-vector type is well
-defined if it is neither '``undef``' constant nor '``poison``' constant.
-The result of :ref:`freeze instruction <i_freeze>` is well defined regardless
+A constant of a {ref}`single value <t_single_value>`, non-vector type is well
+defined if it is neither '`undef`' constant nor '`poison`' constant.
+The result of {ref}`freeze instruction <i_freeze>` is well defined regardless
of its operand.
-.. _blockaddress:
+(blockaddress)=
-Addresses of Basic Blocks
--------------------------
+### Addresses of Basic Blocks
-``blockaddress(@function, %block)``
+`blockaddress(@function, %block)`
-The '``blockaddress``' constant computes the address of the specified
+The '`blockaddress`' constant computes the address of the specified
basic block in the specified function.
-It always has a ``ptr addrspace(P)`` type, where ``P`` is the address space
-of the function containing ``%block`` (usually ``addrspace(0)``).
+It always has a `ptr addrspace(P)` type, where `P` is the address space
+of the function containing `%block` (usually `addrspace(0)`).
Taking the address of the entry block is illegal.
This value only has defined behavior when used as an operand to the
-':ref:`indirectbr <i_indirectbr>`' or for comparisons against null. Pointer
+'{ref}`indirectbr <i_indirectbr>`' or for comparisons against null. Pointer
equality tests between label addresses results in undefined behavior ---
though, again, comparison against null is ok, and no label is equal to the null
pointer. This may be passed around as an opaque pointer sized value as long as
-the bits are not inspected. This allows ``ptrtoint`` and arithmetic to be
+the bits are not inspected. This allows `ptrtoint` and arithmetic to be
performed on these values so long as the original value is reconstituted before
-the ``indirectbr`` instruction.
+the `indirectbr` instruction.
Finally, some targets may provide defined semantics when using the value
as the operand to an inline assembly, but that is target specific.
-.. _dso_local_equivalent:
+(dso_local_equivalent)=
-DSO Local Equivalent
---------------------
+### DSO Local Equivalent
-``dso_local_equivalent @func``
+`dso_local_equivalent @func`
-A '``dso_local_equivalent``' constant represents a function which is
+A '`dso_local_equivalent`' constant represents a function which is
functionally equivalent to a given function, but is always defined in the
current linkage unit. The resulting pointer has the same type as the underlying
function. The resulting pointer is permitted, but not required, to be different
from a pointer to the function, and it may have different values in different
translation units.
-The target function may not have ``extern_weak`` linkage.
+The target function may not have `extern_weak` linkage.
-``dso_local_equivalent`` can be implemented as such:
+`dso_local_equivalent` can be implemented as such:
- If the function has local linkage, hidden visibility, or is
- ``dso_local``, ``dso_local_equivalent`` can be implemented as simply a pointer
+ `dso_local`, `dso_local_equivalent` can be implemented as simply a pointer
to the function.
-- ``dso_local_equivalent`` can be implemented with a stub that tail-calls the
+- `dso_local_equivalent` can be implemented with a stub that tail-calls the
function. Many targets support relocations that resolve at link time to either
a function or a stub for it, depending on whether the function is defined within the
linkage unit; LLVM will use this when available. (This is commonly called a
"PLT stub".) On other targets, the stub may need to be emitted explicitly.
-This can be used wherever a ``dso_local`` instance of a function is needed without
-needing to explicitly make the original function ``dso_local``. An instance where
+This can be used wherever a `dso_local` instance of a function is needed without
+needing to explicitly make the original function `dso_local`. An instance where
this can be used is for static offset calculations between a function and some other
-``dso_local`` symbol. This is especially useful for the Relative VTables C++ ABI,
+`dso_local` symbol. This is especially useful for the Relative VTables C++ ABI,
where dynamic relocations for function pointers in VTables can be replaced with
static relocations for offsets between the VTable and virtual functions which
-may not be ``dso_local``.
+may not be `dso_local`.
This is currently only supported for ELF binary formats.
-.. _no_cfi:
+(no_cfi)=
-No CFI
-------
+### No CFI
-``no_cfi @func``
+`no_cfi @func`
-With `Control-Flow Integrity (CFI)
-<https://clang.llvm.org/docs/ControlFlowIntegrity.html>`_, a '``no_cfi``'
+With [Control-Flow Integrity (CFI)](https://clang.llvm.org/docs/ControlFlowIntegrity.html), a '`no_cfi`'
constant represents a function reference that does not get replaced with a
-reference to the CFI jump table in the ``LowerTypeTests`` pass. These constants
+reference to the CFI jump table in the `LowerTypeTests` pass. These constants
may be useful in low-level programs, such as operating system kernels, which
need to refer to the actual function body.
-.. _ptrauth_constant:
+(ptrauth_constant)=
-Pointer Authentication Constants
---------------------------------
+### Pointer Authentication Constants
-``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?)``
+`ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?)`
-A '``ptrauth``' constant represents a pointer with a cryptographic
+A '`ptrauth`' constant represents a pointer with a cryptographic
authentication signature embedded into some bits, as described in the
-`Pointer Authentication <PointerAuth.html>`__ document.
+{doc}`Pointer Authentication <PointerAuth>` document.
-A '``ptrauth``' constant is simply a constant equivalent to the
-``llvm.ptrauth.sign`` intrinsic, potentially fed by a discriminator
-``llvm.ptrauth.blend`` if needed.
+A '`ptrauth`' constant is simply a constant equivalent to the
+`llvm.ptrauth.sign` intrinsic, potentially fed by a discriminator
+`llvm.ptrauth.blend` if needed.
Its type is the same as the first argument. An integer constant discriminator
and an address discriminator may be optionally specified. Otherwise, they have
-values ``i64 0`` and ``ptr null``.
-
-If the address discriminator is ``null`` then the expression is equivalent to
+values `i64 0` and `ptr null`.
-.. code-block:: llvm
+If the address discriminator is `null` then the expression is equivalent to
- %tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 DISC)
- %val = inttoptr i64 %tmp to ptr
+```llvm
+%tmp = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 DISC)
+%val = inttoptr i64 %tmp to ptr
+```
Otherwise, the expression is equivalent to:
-.. code-block:: llvm
+```llvm
+%tmp1 = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC)
+%tmp2 = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 %tmp1)
+%val = inttoptr i64 %tmp2 to ptr
+```
- %tmp1 = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr ADDRDISC to i64), i64 DISC)
- %tmp2 = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 %tmp1)
- %val = inttoptr i64 %tmp2 to ptr
+If the deactivation symbol operand `DS` has a non-null value,
+the semantics are as if a {ref}`deactivation-symbol operand bundle
+<deactivationsymbol>` were added to the `llvm.ptrauth.sign` intrinsic
+calls above, with `DS` as the only operand.
-If the deactivation symbol operand ``DS`` has a non-null value,
-the semantics are as if a :ref:`deactivation-symbol operand bundle
-<deactivationsymbol>` were added to the ``llvm.ptrauth.sign`` intrinsic
-calls above, with ``DS`` as the only operand.
+(constantexprs)=
-.. _constantexprs:
-
-Constant Expressions
---------------------
+### Constant Expressions
Constant expressions are used to allow expressions involving other
constants to be used as constants. Constant expressions may be of any
-:ref:`first class <t_firstclass>` type and may involve any LLVM operation
+{ref}`first class <t_firstclass>` type and may involve any LLVM operation
that does not have side effects (e.g., load and call are not supported).
The following is the syntax for constant expressions:
-``trunc (CST to TYPE)``
- Perform the :ref:`trunc operation <i_trunc>` on constants.
-``ptrtoint (CST to TYPE)``
- Perform the :ref:`ptrtoint operation <i_ptrtoint>` on constants.
-``ptrtoaddr (CST to TYPE)``
- Perform the :ref:`ptrtoaddr operation <i_ptrtoaddr>` on constants.
-``inttoptr (CST to TYPE)``
- Perform the :ref:`inttoptr operation <i_inttoptr>` on constants.
+`trunc (CST to TYPE)`
+: Perform the {ref}`trunc operation <i_trunc>` on constants.
+
+`ptrtoint (CST to TYPE)`
+: Perform the {ref}`ptrtoint operation <i_ptrtoint>` on constants.
+
+`ptrtoaddr (CST to TYPE)`
+: Perform the {ref}`ptrtoaddr operation <i_ptrtoaddr>` on constants.
+
+`inttoptr (CST to TYPE)`
+: Perform the {ref}`inttoptr operation <i_inttoptr>` on constants.
This one is *really* dangerous!
-``bitcast (CST to TYPE)``
- Convert a constant, CST, to another TYPE.
+
+`bitcast (CST to TYPE)`
+: Convert a constant, CST, to another TYPE.
The constraints of the operands are the same as those for the
- :ref:`bitcast instruction <i_bitcast>`.
-``addrspacecast (CST to TYPE)``
- Convert a constant pointer or constant vector of pointer, CST, to another
+ {ref}`bitcast instruction <i_bitcast>`.
+
+`addrspacecast (CST to TYPE)`
+: Convert a constant pointer or constant vector of pointer, CST, to another
TYPE in a different address space. The constraints of the operands are the
- same as those for the :ref:`addrspacecast instruction <i_addrspacecast>`.
-``getelementptr (TY, CSTPTR, IDX0, IDX1, ...)``, ``getelementptr inbounds (TY, CSTPTR, IDX0, IDX1, ...)``
- Perform the :ref:`getelementptr operation <i_getelementptr>` on
- constants. As with the :ref:`getelementptr <i_getelementptr>`
+ same as those for the {ref}`addrspacecast instruction <i_addrspacecast>`.
+
+`getelementptr (TY, CSTPTR, IDX0, IDX1, ...)`, `getelementptr inbounds (TY, CSTPTR, IDX0, IDX1, ...)`
+: Perform the {ref}`getelementptr operation <i_getelementptr>` on
+ constants. As with the {ref}`getelementptr <i_getelementptr>`
instruction, the index list may have one or more indexes, which are
required to make sense for the type of "pointer to TY". These indexes
may be implicitly sign-extended or truncated to match the index size
of CSTPTR's address space.
-``extractelement (VAL, IDX)``
- Perform the :ref:`extractelement operation <i_extractelement>` on
+
+`extractelement (VAL, IDX)`
+: Perform the {ref}`extractelement operation <i_extractelement>` on
constants.
-``insertelement (VAL, ELT, IDX)``
- Perform the :ref:`insertelement operation <i_insertelement>` on
+
+`insertelement (VAL, ELT, IDX)`
+: Perform the {ref}`insertelement operation <i_insertelement>` on
constants.
-``shufflevector (VEC1, VEC2, IDXMASK)``
- Perform the :ref:`shufflevector operation <i_shufflevector>` on
+
+`shufflevector (VEC1, VEC2, IDXMASK)`
+: Perform the {ref}`shufflevector operation <i_shufflevector>` on
constants.
-``add (LHS, RHS)``
- Perform an addition on constants.
-``sub (LHS, RHS)``
- Perform a subtraction on constants.
-``xor (LHS, RHS)``
- Perform a bitwise xor on constants.
-Other Values
-============
+`add (LHS, RHS)`
+: Perform an addition on constants.
-.. _inlineasmexprs:
+`sub (LHS, RHS)`
+: Perform a subtraction on constants.
-Inline Assembler Expressions
-----------------------------
+`xor (LHS, RHS)`
+: Perform a bitwise xor on constants.
-LLVM supports inline assembler expressions (as opposed to :ref:`Module-Level
+## Other Values
+
+(inlineasmexprs)=
+
+### Inline Assembler Expressions
+
+LLVM supports inline assembler expressions (as opposed to {ref}`Module-Level
Inline Assembly <moduleasm>`) through the use of a special value. This value
represents the inline assembler as a template string (containing the
instructions to emit), a list of operand constraints (stored as a string), a
@@ -5584,33 +5670,33 @@ code emitted by this expression is altered later, e.g. via self-modifying code,
as long as the code keeps upholding the requirements of the operand constraints
and the flags.
-The template string supports argument substitution of the operands using "``$``"
+The template string supports argument substitution of the operands using "`$`"
followed by a number, to indicate substitution of the given register/memory
-location, as specified by the constraint string. "``${NUM:MODIFIER}``" may also
-be used, where ``MODIFIER`` is a target-specific annotation for how to print the
-operand (See :ref:`inline-asm-modifiers`).
+location, as specified by the constraint string. "`${NUM:MODIFIER}`" may also
+be used, where `MODIFIER` is a target-specific annotation for how to print the
+operand (See {ref}`inline-asm-modifiers`).
-A literal "``$``" may be included by using "``$$``" in the template. To include
-other special characters into the output, the usual "``\XX``" escapes may be
+A literal "`$`" may be included by using "`$$`" in the template. To include
+other special characters into the output, the usual "`\XX`" escapes may be
used, just as in other strings. Note that after template substitution, the
resulting assembly string is parsed by LLVM's integrated assembler unless it is
-disabled -- even when emitting a ``.s`` file -- and thus must contain assembly
+disabled -- even when emitting a `.s` file -- and thus must contain assembly
syntax known to LLVM.
LLVM also supports a few more substitutions useful for writing inline assembly:
-- ``${:uid}``: Expands to a decimal integer unique to this inline assembly blob.
+- `${:uid}`: Expands to a decimal integer unique to this inline assembly blob.
This substitution is useful when declaring a local label. Many standard
compiler optimizations, such as inlining, may duplicate an inline asm blob.
Adding a blob-unique identifier ensures that the two labels will not conflict
- during assembly. This is used to implement `GCC's %= special format
- string <https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_.
-- ``${:comment}``: Expands to the comment character of the current target's
- assembly dialect. This is usually ``#``, but many targets use other strings,
- such as ``;``, ``//``, or ``!``.
-- ``${:private}``: Expands to the assembler private label prefix. Labels with
+ during assembly. This is used to implement [GCC's %= special format
+ string](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html).
+- `${:comment}`: Expands to the comment character of the current target's
+ assembly dialect. This is usually `#`, but many targets use other strings,
+ such as `;`, `//`, or `!`.
+- `${:private}`: Expands to the assembler private label prefix. Labels with
this prefix will not appear in the symbol table of the assembled object.
- Typically the prefix is ``L``, but targets may use other strings. ``.L`` is
+ Typically the prefix is `L`, but targets may use other strings. `.L` is
relatively popular.
LLVM's support for inline asm is modeled closely on the requirements of Clang's
@@ -5624,70 +5710,69 @@ assembly.
An example inline assembler expression is:
-.. code-block:: llvm
-
- i32 (i32) asm "bswap $0", "=r,r"
+```llvm
+i32 (i32) asm "bswap $0", "=r,r"
+```
Inline assembler expressions may **only** be used as the callee operand
-of a :ref:`call <i_call>` or an :ref:`invoke <i_invoke>` instruction.
+of a {ref}`call <i_call>` or an {ref}`invoke <i_invoke>` instruction.
Thus, typically we have:
-.. code-block:: llvm
-
- %X = call i32 asm "bswap $0", "=r,r"(i32 %Y)
+```llvm
+%X = call i32 asm "bswap $0", "=r,r"(i32 %Y)
+```
Inline asms with side effects not visible in the constraint list must be
marked as having side effects. This is done through the use of the
-'``sideeffect``' keyword, like so:
-
-.. code-block:: llvm
+'`sideeffect`' keyword, like so:
- call void asm sideeffect "eieio", ""()
+```llvm
+call void asm sideeffect "eieio", ""()
+```
In some cases inline asms will contain code that will not work unless
the stack is aligned in some way, such as calls or SSE instructions on
x86, yet will not contain code that does that alignment within the asm.
The compiler should make conservative assumptions about what the asm
might contain and should generate its usual stack alignment code in the
-prologue if the '``alignstack``' keyword is present:
+prologue if the '`alignstack`' keyword is present:
-.. code-block:: llvm
-
- call void asm alignstack "eieio", ""()
+```llvm
+call void asm alignstack "eieio", ""()
+```
Inline asms also support using non-standard assembly dialects. The
-assumed dialect is ATT. When the '``inteldialect``' keyword is present,
+assumed dialect is ATT. When the '`inteldialect`' keyword is present,
the inline asm is using the Intel dialect. Currently, ATT and Intel are
the only supported dialects. An example is:
-.. code-block:: llvm
-
- call void asm inteldialect "eieio", ""()
+```llvm
+call void asm inteldialect "eieio", ""()
+```
In the case that the inline asm might unwind the stack,
-the '``unwind``' keyword must be used, so that the compiler emits
+the '`unwind`' keyword must be used, so that the compiler emits
unwinding information:
-.. code-block:: llvm
-
- call void asm unwind "call func", ""()
+```llvm
+call void asm unwind "call func", ""()
+```
If the inline asm unwinds the stack and isn't marked with
-the '``unwind``' keyword, the behavior is undefined.
+the '`unwind`' keyword, the behavior is undefined.
-If multiple keywords appear, the '``sideeffect``' keyword must come
-first, the '``alignstack``' keyword second, the '``inteldialect``' keyword
-third, and the '``unwind``' keyword last.
+If multiple keywords appear, the '`sideeffect`' keyword must come
+first, the '`alignstack`' keyword second, the '`inteldialect`' keyword
+third, and the '`unwind`' keyword last.
-Inline Asm Constraint String
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Inline Asm Constraint String
The constraint list is a comma-separated string, each element containing one or
more constraint codes.
For each element in the constraint list an appropriate register or memory
operand will be chosen, and it will be made available to assembly template
-string expansion as ``$0`` for the first constraint in the list, ``$1`` for the
+string expansion as `$0` for the first constraint in the list, `$1` for the
second, etc.
There are three different types of constraints, which are distinguished by a
@@ -5708,12 +5793,11 @@ There are also three different categories of constraint codes:
various target-specific constraints allow the selection of a value in the
proper range for the instruction you wish to use it with.
-Output constraints
-""""""""""""""""""
+##### Output constraints
-Output constraints are specified by an "``=``" prefix (e.g., "``=r``"). This
+Output constraints are specified by an "`=`" prefix (e.g., "`=r`"). This
indicates that the assembly will write to this operand, and the operand will
-then be made available as a return value of the ``asm`` expression. Output
+then be made available as a return value of the `asm` expression. Output
constraints do not consume an argument from the call instruction. (Except, see
below about indirect outputs).
@@ -5721,14 +5805,13 @@ Normally, it is expected that no output locations are written to by the assembly
expression until *all* of the inputs have been read. As such, LLVM may assign
the same register to an output and an input. If this is not safe (e.g., if the
assembly contains two instructions, where the first writes to one output, and
-the second reads an input and writes to a second output), then the "``&``"
-modifier must be used (e.g., "``=&r``") to specify that the output is an
+the second reads an input and writes to a second output), then the "`&`"
+modifier must be used (e.g., "`=&r`") to specify that the output is an
"early-clobber" output. Marking an output as "early-clobber" ensures that LLVM
will not use the same register for any inputs (other than an input tied to this
output).
-Input constraints
-"""""""""""""""""
+##### Input constraints
Input constraints do not have a prefix -- just the constraint codes. Each input
constraint will consume one argument from the call instruction. It is not
@@ -5742,7 +5825,7 @@ themselves to an output constraint, by providing an integer as the constraint
string. Tied inputs still consume an argument from the call instruction, and
take up a position in the asm template numbering as is usual -- they will simply
be constrained to always use the same register as the output they've been tied
-to. For example, a constraint string of "``=r,0``" says to assign a register for
+to. For example, a constraint string of "`=r,0`" says to assign a register for
output, and use that register as an input as well (it being the 0'th
constraint).
@@ -5768,19 +5851,18 @@ hardware then loads into both the named register, and the next register. This
feature of inline asm would not be useful to support that.)
A few of the targets provide a template string modifier allowing explicit access
-to the second register of a two-register operand (e.g., MIPS ``L``, ``M``, and
-``D``). On such an architecture, you can actually access the second allocated
+to the second register of a two-register operand (e.g., MIPS `L`, `M`, and
+`D`). On such an architecture, you can actually access the second allocated
register (yet, still, not any subsequent ones). But, in that case, you're still
probably better off simply splitting the value into two separate operands, for
-clarity. (e.g., see the description of the ``A`` constraint on X86, which,
+clarity. (e.g., see the description of the `A` constraint on X86, which,
despite existing only for use with this feature, is not really a good idea to
use)
-Indirect inputs and outputs
-"""""""""""""""""""""""""""
+##### Indirect inputs and outputs
-Indirect output or input constraints can be specified by the "``*``" modifier
-(which goes after the "``=``" in case of an output). This indicates that the asm
+Indirect output or input constraints can be specified by the "`*`" modifier
+(which goes after the "`=`" in case of an output). This indicates that the asm
will write to or read from the contents of an *address* provided as an input
argument. (Note that in this way, indirect outputs act more like an *input* than
an output: just like an input, they consume an argument of the call expression,
@@ -5788,11 +5870,11 @@ rather than producing a return value. An indirect output constraint is an
"output" only in that the asm is expected to write to the contents of the input
memory location, instead of just read from it).
-This is most typically used for memory constraint, e.g., "``=*m``", to pass the
+This is most typically used for memory constraint, e.g., "`=*m`", to pass the
address of a variable as a value.
It is also possible to use an indirect *register* constraint, but only on output
-(e.g., "``=*r``"). This will cause LLVM to allocate a register for an output
+(e.g., "`=*r`"). This will cause LLVM to allocate a register for an output
value normally, and then, separately emit a store to the address provided as
input, after the provided inline asm. (It's not clear what value this
functionality provides, compared to writing the store explicitly after the asm
@@ -5800,18 +5882,17 @@ statement, and it can only produce worse code, since it bypasses many
optimization passes. I would recommend not using it.)
Call arguments for indirect constraints must have pointer type and must specify
-the :ref:`elementtype <attr_elementtype>` attribute to indicate the pointer
+the {ref}`elementtype <attr_elementtype>` attribute to indicate the pointer
element type.
-Clobber constraints
-"""""""""""""""""""
+##### Clobber constraints
-A clobber constraint is indicated by a "``~``" prefix. A clobber does not
+A clobber constraint is indicated by a "`~`" prefix. A clobber does not
consume an input operand, nor generate an output. Clobbers cannot use any of the
general constraint code letters -- they may use only explicit register
-constraints, e.g., "``~{eax}``".
+constraints, e.g., "`~{eax}`".
-The one exception is that a clobber string of "``~{memory}``" indicates that the
+The one exception is that a clobber string of "`~{memory}`" indicates that the
assembly reads and writes to arbitrary undeclared memory locations -- not only
the memory pointed to by a declared indirect output. Furthermore, the assembly
may also cause synchronization with other threads, such as via release/acquire
@@ -5820,25 +5901,23 @@ fences and atomic memory accesses.
Note that clobbering named registers that are also present in output
constraints is not legal.
-Label constraints
-"""""""""""""""""
+##### Label constraints
-A label constraint is indicated by a "``!``" prefix and typically used in the
-form ``"!i"``. Instead of consuming call arguments, label constraints consume
-indirect destination labels of ``callbr`` instructions.
+A label constraint is indicated by a "`!`" prefix and typically used in the
+form `"!i"`. Instead of consuming call arguments, label constraints consume
+indirect destination labels of `callbr` instructions.
-Label constraints can only be used in conjunction with ``callbr`` and the
+Label constraints can only be used in conjunction with `callbr` and the
number of label constraints must match the number of indirect destination
-labels in the ``callbr`` instruction.
+labels in the `callbr` instruction.
-Constraint Codes
-""""""""""""""""
+##### Constraint Codes
After a potential prefix comes constraint code, or codes.
-A Constraint Code is either a single letter (e.g., "``r``"), a "``^``" character
-followed by two letters (e.g., "``^wc``"), or "``{``" register-name "``}``"
-(e.g., "``{eax}``").
+A Constraint Code is either a single letter (e.g., "`r`"), a "`^`" character
+followed by two letters (e.g., "`^wc`"), or "`{`" register-name "`}`"
+(e.g., "`{eax}`").
The one and two letter constraint codes are typically chosen to be the same as
GCC's constraint codes.
@@ -5850,35 +5929,34 @@ compatibility with the translation of GCC inline asm coming from clang.
There are two ways to specify alternatives, and either or both may be used in an
inline asm constraint list:
-1) Append the codes to each other, making a constraint code set. E.g. "``im``"
- or "``{eax}m``". This means "choose any of the options in the set". The
+1) Append the codes to each other, making a constraint code set. E.g. "`im`"
+ or "`{eax}m`". This means "choose any of the options in the set". The
choice of constraint is made independently for each constraint in the
constraint list.
-2) Use "``|``" between constraint code sets, creating alternatives. Every
+2) Use "`|`" between constraint code sets, creating alternatives. Every
constraint in the constraint list must have the same number of alternative
sets. With this syntax, the same alternative in *all* of the items in the
constraint list will be chosen together.
Putting those together, you might have a two operand constraint string like
-``"rm|r,ri|rm"``. This indicates that if operand 0 is ``r`` or ``m``, then
-operand 1 may be one of ``r`` or ``i``. If operand 0 is ``r``, then operand 1
-may be one of ``r`` or ``m``. But, operand 0 and 1 cannot both be of type m.
+`"rm|r,ri|rm"`. This indicates that if operand 0 is `r` or `m`, then
+operand 1 may be one of `r` or `i`. If operand 0 is `r`, then operand 1
+may be one of `r` or `m`. But, operand 0 and 1 cannot both be of type m.
However, the use of either of the alternatives features is *NOT* recommended, as
LLVM is not able to make an intelligent choice about which one to use. (At the
point it currently needs to choose, not enough information is available to do so
in a smart way.) Thus, it simply tries to make a choice that's most likely to
-compile, not one that will be optimal performance. (e.g., given "``rm``", it'll
+compile, not one that will be optimal performance. (e.g., given "`rm`", it'll
always choose to use memory, not registers). And, if given multiple registers,
or multiple register classes, it will simply choose the first one. (In fact, it
doesn't currently even ensure explicitly specified physical registers are
unique, so specifying multiple physical registers as alternatives, like
-``{r11}{r12},{r11}{r12}``, will assign r11 to both operands, not at all what was
+`{r11}{r12},{r11}{r12}`, will assign r11 to both operands, not at all what was
intended.)
-Supported Constraint Code List
-""""""""""""""""""""""""""""""
+##### Supported Constraint Code List
The constraint codes are, in general, expected to behave the same way they do in
GCC. LLVM's support is often implemented on an 'as-needed' basis, to support C
@@ -5887,324 +5965,320 @@ and GCC likely indicates a bug in LLVM.
Some constraint codes are typically supported by all targets:
-- ``r``: A register in the target's general purpose register class.
-- ``m``: A memory address operand. It is target-specific what addressing modes
+- `r`: A register in the target's general purpose register class.
+- `m`: A memory address operand. It is target-specific what addressing modes
are supported, typical examples are register, or register + register offset,
or register + immediate offset (of some target-specific size).
-- ``p``: An address operand. Similar to ``m``, but used by "load address"
+- `p`: An address operand. Similar to `m`, but used by "load address"
type instructions without touching memory.
-- ``i``: An integer constant (of target-specific width). Allows either a simple
+- `i`: An integer constant (of target-specific width). Allows either a simple
immediate, or a relocatable value.
-- ``n``: An integer constant -- *not* including relocatable values.
-- ``s``: A symbol or label reference with a constant offset.
-- ``X``: Allows an operand of any kind, no constraint whatsoever. Typically
+- `n`: An integer constant -- *not* including relocatable values.
+- `s`: A symbol or label reference with a constant offset.
+- `X`: Allows an operand of any kind, no constraint whatsoever. Typically
useful to pass a label for an asm branch or call.
-
- .. FIXME: but that surely isn't actually okay to jump out of an asm
- block without telling llvm about the control transfer???)
-
-- ``{register-name}``: Requires exactly the named physical register.
+ % FIXME: but that surely isn't actually okay to jump out of an asm block without telling llvm about the control transfer???)
+- `{register-name}`: Requires exactly the named physical register.
Other constraints are target-specific:
AArch64:
-- ``z``: An immediate integer 0. Outputs ``WZR`` or ``XZR``, as appropriate.
-- ``I``: An immediate integer valid for an ``ADD`` or ``SUB`` instruction,
+- `z`: An immediate integer 0. Outputs `WZR` or `XZR`, as appropriate.
+- `I`: An immediate integer valid for an `ADD` or `SUB` instruction,
i.e., 0 to 4095 with optional shift by 12.
-- ``J``: An immediate integer that, when negated, is valid for an ``ADD`` or
- ``SUB`` instruction, i.e., -1 to -4095 with optional left shift by 12.
-- ``K``: An immediate integer that is valid for the 'bitmask immediate 32' of a
- logical instruction like ``AND``, ``EOR``, or ``ORR`` with a 32-bit register.
-- ``L``: An immediate integer that is valid for the 'bitmask immediate 64' of a
- logical instruction like ``AND``, ``EOR``, or ``ORR`` with a 64-bit register.
-- ``M``: An immediate integer for use with the ``MOV`` assembly alias on a
- 32-bit register. This is a superset of ``K``: in addition to the bitmask
+- `J`: An immediate integer that, when negated, is valid for an `ADD` or
+ `SUB` instruction, i.e., -1 to -4095 with optional left shift by 12.
+- `K`: An immediate integer that is valid for the 'bitmask immediate 32' of a
+ logical instruction like `AND`, `EOR`, or `ORR` with a 32-bit register.
+- `L`: An immediate integer that is valid for the 'bitmask immediate 64' of a
+ logical instruction like `AND`, `EOR`, or `ORR` with a 64-bit register.
+- `M`: An immediate integer for use with the `MOV` assembly alias on a
+ 32-bit register. This is a superset of `K`: in addition to the bitmask
immediate, also allows immediate integers which can be loaded with a single
- ``MOVZ`` or ``MOVL`` instruction.
-- ``N``: An immediate integer for use with the ``MOV`` assembly alias on a
- 64-bit register. This is a superset of ``L``.
-- ``Q``: Memory address operand must be in a single register (no
- offsets). (However, LLVM currently does this for the ``m`` constraint as
+ `MOVZ` or `MOVL` instruction.
+- `N`: An immediate integer for use with the `MOV` assembly alias on a
+ 64-bit register. This is a superset of `L`.
+- `Q`: Memory address operand must be in a single register (no
+ offsets). (However, LLVM currently does this for the `m` constraint as
well.)
-- ``r``: A 32 or 64-bit integer register (W* or X*).
-- ``S``: A symbol or label reference with a constant offset. The generic ``s``
+- `r`: A 32 or 64-bit integer register (W* or X*).
+- `S`: A symbol or label reference with a constant offset. The generic `s`
is not supported.
-- ``Uci``: Like r, but restricted to registers 8 to 11 inclusive.
-- ``Ucj``: Like r, but restricted to registers 12 to 15 inclusive.
-- ``w``: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
-- ``x``: Like w, but restricted to registers 0 to 15 inclusive.
-- ``y``: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.
-- ``Uph``: One of the upper eight SVE predicate registers (P8 to P15)
-- ``Upl``: One of the lower eight SVE predicate registers (P0 to P7)
-- ``Upa``: Any of the SVE predicate registers (P0 to P15)
+- `Uci`: Like r, but restricted to registers 8 to 11 inclusive.
+- `Ucj`: Like r, but restricted to registers 12 to 15 inclusive.
+- `w`: A 32, 64, or 128-bit floating-point, SIMD or SVE vector register.
+- `x`: Like w, but restricted to registers 0 to 15 inclusive.
+- `y`: Like w, but restricted to SVE vector registers Z0 to Z7 inclusive.
+- `Uph`: One of the upper eight SVE predicate registers (P8 to P15)
+- `Upl`: One of the lower eight SVE predicate registers (P0 to P7)
+- `Upa`: Any of the SVE predicate registers (P0 to P15)
AMDGPU:
-- ``r``: A 32 or 64-bit integer register.
-- ``s``: SGPR register or tuple
-- ``v``: VGPR register or tuple
-- ``a``: AGPR register or tuple. Only valid on gfx908+.
-- ``VA``: VGPR or AGPR register or tuple. Only valid on gfx90a+.
-- ``v[0-9]``: The 32-bit VGPR register, number 0-9.
-- ``s[0-9]``: The 32-bit SGPR register, number 0-9.
-- ``a[0-9]``: The 32-bit AGPR register, number 0-9.
-- ``I``: An integer inline constant in the range from -16 to 64.
-- ``J``: A 16-bit signed integer constant.
-- ``A``: An integer or a floating-point inline constant.
-- ``B``: A 32-bit signed integer constant.
-- ``C``: A 32-bit unsigned integer constant or an integer inline constant in the range from -16 to 64.
-- ``DA``: A 64-bit constant that can be split into two "A" constants.
-- ``DB``: A 64-bit constant that can be split into two "B" constants.
+- `r`: A 32 or 64-bit integer register.
+- `s`: SGPR register or tuple
+- `v`: VGPR register or tuple
+- `a`: AGPR register or tuple. Only valid on gfx908+.
+- `VA`: VGPR or AGPR register or tuple. Only valid on gfx90a+.
+- `v[0-9]`: The 32-bit VGPR register, number 0-9.
+- `s[0-9]`: The 32-bit SGPR register, number 0-9.
+- `a[0-9]`: The 32-bit AGPR register, number 0-9.
+- `I`: An integer inline constant in the range from -16 to 64.
+- `J`: A 16-bit signed integer constant.
+- `A`: An integer or a floating-point inline constant.
+- `B`: A 32-bit signed integer constant.
+- `C`: A 32-bit unsigned integer constant or an integer inline constant in the range from -16 to 64.
+- `DA`: A 64-bit constant that can be split into two "A" constants.
+- `DB`: A 64-bit constant that can be split into two "B" constants.
All ARM modes:
-- ``Q``, ``Um``, ``Un``, ``Uq``, ``Us``, ``Ut``, ``Uv``, ``Uy``: Memory address
- operand. Treated the same as operand ``m``, at the moment.
-- ``Te``: An even general-purpose 32-bit integer register: ``r0,r2,...,r12,r14``
-- ``To``: An odd general-purpose 32-bit integer register: ``r1,r3,...,r11``
+- `Q`, `Um`, `Un`, `Uq`, `Us`, `Ut`, `Uv`, `Uy`: Memory address
+ operand. Treated the same as operand `m`, at the moment.
+- `Te`: An even general-purpose 32-bit integer register: `r0,r2,...,r12,r14`
+- `To`: An odd general-purpose 32-bit integer register: `r1,r3,...,r11`
ARM and ARM's Thumb2 mode:
-- ``j``: An immediate integer between 0 and 65535 (valid for ``MOVW``)
-- ``I``: An immediate integer valid for a data-processing instruction.
-- ``J``: An immediate integer between -4095 and 4095.
-- ``K``: An immediate integer whose bitwise inverse is valid for a
- data-processing instruction. (Can be used with template modifier "``B``" to
+- `j`: An immediate integer between 0 and 65535 (valid for `MOVW`)
+- `I`: An immediate integer valid for a data-processing instruction.
+- `J`: An immediate integer between -4095 and 4095.
+- `K`: An immediate integer whose bitwise inverse is valid for a
+ data-processing instruction. (Can be used with template modifier "`B`" to
print the inverted value).
-- ``L``: An immediate integer whose negation is valid for a data-processing
- instruction. (Can be used with template modifier "``n``" to print the negated
+- `L`: An immediate integer whose negation is valid for a data-processing
+ instruction. (Can be used with template modifier "`n`" to print the negated
value).
-- ``M``: A power of two or an integer between 0 and 32.
-- ``N``: Invalid immediate constraint.
-- ``O``: Invalid immediate constraint.
-- ``r``: A general-purpose 32-bit integer register (``r0-r15``).
-- ``l``: In Thumb2 mode, low 32-bit GPR registers (``r0-r7``). In ARM mode, same
- as ``r``.
-- ``h``: In Thumb2 mode, a high 32-bit GPR register (``r8-r15``). In ARM mode,
+- `M`: A power of two or an integer between 0 and 32.
+- `N`: Invalid immediate constraint.
+- `O`: Invalid immediate constraint.
+- `r`: A general-purpose 32-bit integer register (`r0-r15`).
+- `l`: In Thumb2 mode, low 32-bit GPR registers (`r0-r7`). In ARM mode, same
+ as `r`.
+- `h`: In Thumb2 mode, a high 32-bit GPR register (`r8-r15`). In ARM mode,
invalid.
-- ``w``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s31``, ``d0-d31``, or ``q0-q15``, respectively.
-- ``t``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s31``, ``d0-d15``, or ``q0-q7``, respectively.
-- ``x``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s15``, ``d0-d7``, or ``q0-q3``, respectively.
+- `w`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s31`, `d0-d31`, or `q0-q15`, respectively.
+- `t`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s31`, `d0-d15`, or `q0-q7`, respectively.
+- `x`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s15`, `d0-d7`, or `q0-q3`, respectively.
ARM's Thumb1 mode:
-- ``I``: An immediate integer between 0 and 255.
-- ``J``: An immediate integer between -255 and -1.
-- ``K``: An immediate integer between 0 and 255, with optional left-shift by
+- `I`: An immediate integer between 0 and 255.
+- `J`: An immediate integer between -255 and -1.
+- `K`: An immediate integer between 0 and 255, with optional left-shift by
some amount.
-- ``L``: An immediate integer between -7 and 7.
-- ``M``: An immediate integer which is a multiple of 4 between 0 and 1020.
-- ``N``: An immediate integer between 0 and 31.
-- ``O``: An immediate integer which is a multiple of 4 between -508 and 508.
-- ``r``: A low 32-bit GPR register (``r0-r7``).
-- ``l``: A low 32-bit GPR register (``r0-r7``).
-- ``h``: A high GPR register (``r0-r7``).
-- ``w``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s31``, ``d0-d31``, or ``q0-q15``, respectively.
-- ``t``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s31``, ``d0-d15``, or ``q0-q7``, respectively.
-- ``x``: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
- ``s0-s15``, ``d0-d7``, or ``q0-q3``, respectively.
+- `L`: An immediate integer between -7 and 7.
+- `M`: An immediate integer which is a multiple of 4 between 0 and 1020.
+- `N`: An immediate integer between 0 and 31.
+- `O`: An immediate integer which is a multiple of 4 between -508 and 508.
+- `r`: A low 32-bit GPR register (`r0-r7`).
+- `l`: A low 32-bit GPR register (`r0-r7`).
+- `h`: A high GPR register (`r0-r7`).
+- `w`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s31`, `d0-d31`, or `q0-q15`, respectively.
+- `t`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s31`, `d0-d15`, or `q0-q7`, respectively.
+- `x`: A 32, 64, or 128-bit floating-point/SIMD register in the ranges
+ `s0-s15`, `d0-d7`, or `q0-q3`, respectively.
Hexagon:
-- ``o``, ``v``: A memory address operand, treated the same as constraint ``m``,
+- `o`, `v`: A memory address operand, treated the same as constraint `m`,
at the moment.
-- ``r``: A 32 or 64-bit register.
+- `r`: A 32 or 64-bit register.
LoongArch:
-- ``f``: A floating-point register (if available).
-- ``k``: A memory operand whose address is formed by a base register and
+- `f`: A floating-point register (if available).
+- `k`: A memory operand whose address is formed by a base register and
(optionally scaled) index register.
-- ``l``: A signed 16-bit constant.
-- ``m``: A memory operand whose address is formed by a base register and
+- `l`: A signed 16-bit constant.
+- `m`: A memory operand whose address is formed by a base register and
offset that is suitable for use in instructions with the same addressing
mode as st.w and ld.w.
-- ``q``: A general-purpose register except for $r0 and $r1 (for the csrxchg
+- `q`: A general-purpose register except for $r0 and $r1 (for the csrxchg
instruction).
-- ``I``: A signed 12-bit constant (for arithmetic instructions).
-- ``J``: An immediate integer zero.
-- ``K``: An unsigned 12-bit constant (for logic instructions).
-- ``ZB``: An address that is held in a general-purpose register. The offset
+- `I`: A signed 12-bit constant (for arithmetic instructions).
+- `J`: An immediate integer zero.
+- `K`: An unsigned 12-bit constant (for logic instructions).
+- `ZB`: An address that is held in a general-purpose register. The offset
is zero.
-- ``ZC``: A memory operand whose address is formed by a base register and
+- `ZC`: A memory operand whose address is formed by a base register and
offset that is suitable for use in instructions with the same addressing
mode as ll.w and sc.w.
MSP430:
-- ``r``: An 8 or 16-bit register.
+- `r`: An 8 or 16-bit register.
MIPS:
-- ``I``: An immediate signed 16-bit integer.
-- ``J``: An immediate integer zero.
-- ``K``: An immediate unsigned 16-bit integer.
-- ``L``: An immediate 32-bit integer, where the lower 16 bits are 0.
-- ``N``: An immediate integer between -65535 and -1.
-- ``O``: An immediate signed 15-bit integer.
-- ``P``: An immediate integer between 1 and 65535.
-- ``m``: A memory address operand. In MIPS-SE mode, allows a base address
+- `I`: An immediate signed 16-bit integer.
+- `J`: An immediate integer zero.
+- `K`: An immediate unsigned 16-bit integer.
+- `L`: An immediate 32-bit integer, where the lower 16 bits are 0.
+- `N`: An immediate integer between -65535 and -1.
+- `O`: An immediate signed 15-bit integer.
+- `P`: An immediate integer between 1 and 65535.
+- `m`: A memory address operand. In MIPS-SE mode, allows a base address
register plus 16-bit immediate offset. In MIPS mode, just a base register.
-- ``R``: A memory address operand. In MIPS-SE mode, allows a base address
+- `R`: A memory address operand. In MIPS-SE mode, allows a base address
register plus a 9-bit signed offset. In MIPS mode, the same as constraint
- ``m``.
-- ``ZC``: A memory address operand, suitable for use in a ``pref``, ``ll``, or
- ``sc`` instruction on the given subtarget (details vary).
-- ``r``, ``d``, ``y``: A 32 or 64-bit GPR register.
-- ``f``: A 32 or 64-bit FPU register (``F0-F31``), or a 128-bit MSA register
- (``W0-W31``). In the case of MSA registers, it is recommended to use the ``w``
+ `m`.
+- `ZC`: A memory address operand, suitable for use in a `pref`, `ll`, or
+ `sc` instruction on the given subtarget (details vary).
+- `r`, `d`, `y`: A 32 or 64-bit GPR register.
+- `f`: A 32 or 64-bit FPU register (`F0-F31`), or a 128-bit MSA register
+ (`W0-W31`). In the case of MSA registers, it is recommended to use the `w`
argument modifier for compatibility with GCC.
-- ``c``: A 32-bit or 64-bit GPR register suitable for indirect jump (always
- ``25``).
-- ``l``: The ``lo`` register, 32 or 64-bit.
-- ``x``: Invalid.
+- `c`: A 32-bit or 64-bit GPR register suitable for indirect jump (always
+ `25`).
+- `l`: The `lo` register, 32 or 64-bit.
+- `x`: Invalid.
NVPTX:
-- ``b``: A 1-bit integer register.
-- ``c`` or ``h``: A 16-bit integer register.
-- ``r``: A 32-bit integer register.
-- ``l`` or ``N``: A 64-bit integer register.
-- ``q``: A 128-bit integer register.
-- ``f``: A 32-bit float register.
-- ``d``: A 64-bit float register.
+- `b`: A 1-bit integer register.
+- `c` or `h`: A 16-bit integer register.
+- `r`: A 32-bit integer register.
+- `l` or `N`: A 64-bit integer register.
+- `q`: A 128-bit integer register.
+- `f`: A 32-bit float register.
+- `d`: A 64-bit float register.
PowerPC:
-- ``I``: An immediate signed 16-bit integer.
-- ``J``: An immediate unsigned 16-bit integer, shifted left 16 bits.
-- ``K``: An immediate unsigned 16-bit integer.
-- ``L``: An immediate signed 16-bit integer, shifted left 16 bits.
-- ``M``: An immediate integer greater than 31.
-- ``N``: An immediate integer that is an exact power of 2.
-- ``O``: The immediate integer constant 0.
-- ``P``: An immediate integer constant whose negation is a signed 16-bit
+- `I`: An immediate signed 16-bit integer.
+- `J`: An immediate unsigned 16-bit integer, shifted left 16 bits.
+- `K`: An immediate unsigned 16-bit integer.
+- `L`: An immediate signed 16-bit integer, shifted left 16 bits.
+- `M`: An immediate integer greater than 31.
+- `N`: An immediate integer that is an exact power of 2.
+- `O`: The immediate integer constant 0.
+- `P`: An immediate integer constant whose negation is a signed 16-bit
constant.
-- ``es``, ``o``, ``Q``, ``Z``, ``Zy``: A memory address operand, currently
- treated the same as ``m``.
-- ``r``: A 32 or 64-bit integer register.
-- ``b``: A 32 or 64-bit integer register, excluding ``R0`` (that is:
- ``R1-R31``).
-- ``f``: A 32 or 64-bit float register (``F0-F31``),
-- ``v``: For ``4 x f32`` or ``4 x f64`` types, a 128-bit altivec vector
- register (``V0-V31``).
-
-- ``y``: Condition register (``CR0-CR7``).
-- ``wc``: An individual CR bit in a CR register.
-- ``wa``, ``wd``, ``wf``: Any 128-bit VSX vector register, from the full VSX
+- `es`, `o`, `Q`, `Z`, `Zy`: A memory address operand, currently
+ treated the same as `m`.
+- `r`: A 32 or 64-bit integer register.
+- `b`: A 32 or 64-bit integer register, excluding `R0` (that is:
+ `R1-R31`).
+- `f`: A 32 or 64-bit float register (`F0-F31`),
+- `v`: For `4 x f32` or `4 x f64` types, a 128-bit altivec vector
+ : register (`V0-V31`).
+
+- `y`: Condition register (`CR0-CR7`).
+- `wc`: An individual CR bit in a CR register.
+- `wa`, `wd`, `wf`: Any 128-bit VSX vector register, from the full VSX
register set (overlapping both the floating-point and vector register files).
-- ``ws``: A 32 or 64-bit floating-point register, from the full VSX register
+- `ws`: A 32 or 64-bit floating-point register, from the full VSX register
set.
RISC-V:
-- ``A``: An address operand (using a general-purpose register, without an
+- `A`: An address operand (using a general-purpose register, without an
offset).
-- ``I``: A 12-bit signed integer immediate operand.
-- ``J``: A zero integer immediate operand.
-- ``K``: A 5-bit unsigned integer immediate operand.
-- ``f``: A 32- or 64-bit floating-point register (requires F or D extension).
-- ``r``: A 32- or 64-bit general-purpose register (depending on the platform
- ``XLEN``).
-- ``S``: Alias for ``s``.
-- ``vd``: A vector register, excluding ``v0`` (requires V extension).
-- ``vm``: The vector register ``v0`` (requires V extension).
-- ``vr``: A vector register (requires V extension).
+- `I`: A 12-bit signed integer immediate operand.
+- `J`: A zero integer immediate operand.
+- `K`: A 5-bit unsigned integer immediate operand.
+- `f`: A 32- or 64-bit floating-point register (requires F or D extension).
+- `r`: A 32- or 64-bit general-purpose register (depending on the platform
+ `XLEN`).
+- `S`: Alias for `s`.
+- `vd`: A vector register, excluding `v0` (requires V extension).
+- `vm`: The vector register `v0` (requires V extension).
+- `vr`: A vector register (requires V extension).
Sparc:
-- ``I``: An immediate 13-bit signed integer.
-- ``r``: A 32-bit integer register.
-- ``f``: Any floating-point register on SparcV8, or a floating-point
+- `I`: An immediate 13-bit signed integer.
+- `r`: A 32-bit integer register.
+- `f`: Any floating-point register on SparcV8, or a floating-point
register in the "low" half of the registers on SparcV9.
-- ``e``: Any floating-point register. (Same as ``f`` on SparcV8.)
+- `e`: Any floating-point register. (Same as `f` on SparcV8.)
SystemZ:
-- ``I``: An immediate unsigned 8-bit integer.
-- ``J``: An immediate unsigned 12-bit integer.
-- ``K``: An immediate signed 16-bit integer.
-- ``L``: An immediate signed 20-bit integer.
-- ``M``: An immediate integer 0x7fffffff.
-- ``Q``: A memory address operand with a base address and a 12-bit immediate
+- `I`: An immediate unsigned 8-bit integer.
+- `J`: An immediate unsigned 12-bit integer.
+- `K`: An immediate signed 16-bit integer.
+- `L`: An immediate signed 20-bit integer.
+- `M`: An immediate integer 0x7fffffff.
+- `Q`: A memory address operand with a base address and a 12-bit immediate
unsigned displacement.
-- ``R``: A memory address operand with a base address, a 12-bit immediate
+- `R`: A memory address operand with a base address, a 12-bit immediate
unsigned displacement, and an index register.
-- ``S``: A memory address operand with a base address and a 20-bit immediate
+- `S`: A memory address operand with a base address and a 20-bit immediate
signed displacement.
-- ``T``: A memory address operand with a base address, a 20-bit immediate
+- `T`: A memory address operand with a base address, a 20-bit immediate
signed displacement, and an index register.
-- ``r`` or ``d``: A 32, 64, or 128-bit integer register.
-- ``a``: A 32, 64, or 128-bit integer address register (excludes R0, which in an
+- `r` or `d`: A 32, 64, or 128-bit integer register.
+- `a`: A 32, 64, or 128-bit integer address register (excludes R0, which in an
address context evaluates as zero).
-- ``h``: A 32-bit value in the high part of a 64bit data register
+- `h`: A 32-bit value in the high part of a 64bit data register
(LLVM-specific)
-- ``f``: A 16, 32, 64, or 128-bit floating-point register.
+- `f`: A 16, 32, 64, or 128-bit floating-point register.
X86:
-- ``I``: An immediate integer between 0 and 31.
-- ``J``: An immediate integer between 0 and 64.
-- ``K``: An immediate signed 8-bit integer.
-- ``L``: An immediate integer, 0xff or 0xffff or (in 64-bit mode only)
+- `I`: An immediate integer between 0 and 31.
+- `J`: An immediate integer between 0 and 64.
+- `K`: An immediate signed 8-bit integer.
+- `L`: An immediate integer, 0xff or 0xffff or (in 64-bit mode only)
0xffffffff.
-- ``M``: An immediate integer between 0 and 3.
-- ``N``: An immediate unsigned 8-bit integer.
-- ``O``: An immediate integer between 0 and 127.
-- ``e``: An immediate 32-bit signed integer.
-- ``Z``: An immediate 32-bit unsigned integer.
-- ``q``: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
- ``l`` integer register. On X86-32, this is the ``a``, ``b``, ``c``, and ``d``
+- `M`: An immediate integer between 0 and 3.
+- `N`: An immediate unsigned 8-bit integer.
+- `O`: An immediate integer between 0 and 127.
+- `e`: An immediate 32-bit signed integer.
+- `Z`: An immediate 32-bit unsigned integer.
+- `q`: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
+ `l` integer register. On X86-32, this is the `a`, `b`, `c`, and `d`
registers, and on X86-64, it is all of the integer registers. When feature
`egpr` and `inline-asm-use-gpr32` are both on, it will be extended to gpr32.
-- ``Q``: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
- ``h`` integer register. This is the ``a``, ``b``, ``c``, and ``d`` registers.
-- ``r`` or ``l``: An 8, 16, 32, or 64-bit integer register. When feature
+- `Q`: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
+ `h` integer register. This is the `a`, `b`, `c`, and `d` registers.
+- `r` or `l`: An 8, 16, 32, or 64-bit integer register. When feature
`egpr` and `inline-asm-use-gpr32` are both on, it will be extended to gpr32.
-- ``R``: An 8, 16, 32, or 64-bit "legacy" integer register -- one which has
+- `R`: An 8, 16, 32, or 64-bit "legacy" integer register -- one which has
existed since i386, and can be accessed without the REX prefix.
-- ``f``: A 32, 64, or 80-bit '387 FPU stack pseudo-register.
-- ``y``: A 64-bit MMX register, if MMX is enabled.
-- ``v``: If SSE is enabled: a 32 or 64-bit scalar operand, or 128-bit vector
+- `f`: A 32, 64, or 80-bit '387 FPU stack pseudo-register.
+- `y`: A 64-bit MMX register, if MMX is enabled.
+- `v`: If SSE is enabled: a 32 or 64-bit scalar operand, or 128-bit vector
operand in a SSE register. If AVX is also enabled, can also be a 256-bit
vector operand in an AVX register. If AVX-512 is also enabled, can also be a
512-bit vector operand in an AVX512 register. Otherwise, an error.
-- ``Ws``: A symbolic reference with an optional constant addend or a label
+- `Ws`: A symbolic reference with an optional constant addend or a label
reference.
-- ``x``: The same as ``v``, except that when AVX-512 is enabled, the ``x`` code
- only allocates into the first 16 AVX-512 registers, while the ``v`` code
+- `x`: The same as `v`, except that when AVX-512 is enabled, the `x` code
+ only allocates into the first 16 AVX-512 registers, while the `v` code
allocates into any of the 32 AVX-512 registers.
-- ``Y``: The same as ``x``, if *SSE2* is enabled, otherwise an error.
-- ``A``: Special case: allocates EAX first, then EDX, for a single operand (in
+- `Y`: The same as `x`, if *SSE2* is enabled, otherwise an error.
+- `A`: Special case: allocates EAX first, then EDX, for a single operand (in
32-bit mode, a 64-bit integer operand will get split into two registers). It
is not recommended to use this constraint, as in 64-bit mode, the 64-bit
operand will get allocated only to RAX -- if two 32-bit operands are needed,
you're better off splitting it yourself, before passing it to the asm
statement.
-- ``jr``: An 8, 16, 32, or 64-bit integer gpr16. It won't be extended to gpr32
+- `jr`: An 8, 16, 32, or 64-bit integer gpr16. It won't be extended to gpr32
when feature `egpr` or `inline-asm-use-gpr32` is on.
-- ``jR``: An 8, 16, 32, or 64-bit integer gpr32 when feature `egpr`` is on.
- Otherwise, same as ``r``.
+- `jR`: An 8, 16, 32, or 64-bit integer gpr32 when feature `egpr` is on.
+ Otherwise, same as `r`.
XCore:
-- ``r``: A 32-bit integer register.
+- `r`: A 32-bit integer register.
-.. _inline-asm-modifiers:
+(inline-asm-modifiers)=
-Asm template argument modifiers
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Asm template argument modifiers
In the asm template string, modifiers can be used on the operand reference, like
-"``${0:n}``".
+"`${0:n}`".
The modifiers are, in general, expected to behave the same way they do in
GCC. LLVM's support is often implemented on an 'as-needed' basis, to support C
@@ -6213,72 +6287,66 @@ and GCC likely indicates a bug in LLVM.
Target-independent:
-- ``a``: Print a memory reference. Targets might customize the output.
-- ``c``: Print an immediate integer constant unadorned, without
- the target-specific immediate punctuation (e.g., no ``$`` prefix).
-- ``n``: Negate and print immediate integer constant unadorned, without the
- target-specific immediate punctuation (e.g., no ``$`` prefix).
-- ``l``: Print as an unadorned label, without the target-specific label
- punctuation (e.g., no ``$`` prefix).
+- `a`: Print a memory reference. Targets might customize the output.
+- `c`: Print an immediate integer constant unadorned, without
+ the target-specific immediate punctuation (e.g., no `$` prefix).
+- `n`: Negate and print immediate integer constant unadorned, without the
+ target-specific immediate punctuation (e.g., no `$` prefix).
+- `l`: Print as an unadorned label, without the target-specific label
+ punctuation (e.g., no `$` prefix).
AArch64:
-- ``w``: Print a GPR register with a ``w*`` name instead of ``x*`` name. E.g.,
- instead of ``x30``, print ``w30``.
-- ``x``: Print a GPR register with a ``x*`` name. (this is the default, anyhow).
-- ``b``, ``h``, ``s``, ``d``, ``q``: Print a floating-point/SIMD register with a
- ``b*``, ``h*``, ``s*``, ``d*``, or ``q*`` name, rather than the default of
- ``v*``.
+- `w`: Print a GPR register with a `w*` name instead of `x*` name. E.g.,
+ instead of `x30`, print `w30`.
+- `x`: Print a GPR register with a `x*` name. (this is the default, anyhow).
+- `b`, `h`, `s`, `d`, `q`: Print a floating-point/SIMD register with a
+ `b*`, `h*`, `s*`, `d*`, or `q*` name, rather than the default of
+ `v*`.
AMDGPU:
-- ``r``: No effect.
+- `r`: No effect.
ARM:
-- ``a``: Print an operand as an address (with ``[`` and ``]`` surrounding a
+- `a`: Print an operand as an address (with `[` and `]` surrounding a
register).
-- ``P``: No effect.
-- ``q``: No effect.
-- ``y``: Print a VFP single-precision register as an indexed double (e.g., print
- as ``d4[1]`` instead of ``s9``)
-- ``B``: Bitwise invert and print an immediate integer constant without ``#``
+- `P`: No effect.
+- `q`: No effect.
+- `y`: Print a VFP single-precision register as an indexed double (e.g., print
+ as `d4[1]` instead of `s9`)
+- `B`: Bitwise invert and print an immediate integer constant without `#`
prefix.
-- ``L``: Print the low 16-bits of an immediate integer constant.
-- ``M``: Print as a register set suitable for ldm/stm. Also prints *all*
+- `L`: Print the low 16-bits of an immediate integer constant.
+- `M`: Print as a register set suitable for ldm/stm. Also prints *all*
register operands subsequent to the specified one (!), so use carefully.
-- ``Q``: Print the low-order register of a register-pair, or the low-order
+- `Q`: Print the low-order register of a register-pair, or the low-order
register of a two-register operand.
-- ``R``: Print the high-order register of a register-pair, or the high-order
+- `R`: Print the high-order register of a register-pair, or the high-order
register of a two-register operand.
-- ``H``: Print the second register of a register-pair. (On a big-endian system,
- ``H`` is equivalent to ``Q``, and on little-endian system, ``H`` is equivalent
- to ``R``.)
-
- .. FIXME: H doesn't currently support printing the second register
- of a two-register operand.
-
-- ``e``: Print the low doubleword register of a NEON quad register.
-- ``f``: Print the high doubleword register of a NEON quad register.
-- ``m``: Print the base register of a memory operand without the ``[`` and ``]``
+- `H`: Print the second register of a register-pair. (On a big-endian system,
+ `H` is equivalent to `Q`, and on little-endian system, `H` is equivalent
+ to `R`.)
+ % FIXME: H doesn't currently support printing the second register of a two-register operand.
+- `e`: Print the low doubleword register of a NEON quad register.
+- `f`: Print the high doubleword register of a NEON quad register.
+- `m`: Print the base register of a memory operand without the `[` and `]`
adornment.
Hexagon:
-- ``L``: Print the second register of a two-register operand. Requires that it
+- `L`: Print the second register of a two-register operand. Requires that it
has been allocated consecutively to the first.
-
- .. FIXME: why is it restricted to consecutive ones? And there's
- nothing that ensures that happens, is there?
-
-- ``I``: Print the letter 'i' if the operand is an integer constant, otherwise
+ % FIXME: why is it restricted to consecutive ones? And there's nothing that ensures that happens, is there?
+- `I`: Print the letter 'i' if the operand is an integer constant, otherwise
nothing. Used to print 'addi' vs 'add' instructions.
LoongArch:
-- ``u``: Print an LASX register.
-- ``w``: Print an LSX register.
-- ``z``: Print $zero register if operand is zero, otherwise print it normally.
+- `u`: Print an LASX register.
+- `w`: Print an LSX register.
+- `z`: Print $zero register if operand is zero, otherwise print it normally.
MSP430:
@@ -6286,95 +6354,88 @@ No additional modifiers.
MIPS:
-- ``X``: Print an immediate integer as hexadecimal
-- ``x``: Print the low 16 bits of an immediate integer as hexadecimal.
-- ``d``: Print an immediate integer as decimal.
-- ``m``: Subtract one and print an immediate integer as decimal.
-- ``z``: Print $0 if an immediate zero, otherwise print normally.
-- ``L``: Print the low-order register of a two-register operand, or prints the
+- `X`: Print an immediate integer as hexadecimal
+- `x`: Print the low 16 bits of an immediate integer as hexadecimal.
+- `d`: Print an immediate integer as decimal.
+- `m`: Subtract one and print an immediate integer as decimal.
+- `z`: Print $0 if an immediate zero, otherwise print normally.
+- `L`: Print the low-order register of a two-register operand, or prints the
address of the low-order word of a double-word memory operand.
-
- .. FIXME: L seems to be missing memory operand support.
-
-- ``M``: Print the high-order register of a two-register operand, or prints the
+ % FIXME: L seems to be missing memory operand support.
+- `M`: Print the high-order register of a two-register operand, or prints the
address of the high-order word of a double-word memory operand.
-
- .. FIXME: M seems to be missing memory operand support.
-
-- ``D``: Print the second register of a two-register operand, or prints the
- second word of a double-word memory operand. (On a big-endian system, ``D`` is
- equivalent to ``L``, and on little-endian system, ``D`` is equivalent to
- ``M``.)
-- ``w``: No effect. Provided for compatibility with GCC which requires this
- modifier in order to print MSA registers (``W0-W31``) with the ``f``
+ % FIXME: M seems to be missing memory operand support.
+- `D`: Print the second register of a two-register operand, or prints the
+ second word of a double-word memory operand. (On a big-endian system, `D` is
+ equivalent to `L`, and on little-endian system, `D` is equivalent to
+ `M`.)
+- `w`: No effect. Provided for compatibility with GCC which requires this
+ modifier in order to print MSA registers (`W0-W31`) with the `f`
constraint.
NVPTX:
-- ``r``: No effect.
+- `r`: No effect.
PowerPC:
-- ``L``: Print the second register of a two-register operand. Requires that it
+- `L`: Print the second register of a two-register operand. Requires that it
has been allocated consecutively to the first.
-
- .. FIXME: why is it restricted to consecutive ones? And there's
- nothing that ensures that happens, is there?
-
-- ``I``: Print the letter 'i' if the operand is an integer constant, otherwise
+ % FIXME: why is it restricted to consecutive ones? And there's nothing that ensures that happens, is there?
+- `I`: Print the letter 'i' if the operand is an integer constant, otherwise
nothing. Used to print 'addi' vs 'add' instructions.
-- ``y``: For a memory operand, prints formatter for a two-register X-form
- instruction. (Currently always prints ``r0,OPERAND``).
-- ``U``: Prints 'u' if the memory operand is an update form, and nothing
+- `y`: For a memory operand, prints formatter for a two-register X-form
+ instruction. (Currently always prints `r0,OPERAND`).
+- `U`: Prints 'u' if the memory operand is an update form, and nothing
otherwise. (NOTE: LLVM does not support update form, so this will currently
always print nothing)
-- ``X``: Prints 'x' if the memory operand is an indexed form. (NOTE: LLVM does
+- `X`: Prints 'x' if the memory operand is an indexed form. (NOTE: LLVM does
not support indexed form, so this will currently always print nothing)
RISC-V:
-- ``i``: Print the letter 'i' if the operand is not a register, otherwise print
+- `i`: Print the letter 'i' if the operand is not a register, otherwise print
nothing. Used to print 'addi' vs 'add' instructions, etc.
-- ``z``: Print the register ``zero`` if an immediate zero, otherwise print
+- `z`: Print the register `zero` if an immediate zero, otherwise print
normally.
Sparc:
-- ``L``: Print the low-order register of a two-register operand.
-- ``H``: Print the high-order register of a two-register operand.
-- ``r``: No effect.
+- `L`: Print the low-order register of a two-register operand.
+- `H`: Print the high-order register of a two-register operand.
+- `r`: No effect.
SystemZ:
-SystemZ implements only ``n``, and does *not* support any of the other
+SystemZ implements only `n`, and does *not* support any of the other
target-independent modifiers.
X86:
-- ``a``: Print a memory reference. This displays as ``sym(%rip)`` for x86-64.
+- `a`: Print a memory reference. This displays as `sym(%rip)` for x86-64.
i386 should only use this with the static relocation model.
-- ``c``: Print an unadorned integer or symbol name. (The latter is
+- `c`: Print an unadorned integer or symbol name. (The latter is
target-specific behavior for this typically target-independent modifier).
-- ``A``: Print a register name with a '``*``' before it.
-- ``b``: Print an 8-bit register name (e.g., ``al``); do nothing on a memory
+- `A`: Print a register name with a '`*`' before it.
+- `b`: Print an 8-bit register name (e.g., `al`); do nothing on a memory
operand.
-- ``h``: Print the upper 8-bit register name (e.g., ``ah``); do nothing on a
+- `h`: Print the upper 8-bit register name (e.g., `ah`); do nothing on a
memory operand.
-- ``w``: Print the 16-bit register name (e.g., ``ax``); do nothing on a memory
+- `w`: Print the 16-bit register name (e.g., `ax`); do nothing on a memory
operand.
-- ``k``: Print the 32-bit register name (e.g., ``eax``); do nothing on a memory
+- `k`: Print the 32-bit register name (e.g., `eax`); do nothing on a memory
operand.
-- ``q``: Print the 64-bit register name (e.g., ``rax``), if 64-bit registers are
+- `q`: Print the 64-bit register name (e.g., `rax`), if 64-bit registers are
available, otherwise the 32-bit register name; do nothing on a memory operand.
-- ``n``: Negate and print an unadorned integer, or, for operands other than an
+- `n`: Negate and print an unadorned integer, or, for operands other than an
immediate integer (e.g., a relocatable symbol expression), print a '-' before
the operand. (The behavior for relocatable symbol expressions is a
target-specific behavior for this typically target-independent modifier)
-- ``H``: Print a memory reference with additional offset +8.
-- ``p``: Print a raw symbol name (without syntax-specific prefixes).
-- ``P``: Print a memory reference used as the argument of a call instruction or
+- `H`: Print a memory reference with additional offset +8.
+- `p`: Print a raw symbol name (without syntax-specific prefixes).
+- `P`: Print a memory reference used as the argument of a call instruction or
used with explicit base reg and index reg as its offset. So it can not use
- additional regs to present the memory reference. (E.g. omit ``(rip)``, even
+ additional regs to present the memory reference. (E.g. omit `(rip)`, even
though it's PC-relative.)
XCore:
@@ -6382,32 +6443,30 @@ XCore:
No additional modifiers.
-Inline Asm Metadata
-^^^^^^^^^^^^^^^^^^^
+#### Inline Asm Metadata
The call instructions that wrap inline asm nodes may have a
-"``!srcloc``" MDNode attached to it that contains a list of constant
+"`!srcloc`" MDNode attached to it that contains a list of constant
integers. If present, the code generator will use the integer as the
-location cookie value when reporting errors through the ``LLVMContext``
+location cookie value when reporting errors through the `LLVMContext`
error reporting mechanisms. This allows a front-end to correlate backend
errors that occur with inline asm back to the source code that produced
it. For example:
-.. code-block:: llvm
-
- call void asm sideeffect "something bad", ""(), !srcloc !42
- ...
- !42 = !{ i64 1234567 }
+```llvm
+call void asm sideeffect "something bad", ""(), !srcloc !42
+...
+!42 = !{ i64 1234567 }
+```
It is up to the front-end to make sense of the magic numbers it places
in the IR. If the MDNode contains multiple constants, the code generator
will use the one that corresponds to the line of the asm that the error
occurs on.
-.. _metadata:
+(metadata)=
-Metadata
-========
+## Metadata
LLVM IR allows metadata to be attached to instructions and global objects in
the program that can convey extra information about the code to the optimizers
@@ -6417,173 +6476,161 @@ There are two metadata primitives: strings and nodes. There are
also specialized nodes which have a distinguished name and a set of named
arguments.
-.. note::
-
- One example application of metadata is source-level debug information,
- which is currently the only user of specialized nodes.
+```{note}
+One example application of metadata is source-level debug information,
+which is currently the only user of specialized nodes.
+```
Metadata does not have a type, and is not a value.
-A value of non-\ ``metadata`` type can be used in a metadata context using the
-syntax '``<type> <value>``'.
+A value of non-`metadata` type can be used in a metadata context using the
+syntax '`<type> <value>`'.
All other metadata is identified in syntax as starting with an exclamation
-point ('``!``').
+point ('`!`').
-Metadata may be used in the following value contexts by using the ``metadata``
+Metadata may be used in the following value contexts by using the `metadata`
type:
- Arguments to certain intrinsic functions, as described in their specification.
-- Arguments to the ``catchpad``/``cleanuppad`` instructions.
-
-.. note::
+- Arguments to the `catchpad`/`cleanuppad` instructions.
- Metadata can be "wrapped" in a ``MetadataAsValue`` so it can be referenced
- in a value context: ``MetadataAsValue`` is-a ``Value``.
+````{note}
+Metadata can be "wrapped" in a `MetadataAsValue` so it can be referenced
+in a value context: `MetadataAsValue` is-a `Value`.
- A typed value can be "wrapped" in ``ValueAsMetadata`` so it can be
- referenced in a metadata context: ``ValueAsMetadata`` is-a ``Metadata``.
+A typed value can be "wrapped" in `ValueAsMetadata` so it can be
+referenced in a metadata context: `ValueAsMetadata` is-a `Metadata`.
- There is no explicit syntax for a ``ValueAsMetadata``, and instead
- the fact that a type identifier cannot begin with an exclamation point
- is used to resolve ambiguity.
+There is no explicit syntax for a `ValueAsMetadata`, and instead
+the fact that a type identifier cannot begin with an exclamation point
+is used to resolve ambiguity.
- A ``metadata`` type implies a ``MetadataAsValue``, and when followed with a
- '``<type> <value>``' pair it wraps the typed value in a ``ValueAsMetadata``.
+A `metadata` type implies a `MetadataAsValue`, and when followed with a
+'`<type> <value>`' pair it wraps the typed value in a `ValueAsMetadata`.
- For example, the first argument
- to this call is a ``MetadataAsValue(ValueAsMetadata(Value))``:
+For example, the first argument
+to this call is a `MetadataAsValue(ValueAsMetadata(Value))`:
- .. code-block:: llvm
+```llvm
+call void @llvm.foo(metadata i32 1)
+```
- call void @llvm.foo(metadata i32 1)
+Whereas the first argument to this call is a `MetadataAsValue(MDNode)`:
- Whereas the first argument to this call is a ``MetadataAsValue(MDNode)``:
+```llvm
+call void @llvm.foo(metadata !0)
+```
- .. code-block:: llvm
+The first element of this `MDTuple` is a `MDNode`:
- call void @llvm.foo(metadata !0)
+```llvm
+!{!0}
+```
- The first element of this ``MDTuple`` is a ``MDNode``:
+And the first element of this `MDTuple` is a `ValueAsMetadata(Value)`:
- .. code-block:: llvm
+```llvm
+!{i32 1}
+```
+````
- !{!0}
+(metadata-string)=
- And the first element of this ``MDTuple`` is a ``ValueAsMetadata(Value)``:
-
- .. code-block:: llvm
-
- !{i32 1}
-
-.. _metadata-string:
-
-Metadata Strings (``MDString``)
--------------------------------
-
-.. FIXME Either fix all references to "MDString" in the docs, or make that
- identifier a formal part of the document.
+### Metadata Strings (`MDString`)
+% FIXME Either fix all references to "MDString" in the docs, or make that identifier a formal part of the document.
A metadata string is a string surrounded by double quotes. It can
contain any character by escaping non-printable characters with
-"``\xx``" where "``xx``" is the two digit hex code. For example:
-"``!"test\00"``".
-
-.. note::
+"`\xx`" where "`xx`" is the two digit hex code. For example:
+"`!"test\00"`".
- A metadata string is metadata, but is not a metadata node.
+```{note}
+A metadata string is metadata, but is not a metadata node.
+```
-.. _metadata-node:
+(metadata-node)=
-Metadata Nodes (``MDNode``)
----------------------------
-
-.. FIXME Either fix all references to "MDNode" in the docs, or make that
- identifier a formal part of the document.
+### Metadata Nodes (`MDNode`)
+% FIXME Either fix all references to "MDNode" in the docs, or make that identifier a formal part of the document.
Metadata tuples are represented with notation similar to structure
constants: a comma separated list of elements, surrounded by braces and
preceded by an exclamation point. Metadata nodes can have any values as
their operand. For example:
-.. code-block:: llvm
-
- !{!"test\00", i32 10}
+```llvm
+!{!"test\00", i32 10}
+```
-Metadata nodes that aren't uniqued use the ``distinct`` keyword. For example:
+Metadata nodes that aren't uniqued use the `distinct` keyword. For example:
-.. code-block:: text
+```text
+!0 = distinct !{!"test\00", i32 10}
+```
- !0 = distinct !{!"test\00", i32 10}
-
-``distinct`` nodes are useful when nodes shouldn't be merged based on their
+`distinct` nodes are useful when nodes shouldn't be merged based on their
content. They can also occur when transformations cause uniquing collisions
when metadata operands change.
-A :ref:`named metadata <namedmetadatastructure>` is a collection of
+A {ref}`named metadata <namedmetadatastructure>` is a collection of
metadata nodes, which can be looked up in the module symbol table. For
example:
-.. code-block:: llvm
-
- !foo = !{!4, !3}
+```llvm
+!foo = !{!4, !3}
+```
-Metadata can be used as function arguments. Here the ``llvm.dbg.value``
+Metadata can be used as function arguments. Here the `llvm.dbg.value`
intrinsic is using three metadata arguments:
-.. code-block:: llvm
-
- call void @llvm.dbg.value(metadata !24, metadata !25, metadata !26)
-
+```llvm
+call void @llvm.dbg.value(metadata !24, metadata !25, metadata !26)
+```
-.. FIXME Attachments cannot be ValueAsMetadata, but we don't have a
- particularly clear way to refer to ValueAsMetadata without getting into
- implementation details. Ideally the restriction would be explicit somewhere,
- though?
+% FIXME Attachments cannot be ValueAsMetadata, but we don't have a particularly clear way to refer to ValueAsMetadata without getting into implementation details. Ideally the restriction would be explicit somewhere, though?
+Metadata can be attached to an instruction. Here metadata `!21` is attached
+to the `add` instruction using the `!dbg` identifier:
-Metadata can be attached to an instruction. Here metadata ``!21`` is attached
-to the ``add`` instruction using the ``!dbg`` identifier:
-
-.. code-block:: llvm
-
- %indvar.next = add i64 %indvar, 1, !dbg !21
+```llvm
+%indvar.next = add i64 %indvar, 1, !dbg !21
+```
Instructions may not have multiple metadata attachments with the same
identifier.
Metadata can also be attached to a function or a global variable. Here metadata
-``!22`` is attached to the ``f1`` and ``f2`` functions, and the globals ``g1``
-and ``g2`` using the ``!dbg`` identifier:
+`!22` is attached to the `f1` and `f2` functions, and the globals `g1`
+and `g2` using the `!dbg` identifier:
-.. code-block:: llvm
+```llvm
+declare !dbg !22 void @f1()
+define void @f2() !dbg !22 {
+ ret void
+}
- declare !dbg !22 void @f1()
- define void @f2() !dbg !22 {
- ret void
- }
-
- @g1 = global i32 0, !dbg !22
- @g2 = external global i32, !dbg !22
+ at g1 = global i32 0, !dbg !22
+ at g2 = external global i32, !dbg !22
+```
Unlike instructions, global objects (functions and global variables) may have
multiple metadata attachments with the same identifier.
A transformation is required to drop any metadata attachment that it
does not recognize or cannot preserve. Currently there is an
-exception for metadata attachment to globals for ``!func_sanitize``,
-``!type``, ``!absolute_symbol``, ``!implicit.ref`` and ``!associated`` which
+exception for metadata attachment to globals for `!func_sanitize`,
+`!type`, `!absolute_symbol`, `!implicit.ref` and `!associated` which
can't be unconditionally dropped unless the global is itself deleted.
Metadata attached to a module using named metadata may not be dropped, with
-the exception of debug metadata (named metadata with the name ``!llvm.dbg.*``).
+the exception of debug metadata (named metadata with the name `!llvm.dbg.*`).
More information about specific metadata nodes recognized by the
optimizers and code generator is found below.
-.. _specialized-metadata:
+(specialized-metadata)=
-Specialized Metadata Nodes
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Specialized Metadata Nodes
Specialized metadata nodes are custom data structures in metadata (as opposed
to generic tuples). Their fields are labelled, and can be specified in any
@@ -6592,737 +6639,697 @@ order.
These aren't inherently debug info centric, but currently all the specialized
metadata nodes are related to debug info.
-.. _DICompileUnit:
+(DICompileUnit)=
-DICompileUnit
-"""""""""""""
+##### DICompileUnit
-``DICompileUnit`` nodes represent a compile unit. The ``enums:``,
-``retainedTypes:``, ``globals:``, ``imports:`` and ``macros:`` fields are tuples
+`DICompileUnit` nodes represent a compile unit. The `enums:`,
+`retainedTypes:`, `globals:`, `imports:` and `macros:` fields are tuples
containing the debug info to be emitted along with the compile unit, regardless
of code optimizations (some nodes are only emitted if there are references to
-them from instructions). The ``debugInfoForProfiling:`` field is a boolean
+them from instructions). The `debugInfoForProfiling:` field is a boolean
indicating whether or not line-table discriminators are updated to provide
more-accurate debug info for profiling results.
-.. code-block:: text
-
- !0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang",
- isOptimized: true, flags: "-O2", runtimeVersion: 2,
- splitDebugFilename: "abc.debug", emissionKind: FullDebug,
- enums: !2, retainedTypes: !3, globals: !4, imports: !5,
- macros: !6, dwoId: 0x0abcd)
-
-The optional ``dialect:`` field encodes the source-language *dialect* of the
-compile unit as an enum. It corresponds to the ``DW_AT_LLVM_language_dialect``
-attribute emitted on ``DW_TAG_compile_unit`` and is intended for language
+```text
+!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang",
+ isOptimized: true, flags: "-O2", runtimeVersion: 2,
+ splitDebugFilename: "abc.debug", emissionKind: FullDebug,
+ enums: !2, retainedTypes: !3, globals: !4, imports: !5,
+ macros: !6, dwoId: 0x0abcd)
+```
+
+The optional `dialect:` field encodes the source-language *dialect* of the
+compile unit as an enum. It corresponds to the `DW_AT_LLVM_language_dialect`
+attribute emitted on `DW_TAG_compile_unit` and is intended for language
dialects that represent different execution models. When specified, the field
must name one of the known dialects, either symbolically or with the matching
-numeric value; see :ref:`llvm_language_dialect` for the list of supported
+numeric value; see {ref}`llvm_language_dialect` for the list of supported
values.
-Omitting the ``dialect:`` field is the only way to express "no dialect" in
+Omitting the `dialect:` field is the only way to express "no dialect" in
textual IR.
-.. code-block:: text
-
- !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang",
- isOptimized: false, runtimeVersion: 0,
- emissionKind: FullDebug,
- dialect: DW_LLVM_LANG_DIALECT_simt)
+```text
+!0 = !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang",
+ isOptimized: false, runtimeVersion: 0,
+ emissionKind: FullDebug,
+ dialect: DW_LLVM_LANG_DIALECT_simt)
+```
Compile unit descriptors provide the root scope for objects declared in a
specific compilation unit. File descriptors are defined using this scope. These
-descriptors are collected by a named metadata node ``!llvm.dbg.cu``. They keep
+descriptors are collected by a named metadata node `!llvm.dbg.cu`. They keep
track of global variables, type information, and imported entities (declarations
and namespaces).
-.. _DIFile:
+(DIFile)=
-DIFile
-""""""
+##### DIFile
-``DIFile`` nodes represent files. The ``filename:`` can include slashes.
+`DIFile` nodes represent files. The `filename:` can include slashes.
-.. code-block:: none
+```
+!0 = !DIFile(filename: "path/to/file", directory: "/path/to/dir",
+ checksumkind: CSK_MD5,
+ checksum: "000102030405060708090a0b0c0d0e0f")
+```
- !0 = !DIFile(filename: "path/to/file", directory: "/path/to/dir",
- checksumkind: CSK_MD5,
- checksum: "000102030405060708090a0b0c0d0e0f")
+Files are sometimes used in `scope:` fields, and are the only valid target
+for `file:` fields.
-Files are sometimes used in ``scope:`` fields, and are the only valid target
-for ``file:`` fields.
-
-The ``checksum:`` and ``checksumkind:`` fields are optional. If one of these
+The `checksum:` and `checksumkind:` fields are optional. If one of these
fields is present, then the other is required to be present as well. Valid
-values for ``checksumkind:`` field are: {CSK_MD5, CSK_SHA1, CSK_SHA256}
-
-.. _DIBasicType:
+values for `checksumkind:` field are: {CSK_MD5, CSK_SHA1, CSK_SHA256}
-DIBasicType
-"""""""""""
+(DIBasicType)=
-``DIBasicType`` nodes represent primitive types, such as ``int``, ``bool`` and
-``float``. ``tag:`` defaults to ``DW_TAG_base_type``.
+##### DIBasicType
-.. code-block:: text
+`DIBasicType` nodes represent primitive types, such as `int`, `bool` and
+`float`. `tag:` defaults to `DW_TAG_base_type`.
- !0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
- encoding: DW_ATE_unsigned_char)
- !1 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
+```text
+!0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
+ encoding: DW_ATE_unsigned_char)
+!1 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
+```
-The ``encoding:`` describes the details of the type. Usually it's one of the
+The `encoding:` describes the details of the type. Usually it's one of the
following:
-.. code-block:: text
+```text
+DW_ATE_address = 1
+DW_ATE_boolean = 2
+DW_ATE_float = 4
+DW_ATE_signed = 5
+DW_ATE_signed_char = 6
+DW_ATE_unsigned = 7
+DW_ATE_unsigned_char = 8
+```
- DW_ATE_address = 1
- DW_ATE_boolean = 2
- DW_ATE_float = 4
- DW_ATE_signed = 5
- DW_ATE_signed_char = 6
- DW_ATE_unsigned = 7
- DW_ATE_unsigned_char = 8
+(DIFixedPointType)=
-.. _DIFixedPointType:
+##### DIFixedPointType
-DIFixedPointType
-""""""""""""""""
-
-``DIFixedPointType`` nodes represent fixed-point types. A fixed-point
+`DIFixedPointType` nodes represent fixed-point types. A fixed-point
type is conceptually an integer with a scale factor.
-``DIFixedPointType`` is derived from ``DIBasicType`` and inherits its
+`DIFixedPointType` is derived from `DIBasicType` and inherits its
attributes. However, only certain encodings are accepted:
-.. code-block:: text
-
- DW_ATE_signed_fixed = 13
- DW_ATE_unsigned_fixed = 14
+```text
+DW_ATE_signed_fixed = 13
+DW_ATE_unsigned_fixed = 14
+```
There are three kinds of fixed-point type: binary, where the scale
factor is a power of 2; decimal, where the scale factor is a power of
10; and rational, where the scale factor is an arbitrary rational
number.
-.. code-block:: text
+```text
+!0 = !DIFixedPointType(name: "decimal", size: 8, encoding: DW_ATE_signed_fixed,
+ kind: Decimal, factor: -4)
+!1 = !DIFixedPointType(name: "binary", size: 8, encoding: DW_ATE_unsigned_fixed,
+ kind: Binary, factor: -16)
+!2 = !DIFixedPointType(name: "rational", size: 8, encoding: DW_ATE_signed_fixed,
+ kind: Rational, numerator: 1234, denominator: 5678)
+```
- !0 = !DIFixedPointType(name: "decimal", size: 8, encoding: DW_ATE_signed_fixed,
- kind: Decimal, factor: -4)
- !1 = !DIFixedPointType(name: "binary", size: 8, encoding: DW_ATE_unsigned_fixed,
- kind: Binary, factor: -16)
- !2 = !DIFixedPointType(name: "rational", size: 8, encoding: DW_ATE_signed_fixed,
- kind: Rational, numerator: 1234, denominator: 5678)
+(DISubroutineType)=
-.. _DISubroutineType:
+##### DISubroutineType
-DISubroutineType
-""""""""""""""""
-
-``DISubroutineType`` nodes represent subroutine types. Their ``types:`` field
+`DISubroutineType` nodes represent subroutine types. Their `types:` field
refers to a tuple; the first operand is the return type, while the rest are the
-types of the formal arguments in order. If the first operand is ``null``, that
-represents a function with no return value (such as ``void foo() {}`` in C++).
-
-.. code-block:: text
+types of the formal arguments in order. If the first operand is `null`, that
+represents a function with no return value (such as `void foo() {}` in C++).
- !0 = !BasicType(name: "int", size: 32, align: 32, DW_ATE_signed)
- !1 = !BasicType(name: "char", size: 8, align: 8, DW_ATE_signed_char)
- !2 = !DISubroutineType(types: !{null, !0, !1}) ; void (int, char)
+```text
+!0 = !BasicType(name: "int", size: 32, align: 32, DW_ATE_signed)
+!1 = !BasicType(name: "char", size: 8, align: 8, DW_ATE_signed_char)
+!2 = !DISubroutineType(types: !{null, !0, !1}) ; void (int, char)
+```
-.. _DIDerivedType:
+(DIDerivedType)=
-DIDerivedType
-"""""""""""""
+##### DIDerivedType
-``DIDerivedType`` nodes represent types derived from other types, such as
+`DIDerivedType` nodes represent types derived from other types, such as
qualified types.
-.. code-block:: text
-
- !0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
- encoding: DW_ATE_unsigned_char)
- !1 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !0, size: 32,
- align: 32)
-
-The following ``tag:`` values are valid:
-
-.. code-block:: text
-
- DW_TAG_member = 13
- DW_TAG_pointer_type = 15
- DW_TAG_reference_type = 16
- DW_TAG_typedef = 22
- DW_TAG_inheritance = 28
- DW_TAG_ptr_to_member_type = 31
- DW_TAG_const_type = 38
- DW_TAG_friend = 42
- DW_TAG_volatile_type = 53
- DW_TAG_restrict_type = 55
- DW_TAG_atomic_type = 71
- DW_TAG_immutable_type = 75
-
-.. _DIDerivedTypeMember:
-
-``DW_TAG_member`` is used to define a member of a :ref:`composite type
-<DICompositeType>`. The type of the member is the ``baseType:``. The
-``offset:`` is the member's bit offset. If the composite type has an ODR
-``identifier:`` and does not set ``flags: DIFwdDecl``, then the member is
-uniqued based only on its ``name:`` and ``scope:``.
-
-``DW_TAG_inheritance`` and ``DW_TAG_friend`` are used in the ``elements:``
-field of :ref:`composite types <DICompositeType>` to describe parents and
+```text
+!0 = !DIBasicType(name: "unsigned char", size: 8, align: 8,
+ encoding: DW_ATE_unsigned_char)
+!1 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !0, size: 32,
+ align: 32)
+```
+
+The following `tag:` values are valid:
+
+```text
+DW_TAG_member = 13
+DW_TAG_pointer_type = 15
+DW_TAG_reference_type = 16
+DW_TAG_typedef = 22
+DW_TAG_inheritance = 28
+DW_TAG_ptr_to_member_type = 31
+DW_TAG_const_type = 38
+DW_TAG_friend = 42
+DW_TAG_volatile_type = 53
+DW_TAG_restrict_type = 55
+DW_TAG_atomic_type = 71
+DW_TAG_immutable_type = 75
+```
+
+(DIDerivedTypeMember)=
+
+`DW_TAG_member` is used to define a member of a {ref}`composite type
+<DICompositeType>`. The type of the member is the `baseType:`. The
+`offset:` is the member's bit offset. If the composite type has an ODR
+`identifier:` and does not set `flags: DIFwdDecl`, then the member is
+uniqued based only on its `name:` and `scope:`.
+
+`DW_TAG_inheritance` and `DW_TAG_friend` are used in the `elements:`
+field of {ref}`composite types <DICompositeType>` to describe parents and
friends.
-``DW_TAG_typedef`` is used to provide a name for the ``baseType:``.
+`DW_TAG_typedef` is used to provide a name for the `baseType:`.
-``DW_TAG_pointer_type``, ``DW_TAG_reference_type``, ``DW_TAG_const_type``,
-``DW_TAG_volatile_type``, ``DW_TAG_restrict_type``, ``DW_TAG_atomic_type`` and
-``DW_TAG_immutable_type`` are used to qualify the ``baseType:``.
+`DW_TAG_pointer_type`, `DW_TAG_reference_type`, `DW_TAG_const_type`,
+`DW_TAG_volatile_type`, `DW_TAG_restrict_type`, `DW_TAG_atomic_type` and
+`DW_TAG_immutable_type` are used to qualify the `baseType:`.
-Note that the ``void *`` type is expressed as a type derived from NULL.
+Note that the `void *` type is expressed as a type derived from NULL.
-.. _DICompositeType:
+(DICompositeType)=
-DICompositeType
-"""""""""""""""
+##### DICompositeType
-``DICompositeType`` nodes represent types composed of other types, like
-structures and unions. ``elements:`` points to a tuple of the composed types.
+`DICompositeType` nodes represent types composed of other types, like
+structures and unions. `elements:` points to a tuple of the composed types.
-If the source language supports ODR, the ``identifier:`` field gives the unique
+If the source language supports ODR, the `identifier:` field gives the unique
identifier used for type merging between modules. When specified,
-:ref:`subprogram declarations <DISubprogramDeclaration>` and :ref:`member
+{ref}`subprogram declarations <DISubprogramDeclaration>` and {ref}`member
derived types <DIDerivedTypeMember>` that reference the ODR-type in their
-``scope:`` change uniquing rules.
-
-For a given ``identifier:``, there should only be a single composite type that
-does not have ``flags: DIFlagFwdDecl`` set. LLVM tools that link modules
-together will unique such definitions at parse time via the ``identifier:``
-field, even if the nodes are ``distinct``.
-
-.. code-block:: text
-
- !0 = !DIEnumerator(name: "SixKind", value: 7)
- !1 = !DIEnumerator(name: "SevenKind", value: 7)
- !2 = !DIEnumerator(name: "NegEightKind", value: -8)
- !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !12,
- line: 2, size: 32, align: 32, identifier: "_M4Enum",
- elements: !{!0, !1, !2})
-
-The following ``tag:`` values are valid:
-
-.. code-block:: text
-
- DW_TAG_array_type = 1
- DW_TAG_class_type = 2
- DW_TAG_enumeration_type = 4
- DW_TAG_structure_type = 19
- DW_TAG_union_type = 23
- DW_TAG_variant = 25
- DW_TAG_variant_part = 51
-
-For ``DW_TAG_array_type``, the ``elements:`` should be :ref:`subrange
-descriptors <DISubrange>` or :ref:`subrange descriptors
+`scope:` change uniquing rules.
+
+For a given `identifier:`, there should only be a single composite type that
+does not have `flags: DIFlagFwdDecl` set. LLVM tools that link modules
+together will unique such definitions at parse time via the `identifier:`
+field, even if the nodes are `distinct`.
+
+```text
+!0 = !DIEnumerator(name: "SixKind", value: 7)
+!1 = !DIEnumerator(name: "SevenKind", value: 7)
+!2 = !DIEnumerator(name: "NegEightKind", value: -8)
+!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !12,
+ line: 2, size: 32, align: 32, identifier: "_M4Enum",
+ elements: !{!0, !1, !2})
+```
+
+The following `tag:` values are valid:
+
+```text
+DW_TAG_array_type = 1
+DW_TAG_class_type = 2
+DW_TAG_enumeration_type = 4
+DW_TAG_structure_type = 19
+DW_TAG_union_type = 23
+DW_TAG_variant = 25
+DW_TAG_variant_part = 51
+```
+
+For `DW_TAG_array_type`, the `elements:` should be {ref}`subrange
+descriptors <DISubrange>` or {ref}`subrange descriptors
<DISubrangeType>`, each representing the range of subscripts at that
-level of indexing. The ``DIFlagVector`` flag to ``flags:`` indicates
+level of indexing. The `DIFlagVector` flag to `flags:` indicates
that an array type is a native packed vector. The optional
-``dataLocation`` is a ``DIExpression`` that describes how to get from an
+`dataLocation` is a `DIExpression` that describes how to get from an
object's address to the actual raw data, if they aren't
equivalent. This is only supported for array types, particularly to
describe Fortran arrays, which have an array descriptor in addition to
-the array data. Alternatively it can also be ``DIVariable`` which has the
+the array data. Alternatively it can also be `DIVariable` which has the
address of the actual raw data. The Fortran language supports pointer
arrays which can be attached to actual arrays, this attachment between
pointer and pointee is called association. The optional
-``associated`` is a ``DIExpression`` that describes whether the pointer
-array is currently associated. The optional ``allocated`` is a
-``DIExpression`` that describes whether the allocatable array is currently
-allocated. The optional ``rank`` is a ``DIExpression`` that describes the
+`associated` is a `DIExpression` that describes whether the pointer
+array is currently associated. The optional `allocated` is a
+`DIExpression` that describes whether the allocatable array is currently
+allocated. The optional `rank` is a `DIExpression` that describes the
rank (number of dimensions) of Fortran assumed rank array (rank is
-known at runtime). The optional ``bitStride`` is an unsigned constant
+known at runtime). The optional `bitStride` is an unsigned constant
that describes the number of bits occupied by an element of the array;
this is only needed if it differs from the element type's natural
size, and is normally used for packed arrays.
-For ``DW_TAG_enumeration_type``, the ``elements:`` should be :ref:`enumerator
+For `DW_TAG_enumeration_type`, the `elements:` should be {ref}`enumerator
descriptors <DIEnumerator>`, each representing the definition of an enumeration
value for the set. All enumeration type descriptors are collected in the
-``enums:`` field of the :ref:`compile unit <DICompileUnit>`.
+`enums:` field of the {ref}`compile unit <DICompileUnit>`.
-For ``DW_TAG_structure_type``, ``DW_TAG_class_type``, and
-``DW_TAG_union_type``, the ``elements:`` should be :ref:`derived types
-<DIDerivedType>` with ``tag: DW_TAG_member``, ``tag: DW_TAG_inheritance``, or
-``tag: DW_TAG_friend``; or :ref:`subprograms <DISubprogram>` with
-``isDefinition: false``.
+For `DW_TAG_structure_type`, `DW_TAG_class_type`, and
+`DW_TAG_union_type`, the `elements:` should be {ref}`derived types
+<DIDerivedType>` with `tag: DW_TAG_member`, `tag: DW_TAG_inheritance`, or
+`tag: DW_TAG_friend`; or {ref}`subprograms <DISubprogram>` with
+`isDefinition: false`.
-``DW_TAG_variant_part`` introduces a variant part of a structure type.
+`DW_TAG_variant_part` introduces a variant part of a structure type.
This should have a discriminant, a member that is used to decide which
elements are active. The elements of the variant part should each be
-a ``DW_TAG_member``; if a member has a non-null ``ExtraData``, then it
-is a ``ConstantInt`` or ``ConstantDataArray`` indicating the values of
+a `DW_TAG_member`; if a member has a non-null `ExtraData`, then it
+is a `ConstantInt` or `ConstantDataArray` indicating the values of
the discriminant member that cause the activation of this branch. A
-member itself may be of composite type with tag ``DW_TAG_variant``; in
+member itself may be of composite type with tag `DW_TAG_variant`; in
this case the members of that composite type are inlined into the
current one.
-.. _DISubrange:
+(DISubrange)=
-DISubrange
-""""""""""
+##### DISubrange
-``DISubrange`` nodes are the elements for ``DW_TAG_array_type`` variants of
-:ref:`DICompositeType`.
+`DISubrange` nodes are the elements for `DW_TAG_array_type` variants of
+{ref}`DICompositeType`.
-- ``count: -1`` indicates an empty array.
-- ``count: !10`` describes the count with a :ref:`DILocalVariable`.
-- ``count: !12`` describes the count with a :ref:`DIGlobalVariable`.
+- `count: -1` indicates an empty array.
+- `count: !10` describes the count with a {ref}`DILocalVariable`.
+- `count: !12` describes the count with a {ref}`DIGlobalVariable`.
-.. code-block:: text
+```text
+!0 = !DISubrange(count: 5, lowerBound: 0) ; array counting from 0
+!1 = !DISubrange(count: 5, lowerBound: 1) ; array counting from 1
+!2 = !DISubrange(count: -1) ; empty array.
- !0 = !DISubrange(count: 5, lowerBound: 0) ; array counting from 0
- !1 = !DISubrange(count: 5, lowerBound: 1) ; array counting from 1
- !2 = !DISubrange(count: -1) ; empty array.
+; Scopes used in rest of example
+!6 = !DIFile(filename: "vla.c", directory: "/path/to/file")
+!7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6)
+!8 = distinct !DISubprogram(name: "foo", scope: !7, file: !6, line: 5)
- ; Scopes used in rest of example
- !6 = !DIFile(filename: "vla.c", directory: "/path/to/file")
- !7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6)
- !8 = distinct !DISubprogram(name: "foo", scope: !7, file: !6, line: 5)
+; Use of local variable as count value
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !DILocalVariable(name: "count", scope: !8, file: !6, line: 42, type: !9)
+!11 = !DISubrange(count: !10, lowerBound: 0)
- ; Use of local variable as count value
- !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
- !10 = !DILocalVariable(name: "count", scope: !8, file: !6, line: 42, type: !9)
- !11 = !DISubrange(count: !10, lowerBound: 0)
+; Use of global variable as count value
+!12 = !DIGlobalVariable(name: "count", scope: !8, file: !6, line: 22, type: !9)
+!13 = !DISubrange(count: !12, lowerBound: 0)
+```
- ; Use of global variable as count value
- !12 = !DIGlobalVariable(name: "count", scope: !8, file: !6, line: 22, type: !9)
- !13 = !DISubrange(count: !12, lowerBound: 0)
+(DISubrangeType)=
-.. _DISubrangeType:
+##### DISubrangeType
-DISubrangeType
-""""""""""""""
-
-``DISubrangeType`` is similar to ``DISubrange``, but it is also a
-``DIType``. It may be used as the type of an object, but could also
+`DISubrangeType` is similar to `DISubrange`, but it is also a
+`DIType`. It may be used as the type of an object, but could also
be used as an array index.
-Like ``DISubrange``, it can hold a lower bound and count, or a lower
-bound and upper bound. A ``DISubrangeType`` refers to the underlying
+Like `DISubrange`, it can hold a lower bound and count, or a lower
+bound and upper bound. A `DISubrangeType` refers to the underlying
type of which it is a subrange; this type can be an integer type or an
enumeration type.
-A ``DISubrangeType`` may also have a stride -- unlike ``DISubrange``,
+A `DISubrangeType` may also have a stride -- unlike `DISubrange`,
this stride is a bit stride. The stride is only useful when a
-``DISubrangeType`` is used as an array index type.
+`DISubrangeType` is used as an array index type.
-Finally, ``DISubrangeType`` may have a bias. In Ada, a program can
+Finally, `DISubrangeType` may have a bias. In Ada, a program can
request that a subrange value be stored in the minimum number of bits
required. In this situation, the stored value is biased by the lower
-bound -- e.g., a range ``-7 .. 0`` may take 3 bits in memory, and the
+bound -- e.g., a range `-7 .. 0` may take 3 bits in memory, and the
value -5 would be stored as 2 (a bias of -7).
-.. code-block:: text
-
- ; Scopes used in rest of example
- !0 = !DIFile(filename: "vla.c", directory: "/path/to/file")
- !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !0)
- !2 = distinct !DISubprogram(name: "foo", scope: !1, file: !0, line: 5)
+```text
+; Scopes used in rest of example
+!0 = !DIFile(filename: "vla.c", directory: "/path/to/file")
+!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !0)
+!2 = distinct !DISubprogram(name: "foo", scope: !1, file: !0, line: 5)
- ; Base type used in example.
- !3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+; Base type used in example.
+!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
- ; A simple subrange with a name.
- !4 = !DISubrange(name: "subrange", file: !0, line: 17, size: 32,
- align: 32, baseType: !3, lowerBound: 18, count: 12)
- ; A subrange with a bias.
- !5 = !DISubrange(name: "biased", lowerBound: -7, upperBound: 0,
- bias: -7, size: 3)
- ; A subrange with a bit stride.
- !6 = !DISubrange(name: "biased", lowerBound: 0, upperBound: 7,
- stride: 3)
+; A simple subrange with a name.
+!4 = !DISubrange(name: "subrange", file: !0, line: 17, size: 32,
+ align: 32, baseType: !3, lowerBound: 18, count: 12)
+; A subrange with a bias.
+!5 = !DISubrange(name: "biased", lowerBound: -7, upperBound: 0,
+ bias: -7, size: 3)
+; A subrange with a bit stride.
+!6 = !DISubrange(name: "biased", lowerBound: 0, upperBound: 7,
+ stride: 3)
+```
-.. _DIEnumerator:
+(DIEnumerator)=
-DIEnumerator
-""""""""""""
+##### DIEnumerator
-``DIEnumerator`` nodes are the elements for ``DW_TAG_enumeration_type``
-variants of :ref:`DICompositeType`.
+`DIEnumerator` nodes are the elements for `DW_TAG_enumeration_type`
+variants of {ref}`DICompositeType`.
-.. code-block:: text
+```text
+!0 = !DIEnumerator(name: "SixKind", value: 7)
+!1 = !DIEnumerator(name: "SevenKind", value: 7)
+!2 = !DIEnumerator(name: "NegEightKind", value: -8)
+```
- !0 = !DIEnumerator(name: "SixKind", value: 7)
- !1 = !DIEnumerator(name: "SevenKind", value: 7)
- !2 = !DIEnumerator(name: "NegEightKind", value: -8)
+##### DITemplateTypeParameter
-DITemplateTypeParameter
-"""""""""""""""""""""""
+`DITemplateTypeParameter` nodes represent type parameters to generic source
+language constructs. They are used (optionally) in {ref}`DICompositeType` and
+{ref}`DISubprogram` `templateParams:` fields.
-``DITemplateTypeParameter`` nodes represent type parameters to generic source
-language constructs. They are used (optionally) in :ref:`DICompositeType` and
-:ref:`DISubprogram` ``templateParams:`` fields.
+```text
+!0 = !DITemplateTypeParameter(name: "Ty", type: !1)
+```
-.. code-block:: text
+##### DITemplateValueParameter
- !0 = !DITemplateTypeParameter(name: "Ty", type: !1)
+`DITemplateValueParameter` nodes represent value parameters to generic source
+language constructs. `tag:` defaults to `DW_TAG_template_value_parameter`,
+but if specified can also be set to `DW_TAG_GNU_template_template_param` or
+`DW_TAG_GNU_template_param_pack`. They are used (optionally) in
+{ref}`DICompositeType` and {ref}`DISubprogram` `templateParams:` fields.
-DITemplateValueParameter
-""""""""""""""""""""""""
+```text
+!0 = !DITemplateValueParameter(name: "Ty", type: !1, value: i32 7)
+```
-``DITemplateValueParameter`` nodes represent value parameters to generic source
-language constructs. ``tag:`` defaults to ``DW_TAG_template_value_parameter``,
-but if specified can also be set to ``DW_TAG_GNU_template_template_param`` or
-``DW_TAG_GNU_template_param_pack``. They are used (optionally) in
-:ref:`DICompositeType` and :ref:`DISubprogram` ``templateParams:`` fields.
+##### DINamespace
-.. code-block:: text
+`DINamespace` nodes represent namespaces in the source language.
- !0 = !DITemplateValueParameter(name: "Ty", type: !1, value: i32 7)
+```text
+!0 = !DINamespace(name: "myawesomeproject", scope: !1, file: !2, line: 7)
+```
-DINamespace
-"""""""""""
+(DIGlobalVariable)=
-``DINamespace`` nodes represent namespaces in the source language.
+##### DIGlobalVariable
-.. code-block:: text
+`DIGlobalVariable` nodes represent global variables in the source language.
- !0 = !DINamespace(name: "myawesomeproject", scope: !1, file: !2, line: 7)
+```text
+ at foo = global i32, !dbg !0
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !2,
+ file: !3, line: 7, type: !4, isLocal: true,
+ isDefinition: false, declaration: !5)
+```
-.. _DIGlobalVariable:
+##### DIGlobalVariableExpression
-DIGlobalVariable
-""""""""""""""""
+`DIGlobalVariableExpression` nodes tie a {ref}`DIGlobalVariable` together
+with a {ref}`DIExpression`.
-``DIGlobalVariable`` nodes represent global variables in the source language.
-
-.. code-block:: text
-
- @foo = global i32, !dbg !0
- !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
- !1 = !DIGlobalVariable(name: "foo", linkageName: "foo", scope: !2,
- file: !3, line: 7, type: !4, isLocal: true,
- isDefinition: false, declaration: !5)
-
-
-DIGlobalVariableExpression
-""""""""""""""""""""""""""
-
-``DIGlobalVariableExpression`` nodes tie a :ref:`DIGlobalVariable` together
-with a :ref:`DIExpression`.
-
-.. code-block:: text
-
- @lower = global i32, !dbg !0
- @upper = global i32, !dbg !1
- !0 = !DIGlobalVariableExpression(
- var: !2,
- expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32)
- )
- !1 = !DIGlobalVariableExpression(
- var: !2,
- expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32)
- )
- !2 = !DIGlobalVariable(name: "split64", linkageName: "split64", scope: !3,
- file: !4, line: 8, type: !5, declaration: !6)
+```text
+ at lower = global i32, !dbg !0
+ at upper = global i32, !dbg !1
+!0 = !DIGlobalVariableExpression(
+ var: !2,
+ expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32)
+ )
+!1 = !DIGlobalVariableExpression(
+ var: !2,
+ expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32)
+ )
+!2 = !DIGlobalVariable(name: "split64", linkageName: "split64", scope: !3,
+ file: !4, line: 8, type: !5, declaration: !6)
+```
All global variable expressions should be referenced by the `globals:` field of
-a :ref:`compile unit <DICompileUnit>`.
+a {ref}`compile unit <DICompileUnit>`.
-.. _DISubprogram:
+(DISubprogram)=
-DISubprogram
-""""""""""""
+##### DISubprogram
-``DISubprogram`` nodes represent functions from the source language. A distinct
-``DISubprogram`` may be attached to a function definition using ``!dbg``
-metadata. A unique ``DISubprogram`` may be attached to a function declaration
-used for call site debug info. The ``retainedNodes:`` field is a list of
-:ref:`variables <DILocalVariable>` and :ref:`labels <DILabel>` that must be
+`DISubprogram` nodes represent functions from the source language. A distinct
+`DISubprogram` may be attached to a function definition using `!dbg`
+metadata. A unique `DISubprogram` may be attached to a function declaration
+used for call site debug info. The `retainedNodes:` field is a list of
+{ref}`variables <DILocalVariable>` and {ref}`labels <DILabel>` that must be
retained, even if their IR counterparts are optimized out of the IR. The
-``type:`` field must point at an :ref:`DISubroutineType`.
+`type:` field must point at an {ref}`DISubroutineType`.
-.. _DISubprogramDeclaration:
+(DISubprogramDeclaration)=
-When ``spFlags: DISPFlagDefinition`` is not present, subprograms describe a
+When `spFlags: DISPFlagDefinition` is not present, subprograms describe a
declaration in the type tree as opposed to a definition of a function. In this
-case, the ``declaration`` field must be empty. If the scope is a composite type
-with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``, then
-the subprogram declaration is uniqued based only on its ``linkageName:`` and
-``scope:``.
-
-.. code-block:: text
+case, the `declaration` field must be empty. If the scope is a composite type
+with an ODR `identifier:` and that does not set `flags: DIFwdDecl`, then
+the subprogram declaration is uniqued based only on its `linkageName:` and
+`scope:`.
- define void @_Z3foov() !dbg !0 {
- ...
- }
+```text
+define void @_Z3foov() !dbg !0 {
+ ...
+}
- !0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
- file: !2, line: 7, type: !3,
- spFlags: DISPFlagDefinition | DISPFlagLocalToUnit,
- scopeLine: 8, containingType: !4,
- virtuality: DW_VIRTUALITY_pure_virtual,
- virtualIndex: 10, flags: DIFlagPrototyped,
- isOptimized: true, unit: !5, templateParams: !6,
- declaration: !7, retainedNodes: !8,
- thrownTypes: !9)
+!0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
+ file: !2, line: 7, type: !3,
+ spFlags: DISPFlagDefinition | DISPFlagLocalToUnit,
+ scopeLine: 8, containingType: !4,
+ virtuality: DW_VIRTUALITY_pure_virtual,
+ virtualIndex: 10, flags: DIFlagPrototyped,
+ isOptimized: true, unit: !5, templateParams: !6,
+ declaration: !7, retainedNodes: !8,
+ thrownTypes: !9)
+```
-.. _DILexicalBlock:
+(DILexicalBlock)=
-DILexicalBlock
-""""""""""""""
+##### DILexicalBlock
-``DILexicalBlock`` nodes describe nested blocks within a :ref:`subprogram
+`DILexicalBlock` nodes describe nested blocks within a {ref}`subprogram
<DISubprogram>`. The line number and column numbers are used to distinguish
-two lexical blocks at same depth. They are valid targets for ``scope:``
+two lexical blocks at same depth. They are valid targets for `scope:`
fields.
-.. code-block:: text
-
- !0 = distinct !DILexicalBlock(scope: !1, file: !2, line: 7, column: 35)
+```text
+!0 = distinct !DILexicalBlock(scope: !1, file: !2, line: 7, column: 35)
+```
-Usually lexical blocks are ``distinct`` to prevent node merging based on
+Usually lexical blocks are `distinct` to prevent node merging based on
operands.
-.. _DILexicalBlockFile:
+(DILexicalBlockFile)=
-DILexicalBlockFile
-""""""""""""""""""
+##### DILexicalBlockFile
-``DILexicalBlockFile`` nodes are used to discriminate between sections of a
-:ref:`lexical block <DILexicalBlock>`. The ``file:`` field can be changed to
-indicate textual inclusion, or the ``discriminator:`` field can be used to
+`DILexicalBlockFile` nodes are used to discriminate between sections of a
+{ref}`lexical block <DILexicalBlock>`. The `file:` field can be changed to
+indicate textual inclusion, or the `discriminator:` field can be used to
discriminate between control flow within a single block in the source language.
-.. code-block:: text
-
- !0 = !DILexicalBlock(scope: !3, file: !4, line: 7, column: 35)
- !1 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 0)
- !2 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 1)
-
-.. _DILocation:
+```text
+!0 = !DILexicalBlock(scope: !3, file: !4, line: 7, column: 35)
+!1 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 0)
+!2 = !DILexicalBlockFile(scope: !0, file: !4, discriminator: 1)
+```
-DILocation
-""""""""""
+(DILocation)=
-``DILocation`` nodes represent source debug locations. The ``scope:`` field is
-mandatory, and points at an :ref:`DILexicalBlockFile`, an
-:ref:`DILexicalBlock`, or an :ref:`DISubprogram`.
+##### DILocation
-.. code-block:: text
+`DILocation` nodes represent source debug locations. The `scope:` field is
+mandatory, and points at an {ref}`DILexicalBlockFile`, an
+{ref}`DILexicalBlock`, or an {ref}`DISubprogram`.
- !0 = !DILocation(line: 2900, column: 42, scope: !1, inlinedAt: !2)
+```text
+!0 = !DILocation(line: 2900, column: 42, scope: !1, inlinedAt: !2)
+```
-.. _DILocalVariable:
+(DILocalVariable)=
-DILocalVariable
-"""""""""""""""
+##### DILocalVariable
-``DILocalVariable`` nodes represent local variables in the source language. If
-the ``arg:`` field is set to non-zero, then this variable is a subprogram
-parameter, and it will be included in the ``retainedNodes:`` field of its
-:ref:`DISubprogram`.
+`DILocalVariable` nodes represent local variables in the source language. If
+the `arg:` field is set to non-zero, then this variable is a subprogram
+parameter, and it will be included in the `retainedNodes:` field of its
+{ref}`DISubprogram`.
-.. code-block:: text
+```text
+!0 = !DILocalVariable(name: "this", arg: 1, scope: !3, file: !2, line: 7,
+ type: !3, flags: DIFlagArtificial)
+!1 = !DILocalVariable(name: "x", arg: 2, scope: !4, file: !2, line: 7,
+ type: !3)
+!2 = !DILocalVariable(name: "y", scope: !5, file: !2, line: 7, type: !3)
+```
- !0 = !DILocalVariable(name: "this", arg: 1, scope: !3, file: !2, line: 7,
- type: !3, flags: DIFlagArtificial)
- !1 = !DILocalVariable(name: "x", arg: 2, scope: !4, file: !2, line: 7,
- type: !3)
- !2 = !DILocalVariable(name: "y", scope: !5, file: !2, line: 7, type: !3)
+##### DIExpression
-DIExpression
-""""""""""""
-
-``DIExpression`` nodes represent expressions that are inspired by the DWARF
-expression language. They are used in :ref:`debug records <debug_records>`
-(such as ``#dbg_declare`` and ``#dbg_value``) to describe how the referenced
+`DIExpression` nodes represent expressions that are inspired by the DWARF
+expression language. They are used in {ref}`debug records <debug_records>`
+(such as `#dbg_declare` and `#dbg_value`) to describe how the referenced
LLVM variable relates to the source language variable.
-See :ref:`diexpression` for details.
-
-.. note::
+See {ref}`diexpression` for details.
- ``DIExpression``\s are always printed and parsed inline; they can never be
- referenced by an ID (e.g., ``!1``).
+```{note}
+`DIExpression`s are always printed and parsed inline; they can never be
+referenced by an ID (e.g., `!1`).
+```
Some examples of expressions:
-.. code-block:: text
-
- !DIExpression(DW_OP_deref)
- !DIExpression(DW_OP_plus_uconst, 3)
- !DIExpression(DW_OP_constu, 3, DW_OP_plus)
- !DIExpression(DW_OP_bit_piece, 3, 7)
- !DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_fragment, 3, 7)
- !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)
- !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
-
-DIAssignID
-""""""""""
+```text
+!DIExpression(DW_OP_deref)
+!DIExpression(DW_OP_plus_uconst, 3)
+!DIExpression(DW_OP_constu, 3, DW_OP_plus)
+!DIExpression(DW_OP_bit_piece, 3, 7)
+!DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_fragment, 3, 7)
+!DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)
+!DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
+```
-``DIAssignID`` nodes have no operands and are always distinct. They are used to
-link together (:ref:`#dbg_assign records <debugrecords>`) and instructions
-that store in IR. See `Debug Info Assignment Tracking
-<AssignmentTracking.html>`_ for more info.
+##### DIAssignID
-.. code-block:: llvm
+`DIAssignID` nodes have no operands and are always distinct. They are used to
+link together ({ref}`#dbg_assign records <debugrecords>`) and instructions
+that store in IR. See {doc}`Debug Info Assignment Tracking <AssignmentTracking>` for more info.
- store i32 %a, ptr %a.addr, align 4, !DIAssignID !2
- #dbg_assign(%a, !1, !DIExpression(), !2, %a.addr, !DIExpression(), !3)
+```llvm
+store i32 %a, ptr %a.addr, align 4, !DIAssignID !2
+#dbg_assign(%a, !1, !DIExpression(), !2, %a.addr, !DIExpression(), !3)
- !2 = distinct !DIAssignID()
+!2 = distinct !DIAssignID()
+```
-DIArgList
-"""""""""
+##### DIArgList
-.. FIXME In the implementation this is not a "node", but as it can only appear
- inline in a function context that distinction isn't observable anyway. Even
- if it is not required, it would be nice to be more clear about what is a
- "node", and what that actually means. The names in the implementation could
- also be updated to mirror whatever we decide here.
-
-``DIArgList`` nodes hold a list of constant or SSA value references. These are
-used in :ref:`debug records <debugrecords>` in combination with a
-``DIExpression`` that uses the
-``DW_OP_LLVM_arg`` operator. Because a ``DIArgList`` may refer to local values
+% FIXME In the implementation this is not a "node", but as it can only appear inline in a function context that distinction isn't observable anyway. Even if it is not required, it would be nice to be more clear about what is a "node", and what that actually means. The names in the implementation could also be updated to mirror whatever we decide here.
+`DIArgList` nodes hold a list of constant or SSA value references. These are
+used in {ref}`debug records <debugrecords>` in combination with a
+`DIExpression` that uses the
+`DW_OP_LLVM_arg` operator. Because a `DIArgList` may refer to local values
within a function, it must only be used as a function argument, must always be
inlined, and cannot appear in named metadata.
-.. code-block:: text
-
- #dbg_value(!DIArgList(i32 %a, i32 %b),
- !16,
- !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
- !26)
+```text
+#dbg_value(!DIArgList(i32 %a, i32 %b),
+ !16,
+ !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
+ !26)
+```
-DIFlags
-"""""""
+##### DIFlags
These flags encode various properties of DINodes.
The `ExportSymbols` flag marks a class, struct or union whose members
may be referenced as if they were defined in the containing class or
-union. This flag is used to decide whether the ``DW_AT_export_symbols`` can
+union. This flag is used to decide whether the `DW_AT_export_symbols` can
be used for the structure type.
-DIObjCProperty
-""""""""""""""
+##### DIObjCProperty
-``DIObjCProperty`` nodes represent Objective-C property nodes.
+`DIObjCProperty` nodes represent Objective-C property nodes.
-.. code-block:: text
+```text
+!3 = !DIObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
+ getter: "getFoo", attributes: 7, type: !2)
+```
- !3 = !DIObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
- getter: "getFoo", attributes: 7, type: !2)
+##### DIImportedEntity
-DIImportedEntity
-""""""""""""""""
-
-``DIImportedEntity`` nodes represent entities (such as modules) imported into a
-compile unit. The ``elements`` field is a list of renamed entities (such as
+`DIImportedEntity` nodes represent entities (such as modules) imported into a
+compile unit. The `elements` field is a list of renamed entities (such as
variables and subprograms) in the imported entity (such as module).
-.. code-block:: text
-
- !2 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
- entity: !1, line: 7, elements: !3)
- !3 = !{!4}
- !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "bar", scope: !0,
- entity: !5, line: 7)
+```text
+!2 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
+ entity: !1, line: 7, elements: !3)
+!3 = !{!4}
+!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "bar", scope: !0,
+ entity: !5, line: 7)
+```
-DIMacro
-"""""""
+##### DIMacro
-``DIMacro`` nodes represent definition or undefinition of a macro identifiers.
-The ``name:`` field is the macro identifier, followed by macro parameters when
-defining a function-like macro, and the ``value`` field is the token-string
+`DIMacro` nodes represent definition or undefinition of a macro identifiers.
+The `name:` field is the macro identifier, followed by macro parameters when
+defining a function-like macro, and the `value` field is the token-string
used to expand the macro identifier.
-.. code-block:: text
+```text
+!2 = !DIMacro(macinfo: DW_MACINFO_define, line: 7, name: "foo(x)",
+ value: "((x) + 1)")
+!3 = !DIMacro(macinfo: DW_MACINFO_undef, line: 30, name: "foo")
+```
- !2 = !DIMacro(macinfo: DW_MACINFO_define, line: 7, name: "foo(x)",
- value: "((x) + 1)")
- !3 = !DIMacro(macinfo: DW_MACINFO_undef, line: 30, name: "foo")
+##### DIMacroFile
-DIMacroFile
-"""""""""""
-
-``DIMacroFile`` nodes represent inclusion of source files.
-The ``nodes:`` field is a list of ``DIMacro`` and ``DIMacroFile`` nodes that
+`DIMacroFile` nodes represent inclusion of source files.
+The `nodes:` field is a list of `DIMacro` and `DIMacroFile` nodes that
appear in the included source file.
-.. code-block:: text
-
- !2 = !DIMacroFile(macinfo: DW_MACINFO_start_file, line: 7, file: !2,
- nodes: !3)
+```text
+!2 = !DIMacroFile(macinfo: DW_MACINFO_start_file, line: 7, file: !2,
+ nodes: !3)
+```
-.. _DILabel:
+(DILabel)=
-DILabel
-"""""""
+##### DILabel
-``DILabel`` nodes represent labels within a :ref:`DISubprogram`. The ``scope:``
-field must be one of either a :ref:`DILexicalBlockFile`, a
-:ref:`DILexicalBlock`, or a :ref:`DISubprogram`. The ``name:`` field is the
-label identifier. The ``file:`` field is the :ref:`DIFile` the label is
-present in. The ``line:`` and ``column:`` field are the source line and column
+`DILabel` nodes represent labels within a {ref}`DISubprogram`. The `scope:`
+field must be one of either a {ref}`DILexicalBlockFile`, a
+{ref}`DILexicalBlock`, or a {ref}`DISubprogram`. The `name:` field is the
+label identifier. The `file:` field is the {ref}`DIFile` the label is
+present in. The `line:` and `column:` field are the source line and column
within the file where the label is declared.
Furthermore, a label can be marked as artificial, i.e., compiler-generated,
-using ``isArtificial:``. Such artificial labels are generated, e.g., by
-the ``CoroSplit`` pass. In addition, the ``CoroSplit`` pass also uses the
-``coroSuspendIdx:`` field to identify the coroutine suspend points.
+using `isArtificial:`. Such artificial labels are generated, e.g., by
+the `CoroSplit` pass. In addition, the `CoroSplit` pass also uses the
+`coroSuspendIdx:` field to identify the coroutine suspend points.
-``scope:``, ``name:``, ``file:`` and ``line:`` are mandatory. The remaining
+`scope:`, `name:`, `file:` and `line:` are mandatory. The remaining
fields are optional.
-.. code-block:: text
+```text
+!2 = !DILabel(scope: !0, name: "foo", file: !1, line: 7, column: 4)
+!3 = !DILabel(scope: !0, name: "__coro_resume_3", file: !1, line: 9, column: 3, isArtificial: true, coroSuspendIdx: 3)
+```
- !2 = !DILabel(scope: !0, name: "foo", file: !1, line: 7, column: 4)
- !3 = !DILabel(scope: !0, name: "__coro_resume_3", file: !1, line: 9, column: 3, isArtificial: true, coroSuspendIdx: 3)
+##### DICommonBlock
-DICommonBlock
-"""""""""""""
+`DICommonBlock` nodes represent Fortran common blocks. The `scope:` field
+is mandatory and points to a {ref}`DILexicalBlockFile`, a
+{ref}`DILexicalBlock`, or a {ref}`DISubprogram`. The `declaration:`,
+`name:`, `file:`, and `line:` fields are optional.
-``DICommonBlock`` nodes represent Fortran common blocks. The ``scope:`` field
-is mandatory and points to a :ref:`DILexicalBlockFile`, a
-:ref:`DILexicalBlock`, or a :ref:`DISubprogram`. The ``declaration:``,
-``name:``, ``file:``, and ``line:`` fields are optional.
+##### DIModule
-DIModule
-""""""""
+`DIModule` nodes represent a source language module, for example, a Clang
+module, or a Fortran module. The `scope:` field is mandatory and points to a
+{ref}`DILexicalBlockFile`, a {ref}`DILexicalBlock`, or a {ref}`DISubprogram`.
+The `name:` field is mandatory. The `configMacros:`, `includePath:`,
+`apinotes:`, `file:`, `line:`, and `isDecl:` fields are optional.
-``DIModule`` nodes represent a source language module, for example, a Clang
-module, or a Fortran module. The ``scope:`` field is mandatory and points to a
-:ref:`DILexicalBlockFile`, a :ref:`DILexicalBlock`, or a :ref:`DISubprogram`.
-The ``name:`` field is mandatory. The ``configMacros:``, ``includePath:``,
-``apinotes:``, ``file:``, ``line:``, and ``isDecl:`` fields are optional.
+##### DIStringType
-DIStringType
-""""""""""""
-
-``DIStringType`` nodes represent a Fortran ``CHARACTER(n)`` type, with a
+`DIStringType` nodes represent a Fortran `CHARACTER(n)` type, with a
dynamic length and location encoded as an expression.
-The ``tag:`` field is optional and defaults to ``DW_TAG_string_type``. The ``name:``,
-``stringLength:``, ``stringLengthExpression``, ``stringLocationExpression:``,
-``size:``, ``align:``, and ``encoding:`` fields are optional.
+The `tag:` field is optional and defaults to `DW_TAG_string_type`. The `name:`,
+`stringLength:`, `stringLengthExpression`, `stringLocationExpression:`,
+`size:`, `align:`, and `encoding:` fields are optional.
-If not present, the ``size:`` and ``align:`` fields default to the value zero.
+If not present, the `size:` and `align:` fields default to the value zero.
The length in bits of the string is specified by the first of the following
fields present:
-- ``stringLength:``, which points to a ``DIVariable`` whose value is the string
+- `stringLength:`, which points to a `DIVariable` whose value is the string
length in bits.
-- ``stringLengthExpression:``, which points to a ``DIExpression`` which
+- `stringLengthExpression:`, which points to a `DIExpression` which
computes the length in bits.
-- ``size``, which contains the literal length in bits.
+- `size`, which contains the literal length in bits.
-The ``stringLocationExpression:`` points to a ``DIExpression`` which describes
+The `stringLocationExpression:` points to a `DIExpression` which describes
the "data location" of the string object, if present.
-'``tbaa``' Metadata
-^^^^^^^^^^^^^^^^^^^
+#### '`tbaa`' Metadata
In LLVM IR, memory does not have types, so LLVM's own type system is not
suitable for doing type based alias analysis (TBAA). Instead, metadata is
@@ -7331,23 +7338,22 @@ can be used to implement C/C++ strict type aliasing rules, but it can also
be used to implement custom alias analysis behavior for other languages.
This description of LLVM's TBAA system is broken into two parts:
-:ref:`Semantics<tbaa_node_semantics>` talks about high level issues, and
-:ref:`Representation<tbaa_node_representation>` talks about the metadata
+{ref}`Semantics<tbaa_node_semantics>` talks about high level issues, and
+{ref}`Representation<tbaa_node_representation>` talks about the metadata
encoding of various entities.
It is always possible to trace any TBAA node to a "root" TBAA node (details
-in the :ref:`Representation<tbaa_node_representation>` section). TBAA
+in the {ref}`Representation<tbaa_node_representation>` section). TBAA
nodes with different roots have an unknown aliasing relationship, and LLVM
-conservatively infers ``MayAlias`` between them. The rules mentioned in
+conservatively infers `MayAlias` between them. The rules mentioned in
this section only pertain to TBAA nodes living under the same root.
-.. _tbaa_node_semantics:
+(tbaa_node_semantics)=
-Semantics
-"""""""""
+##### Semantics
The TBAA metadata system, referred to as "struct path TBAA" (not to be
-confused with ``tbaa.struct``), consists of the following high level
+confused with `tbaa.struct`), consists of the following high level
concepts: *Type Descriptors*, further subdivided into scalar type
descriptors and struct type descriptors; and *Access Tags*.
@@ -7367,139 +7373,136 @@ tuples consisting of a base type, an access type and an offset. The base
type is a scalar type descriptor or a struct type descriptor, the access
type is a scalar type descriptor, and the offset is a constant integer.
-The access tag ``(BaseTy, AccessTy, Offset)`` can describe one of two
+The access tag `(BaseTy, AccessTy, Offset)` can describe one of two
things:
- * If ``BaseTy`` is a struct type, the tag describes a memory access (load
- or store) of a value of type ``AccessTy`` contained in the struct type
- ``BaseTy`` at offset ``Offset``.
+ * If `BaseTy` is a struct type, the tag describes a memory access (load
+ or store) of a value of type `AccessTy` contained in the struct type
+ `BaseTy` at offset `Offset`.
- * If ``BaseTy`` is a scalar type, ``Offset`` must be 0 and ``BaseTy`` and
- ``AccessTy`` must be the same; and the access tag describes a scalar
- access with scalar type ``AccessTy``.
+ * If `BaseTy` is a scalar type, `Offset` must be 0 and `BaseTy` and
+ `AccessTy` must be the same; and the access tag describes a scalar
+ access with scalar type `AccessTy`.
-We first define an ``ImmediateParent`` relation on ``(BaseTy, Offset)``
+We first define an `ImmediateParent` relation on `(BaseTy, Offset)`
tuples this way:
- * If ``BaseTy`` is a scalar type then ``ImmediateParent(BaseTy, 0)`` is
- ``(ParentTy, 0)`` where ``ParentTy`` is the parent of the scalar type as
- described in the TBAA metadata. ``ImmediateParent(BaseTy, Offset)`` is
- undefined if ``Offset`` is non-zero.
+ * If `BaseTy` is a scalar type then `ImmediateParent(BaseTy, 0)` is
+ `(ParentTy, 0)` where `ParentTy` is the parent of the scalar type as
+ described in the TBAA metadata. `ImmediateParent(BaseTy, Offset)` is
+ undefined if `Offset` is non-zero.
- * If ``BaseTy`` is a struct type then ``ImmediateParent(BaseTy, Offset)``
- is ``(NewTy, NewOffset)`` where ``NewTy`` is the type contained in
- ``BaseTy`` at offset ``Offset`` and ``NewOffset`` is ``Offset`` adjusted
+ * If `BaseTy` is a struct type then `ImmediateParent(BaseTy, Offset)`
+ is `(NewTy, NewOffset)` where `NewTy` is the type contained in
+ `BaseTy` at offset `Offset` and `NewOffset` is `Offset` adjusted
to be relative within that inner type.
-A memory access with an access tag ``(BaseTy1, AccessTy1, Offset1)``
-aliases a memory access with an access tag ``(BaseTy2, AccessTy2,
-Offset2)`` if either ``(BaseTy1, Offset1)`` is reachable from ``(Base2,
-Offset2)`` via the ``Parent`` relation or vice versa. If memory accesses
-alias even though they are noalias according to ``!tbaa`` metadata, the
+A memory access with an access tag `(BaseTy1, AccessTy1, Offset1)`
+aliases a memory access with an access tag `(BaseTy2, AccessTy2,
+Offset2)` if either `(BaseTy1, Offset1)` is reachable from `(Base2,
+Offset2)` via the `Parent` relation or vice versa. If memory accesses
+alias even though they are noalias according to `!tbaa` metadata, the
behavior is undefined.
As a concrete example, the type descriptor graph for the following program
-.. code-block:: c
-
- struct Inner {
- int i; // offset 0
- float f; // offset 4
- };
-
- struct Outer {
- float f; // offset 0
- double d; // offset 4
- struct Inner inner_a; // offset 12
- };
-
- void f(struct Outer* outer, struct Inner* inner, float* f, int* i, char* c) {
- outer->f = 0; // tag0: (OuterStructTy, FloatScalarTy, 0)
- outer->inner_a.i = 0; // tag1: (OuterStructTy, IntScalarTy, 12)
- outer->inner_a.f = 0.0; // tag2: (OuterStructTy, FloatScalarTy, 16)
- *f = 0.0; // tag3: (FloatScalarTy, FloatScalarTy, 0)
- }
-
-is (note that in C and C++, ``char`` can be used to access any arbitrary
+```c
+struct Inner {
+ int i; // offset 0
+ float f; // offset 4
+};
+
+struct Outer {
+ float f; // offset 0
+ double d; // offset 4
+ struct Inner inner_a; // offset 12
+};
+
+void f(struct Outer* outer, struct Inner* inner, float* f, int* i, char* c) {
+ outer->f = 0; // tag0: (OuterStructTy, FloatScalarTy, 0)
+ outer->inner_a.i = 0; // tag1: (OuterStructTy, IntScalarTy, 12)
+ outer->inner_a.f = 0.0; // tag2: (OuterStructTy, FloatScalarTy, 16)
+ *f = 0.0; // tag3: (FloatScalarTy, FloatScalarTy, 0)
+}
+```
+
+is (note that in C and C++, `char` can be used to access any arbitrary
type):
-.. code-block:: text
-
- Root = "TBAA Root"
- CharScalarTy = ("char", Root, 0)
- FloatScalarTy = ("float", CharScalarTy, 0)
- DoubleScalarTy = ("double", CharScalarTy, 0)
- IntScalarTy = ("int", CharScalarTy, 0)
- InnerStructTy = {"Inner" (IntScalarTy, 0), (FloatScalarTy, 4)}
- OuterStructTy = {"Outer", (FloatScalarTy, 0), (DoubleScalarTy, 4),
- (InnerStructTy, 12)}
+```text
+Root = "TBAA Root"
+CharScalarTy = ("char", Root, 0)
+FloatScalarTy = ("float", CharScalarTy, 0)
+DoubleScalarTy = ("double", CharScalarTy, 0)
+IntScalarTy = ("int", CharScalarTy, 0)
+InnerStructTy = {"Inner" (IntScalarTy, 0), (FloatScalarTy, 4)}
+OuterStructTy = {"Outer", (FloatScalarTy, 0), (DoubleScalarTy, 4),
+ (InnerStructTy, 12)}
+```
+with (e.g.) `ImmediateParent(OuterStructTy, 12)` = `(InnerStructTy,
+0)`, `ImmediateParent(InnerStructTy, 0)` = `(IntScalarTy, 0)`, and
+`ImmediateParent(IntScalarTy, 0)` = `(CharScalarTy, 0)`.
-with (e.g.) ``ImmediateParent(OuterStructTy, 12)`` = ``(InnerStructTy,
-0)``, ``ImmediateParent(InnerStructTy, 0)`` = ``(IntScalarTy, 0)``, and
-``ImmediateParent(IntScalarTy, 0)`` = ``(CharScalarTy, 0)``.
+(tbaa_node_representation)=
-.. _tbaa_node_representation:
+##### Representation
-Representation
-""""""""""""""
+The root node of a TBAA type hierarchy is an `MDNode` with 0 operands or
+with exactly one `MDString` operand.
-The root node of a TBAA type hierarchy is an ``MDNode`` with 0 operands or
-with exactly one ``MDString`` operand.
-
-Scalar type descriptors are represented as an ``MDNode`` s with two
-operands. The first operand is an ``MDString`` denoting the name of the
+Scalar type descriptors are represented as an `MDNode` s with two
+operands. The first operand is an `MDString` denoting the name of the
struct type. LLVM does not assign meaning to the value of this operand, it
-only cares about it being an ``MDString``. The second operand is an
-``MDNode`` which points to the parent for said scalar type descriptor,
+only cares about it being an `MDString`. The second operand is an
+`MDNode` which points to the parent for said scalar type descriptor,
which is either another scalar type descriptor or the TBAA root. Scalar
type descriptors can have an optional third argument, but that must be the
constant integer zero.
-Struct type descriptors are represented as ``MDNode`` s with an odd number
-of operands greater than 1. The first operand is an ``MDString`` denoting
+Struct type descriptors are represented as `MDNode` s with an odd number
+of operands greater than 1. The first operand is an `MDString` denoting
the name of the struct type. Like in scalar type descriptors the actual
value of this name operand is irrelevant to LLVM. After the name operand,
-the struct type descriptors have a sequence of alternating ``MDNode`` and
-``ConstantInt`` operands. With N starting from 1, the 2N - 1 th operand,
-an ``MDNode``, denotes a contained field, and the 2N th operand, a
-``ConstantInt``, is the offset of the said contained field. The offsets
+the struct type descriptors have a sequence of alternating `MDNode` and
+`ConstantInt` operands. With N starting from 1, the 2N - 1 th operand,
+an `MDNode`, denotes a contained field, and the 2N th operand, a
+`ConstantInt`, is the offset of the said contained field. The offsets
must be in non-decreasing order.
-Access tags are represented as ``MDNode`` s with either 3 or 4 operands.
-The first operand is an ``MDNode`` pointing to the node representing the
-base type. The second operand is an ``MDNode`` pointing to the node
-representing the access type. The third operand is a ``ConstantInt`` that
+Access tags are represented as `MDNode` s with either 3 or 4 operands.
+The first operand is an `MDNode` pointing to the node representing the
+base type. The second operand is an `MDNode` pointing to the node
+representing the access type. The third operand is a `ConstantInt` that
states the offset of the access. If a fourth field is present, it must be
-a ``ConstantInt`` valued at 0 or 1. If it is 1 then the access tag states
+a `ConstantInt` valued at 0 or 1. If it is 1 then the access tag states
that the location being accessed is "constant" (meaning
-``pointsToConstantMemory`` should return true; see `other useful
-AliasAnalysis methods <AliasAnalysis.html#OtherItfs>`_). The TBAA root of
+`pointsToConstantMemory` should return true; see [other useful
+AliasAnalysis methods](AliasAnalysis.md#other-useful-aliasanalysis-methods)). The TBAA root of
the access type and the base type of an access tag must be the same, and
that is the TBAA root of the access tag.
-'``tbaa.struct``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`tbaa.struct`' Metadata
-The :ref:`llvm.memcpy <int_memcpy>` is often used to implement
+The {ref}`llvm.memcpy <int_memcpy>` is often used to implement
aggregate assignment operations in C and similar languages, however it
is defined to copy a contiguous region of memory, which is more than
strictly necessary for aggregate types which contain holes due to
padding. Also, it doesn't contain any TBAA information about the fields
of the aggregate.
-``!tbaa.struct`` metadata can describe which memory subregions in a
+`!tbaa.struct` metadata can describe which memory subregions in a
memcpy are padding and what the TBAA tags of the struct are.
-The current metadata format is very simple. ``!tbaa.struct`` metadata
+The current metadata format is very simple. `!tbaa.struct` metadata
nodes are a list of operands which are in conceptual groups of three.
For each group of three, the first operand gives the byte offset of a
field in bytes, the second gives its size in bytes, and the third gives
its tbaa tag. e.g.:
-.. code-block:: llvm
-
- !4 = !{ i64 0, i64 4, !1, i64 8, i64 4, !2 }
+```llvm
+!4 = !{ i64 0, i64 4, !1, i64 8, i64 4, !2 }
+```
This describes a struct with two fields. The first is at offset 0 bytes
with size 4 bytes, and has tbaa tag !1. The second is at offset 8 bytes
@@ -7509,15 +7512,14 @@ Note that the fields need not be contiguous. In this example, there is a
4 byte gap between the two fields. This gap represents padding which
does not carry useful data and need not be preserved.
-'``noalias``' and '``alias.scope``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`noalias`' and '`alias.scope`' Metadata
-``noalias`` and ``alias.scope`` metadata provide the ability to specify generic
+`noalias` and `alias.scope` metadata provide the ability to specify generic
noalias memory-access sets. This means that some collection of memory access
instructions (loads, stores, memory-accessing calls, etc.) that carry
-``noalias`` metadata can specifically be specified not to alias with some other
-collection of memory access instructions that carry ``alias.scope`` metadata.
-These metadata kinds may also be attached to ``fence`` instructions to indicate
+`noalias` metadata can specifically be specified not to alias with some other
+collection of memory access instructions that carry `alias.scope` metadata.
+These metadata kinds may also be attached to `fence` instructions to indicate
which scoped memory regions the fence does (or does not) concern; this allows
alias analysis to prove that a fence cannot affect a particular memory location.
If accesses from different collections alias, the behavior is undefined. Each
@@ -7525,9 +7527,9 @@ type of metadata specifies a list of scopes where each scope has an id and a
domain.
When evaluating an aliasing query, if for some domain, the set
-of scopes with that domain in one instruction's ``alias.scope`` list is a
+of scopes with that domain in one instruction's `alias.scope` list is a
subset of (or equal to) the set of scopes for that domain in another
-instruction's ``noalias`` list, then the two memory accesses are assumed not to
+instruction's `noalias` list, then the two memory accesses are assumed not to
alias.
Because scopes in one domain don't affect scopes in other domains, separate
@@ -7551,67 +7553,65 @@ optionally be provided as a third list entry.
For example,
-.. code-block:: llvm
+```llvm
+; Two scope domains:
+!0 = !{!0}
+!1 = !{!1}
- ; Two scope domains:
- !0 = !{!0}
- !1 = !{!1}
+; Some scopes in these domains:
+!2 = !{!2, !0}
+!3 = !{!3, !0}
+!4 = !{!4, !1}
- ; Some scopes in these domains:
- !2 = !{!2, !0}
- !3 = !{!3, !0}
- !4 = !{!4, !1}
+; Some scope lists:
+!5 = !{!4} ; A list containing only scope !4
+!6 = !{!4, !3, !2}
+!7 = !{!3}
- ; Some scope lists:
- !5 = !{!4} ; A list containing only scope !4
- !6 = !{!4, !3, !2}
- !7 = !{!3}
+; These two instructions don't alias:
+%0 = load float, ptr %c, align 4, !alias.scope !5
+store float %0, ptr %arrayidx.i, align 4, !noalias !5
- ; These two instructions don't alias:
- %0 = load float, ptr %c, align 4, !alias.scope !5
- store float %0, ptr %arrayidx.i, align 4, !noalias !5
+; These two instructions also don't alias (for domain !1, the set of scopes
+; in the !alias.scope equals that in the !noalias list):
+%2 = load float, ptr %c, align 4, !alias.scope !5
+store float %2, ptr %arrayidx.i2, align 4, !noalias !6
- ; These two instructions also don't alias (for domain !1, the set of scopes
- ; in the !alias.scope equals that in the !noalias list):
- %2 = load float, ptr %c, align 4, !alias.scope !5
- store float %2, ptr %arrayidx.i2, align 4, !noalias !6
+; These two instructions may alias (for domain !0, the set of scopes in
+; the !noalias list is not a superset of, or equal to, the scopes in the
+; !alias.scope list):
+%2 = load float, ptr %c, align 4, !alias.scope !6
+store float %0, ptr %arrayidx.i, align 4, !noalias !7
+```
- ; These two instructions may alias (for domain !0, the set of scopes in
- ; the !noalias list is not a superset of, or equal to, the scopes in the
- ; !alias.scope list):
- %2 = load float, ptr %c, align 4, !alias.scope !6
- store float %0, ptr %arrayidx.i, align 4, !noalias !7
+(fpmath-metadata)=
-.. _fpmath-metadata:
+#### '`fpmath`' Metadata
-'``fpmath``' Metadata
-^^^^^^^^^^^^^^^^^^^^^
-
-``fpmath`` metadata may be attached to any instruction of floating-point
+`fpmath` metadata may be attached to any instruction of floating-point
type. It can be used to express the maximum acceptable error in the
result of that instruction, in ULPs, thus potentially allowing the
compiler to use a more efficient but less accurate method of computing
it. ULP is defined as follows:
- If ``x`` is a real number that lies between two finite consecutive
- floating-point numbers ``a`` and ``b``, without being equal to one
- of them, then ``ulp(x) = |b - a|``, otherwise ``ulp(x)`` is the
- distance between the two non-equal finite floating-point numbers
- nearest ``x``. Moreover, ``ulp(NaN)`` is ``NaN``.
+> If `x` is a real number that lies between two finite consecutive
+> floating-point numbers `a` and `b`, without being equal to one
+> of them, then `ulp(x) = |b - a|`, otherwise `ulp(x)` is the
+> distance between the two non-equal finite floating-point numbers
+> nearest `x`. Moreover, `ulp(NaN)` is `NaN`.
The metadata node shall consist of a single positive float type number
representing the maximum relative error, for example:
-.. code-block:: llvm
-
- !0 = !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
+```llvm
+!0 = !{ float 2.5 } ; maximum acceptable inaccuracy is 2.5 ULPs
+```
-.. _range-metadata:
+(range-metadata)=
-'``range``' Metadata
-^^^^^^^^^^^^^^^^^^^^
+#### '`range`' Metadata
-``range`` metadata may be attached only to ``load``, ``call`` and ``invoke`` of
+`range` metadata may be attached only to `load`, `call` and `invoke` of
integer or vector of integer types. It expresses the possible ranges the loaded
value or the value returned by the called function at this call site is in. If
the loaded or returned value is not in the specified range, a poison value is
@@ -7620,11 +7620,11 @@ The loaded value or the value returned is known to be in the union of the ranges
defined by each consecutive pair. Each pair has the following properties:
- The type must match the scalar type of the instruction.
-- The pair ``a,b`` represents the range ``[a,b)``.
-- Both ``a`` and ``b`` are constants.
+- The pair `a,b` represents the range `[a,b)`.
+- Both `a` and `b` are constants.
- The range is allowed to wrap.
- The range should not represent the full or empty set. That is,
- ``a!=b``.
+ `a!=b`.
In addition, the pairs must be in signed order of the lower bound and
they must be non-contiguous.
@@ -7633,103 +7633,97 @@ For vector-typed instructions, the range is applied element-wise.
Examples:
-.. code-block:: llvm
-
- %a = load i8, ptr %x, align 1, !range !0 ; Can only be 0 or 1
- %b = load i8, ptr %y, align 1, !range !1 ; Can only be 255 (-1), 0 or 1
- %c = call i8 @foo(), !range !2 ; Can only be 0, 1, 3, 4 or 5
- %d = invoke i8 @bar() to label %cont
- unwind label %lpad, !range !3 ; Can only be -2, -1, 3, 4 or 5
- %e = load <2 x i8>, ptr %x, !range 0 ; Can only be <0 or 1, 0 or 1>
- ...
- !0 = !{ i8 0, i8 2 }
- !1 = !{ i8 255, i8 2 }
- !2 = !{ i8 0, i8 2, i8 3, i8 6 }
- !3 = !{ i8 -2, i8 0, i8 3, i8 6 }
-
-
-.. _nofpclass-metadata:
-
-'``nofpclass``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-``nofpclass`` metadata may be attached only to ``load``
+```llvm
+ %a = load i8, ptr %x, align 1, !range !0 ; Can only be 0 or 1
+ %b = load i8, ptr %y, align 1, !range !1 ; Can only be 255 (-1), 0 or 1
+ %c = call i8 @foo(), !range !2 ; Can only be 0, 1, 3, 4 or 5
+ %d = invoke i8 @bar() to label %cont
+ unwind label %lpad, !range !3 ; Can only be -2, -1, 3, 4 or 5
+ %e = load <2 x i8>, ptr %x, !range 0 ; Can only be <0 or 1, 0 or 1>
+...
+!0 = !{ i8 0, i8 2 }
+!1 = !{ i8 255, i8 2 }
+!2 = !{ i8 0, i8 2, i8 3, i8 6 }
+!3 = !{ i8 -2, i8 0, i8 3, i8 6 }
+```
+
+(nofpclass-metadata)=
+
+#### '`nofpclass`' Metadata
+
+`nofpclass` metadata may be attached only to `load`
instructions. It asserts floating-point value classes which will not
be loaded. The representation is an i32 constant integer encoding a
10-bit bitmask, with the same meaning and format as the
-:ref:`nofpclass <nofpclass>` attribute. If the loaded value is one of
+{ref}`nofpclass <nofpclass>` attribute. If the loaded value is one of
the specified floating-point classes, a poison value is returned. The
interpretation does not depend on the floating-point environment. A
zero value would be meaningless and is invalid.
Examples:
-.. code-block:: llvm
-
- %not.nan = load float, ptr %p, align 4, !nofpclass !0
- %not.inf = load <2 x float>, ptr %p, align 4, !nofpclass !1
- %only.normal = load double, ptr %p, align 8, !nofpclass !2
- %always.poison = load double, ptr %p, align 8, !nofpclass !3
- %not.nan.array = load [2 x <2 x float>], ptr %p, !nofpclass !1
- %not.nan.struct = load { 2 x float }, ptr %p, align 8, !nofpclass !1
- ...
- !0 = !{ i32 3 }
- !1 = !{ i32 516 }
- !2 = !{ i32 759 }
- !3 = !{ i32 1023 }
-
-
-'``absolute_symbol``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-``absolute_symbol`` metadata may be attached to a global variable
+```llvm
+%not.nan = load float, ptr %p, align 4, !nofpclass !0
+%not.inf = load <2 x float>, ptr %p, align 4, !nofpclass !1
+%only.normal = load double, ptr %p, align 8, !nofpclass !2
+%always.poison = load double, ptr %p, align 8, !nofpclass !3
+%not.nan.array = load [2 x <2 x float>], ptr %p, !nofpclass !1
+%not.nan.struct = load { 2 x float }, ptr %p, align 8, !nofpclass !1
+...
+!0 = !{ i32 3 }
+!1 = !{ i32 516 }
+!2 = !{ i32 759 }
+!3 = !{ i32 1023 }
+```
+
+#### '`absolute_symbol`' Metadata
+
+`absolute_symbol` metadata may be attached to a global variable
declaration. It marks the declaration as a reference to an absolute symbol,
which causes the backend to use absolute relocations for the symbol even
in position independent code, and expresses the possible ranges that the
global variable's *address* (not its value) is in, in the same format as
-``range`` metadata, with the extension that the pair ``all-ones,all-ones``
+`range` metadata, with the extension that the pair `all-ones,all-ones`
may be used to represent the full set.
Example (assuming 64-bit pointers):
-.. code-block:: llvm
+```llvm
+ @a = external global i8, !absolute_symbol !0 ; Absolute symbol in range [0,256)
+ @b = external global i8, !absolute_symbol !1 ; Absolute symbol in range [0,2^64)
- @a = external global i8, !absolute_symbol !0 ; Absolute symbol in range [0,256)
- @b = external global i8, !absolute_symbol !1 ; Absolute symbol in range [0,2^64)
+...
+!0 = !{ i64 0, i64 256 }
+!1 = !{ i64 -1, i64 -1 }
+```
- ...
- !0 = !{ i64 0, i64 256 }
- !1 = !{ i64 -1, i64 -1 }
+#### '`callees`' Metadata
-'``callees``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^
-
-``callees`` metadata may be attached to indirect call sites. If ``callees``
+`callees` metadata may be attached to indirect call sites. If `callees`
metadata is attached to a call site, and any callee is not among the set of
functions provided by the metadata, the behavior is undefined. The intent of
this metadata is to facilitate optimizations such as indirect-call promotion.
For example, in the code below, the call instruction may only target the
-``add`` or ``sub`` functions:
-
-.. code-block:: llvm
+`add` or `sub` functions:
- %result = call i64 %binop(i64 %x, i64 %y), !callees !0
+```llvm
+%result = call i64 %binop(i64 %x, i64 %y), !callees !0
- ...
- !0 = !{ptr @add, ptr @sub}
+...
+!0 = !{ptr @add, ptr @sub}
+```
-'``callback``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^
+#### '`callback`' Metadata
-``callback`` metadata may be attached to a function declaration, or definition.
+`callback` metadata may be attached to a function declaration, or definition.
(Call sites are excluded only due to the lack of a use case.) For ease of
exposition, we'll refer to the function annotated with metadata as a broker
function. The metadata describes how the arguments of a call to the broker are
in turn passed to the callback function specified by the metadata. Thus, the
-``callback`` metadata provides a partial description of a call site inside the
+`callback` metadata provides a partial description of a call site inside the
broker function with regards to the arguments of a call to the broker. The only
semantic restriction on the broker function itself is that it is not allowed to
-inspect or modify arguments referenced in the ``callback`` metadata as
+inspect or modify arguments referenced in the `callback` metadata as
pass-through to the callback function.
The broker is not required to actually invoke the callback function at runtime.
@@ -7741,231 +7735,218 @@ also allowed to invoke (directly or indirectly) the function passed as a
callback through another use. Finally, the broker is also allowed to relay the
callback callee invocation to a different thread.
-The metadata is structured as follows: At the outer level, ``callback``
-metadata is a list of ``callback`` encodings. Each encoding starts with a
-constant ``i64`` which describes the argument position of the callback function
+The metadata is structured as follows: At the outer level, `callback`
+metadata is a list of `callback` encodings. Each encoding starts with a
+constant `i64` which describes the argument position of the callback function
in the call to the broker. The following elements, except the last, describe
what arguments are passed to the callback function. Each element is again an
-``i64`` constant identifying the argument of the broker that is passed through,
-or ``i64 -1`` to indicate an unknown or inspected argument. The order in which
+`i64` constant identifying the argument of the broker that is passed through,
+or `i64 -1` to indicate an unknown or inspected argument. The order in which
they are listed has to be the same in which they are passed to the callback
callee. The last element of the encoding is a boolean which specifies how
variadic arguments of the broker are handled. If it is true, all variadic
arguments of the broker are passed through to the callback function *after* the
arguments encoded explicitly before.
-In the code below, the ``pthread_create`` function is marked as a broker
-through the ``!callback !1`` metadata. In the example, there is only one
-callback encoding, namely ``!2``, associated with the broker. This encoding
-identifies the callback function as the second argument of the broker (``i64
-2``) and the sole argument of the callback function as the third one of the
-broker function (``i64 3``).
+In the code below, the `pthread_create` function is marked as a broker
+through the `!callback !1` metadata. In the example, there is only one
+callback encoding, namely `!2`, associated with the broker. This encoding
+identifies the callback function as the second argument of the broker (`i64
+2`) and the sole argument of the callback function as the third one of the
+broker function (`i64 3`).
-.. FIXME why does the llvm-sphinx-docs builder give a highlighting
- error if the below is set to highlight as 'llvm', despite that we
- have misc.highlighting_failure set?
+% FIXME why does the llvm-sphinx-docs builder give a highlighting error if the below is set to highlight as 'llvm', despite that we have misc.highlighting_failure set?
+```text
+declare !callback !1 dso_local i32 @pthread_create(ptr, ptr, ptr, ptr)
-.. code-block:: text
-
- declare !callback !1 dso_local i32 @pthread_create(ptr, ptr, ptr, ptr)
-
- ...
- !2 = !{i64 2, i64 3, i1 false}
- !1 = !{!2}
+...
+!2 = !{i64 2, i64 3, i1 false}
+!1 = !{!2}
+```
Another example is shown below. The callback callee is the second argument of
-the ``__kmpc_fork_call`` function (``i64 2``). The callee is given two unknown
-values (each identified by a ``i64 -1``) and afterwards all
-variadic arguments that are passed to the ``__kmpc_fork_call`` call (due to the
-final ``i1 true``).
-
-.. FIXME why does the llvm-sphinx-docs builder give a highlighting
- error if the below is set to highlight as 'llvm', despite that we
- have misc.highlighting_failure set?
-
-.. code-block:: text
+the `__kmpc_fork_call` function (`i64 2`). The callee is given two unknown
+values (each identified by a `i64 -1`) and afterwards all
+variadic arguments that are passed to the `__kmpc_fork_call` call (due to the
+final `i1 true`).
- declare !callback !0 dso_local void @__kmpc_fork_call(ptr, i32, ptr, ...)
+% FIXME why does the llvm-sphinx-docs builder give a highlighting error if the below is set to highlight as 'llvm', despite that we have misc.highlighting_failure set?
+```text
+declare !callback !0 dso_local void @__kmpc_fork_call(ptr, i32, ptr, ...)
- ...
- !1 = !{i64 2, i64 -1, i64 -1, i1 true}
- !0 = !{!1}
+...
+!1 = !{i64 2, i64 -1, i64 -1, i1 true}
+!0 = !{!1}
+```
-'``exclude``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`exclude`' Metadata
-``exclude`` metadata may be attached to a global variable to signify that its
+`exclude` metadata may be attached to a global variable to signify that its
section should not be included in the final executable or shared library. This
option is only valid for global variables with an explicit section targeting ELF
-or COFF. This is done using the ``SHF_EXCLUDE`` flag on ELF targets and the
-``IMAGE_SCN_LNK_REMOVE`` and ``IMAGE_SCN_MEM_DISCARDABLE`` flags for COFF
+or COFF. This is done using the `SHF_EXCLUDE` flag on ELF targets and the
+`IMAGE_SCN_LNK_REMOVE` and `IMAGE_SCN_MEM_DISCARDABLE` flags for COFF
targets. Additionally, this metadata is only used as a flag, so the associated
node must be empty. The explicit section should not conflict with any other
sections that the user does not want removed after linking.
-.. code-block:: text
+```text
+ at object = private constant [1 x i8] c"\00", section ".foo" !exclude !0
- @object = private constant [1 x i8] c"\00", section ".foo" !exclude !0
+...
+!0 = !{}
+```
- ...
- !0 = !{}
-
-'``unpredictable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`unpredictable`' Metadata
-``unpredictable`` metadata may be attached to any branch, select, or switch
+`unpredictable` metadata may be attached to any branch, select, or switch
instruction. It can be used to express the unpredictability of control flow.
-Similar to the ``llvm.expect`` intrinsic, it may be used to alter optimizations
+Similar to the `llvm.expect` intrinsic, it may be used to alter optimizations
related to compare and branch instructions. The metadata is treated as a
boolean value; if it exists, it signals that the branch, select, or switch that
it is attached to is completely unpredictable.
-.. _md_dereferenceable:
+(md_dereferenceable)=
-'``dereferenceable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`dereferenceable`' Metadata
-The existence of the ``!dereferenceable`` metadata on the instruction
+The existence of the `!dereferenceable` metadata on the instruction
tells the optimizer that the value loaded is known to be dereferenceable,
otherwise the behavior is undefined.
The number of bytes known to be dereferenceable is specified by the integer
value in the metadata node. This is analogous to the ''dereferenceable''
attribute on parameters and return values.
-.. _md_dereferenceable_or_null:
+(md_dereferenceable_or_null)=
-'``dereferenceable_or_null``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`dereferenceable_or_null`' Metadata
-The existence of the ``!dereferenceable_or_null`` metadata on the
+The existence of the `!dereferenceable_or_null` metadata on the
instruction tells the optimizer that the value loaded is known to be either
dereferenceable or null, otherwise the behavior is undefined.
The number of bytes known to be dereferenceable is specified by the integer
value in the metadata node. This is analogous to the ''dereferenceable_or_null''
attribute on parameters and return values.
-'``captures``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^
+#### '`captures`' Metadata
-The ``!captures`` metadata can only be applied to ``store`` instructions with
+The `!captures` metadata can only be applied to `store` instructions with
a pointer-typed value operand. It restricts the capturing behavior of the store
-value operand in the same way the ``captures(...)`` attribute would do on a
-call. See the :ref:`pointer capture section <pointercapture>` for a detailed
+value operand in the same way the `captures(...)` attribute would do on a
+call. See the {ref}`pointer capture section <pointercapture>` for a detailed
discussion of capture semantics.
-The ``!captures`` metadata accepts a non-empty list of strings from the same
-set as the :ref:`captures attribute <captures_attr>`:
-``!"address"``, ``!"address_is_null"``, ``!"provenance"`` and
-``!"read_provenance"``. ``!"none"`` is not supported.
+The `!captures` metadata accepts a non-empty list of strings from the same
+set as the {ref}`captures attribute <captures_attr>`:
+`!"address"`, `!"address_is_null"`, `!"provenance"` and
+`!"read_provenance"`. `!"none"` is not supported.
-For example ``store ptr %x, ptr %y, !captures !{!"address"}`` indicates that
-the copy of pointer ``%x`` stored to location ``%y`` will only be used to
+For example `store ptr %x, ptr %y, !captures !{!"address"}` indicates that
+the copy of pointer `%x` stored to location `%y` will only be used to
inspect its integral address value, and not dereferenced. Dereferencing the
pointer would result in undefined behavior.
-Similarly ``store ptr %x, ptr %y, !captures !{!"address", !"read_provenance"}``
+Similarly `store ptr %x, ptr %y, !captures !{!"address", !"read_provenance"}`
indicates that while reads through the stored pointer are allowed, writes would
result in undefined behavior.
-The ``!captures`` attribute makes no statement about other uses of ``%x``, or
+The `!captures` attribute makes no statement about other uses of `%x`, or
uses of the stored-to memory location after it has been overwritten with a
different value.
-'``mem.cache_hint``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`mem.cache_hint`' Metadata
-The ``!mem.cache_hint`` metadata may be attached to any instruction that reads
+The `!mem.cache_hint` metadata may be attached to any instruction that reads
or writes memory, except non-intrinsic calls. Cache hints are not permitted on
function calls because their memory behavior depends on attributes, which may
change independently.
-The ``!mem.cache_hint`` metadata provides target-specific cache control hints
+The `!mem.cache_hint` metadata provides target-specific cache control hints
for the memory operation. This metadata is purely a performance hint: dropping
or ignoring it must not change the observable behavior of the program
(particularly, cache hints do not affect memory model semantics).
-The ``!mem.cache_hint`` node must contain an even number of entries,
-alternating between ``i32`` operand numbers and metadata hint nodes.
+The `!mem.cache_hint` node must contain an even number of entries,
+alternating between `i32` operand numbers and metadata hint nodes.
Each operand number identifies the pointer operand to which the following hint
node applies. For non-call instructions, the operand number is the IR operand
index. For intrinsic calls, the operand number is the call argument index.
Operand numbers must be unique and appear in increasing order within a
-``!mem.cache_hint`` node and must refer to a pointer-typed operand.
+`!mem.cache_hint` node and must refer to a pointer-typed operand.
-For example, for a ``load``, the pointer is operand 0. For a ``store``, the
+For example, for a `load`, the pointer is operand 0. For a `store`, the
value is operand 0 and the pointer is operand 1. For intrinsic calls such as
-``llvm.memcpy``, operand numbers correspond to argument positions: e.g.,
+`llvm.memcpy`, operand numbers correspond to argument positions: e.g.,
destination is argument 0 and source is argument 1.
Each hint node is a metadata node containing target-prefixed key/value pairs.
Keys must be strings, and values must be either strings or integer constants.
Keys within a single hint node must be unique.
-The hint node keys are prefixed with a target identifier (e.g., ``nvvm.``) and
+The hint node keys are prefixed with a target identifier (e.g., `nvvm.`) and
their interpretation is target-dependent. Each hint must describe a property of
the individual memory access through the corresponding pointer operand. The IR
verifier enforces only the structural rules above; validation of target-specific
keys and values is performed by the corresponding backend. Unsupported
properties may be silently ignored during code generation.
-The following examples use ``nvvm.`` prefixed keys for NVIDIA GPU targets.
+The following examples use `nvvm.` prefixed keys for NVIDIA GPU targets.
Other targets may define their own prefixed keys.
Example: load with cache hints:
-.. code-block:: llvm
+```llvm
+%v = load i32, ptr addrspace(1) %p, align 4, !mem.cache_hint !0
- %v = load i32, ptr addrspace(1) %p, align 4, !mem.cache_hint !0
-
- !0 = !{ i32 0, !1 }
- !1 = !{ !"nvvm.l1_eviction", !"first",
- !"nvvm.l2_eviction", !"first",
- !"nvvm.l2_prefetch_size", !"128B" }
+!0 = !{ i32 0, !1 }
+!1 = !{ !"nvvm.l1_eviction", !"first",
+ !"nvvm.l2_eviction", !"first",
+ !"nvvm.l2_prefetch_size", !"128B" }
+```
Example: store with cache hints:
-.. code-block:: llvm
-
- store i32 %v, ptr addrspace(1) %p, align 4, !mem.cache_hint !0
+```llvm
+store i32 %v, ptr addrspace(1) %p, align 4, !mem.cache_hint !0
- !0 = !{ i32 1, !1 }
- !1 = !{ !"nvvm.l1_eviction", !"last",
- !"nvvm.l2_eviction", !"last" }
+!0 = !{ i32 1, !1 }
+!1 = !{ !"nvvm.l1_eviction", !"last",
+ !"nvvm.l2_eviction", !"last" }
+```
Example: memcpy with per-operand hints:
-.. code-block:: llvm
+```llvm
+call void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) %d,
+ ptr addrspace(1) %s, i64 16, i1 false),
+ !mem.cache_hint !0
- call void @llvm.memcpy.p1.p1.i64(ptr addrspace(1) %d,
- ptr addrspace(1) %s, i64 16, i1 false),
- !mem.cache_hint !0
+!0 = !{ i32 0, !1, i32 1, !2 }
+!1 = !{ !"nvvm.l1_eviction", !"last" }
+!2 = !{ !"nvvm.l1_eviction", !"first",
+ !"nvvm.l2_prefetch_size", !"128B" }
+```
- !0 = !{ i32 0, !1, i32 1, !2 }
- !1 = !{ !"nvvm.l1_eviction", !"last" }
- !2 = !{ !"nvvm.l1_eviction", !"first",
- !"nvvm.l2_prefetch_size", !"128B" }
+(llvm.loop)=
-.. _llvm.loop:
-
-'``llvm.loop``'
-^^^^^^^^^^^^^^^
+#### '`llvm.loop`'
It is sometimes useful to attach information to loop constructs. Currently,
loop metadata is implemented as metadata attached to the branch instruction
in the loop latch block. The loop metadata node is a list of
other metadata nodes, each representing a property of the loop. Usually,
the first item of the property node is a string. For example, the
-``llvm.loop.unroll.count`` suggests an unroll factor to the loop
+`llvm.loop.unroll.count` suggests an unroll factor to the loop
unroller:
-.. code-block:: llvm
-
- br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0
- ...
- !0 = !{!0, !1, !2}
- !1 = !{!"llvm.loop.unroll.enable"}
- !2 = !{!"llvm.loop.unroll.count", i32 4}
+```llvm
+ br i1 %exitcond, label %._crit_edge, label %.lr.ph, !llvm.loop !0
+...
+!0 = !{!0, !1, !2}
+!1 = !{!"llvm.loop.unroll.enable"}
+!2 = !{!"llvm.loop.unroll.count", i32 4}
+```
For legacy reasons, the first item of a loop metadata node must be a
reference to itself. Before the advent of the 'distinct' keyword, this
@@ -7973,7 +7954,7 @@ forced the preservation of otherwise identical metadata nodes. Since
the loop-metadata node can be attached to multiple nodes, the 'distinct'
keyword has become unnecessary.
-Prior to the property nodes, one or two ``DILocation`` (debug location)
+Prior to the property nodes, one or two `DILocation` (debug location)
nodes can be present in the list. The first, if present, identifies the
source-code location where the loop begins. The second, if present,
identifies the source-code location where the loop ends.
@@ -7982,365 +7963,334 @@ Loop metadata nodes cannot be used as unique identifiers. They are
neither persistent for the same loop through transformations nor
necessarily unique to just one loop.
-'``llvm.loop.disable_nonforced``'
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.disable_nonforced`'
This metadata disables all optional loop transformations unless
explicitly instructed using other transformation metadata such as
-``llvm.loop.unroll.enable``. That is, no heuristic will try to determine
+`llvm.loop.unroll.enable`. That is, no heuristic will try to determine
whether a transformation is profitable. The purpose is to avoid that the
loop is transformed to a different loop before an explicitly requested
(forced) transformation is applied. For instance, loop fusion can make
other transformations impossible. Mandatory loop canonicalizations such
as loop rotation are still applied.
-It is recommended to use this metadata in addition to any ``llvm.loop.*``
+It is recommended to use this metadata in addition to any `llvm.loop.*`
transformation directive. Also, any loop should have at most one
directive applied to it (and a sequence of transformations built using
followup-attributes). Otherwise, which transformation will be applied
depends on implementation details such as the pass pipeline order.
-See :ref:`transformation-metadata` for details.
+See {ref}`transformation-metadata` for details.
-'``llvm.loop.vectorize``' and '``llvm.loop.interleave``'
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize`' and '`llvm.loop.interleave`'
-Metadata prefixed with ``llvm.loop.vectorize`` or ``llvm.loop.interleave`` are
+Metadata prefixed with `llvm.loop.vectorize` or `llvm.loop.interleave` are
used to control per-loop vectorization and interleaving parameters such as
vectorization width and interleave count. These metadata should be used in
-conjunction with ``llvm.loop`` loop identification metadata. The
-``llvm.loop.vectorize`` and ``llvm.loop.interleave`` metadata are only
+conjunction with `llvm.loop` loop identification metadata. The
+`llvm.loop.vectorize` and `llvm.loop.interleave` metadata are only
optimization hints and the optimizer will only interleave and vectorize loops if
-it believes it is safe to do so. The ``llvm.loop.parallel_accesses`` metadata
+it believes it is safe to do so. The `llvm.loop.parallel_accesses` metadata
which contains information about loop-carried memory dependencies can be helpful
in determining the safety of these transformations.
-'``llvm.loop.interleave.count``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.interleave.count`' Metadata
This metadata suggests an interleave count to the loop interleaver.
-The first operand is the string ``llvm.loop.interleave.count`` and the
+The first operand is the string `llvm.loop.interleave.count` and the
second operand is an integer specifying the interleave count. For
example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.interleave.count", i32 4}
+```
- !0 = !{!"llvm.loop.interleave.count", i32 4}
-
-Note that setting ``llvm.loop.interleave.count`` to 1 disables interleaving
-multiple iterations of the loop. If ``llvm.loop.interleave.count`` is set to 0
+Note that setting `llvm.loop.interleave.count` to 1 disables interleaving
+multiple iterations of the loop. If `llvm.loop.interleave.count` is set to 0
then the interleave count will be determined automatically.
-'``llvm.loop.vectorize.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.enable`' Metadata
This metadata selectively enables or disables vectorization for the loop. The
-first operand is the string ``llvm.loop.vectorize.enable`` and the second operand
+first operand is the string `llvm.loop.vectorize.enable` and the second operand
is a bit. If the bit operand value is 1 vectorization is enabled. A value of
0 disables vectorization:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.vectorize.enable", i1 0}
- !1 = !{!"llvm.loop.vectorize.enable", i1 1}
+```llvm
+!0 = !{!"llvm.loop.vectorize.enable", i1 0}
+!1 = !{!"llvm.loop.vectorize.enable", i1 1}
+```
-'``llvm.loop.vectorize.predicate.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.predicate.enable`' Metadata
This metadata selectively enables or disables creating predicated instructions
for the loop, which can enable folding of the scalar epilogue loop into the
main loop. The first operand is the string
-``llvm.loop.vectorize.predicate.enable`` and the second operand is a bit. If
+`llvm.loop.vectorize.predicate.enable` and the second operand is a bit. If
the bit operand value is 1 predication is enabled. A value of 0 disables
predication:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}
- !1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}
+```llvm
+!0 = !{!"llvm.loop.vectorize.predicate.enable", i1 0}
+!1 = !{!"llvm.loop.vectorize.predicate.enable", i1 1}
+```
Additionally, enabling predication implicitly enables vectorization.
-'``llvm.loop.vectorize.scalable.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.scalable.enable`' Metadata
This metadata selectively enables or disables scalable vectorization for the
loop, and only has any effect if vectorization for the loop is already enabled.
-The first operand is the string ``llvm.loop.vectorize.scalable.enable``
+The first operand is the string `llvm.loop.vectorize.scalable.enable`
and the second operand is a bit. If the bit operand value is 1 scalable
vectorization is enabled, whereas a value of 0 reverts to the default fixed
width vectorization:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.vectorize.scalable.enable", i1 0}
- !1 = !{!"llvm.loop.vectorize.scalable.enable", i1 1}
+```llvm
+!0 = !{!"llvm.loop.vectorize.scalable.enable", i1 0}
+!1 = !{!"llvm.loop.vectorize.scalable.enable", i1 1}
+```
-'``llvm.loop.vectorize.width``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.width`' Metadata
This metadata sets the target width of the vectorizer. The first
-operand is the string ``llvm.loop.vectorize.width`` and the second
+operand is the string `llvm.loop.vectorize.width` and the second
operand is an integer specifying the width. For example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.vectorize.width", i32 4}
+```
- !0 = !{!"llvm.loop.vectorize.width", i32 4}
-
-Note that setting ``llvm.loop.vectorize.width`` to 1 disables
-vectorization of the loop. If ``llvm.loop.vectorize.width`` is set to
+Note that setting `llvm.loop.vectorize.width` to 1 disables
+vectorization of the loop. If `llvm.loop.vectorize.width` is set to
0 or if the loop does not have this metadata the width will be
determined automatically.
-'``llvm.loop.vectorize.followup_vectorized``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.followup_vectorized`' Metadata
This metadata defines which loop attributes the vectorized loop will
-have. See :ref:`transformation-metadata` for details.
+have. See {ref}`transformation-metadata` for details.
-'``llvm.loop.vectorize.followup_epilogue``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.followup_epilogue`' Metadata
This metadata defines which loop attributes the epilogue will have. The
epilogue is not vectorized and is executed when either the vectorized
loop is not known to preserve semantics (because e.g., it processes two
arrays that are found to alias by a runtime check) or for the last
iterations that do not fill a complete set of vector lanes. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.vectorize.followup_all``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.followup_all`' Metadata
Attributes in the metadata will be added to both the vectorized and
epilogue loop.
-See :ref:`Transformation Metadata <transformation-metadata>` for details.
+See {ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.vectorize.body``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.body`' Metadata
This metadata is automatically added by the loop vectorizer to the
vectorized loop body. It is used by subsequent optimization passes
-(such as the loop unroller and ``WarnMissedTransforms``) to emit more
+(such as the loop unroller and `WarnMissedTransforms`) to emit more
precise optimization remarks that identify the loop as a vector loop.
The first operand is the string
-``llvm.loop.vectorize.body`` and the second operand is an
+`llvm.loop.vectorize.body` and the second operand is an
integer. A value of 1 indicates this is a vectorized loop body:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.vectorize.body", i32 1}
+```llvm
+!0 = !{!"llvm.loop.vectorize.body", i32 1}
+```
-'``llvm.loop.vectorize.epilogue``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.vectorize.epilogue`' Metadata
This metadata is automatically added by the loop vectorizer to the
scalar remainder (epilogue) loop to identify it as such. It is used by
subsequent optimization passes (such as the loop unroller and
-``WarnMissedTransforms``) to emit more precise optimization remarks
+`WarnMissedTransforms`) to emit more precise optimization remarks
that distinguish between the vectorized loop and its scalar remainder.
Together these two attributes provide a four-way classification:
-- ``body`` only: main vectorized loop body
-- ``epilogue`` only: scalar epilogue loop after vectorization
-- Both ``body`` and ``epilogue``: vectorized epilogue
+- `body` only: main vectorized loop body
+- `epilogue` only: scalar epilogue loop after vectorization
+- Both `body` and `epilogue`: vectorized epilogue
(a remainder loop that was itself vectorized during epilogue
vectorization)
- Neither: a plain loop not produced by the vectorizer
The first operand is the string
-``llvm.loop.vectorize.epilogue`` and the second operand is
+`llvm.loop.vectorize.epilogue` and the second operand is
an integer. A value of 1 indicates the loop is a remainder loop:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.vectorize.epilogue", i32 1}
+```
- !0 = !{!"llvm.loop.vectorize.epilogue", i32 1}
+#### '`llvm.loop.unroll`'
-'``llvm.loop.unroll``'
-^^^^^^^^^^^^^^^^^^^^^^
-
-Metadata prefixed with ``llvm.loop.unroll`` are loop unrolling
-optimization hints such as the unroll factor. ``llvm.loop.unroll``
-metadata should be used in conjunction with ``llvm.loop`` loop
-identification metadata. The ``llvm.loop.unroll`` metadata are only
+Metadata prefixed with `llvm.loop.unroll` are loop unrolling
+optimization hints such as the unroll factor. `llvm.loop.unroll`
+metadata should be used in conjunction with `llvm.loop` loop
+identification metadata. The `llvm.loop.unroll` metadata are only
optimization hints and the unrolling will only be performed if the
optimizer believes it is safe to do so.
-'``llvm.loop.unroll.count``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.count`' Metadata
This metadata suggests an unroll factor to the loop unroller. The
-first operand is the string ``llvm.loop.unroll.count`` and the second
+first operand is the string `llvm.loop.unroll.count` and the second
operand is a positive integer specifying the unroll factor. For
example:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.unroll.count", i32 4}
+```llvm
+!0 = !{!"llvm.loop.unroll.count", i32 4}
+```
If the trip count of the loop is less than the unroll count the loop
will be partially unrolled.
-'``llvm.loop.unroll.disable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.disable`' Metadata
This metadata disables loop unrolling. The metadata has a single operand
-which is the string ``llvm.loop.unroll.disable``. For example:
+which is the string `llvm.loop.unroll.disable`. For example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.unroll.disable"}
+```
- !0 = !{!"llvm.loop.unroll.disable"}
-
-'``llvm.loop.unroll.runtime.disable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.runtime.disable`' Metadata
This metadata disables runtime loop unrolling. The metadata has a single
-operand which is the string ``llvm.loop.unroll.runtime.disable``. For example:
-
-.. code-block:: llvm
+operand which is the string `llvm.loop.unroll.runtime.disable`. For example:
- !0 = !{!"llvm.loop.unroll.runtime.disable"}
+```llvm
+!0 = !{!"llvm.loop.unroll.runtime.disable"}
+```
-'``llvm.loop.unroll.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.enable`' Metadata
This metadata suggests that the loop should be fully unrolled if the trip count
is known at compile time and partially unrolled if the trip count is not known
at compile time. The metadata has a single operand which is the string
-``llvm.loop.unroll.enable``. For example:
+`llvm.loop.unroll.enable`. For example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.unroll.enable"}
+```
- !0 = !{!"llvm.loop.unroll.enable"}
-
-'``llvm.loop.unroll.full``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.full`' Metadata
This metadata suggests that the loop should be unrolled fully. The
-metadata has a single operand which is the string ``llvm.loop.unroll.full``.
+metadata has a single operand which is the string `llvm.loop.unroll.full`.
For example:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.unroll.full"}
+```llvm
+!0 = !{!"llvm.loop.unroll.full"}
+```
-'``llvm.loop.unroll.followup``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.followup`' Metadata
This metadata defines which loop attributes the unrolled loop will have.
-See :ref:`Transformation Metadata <transformation-metadata>` for details.
+See {ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.unroll.followup_remainder``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll.followup_remainder`' Metadata
This metadata defines which loop attributes the remainder loop after
partial/runtime unrolling will have. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.unroll_and_jam``'
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam`'
-This metadata is treated very similarly to the ``llvm.loop.unroll`` metadata
+This metadata is treated very similarly to the `llvm.loop.unroll` metadata
above, but affect the unroll and jam pass. In addition any loop with
-``llvm.loop.unroll`` metadata but no ``llvm.loop.unroll_and_jam`` metadata will
-disable unroll and jam (so ``llvm.loop.unroll`` metadata will be left to the
-unroller, plus ``llvm.loop.unroll.disable`` metadata will disable unroll and jam
+`llvm.loop.unroll` metadata but no `llvm.loop.unroll_and_jam` metadata will
+disable unroll and jam (so `llvm.loop.unroll` metadata will be left to the
+unroller, plus `llvm.loop.unroll.disable` metadata will disable unroll and jam
too.)
-The metadata for unroll and jam otherwise is the same as for ``unroll``.
-``llvm.loop.unroll_and_jam.enable``, ``llvm.loop.unroll_and_jam.disable`` and
-``llvm.loop.unroll_and_jam.count`` do the same as for unroll.
-``llvm.loop.unroll_and_jam.full`` is not supported. Again these are only hints
+The metadata for unroll and jam otherwise is the same as for `unroll`.
+`llvm.loop.unroll_and_jam.enable`, `llvm.loop.unroll_and_jam.disable` and
+`llvm.loop.unroll_and_jam.count` do the same as for unroll.
+`llvm.loop.unroll_and_jam.full` is not supported. Again these are only hints
and the normal safety checks will still be performed.
-'``llvm.loop.unroll_and_jam.count``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.count`' Metadata
This metadata suggests an unroll and jam factor to use, similarly to
-``llvm.loop.unroll.count``. The first operand is the string
-``llvm.loop.unroll_and_jam.count`` and the second operand is a positive integer
+`llvm.loop.unroll.count`. The first operand is the string
+`llvm.loop.unroll_and_jam.count` and the second operand is a positive integer
specifying the unroll factor. For example:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.unroll_and_jam.count", i32 4}
+```llvm
+!0 = !{!"llvm.loop.unroll_and_jam.count", i32 4}
+```
If the trip count of the loop is less than the unroll count the loop
will be partially unroll and jammed.
-'``llvm.loop.unroll_and_jam.disable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.disable`' Metadata
This metadata disables loop unroll and jamming. The metadata has a single
-operand which is the string ``llvm.loop.unroll_and_jam.disable``. For example:
-
-.. code-block:: llvm
+operand which is the string `llvm.loop.unroll_and_jam.disable`. For example:
- !0 = !{!"llvm.loop.unroll_and_jam.disable"}
+```llvm
+!0 = !{!"llvm.loop.unroll_and_jam.disable"}
+```
-'``llvm.loop.unroll_and_jam.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.enable`' Metadata
This metadata suggests that the loop should be fully unroll and jammed if the
trip count is known at compile time and partially unrolled if the trip count is
not known at compile time. The metadata has a single operand which is the
-string ``llvm.loop.unroll_and_jam.enable``. For example:
+string `llvm.loop.unroll_and_jam.enable`. For example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.unroll_and_jam.enable"}
+```
- !0 = !{!"llvm.loop.unroll_and_jam.enable"}
-
-'``llvm.loop.unroll_and_jam.followup_outer``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.followup_outer`' Metadata
This metadata defines which loop attributes the outer unrolled loop will
-have. See :ref:`Transformation Metadata <transformation-metadata>` for
+have. See {ref}`Transformation Metadata <transformation-metadata>` for
details.
-'``llvm.loop.unroll_and_jam.followup_inner``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.followup_inner`' Metadata
This metadata defines which loop attributes the inner jammed loop will
-have. See :ref:`Transformation Metadata <transformation-metadata>` for
+have. See {ref}`Transformation Metadata <transformation-metadata>` for
details.
-'``llvm.loop.unroll_and_jam.followup_remainder_outer``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.followup_remainder_outer`' Metadata
This metadata defines which attributes the epilogue of the outer loop
will have. This loop is usually unrolled, meaning there is no such
loop. This attribute will be ignored in this case. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.unroll_and_jam.followup_remainder_inner``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.followup_remainder_inner`' Metadata
This metadata defines which attributes the inner loop of the epilogue
will have. The outer epilogue will usually be unrolled, meaning there
can be multiple inner remainder loops. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.unroll_and_jam.followup_all``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.unroll_and_jam.followup_all`' Metadata
Attributes specified in the metadata is added to all
-``llvm.loop.unroll_and_jam.*`` loops. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+`llvm.loop.unroll_and_jam.*` loops. See
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.licm_versioning.disable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.licm_versioning.disable`' Metadata
This metadata indicates that the loop should not be versioned for the purpose
of enabling loop-invariant code motion (LICM). The metadata has a single operand
-which is the string ``llvm.loop.licm_versioning.disable``. For example:
-
-.. code-block:: llvm
+which is the string `llvm.loop.licm_versioning.disable`. For example:
- !0 = !{!"llvm.loop.licm_versioning.disable"}
+```llvm
+!0 = !{!"llvm.loop.licm_versioning.disable"}
+```
-'``llvm.loop.distribute.enable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.distribute.enable`' Metadata
Loop distribution allows splitting a loop into multiple loops. Currently,
this is only performed if the entire loop cannot be vectorized due to unsafe
@@ -8348,67 +8298,60 @@ memory dependencies. The transformation will attempt to isolate the unsafe
dependencies into their own loop.
This metadata can be used to selectively enable or disable distribution of the
-loop. The first operand is the string ``llvm.loop.distribute.enable`` and the
+loop. The first operand is the string `llvm.loop.distribute.enable` and the
second operand is a bit. If the bit operand value is 1 distribution is
enabled. A value of 0 disables distribution:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.loop.distribute.enable", i1 0}
+!1 = !{!"llvm.loop.distribute.enable", i1 1}
+```
- !0 = !{!"llvm.loop.distribute.enable", i1 0}
- !1 = !{!"llvm.loop.distribute.enable", i1 1}
-
-This metadata should be used in conjunction with ``llvm.loop`` loop
+This metadata should be used in conjunction with `llvm.loop` loop
identification metadata.
-'``llvm.loop.distribute.followup_coincident``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.distribute.followup_coincident`' Metadata
This metadata defines which attributes extracted loops with no cyclic
dependencies will have (i.e., can be vectorized). See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.distribute.followup_sequential``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.distribute.followup_sequential`' Metadata
This metadata defines which attributes the isolated loops with unsafe
memory dependencies will have. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.distribute.followup_fallback``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.distribute.followup_fallback`' Metadata
If loop versioning is necessary, this metadata defined the attributes
the non-distributed fallback version will have. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.distribute.followup_all``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.distribute.followup_all`' Metadata
The attributes in this metadata are added to all followup loops of the
loop distribution pass. See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.isdistributed``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.isdistributed`' Metadata
If a loop was successfully processed by the loop distribution pass,
this metadata is added (i.e., has been distributed). See
-:ref:`Transformation Metadata <transformation-metadata>` for details.
+{ref}`Transformation Metadata <transformation-metadata>` for details.
-'``llvm.loop.estimated_trip_count``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.estimated_trip_count`' Metadata
This metadata records an estimated trip count for the loop. The first operand
-is the string ``llvm.loop.estimated_trip_count``. The second operand is an
-integer constant of type ``i32`` or smaller specifying the estimate. For
+is the string `llvm.loop.estimated_trip_count`. The second operand is an
+integer constant of type `i32` or smaller specifying the estimate. For
example:
-.. code-block:: llvm
-
- !0 = !{!"llvm.loop.estimated_trip_count", i32 8}
+```llvm
+!0 = !{!"llvm.loop.estimated_trip_count", i32 8}
+```
-Purpose
-"""""""
+##### Purpose
A loop's estimated trip count is an estimate of the average number of loop
iterations (specifically, the number of times the loop's header executes) each
@@ -8419,76 +8362,72 @@ The estimated trip count serves as a parameter for various loop transformations
and typically helps estimate transformation cost. For example, it can help
determine how many iterations to peel or how aggressively to unroll.
-Initialization and Maintenance
-""""""""""""""""""""""""""""""
+##### Initialization and Maintenance
Passes should interact with estimated trip counts always via
-``llvm::getLoopEstimatedTripCount`` and ``llvm::setLoopEstimatedTripCount``.
+`llvm::getLoopEstimatedTripCount` and `llvm::setLoopEstimatedTripCount`.
-When the ``llvm.loop.estimated_trip_count`` metadata is not present on a loop,
-``llvm::getLoopEstimatedTripCount`` estimates the loop's trip count from the
-loop's ``branch_weights`` metadata under the assumption that the latter still
+When the `llvm.loop.estimated_trip_count` metadata is not present on a loop,
+`llvm::getLoopEstimatedTripCount` estimates the loop's trip count from the
+loop's `branch_weights` metadata under the assumption that the latter still
accurately encodes the program's original profile data. However, as passes
transform existing loops and create new loops, they must be free to update and
-create ``branch_weights`` metadata in a way that maintains accurate block
-frequencies. Trip counts estimated from this new ``branch_weights`` metadata
+create `branch_weights` metadata in a way that maintains accurate block
+frequencies. Trip counts estimated from this new `branch_weights` metadata
are not necessarily useful to the passes that consume estimated trip counts.
For this reason, when a pass transforms or creates loops, the pass should
separately estimate new trip counts based on the estimated trip counts that
-``llvm::getLoopEstimatedTripCount`` returns at the start of the pass, and the
+`llvm::getLoopEstimatedTripCount` returns at the start of the pass, and the
pass should record the new estimates by calling
-``llvm::setLoopEstimatedTripCount``, which creates or updates
-``llvm.loop.estimated_trip_count`` metadata. Once this metadata is present on a
-loop, ``llvm::getLoopEstimatedTripCount`` returns its value instead of
-estimating the trip count from the loop's ``branch_weights`` metadata.
+`llvm::setLoopEstimatedTripCount`, which creates or updates
+`llvm.loop.estimated_trip_count` metadata. Once this metadata is present on a
+loop, `llvm::getLoopEstimatedTripCount` returns its value instead of
+estimating the trip count from the loop's `branch_weights` metadata.
-Zero
-""""
+##### Zero
-Some passes set ``llvm.loop.estimated_trip_count`` to 0. For example, after
+Some passes set `llvm.loop.estimated_trip_count` to 0. For example, after
peeling 10 or more iterations from a loop with an estimated trip count of 10,
-``llvm.loop.estimated_trip_count`` becomes 0 on the remaining loop. It
+`llvm.loop.estimated_trip_count` becomes 0 on the remaining loop. It
indicates that, each time execution reaches the peeled iterations, execution is
estimated to exit them without reaching the remaining loop's header.
Even if the probability of reaching a loop's header is low, if it is reached, it
is the start of an iteration. Consequently, some passes historically assume
-that ``llvm::getLoopEstimatedTripCount`` always returns a positive count or
-``std::nullopt``. Thus, it returns ``std::nullopt`` when
-``llvm.loop.estimated_trip_count`` is 0.
+that `llvm::getLoopEstimatedTripCount` always returns a positive count or
+`std::nullopt`. Thus, it returns `std::nullopt` when
+`llvm.loop.estimated_trip_count` is 0.
-'``llvm.licm.disable``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.licm.disable`' Metadata
This metadata indicates that loop-invariant code motion (LICM) should not be
performed on this loop. The metadata has a single operand which is the string
-``llvm.licm.disable``. For example:
+`llvm.licm.disable`. For example:
-.. code-block:: llvm
+```llvm
+!0 = !{!"llvm.licm.disable"}
+```
- !0 = !{!"llvm.licm.disable"}
+Note that although it operates per loop it isn't given the `llvm.loop` prefix
+as it is not affected by the `llvm.loop.disable_nonforced` metadata.
-Note that although it operates per loop it isn't given the ``llvm.loop`` prefix
-as it is not affected by the ``llvm.loop.disable_nonforced`` metadata.
+#### '`llvm.access.group`' Metadata
-'``llvm.access.group``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-``llvm.access.group`` metadata can be attached to any instruction that
+`llvm.access.group` metadata can be attached to any instruction that
potentially accesses memory. It can point to a single distinct metadata
node, which we call access group. This node represents all memory access
-instructions referring to it via ``llvm.access.group``. When an
+instructions referring to it via `llvm.access.group`. When an
instruction belongs to multiple access groups, it can also point to a
list of accesses groups, illustrated by the following example.
-.. code-block:: llvm
-
- %val = load i32, ptr %arrayidx, !llvm.access.group !0
- ...
- !0 = !{!1, !2}
- !1 = distinct !{}
- !2 = distinct !{}
+```llvm
+%val = load i32, ptr %arrayidx, !llvm.access.group !0
+...
+!0 = !{!1, !2}
+!1 = distinct !{}
+!2 = distinct !{}
+```
It is illegal for the list node to be empty since it might be confused
with an access group.
@@ -8504,34 +8443,33 @@ to the access group node.
The access group can be used to refer to a memory access instruction
without pointing to it directly (which is not possible in global
metadata). Currently, the only metadata making use of it is
-``llvm.loop.parallel_accesses``.
+`llvm.loop.parallel_accesses`.
-'``llvm.loop.parallel_accesses``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.parallel_accesses`' Metadata
-The ``llvm.loop.parallel_accesses`` metadata refers to one or more
-access group metadata nodes (see ``llvm.access.group``). It denotes that
+The `llvm.loop.parallel_accesses` metadata refers to one or more
+access group metadata nodes (see `llvm.access.group`). It denotes that
no loop-carried memory dependence exist between it and other instructions
in the loop with this metadata.
-Let ``m1`` and ``m2`` be two instructions that both have the
-``llvm.access.group`` metadata to the access group ``g1``, respectively
-``g2`` (which might be identical). If a loop contains both access groups
-in its ``llvm.loop.parallel_accesses`` metadata, then the compiler can
-assume that there is no dependency between ``m1`` and ``m2`` carried by
+Let `m1` and `m2` be two instructions that both have the
+`llvm.access.group` metadata to the access group `g1`, respectively
+`g2` (which might be identical). If a loop contains both access groups
+in its `llvm.loop.parallel_accesses` metadata, then the compiler can
+assume that there is no dependency between `m1` and `m2` carried by
this loop. Instructions that belong to multiple access groups are
considered having this property if at least one of the access groups
-matches the ``llvm.loop.parallel_accesses`` list.
+matches the `llvm.loop.parallel_accesses` list.
If all memory-accessing instructions in a loop have
-``llvm.access.group`` metadata that each refer to one of the access
-groups of a loop's ``llvm.loop.parallel_accesses`` metadata, then the
+`llvm.access.group` metadata that each refer to one of the access
+groups of a loop's `llvm.loop.parallel_accesses` metadata, then the
loop has no loop carried memory dependencies and is considered to be a
parallel loop. If there is a loop-carried dependency, the behavior is
undefined.
Note that if not all memory access instructions belong to an access
-group referred to by ``llvm.loop.parallel_accesses``, then the loop must
+group referred to by `llvm.loop.parallel_accesses`, then the loop must
not be considered trivially parallel. Additional
memory dependence analysis is required to make that determination. As a
fail-safe mechanism, this causes loops that were originally parallel to be considered
@@ -8539,100 +8477,97 @@ sequential (if optimization passes that are unaware of the parallel semantics
insert new memory instructions into the loop body).
Example of a loop that is considered parallel due to its correct use of
-both ``llvm.access.group`` and ``llvm.loop.parallel_accesses``
+both `llvm.access.group` and `llvm.loop.parallel_accesses`
metadata types.
-.. code-block:: llvm
-
- for.body:
- ...
- %val0 = load i32, ptr %arrayidx, !llvm.access.group !1
- ...
- store i32 %val0, ptr %arrayidx1, !llvm.access.group !1
- ...
- br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
+```llvm
+for.body:
+ ...
+ %val0 = load i32, ptr %arrayidx, !llvm.access.group !1
+ ...
+ store i32 %val0, ptr %arrayidx1, !llvm.access.group !1
+ ...
+ br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
- for.end:
- ...
- !0 = distinct !{!0, !{!"llvm.loop.parallel_accesses", !1}}
- !1 = distinct !{}
+for.end:
+...
+!0 = distinct !{!0, !{!"llvm.loop.parallel_accesses", !1}}
+!1 = distinct !{}
+```
It is also possible to have nested parallel loops:
-.. code-block:: llvm
-
- outer.for.body:
- ...
- %val1 = load i32, ptr %arrayidx3, !llvm.access.group !4
- ...
- br label %inner.for.body
-
- inner.for.body:
- ...
- %val0 = load i32, ptr %arrayidx1, !llvm.access.group !3
- ...
- store i32 %val0, ptr %arrayidx2, !llvm.access.group !3
- ...
- br i1 %exitcond, label %inner.for.end, label %inner.for.body, !llvm.loop !1
-
- inner.for.end:
- ...
- store i32 %val1, ptr %arrayidx4, !llvm.access.group !4
- ...
- br i1 %exitcond, label %outer.for.end, label %outer.for.body, !llvm.loop !2
-
- outer.for.end: ; preds = %for.body
- ...
- !1 = distinct !{!1, !{!"llvm.loop.parallel_accesses", !3}} ; metadata for the inner loop
- !2 = distinct !{!2, !{!"llvm.loop.parallel_accesses", !3, !4}} ; metadata for the outer loop
- !3 = distinct !{} ; access group for instructions in the inner loop (which are implicitly contained in outer loop as well)
- !4 = distinct !{} ; access group for instructions in the outer, but not the inner loop
-
-.. _langref_llvm_loop_mustprogress:
-
-'``llvm.loop.mustprogress``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``llvm.loop.mustprogress`` metadata indicates that this loop is required to
+```llvm
+outer.for.body:
+ ...
+ %val1 = load i32, ptr %arrayidx3, !llvm.access.group !4
+ ...
+ br label %inner.for.body
+
+inner.for.body:
+ ...
+ %val0 = load i32, ptr %arrayidx1, !llvm.access.group !3
+ ...
+ store i32 %val0, ptr %arrayidx2, !llvm.access.group !3
+ ...
+ br i1 %exitcond, label %inner.for.end, label %inner.for.body, !llvm.loop !1
+
+inner.for.end:
+ ...
+ store i32 %val1, ptr %arrayidx4, !llvm.access.group !4
+ ...
+ br i1 %exitcond, label %outer.for.end, label %outer.for.body, !llvm.loop !2
+
+outer.for.end: ; preds = %for.body
+...
+!1 = distinct !{!1, !{!"llvm.loop.parallel_accesses", !3}} ; metadata for the inner loop
+!2 = distinct !{!2, !{!"llvm.loop.parallel_accesses", !3, !4}} ; metadata for the outer loop
+!3 = distinct !{} ; access group for instructions in the inner loop (which are implicitly contained in outer loop as well)
+!4 = distinct !{} ; access group for instructions in the outer, but not the inner loop
+```
+
+(langref_llvm_loop_mustprogress)=
+
+#### '`llvm.loop.mustprogress`' Metadata
+
+The `llvm.loop.mustprogress` metadata indicates that this loop is required to
terminate, unwind, or interact with the environment in an observable way e.g.
via a volatile memory access, I/O, or other synchronization. If such a loop is
not found to interact with the environment in an observable way, the loop may
-be removed. This corresponds to the ``mustprogress`` function attribute.
+be removed. This corresponds to the `mustprogress` function attribute.
-'``irr_loop``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^
+#### '`irr_loop`' Metadata
-``irr_loop`` metadata may be attached to the terminator instruction of a basic
+`irr_loop` metadata may be attached to the terminator instruction of a basic
block that's an irreducible loop header (note that an irreducible loop has more
-than once header basic blocks.) If ``irr_loop`` metadata is attached to the
+than once header basic blocks.) If `irr_loop` metadata is attached to the
terminator instruction of a basic block that is not really an irreducible loop
header, the behavior is undefined. The intent of this metadata is to improve the
accuracy of the block frequency propagation. For example, in the code below, the
-block ``header0`` may have a loop header weight (relative to the other headers of
+block `header0` may have a loop header weight (relative to the other headers of
the irreducible loop) of 100:
-.. code-block:: llvm
-
- header0:
- ...
- br i1 %cmp, label %t1, label %t2, !irr_loop !0
+```llvm
+header0:
+...
+br i1 %cmp, label %t1, label %t2, !irr_loop !0
- ...
- !0 = !{"loop_header_weight", i64 100}
+...
+!0 = !{"loop_header_weight", i64 100}
+```
Irreducible loop header weights are typically based on profile data.
-.. _md_invariant.group:
+(md_invariant.group)=
-'``invariant.group``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`invariant.group`' Metadata
-The experimental ``invariant.group`` metadata may be attached to
-``load``/``store`` instructions referencing a single metadata with no entries.
-The existence of the ``invariant.group`` metadata on the instruction tells
-the optimizer that every ``load`` and ``store`` to the same pointer operand
+The experimental `invariant.group` metadata may be attached to
+`load`/`store` instructions referencing a single metadata with no entries.
+The existence of the `invariant.group` metadata on the instruction tells
+the optimizer that every `load` and `store` to the same pointer operand
can be assumed to load or store the same
-value (but see the ``llvm.launder.invariant.group`` intrinsic which affects
+value (but see the `llvm.launder.invariant.group` intrinsic which affects
when two pointers are considered the same). Pointers returned by bitcast or
getelementptr with only zero indices are considered the same.
@@ -8642,72 +8577,69 @@ reference the same uniqued empty node.
Examples:
-.. code-block:: llvm
+```llvm
+ at unknownPtr = external global i8
+...
+%ptr = alloca i8
+store i8 42, ptr %ptr, !invariant.group !0
+call void @foo(ptr %ptr)
- @unknownPtr = external global i8
- ...
- %ptr = alloca i8
- store i8 42, ptr %ptr, !invariant.group !0
- call void @foo(ptr %ptr)
+%a = load i8, ptr %ptr, !invariant.group !0 ; Can assume that value under %ptr didn't change
+call void @foo(ptr %ptr)
- %a = load i8, ptr %ptr, !invariant.group !0 ; Can assume that value under %ptr didn't change
- call void @foo(ptr %ptr)
+%newPtr = call ptr @getPointer(ptr %ptr)
+%c = load i8, ptr %newPtr, !invariant.group !0 ; Can't assume anything, because we only have information about %ptr
- %newPtr = call ptr @getPointer(ptr %ptr)
- %c = load i8, ptr %newPtr, !invariant.group !0 ; Can't assume anything, because we only have information about %ptr
+%unknownValue = load i8, ptr @unknownPtr
+store i8 %unknownValue, ptr %ptr, !invariant.group !0 ; Can assume that %unknownValue == 42
- %unknownValue = load i8, ptr @unknownPtr
- store i8 %unknownValue, ptr %ptr, !invariant.group !0 ; Can assume that %unknownValue == 42
+call void @foo(ptr %ptr)
+%newPtr2 = call ptr @llvm.launder.invariant.group.p0(ptr %ptr)
+%d = load i8, ptr %newPtr2, !invariant.group !0 ; Can't step through launder.invariant.group to get value of %ptr
- call void @foo(ptr %ptr)
- %newPtr2 = call ptr @llvm.launder.invariant.group.p0(ptr %ptr)
- %d = load i8, ptr %newPtr2, !invariant.group !0 ; Can't step through launder.invariant.group to get value of %ptr
+...
+declare void @foo(ptr)
+declare ptr @getPointer(ptr)
+declare ptr @llvm.launder.invariant.group.p0(ptr)
- ...
- declare void @foo(ptr)
- declare ptr @getPointer(ptr)
- declare ptr @llvm.launder.invariant.group.p0(ptr)
+!0 = !{}
+```
- !0 = !{}
-
-The ``invariant.group`` metadata must be dropped when replacing one pointer by
-another based on aliasing information. This is because ``invariant.group`` is tied
+The `invariant.group` metadata must be dropped when replacing one pointer by
+another based on aliasing information. This is because `invariant.group` is tied
to the SSA value of the pointer operand.
-.. code-block:: llvm
-
- %v = load i8, ptr %x, !invariant.group !0
- ; if %x mustalias %y then we can replace the above instruction with
- %v = load i8, ptr %y
+```llvm
+%v = load i8, ptr %x, !invariant.group !0
+; if %x mustalias %y then we can replace the above instruction with
+%v = load i8, ptr %y
+```
Note that this is an experimental feature, which means that its semantics might
change in the future.
-'``type``' Metadata
-^^^^^^^^^^^^^^^^^^^
+#### '`type`' Metadata
-See :doc:`TypeMetadata`.
+See {doc}`TypeMetadata`.
-'``callee_type``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`callee_type`' Metadata
-See :doc:`CalleeTypeMetadata`.
+See {doc}`CalleeTypeMetadata`.
-'``associated``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`associated`' Metadata
-The ``associated`` metadata may be attached to a global variable definition with
+The `associated` metadata may be attached to a global variable definition with
a single argument that references a global object (optionally through an alias).
-This metadata lowers to the ELF section flag ``SHF_LINK_ORDER`` which prevents
+This metadata lowers to the ELF section flag `SHF_LINK_ORDER` which prevents
discarding of the global variable in linker GC unless the referenced object is
also discarded. The linker support for this feature is spotty. For best
compatibility, globals carrying this metadata should:
-- Be in ``@llvm.compiler.used``.
+- Be in `@llvm.compiler.used`.
- If the referenced global variable is in a comdat, be in the same comdat.
-``!associated`` can not express a many-to-one relationship. A global variable with
+`!associated` can not express a many-to-one relationship. A global variable with
the metadata should generally not be referenced by a function: the function may
be inlined into other functions, leading to more references to the metadata.
Ideally we would want to keep metadata alive as long as any inline location is
@@ -8717,63 +8649,58 @@ error of a relocation referencing a discarded section.
The metadata is often used with an explicit section consisting of valid C
identifiers so that the runtime can find the metadata section with
-linker-defined encapsulation symbols ``__start_<section_name>`` and
-``__stop_<section_name>``.
+linker-defined encapsulation symbols `__start_<section_name>` and
+`__stop_<section_name>`.
It does not have any effect on non-ELF targets.
Example:
-.. code-block:: text
-
- $a = comdat any
- @a = global i32 1, comdat $a
- @b = internal global i32 2, comdat $a, section "abc", !associated !0
- !0 = !{ptr @a}
-
+```text
+$a = comdat any
+ at a = global i32 1, comdat $a
+ at b = internal global i32 2, comdat $a, section "abc", !associated !0
+!0 = !{ptr @a}
+```
-'``prof``' Metadata
-^^^^^^^^^^^^^^^^^^^
+#### '`prof`' Metadata
-The ``prof`` metadata is used to record profile data in the IR.
+The `prof` metadata is used to record profile data in the IR.
The first operand of the metadata node indicates the profile metadata
type. There are currently 3 types:
-:ref:`branch_weights<prof_node_branch_weights>`,
-:ref:`function_entry_count<prof_node_function_entry_count>`, and
-:ref:`VP<prof_node_VP>`.
+{ref}`branch_weights<prof_node_branch_weights>`,
+{ref}`function_entry_count<prof_node_function_entry_count>`, and
+{ref}`VP<prof_node_VP>`.
-.. _prof_node_branch_weights:
+(prof_node_branch_weights)=
-branch_weights
-""""""""""""""
+##### branch_weights
Branch weight metadata attached to a branch, select, switch or call instruction
represents the likeliness of the associated branch being taken.
-For more information, see :doc:`BranchWeightMetadata`.
+For more information, see {doc}`BranchWeightMetadata`.
-.. _prof_node_function_entry_count:
+(prof_node_function_entry_count)=
-function_entry_count
-""""""""""""""""""""
+##### function_entry_count
Function entry count metadata can be attached to function definitions
to record the number of times the function is called. Used with BFI
information, it is also used to derive the basic block profile count.
-For more information, see :doc:`BranchWeightMetadata`.
+For more information, see {doc}`BranchWeightMetadata`.
-.. _prof_node_VP:
+(prof_node_VP)=
-VP
-""
+##### VP
VP (value profile) metadata can be attached to instructions that have
value profile information. Currently this is indirect calls (where it
records the hottest callees) and calls to memory intrinsics, such as memcpy,
memmove, and memset (where it records the hottest byte lengths).
-Each VP metadata node contains "VP" string, then a ``uint32_t`` value for the value
-profiling kind, a ``uint64_t`` value for the total number of times the instruction
-is executed, followed by ``uint64_t`` value and execution count pairs.
+Each VP metadata node contains "VP" string, then a `uint32_t` value for the value
+profiling kind, a `uint64_t` value for the total number of times the instruction
+is executed, followed by `uint64_t` value and execution count pairs.
The value profiling kind is 0 for indirect call targets and 1 for memory
operations. For indirect call targets, each profile value is a hash
of the callee function name, and for memory operations each value is the
@@ -8787,10 +8714,10 @@ are tracked and reported).
Indirect call example:
-.. code-block:: llvm
-
- call void %f(), !prof !1
- !1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410}
+```llvm
+call void %f(), !prof !1
+!1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410}
+```
Note that the VP type is 0 (the second operand), which indicates this is
an indirect call value profile data. The third operand indicates that the
@@ -8800,141 +8727,133 @@ to represent function names in the profile database), and the 5th and 7th
operands give the execution count that each of the respective prior target
functions was called.
-.. _md_annotation:
+(md_annotation)=
-'``annotation``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`annotation`' Metadata
-The ``annotation`` metadata can be used to attach a tuple of annotation strings
+The `annotation` metadata can be used to attach a tuple of annotation strings
or a tuple of a tuple of annotation strings to any instruction. This metadata does
not impact the semantics of the program and may only be used to provide additional
insight about the program and transformations to users.
Example:
-.. code-block:: text
-
- %a.addr = alloca ptr, align 8, !annotation !0
- !0 = !{!"auto-init"}
+```text
+%a.addr = alloca ptr, align 8, !annotation !0
+!0 = !{!"auto-init"}
+```
Embedding tuple of strings example:
-.. code-block:: text
+```text
+%a.ptr = getelementptr ptr, ptr %base, i64 0. !annotation !0
+!0 = !{!1}
+!1 = !{!"gep offset", !"0"}
+```
- %a.ptr = getelementptr ptr, ptr %base, i64 0. !annotation !0
- !0 = !{!1}
- !1 = !{!"gep offset", !"0"}
+#### '`func_sanitize`' Metadata
-'``func_sanitize``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``func_sanitize`` metadata is used to attach two values for the function
+The `func_sanitize` metadata is used to attach two values for the function
sanitizer instrumentation. The first value is the ubsan function signature.
The second value is the address of the proxy variable which stores the address
-of the RTTI descriptor. If :ref:`prologue <prologuedata>` and '``func_sanitize``'
-are used at the same time, :ref:`prologue <prologuedata>` is emitted before
-'``func_sanitize``' in the output.
+of the RTTI descriptor. If {ref}`prologue <prologuedata>` and '`func_sanitize`'
+are used at the same time, {ref}`prologue <prologuedata>` is emitted before
+'`func_sanitize`' in the output.
Example:
-.. code-block:: text
-
- @__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
- define void @_Z3funv() !func_sanitize !0 {
- return void
- }
- !0 = !{i32 846595819, ptr @__llvm_rtti_proxy}
+```text
+ at __llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
+define void @_Z3funv() !func_sanitize !0 {
+ return void
+}
+!0 = !{i32 846595819, ptr @__llvm_rtti_proxy}
+```
-.. _md_kcfi_type:
+(md_kcfi_type)=
-'``kcfi_type``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`kcfi_type`' Metadata
-The ``kcfi_type`` metadata can be used to attach a type identifier to
+The `kcfi_type` metadata can be used to attach a type identifier to
functions that can be called indirectly. The type data is emitted before the
-function entry in the assembly. Indirect calls with the :ref:`kcfi operand
-bundle<ob_kcfi>` will emit a check that compares the type identifier to the
+function entry in the assembly. Indirect calls with the {ref}`kcfi operand bundle<ob_kcfi>` will emit a check that compares the type identifier to the
metadata.
Example:
-.. code-block:: text
+```text
+define dso_local i32 @f() !kcfi_type !0 {
+ ret i32 0
+}
+!0 = !{i32 12345678}
+```
- define dso_local i32 @f() !kcfi_type !0 {
- ret i32 0
- }
- !0 = !{i32 12345678}
+Clang emits `kcfi_type` metadata nodes for address-taken functions with
+`-fsanitize=kcfi`.
-Clang emits ``kcfi_type`` metadata nodes for address-taken functions with
-``-fsanitize=kcfi``.
+#### '`pcsections`' Metadata
-'``pcsections``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``pcsections`` metadata can be attached to instructions and functions, for
+The `pcsections` metadata can be attached to instructions and functions, for
which addresses, viz. program counters (PCs), are to be emitted in specially
-encoded binary sections. More details can be found in the `PC Sections Metadata
-<PCSectionsMetadata.html>`_ documentation.
+encoded binary sections. More details can be found in the {doc}`PC Sections Metadata <PCSectionsMetadata>` documentation.
-.. _md_memprof:
+(md_memprof)=
-'``memprof``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`memprof`' Metadata
-The ``memprof`` metadata is used to record memory profile data on heap
+The `memprof` metadata is used to record memory profile data on heap
allocation calls. Multiple context-sensitive profiles can be represented
-with a single ``memprof`` metadata attachment.
+with a single `memprof` metadata attachment.
Example:
-.. code-block:: text
-
- %call = call ptr @_Znam(i64 10), !memprof !0, !callsite !5
- !0 = !{!1, !3}
- !1 = !{!2, !"cold"}
- !2 = !{i64 4854880825882961848, i64 1905834578520680781}
- !3 = !{!4, !"notcold"}
- !4 = !{i64 4854880825882961848, i64 -6528110295079665978}
- !5 = !{i64 4854880825882961848}
-
-Each operand in the ``memprof`` metadata attachment describes the profiled
+```text
+%call = call ptr @_Znam(i64 10), !memprof !0, !callsite !5
+!0 = !{!1, !3}
+!1 = !{!2, !"cold"}
+!2 = !{i64 4854880825882961848, i64 1905834578520680781}
+!3 = !{!4, !"notcold"}
+!4 = !{i64 4854880825882961848, i64 -6528110295079665978}
+!5 = !{i64 4854880825882961848}
+```
+
+Each operand in the `memprof` metadata attachment describes the profiled
behavior of memory allocated by the associated allocation for a given context.
In the above example, there were 2 profiled contexts, one allocating memory
that was typically cold and one allocating memory that was typically not cold.
The format of the metadata describing a context specific profile (e.g.
-``!1`` and ``!3`` above) requires a first operand that is a metadata node
+`!1` and `!3` above) requires a first operand that is a metadata node
describing the context, followed by a list of string metadata tags describing
-the profile behavior (e.g., ``cold`` and ``notcold``) above. The metadata nodes
-describing the context (e.g., ``!2`` and ``!4`` above) are unique ids
+the profile behavior (e.g., `cold` and `notcold`) above. The metadata nodes
+describing the context (e.g., `!2` and `!4` above) are unique ids
corresponding to callsites, which can be matched to associated IR calls via
-:ref:`callsite metadata<md_callsite>`. In practice these ids are formed via
+{ref}`callsite metadata<md_callsite>`. In practice these ids are formed via
a hash of the callsite's debug info, and the associated call may be in a
different module. The contexts are listed in order from leaf-most call (the
allocation itself) to the outermost callsite context required for uniquely
identifying the described profile behavior (note this may not be the top of
the profiled call stack).
-.. _md_callsite:
+(md_callsite)=
-'``callsite``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`callsite`' Metadata
-The ``callsite`` metadata is used to identify callsites involved in memory
-profile contexts described in :ref:`memprof metadata<md_memprof>`.
+The `callsite` metadata is used to identify callsites involved in memory
+profile contexts described in {ref}`memprof metadata<md_memprof>`.
It is attached both to the profile allocation calls (see the example in
-:ref:`memprof metadata<md_memprof>`), as well as to other callsites
-in profiled contexts described in heap allocation ``memprof`` metadata.
+{ref}`memprof metadata<md_memprof>`), as well as to other callsites
+in profiled contexts described in heap allocation `memprof` metadata.
Example:
-.. code-block:: text
-
- %call = call ptr @_Z1Bb(void), !callsite !0
- !0 = !{i64 -6528110295079665978, i64 5462047985461644151}
+```text
+%call = call ptr @_Z1Bb(void), !callsite !0
+!0 = !{i64 -6528110295079665978, i64 5462047985461644151}
+```
-Each operand in the ``callsite`` metadata attachment is a unique id
+Each operand in the `callsite` metadata attachment is a unique id
corresponding to a callsite (possibly inlined). In practice these ids are
formed via a hash of the callsite's debug info. If the call was not inlined
into any callers it will contain a single operand (id). If it was inlined
@@ -8943,34 +8862,32 @@ full inline sequence, in order from the leaf-most call's id to the outermost
inlined call.
-'``noalias.addrspace``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`noalias.addrspace`' Metadata
-The ``noalias.addrspace`` metadata is used to identify memory
+The `noalias.addrspace` metadata is used to identify memory
operations which cannot access objects allocated in a range of address
spaces. It is attached to memory instructions, including
-:ref:`atomicrmw <i_atomicrmw>`, :ref:`cmpxchg <i_cmpxchg>`, and
-:ref:`call <i_call>` instructions.
+{ref}`atomicrmw <i_atomicrmw>`, {ref}`cmpxchg <i_cmpxchg>`, and
+{ref}`call <i_call>` instructions.
-This follows the same form as :ref:`range metadata <range-metadata>`,
+This follows the same form as {ref}`range metadata <range-metadata>`,
except the field entries must be of type `i32`. The interpretation is
the same numeric address spaces as applied to IR values.
Example:
-.. code-block:: llvm
+```llvm
+; %ptr cannot point to an object allocated in addrspace(5)
+%rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !noalias.addrspace !0
- ; %ptr cannot point to an object allocated in addrspace(5)
- %rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !noalias.addrspace !0
-
- ; Undefined behavior. The underlying object is allocated in one of the listed
- ; address spaces.
- %alloca = alloca i64, addrspace(5)
- %alloca.cast = addrspacecast ptr addrspace(5) %alloca to ptr
- %rmw.ub = atomicrmw and ptr %alloca.cast, i64 %value seq_cst, !noalias.addrspace !0
-
- !0 = !{i32 5, i32 6} ; Exclude addrspace(5) only
+; Undefined behavior. The underlying object is allocated in one of the listed
+; address spaces.
+%alloca = alloca i64, addrspace(5)
+%alloca.cast = addrspacecast ptr addrspace(5) %alloca to ptr
+%rmw.ub = atomicrmw and ptr %alloca.cast, i64 %value seq_cst, !noalias.addrspace !0
+!0 = !{i32 5, i32 6} ; Exclude addrspace(5) only
+```
This is intended for use on targets with a notion of generic address
spaces, which at runtime resolve to different physical memory
@@ -8978,65 +8895,61 @@ spaces. The interpretation of the address space values is target specific.
The behavior is undefined if the runtime memory address does
resolve to an object defined in one of the indicated address spaces.
-'``mmra``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`mmra`' Metadata
-The ``mmra`` metadata represents target-defined properties on instructions that
+The `mmra` metadata represents target-defined properties on instructions that
can be used to selectively relax constraints placed by the memory model.
-Refer to :doc:`MemoryModelRelaxationAnnotations` for more information on how this metadata
+Refer to {doc}`MemoryModelRelaxationAnnotations` for more information on how this metadata
affects the memory model of a given target.
It is attached to memory instructions such as:
-:ref:`atomicrmw <i_atomicrmw>`, :ref:`cmpxchg <i_cmpxchg>`, :ref:`load <i_load>`,
-:ref:`store <i_store>`, :ref:`fence <i_fence>` and
-:ref:`call <i_call>` instructions that read or write memory.
+{ref}`atomicrmw <i_atomicrmw>`, {ref}`cmpxchg <i_cmpxchg>`, {ref}`load <i_load>`,
+{ref}`store <i_store>`, {ref}`fence <i_fence>` and
+{ref}`call <i_call>` instructions that read or write memory.
The metadata is structured as pairs of strings: a prefix, and suffix that form a MMRA "tag".
-The ``!mmra`` operand can either point to a pair of metadata strings, or a tuple containing
+The `!mmra` operand can either point to a pair of metadata strings, or a tuple containing
multiple pairs of metadata strings.
Example:
-.. code-block:: llvm
+```llvm
+; Simple pair of strings used directly:
+%rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !mmra !0
- ; Simple pair of strings used directly:
- %rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !mmra !0
+; Using multiple pairs of strings using a metadata tuple:
+%rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !mmra !2
- ; Using multiple pairs of strings using a metadata tuple:
- %rmw.valid = atomicrmw and ptr %ptr, i64 %value seq_cst, !mmra !2
+!0 = !{!"amdgpu-synchronize-as", !"global"}
+!1 = !{!"amdgpu-synchronize-as", !"private"}
+!2 = !{!0, !1}
+```
- !0 = !{!"amdgpu-synchronize-as", !"global"}
- !1 = !{!"amdgpu-synchronize-as", !"private"}
- !2 = !{!0, !1}
+#### '`nofree`' Metadata
-'``nofree``' Metadata
-^^^^^^^^^^^^^^^^^^^^^
-
-The ``nofree`` metadata indicates the memory pointed by the pointer will not be
+The `nofree` metadata indicates the memory pointed by the pointer will not be
freed after the attached instruction.
-'``alloc_token``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`alloc_token`' Metadata
-The ``alloc_token`` metadata may be attached to calls to memory allocation
+The `alloc_token` metadata may be attached to calls to memory allocation
functions, and contains richer semantic information about the type of the
-allocation. This information is consumed by the ``alloc-token`` pass to
+allocation. This information is consumed by the `alloc-token` pass to
instrument such calls with allocation token IDs.
The metadata contains: string with the type of an allocation, and a boolean
denoting if the type contains a pointer.
-.. code-block:: none
-
- call ptr @malloc(i64 64), !alloc_token !0
+```
+call ptr @malloc(i64 64), !alloc_token !0
- !0 = !{!"<type-name>", i1 <contains-pointer>}
+!0 = !{!"<type-name>", i1 <contains-pointer>}
+```
-'``stack-protector``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`stack-protector`' Metadata
-The ``stack-protector`` metadata may be attached to alloca instructions. An
+The `stack-protector` metadata may be attached to alloca instructions. An
alloca instruction with this metadata and value `i32 0` will be skipped when
deciding whether a given function requires a stack protector. The function
may still use a stack protector, if other criteria determine it needs one.
@@ -9044,21 +8957,20 @@ may still use a stack protector, if other criteria determine it needs one.
The metadata contains an integer, where a 0 value opts the given alloca out
of requiring a stack protector.
-.. code-block:: none
+```
+ %a = alloca [1000 x i8], align 1, !stack-protector !0
- %a = alloca [1000 x i8], align 1, !stack-protector !0
+!0 = !{i32 0}
+```
- !0 = !{i32 0}
+#### '`implicit.ref`' Metadata
-'``implicit.ref``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``implicit.ref`` metadata may be attached to a function or global variable
+The `implicit.ref` metadata may be attached to a function or global variable
definition with a single argument that references a global object.
This is typically used when there is some implicit dependence between the
symbols that is otherwise opaque to the linker. One such example is metadata
-which is accessed by a runtime with associated ``__start_<section_name>`` and
-``__stop_<section_name>`` symbols.
+which is accessed by a runtime with associated `__start_<section_name>` and
+`__stop_<section_name>` symbols.
It does not have any effect on non-XCOFF targets.
@@ -9071,17 +8983,16 @@ to the same function or global variable.
Example:
-.. code-block:: text
-
- @a = global i32 1
- @b = global i32 2
- @c = global i32 3, section "abc", !implicit.ref !0, !implicit.ref !1
- !0 = !{ptr @a}
- !1 = !{ptr @b}
+```text
+ at a = global i32 1
+ at b = global i32 2
+ at c = global i32 3, section "abc", !implicit.ref !0, !implicit.ref !1
+!0 = !{ptr @a}
+!1 = !{ptr @b}
+```
-'``inline_history``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The ``inline_history`` metadata may be attached to a call instruction. It
+#### '`inline_history`' Metadata
+The `inline_history` metadata may be attached to a call instruction. It
indicates that the call instruction has been inlined from the referenced
functions. The call itself should not be inlined if it is a call to any of the
referenced functions since that could result in infinite inlining as we
@@ -9089,20 +9000,19 @@ continually inline through mutually recursive functions.
This is intended to be added by and used by inliner passes.
-The metadata operands must all be function pointers or ``null``. ``null`` can
+The metadata operands must all be function pointers or `null`. `null` can
appear when the referenced function is erased from the module, e.g. an internal
function that has had all calls to it inlined.
-.. code-block:: text
+```text
+call void @foo(), !inline_history !0
- call void @foo(), !inline_history !0
+!0 = !{ptr @bar, null, ptr @baz}
+```
- !0 = !{ptr @bar, null, ptr @baz}
+#### '`elf_section_properties`' Metadata
-'``elf_section_properties``' Metadata
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The '``elf_section_properties``' metadata is attached to a function or
+The '`elf_section_properties`' metadata is attached to a function or
global variable and is used when writing an object file in ELF format to
specify the values of the global's section type (`sh_type`) and entry
size (`sh_entsize`) fields. The first operand specifies the type, and
@@ -9110,25 +9020,24 @@ the second operand specifies the entry size.
Example:
-.. code-block:: llvm
-
- @global = global i32 1, !elf_section_properties !{i32 1879002126, i32 8}
+```llvm
+ at global = global i32 1, !elf_section_properties !{i32 1879002126, i32 8}
+```
-This defines a global with type ``SHT_LLVM_CFI_JUMP_TABLE`` and entry
+This defines a global with type `SHT_LLVM_CFI_JUMP_TABLE` and entry
size 8.
-Module Flags Metadata
-=====================
+## Module Flags Metadata
Information about the module as a whole is difficult to convey to LLVM's
subsystems. The LLVM IR isn't sufficient to transmit this information.
-The ``llvm.module.flags`` named metadata exists in order to facilitate
+The `llvm.module.flags` named metadata exists in order to facilitate
this. These flags are in the form of key / value pairs --- much like a
dictionary --- making it easy for any subsystem that cares about a flag to
look it up.
-The ``llvm.module.flags`` metadata contains a list of metadata triplets.
+The `llvm.module.flags` metadata contains a list of metadata triplets.
Each triplet has the following form:
- The first element is a *behavior* flag, which specifies the behavior
@@ -9141,68 +9050,68 @@ Each triplet has the following form:
- The third element is the value of the flag.
When two (or more) modules are merged together, the resulting
-``llvm.module.flags`` metadata is the union of the modules' flags. That is, for
+`llvm.module.flags` metadata is the union of the modules' flags. That is, for
each unique metadata ID string, there will be exactly one entry in the merged
-modules ``llvm.module.flags`` metadata table, and the value for that entry will
+modules `llvm.module.flags` metadata table, and the value for that entry will
be determined by the merge behavior flag, as described below. The only exception
is that entries with the *Require* behavior are always preserved.
The following behaviors are supported:
-.. list-table::
- :header-rows: 1
- :widths: 10 90
-
- * - Value
- - Behavior
-
- * - 1
- - **Error**
- Emits an error if two values disagree, otherwise the resulting value
- is that of the operands.
-
- * - 2
- - **Warning**
- Emits a warning if two values disagree. The result value will be the
- operand for the flag from the first module being linked, unless the
- other module uses **Min** or **Max**, in which case the result will
- be **Min** (with the min value) or **Max** (with the max value),
- respectively.
-
- * - 3
- - **Require**
- Adds a requirement that another module flag be present and have a
- specified value after linking is performed. The value must be a
- metadata pair, where the first element of the pair is the ID of the
- module flag to be restricted, and the second element of the pair is
- the value the module flag should be restricted to. This behavior can
- be used to restrict the allowable results (via triggering of an
- error) of linking IDs with the **Override** behavior.
-
- * - 4
- - **Override**
- Uses the specified value, regardless of the behavior or value of the
- other module. If both modules specify **Override**, but the values
- differ, an error will be emitted.
-
- * - 5
- - **Append**
- Appends the two values, which are required to be metadata nodes.
-
- * - 6
- - **AppendUnique**
- Appends the two values, which are required to be metadata
- nodes. However, duplicate entries in the second list are dropped
- during the append operation.
-
- * - 7
- - **Max**
- Takes the max of the two values, which are required to be integers.
-
- * - 8
- - **Min**
- Takes the min of the two values, which are required to be non-negative integers.
- An absent module flag is treated as having the value 0.
+```{list-table}
+:header-rows: 1
+:widths: 10 90
+* - Value
+ - Behavior
+
+* - 1
+ - **Error**
+ : Emits an error if two values disagree, otherwise the resulting value
+ is that of the operands.
+
+* - 2
+ - **Warning**
+ : Emits a warning if two values disagree. The result value will be the
+ operand for the flag from the first module being linked, unless the
+ other module uses **Min** or **Max**, in which case the result will
+ be **Min** (with the min value) or **Max** (with the max value),
+ respectively.
+
+* - 3
+ - **Require**
+ : Adds a requirement that another module flag be present and have a
+ specified value after linking is performed. The value must be a
+ metadata pair, where the first element of the pair is the ID of the
+ module flag to be restricted, and the second element of the pair is
+ the value the module flag should be restricted to. This behavior can
+ be used to restrict the allowable results (via triggering of an
+ error) of linking IDs with the **Override** behavior.
+
+* - 4
+ - **Override**
+ : Uses the specified value, regardless of the behavior or value of the
+ other module. If both modules specify **Override**, but the values
+ differ, an error will be emitted.
+
+* - 5
+ - **Append**
+ : Appends the two values, which are required to be metadata nodes.
+
+* - 6
+ - **AppendUnique**
+ : Appends the two values, which are required to be metadata
+ nodes. However, duplicate entries in the second list are dropped
+ during the append operation.
+
+* - 7
+ - **Max**
+ : Takes the max of the two values, which are required to be integers.
+
+* - 8
+ - **Min**
+ : Takes the min of the two values, which are required to be non-negative integers.
+ An absent module flag is treated as having the value 0.
+```
It is an error for a particular unique flag ID to have multiple behaviors,
except in the case of **Require** (which adds restrictions on another metadata
@@ -9210,42 +9119,41 @@ value) or **Override**.
An example of module flags:
-.. code-block:: llvm
-
- !0 = !{ i32 1, !"foo", i32 1 }
- !1 = !{ i32 4, !"bar", i32 37 }
- !2 = !{ i32 2, !"qux", i32 42 }
- !3 = !{ i32 3, !"qux",
- !{
- !"foo", i32 1
- }
- }
- !llvm.module.flags = !{ !0, !1, !2, !3 }
+```llvm
+!0 = !{ i32 1, !"foo", i32 1 }
+!1 = !{ i32 4, !"bar", i32 37 }
+!2 = !{ i32 2, !"qux", i32 42 }
+!3 = !{ i32 3, !"qux",
+ !{
+ !"foo", i32 1
+ }
+}
+!llvm.module.flags = !{ !0, !1, !2, !3 }
+```
-- Metadata ``!0`` has the ID ``!"foo"`` and the value '1'. The behavior
- if two or more ``!"foo"`` flags are seen is to emit an error if their
+- Metadata `!0` has the ID `!"foo"` and the value '1'. The behavior
+ if two or more `!"foo"` flags are seen is to emit an error if their
values are not equal.
-- Metadata ``!1`` has the ID ``!"bar"`` and the value '37'. The
- behavior if two or more ``!"bar"`` flags are seen is to use the value
+- Metadata `!1` has the ID `!"bar"` and the value '37'. The
+ behavior if two or more `!"bar"` flags are seen is to use the value
'37'.
-- Metadata ``!2`` has the ID ``!"qux"`` and the value '42'. The
- behavior if two or more ``!"qux"`` flags are seen is to emit a
+- Metadata `!2` has the ID `!"qux"` and the value '42'. The
+ behavior if two or more `!"qux"` flags are seen is to emit a
warning if their values are not equal.
-- Metadata ``!3`` has the ID ``!"qux"`` and the value:
-
- ::
+- Metadata `!3` has the ID `!"qux"` and the value:
- !{ !"foo", i32 1 }
+ ```
+ !{ !"foo", i32 1 }
+ ```
- The behavior is to emit an error if the ``llvm.module.flags`` does not
- contain a flag with the ID ``!"foo"`` that has the value '1' after linking is
+ The behavior is to emit an error if the `llvm.module.flags` does not
+ contain a flag with the ID `!"foo"` that has the value '1' after linking is
performed.
-Synthesized Functions Module Flags Metadata
--------------------------------------------
+### Synthesized Functions Module Flags Metadata
These metadata specify the default attributes synthesized functions should have.
These metadata are currently respected by a few instrumentation passes, such as
@@ -9260,13 +9168,12 @@ functions is small.
will get the "frame-pointer" function attribute, with value being "none",
"non-leaf", or "all", respectively.
- "function_return_thunk_extern": The synthesized function will get the
- ``fn_return_thunk_extern`` function attribute.
+ `fn_return_thunk_extern` function attribute.
- "uwtable": **Max**. The value can be 0, 1, or 2. If the value is 1, a synthesized
- function will get the ``uwtable(sync)`` function attribute, if the value is 2,
- a synthesized function will get the ``uwtable(async)`` function attribute.
+ function will get the `uwtable(sync)` function attribute, if the value is 2,
+ a synthesized function will get the `uwtable(async)` function attribute.
-Objective-C Garbage Collection Module Flags Metadata
-----------------------------------------------------
+### Objective-C Garbage Collection Module Flags Metadata
On the Mach-O platform, Objective-C stores metadata about garbage
collection in a special section called "image info". The metadata
@@ -9278,47 +9185,46 @@ be merged rather than appended together.
The Objective-C garbage collection module flags metadata consists of the
following key-value pairs:
-.. list-table::
- :header-rows: 1
- :widths: 30 70
-
- * - Key
- - Value
+```{list-table}
+:header-rows: 1
+:widths: 30 70
+* - Key
+ - Value
- * - ``Objective-C Version``
- - **[Required]** --- The Objective-C ABI version. Valid values are 1 and 2.
+* - `Objective-C Version`
+ - **[Required]** --- The Objective-C ABI version. Valid values are 1 and 2.
- * - ``Objective-C Image Info Version``
- - **[Required]** --- The version of the image info section. Currently
- always 0.
+* - `Objective-C Image Info Version`
+ - **[Required]** --- The version of the image info section. Currently
+ always 0.
- * - ``Objective-C Image Info Section``
- - **[Required]** --- The section to place the metadata. Valid values are
- ``"__OBJC, __image_info, regular"`` for Objective-C ABI version 1, and
- ``"__DATA,__objc_imageinfo, regular, no_dead_strip"`` for
- Objective-C ABI version 2.
+* - `Objective-C Image Info Section`
+ - **[Required]** --- The section to place the metadata. Valid values are
+ `"__OBJC, __image_info, regular"` for Objective-C ABI version 1, and
+ `"__DATA,__objc_imageinfo, regular, no_dead_strip"` for
+ Objective-C ABI version 2.
- * - ``Objective-C Garbage Collection``
- - **[Required]** --- Specifies whether garbage collection is supported or
- not. Valid values are 0, for no garbage collection, and 2, for garbage
- collection supported.
+* - `Objective-C Garbage Collection`
+ - **[Required]** --- Specifies whether garbage collection is supported or
+ not. Valid values are 0, for no garbage collection, and 2, for garbage
+ collection supported.
- * - ``Objective-C GC Only``
- - **[Optional]** --- Specifies that only garbage collection is supported.
- If present, its value must be 6. This flag requires that the
- ``Objective-C Garbage Collection`` flag have the value 2.
+* - `Objective-C GC Only`
+ - **[Optional]** --- Specifies that only garbage collection is supported.
+ If present, its value must be 6. This flag requires that the
+ `Objective-C Garbage Collection` flag have the value 2.
+```
Some important flag interactions:
-- If a module with ``Objective-C Garbage Collection`` set to 0 is
- merged with a module with ``Objective-C Garbage Collection`` set to
+- If a module with `Objective-C Garbage Collection` set to 0 is
+ merged with a module with `Objective-C Garbage Collection` set to
2, then the resulting module has the
- ``Objective-C Garbage Collection`` flag set to 0.
-- A module with ``Objective-C Garbage Collection`` set to 0 cannot be
- merged with a module with ``Objective-C GC Only`` set to 6.
+ `Objective-C Garbage Collection` flag set to 0.
+- A module with `Objective-C Garbage Collection` set to 0 cannot be
+ merged with a module with `Objective-C GC Only` set to 6.
-C type width Module Flags Metadata
-----------------------------------
+### C type width Module Flags Metadata
The ARM backend emits a section into each generated object file describing the
options that it was compiled with (in a compiler-independent way) to prevent
@@ -9329,32 +9235,32 @@ width.
To pass this information to the backend, these options are encoded in module
flags metadata, using the following key-value pairs:
-.. list-table::
- :header-rows: 1
- :widths: 30 70
-
- * - Key
- - Value
+```{list-table}
+:header-rows: 1
+:widths: 30 70
+* - Key
+ - Value
- * - short_wchar
- - * 0 --- sizeof(wchar_t) == 4
- * 1 --- sizeof(wchar_t) == 2
+* - short_wchar
+ - * 0 --- sizeof(wchar_t) == 4
+ * 1 --- sizeof(wchar_t) == 2
- * - short_enum
- - * 0 --- Enums are at least as large as an ``int``.
- * 1 --- Enums are stored in the smallest integer type which can
- represent all of its values.
+* - short_enum
+ - * 0 --- Enums are at least as large as an `int`.
+ * 1 --- Enums are stored in the smallest integer type which can
+ represent all of its values.
+```
For example, the following metadata section specifies that the module was
-compiled with a ``wchar_t`` width of 4 bytes, and the underlying type of an
-enum is the smallest type which can represent all of its values::
+compiled with a `wchar_t` width of 4 bytes, and the underlying type of an
+enum is the smallest type which can represent all of its values:
+```
+!llvm.module.flags = !{!0, !1}
+!0 = !{i32 1, !"short_wchar", i32 1}
+!1 = !{i32 1, !"short_enum", i32 0}
+```
- !llvm.module.flags = !{!0, !1}
- !0 = !{i32 1, !"short_wchar", i32 1}
- !1 = !{i32 1, !"short_enum", i32 0}
-
-Stack Alignment Metadata
-------------------------
+### Stack Alignment Metadata
Changes the default stack alignment from the target ABI's implicit default
stack alignment. Takes an i32 value in bytes. It is considered an error to link
@@ -9362,13 +9268,14 @@ two modules together with different values for this metadata.
For example:
- !llvm.module.flags = !{!0}
- !0 = !{i32 1, !"override-stack-alignment", i32 8}
+```llvm
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"override-stack-alignment", i32 8}
+```
This will change the stack alignment to 8B.
-Windows Control Flow Guard Metadata
------------------------------------
+### Windows Control Flow Guard Metadata
Controls what Control Flow Guard (CFG) checks are performed, how they are
performed, and what metadata is emitted. There are multiple flags that can be
@@ -9378,50 +9285,48 @@ same flag will raise a warning when linking.
To pass this information to the backend, these options are encoded in module
flags metadata, using the following key-value pairs:
-.. list-table::
- :header-rows: 1
- :widths: 30 70
-
- * - Key
- - Value
+```{list-table}
+:header-rows: 1
+:widths: 30 70
+* - Key
+ - Value
- * - cfguard
- - * 0 --- CFG is completely disabled.
- * 1 --- The CFG table is emitted, but no checks are performed.
- * 2 --- The CFG table is emitted and checks are performed.
+* - cfguard
+ - * 0 --- CFG is completely disabled.
+ * 1 --- The CFG table is emitted, but no checks are performed.
+ * 2 --- The CFG table is emitted and checks are performed.
- * - cfguard-mechanism
- - * 0 --- CFG uses the default mechanism for the architecture.
- * 1 --- CFG uses the "check" mechanism. This will result in a separate
- call to the checker function and then one to the target.
- * 2 --- CFG uses the "dispatch" mechanism. This calls a dispatcher
- function which both checks and then calls the target.
+* - cfguard-mechanism
+ - * 0 --- CFG uses the default mechanism for the architecture.
+ * 1 --- CFG uses the "check" mechanism. This will result in a separate
+ call to the checker function and then one to the target.
+ * 2 --- CFG uses the "dispatch" mechanism. This calls a dispatcher
+ function which both checks and then calls the target.
+```
-Other Module Flags
-------------------
+### Other Module Flags
-``require-logical-pointer``
- This flag indicates this module must only use logical pointer intrinsics
- such as :ref:`@llvm.structured.gep <i_structured_gep>` or
- :ref:`@llvm.structured.alloca <i_structured_alloca>`.
- Using a normal :ref:`getelementptr <i_getelementptr>` or
- :ref:`alloca <i_alloca>` is illegal.
+`require-logical-pointer`
+: This flag indicates this module must only use logical pointer intrinsics
+ such as {ref}`@llvm.structured.gep <i_structured_gep>` or
+ {ref}`@llvm.structured.alloca <i_structured_alloca>`.
+ Using a normal {ref}`getelementptr <i_getelementptr>` or
+ {ref}`alloca <i_alloca>` is illegal.
-Embedded Objects Names Metadata
-===============================
+## Embedded Objects Names Metadata
Offloading compilations need to embed device code into the host section table to
create a fat binary. This metadata node references each global that will be
embedded in the module. The primary use for this is to make referencing these
globals more efficient in the IR. The metadata references nodes containing
pointers to the global to be embedded followed by the section name it will be
-stored at::
-
- !llvm.embedded.objects = !{!0}
- !0 = !{ptr @object, !".section"}
+stored at:
+```
+!llvm.embedded.objects = !{!0}
+!0 = !{ptr @object, !".section"}
+```
-Automatic Linker Flags Named Metadata
-=====================================
+## Automatic Linker Flags Named Metadata
Some targets support embedding of flags to the linker inside individual object
files. Typically this is used in conjunction with language extensions which
@@ -9429,17 +9334,18 @@ allow source files to contain linker command-line options, and have these
automatically be transmitted to the linker via object files.
These flags are encoded in the IR using named metadata with the name
-``!llvm.linker.options``. Each operand is expected to be a metadata node
+`!llvm.linker.options`. Each operand is expected to be a metadata node
which should be a list of other metadata nodes, each of which should be a
list of metadata strings defining linker options.
For example, the following metadata section specifies two separate sets of
-linker options, presumably to link against ``libz`` and the ``Cocoa``
-framework::
-
- !0 = !{ !"-lz" }
- !1 = !{ !"-framework", !"Cocoa" }
- !llvm.linker.options = !{ !0, !1 }
+linker options, presumably to link against `libz` and the `Cocoa`
+framework:
+```
+!0 = !{ !"-lz" }
+!1 = !{ !"-framework", !"Cocoa" }
+!llvm.linker.options = !{ !0, !1 }
+```
The metadata encoding as lists of lists of options, as opposed to a collapsed
list of options, is chosen so that the IR encoding can use multiple option
@@ -9451,8 +9357,7 @@ Each individual option is required to be either a valid option for the target's
linker, or an option that is reserved by the target-specific assembly writer or
object file emitter. No other aspect of these options is defined by the IR.
-Dependent Libs Named Metadata
-=============================
+## Dependent Libs Named Metadata
Some targets support embedding of strings into object files to indicate
a set of libraries to add to the link. Typically this is used in conjunction
@@ -9461,53 +9366,53 @@ libraries they depend on, and have these automatically be transmitted to the
linker via object files.
The list is encoded in the IR using named metadata with the name
-``!llvm.dependent-libraries``. Each operand is expected to be a metadata node
+`!llvm.dependent-libraries`. Each operand is expected to be a metadata node
which should contain a single string operand.
-For example, the following metadata section contains two library specifiers::
-
- !0 = !{!"a library specifier"}
- !1 = !{!"another library specifier"}
- !llvm.dependent-libraries = !{ !0, !1 }
+For example, the following metadata section contains two library specifiers:
+```
+!0 = !{!"a library specifier"}
+!1 = !{!"another library specifier"}
+!llvm.dependent-libraries = !{ !0, !1 }
+```
Each library specifier will be handled independently by the consuming linker.
The effect of the library specifiers are defined by the consuming linker.
-'``llvm.errno.tbaa``' Named Metadata
-====================================
+## '`llvm.errno.tbaa`' Named Metadata
-The module-level ``!llvm.errno.tbaa`` metadata specifies the TBAA nodes used
-for accessing ``errno``. These nodes are guaranteed to represent int-compatible
+The module-level `!llvm.errno.tbaa` metadata specifies the TBAA nodes used
+for accessing `errno`. These nodes are guaranteed to represent int-compatible
accesses according to C/C++ strict aliasing rules. This should let LLVM alias
-analyses to reason about aliasing with ``errno`` when calling library functions
-that may set ``errno``, allowing optimizations such as store-to-load forwarding
+analyses to reason about aliasing with `errno` when calling library functions
+that may set `errno`, allowing optimizations such as store-to-load forwarding
across such routines.
For example, the following is a valid metadata specifying the TBAA information
-for an integer access::
-
- !llvm.errno.tbaa = !{!0}
- !0 = !{!1, !1, i64 0}
- !1 = !{!"int", !2, i64 0}
- !2 = !{!"omnipotent char", !3, i64 0}
- !3 = !{!"Simple C/C++ TBAA"}
+for an integer access:
+```
+!llvm.errno.tbaa = !{!0}
+!0 = !{!1, !1, i64 0}
+!1 = !{!"int", !2, i64 0}
+!2 = !{!"omnipotent char", !3, i64 0}
+!3 = !{!"Simple C/C++ TBAA"}
+```
Multiple TBAA operands are allowed to support merging of modules that may use
different TBAA hierarchies (e.g., when mixing C and C++).
-.. _summary:
+(summary)=
-ThinLTO Summary
-===============
+## ThinLTO Summary
-Compiling with `ThinLTO <https://clang.llvm.org/docs/ThinLTO.html>`_
+Compiling with [ThinLTO](https://clang.llvm.org/docs/ThinLTO.html)
causes the building of a compact summary of the module that is emitted into
the bitcode. The summary is emitted into the LLVM assembly and identified
-in syntax by a caret ('``^``').
+in syntax by a caret ('`^`').
The summary is parsed into a bitcode output, along with the Module
-IR, via the "``llvm-as``" tool. Tools that parse the Module IR for the purposes
-of optimization (e.g., "``clang -x ir``" and "``opt``"), will ignore the
+IR, via the "`llvm-as`" tool. Tools that parse the Module IR for the purposes
+of optimization (e.g., "`clang -x ir`" and "`opt`"), will ignore the
summary entries (just as they currently ignore summary entries in a bitcode
input file).
@@ -9515,19 +9420,18 @@ Eventually, the summary will be parsed into a ModuleSummaryIndex object under
the same conditions where summary index is currently built from bitcode.
Specifically, tools that test the Thin Link portion of a ThinLTO compile
(i.e., llvm-lto and llvm-lto2), or when parsing a combined index
-for a distributed ThinLTO backend via clang's "``-fthinlto-index=<>``" flag
+for a distributed ThinLTO backend via clang's "`-fthinlto-index=<>`" flag
(this part is not yet implemented, use llvm-as to create a bitcode object
before feeding into thin link tools for now).
There are currently 3 types of summary entries in the LLVM assembly:
-:ref:`module paths<module_path_summary>`,
-:ref:`global values<gv_summary>`, and
-:ref:`type identifiers<typeid_summary>`.
+{ref}`module paths<module_path_summary>`,
+{ref}`global values<gv_summary>`, and
+{ref}`type identifiers<typeid_summary>`.
-.. _module_path_summary:
+(module_path_summary)=
-Module Path Summary Entry
--------------------------
+### Module Path Summary Entry
Each module path summary entry lists a module containing global values included
in the summary. For a single IR module there will be one such entry, but
@@ -9536,409 +9440,390 @@ one module path entry per linked module with summary.
Example:
-.. code-block:: text
-
- ^0 = module: (path: "/path/to/file.o", hash: (2468601609, 1329373163, 1565878005, 638838075, 3148790418))
+```text
+^0 = module: (path: "/path/to/file.o", hash: (2468601609, 1329373163, 1565878005, 638838075, 3148790418))
+```
-The ``path`` field is a string path to the bitcode file, and the ``hash``
+The `path` field is a string path to the bitcode file, and the `hash`
field is the 160-bit SHA-1 hash of the IR bitcode contents, used for
incremental builds and caching.
-.. _gv_summary:
+(gv_summary)=
-Global Value Summary Entry
---------------------------
+### Global Value Summary Entry
Each global value summary entry corresponds to a global value defined or
referenced by a summarized module.
Example:
-.. code-block:: text
-
- ^4 = gv: (name: "f"[, summaries: (Summary)[, (Summary)]*]?) ; guid = 14740650423002898831
+```text
+^4 = gv: (name: "f"[, summaries: (Summary)[, (Summary)]*]?) ; guid = 14740650423002898831
+```
For declarations, there will not be a summary list. For definitions, a
global value will contain a list of summaries, one per module containing
a definition. There can be multiple entries in a combined summary index
for symbols with weak linkage.
-Each ``Summary`` format will depend on whether the global value is a
-:ref:`function<function_summary>`, :ref:`variable<variable_summary>`, or
-:ref:`alias<alias_summary>`.
-
-.. _function_summary:
+Each `Summary` format will depend on whether the global value is a
+{ref}`function<function_summary>`, {ref}`variable<variable_summary>`, or
+{ref}`alias<alias_summary>`.
-Function Summary
-^^^^^^^^^^^^^^^^
+(function_summary)=
-If the global value is a function, the ``Summary`` entry will look like:
+#### Function Summary
-.. code-block:: text
+If the global value is a function, the `Summary` entry will look like:
- function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2[, FuncFlags]?[, Calls]?[, TypeIdInfo]?[, Params]?[, Refs]?
+```text
+function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2[, FuncFlags]?[, Calls]?[, TypeIdInfo]?[, Params]?[, Refs]?
+```
-The ``module`` field includes the summary entry id for the module containing
-this definition, and the ``flags`` field contains information such as
+The `module` field includes the summary entry id for the module containing
+this definition, and the `flags` field contains information such as
the linkage type, a flag indicating whether it is legal to import the
definition, whether it is globally live and whether the linker resolved it
to a local definition (the latter two are populated during the thin link).
-The ``insts`` field contains the number of IR instructions in the function.
-Finally, there are several optional fields: :ref:`FuncFlags<funcflags_summary>`,
-:ref:`Calls<calls_summary>`, :ref:`TypeIdInfo<typeidinfo_summary>`,
-:ref:`Params<params_summary>`, :ref:`Refs<refs_summary>`.
+The `insts` field contains the number of IR instructions in the function.
+Finally, there are several optional fields: {ref}`FuncFlags<funcflags_summary>`,
+{ref}`Calls<calls_summary>`, {ref}`TypeIdInfo<typeidinfo_summary>`,
+{ref}`Params<params_summary>`, {ref}`Refs<refs_summary>`.
-.. _variable_summary:
+(variable_summary)=
-Global Variable Summary
-^^^^^^^^^^^^^^^^^^^^^^^
+#### Global Variable Summary
-If the global value is a variable, the ``Summary`` entry will look like:
+If the global value is a variable, the `Summary` entry will look like:
-.. code-block:: text
-
- variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0)[, Refs]?
+```text
+variable: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0)[, Refs]?
+```
The variable entry contains a subset of the fields in a
-:ref:`function summary <function_summary>`, see the descriptions there.
-
-.. _alias_summary:
+{ref}`function summary <function_summary>`, see the descriptions there.
-Alias Summary
-^^^^^^^^^^^^^
+(alias_summary)=
-If the global value is an alias, the ``Summary`` entry will look like:
+#### Alias Summary
-.. code-block:: text
+If the global value is an alias, the `Summary` entry will look like:
- alias: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), aliasee: ^2)
+```text
+alias: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), aliasee: ^2)
+```
-The ``module`` and ``flags`` fields are as described for a
-:ref:`function summary <function_summary>`. The ``aliasee`` field
+The `module` and `flags` fields are as described for a
+{ref}`function summary <function_summary>`. The `aliasee` field
contains a reference to the global value summary entry of the aliasee.
-.. _funcflags_summary:
+(funcflags_summary)=
-Function Flags
-^^^^^^^^^^^^^^
+#### Function Flags
-The optional ``FuncFlags`` field looks like:
+The optional `FuncFlags` field looks like:
-.. code-block:: text
+```text
+funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0)
+```
- funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0)
+If unspecified, flags are assumed to hold the conservative `false` value of
+`0`.
-If unspecified, flags are assumed to hold the conservative ``false`` value of
-``0``.
+(calls_summary)=
-.. _calls_summary:
+#### Calls
-Calls
-^^^^^
+The optional `Calls` field looks like:
-The optional ``Calls`` field looks like:
+```text
+calls: ((Callee)[, (Callee)]*)
+```
-.. code-block:: text
+where each `Callee` looks like:
- calls: ((Callee)[, (Callee)]*)
+```text
+callee: ^1[, hotness: None]?[, relbf: 0]?
+```
-where each ``Callee`` looks like:
-
-.. code-block:: text
-
- callee: ^1[, hotness: None]?[, relbf: 0]?
-
-The ``callee`` refers to the summary entry id of the callee. At most one
-of ``hotness`` (which can take the values ``Unknown``, ``Cold``, ``None``,
-``Hot``, and ``Critical``), and ``relbf`` (which holds the integer
+The `callee` refers to the summary entry id of the callee. At most one
+of `hotness` (which can take the values `Unknown`, `Cold`, `None`,
+`Hot`, and `Critical`), and `relbf` (which holds the integer
branch frequency relative to the entry frequency, scaled down by 2^8)
-may be specified. The defaults are ``Unknown`` and ``0``, respectively.
-
-.. _params_summary:
+may be specified. The defaults are `Unknown` and `0`, respectively.
-Params
-^^^^^^
+(params_summary)=
-The optional ``Params`` is used by ``StackSafety`` and looks like:
+#### Params
-.. code-block:: text
+The optional `Params` is used by `StackSafety` and looks like:
- Params: ((Param)[, (Param)]*)
+```text
+Params: ((Param)[, (Param)]*)
+```
-where each ``Param`` describes pointer parameter access inside of the
+where each `Param` describes pointer parameter access inside of the
function and looks like:
-.. code-block:: text
+```text
+param: 4, offset: [0, 5][, calls: ((Callee)[, (Callee)]*)]?
+```
- param: 4, offset: [0, 5][, calls: ((Callee)[, (Callee)]*)]?
-
-where the first ``param`` is the number of the parameter it describes,
-``offset`` is the inclusive range of offsets from the pointer parameter to bytes
+where the first `param` is the number of the parameter it describes,
+`offset` is the inclusive range of offsets from the pointer parameter to bytes
which can be accessed by the function. This range does not include accesses by
-function calls from ``calls`` list.
+function calls from `calls` list.
-where each ``Callee`` describes how parameter is forwarded into other
+where each `Callee` describes how parameter is forwarded into other
functions and looks like:
-.. code-block:: text
-
- callee: ^3, param: 5, offset: [-3, 3]
+```text
+callee: ^3, param: 5, offset: [-3, 3]
+```
-The ``callee`` refers to the summary entry id of the callee, ``param`` is
+The `callee` refers to the summary entry id of the callee, `param` is
the number of the callee parameter which points into the callers parameter
-with offset known to be inside of the ``offset`` range. ``calls`` will be
-consumed and removed by thin link stage to update ``Param::offset`` so it
-covers all accesses possible by ``calls``.
+with offset known to be inside of the `offset` range. `calls` will be
+consumed and removed by thin link stage to update `Param::offset` so it
+covers all accesses possible by `calls`.
-Pointer parameter without corresponding ``Param`` is considered unsafe and we
+Pointer parameter without corresponding `Param` is considered unsafe and we
assume that access with any offset is possible.
Example:
If we have the following function:
-.. code-block:: text
-
- define i64 @foo(ptr %0, ptr %1, ptr %2, i8 %3) {
- store ptr %1, ptr @x
- %5 = getelementptr inbounds i8, ptr %2, i64 5
- %6 = load i8, ptr %5
- %7 = getelementptr inbounds i8, ptr %2, i8 %3
- tail call void @bar(i8 %3, ptr %7)
- %8 = load i64, ptr %0
- ret i64 %8
- }
+```text
+define i64 @foo(ptr %0, ptr %1, ptr %2, i8 %3) {
+ store ptr %1, ptr @x
+ %5 = getelementptr inbounds i8, ptr %2, i64 5
+ %6 = load i8, ptr %5
+ %7 = getelementptr inbounds i8, ptr %2, i8 %3
+ tail call void @bar(i8 %3, ptr %7)
+ %8 = load i64, ptr %0
+ ret i64 %8
+}
+```
We can expect the record like this:
-.. code-block:: text
-
- params: ((param: 0, offset: [0, 7]),(param: 2, offset: [5, 5], calls: ((callee: ^3, param: 1, offset: [-128, 127]))))
+```text
+params: ((param: 0, offset: [0, 7]),(param: 2, offset: [5, 5], calls: ((callee: ^3, param: 1, offset: [-128, 127]))))
+```
-The function may access just 8 bytes of the parameter %0 . ``calls`` is empty,
-so the parameter is either not used for function calls or ``offset`` already
+The function may access just 8 bytes of the parameter %0 . `calls` is empty,
+so the parameter is either not used for function calls or `offset` already
covers all accesses from nested function calls.
Parameter %1 escapes, so access is unknown.
The function itself can access just a single byte of the parameter %2. Additional
-access is possible inside of the ``@bar`` or ``^3``. The function adds signed
-offset to the pointer and passes the result as the argument %1 into ``^3``.
-This record itself does not tell us how ``^3`` will access the parameter.
+access is possible inside of the `@bar` or `^3`. The function adds signed
+offset to the pointer and passes the result as the argument %1 into `^3`.
+This record itself does not tell us how `^3` will access the parameter.
Parameter %3 is not a pointer.
-.. _refs_summary:
+(refs_summary)=
-Refs
-^^^^
+#### Refs
-The optional ``Refs`` field looks like:
+The optional `Refs` field looks like:
-.. code-block:: text
+```text
+refs: ((Ref)[, (Ref)]*)
+```
- refs: ((Ref)[, (Ref)]*)
+where each `Ref` contains a reference to the summary id of the referenced
+value (e.g., `^1`).
-where each ``Ref`` contains a reference to the summary id of the referenced
-value (e.g., ``^1``).
+(typeidinfo_summary)=
-.. _typeidinfo_summary:
+#### TypeIdInfo
-TypeIdInfo
-^^^^^^^^^^
-
-The optional ``TypeIdInfo`` field, used for
-`Control Flow Integrity <https://clang.llvm.org/docs/ControlFlowIntegrity.html>`_,
+The optional `TypeIdInfo` field, used for
+[Control Flow Integrity](https://clang.llvm.org/docs/ControlFlowIntegrity.html),
looks like:
-.. code-block:: text
-
- typeIdInfo: [(TypeTests)]?[, (TypeTestAssumeVCalls)]?[, (TypeCheckedLoadVCalls)]?[, (TypeTestAssumeConstVCalls)]?[, (TypeCheckedLoadConstVCalls)]?
+```text
+typeIdInfo: [(TypeTests)]?[, (TypeTestAssumeVCalls)]?[, (TypeCheckedLoadVCalls)]?[, (TypeTestAssumeConstVCalls)]?[, (TypeCheckedLoadConstVCalls)]?
+```
These optional fields have the following forms:
-TypeTests
-"""""""""
-
-.. code-block:: text
-
- typeTests: (TypeIdRef[, TypeIdRef]*)
+##### TypeTests
-Where each ``TypeIdRef`` refers to a :ref:`type id<typeid_summary>`
-by summary id or ``GUID``.
+```text
+typeTests: (TypeIdRef[, TypeIdRef]*)
+```
-TypeTestAssumeVCalls
-""""""""""""""""""""
+Where each `TypeIdRef` refers to a {ref}`type id<typeid_summary>`
+by summary id or `GUID`.
-.. code-block:: text
+##### TypeTestAssumeVCalls
- typeTestAssumeVCalls: (VFuncId[, VFuncId]*)
+```text
+typeTestAssumeVCalls: (VFuncId[, VFuncId]*)
+```
Where each VFuncId has the format:
-.. code-block:: text
+```text
+vFuncId: (TypeIdRef, offset: 16)
+```
- vFuncId: (TypeIdRef, offset: 16)
+Where each `TypeIdRef` refers to a {ref}`type id<typeid_summary>`
+by summary id or `GUID` preceded by a `guid:` tag.
-Where each ``TypeIdRef`` refers to a :ref:`type id<typeid_summary>`
-by summary id or ``GUID`` preceded by a ``guid:`` tag.
+##### TypeCheckedLoadVCalls
-TypeCheckedLoadVCalls
-"""""""""""""""""""""
+```text
+typeCheckedLoadVCalls: (VFuncId[, VFuncId]*)
+```
-.. code-block:: text
+Where each VFuncId has the format described for `TypeTestAssumeVCalls`.
- typeCheckedLoadVCalls: (VFuncId[, VFuncId]*)
+##### TypeTestAssumeConstVCalls
-Where each VFuncId has the format described for ``TypeTestAssumeVCalls``.
-
-TypeTestAssumeConstVCalls
-"""""""""""""""""""""""""
-
-.. code-block:: text
-
- typeTestAssumeConstVCalls: (ConstVCall[, ConstVCall]*)
+```text
+typeTestAssumeConstVCalls: (ConstVCall[, ConstVCall]*)
+```
Where each ConstVCall has the format:
-.. code-block:: text
-
- (VFuncId, args: (Arg[, Arg]*))
+```text
+(VFuncId, args: (Arg[, Arg]*))
+```
-and where each VFuncId has the format described for ``TypeTestAssumeVCalls``,
+and where each VFuncId has the format described for `TypeTestAssumeVCalls`,
and each Arg is an integer argument number.
-TypeCheckedLoadConstVCalls
-""""""""""""""""""""""""""
+##### TypeCheckedLoadConstVCalls
-.. code-block:: text
-
- typeCheckedLoadConstVCalls: (ConstVCall[, ConstVCall]*)
+```text
+typeCheckedLoadConstVCalls: (ConstVCall[, ConstVCall]*)
+```
Where each ConstVCall has the format described for
-``TypeTestAssumeConstVCalls``.
+`TypeTestAssumeConstVCalls`.
-.. _typeid_summary:
+(typeid_summary)=
-Type ID Summary Entry
----------------------
+### Type ID Summary Entry
Each type id summary entry corresponds to a type identifier resolution
which is generated during the LTO link portion of the compile when building
-with `Control Flow Integrity <https://clang.llvm.org/docs/ControlFlowIntegrity.html>`_,
+with [Control Flow Integrity](https://clang.llvm.org/docs/ControlFlowIntegrity.html),
so these are only present in a combined summary index.
Example:
-.. code-block:: text
-
- ^4 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7[, alignLog2: 0]?[, sizeM1: 0]?[, bitMask: 0]?[, inlineBits: 0]?)[, WpdResolutions]?)) ; guid = 7004155349499253778
+```text
+^4 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7[, alignLog2: 0]?[, sizeM1: 0]?[, bitMask: 0]?[, inlineBits: 0]?)[, WpdResolutions]?)) ; guid = 7004155349499253778
+```
-The ``typeTestRes`` gives the type test resolution ``kind`` (which may
-be ``unsat``, ``byteArray``, ``inline``, ``single``, or ``allOnes``), and
-the ``size-1`` bit width. It is followed by optional flags, which default to 0,
+The `typeTestRes` gives the type test resolution `kind` (which may
+be `unsat`, `byteArray`, `inline`, `single`, or `allOnes`), and
+the `size-1` bit width. It is followed by optional flags, which default to 0,
and an optional WpdResolutions (whole program devirtualization resolution)
field that looks like:
-.. code-block:: text
-
- wpdResolutions: ((offset: 0, WpdRes)[, (offset: 1, WpdRes)]*
+```text
+wpdResolutions: ((offset: 0, WpdRes)[, (offset: 1, WpdRes)]*
+```
where each entry is a mapping from the given byte offset to the whole-program
devirtualization resolution WpdRes, that has one of the following formats:
-.. code-block:: text
-
- wpdRes: (kind: branchFunnel)
- wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi")
- wpdRes: (kind: indir)
+```text
+wpdRes: (kind: branchFunnel)
+wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi")
+wpdRes: (kind: indir)
+```
-Additionally, each wpdRes has an optional ``resByArg`` field, which
+Additionally, each wpdRes has an optional `resByArg` field, which
describes the resolutions for calls with all constant integer arguments:
-.. code-block:: text
-
- resByArg: (ResByArg[, ResByArg]*)
+```text
+resByArg: (ResByArg[, ResByArg]*)
+```
where ResByArg is:
-.. code-block:: text
-
- args: (Arg[, Arg]*), byArg: (kind: UniformRetVal[, info: 0][, byte: 0][, bit: 0])
+```text
+args: (Arg[, Arg]*), byArg: (kind: UniformRetVal[, info: 0][, byte: 0][, bit: 0])
+```
-Where the ``kind`` can be ``Indir``, ``UniformRetVal``, ``UniqueRetVal``
-or ``VirtualConstProp``. The ``info`` field is only used if the kind
-is ``UniformRetVal`` (indicates the uniform return value), or
-``UniqueRetVal`` (holds the return value associated with the unique vtable
-(0 or 1)). The ``byte`` and ``bit`` fields are only used if the target does
+Where the `kind` can be `Indir`, `UniformRetVal`, `UniqueRetVal`
+or `VirtualConstProp`. The `info` field is only used if the kind
+is `UniformRetVal` (indicates the uniform return value), or
+`UniqueRetVal` (holds the return value associated with the unique vtable
+(0 or 1)). The `byte` and `bit` fields are only used if the target does
not support the use of absolute symbols to store constants.
-.. _intrinsicglobalvariables:
+(intrinsicglobalvariables)=
-Intrinsic Global Variables
-==========================
+## Intrinsic Global Variables
LLVM has a number of "magic" global variables that contain data that
affect code generation or other IR semantics. These are documented here.
All globals of this sort should have a section specified as
-"``llvm.metadata``". This section and all globals that start with
-"``llvm.``" are reserved for use by LLVM.
+"`llvm.metadata`". This section and all globals that start with
+"`llvm.`" are reserved for use by LLVM.
-.. _gv_llvmused:
+(gv_llvmused)=
-The '``llvm.used``' Global Variable
------------------------------------
+### The '`llvm.used`' Global Variable
-The ``@llvm.used`` global is an array which has
-:ref:`appending linkage <linkage_appending>`. This array contains a list of
+The `@llvm.used` global is an array which has
+{ref}`appending linkage <linkage_appending>`. This array contains a list of
pointers to named global variables, functions and aliases which may optionally
have a pointer cast formed of bitcast or getelementptr. For example, a legal
use of it is:
-.. code-block:: llvm
+```llvm
+ at X = global i8 4
+ at Y = global i32 123
- @X = global i8 4
- @Y = global i32 123
+ at llvm.used = appending global [2 x ptr] [
+ ptr @X,
+ ptr @Y
+], section "llvm.metadata"
+```
- @llvm.used = appending global [2 x ptr] [
- ptr @X,
- ptr @Y
- ], section "llvm.metadata"
-
-If a symbol appears in the ``@llvm.used`` list, then the compiler, assembler,
+If a symbol appears in the `@llvm.used` list, then the compiler, assembler,
and linker are required to treat the symbol as if there is a reference to the
symbol that it cannot see (which is why they have to be named). For example, if
a variable has internal linkage and no references other than that from the
-``@llvm.used`` list, it cannot be deleted. This is commonly used to represent
+`@llvm.used` list, it cannot be deleted. This is commonly used to represent
references from inline asms and other things the compiler cannot "see", and
-corresponds to "``attribute((used))``" in GNU C.
+corresponds to "`attribute((used))`" in GNU C.
On some targets, the code generator must emit a directive to the
assembler or object file to prevent the assembler and linker from
removing the symbol.
-.. _gv_llvmcompilerused:
+(gv_llvmcompilerused)=
-The '``llvm.compiler.used``' Global Variable
---------------------------------------------
+### The '`llvm.compiler.used`' Global Variable
-The ``@llvm.compiler.used`` directive is the same as the ``@llvm.used``
+The `@llvm.compiler.used` directive is the same as the `@llvm.used`
directive, except that it only prevents the compiler from touching the
symbol. On targets that support it, this allows an intelligent linker to
optimize references to the symbol without being impeded as it would be
-by ``@llvm.used``.
+by `@llvm.used`.
This is a rare construct that should only be used in rare circumstances,
and should not be exposed to source languages.
-.. _gv_llvmglobalctors:
-
-The '``llvm.global_ctors``' Global Variable
--------------------------------------------
+(gv_llvmglobalctors)=
-.. code-block:: llvm
+### The '`llvm.global_ctors`' Global Variable
- %0 = type { i32, ptr, ptr }
- @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @data }]
+```llvm
+%0 = type { i32, ptr, ptr }
+ at llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @data }]
+```
-The ``@llvm.global_ctors`` array contains a list of constructor
+The `@llvm.global_ctors` array contains a list of constructor
functions, priorities, and an associated global or function.
The functions referenced by this array will be called in ascending order
of priority (i.e., lowest first) when the module is loaded. The order of
@@ -9949,17 +9834,16 @@ or function, the initializer function will only run if the associated
data from the current module is not discarded.
On ELF the referenced global variable or function must be in a comdat.
-.. _llvmglobaldtors:
+(llvmglobaldtors)=
-The '``llvm.global_dtors``' Global Variable
--------------------------------------------
+### The '`llvm.global_dtors`' Global Variable
-.. code-block:: llvm
+```llvm
+%0 = type { i32, ptr, ptr }
+ at llvm.global_dtors = appending global [1 x %0] [%0 { i32 65535, ptr @dtor, ptr @data }]
+```
- %0 = type { i32, ptr, ptr }
- @llvm.global_dtors = appending global [1 x %0] [%0 { i32 65535, ptr @dtor, ptr @data }]
-
-The ``@llvm.global_dtors`` array contains a list of destructor
+The `@llvm.global_dtors` array contains a list of destructor
functions, priorities, and an associated global or function.
The functions referenced by this array will be called in descending
order of priority (i.e., highest first) when the module is unloaded. The
@@ -9970,235 +9854,206 @@ or function, the destructor function will only run if the associated
data from the current module is not discarded.
On ELF the referenced global variable or function must be in a comdat.
-Instruction Reference
-=====================
+## Instruction Reference
The LLVM instruction set consists of several different classifications
-of instructions: :ref:`terminator instructions <terminators>`, :ref:`binary
-instructions <binaryops>`, :ref:`bitwise binary
-instructions <bitwiseops>`, :ref:`memory instructions <memoryops>`, and
-:ref:`other instructions <otherops>`. There are also :ref:`debug records
-<debugrecords>`, which are not instructions themselves but are printed
+of instructions: {ref}`terminator instructions <terminators>`, {ref}`binary instructions <binaryops>`, {ref}`bitwise binary instructions <bitwiseops>`, {ref}`memory instructions <memoryops>`, and
+{ref}`other instructions <otherops>`. There are also {ref}`debug records <debugrecords>`, which are not instructions themselves but are printed
interleaved with instructions to describe changes in the state of the program's
debug information at each position in the program's execution.
-.. _terminators:
+(terminators)=
-Terminator Instructions
------------------------
+### Terminator Instructions
-As mentioned :ref:`previously <functionstructure>`, every basic block in a
+As mentioned {ref}`previously <functionstructure>`, every basic block in a
program ends with a "Terminator" instruction, which indicates which
block should be executed after the current block is finished. These
-terminator instructions typically yield a '``void``' value: they produce
+terminator instructions typically yield a '`void`' value: they produce
control flow, not values (the one exception being the
-':ref:`invoke <i_invoke>`' instruction).
-
-The terminator instructions are: ':ref:`ret <i_ret>`',
-':ref:`br <i_br>`', ':ref:`switch <i_switch>`',
-':ref:`indirectbr <i_indirectbr>`', ':ref:`invoke <i_invoke>`',
-':ref:`callbr <i_callbr>`'
-':ref:`resume <i_resume>`', ':ref:`catchswitch <i_catchswitch>`',
-':ref:`catchret <i_catchret>`',
-':ref:`cleanupret <i_cleanupret>`',
-and ':ref:`unreachable <i_unreachable>`'.
+'{ref}`invoke <i_invoke>`' instruction).
-.. _i_ret:
+The terminator instructions are: '{ref}`ret <i_ret>`',
+'{ref}`br <i_br>`', '{ref}`switch <i_switch>`',
+'{ref}`indirectbr <i_indirectbr>`', '{ref}`invoke <i_invoke>`',
+'{ref}`callbr <i_callbr>`'
+'{ref}`resume <i_resume>`', '{ref}`catchswitch <i_catchswitch>`',
+'{ref}`catchret <i_catchret>`',
+'{ref}`cleanupret <i_cleanupret>`',
+and '{ref}`unreachable <i_unreachable>`'.
-'``ret``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+(i_ret)=
-Syntax:
-"""""""
+#### '`ret`' Instruction
-::
+##### Syntax:
- ret <type> <value> ; Return a value from a non-void function
- ret void ; Return from void function
+```
+ret <type> <value> ; Return a value from a non-void function
+ret void ; Return from void function
+```
-Overview:
-"""""""""
+##### Overview:
-The '``ret``' instruction is used to return control flow (and optionally
+The '`ret`' instruction is used to return control flow (and optionally
a value) from a function back to the caller.
-There are two forms of the '``ret``' instruction: one that returns a
+There are two forms of the '`ret`' instruction: one that returns a
value and then causes control flow, and one that just causes control
flow to occur.
-Arguments:
-""""""""""
+##### Arguments:
-The '``ret``' instruction optionally accepts a single argument, the
-return value. The type of the return value must be a ':ref:`first
-class <t_firstclass>`' type.
+The '`ret`' instruction optionally accepts a single argument, the
+return value. The type of the return value must be a '{ref}`first class <t_firstclass>`' type.
-A function is not :ref:`well formed <wellformed>` if it has a non-void
-return type and contains a '``ret``' instruction with no return value or
+A function is not {ref}`well formed <wellformed>` if it has a non-void
+return type and contains a '`ret`' instruction with no return value or
a return value with a type that does not match its type, or if it has a
-void return type and contains a '``ret``' instruction with a return
+void return type and contains a '`ret`' instruction with a return
value.
-Semantics:
-""""""""""
+##### Semantics:
-When the '``ret``' instruction is executed, control flow returns back to
+When the '`ret`' instruction is executed, control flow returns back to
the calling function's context. If the caller is a
-":ref:`call <i_call>`" instruction, execution continues at the
+"{ref}`call <i_call>`" instruction, execution continues at the
instruction after the call. If the caller was an
-":ref:`invoke <i_invoke>`" instruction, execution continues at the
+"{ref}`invoke <i_invoke>`" instruction, execution continues at the
beginning of the "normal" destination block. If the instruction returns
a value, that value shall set the call or invoke instruction's return
value.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- ret i32 5 ; Return an integer value of 5
- ret void ; Return from a void function
- ret { i32, i8 } { i32 4, i8 2 } ; Return a struct of values 4 and 2
+##### Example:
-.. _i_br:
+```llvm
+ret i32 5 ; Return an integer value of 5
+ret void ; Return from a void function
+ret { i32, i8 } { i32 4, i8 2 } ; Return a struct of values 4 and 2
+```
-'``br``' Instruction
-^^^^^^^^^^^^^^^^^^^^
+(i_br)=
-Syntax:
-"""""""
+#### '`br`' Instruction
-::
+##### Syntax:
- br i1 <cond>, label <iftrue>, label <iffalse>
- br label <dest> ; Unconditional branch
+```
+br i1 <cond>, label <iftrue>, label <iffalse>
+br label <dest> ; Unconditional branch
+```
-Overview:
-"""""""""
+##### Overview:
-The '``br``' instruction is used to cause control flow to transfer to a
+The '`br`' instruction is used to cause control flow to transfer to a
different basic block in the current function. There are two forms of
this instruction, corresponding to a conditional branch and an
unconditional branch.
-Arguments:
-""""""""""
+##### Arguments:
-The conditional branch form of the '``br``' instruction takes a single
-'``i1``' value and two '``label``' values. The unconditional form of the
-'``br``' instruction takes a single '``label``' value as a target.
+The conditional branch form of the '`br`' instruction takes a single
+'`i1`' value and two '`label`' values. The unconditional form of the
+'`br`' instruction takes a single '`label`' value as a target.
-Semantics:
-""""""""""
+##### Semantics:
-Upon execution of a conditional '``br``' instruction, the '``i1``'
-argument is evaluated. If the value is ``true``, control flows to the
-'``iftrue``' ``label`` argument. If "cond" is ``false``, control flows
-to the '``iffalse``' ``label`` argument.
-If '``cond``' is ``poison`` or ``undef``, this instruction has undefined
+Upon execution of a conditional '`br`' instruction, the '`i1`'
+argument is evaluated. If the value is `true`, control flows to the
+'`iftrue`' `label` argument. If "cond" is `false`, control flows
+to the '`iffalse`' `label` argument.
+If '`cond`' is `poison` or `undef`, this instruction has undefined
behavior.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- Test:
- %cond = icmp eq i32 %a, %b
- br i1 %cond, label %IfEqual, label %IfUnequal
- IfEqual:
- ret i32 1
- IfUnequal:
- ret i32 0
+##### Example:
-.. _i_switch:
+```llvm
+Test:
+ %cond = icmp eq i32 %a, %b
+ br i1 %cond, label %IfEqual, label %IfUnequal
+IfEqual:
+ ret i32 1
+IfUnequal:
+ ret i32 0
+```
-'``switch``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+(i_switch)=
-Syntax:
-"""""""
+#### '`switch`' Instruction
-::
+##### Syntax:
- switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ]
+```
+switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ]
+```
-Overview:
-"""""""""
+##### Overview:
-The '``switch``' instruction is used to transfer control flow to one of
-several different places. It is a generalization of the '``br``'
+The '`switch`' instruction is used to transfer control flow to one of
+several different places. It is a generalization of the '`br`'
instruction, allowing a branch to occur to one of many possible
destinations.
-Arguments:
-""""""""""
+##### Arguments:
-The '``switch``' instruction uses three parameters: an integer
-comparison value '``value``', a default '``label``' destination, and an
-array of pairs of comparison value constants and '``label``'s. The table
+The '`switch`' instruction uses three parameters: an integer
+comparison value '`value`', a default '`label`' destination, and an
+array of pairs of comparison value constants and '`label`'s. The table
is not allowed to contain duplicate constant entries.
-Semantics:
-""""""""""
+##### Semantics:
-The ``switch`` instruction specifies a table of values and destinations.
-When the '``switch``' instruction is executed, this table is searched
+The `switch` instruction specifies a table of values and destinations.
+When the '`switch`' instruction is executed, this table is searched
for the given value. If the value is found, control flow is transferred
to the corresponding destination; otherwise, control flow is transferred
to the default destination.
-If '``value``' is ``poison`` or ``undef``, this instruction has undefined
+If '`value`' is `poison` or `undef`, this instruction has undefined
behavior.
-Implementation:
-"""""""""""""""
+##### Implementation:
Depending on properties of the target machine and the particular
-``switch`` instruction, this instruction may be code generated in
+`switch` instruction, this instruction may be code generated in
different ways. For example, it could be generated as a series of
chained conditional branches or with a lookup table.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- ; Emulate a conditional br instruction
- %Val = zext i1 %value to i32
- switch i32 %Val, label %truedest [ i32 0, label %falsedest ]
+##### Example:
- ; Emulate an unconditional br instruction
- switch i32 0, label %dest [ ]
+```llvm
+; Emulate a conditional br instruction
+%Val = zext i1 %value to i32
+switch i32 %Val, label %truedest [ i32 0, label %falsedest ]
- ; Implement a jump table:
- switch i32 %val, label %otherwise [ i32 0, label %onzero
- i32 1, label %onone
- i32 2, label %ontwo ]
+; Emulate an unconditional br instruction
+switch i32 0, label %dest [ ]
-.. _i_indirectbr:
+; Implement a jump table:
+switch i32 %val, label %otherwise [ i32 0, label %onzero
+ i32 1, label %onone
+ i32 2, label %ontwo ]
+```
-'``indirectbr``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_indirectbr)=
-Syntax:
-"""""""
+#### '`indirectbr`' Instruction
-::
+##### Syntax:
- indirectbr ptr <address>, [ label <dest1>, label <dest2>, ... ]
+```
+indirectbr ptr <address>, [ label <dest1>, label <dest2>, ... ]
+```
-Overview:
-"""""""""
+##### Overview:
-The '``indirectbr``' instruction implements an indirect branch to a
+The '`indirectbr`' instruction implements an indirect branch to a
label within the current function, whose address is specified by
-"``address``". Address must be derived from a
-:ref:`blockaddress <blockaddress>` constant.
+"`address`". Address must be derived from a
+{ref}`blockaddress <blockaddress>` constant.
-Arguments:
-""""""""""
+##### Arguments:
-The '``address``' argument is the address of the label to jump to. The
+The '`address`' argument is the address of the label to jump to. The
rest of the arguments indicate the full set of possible destinations
that the address may point to. Blocks are allowed to occur multiple
times in the destination list, though this isn't particularly useful.
@@ -10206,1044 +10061,916 @@ times in the destination list, though this isn't particularly useful.
This destination list is required so that dataflow analysis has an
accurate understanding of the CFG.
-Semantics:
-""""""""""
+##### Semantics:
Control transfers to the block specified in the address argument. All
possible destination blocks must be listed in the label list, otherwise
this instruction has undefined behavior. This implies that jumps to
labels defined in other functions have undefined behavior as well.
-If '``address``' is ``poison`` or ``undef``, this instruction has undefined
+If '`address`' is `poison` or `undef`, this instruction has undefined
behavior.
-Implementation:
-"""""""""""""""
+##### Implementation:
This is typically implemented with a jump through a register.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- indirectbr ptr %Addr, [ label %bb1, label %bb2, label %bb3 ]
+##### Example:
-.. _i_invoke:
+```llvm
+indirectbr ptr %Addr, [ label %bb1, label %bb2, label %bb3 ]
+```
-'``invoke``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+(i_invoke)=
-Syntax:
-"""""""
+#### '`invoke`' Instruction
-::
+##### Syntax:
- <result> = invoke [cconv] [ret attrs] [addrspace(<num>)] <ty>|<fnty> <fnptrval>(<function args>) [fn attrs]
- [operand bundles] to label <normal label> unwind label <exception label>
+```
+<result> = invoke [cconv] [ret attrs] [addrspace(<num>)] <ty>|<fnty> <fnptrval>(<function args>) [fn attrs]
+ [operand bundles] to label <normal label> unwind label <exception label>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``invoke``' instruction causes control to transfer to a specified
+The '`invoke`' instruction causes control to transfer to a specified
function, with the possibility of control flow transfer to either the
-'``normal``' label or the '``exception``' label. If the callee function
-returns with the "``ret``" instruction, control flow will return to the
+'`normal`' label or the '`exception`' label. If the callee function
+returns with the "`ret`" instruction, control flow will return to the
"normal" label. If the callee (or any indirect callees) returns via the
-":ref:`resume <i_resume>`" instruction or other exception handling
+"{ref}`resume <i_resume>`" instruction or other exception handling
mechanism, control is interrupted and continued at the dynamically
nearest "exception" label.
-The '``exception``' label is a `landing
-pad <ExceptionHandling.html#overview>`_ for the exception. As such,
-'``exception``' label is required to have the
-":ref:`landingpad <i_landingpad>`" instruction, which contains the
+The '`exception`' label is a [landing
+pad](ExceptionHandling.md#overview) for the exception. As such,
+'`exception`' label is required to have the
+"{ref}`landingpad <i_landingpad>`" instruction, which contains the
information about the behavior of the program after unwinding happens,
as its first non-PHI instruction. The restrictions on the
-"``landingpad``" instruction's tightly couples it to the "``invoke``"
+"`landingpad`" instruction's tightly couples it to the "`invoke`"
instruction, so that the important information contained within the
-"``landingpad``" instruction can't be lost through normal code motion.
+"`landingpad`" instruction can't be lost through normal code motion.
-Arguments:
-""""""""""
+##### Arguments:
This instruction requires several arguments:
-#. The optional "cconv" marker indicates which :ref:`calling
- convention <callingconv>` the call should use. If none is
+1. The optional "cconv" marker indicates which {ref}`calling convention <callingconv>` the call should use. If none is
specified, the call defaults to using C calling conventions.
-#. The optional :ref:`Parameter Attributes <paramattrs>` list for return
- values. Only '``zeroext``', '``signext``', '``noext``', and '``inreg``'
+1. The optional {ref}`Parameter Attributes <paramattrs>` list for return
+ values. Only '`zeroext`', '`signext`', '`noext`', and '`inreg`'
attributes are valid here.
-#. The optional addrspace attribute can be used to indicate the address space
+1. The optional addrspace attribute can be used to indicate the address space
of the called function. If it is not specified, the program address space
- from the :ref:`datalayout string<langref_datalayout>` will be used.
-#. '``ty``': the type of the call instruction itself which is also the
+ from the {ref}`datalayout string<langref_datalayout>` will be used.
+1. '`ty`': the type of the call instruction itself which is also the
type of the return value. Functions that return no value are marked
- ``void``. The signature is computed based on the return type and argument
+ `void`. The signature is computed based on the return type and argument
types.
-#. '``fnty``': shall be the signature of the function being invoked. The
+1. '`fnty`': shall be the signature of the function being invoked. The
argument types must match the types implied by this signature. This
is only required if the signature specifies a varargs type.
-#. '``fnptrval``': An LLVM value containing a pointer to a function to
+1. '`fnptrval`': An LLVM value containing a pointer to a function to
be invoked. In most cases, this is a direct function invocation, but
- indirect ``invoke``'s are just as possible, calling an arbitrary pointer
+ indirect `invoke`'s are just as possible, calling an arbitrary pointer
to function value.
-#. '``function args``': argument list whose types match the function
+1. '`function args`': argument list whose types match the function
signature argument types and parameter attributes. All arguments must
- be of :ref:`first class <t_firstclass>` type. If the function signature
+ be of {ref}`first class <t_firstclass>` type. If the function signature
indicates the function accepts a variable number of arguments, the
extra arguments can be specified.
-#. '``normal label``': the label reached when the called function
- executes a '``ret``' instruction.
-#. '``exception label``': the label reached when a callee returns via
- the :ref:`resume <i_resume>` instruction or other exception handling
+1. '`normal label`': the label reached when the called function
+ executes a '`ret`' instruction.
+1. '`exception label`': the label reached when a callee returns via
+ the {ref}`resume <i_resume>` instruction or other exception handling
mechanism.
-#. The optional :ref:`function attributes <fnattrs>` list.
-#. The optional :ref:`operand bundles <opbundles>` list.
+1. The optional {ref}`function attributes <fnattrs>` list.
+1. The optional {ref}`operand bundles <opbundles>` list.
-Semantics:
-""""""""""
+##### Semantics:
-This instruction is designed to operate as a standard '``call``'
+This instruction is designed to operate as a standard '`call`'
instruction in most regards. The primary difference is that it
establishes an association with a label, which is used by the runtime
library to unwind the stack.
This instruction is used in languages with destructors to ensure that
-proper cleanup is performed in the case of either a ``longjmp`` or a
+proper cleanup is performed in the case of either a `longjmp` or a
thrown exception. Additionally, this is important for implementation of
-'``catch``' clauses in high-level languages that support them.
+'`catch`' clauses in high-level languages that support them.
For the purposes of the SSA form, the definition of the value returned
-by the '``invoke``' instruction is deemed to occur on the edge from the
+by the '`invoke`' instruction is deemed to occur on the edge from the
current block to the "normal" label. If the callee unwinds then no
return value is available.
-Example:
-""""""""
+##### Example:
-.. code-block:: llvm
+```llvm
+%retval = invoke i32 @Test(i32 15) to label %Continue
+ unwind label %TestCleanup ; i32:retval set
+%retval = invoke coldcc i32 %Testfnptr(i32 15) to label %Continue
+ unwind label %TestCleanup ; i32:retval set
+```
- %retval = invoke i32 @Test(i32 15) to label %Continue
- unwind label %TestCleanup ; i32:retval set
- %retval = invoke coldcc i32 %Testfnptr(i32 15) to label %Continue
- unwind label %TestCleanup ; i32:retval set
+(i_callbr)=
-.. _i_callbr:
+#### '`callbr`' Instruction
-'``callbr``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+<result> = callbr [cconv] [ret attrs] [addrspace(<num>)] <ty>|<fnty> <fnptrval>(<function args>) [fn attrs]
+ [operand bundles] to label <fallthrough label> [indirect labels]
+```
- <result> = callbr [cconv] [ret attrs] [addrspace(<num>)] <ty>|<fnty> <fnptrval>(<function args>) [fn attrs]
- [operand bundles] to label <fallthrough label> [indirect labels]
+##### Overview:
-Overview:
-"""""""""
-
-The '``callbr``' instruction causes control to transfer to a specified
+The '`callbr`' instruction causes control to transfer to a specified
function, with the possibility of control flow transfer to either the
-'``fallthrough``' label or one of the '``indirect``' labels.
+'`fallthrough`' label or one of the '`indirect`' labels.
This instruction can currently only be used
-#. to implement the "goto" feature of gcc style inline assembly or
-#. to call selected intrinsics.
+1. to implement the "goto" feature of gcc style inline assembly or
+1. to call selected intrinsics.
Any other usage is an error in the IR verifier.
Note that in order to support outputs along indirect edges, LLVM may need to
split critical edges, which may require synthesizing a replacement block for
-the ``indirect labels``. Therefore, the address of a label as seen by another
-``callbr`` instruction, or for a :ref:`blockaddress <blockaddress>` constant,
+the `indirect labels`. Therefore, the address of a label as seen by another
+`callbr` instruction, or for a {ref}`blockaddress <blockaddress>` constant,
may not be equal to the address provided for the same block to this
-instruction's ``indirect labels`` operand. The assembly code may only transfer
-control to addresses provided via this instruction's ``indirect labels``.
+instruction's `indirect labels` operand. The assembly code may only transfer
+control to addresses provided via this instruction's `indirect labels`.
On target architectures that implement branch target enforcement by requiring
indirect (register-controlled) branch instructions to jump only to locations
-marked by a special instruction (such as AArch64 ``bti``), the called code is
+marked by a special instruction (such as AArch64 `bti`), the called code is
expected not to use such an indirect branch to transfer control to the
-locations in ``indirect labels``. Therefore, including a label in the
-``indirect labels`` of a ``callbr`` does not require the compiler to put a
-``bti`` or equivalent instruction at the label.
+locations in `indirect labels`. Therefore, including a label in the
+`indirect labels` of a `callbr` does not require the compiler to put a
+`bti` or equivalent instruction at the label.
-Arguments:
-""""""""""
+##### Arguments:
This instruction requires several arguments:
-#. The optional "cconv" marker indicates which :ref:`calling
- convention <callingconv>` the call should use. If none is
+1. The optional "cconv" marker indicates which {ref}`calling convention <callingconv>` the call should use. If none is
specified, the call defaults to using C calling conventions.
-#. The optional :ref:`Parameter Attributes <paramattrs>` list for return
- values. Only '``zeroext``', '``signext``', '``noext``', and '``inreg``'
+1. The optional {ref}`Parameter Attributes <paramattrs>` list for return
+ values. Only '`zeroext`', '`signext`', '`noext`', and '`inreg`'
attributes are valid here.
-#. The optional addrspace attribute can be used to indicate the address space
+1. The optional addrspace attribute can be used to indicate the address space
of the called function. If it is not specified, the program address space
- from the :ref:`datalayout string<langref_datalayout>` will be used.
-#. '``ty``': the type of the call instruction itself which is also the
+ from the {ref}`datalayout string<langref_datalayout>` will be used.
+1. '`ty`': the type of the call instruction itself which is also the
type of the return value. Functions that return no value are marked
- ``void``. The signature is computed based on the return type and argument
+ `void`. The signature is computed based on the return type and argument
types.
-#. '``fnty``': shall be the signature of the function being called. The
+1. '`fnty`': shall be the signature of the function being called. The
argument types must match the types implied by this signature. This
is only required if the signature specifies a varargs type.
-#. '``fnptrval``': An LLVM value containing a pointer to a function to
+1. '`fnptrval`': An LLVM value containing a pointer to a function to
be called. In most cases, this is a direct function call, but
- other ``callbr``'s are just as possible, calling an arbitrary pointer
+ other `callbr`'s are just as possible, calling an arbitrary pointer
to function value.
-#. '``function args``': argument list whose types match the function
+1. '`function args`': argument list whose types match the function
signature argument types and parameter attributes. All arguments must
- be of :ref:`first class <t_firstclass>` type. If the function signature
+ be of {ref}`first class <t_firstclass>` type. If the function signature
indicates the function accepts a variable number of arguments, the
extra arguments can be specified.
-#. '``fallthrough label``': the label reached when the inline assembly's
+1. '`fallthrough label`': the label reached when the inline assembly's
execution exits the bottom / the intrinsic call returns.
-#. '``indirect labels``': the labels reached when a callee transfers control
- to a location other than the '``fallthrough label``'. Label constraints
+1. '`indirect labels`': the labels reached when a callee transfers control
+ to a location other than the '`fallthrough label`'. Label constraints
refer to these destinations.
-#. The optional :ref:`function attributes <fnattrs>` list.
-#. The optional :ref:`operand bundles <opbundles>` list.
+1. The optional {ref}`function attributes <fnattrs>` list.
+1. The optional {ref}`operand bundles <opbundles>` list.
-Semantics:
-""""""""""
+##### Semantics:
-This instruction is designed to operate as a standard '``call``'
+This instruction is designed to operate as a standard '`call`'
instruction in most regards. The primary difference is that it
establishes an association with additional labels to define where control
flow goes after the call.
-The output values of a '``callbr``' instruction are available both in the
-the '``fallthrough``' block, and any '``indirect``' blocks(s).
+The output values of a '`callbr`' instruction are available both in the
+the '`fallthrough`' block, and any '`indirect`' blocks(s).
The only current uses of this are:
-#. implement the "goto" feature of gcc inline assembly where additional
+1. implement the "goto" feature of gcc inline assembly where additional
labels can be provided as locations for the inline assembly to jump to.
-#. support selected intrinsics which manipulate control flow and should
- be chained to specific terminators, such as '``unreachable``'.
-
-Example:
-""""""""
-
-.. code-block:: llvm
+1. support selected intrinsics which manipulate control flow and should
+ be chained to specific terminators, such as '`unreachable`'.
- ; "asm goto" without output constraints.
- callbr void asm "", "r,!i"(i32 %x)
- to label %fallthrough [label %indirect]
+##### Example:
- ; "asm goto" with output constraints.
- <result> = callbr i32 asm "", "=r,r,!i"(i32 %x)
- to label %fallthrough [label %indirect]
+```llvm
+; "asm goto" without output constraints.
+callbr void asm "", "r,!i"(i32 %x)
+ to label %fallthrough [label %indirect]
- ; intrinsic which should be followed by unreachable (the order of the
- ; blocks after the callbr instruction doesn't matter)
- callbr void @llvm.amdgcn.kill(i1 %c) to label %cont [label %kill]
- cont:
- ...
- kill:
- unreachable
+; "asm goto" with output constraints.
+<result> = callbr i32 asm "", "=r,r,!i"(i32 %x)
+ to label %fallthrough [label %indirect]
-.. _i_resume:
+; intrinsic which should be followed by unreachable (the order of the
+; blocks after the callbr instruction doesn't matter)
+ callbr void @llvm.amdgcn.kill(i1 %c) to label %cont [label %kill]
+cont:
+ ...
+kill:
+ unreachable
+```
-'``resume``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+(i_resume)=
-Syntax:
-"""""""
+#### '`resume`' Instruction
-::
+##### Syntax:
- resume <type> <value>
+```
+resume <type> <value>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``resume``' instruction is a terminator instruction that has no
+The '`resume`' instruction is a terminator instruction that has no
successors.
-Arguments:
-""""""""""
+##### Arguments:
-The '``resume``' instruction requires one argument, which must have the
-same type as the result of any '``landingpad``' instruction in the same
+The '`resume`' instruction requires one argument, which must have the
+same type as the result of any '`landingpad`' instruction in the same
function.
-Semantics:
-""""""""""
+##### Semantics:
-The '``resume``' instruction resumes propagation of an existing
+The '`resume`' instruction resumes propagation of an existing
(in-flight) exception whose unwinding was interrupted with a
-:ref:`landingpad <i_landingpad>` instruction.
+{ref}`landingpad <i_landingpad>` instruction.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- resume { ptr, i32 } %exn
+```llvm
+resume { ptr, i32 } %exn
+```
-.. _i_catchswitch:
+(i_catchswitch)=
-'``catchswitch``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`catchswitch`' Instruction
-::
+##### Syntax:
- <resultval> = catchswitch within <parent> [ label <handler1>, label <handler2>, ... ] unwind to caller
- <resultval> = catchswitch within <parent> [ label <handler1>, label <handler2>, ... ] unwind label <default>
+```
+<resultval> = catchswitch within <parent> [ label <handler1>, label <handler2>, ... ] unwind to caller
+<resultval> = catchswitch within <parent> [ label <handler1>, label <handler2>, ... ] unwind label <default>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``catchswitch``' instruction is used by `LLVM's exception handling system
-<ExceptionHandling.html#overview>`_ to describe the set of possible catch handlers
-that may be executed by the :ref:`EH personality routine <personalityfn>`.
+The '`catchswitch`' instruction is used by [LLVM's exception handling system](ExceptionHandling.md#overview) to describe the set of possible catch handlers
+that may be executed by the {ref}`EH personality routine <personalityfn>`.
-Arguments:
-""""""""""
+##### Arguments:
-The ``parent`` argument is the token of the funclet that contains the
-``catchswitch`` instruction. If the ``catchswitch`` is not inside a funclet,
-this operand may be the token ``none``.
+The `parent` argument is the token of the funclet that contains the
+`catchswitch` instruction. If the `catchswitch` is not inside a funclet,
+this operand may be the token `none`.
-The ``default`` argument is the label of another basic block beginning with
-either a ``cleanuppad`` or ``catchswitch`` instruction. This unwind destination
-must be a legal target with respect to the ``parent`` links, as described in
-the `exception handling documentation\ <ExceptionHandling.html#wineh-constraints>`_.
+The `default` argument is the label of another basic block beginning with
+either a `cleanuppad` or `catchswitch` instruction. This unwind destination
+must be a legal target with respect to the `parent` links, as described in
+the {ref}`exception handling documentation <wineh-constraints>`.
-The ``handlers`` are a nonempty list of successor blocks that each begin with a
-:ref:`catchpad <i_catchpad>` instruction.
+The `handlers` are a nonempty list of successor blocks that each begin with a
+{ref}`catchpad <i_catchpad>` instruction.
-Semantics:
-""""""""""
+##### Semantics:
Executing this instruction transfers control to one of the successors in
-``handlers``, if appropriate, or continues to unwind via the unwind label if
+`handlers`, if appropriate, or continues to unwind via the unwind label if
present.
-The ``catchswitch`` is both a terminator and a "pad" instruction, meaning that
+The `catchswitch` is both a terminator and a "pad" instruction, meaning that
it must be both the first non-phi instruction and last instruction in the basic
block. Therefore, it must be the only non-phi instruction in the block.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- dispatch1:
- %cs1 = catchswitch within none [label %handler0, label %handler1] unwind to caller
- dispatch2:
- %cs2 = catchswitch within %parenthandler [label %handler0] unwind label %cleanup
+```text
+dispatch1:
+ %cs1 = catchswitch within none [label %handler0, label %handler1] unwind to caller
+dispatch2:
+ %cs2 = catchswitch within %parenthandler [label %handler0] unwind label %cleanup
+```
-.. _i_catchret:
+(i_catchret)=
-'``catchret``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`catchret`' Instruction
-::
+##### Syntax:
- catchret from <token> to label <normal>
+```
+catchret from <token> to label <normal>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``catchret``' instruction is a terminator instruction that has a
+The '`catchret`' instruction is a terminator instruction that has a
single successor.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to a '``catchret``' indicates which ``catchpad`` it
-exits. It must be a :ref:`catchpad <i_catchpad>`.
-The second argument to a '``catchret``' specifies where control will
+The first argument to a '`catchret`' indicates which `catchpad` it
+exits. It must be a {ref}`catchpad <i_catchpad>`.
+The second argument to a '`catchret`' specifies where control will
transfer to next.
-Semantics:
-""""""""""
+##### Semantics:
-The '``catchret``' instruction ends an existing (in-flight) exception whose
-unwinding was interrupted with a :ref:`catchpad <i_catchpad>` instruction. The
-:ref:`personality function <personalityfn>` gets a chance to execute arbitrary
+The '`catchret`' instruction ends an existing (in-flight) exception whose
+unwinding was interrupted with a {ref}`catchpad <i_catchpad>` instruction. The
+{ref}`personality function <personalityfn>` gets a chance to execute arbitrary
code to, for example, destroy the active exception. Control then transfers to
-``normal``.
+`normal`.
-The ``token`` argument must be a token produced by a ``catchpad`` instruction.
-If the specified ``catchpad`` is not the most-recently-entered not-yet-exited
-funclet pad (as described in the `EH documentation\ <ExceptionHandling.html#wineh-constraints>`_),
-the ``catchret``'s behavior is undefined.
+The `token` argument must be a token produced by a `catchpad` instruction.
+If the specified `catchpad` is not the most-recently-entered not-yet-exited
+funclet pad (as described in the {ref}`EH documentation <wineh-constraints>`),
+the `catchret`'s behavior is undefined.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- catchret from %catch to label %continue
+```text
+catchret from %catch to label %continue
+```
-.. _i_cleanupret:
+(i_cleanupret)=
-'``cleanupret``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`cleanupret`' Instruction
-::
+##### Syntax:
- cleanupret from <value> unwind label <continue>
- cleanupret from <value> unwind to caller
+```
+cleanupret from <value> unwind label <continue>
+cleanupret from <value> unwind to caller
+```
-Overview:
-"""""""""
+##### Overview:
-The '``cleanupret``' instruction is a terminator instruction that has
+The '`cleanupret`' instruction is a terminator instruction that has
an optional successor.
-Arguments:
-""""""""""
+##### Arguments:
-The '``cleanupret``' instruction requires one argument, which indicates
-which ``cleanuppad`` it exits, and must be a :ref:`cleanuppad <i_cleanuppad>`.
-If the specified ``cleanuppad`` is not the most-recently-entered not-yet-exited
-funclet pad (as described in the `EH documentation\ <ExceptionHandling.html#wineh-constraints>`_),
-the ``cleanupret``'s behavior is undefined.
+The '`cleanupret`' instruction requires one argument, which indicates
+which `cleanuppad` it exits, and must be a {ref}`cleanuppad <i_cleanuppad>`.
+If the specified `cleanuppad` is not the most-recently-entered not-yet-exited
+funclet pad (as described in the {ref}`EH documentation <wineh-constraints>`),
+the `cleanupret`'s behavior is undefined.
-The '``cleanupret``' instruction also has an optional successor, ``continue``,
+The '`cleanupret`' instruction also has an optional successor, `continue`,
which must be the label of another basic block beginning with either a
-``cleanuppad`` or ``catchswitch`` instruction. This unwind destination must
-be a legal target with respect to the ``parent`` links, as described in the
-`exception handling documentation\ <ExceptionHandling.html#wineh-constraints>`_.
+`cleanuppad` or `catchswitch` instruction. This unwind destination must
+be a legal target with respect to the `parent` links, as described in the
+{ref}`exception handling documentation <wineh-constraints>`.
-Semantics:
-""""""""""
+##### Semantics:
-The '``cleanupret``' instruction indicates to the
-:ref:`personality function <personalityfn>` that one
-:ref:`cleanuppad <i_cleanuppad>` it transferred control to has ended.
-It transfers control to ``continue`` or unwinds out of the function.
+The '`cleanupret`' instruction indicates to the
+{ref}`personality function <personalityfn>` that one
+{ref}`cleanuppad <i_cleanuppad>` it transferred control to has ended.
+It transfers control to `continue` or unwinds out of the function.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- cleanupret from %cleanup unwind to caller
- cleanupret from %cleanup unwind label %continue
+```text
+cleanupret from %cleanup unwind to caller
+cleanupret from %cleanup unwind label %continue
+```
-.. _i_unreachable:
+(i_unreachable)=
-'``unreachable``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`unreachable`' Instruction
-::
+##### Syntax:
- unreachable
+```
+unreachable
+```
-Overview:
-"""""""""
+##### Overview:
-The '``unreachable``' instruction has no defined semantics. This
+The '`unreachable`' instruction has no defined semantics. This
instruction is used to inform the optimizer that a particular portion of
the code is not reachable. This can be used to indicate that the code
after a no-return function cannot be reached, and other facts.
-Semantics:
-""""""""""
+##### Semantics:
-The '``unreachable``' instruction has no defined semantics.
+The '`unreachable`' instruction has no defined semantics.
-.. _unaryops:
+(unaryops)=
-Unary Operations
------------------
+### Unary Operations
Unary operators require a single operand, execute an operation on
it, and produce a single value. The operand might represent multiple
-data, as is the case with the :ref:`vector <t_vector>` data type. The
+data, as is the case with the {ref}`vector <t_vector>` data type. The
result value has the same type as its operand.
-.. _i_fneg:
+(i_fneg)=
-'``fneg``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`fneg`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = fneg [fast-math flags]* <ty> <op1> ; yields ty:result
+```
+<result> = fneg [fast-math flags]* <ty> <op1> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fneg``' instruction returns the negation of its operand.
+The '`fneg`' instruction returns the negation of its operand.
-Arguments:
-""""""""""
+##### Arguments:
-The argument to the '``fneg``' instruction must be a
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The argument to the '`fneg`' instruction must be a
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is a copy of the operand with its sign bit flipped.
The value is otherwise completely identical; in particular, if the input is a
NaN, then the quiet/signaling bit and payload are perfectly preserved.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = fneg float %val ; yields float:result = -%var
+```text
+<result> = fneg float %val ; yields float:result = -%var
+```
-.. _binaryops:
+(binaryops)=
-Binary Operations
------------------
+### Binary Operations
Binary operators are used to do most of the computation in a program.
They require two operands of the same type, execute an operation on
them, and produce a single value. The operands might represent multiple
-data, as is the case with the :ref:`vector <t_vector>` data type. The
+data, as is the case with the {ref}`vector <t_vector>` data type. The
result value has the same type as its operands.
There are several different binary operators:
-.. _i_add:
+(i_add)=
-'``add``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+#### '`add`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = add <ty> <op1>, <op2> ; yields ty:result
- <result> = add nuw <ty> <op1>, <op2> ; yields ty:result
- <result> = add nsw <ty> <op1>, <op2> ; yields ty:result
- <result> = add nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = add <ty> <op1>, <op2> ; yields ty:result
+<result> = add nuw <ty> <op1>, <op2> ; yields ty:result
+<result> = add nsw <ty> <op1>, <op2> ; yields ty:result
+<result> = add nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``add``' instruction returns the sum of its two operands.
+The '`add`' instruction returns the sum of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``add``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`add`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the integer sum of the two operands.
If the sum has unsigned overflow, the result returned is the
-mathematical result modulo 2\ :sup:`n`\ , where n is the bit width of
+mathematical result modulo 2{sup}`n`, where n is the bit width of
the result.
Because LLVM integers use a two's complement representation, this
instruction is appropriate for both signed and unsigned integers.
-``nuw`` and ``nsw`` stand for "No Unsigned Wrap" and "No Signed Wrap",
-respectively. If the ``nuw`` and/or ``nsw`` keywords are present, the
-result value of the ``add`` is a :ref:`poison value <poisonvalues>` if
+`nuw` and `nsw` stand for "No Unsigned Wrap" and "No Signed Wrap",
+respectively. If the `nuw` and/or `nsw` keywords are present, the
+result value of the `add` is a {ref}`poison value <poisonvalues>` if
unsigned and/or signed overflow, respectively, occurs.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = add i32 4, %var ; yields i32:result = 4 + %var
+```text
+<result> = add i32 4, %var ; yields i32:result = 4 + %var
+```
-.. _i_fadd:
+(i_fadd)=
-'``fadd``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`fadd`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = fadd [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = fadd [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fadd``' instruction returns the sum of its two operands.
+The '`fadd`' instruction returns the sum of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``fadd``' instruction must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The two arguments to the '`fadd`' instruction must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values. Both arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point sum of the two operands.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = fadd float 4.0, %var ; yields float:result = 4.0 + %var
+```text
+<result> = fadd float 4.0, %var ; yields float:result = 4.0 + %var
+```
-.. _i_sub:
+(i_sub)=
-'``sub``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+#### '`sub`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = sub <ty> <op1>, <op2> ; yields ty:result
- <result> = sub nuw <ty> <op1>, <op2> ; yields ty:result
- <result> = sub nsw <ty> <op1>, <op2> ; yields ty:result
- <result> = sub nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = sub <ty> <op1>, <op2> ; yields ty:result
+<result> = sub nuw <ty> <op1>, <op2> ; yields ty:result
+<result> = sub nsw <ty> <op1>, <op2> ; yields ty:result
+<result> = sub nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``sub``' instruction returns the difference of its two operands.
+The '`sub`' instruction returns the difference of its two operands.
-Note that the '``sub``' instruction is used to represent the '``neg``'
+Note that the '`sub`' instruction is used to represent the '`neg`'
instruction present in most other intermediate representations.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``sub``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`sub`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the integer difference of the two operands.
If the difference has unsigned overflow, the result returned is the
-mathematical result modulo 2\ :sup:`n`\ , where n is the bit width of
+mathematical result modulo 2{sup}`n`, where n is the bit width of
the result.
Because LLVM integers use a two's complement representation, this
instruction is appropriate for both signed and unsigned integers.
-``nuw`` and ``nsw`` stand for "No Unsigned Wrap" and "No Signed Wrap",
-respectively. If the ``nuw`` and/or ``nsw`` keywords are present, the
-result value of the ``sub`` is a :ref:`poison value <poisonvalues>` if
+`nuw` and `nsw` stand for "No Unsigned Wrap" and "No Signed Wrap",
+respectively. If the `nuw` and/or `nsw` keywords are present, the
+result value of the `sub` is a {ref}`poison value <poisonvalues>` if
unsigned and/or signed overflow, respectively, occurs.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = sub i32 4, %var ; yields i32:result = 4 - %var
- <result> = sub i32 0, %val ; yields i32:result = -%var
+```text
+<result> = sub i32 4, %var ; yields i32:result = 4 - %var
+<result> = sub i32 0, %val ; yields i32:result = -%var
+```
-.. _i_fsub:
+(i_fsub)=
-'``fsub``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`fsub`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = fsub [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = fsub [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fsub``' instruction returns the difference of its two operands.
+The '`fsub`' instruction returns the difference of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``fsub``' instruction must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The two arguments to the '`fsub`' instruction must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values. Both arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point difference of the two operands.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = fsub float 4.0, %var ; yields float:result = 4.0 - %var
- <result> = fsub float -0.0, %val ; yields float:result = -%var
+```text
+<result> = fsub float 4.0, %var ; yields float:result = 4.0 - %var
+<result> = fsub float -0.0, %val ; yields float:result = -%var
+```
-.. _i_mul:
+(i_mul)=
-'``mul``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+#### '`mul`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = mul <ty> <op1>, <op2> ; yields ty:result
- <result> = mul nuw <ty> <op1>, <op2> ; yields ty:result
- <result> = mul nsw <ty> <op1>, <op2> ; yields ty:result
- <result> = mul nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = mul <ty> <op1>, <op2> ; yields ty:result
+<result> = mul nuw <ty> <op1>, <op2> ; yields ty:result
+<result> = mul nsw <ty> <op1>, <op2> ; yields ty:result
+<result> = mul nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``mul``' instruction returns the product of its two operands.
+The '`mul`' instruction returns the product of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``mul``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`mul`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the integer product of the two operands.
If the result of the multiplication has unsigned overflow, the result
-returned is the mathematical result modulo 2\ :sup:`n`\ , where n is the
+returned is the mathematical result modulo 2{sup}`n`, where n is the
bit width of the result.
Because LLVM integers use a two's complement representation, and the
result is the same width as the operands, this instruction returns the
correct result for both signed and unsigned integers. If a full product
-(e.g., ``i32`` * ``i32`` -> ``i64``) is needed, the operands should be
+(e.g., `i32` * `i32` -> `i64`) is needed, the operands should be
sign-extended or zero-extended as appropriate to the width of the full
product.
-``nuw`` and ``nsw`` stand for "No Unsigned Wrap" and "No Signed Wrap",
-respectively. If the ``nuw`` and/or ``nsw`` keywords are present, the
-result value of the ``mul`` is a :ref:`poison value <poisonvalues>` if
+`nuw` and `nsw` stand for "No Unsigned Wrap" and "No Signed Wrap",
+respectively. If the `nuw` and/or `nsw` keywords are present, the
+result value of the `mul` is a {ref}`poison value <poisonvalues>` if
unsigned and/or signed overflow, respectively, occurs.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = mul i32 4, %var ; yields i32:result = 4 * %var
+```text
+<result> = mul i32 4, %var ; yields i32:result = 4 * %var
+```
-.. _i_fmul:
+(i_fmul)=
-'``fmul``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`fmul`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = fmul [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = fmul [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fmul``' instruction returns the product of its two operands.
+The '`fmul`' instruction returns the product of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``fmul``' instruction must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The two arguments to the '`fmul`' instruction must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values. Both arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point product of the two operands.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = fmul float 4.0, %var ; yields float:result = 4.0 * %var
+```text
+<result> = fmul float 4.0, %var ; yields float:result = 4.0 * %var
+```
-.. _i_udiv:
+(i_udiv)=
-'``udiv``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`udiv`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = udiv <ty> <op1>, <op2> ; yields ty:result
- <result> = udiv exact <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = udiv <ty> <op1>, <op2> ; yields ty:result
+<result> = udiv exact <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``udiv``' instruction returns the quotient of its two operands.
+The '`udiv`' instruction returns the quotient of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``udiv``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`udiv`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the unsigned integer quotient of the two operands.
Note that unsigned integer division and signed integer division are
-distinct operations; for signed integer division, use '``sdiv``'.
+distinct operations; for signed integer division, use '`sdiv`'.
Division by zero is undefined behavior. For vectors, if any element
of the divisor is zero, the operation has undefined behavior.
-If the ``exact`` keyword is present, the result value of the ``udiv`` is
-a :ref:`poison value <poisonvalues>` if %op1 is not a multiple of %op2 (as
+If the `exact` keyword is present, the result value of the `udiv` is
+a {ref}`poison value <poisonvalues>` if %op1 is not a multiple of %op2 (as
such, "((a udiv exact b) mul b) == a").
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = udiv i32 4, %var ; yields i32:result = 4 / %var
+```text
+<result> = udiv i32 4, %var ; yields i32:result = 4 / %var
+```
-.. _i_sdiv:
+(i_sdiv)=
-'``sdiv``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`sdiv`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = sdiv <ty> <op1>, <op2> ; yields ty:result
- <result> = sdiv exact <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = sdiv <ty> <op1>, <op2> ; yields ty:result
+<result> = sdiv exact <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``sdiv``' instruction returns the quotient of its two operands.
+The '`sdiv`' instruction returns the quotient of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``sdiv``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`sdiv`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the signed integer quotient of the two operands
rounded towards zero.
Note that signed integer division and unsigned integer division are
-distinct operations; for unsigned integer division, use '``udiv``'.
+distinct operations; for unsigned integer division, use '`udiv`'.
Division by zero is undefined behavior. For vectors, if any element
of the divisor is zero, the operation has undefined behavior.
Overflow also leads to undefined behavior; this is a rare case, but can
occur, for example, by doing a 32-bit division of -2147483648 by -1.
-If the ``exact`` keyword is present, the result value of the ``sdiv`` is
-a :ref:`poison value <poisonvalues>` if the result would be rounded.
-
-Example:
-""""""""
-
-.. code-block:: text
+If the `exact` keyword is present, the result value of the `sdiv` is
+a {ref}`poison value <poisonvalues>` if the result would be rounded.
- <result> = sdiv i32 4, %var ; yields i32:result = 4 / %var
+##### Example:
-.. _i_fdiv:
+```text
+<result> = sdiv i32 4, %var ; yields i32:result = 4 / %var
+```
-'``fdiv``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+(i_fdiv)=
-Syntax:
-"""""""
+#### '`fdiv`' Instruction
-::
+##### Syntax:
- <result> = fdiv [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = fdiv [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fdiv``' instruction returns the quotient of its two operands.
+The '`fdiv`' instruction returns the quotient of its two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``fdiv``' instruction must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The two arguments to the '`fdiv`' instruction must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values. Both arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point quotient of the two operands.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = fdiv float 4.0, %var ; yields float:result = 4.0 / %var
+```text
+<result> = fdiv float 4.0, %var ; yields float:result = 4.0 / %var
+```
-.. _i_urem:
+(i_urem)=
-'``urem``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`urem`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = urem <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = urem <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``urem``' instruction returns the remainder from the unsigned
+The '`urem`' instruction returns the remainder from the unsigned
division of its two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``urem``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`urem`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
This instruction returns the unsigned integer *remainder* of a division.
This instruction always performs an unsigned division to get the
remainder.
Note that unsigned integer remainder and signed integer remainder are
-distinct operations; for signed integer remainder, use '``srem``'.
+distinct operations; for signed integer remainder, use '`srem`'.
Taking the remainder of a division by zero is undefined behavior.
For vectors, if any element of the divisor is zero, the operation has
undefined behavior.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = urem i32 4, %var ; yields i32:result = 4 % %var
+```text
+<result> = urem i32 4, %var ; yields i32:result = 4 % %var
+```
-.. _i_srem:
+(i_srem)=
-'``srem``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`srem`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = srem <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = srem <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``srem``' instruction returns the remainder from the signed
+The '`srem`' instruction returns the remainder from the signed
division of its two operands. This instruction can also take
-:ref:`vector <t_vector>` versions of the values in which case the elements
+{ref}`vector <t_vector>` versions of the values in which case the elements
must be integers.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``srem``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`srem`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
This instruction returns the *remainder* of a division (where the result
-is either zero or has the same sign as the dividend, ``op1``), not the
+is either zero or has the same sign as the dividend, `op1`), not the
*modulo* operator (where the result is either zero or has the same sign
-as the divisor, ``op2``) of a value. For more information about the
-difference, see `The Math
-Forum <http://mathforum.org/dr.math/problems/anne.4.28.99.html>`_. For a
+as the divisor, `op2`) of a value. For more information about the
+difference, see [The Math
+Forum](http://mathforum.org/dr.math/problems/anne.4.28.99.html). For a
table of how this is implemented in various languages, please see
-`Wikipedia: modulo
-operation <http://en.wikipedia.org/wiki/Modulo_operation>`_.
+[Wikipedia: modulo
+operation](http://en.wikipedia.org/wiki/Modulo_operation).
Note that signed integer remainder and unsigned integer remainder are
-distinct operations; for unsigned integer remainder, use '``urem``'.
+distinct operations; for unsigned integer remainder, use '`urem`'.
Taking the remainder of a division by zero is undefined behavior.
For vectors, if any element of the divisor is zero, the operation has
@@ -11254,68 +10981,58 @@ occur, for example, by taking the remainder of a 32-bit division of
rule lets srem be implemented using instructions that return both the
result of the division and the remainder.)
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = srem i32 4, %var ; yields i32:result = 4 % %var
+```text
+<result> = srem i32 4, %var ; yields i32:result = 4 % %var
+```
-.. _i_frem:
+(i_frem)=
-'``frem``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`frem`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = frem [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = frem [fast-math flags]* <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``frem``' instruction returns the remainder from the division of
+The '`frem`' instruction returns the remainder from the division of
its two operands.
-.. note::
+```{note}
+The instruction is implemented as a call to libm's '`fmod`'
+for some targets, and using the instruction may thus require linking libm.
+```
- The instruction is implemented as a call to libm's '``fmod``'
- for some targets, and using the instruction may thus require linking libm.
+##### Arguments:
-Arguments:
-""""""""""
-
-The two arguments to the '``frem``' instruction must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>` of
+The two arguments to the '`frem`' instruction must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of
floating-point values. Both arguments must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point remainder of the two operands.
-This is the same output as a libm '``fmod``' function, but without any
-possibility of setting ``errno``. The remainder has the same sign as the
+This is the same output as a libm '`fmod`' function, but without any
+possibility of setting `errno`. The remainder has the same sign as the
dividend.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations:
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = frem float 4.0, %var ; yields float:result = 4.0 % %var
+```text
+<result> = frem float 4.0, %var ; yields float:result = 4.0 % %var
+```
-.. _bitwiseops:
+(bitwiseops)=
-Bitwise Binary Operations
--------------------------
+### Bitwise Binary Operations
Bitwise binary operators are used to do various forms of bit-twiddling
in a program. They are generally very efficient instructions and can
@@ -11323,328 +11040,313 @@ commonly be strength reduced from other instructions. They require two
operands of the same type, execute an operation on them, and produce a
single value. The resulting value is the same type as its operands.
-.. _i_shl:
-
-'``shl``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+(i_shl)=
-Syntax:
-"""""""
+#### '`shl`' Instruction
-::
+##### Syntax:
- <result> = shl <ty> <op1>, <op2> ; yields ty:result
- <result> = shl nuw <ty> <op1>, <op2> ; yields ty:result
- <result> = shl nsw <ty> <op1>, <op2> ; yields ty:result
- <result> = shl nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = shl <ty> <op1>, <op2> ; yields ty:result
+<result> = shl nuw <ty> <op1>, <op2> ; yields ty:result
+<result> = shl nsw <ty> <op1>, <op2> ; yields ty:result
+<result> = shl nuw nsw <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``shl``' instruction returns the first operand shifted to the left
+The '`shl`' instruction returns the first operand shifted to the left
a specified number of bits.
-Arguments:
-""""""""""
+##### Arguments:
-Both arguments to the '``shl``' instruction must be the same
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer type.
-'``op2``' is treated as an unsigned value.
+Both arguments to the '`shl`' instruction must be the same
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer type.
+'`op2`' is treated as an unsigned value.
-Semantics:
-""""""""""
+##### Semantics:
-The value produced is ``op1`` \* 2\ :sup:`op2` mod 2\ :sup:`n`,
-where ``n`` is the width of the result. If ``op2`` is (statically or
+The value produced is `op1` * 2{sup}`op2` mod 2{sup}`n`,
+where `n` is the width of the result. If `op2` is (statically or
dynamically) equal to or larger than the number of bits in
-``op1``, this instruction returns a :ref:`poison value <poisonvalues>`.
-If the arguments are vectors, each vector element of ``op1`` is shifted
-by the corresponding shift amount in ``op2``.
+`op1`, this instruction returns a {ref}`poison value <poisonvalues>`.
+If the arguments are vectors, each vector element of `op1` is shifted
+by the corresponding shift amount in `op2`.
-If the ``nuw`` keyword is present, then the shift produces a poison
+If the `nuw` keyword is present, then the shift produces a poison
value if it shifts out any non-zero bits.
-If the ``nsw`` keyword is present, then the shift produces a poison
+If the `nsw` keyword is present, then the shift produces a poison
value if it shifts out any bits that disagree with the resultant sign bit.
-Example:
-""""""""
-
-.. code-block:: text
-
- <result> = shl i32 4, %var ; yields i32: 4 << %var
- <result> = shl i32 4, 2 ; yields i32: 16
- <result> = shl i32 1, 10 ; yields i32: 1024
- <result> = shl i32 1, 32 ; undefined
- <result> = shl <2 x i32> < i32 1, i32 1>, < i32 1, i32 2> ; yields: result=<2 x i32> < i32 2, i32 4>
+##### Example:
-.. _i_lshr:
+```text
+<result> = shl i32 4, %var ; yields i32: 4 << %var
+<result> = shl i32 4, 2 ; yields i32: 16
+<result> = shl i32 1, 10 ; yields i32: 1024
+<result> = shl i32 1, 32 ; undefined
+<result> = shl <2 x i32> < i32 1, i32 1>, < i32 1, i32 2> ; yields: result=<2 x i32> < i32 2, i32 4>
+```
+(i_lshr)=
-'``lshr``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
-Syntax:
-"""""""
+#### '`lshr`' Instruction
-::
+##### Syntax:
- <result> = lshr <ty> <op1>, <op2> ; yields ty:result
- <result> = lshr exact <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = lshr <ty> <op1>, <op2> ; yields ty:result
+<result> = lshr exact <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``lshr``' instruction (logical shift right) returns the first
+The '`lshr`' instruction (logical shift right) returns the first
operand shifted to the right a specified number of bits with zero fill.
-Arguments:
-""""""""""
+##### Arguments:
-Both arguments to the '``lshr``' instruction must be the same
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer type.
-'``op2``' is treated as an unsigned value.
+Both arguments to the '`lshr`' instruction must be the same
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer type.
+'`op2`' is treated as an unsigned value.
-Semantics:
-""""""""""
+##### Semantics:
This instruction always performs a logical shift right operation. The
most significant bits of the result will be filled with zero bits after
-the shift. If ``op2`` is (statically or dynamically) equal to or larger
-than the number of bits in ``op1``, this instruction returns a :ref:`poison
-value <poisonvalues>`. If the arguments are vectors, each vector element
-of ``op1`` is shifted by the corresponding shift amount in ``op2``.
+the shift. If `op2` is (statically or dynamically) equal to or larger
+than the number of bits in `op1`, this instruction returns a {ref}`poison value <poisonvalues>`. If the arguments are vectors, each vector element
+of `op1` is shifted by the corresponding shift amount in `op2`.
-If the ``exact`` keyword is present, the result value of the ``lshr`` is
+If the `exact` keyword is present, the result value of the `lshr` is
a poison value if any of the bits shifted out are non-zero.
-Example:
-""""""""
-
-.. code-block:: text
-
- <result> = lshr i32 4, 1 ; yields i32:result = 2
- <result> = lshr i32 4, 2 ; yields i32:result = 1
- <result> = lshr i8 4, 3 ; yields i8:result = 0
- <result> = lshr i8 -2, 1 ; yields i8:result = 0x7F
- <result> = lshr i32 1, 32 ; undefined
- <result> = lshr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 2> ; yields: result=<2 x i32> < i32 0x7FFFFFFF, i32 1>
+##### Example:
-.. _i_ashr:
+```text
+<result> = lshr i32 4, 1 ; yields i32:result = 2
+<result> = lshr i32 4, 2 ; yields i32:result = 1
+<result> = lshr i8 4, 3 ; yields i8:result = 0
+<result> = lshr i8 -2, 1 ; yields i8:result = 0x7F
+<result> = lshr i32 1, 32 ; undefined
+<result> = lshr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 2> ; yields: result=<2 x i32> < i32 0x7FFFFFFF, i32 1>
+```
-'``ashr``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+(i_ashr)=
-Syntax:
-"""""""
+#### '`ashr`' Instruction
-::
+##### Syntax:
- <result> = ashr <ty> <op1>, <op2> ; yields ty:result
- <result> = ashr exact <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = ashr <ty> <op1>, <op2> ; yields ty:result
+<result> = ashr exact <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``ashr``' instruction (arithmetic shift right) returns the first
+The '`ashr`' instruction (arithmetic shift right) returns the first
operand shifted to the right a specified number of bits with sign
extension.
-Arguments:
-""""""""""
+##### Arguments:
-Both arguments to the '``ashr``' instruction must be the same
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer type.
-'``op2``' is treated as an unsigned value.
+Both arguments to the '`ashr`' instruction must be the same
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer type.
+'`op2`' is treated as an unsigned value.
-Semantics:
-""""""""""
+##### Semantics:
This instruction always performs an arithmetic shift right operation,
The most significant bits of the result will be filled with the sign bit
-of ``op1``. If ``op2`` is (statically or dynamically) equal to or larger
-than the number of bits in ``op1``, this instruction returns a :ref:`poison
-value <poisonvalues>`. If the arguments are vectors, each vector element
-of ``op1`` is shifted by the corresponding shift amount in ``op2``.
+of `op1`. If `op2` is (statically or dynamically) equal to or larger
+than the number of bits in `op1`, this instruction returns a {ref}`poison value <poisonvalues>`. If the arguments are vectors, each vector element
+of `op1` is shifted by the corresponding shift amount in `op2`.
-If the ``exact`` keyword is present, the result value of the ``ashr`` is
+If the `exact` keyword is present, the result value of the `ashr` is
a poison value if any of the bits shifted out are non-zero.
-Example:
-""""""""
-
-.. code-block:: text
-
- <result> = ashr i32 4, 1 ; yields i32:result = 2
- <result> = ashr i32 4, 2 ; yields i32:result = 1
- <result> = ashr i8 4, 3 ; yields i8:result = 0
- <result> = ashr i8 -2, 1 ; yields i8:result = -1
- <result> = ashr i32 1, 32 ; undefined
- <result> = ashr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 3> ; yields: result=<2 x i32> < i32 -1, i32 0>
+##### Example:
-.. _i_and:
+```text
+<result> = ashr i32 4, 1 ; yields i32:result = 2
+<result> = ashr i32 4, 2 ; yields i32:result = 1
+<result> = ashr i8 4, 3 ; yields i8:result = 0
+<result> = ashr i8 -2, 1 ; yields i8:result = -1
+<result> = ashr i32 1, 32 ; undefined
+<result> = ashr <2 x i32> < i32 -2, i32 4>, < i32 1, i32 3> ; yields: result=<2 x i32> < i32 -1, i32 0>
+```
-'``and``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+(i_and)=
-Syntax:
-"""""""
+#### '`and`' Instruction
-::
+##### Syntax:
- <result> = and <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = and <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``and``' instruction returns the bitwise logical and of its two
+The '`and`' instruction returns the bitwise logical and of its two
operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``and``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`and`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
-
-The truth table used for the '``and``' instruction is:
+##### Semantics:
-+-----+-----+-----+
-| In0 | In1 | Out |
-+-----+-----+-----+
-| 0 | 0 | 0 |
-+-----+-----+-----+
-| 0 | 1 | 0 |
-+-----+-----+-----+
-| 1 | 0 | 0 |
-+-----+-----+-----+
-| 1 | 1 | 1 |
-+-----+-----+-----+
+The truth table used for the '`and`' instruction is:
-Example:
-""""""""
+```{list-table}
+:header-rows: 0
-.. code-block:: text
+* - In0
+ - In1
+ - Out
+* - 0
+ - 0
+ - 0
+* - 0
+ - 1
+ - 0
+* - 1
+ - 0
+ - 0
+* - 1
+ - 1
+ - 1
+```
- <result> = and i32 4, %var ; yields i32:result = 4 & %var
- <result> = and i32 15, 40 ; yields i32:result = 8
- <result> = and i32 4, 8 ; yields i32:result = 0
+##### Example:
-.. _i_or:
+```text
+<result> = and i32 4, %var ; yields i32:result = 4 & %var
+<result> = and i32 15, 40 ; yields i32:result = 8
+<result> = and i32 4, 8 ; yields i32:result = 0
+```
-'``or``' Instruction
-^^^^^^^^^^^^^^^^^^^^
+(i_or)=
-Syntax:
-"""""""
+#### '`or`' Instruction
-::
+##### Syntax:
- <result> = or <ty> <op1>, <op2> ; yields ty:result
- <result> = or disjoint <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = or <ty> <op1>, <op2> ; yields ty:result
+<result> = or disjoint <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``or``' instruction returns the bitwise logical inclusive or of its
+The '`or`' instruction returns the bitwise logical inclusive or of its
two operands.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``or``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`or`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
-
-The truth table used for the '``or``' instruction is:
-
-+-----+-----+-----+
-| In0 | In1 | Out |
-+-----+-----+-----+
-| 0 | 0 | 0 |
-+-----+-----+-----+
-| 0 | 1 | 1 |
-+-----+-----+-----+
-| 1 | 0 | 1 |
-+-----+-----+-----+
-| 1 | 1 | 1 |
-+-----+-----+-----+
-
-``disjoint`` means that for each bit, that bit is zero in at least one of the
+##### Semantics:
+
+The truth table used for the '`or`' instruction is:
+
+```{list-table}
+:header-rows: 0
+
+* - In0
+ - In1
+ - Out
+* - 0
+ - 0
+ - 0
+* - 0
+ - 1
+ - 1
+* - 1
+ - 0
+ - 1
+* - 1
+ - 1
+ - 1
+```
+
+`disjoint` means that for each bit, that bit is zero in at least one of the
inputs. This allows the Or to be treated as an Add since no carry can occur from
-any bit. If the disjoint keyword is present, the result value of the ``or`` is a
-:ref:`poison value <poisonvalues>` if both inputs have a one in the same bit
+any bit. If the disjoint keyword is present, the result value of the `or` is a
+{ref}`poison value <poisonvalues>` if both inputs have a one in the same bit
position. For vectors, only the element containing the bit is poison.
-Example:
-""""""""
-
-::
-
- <result> = or i32 4, %var ; yields i32:result = 4 | %var
- <result> = or i32 15, 40 ; yields i32:result = 47
- <result> = or i32 4, 8 ; yields i32:result = 12
+##### Example:
-.. _i_xor:
+```
+<result> = or i32 4, %var ; yields i32:result = 4 | %var
+<result> = or i32 15, 40 ; yields i32:result = 47
+<result> = or i32 4, 8 ; yields i32:result = 12
+```
-'``xor``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+(i_xor)=
-Syntax:
-"""""""
+#### '`xor`' Instruction
-::
+##### Syntax:
- <result> = xor <ty> <op1>, <op2> ; yields ty:result
+```
+<result> = xor <ty> <op1>, <op2> ; yields ty:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``xor``' instruction returns the bitwise logical exclusive or of
-its two operands. The ``xor`` is used to implement the "one's
+The '`xor`' instruction returns the bitwise logical exclusive or of
+its two operands. The `xor` is used to implement the "one's
complement" operation, which is the "~" operator in C.
-Arguments:
-""""""""""
+##### Arguments:
-The two arguments to the '``xor``' instruction must be
-:ref:`integer <t_integer>` or :ref:`vector <t_vector>` of integer values. Both
+The two arguments to the '`xor`' instruction must be
+{ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values. Both
arguments must have identical types.
-Semantics:
-""""""""""
-
-The truth table used for the '``xor``' instruction is:
-
-+-----+-----+-----+
-| In0 | In1 | Out |
-+-----+-----+-----+
-| 0 | 0 | 0 |
-+-----+-----+-----+
-| 0 | 1 | 1 |
-+-----+-----+-----+
-| 1 | 0 | 1 |
-+-----+-----+-----+
-| 1 | 1 | 0 |
-+-----+-----+-----+
-
-Example:
-""""""""
-
-.. code-block:: text
-
- <result> = xor i32 4, %var ; yields i32:result = 4 ^ %var
- <result> = xor i32 15, 40 ; yields i32:result = 39
- <result> = xor i32 4, 8 ; yields i32:result = 12
- <result> = xor i32 %V, -1 ; yields i32:result = ~%V
-
-Vector Operations
------------------
+##### Semantics:
+
+The truth table used for the '`xor`' instruction is:
+
+```{list-table}
+:header-rows: 0
+
+* - In0
+ - In1
+ - Out
+* - 0
+ - 0
+ - 0
+* - 0
+ - 1
+ - 1
+* - 1
+ - 0
+ - 1
+* - 1
+ - 1
+ - 0
+```
+
+##### Example:
+
+```text
+<result> = xor i32 4, %var ; yields i32:result = 4 ^ %var
+<result> = xor i32 15, 40 ; yields i32:result = 39
+<result> = xor i32 4, 8 ; yields i32:result = 12
+<result> = xor i32 %V, -1 ; yields i32:result = ~%V
+```
+
+### Vector Operations
LLVM supports several instructions to represent vector operations in a
target-independent manner. These instructions cover the element-access
@@ -11653,128 +11355,111 @@ While LLVM does directly support these vector operations, many
sophisticated algorithms will want to use target-specific intrinsics to
take full advantage of a specific target.
-.. _i_extractelement:
+(i_extractelement)=
-'``extractelement``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`extractelement`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = extractelement <n x <ty>> <val>, <ty2> <idx> ; yields <ty>
- <result> = extractelement <vscale x n x <ty>> <val>, <ty2> <idx> ; yields <ty>
+```
+<result> = extractelement <n x <ty>> <val>, <ty2> <idx> ; yields <ty>
+<result> = extractelement <vscale x n x <ty>> <val>, <ty2> <idx> ; yields <ty>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``extractelement``' instruction extracts a single scalar element
+The '`extractelement`' instruction extracts a single scalar element
from a vector at a specified index.
-Arguments:
-""""""""""
+##### Arguments:
-The first operand of an '``extractelement``' instruction is a value of
-:ref:`vector <t_vector>` type. The second operand is an index indicating
+The first operand of an '`extractelement`' instruction is a value of
+{ref}`vector <t_vector>` type. The second operand is an index indicating
the position from which to extract the element. The index may be a
variable of any integer type, and will be treated as an unsigned integer.
-Semantics:
-""""""""""
-
-The result is a scalar of the same type as the element type of ``val``.
-Its value is the value at position ``idx`` of ``val``. If ``idx``
-exceeds the length of ``val`` for a fixed-length vector, the result is a
-:ref:`poison value <poisonvalues>`. For a scalable vector, if the value
-of ``idx`` exceeds the runtime length of the vector, the result is a
-:ref:`poison value <poisonvalues>`.
-
-Example:
-""""""""
+##### Semantics:
-.. code-block:: text
+The result is a scalar of the same type as the element type of `val`.
+Its value is the value at position `idx` of `val`. If `idx`
+exceeds the length of `val` for a fixed-length vector, the result is a
+{ref}`poison value <poisonvalues>`. For a scalable vector, if the value
+of `idx` exceeds the runtime length of the vector, the result is a
+{ref}`poison value <poisonvalues>`.
- <result> = extractelement <4 x i32> %vec, i32 0 ; yields i32
+##### Example:
-.. _i_insertelement:
+```text
+<result> = extractelement <4 x i32> %vec, i32 0 ; yields i32
+```
-'``insertelement``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_insertelement)=
-Syntax:
-"""""""
+#### '`insertelement`' Instruction
-::
+##### Syntax:
- <result> = insertelement <n x <ty>> <val>, <ty> <elt>, <ty2> <idx> ; yields <n x <ty>>
- <result> = insertelement <vscale x n x <ty>> <val>, <ty> <elt>, <ty2> <idx> ; yields <vscale x n x <ty>>
+```
+<result> = insertelement <n x <ty>> <val>, <ty> <elt>, <ty2> <idx> ; yields <n x <ty>>
+<result> = insertelement <vscale x n x <ty>> <val>, <ty> <elt>, <ty2> <idx> ; yields <vscale x n x <ty>>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``insertelement``' instruction inserts a scalar element into a
+The '`insertelement`' instruction inserts a scalar element into a
vector at a specified index.
-Arguments:
-""""""""""
+##### Arguments:
-The first operand of an '``insertelement``' instruction is a value of
-:ref:`vector <t_vector>` type. The second operand is a scalar value whose
+The first operand of an '`insertelement`' instruction is a value of
+{ref}`vector <t_vector>` type. The second operand is a scalar value whose
type must equal the element type of the first operand. The third operand
is an index indicating the position at which to insert the value. The
index may be a variable of any integer type, and will be treated as an
unsigned integer.
-Semantics:
-""""""""""
-
-The result is a vector of the same type as ``val``. Its element values
-are those of ``val`` except at position ``idx``, where it gets the value
-``elt``. If ``idx`` exceeds the length of ``val`` for a fixed-length vector,
-the result is a :ref:`poison value <poisonvalues>`. For a scalable vector,
-if the value of ``idx`` exceeds the runtime length of the vector, the result
-is a :ref:`poison value <poisonvalues>`.
-
-Example:
-""""""""
+##### Semantics:
-.. code-block:: text
+The result is a vector of the same type as `val`. Its element values
+are those of `val` except at position `idx`, where it gets the value
+`elt`. If `idx` exceeds the length of `val` for a fixed-length vector,
+the result is a {ref}`poison value <poisonvalues>`. For a scalable vector,
+if the value of `idx` exceeds the runtime length of the vector, the result
+is a {ref}`poison value <poisonvalues>`.
- <result> = insertelement <4 x i32> %vec, i32 1, i32 0 ; yields <4 x i32>
+##### Example:
-.. _i_shufflevector:
+```text
+<result> = insertelement <4 x i32> %vec, i32 1, i32 0 ; yields <4 x i32>
+```
-'``shufflevector``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_shufflevector)=
-Syntax:
-"""""""
+#### '`shufflevector`' Instruction
-::
+##### Syntax:
- <result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask> ; yields <m x <ty>>
- <result> = shufflevector <vscale x n x <ty>> <v1>, <vscale x n x <ty>> v2, <vscale x m x i32> <mask> ; yields <vscale x m x <ty>>
+```
+<result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask> ; yields <m x <ty>>
+<result> = shufflevector <vscale x n x <ty>> <v1>, <vscale x n x <ty>> v2, <vscale x m x i32> <mask> ; yields <vscale x m x <ty>>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``shufflevector``' instruction constructs a permutation of elements
+The '`shufflevector`' instruction constructs a permutation of elements
from two input vectors, returning a vector with the same element type as
the input and length that is the same as the shuffle mask.
-Arguments:
-""""""""""
+##### Arguments:
-The first two operands of a '``shufflevector``' instruction are vectors
+The first two operands of a '`shufflevector`' instruction are vectors
with the same type. The third argument is a shuffle mask vector constant
-whose element type is ``i32``. The mask vector elements must be constant
-integers or ``poison`` values. The result of the instruction is a vector
+whose element type is `i32`. The mask vector elements must be constant
+integers or `poison` values. The result of the instruction is a vector
whose length is the same as the shuffle mask and whose element type is the
same as the element type of the first two operands.
-Semantics:
-""""""""""
+##### Semantics:
The elements of the two input vectors are numbered from left to right
across both of the vectors. For each element of the result vector, the
@@ -11782,163 +11467,144 @@ shuffle mask selects an element from one of the input vectors to copy
to the result. Non-negative elements in the mask represent an index
into the concatenated pair of input vectors.
-A ``poison`` element in the mask vector specifies that the resulting element is
-``poison``. For backwards-compatibility reasons, LLVM temporarily also accepts
-``undef`` mask elements. These will be interpreted the same way as ``poison``
-mask elements, also producing a ``poison`` element in the result.
+A `poison` element in the mask vector specifies that the resulting element is
+`poison`. For backwards-compatibility reasons, LLVM temporarily also accepts
+`undef` mask elements. These will be interpreted the same way as `poison`
+mask elements, also producing a `poison` element in the result.
-If the shuffle mask selects an ``undef`` element from one of the input
-vectors, the resulting element is ``undef``.
+If the shuffle mask selects an `undef` element from one of the input
+vectors, the resulting element is `undef`.
For scalable vectors, the only valid mask values at present are
-``zeroinitializer``, ``undef`` and ``poison``, since we cannot write all indices as
+`zeroinitializer`, `undef` and `poison`, since we cannot write all indices as
literals for a vector with a length unknown at compile time.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
- <4 x i32> <i32 0, i32 4, i32 1, i32 5> ; yields <4 x i32>
- <result> = shufflevector <4 x i32> %v1, <4 x i32> poison,
- <4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32> - Identity shuffle.
- <result> = shufflevector <8 x i32> %v1, <8 x i32> poison,
- <4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32>
- <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
- <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7 > ; yields <8 x i32>
+```text
+<result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
+ <4 x i32> <i32 0, i32 4, i32 1, i32 5> ; yields <4 x i32>
+<result> = shufflevector <4 x i32> %v1, <4 x i32> poison,
+ <4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32> - Identity shuffle.
+<result> = shufflevector <8 x i32> %v1, <8 x i32> poison,
+ <4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32>
+<result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
+ <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7 > ; yields <8 x i32>
+```
-Aggregate Operations
---------------------
+### Aggregate Operations
LLVM supports several instructions for working with
-:ref:`aggregate <t_aggregate>` values.
+{ref}`aggregate <t_aggregate>` values.
-.. _i_extractvalue:
+(i_extractvalue)=
-'``extractvalue``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`extractvalue`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = extractvalue <aggregate type> <val>, <idx>{, <idx>}*
+```
+<result> = extractvalue <aggregate type> <val>, <idx>{, <idx>}*
+```
-Overview:
-"""""""""
+##### Overview:
-The '``extractvalue``' instruction extracts the value of a member field
-from an :ref:`aggregate <t_aggregate>` value.
+The '`extractvalue`' instruction extracts the value of a member field
+from an {ref}`aggregate <t_aggregate>` value.
-Arguments:
-""""""""""
+##### Arguments:
-The first operand of an '``extractvalue``' instruction is a value of
-:ref:`struct <t_struct>` or :ref:`array <t_array>` type. The other operands are
+The first operand of an '`extractvalue`' instruction is a value of
+{ref}`struct <t_struct>` or {ref}`array <t_array>` type. The other operands are
constant indices to specify which value to extract in a similar manner
-as indices in a '``getelementptr``' instruction.
+as indices in a '`getelementptr`' instruction.
-The major differences to ``getelementptr`` indexing are:
+The major differences to `getelementptr` indexing are:
- Since the value being indexed is not a pointer, the first index is
omitted and assumed to be zero.
- At least one index must be specified.
- Not only struct indices but also array indices must be in bounds.
-Semantics:
-""""""""""
+##### Semantics:
The result is the value at the position in the aggregate specified by
the index operands.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- <result> = extractvalue {i32, float} %agg, 0 ; yields i32
+```text
+<result> = extractvalue {i32, float} %agg, 0 ; yields i32
+```
-.. _i_insertvalue:
+(i_insertvalue)=
-'``insertvalue``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`insertvalue`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = insertvalue <aggregate type> <val>, <ty> <elt>, <idx>{, <idx>}* ; yields <aggregate type>
+```
+<result> = insertvalue <aggregate type> <val>, <ty> <elt>, <idx>{, <idx>}* ; yields <aggregate type>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``insertvalue``' instruction inserts a value into a member field in
-an :ref:`aggregate <t_aggregate>` value.
+The '`insertvalue`' instruction inserts a value into a member field in
+an {ref}`aggregate <t_aggregate>` value.
-Arguments:
-""""""""""
+##### Arguments:
-The first operand of an '``insertvalue``' instruction is a value of
-:ref:`struct <t_struct>` or :ref:`array <t_array>` type. The second operand is
+The first operand of an '`insertvalue`' instruction is a value of
+{ref}`struct <t_struct>` or {ref}`array <t_array>` type. The second operand is
a first-class value to insert. The following operands are constant
indices indicating the position at which to insert the value in a
-similar manner as indices in a '``extractvalue``' instruction. The value
+similar manner as indices in a '`extractvalue`' instruction. The value
to insert must have the same type as the value identified by the
indices.
-Semantics:
-""""""""""
+##### Semantics:
-The result is an aggregate of the same type as ``val``. Its value is
-that of ``val`` except that the value at the position specified by the
-indices is that of ``elt``.
-
-Example:
-""""""""
+The result is an aggregate of the same type as `val`. Its value is
+that of `val` except that the value at the position specified by the
+indices is that of `elt`.
-.. code-block:: llvm
+##### Example:
- %agg1 = insertvalue {i32, float} poison, i32 1, 0 ; yields {i32 1, float poison}
- %agg2 = insertvalue {i32, float} %agg1, float %val, 1 ; yields {i32 1, float %val}
- %agg3 = insertvalue {i32, {float}} poison, float %val, 1, 0 ; yields {i32 poison, {float %val}}
+```llvm
+%agg1 = insertvalue {i32, float} poison, i32 1, 0 ; yields {i32 1, float poison}
+%agg2 = insertvalue {i32, float} %agg1, float %val, 1 ; yields {i32 1, float %val}
+%agg3 = insertvalue {i32, {float}} poison, float %val, 1, 0 ; yields {i32 poison, {float %val}}
+```
-.. _memoryops:
+(memoryops)=
-Memory Access and Addressing Operations
----------------------------------------
+### Memory Access and Addressing Operations
A key design point of an SSA-based representation is how it represents
memory. In LLVM, no memory locations are in SSA form, which makes things
very simple. This section describes how to read, write, and allocate
memory in LLVM.
-.. _i_alloca:
+(i_alloca)=
-'``alloca``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`alloca`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = alloca [inalloca] <type> [, <ty> <NumElements>] [, align <alignment>] [, addrspace(<num>)] ; yields type addrspace(num)*:result
+```
+<result> = alloca [inalloca] <type> [, <ty> <NumElements>] [, align <alignment>] [, addrspace(<num>)] ; yields type addrspace(num)*:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``alloca``' instruction allocates memory on the stack frame of the
+The '`alloca`' instruction allocates memory on the stack frame of the
currently executing function, to be automatically released when this
function returns to its caller. If the address space is not explicitly
specified, the default address space 0 is used.
-Arguments:
-""""""""""
+##### Arguments:
-The '``alloca``' instruction allocates ``sizeof(<type>)*NumElements``
+The '`alloca`' instruction allocates `sizeof(<type>)*NumElements`
bytes of memory on the runtime stack, returning a pointer of the
appropriate type to the program. If "NumElements" is specified, it is
the number of elements allocated, otherwise "NumElements" is defaulted
@@ -11946,159 +11612,151 @@ to be one.
If a constant alignment is specified, the value result of the
allocation is guaranteed to be aligned to at least that boundary. The
-alignment may not be greater than ``1 << 32``.
+alignment may not be greater than `1 << 32`.
The alignment is only optional when parsing textual IR; for in-memory IR,
it is always present. If not specified, the target can choose to align the
allocation on any convenient boundary compatible with the type.
-'``type``' may be any sized type.
+'`type`' may be any sized type.
Structs containing scalable vectors cannot be used in allocas unless all
-fields are the same scalable vector type (e.g., ``{<vscale x 2 x i32>,
-<vscale x 2 x i32>}`` contains the same type while ``{<vscale x 2 x i32>,
-<vscale x 2 x i64>}`` doesn't).
+fields are the same scalable vector type (e.g.,
+`{<vscale x 2 x i32>, <vscale x 2 x i32>}` contains the same type while
+`{<vscale x 2 x i32>, <vscale x 2 x i64>}` doesn't).
-Semantics:
-""""""""""
+##### Semantics:
Memory is allocated; a pointer is returned. The allocated memory is
uninitialized, and loading from uninitialized memory produces an undefined
value. The operation itself is undefined if there is insufficient stack
-space for the allocation.'``alloca``'d memory is automatically released
-when the function returns. The '``alloca``' instruction is commonly used
+space for the allocation.'`alloca`'d memory is automatically released
+when the function returns. The '`alloca`' instruction is commonly used
to represent automatic variables that must have an address available. When
-the function returns (either with the ``ret`` or ``resume`` instructions),
+the function returns (either with the `ret` or `resume` instructions),
the memory is reclaimed. Allocating zero bytes is legal, but the returned
pointer may not be unique. The order in which memory is allocated (ie.,
which way the stack grows) is not specified.
-Note that '``alloca``' outside of the alloca address space from the
-:ref:`datalayout string<langref_datalayout>` is meaningful only if the
+Note that '`alloca`' outside of the alloca address space from the
+{ref}`datalayout string<langref_datalayout>` is meaningful only if the
target has assigned it a semantics. For targets that specify a non-zero alloca
-address space in the :ref:`datalayout string<langref_datalayout>`, the alloca
+address space in the {ref}`datalayout string<langref_datalayout>`, the alloca
address space needs to be explicitly specified in the instruction if it is to be
used.
-If the returned pointer is used by :ref:`llvm.lifetime.start <int_lifestart>`,
+If the returned pointer is used by {ref}`llvm.lifetime.start <int_lifestart>`,
the returned object is initially dead.
-See :ref:`llvm.lifetime.start <int_lifestart>` and
-:ref:`llvm.lifetime.end <int_lifeend>` for the precise semantics of
+See {ref}`llvm.lifetime.start <int_lifestart>` and
+{ref}`llvm.lifetime.end <int_lifeend>` for the precise semantics of
lifetime-manipulating intrinsics.
-If the element count is ``undef`` or ``poison``, this instruction has undefined
+If the element count is `undef` or `poison`, this instruction has undefined
behavior.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %ptr = alloca i32 ; yields ptr
- %ptr = alloca i32, i32 4 ; yields ptr
- %ptr = alloca i32, i32 4, align 1024 ; yields ptr
- %ptr = alloca i32, align 1024 ; yields ptr
+```llvm
+%ptr = alloca i32 ; yields ptr
+%ptr = alloca i32, i32 4 ; yields ptr
+%ptr = alloca i32, i32 4, align 1024 ; yields ptr
+%ptr = alloca i32, align 1024 ; yields ptr
+```
-.. _i_load:
+(i_load)=
-'``load``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`load`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = load [volatile] <ty>, ptr <pointer>[, align <alignment>][, !nontemporal !<nontemp_node>][, !invariant.load !<empty_node>][, !invariant.group !<empty_node>][, !nonnull !<empty_node>][, !dereferenceable !<deref_bytes_node>][, !dereferenceable_or_null !<deref_bytes_node>][, !align !<align_node>][, !noundef !<empty_node>]
- <result> = load atomic [volatile] <ty>, ptr <pointer> [syncscope("<target-scope>")] <ordering>, align <alignment> [, !invariant.group !<empty_node>]
- !<nontemp_node> = !{ i32 1 }
- !<empty_node> = !{}
- !<deref_bytes_node> = !{ i64 <dereferenceable_bytes> }
- !<align_node> = !{ i64 <value_alignment> }
+```
+<result> = load [volatile] <ty>, ptr <pointer>[, align <alignment>][, !nontemporal !<nontemp_node>][, !invariant.load !<empty_node>][, !invariant.group !<empty_node>][, !nonnull !<empty_node>][, !dereferenceable !<deref_bytes_node>][, !dereferenceable_or_null !<deref_bytes_node>][, !align !<align_node>][, !noundef !<empty_node>]
+<result> = load atomic [volatile] <ty>, ptr <pointer> [syncscope("<target-scope>")] <ordering>, align <alignment> [, !invariant.group !<empty_node>]
+!<nontemp_node> = !{ i32 1 }
+!<empty_node> = !{}
+!<deref_bytes_node> = !{ i64 <dereferenceable_bytes> }
+!<align_node> = !{ i64 <value_alignment> }
+```
-Overview:
-"""""""""
+##### Overview:
-The '``load``' instruction is used to read from memory.
+The '`load`' instruction is used to read from memory.
-Arguments:
-""""""""""
+##### Arguments:
-The argument to the ``load`` instruction specifies the memory address from which
-to load. The type specified must be a :ref:`first class <t_firstclass>` type of
-known size (i.e., not containing an :ref:`opaque structural type <t_opaque>`). If
-the ``load`` is marked as ``volatile``, then the optimizer is not allowed to
-modify the number or order of execution of this ``load`` with other
-:ref:`volatile operations <volatile>`.
+The argument to the `load` instruction specifies the memory address from which
+to load. The type specified must be a {ref}`first class <t_firstclass>` type of
+known size (i.e., not containing an {ref}`opaque structural type <t_opaque>`). If
+the `load` is marked as `volatile`, then the optimizer is not allowed to
+modify the number or order of execution of this `load` with other
+{ref}`volatile operations <volatile>`.
-If the ``load`` is marked as ``atomic``, it takes an extra :ref:`ordering
-<ordering>` and optional ``syncscope("<target-scope>")`` argument. The
-``release`` and ``acq_rel`` orderings are not valid on ``load`` instructions.
-Atomic loads produce :ref:`defined <memmodel>` results when they may see
+If the `load` is marked as `atomic`, it takes an extra {ref}`ordering <ordering>` and optional `syncscope("<target-scope>")` argument. The
+`release` and `acq_rel` orderings are not valid on `load` instructions.
+Atomic loads produce {ref}`defined <memmodel>` results when they may see
multiple atomic stores. The type of the pointee must be an integer, pointer,
floating-point, or vector type whose bit width is a power of two greater than
-or equal to eight. ``align`` must be
+or equal to eight. `align` must be
explicitly specified on atomic loads. Note: if the alignment is not greater or
equal to the size of the `<value>` type, the atomic operation is likely to
-require a lock and have poor performance. ``!nontemporal`` does not have any
+require a lock and have poor performance. `!nontemporal` does not have any
defined semantics for atomic loads.
-The optional constant ``align`` argument specifies the alignment of the
+The optional constant `align` argument specifies the alignment of the
operation (that is, the alignment of the memory address). It is the
responsibility of the code emitter to ensure that the alignment information is
correct. Overestimating the alignment results in undefined behavior.
Underestimating the alignment may produce less efficient code. An alignment of
-1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
+1 is always safe. The maximum possible alignment is `1 << 32`. An alignment
value higher than the size of the loaded type does *not* imply (without target
specific knowledge) that memory up to the alignment value bytes can be safely
loaded without trapping.
The alignment is only optional when parsing textual IR; for in-memory IR, it is
-always present. An omitted ``align`` argument means that the operation has the
+always present. An omitted `align` argument means that the operation has the
ABI alignment for the target.
-The optional ``!nontemporal`` metadata must reference a single
-metadata name ``<nontemp_node>`` corresponding to a metadata node with one
-``i32`` entry of value 1. The existence of the ``!nontemporal``
+The optional `!nontemporal` metadata must reference a single
+metadata name `<nontemp_node>` corresponding to a metadata node with one
+`i32` entry of value 1. The existence of the `!nontemporal`
metadata on the instruction tells the optimizer and code generator
that this load is not expected to be reused in the cache. The code
generator may select special instructions to save cache bandwidth, such
-as the ``MOVNT`` instruction on x86.
+as the `MOVNT` instruction on x86.
-The optional ``!invariant.load`` metadata must reference a single
-metadata name ``<empty_node>`` corresponding to a metadata node with no
-entries. If a load instruction tagged with the ``!invariant.load``
+The optional `!invariant.load` metadata must reference a single
+metadata name `<empty_node>` corresponding to a metadata node with no
+entries. If a load instruction tagged with the `!invariant.load`
metadata is executed, the memory location referenced by the load has
to contain the same value at all points in the program where the
memory location is dereferenceable; otherwise, the behavior is
undefined.
-The optional ``!invariant.group`` metadata must reference a single metadata name
- ``<empty_node>`` corresponding to a metadata node with no entries.
- See ``invariant.group`` metadata :ref:`invariant.group <md_invariant.group>`.
+The optional `!invariant.group` metadata must reference a single metadata name
+: `<empty_node>` corresponding to a metadata node with no entries.
+ See `invariant.group` metadata {ref}`invariant.group <md_invariant.group>`.
-The optional ``!nonnull`` metadata must reference a single
-metadata name ``<empty_node>`` corresponding to a metadata node with no
-entries. The existence of the ``!nonnull`` metadata on the
+The optional `!nonnull` metadata must reference a single
+metadata name `<empty_node>` corresponding to a metadata node with no
+entries. The existence of the `!nonnull` metadata on the
instruction tells the optimizer that the value loaded is known to
never be null. If the value is null at runtime, a poison value is returned
-instead. This is analogous to the ``nonnull`` attribute on parameters and
+instead. This is analogous to the `nonnull` attribute on parameters and
return values. This metadata can only be applied to loads of a pointer type.
-The optional ``!dereferenceable`` metadata must reference a single metadata
-name ``<deref_bytes_node>`` corresponding to a metadata node with one ``i64``
+The optional `!dereferenceable` metadata must reference a single metadata
+name `<deref_bytes_node>` corresponding to a metadata node with one `i64`
entry.
-See ``dereferenceable`` metadata :ref:`dereferenceable <md_dereferenceable>`.
+See `dereferenceable` metadata {ref}`dereferenceable <md_dereferenceable>`.
-The optional ``!dereferenceable_or_null`` metadata must reference a single
-metadata name ``<deref_bytes_node>`` corresponding to a metadata node with one
-``i64`` entry.
-See ``dereferenceable_or_null`` metadata :ref:`dereferenceable_or_null
-<md_dereferenceable_or_null>`.
+The optional `!dereferenceable_or_null` metadata must reference a single
+metadata name `<deref_bytes_node>` corresponding to a metadata node with one
+`i64` entry.
+See `dereferenceable_or_null` metadata {ref}`dereferenceable_or_null <md_dereferenceable_or_null>`.
-The optional ``!align`` metadata must reference a single metadata name
-``<align_node>`` corresponding to a metadata node with one ``i64`` entry.
-The existence of the ``!align`` metadata on the instruction tells the
+The optional `!align` metadata must reference a single metadata name
+`<align_node>` corresponding to a metadata node with one `i64` entry.
+The existence of the `!align` metadata on the instruction tells the
optimizer that the value loaded is known to be aligned to a boundary specified
by the integer value in the metadata node. The alignment must be a power of 2.
This is analogous to the ''align'' attribute on parameters and return values.
@@ -12106,240 +11764,218 @@ This metadata can only be applied to loads of a pointer type. If the returned
value is not appropriately aligned at runtime, a poison value is returned
instead.
-The optional ``!noundef`` metadata must reference a single metadata name
-``<empty_node>`` corresponding to a node with no entries. The existence of
-``!noundef`` metadata on the instruction tells the optimizer that the value
-loaded is known to be :ref:`well defined <welldefinedvalues>`.
-If the value isn't well defined, the behavior is undefined. If the ``!noundef``
-metadata is combined with poison-generating metadata like ``!nonnull``,
+The optional `!noundef` metadata must reference a single metadata name
+`<empty_node>` corresponding to a node with no entries. The existence of
+`!noundef` metadata on the instruction tells the optimizer that the value
+loaded is known to be {ref}`well defined <welldefinedvalues>`.
+If the value isn't well defined, the behavior is undefined. If the `!noundef`
+metadata is combined with poison-generating metadata like `!nonnull`,
violation of that metadata constraint will also result in undefined behavior.
-Semantics:
-""""""""""
+##### Semantics:
The location of memory pointed to is loaded. If the value being loaded
is of scalar type then the number of bytes read does not exceed the
minimum number of bytes needed to hold all bits of the type. For
-example, loading an ``i24`` reads at most three bytes. When loading a
-value of a type like ``i20`` with a size that is not an integral number
+example, loading an `i24` reads at most three bytes. When loading a
+value of a type like `i20` with a size that is not an integral number
of bytes, the load will be performed on the next larger multiple of the byte
-size (here ``i24``) and truncated. If any of the truncated bits are non-zero,
+size (here `i24`) and truncated. If any of the truncated bits are non-zero,
the result is a poison value. As such, a non-byte-sized load behaves like a
-byte-sized load followed by a ``trunc nuw`` operation.
+byte-sized load followed by a `trunc nuw` operation.
If the value being loaded is of aggregate type, the bytes that correspond to
padding may be accessed but are ignored, because it is impossible to observe
padding from the loaded aggregate value.
-If ``<pointer>`` is not a well-defined value, the behavior is undefined.
+If `<pointer>` is not a well-defined value, the behavior is undefined.
The behavior of loading a value of a type that differs from the type used to
-store it is described in the :ref:`bitcast <i_bitcast>` section.
-
-Examples:
-"""""""""
+store it is described in the {ref}`bitcast <i_bitcast>` section.
-.. code-block:: llvm
+##### Examples:
- %ptr = alloca i32 ; yields ptr
- store i32 3, ptr %ptr ; yields void
- %val = load i32, ptr %ptr ; yields i32:val = i32 3
+```llvm
+%ptr = alloca i32 ; yields ptr
+store i32 3, ptr %ptr ; yields void
+%val = load i32, ptr %ptr ; yields i32:val = i32 3
+```
-.. _i_store:
+(i_store)=
-'``store``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^
+#### '`store`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- store [volatile] <ty> <value>, ptr <pointer>[, align <alignment>][, !nontemporal !<nontemp_node>][, !invariant.group !<empty_node>] ; yields void
- store atomic [volatile] <ty> <value>, ptr <pointer> [syncscope("<target-scope>")] <ordering>, align <alignment> [, !invariant.group !<empty_node>] ; yields void
- !<nontemp_node> = !{ i32 1 }
- !<empty_node> = !{}
+```
+store [volatile] <ty> <value>, ptr <pointer>[, align <alignment>][, !nontemporal !<nontemp_node>][, !invariant.group !<empty_node>] ; yields void
+store atomic [volatile] <ty> <value>, ptr <pointer> [syncscope("<target-scope>")] <ordering>, align <alignment> [, !invariant.group !<empty_node>] ; yields void
+!<nontemp_node> = !{ i32 1 }
+!<empty_node> = !{}
+```
-Overview:
-"""""""""
+##### Overview:
-The '``store``' instruction is used to write to memory.
+The '`store`' instruction is used to write to memory.
-Arguments:
-""""""""""
+##### Arguments:
-There are two arguments to the ``store`` instruction: a value to store and an
-address at which to store it. The type of the ``<pointer>`` operand must be a
-pointer to the :ref:`first class <t_firstclass>` type of the ``<value>``
-operand. If the ``store`` is marked as ``volatile``, then the optimizer is not
-allowed to modify the number or order of execution of this ``store`` with other
-:ref:`volatile operations <volatile>`. Only values of :ref:`first class
-<t_firstclass>` types of known size (i.e., not containing an :ref:`opaque
-structural type <t_opaque>`) can be stored.
+There are two arguments to the `store` instruction: a value to store and an
+address at which to store it. The type of the `<pointer>` operand must be a
+pointer to the {ref}`first class <t_firstclass>` type of the `<value>`
+operand. If the `store` is marked as `volatile`, then the optimizer is not
+allowed to modify the number or order of execution of this `store` with other
+{ref}`volatile operations <volatile>`. Only values of {ref}`first class <t_firstclass>` types of known size (i.e., not containing an {ref}`opaque structural type <t_opaque>`) can be stored.
-If the ``store`` is marked as ``atomic``, it takes an extra :ref:`ordering
-<ordering>` and optional ``syncscope("<target-scope>")`` argument. The
-``acquire`` and ``acq_rel`` orderings aren't valid on ``store`` instructions.
-Atomic loads produce :ref:`defined <memmodel>` results when they may see
+If the `store` is marked as `atomic`, it takes an extra {ref}`ordering <ordering>` and optional `syncscope("<target-scope>")` argument. The
+`acquire` and `acq_rel` orderings aren't valid on `store` instructions.
+Atomic loads produce {ref}`defined <memmodel>` results when they may see
multiple atomic stores. The type of the pointee must be an integer, pointer,
floating-point, or vector type whose bit width is a power of two greater than
-or equal to eight. ``align`` must be
+or equal to eight. `align` must be
explicitly specified on atomic stores. Note: if the alignment is not greater or
equal to the size of the `<value>` type, the atomic operation is likely to
-require a lock and have poor performance. ``!nontemporal`` does not have any
+require a lock and have poor performance. `!nontemporal` does not have any
defined semantics for atomic stores.
-The optional constant ``align`` argument specifies the alignment of the
+The optional constant `align` argument specifies the alignment of the
operation (that is, the alignment of the memory address). It is the
responsibility of the code emitter to ensure that the alignment information is
correct. Overestimating the alignment results in undefined behavior.
Underestimating the alignment may produce less efficient code. An alignment of
-1 is always safe. The maximum possible alignment is ``1 << 32``. An alignment
+1 is always safe. The maximum possible alignment is `1 << 32`. An alignment
value higher than the size of the stored type does *not* imply (without target
specific knowledge) that memory up to the alignment value bytes can be safely
loaded without trapping.
The alignment is only optional when parsing textual IR; for in-memory IR, it is
-always present. An omitted ``align`` argument means that the operation has the
+always present. An omitted `align` argument means that the operation has the
ABI alignment for the target.
-The optional ``!nontemporal`` metadata must reference a single metadata
-name ``<nontemp_node>`` corresponding to a metadata node with one ``i32`` entry
-of value 1. The existence of the ``!nontemporal`` metadata on the instruction
+The optional `!nontemporal` metadata must reference a single metadata
+name `<nontemp_node>` corresponding to a metadata node with one `i32` entry
+of value 1. The existence of the `!nontemporal` metadata on the instruction
tells the optimizer and code generator that this load is not expected to
be reused in the cache. The code generator may select special
-instructions to save cache bandwidth, such as the ``MOVNT`` instruction on
+instructions to save cache bandwidth, such as the `MOVNT` instruction on
x86.
-The optional ``!invariant.group`` metadata must reference a
-single metadata name ``<empty_node>``. See ``invariant.group`` metadata.
+The optional `!invariant.group` metadata must reference a
+single metadata name `<empty_node>`. See `invariant.group` metadata.
-Semantics:
-""""""""""
+##### Semantics:
-The contents of memory are updated to contain ``<value>`` at the
-location specified by the ``<pointer>`` operand. If ``<value>`` is
+The contents of memory are updated to contain `<value>` at the
+location specified by the `<pointer>` operand. If `<value>` is
of scalar type then the number of bytes written does not exceed the
minimum number of bytes needed to hold all bits of the type. For
-example, storing an ``i24`` writes at most three bytes. When writing a
-value of a type like ``i20`` with a size that is not an integral number
+example, storing an `i24` writes at most three bytes. When writing a
+value of a type like `i20` with a size that is not an integral number
of bytes, the value will be zero extended to the next larger multiple of the
-byte size (here ``i24``) and then stored. As such, a non-byte-sized store
-behaves like a ``zext`` followed by a byte-sized store.
-
-If ``<value>`` is of aggregate type, padding is filled with
-:ref:`undef <undefvalues>`.
-If ``<pointer>`` is not a well-defined value, the behavior is undefined.
-
-Example:
-""""""""
+byte size (here `i24`) and then stored. As such, a non-byte-sized store
+behaves like a `zext` followed by a byte-sized store.
-.. code-block:: llvm
+If `<value>` is of aggregate type, padding is filled with
+{ref}`undef <undefvalues>`.
+If `<pointer>` is not a well-defined value, the behavior is undefined.
- %ptr = alloca i32 ; yields ptr
- store i32 3, ptr %ptr ; yields void
- %val = load i32, ptr %ptr ; yields i32:val = i32 3
+##### Example:
-.. _i_fence:
+```llvm
+%ptr = alloca i32 ; yields ptr
+store i32 3, ptr %ptr ; yields void
+%val = load i32, ptr %ptr ; yields i32:val = i32 3
+```
-'``fence``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^
+(i_fence)=
-Syntax:
-"""""""
+#### '`fence`' Instruction
-::
+##### Syntax:
- fence [syncscope("<target-scope>")] <ordering> ; yields void
+```
+fence [syncscope("<target-scope>")] <ordering> ; yields void
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fence``' instruction is used to introduce happens-before edges
+The '`fence`' instruction is used to introduce happens-before edges
between operations.
-Arguments:
-""""""""""
+##### Arguments:
-'``fence``' instructions take an :ref:`ordering <ordering>` argument which
+'`fence`' instructions take an {ref}`ordering <ordering>` argument which
defines what *synchronizes-with* edges they add. They can only be given
-``acquire``, ``release``, ``acq_rel``, and ``seq_cst`` orderings.
+`acquire`, `release`, `acq_rel`, and `seq_cst` orderings.
-Semantics:
-""""""""""
+##### Semantics:
-A fence A which has (at least) ``release`` ordering semantics
-*synchronizes with* a fence B with (at least) ``acquire`` ordering
+A fence A which has (at least) `release` ordering semantics
+*synchronizes with* a fence B with (at least) `acquire` ordering
semantics if and only if there exist atomic operations X and Y, both
operating on some atomic object M, such that A is sequenced before X, X
modifies M (either directly or through some side effect of a sequence
headed by X), Y is sequenced before B, and Y observes M. This provides a
*happens-before* dependency between A and B. Rather than an explicit
-``fence``, one (but not both) of the atomic operations X or Y might
-provide a ``release`` or ``acquire`` (resp.) ordering constraint and
-still *synchronize-with* the explicit ``fence`` and establish the
+`fence`, one (but not both) of the atomic operations X or Y might
+provide a `release` or `acquire` (resp.) ordering constraint and
+still *synchronize-with* the explicit `fence` and establish the
*happens-before* edge.
-A ``fence`` which has ``seq_cst`` ordering, in addition to having both
-``acquire`` and ``release`` semantics specified above, participates in
-the global program order of other ``seq_cst`` operations and/or
-fences. Furthermore, the global ordering created by a ``seq_cst``
+A `fence` which has `seq_cst` ordering, in addition to having both
+`acquire` and `release` semantics specified above, participates in
+the global program order of other `seq_cst` operations and/or
+fences. Furthermore, the global ordering created by a `seq_cst`
fence must be compatible with the individual total orders of
-``monotonic`` (or stronger) memory accesses occurring before and after
+`monotonic` (or stronger) memory accesses occurring before and after
such a fence. The exact semantics of this interaction are somewhat
-complicated, see the C++ standard's `[atomics.order]
-<https://wg21.link/atomics.order>`_ section for more details.
-
-A ``fence`` instruction can also take an optional
-":ref:`syncscope <syncscope>`" argument.
-
-Example:
-""""""""
+complicated, see the C++ standard's [[atomics.order]](https://wg21.link/atomics.order) section for more details.
-.. code-block:: text
+A `fence` instruction can also take an optional
+"{ref}`syncscope <syncscope>`" argument.
- fence acquire ; yields void
- fence syncscope("singlethread") seq_cst ; yields void
- fence syncscope("agent") seq_cst ; yields void
+##### Example:
-.. _i_cmpxchg:
+```text
+fence acquire ; yields void
+fence syncscope("singlethread") seq_cst ; yields void
+fence syncscope("agent") seq_cst ; yields void
+```
-'``cmpxchg``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_cmpxchg)=
-Syntax:
-"""""""
+#### '`cmpxchg`' Instruction
-::
+##### Syntax:
- cmpxchg [weak] [volatile] ptr <pointer>, <ty> <cmp>, <ty> <new> [syncscope("<target-scope>")] <success ordering> <failure ordering>[, align <alignment>] ; yields { ty, i1 }
+```
+cmpxchg [weak] [volatile] ptr <pointer>, <ty> <cmp>, <ty> <new> [syncscope("<target-scope>")] <success ordering> <failure ordering>[, align <alignment>] ; yields { ty, i1 }
+```
-Overview:
-"""""""""
+##### Overview:
-The '``cmpxchg``' instruction is used to atomically modify memory. It
+The '`cmpxchg`' instruction is used to atomically modify memory. It
loads a value in memory and compares it to a given value. If they are
equal, it tries to store a new value into the memory.
-Arguments:
-""""""""""
+##### Arguments:
-There are three arguments to the '``cmpxchg``' instruction: an address
+There are three arguments to the '`cmpxchg`' instruction: an address
to operate on, a value to compare to the value currently be at that
address, and a new value to place at that address if the compared values
-are equal. The type of '<cmp>' must be an integer or pointer type whose
+are equal. The type of `<cmp>` must be an integer or pointer type whose
bit width is a power of two greater than or equal to eight.
-'<cmp>' and '<new>' must
-have the same type, and the type of '<pointer>' must be a pointer to
-that type. If the ``cmpxchg`` is marked as ``volatile``, then the
+`<cmp>` and `<new>` must
+have the same type, and the type of `<pointer>` must be a pointer to
+that type. If the `cmpxchg` is marked as `volatile`, then the
optimizer is not allowed to modify the number or order of execution of
-this ``cmpxchg`` with other :ref:`volatile operations <volatile>`.
+this `cmpxchg` with other {ref}`volatile operations <volatile>`.
-The success and failure :ref:`ordering <ordering>` arguments specify how this
-``cmpxchg`` synchronizes with other atomic operations. Both ordering parameters
-must be at least ``monotonic``, the failure ordering cannot be either
-``release`` or ``acq_rel``.
+The success and failure {ref}`ordering <ordering>` arguments specify how this
+`cmpxchg` synchronizes with other atomic operations. Both ordering parameters
+must be at least `monotonic`, the failure ordering cannot be either
+`release` or `acq_rel`.
-A ``cmpxchg`` instruction can also take an optional
-":ref:`syncscope <syncscope>`" argument.
+A `cmpxchg` instruction can also take an optional
+"{ref}`syncscope <syncscope>`" argument.
Note: if the alignment is not greater or equal to the size of the `<value>`
type, the atomic operation is likely to require a lock and have poor
@@ -12347,73 +11983,67 @@ performance.
The alignment is only optional when parsing textual IR; for in-memory IR, it is
always present. If unspecified, the alignment is assumed to be equal to the
-size of the '<value>' type. Note that this default alignment assumption is
+size of the `<value>` type. Note that this default alignment assumption is
different from the alignment used for the load/store instructions when align
isn't specified.
The pointer passed into cmpxchg must have alignment greater than or
equal to the size in memory of the operand.
-Semantics:
-""""""""""
+##### Semantics:
-The contents of memory at the location specified by the '``<pointer>``' operand
-is read and compared to '``<cmp>``'; if the values are equal, '``<new>``' is
+The contents of memory at the location specified by the '`<pointer>`' operand
+is read and compared to '`<cmp>`'; if the values are equal, '`<new>`' is
written to the location. The original value at the location is returned,
together with a flag indicating success (true) or failure (false).
-If the cmpxchg operation is marked as ``weak`` then a spurious failure is
-permitted: the operation may not write ``<new>`` even if the comparison
+If the cmpxchg operation is marked as `weak` then a spurious failure is
+permitted: the operation may not write `<new>` even if the comparison
matched.
If the cmpxchg operation is strong (the default), the i1 value is 1 if and only
-if the value loaded equals ``cmp``.
+if the value loaded equals `cmp`.
-A successful ``cmpxchg`` is a read-modify-write instruction for the purpose of
-identifying release sequences. A failed ``cmpxchg`` is equivalent to an atomic
+A successful `cmpxchg` is a read-modify-write instruction for the purpose of
+identifying release sequences. A failed `cmpxchg` is equivalent to an atomic
load with an ordering parameter determined the second ordering parameter.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- entry:
- %orig = load atomic i32, ptr %ptr unordered, align 4 ; yields i32
- br label %loop
+```llvm
+entry:
+ %orig = load atomic i32, ptr %ptr unordered, align 4 ; yields i32
+ br label %loop
- loop:
- %cmp = phi i32 [ %orig, %entry ], [%value_loaded, %loop]
- %squared = mul i32 %cmp, %cmp
- %val_success = cmpxchg ptr %ptr, i32 %cmp, i32 %squared acq_rel monotonic ; yields { i32, i1 }
- %value_loaded = extractvalue { i32, i1 } %val_success, 0
- %success = extractvalue { i32, i1 } %val_success, 1
- br i1 %success, label %done, label %loop
+loop:
+ %cmp = phi i32 [ %orig, %entry ], [%value_loaded, %loop]
+ %squared = mul i32 %cmp, %cmp
+ %val_success = cmpxchg ptr %ptr, i32 %cmp, i32 %squared acq_rel monotonic ; yields { i32, i1 }
+ %value_loaded = extractvalue { i32, i1 } %val_success, 0
+ %success = extractvalue { i32, i1 } %val_success, 1
+ br i1 %success, label %done, label %loop
- done:
- ...
-
-.. _i_atomicrmw:
+done:
+ ...
+```
-'``atomicrmw``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_atomicrmw)=
-Syntax:
-"""""""
+#### '`atomicrmw`' Instruction
-::
+##### Syntax:
- atomicrmw [volatile] [elementwise] <operation> ptr <pointer>, <ty> <value> [syncscope("<target-scope>")] <ordering>[, align <alignment>] ; yields ty
+```
+atomicrmw [volatile] [elementwise] <operation> ptr <pointer>, <ty> <value> [syncscope("<target-scope>")] <ordering>[, align <alignment>] ; yields ty
+```
-Overview:
-"""""""""
+##### Overview:
-The '``atomicrmw``' instruction is used to atomically modify memory.
+The '`atomicrmw`' instruction is used to atomically modify memory.
-Arguments:
-""""""""""
+##### Arguments:
-There are three arguments to the '``atomicrmw``' instruction: an
+There are three arguments to the '`atomicrmw`' instruction: an
operation to apply, an address whose value to modify, an argument to the
operation. The operation must be one of the following keywords:
@@ -12441,14 +12071,14 @@ operation. The operation must be one of the following keywords:
- usub_cond
- usub_sat
-For all of these operations, the type of '<value>' must be a type whose bit width is a power of two greater than or equal to eight.
-For add/sub/and/nand/or/xor/max/min/umax/umin/uinc_wrap/udec_wrap/usub_cond/usub_sat, this must be an integer type, or, if the ``elementwise`` modifier is present, a fixed vector of integer type.
+For all of these operations, the type of `<value>` must be a type whose bit width is a power of two greater than or equal to eight.
+For add/sub/and/nand/or/xor/max/min/umax/umin/uinc_wrap/udec_wrap/usub_cond/usub_sat, this must be an integer type, or, if the `elementwise` modifier is present, a fixed vector of integer type.
For fadd/fsub/fmax/fmin/fmaximum/fminimum/fmaximumnum/fminimumnum, this must be a floating-point or fixed vector of floating-point type.
-For xchg, this must be an integer type, floating-point type, or pointer type, or, if the ``elementwise`` modifier is present, a fixed vector of integer type, floating-point type, or pointer type.
-The type of the '<pointer>' operand must be a pointer to the type of '<value>'.
-If the ``atomicrmw`` is marked as ``volatile``, then the optimizer is not allowed to modify the
-number or order of execution of this ``atomicrmw`` with other
-:ref:`volatile operations <volatile>`.
+For xchg, this must be an integer type, floating-point type, or pointer type, or, if the `elementwise` modifier is present, a fixed vector of integer type, floating-point type, or pointer type.
+The type of the `<pointer>` operand must be a pointer to the type of `<value>`.
+If the `atomicrmw` is marked as `volatile`, then the optimizer is not allowed to modify the
+number or order of execution of this `atomicrmw` with other
+{ref}`volatile operations <volatile>`.
Note: if the alignment is not greater or equal to the size of the `<value>`
type, the atomic operation is likely to require a lock and have poor
@@ -12456,84 +12086,78 @@ performance.
The alignment is only optional when parsing textual IR; for in-memory IR, it is
always present. If unspecified, the alignment is assumed to be equal to the
-size of the '<value>' type. Note that this default alignment assumption is
+size of the `<value>` type. Note that this default alignment assumption is
different from the alignment used for the load/store instructions when align
isn't specified.
-An ``atomicrmw`` instruction can also take an optional
-":ref:`syncscope <syncscope>`" argument.
+An `atomicrmw` instruction can also take an optional
+"{ref}`syncscope <syncscope>`" argument.
-If the ``elementwise`` modifier is present, the instruction has per-element vector
-atomic semantics. It behaves as if it were expanded into one scalar ``atomicrmw`` per element, that are not ordered with respect to each other.
-Without ``elementwise``, vector ``atomicrmw`` keeps whole-value atomic semantics.
+If the `elementwise` modifier is present, the instruction has per-element vector
+atomic semantics. It behaves as if it were expanded into one scalar `atomicrmw` per element, that are not ordered with respect to each other.
+Without `elementwise`, vector `atomicrmw` keeps whole-value atomic semantics.
-Semantics:
-""""""""""
+##### Semantics:
-The contents of memory at the location specified by the '``<pointer>``'
+The contents of memory at the location specified by the '`<pointer>`'
operand are atomically read, modified, and written back. The original
value at the location is returned. The modification is specified by the
operation argument:
-- xchg: ``*ptr = val``
-- add: ``*ptr = *ptr + val``
-- sub: ``*ptr = *ptr - val``
-- and: ``*ptr = *ptr & val``
-- nand: ``*ptr = ~(*ptr & val)``
-- or: ``*ptr = *ptr | val``
-- xor: ``*ptr = *ptr ^ val``
-- max: ``*ptr = *ptr > val ? *ptr : val`` (using a signed comparison)
-- min: ``*ptr = *ptr < val ? *ptr : val`` (using a signed comparison)
-- umax: ``*ptr = *ptr > val ? *ptr : val`` (using an unsigned comparison)
-- umin: ``*ptr = *ptr < val ? *ptr : val`` (using an unsigned comparison)
-- fadd: ``*ptr = *ptr + val`` (using floating point arithmetic)
-- fsub: ``*ptr = *ptr - val`` (using floating point arithmetic)
-- fmax: ``*ptr = maxnum(*ptr, val)`` (match the `llvm.maxnum.*` intrinsic)
-- fmin: ``*ptr = minnum(*ptr, val)`` (match the `llvm.minnum.*` intrinsic)
-- fmaximum: ``*ptr = maximum(*ptr, val)`` (match the `llvm.maximum.*` intrinsic)
-- fminimum: ``*ptr = minimum(*ptr, val)`` (match the `llvm.minimum.*` intrinsic)
-- fmaximumnum: ``*ptr = maximumnum(*ptr, val)`` (match the `llvm.maximumnum.*` intrinsic)
-- fminimumnum: ``*ptr = minimumnum(*ptr, val)`` (match the `llvm.minimumnum.*` intrinsic)
-- uinc_wrap: ``*ptr = (*ptr u>= val) ? 0 : (*ptr + 1)`` (increment value with wraparound to zero when incremented above input value)
-- udec_wrap: ``*ptr = ((*ptr == 0) || (*ptr u> val)) ? val : (*ptr - 1)`` (decrement with wraparound to input value when decremented below zero).
-- usub_cond: ``*ptr = (*ptr u>= val) ? *ptr - val : *ptr`` (subtract only if no unsigned overflow).
-- usub_sat: ``*ptr = (*ptr u>= val) ? *ptr - val : 0`` (subtract with unsigned clamping to zero).
-
-
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %old = atomicrmw add ptr %ptr, i32 1 acquire ; yields i32
-
-.. _i_getelementptr:
-
-'``getelementptr``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-
-::
-
- <result> = getelementptr <ty>, ptr <ptrval>{, <ty> <idx>}*
- <result> = getelementptr inbounds <ty>, ptr <ptrval>{, <ty> <idx>}*
- <result> = getelementptr nusw <ty>, ptr <ptrval>{, <ty> <idx>}*
- <result> = getelementptr nuw <ty>, ptr <ptrval>{, <ty> <idx>}*
- <result> = getelementptr inrange(S,E) <ty>, ptr <ptrval>{, <ty> <idx>}*
- <result> = getelementptr <ty>, <N x ptr> <ptrval>, <vector index type> <idx>
-
-Overview:
-"""""""""
-
-The '``getelementptr``' instruction is used to get the address of a
-subelement of an :ref:`aggregate <t_aggregate>` data structure. It performs
+- xchg: `*ptr = val`
+- add: `*ptr = *ptr + val`
+- sub: `*ptr = *ptr - val`
+- and: `*ptr = *ptr & val`
+- nand: `*ptr = ~(*ptr & val)`
+- or: `*ptr = *ptr | val`
+- xor: `*ptr = *ptr ^ val`
+- max: `*ptr = *ptr > val ? *ptr : val` (using a signed comparison)
+- min: `*ptr = *ptr < val ? *ptr : val` (using a signed comparison)
+- umax: `*ptr = *ptr > val ? *ptr : val` (using an unsigned comparison)
+- umin: `*ptr = *ptr < val ? *ptr : val` (using an unsigned comparison)
+- fadd: `*ptr = *ptr + val` (using floating point arithmetic)
+- fsub: `*ptr = *ptr - val` (using floating point arithmetic)
+- fmax: `*ptr = maxnum(*ptr, val)` (match the `llvm.maxnum.*` intrinsic)
+- fmin: `*ptr = minnum(*ptr, val)` (match the `llvm.minnum.*` intrinsic)
+- fmaximum: `*ptr = maximum(*ptr, val)` (match the `llvm.maximum.*` intrinsic)
+- fminimum: `*ptr = minimum(*ptr, val)` (match the `llvm.minimum.*` intrinsic)
+- fmaximumnum: `*ptr = maximumnum(*ptr, val)` (match the `llvm.maximumnum.*` intrinsic)
+- fminimumnum: `*ptr = minimumnum(*ptr, val)` (match the `llvm.minimumnum.*` intrinsic)
+- uinc_wrap: `*ptr = (*ptr u>= val) ? 0 : (*ptr + 1)` (increment value with wraparound to zero when incremented above input value)
+- udec_wrap: `*ptr = ((*ptr == 0) || (*ptr u> val)) ? val : (*ptr - 1)` (decrement with wraparound to input value when decremented below zero).
+- usub_cond: `*ptr = (*ptr u>= val) ? *ptr - val : *ptr` (subtract only if no unsigned overflow).
+- usub_sat: `*ptr = (*ptr u>= val) ? *ptr - val : 0` (subtract with unsigned clamping to zero).
+
+
+##### Example:
+
+```llvm
+%old = atomicrmw add ptr %ptr, i32 1 acquire ; yields i32
+```
+
+(i_getelementptr)=
+
+#### '`getelementptr`' Instruction
+
+##### Syntax:
+
+```
+<result> = getelementptr <ty>, ptr <ptrval>{, <ty> <idx>}*
+<result> = getelementptr inbounds <ty>, ptr <ptrval>{, <ty> <idx>}*
+<result> = getelementptr nusw <ty>, ptr <ptrval>{, <ty> <idx>}*
+<result> = getelementptr nuw <ty>, ptr <ptrval>{, <ty> <idx>}*
+<result> = getelementptr inrange(S,E) <ty>, ptr <ptrval>{, <ty> <idx>}*
+<result> = getelementptr <ty>, <N x ptr> <ptrval>, <vector index type> <idx>
+```
+
+##### Overview:
+
+The '`getelementptr`' instruction is used to get the address of a
+subelement of an {ref}`aggregate <t_aggregate>` data structure. It performs
address calculation only and does not access memory. The instruction can also
be used to calculate a vector of such addresses.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is always a type used as the basis for the calculations.
The second argument is always a pointer or a vector of pointers, and is the
@@ -12549,9 +12173,9 @@ subsequent types being indexed into can never be pointers, since that
would require loading the pointer before continuing calculation.
The type of each index argument depends on the type it is indexing into.
-When indexing into a (optionally packed) structure, only ``i32`` integer
+When indexing into a (optionally packed) structure, only `i32` integer
**constants** are allowed (when using a vector of indices they must all
-be the **same** ``i32`` integer constant). When indexing into an array,
+be the **same** `i32` integer constant). When indexing into an array,
pointer or vector, integers of any width are allowed, and they are not
required to be constant. These integers are treated as signed values
where relevant.
@@ -12559,64 +12183,63 @@ where relevant.
For example, let's consider a C code fragment and how it gets compiled
to LLVM:
-.. code-block:: c
-
- struct RT {
- char A;
- int B[10][20];
- char C;
- };
- struct ST {
- int X;
- double Y;
- struct RT Z;
- };
-
- int *foo(struct ST *s) {
- return &s[1].Z.B[5][13];
- }
+```c
+struct RT {
+ char A;
+ int B[10][20];
+ char C;
+};
+struct ST {
+ int X;
+ double Y;
+ struct RT Z;
+};
+
+int *foo(struct ST *s) {
+ return &s[1].Z.B[5][13];
+}
+```
The LLVM code generated by Clang is approximately:
-.. code-block:: llvm
+```llvm
+%struct.RT = type { i8, [10 x [20 x i32]], i8 }
+%struct.ST = type { i32, double, %struct.RT }
- %struct.RT = type { i8, [10 x [20 x i32]], i8 }
- %struct.ST = type { i32, double, %struct.RT }
+define ptr @foo(ptr %s) {
+entry:
+ %arrayidx = getelementptr inbounds %struct.ST, ptr %s, i64 1, i32 2, i32 1, i64 5, i64 13
+ ret ptr %arrayidx
+}
+```
- define ptr @foo(ptr %s) {
- entry:
- %arrayidx = getelementptr inbounds %struct.ST, ptr %s, i64 1, i32 2, i32 1, i64 5, i64 13
- ret ptr %arrayidx
- }
-
-Semantics:
-""""""""""
+##### Semantics:
In the example above, the first index is indexing into the
-'``%struct.ST*``' type, which is a pointer, yielding a '``%struct.ST``'
-= '``{ i32, double, %struct.RT }``' type, a structure. The second index
+'`%struct.ST*`' type, which is a pointer, yielding a '`%struct.ST`'
+= '`{ i32, double, %struct.RT }`' type, a structure. The second index
indexes into the third element of the structure, yielding a
-'``%struct.RT``' = '``{ i8 , [10 x [20 x i32]], i8 }``' type, another
+'`%struct.RT`' = '`{ i8 , [10 x [20 x i32]], i8 }`' type, another
structure. The third index indexes into the second element of the
-structure, yielding a '``[10 x [20 x i32]]``' type, an array. The two
-dimensions of the array are subscripted into, yielding an '``i32``'
-type. The '``getelementptr``' instruction returns a pointer to this
+structure, yielding a '`[10 x [20 x i32]]`' type, an array. The two
+dimensions of the array are subscripted into, yielding an '`i32`'
+type. The '`getelementptr`' instruction returns a pointer to this
element.
Note that it is perfectly legal to index partially through a structure,
returning a pointer to an inner element. Because of this, the LLVM code
for the given testcase is equivalent to:
-.. code-block:: llvm
-
- define ptr @foo(ptr %s) {
- %t1 = getelementptr %struct.ST, ptr %s, i32 1
- %t2 = getelementptr %struct.ST, ptr %t1, i32 0, i32 2
- %t3 = getelementptr %struct.RT, ptr %t2, i32 0, i32 1
- %t4 = getelementptr [10 x [20 x i32]], ptr %t3, i32 0, i32 5
- %t5 = getelementptr [20 x i32], ptr %t4, i32 0, i32 13
- ret ptr %t5
- }
+```llvm
+define ptr @foo(ptr %s) {
+ %t1 = getelementptr %struct.ST, ptr %s, i32 1
+ %t2 = getelementptr %struct.ST, ptr %t1, i32 0, i32 2
+ %t3 = getelementptr %struct.RT, ptr %t2, i32 0, i32 1
+ %t4 = getelementptr [10 x [20 x i32]], ptr %t3, i32 0, i32 5
+ %t5 = getelementptr [20 x i32], ptr %t4, i32 0, i32 13
+ ret ptr %t5
+}
+```
The indices are first converted to offsets in the pointer's index type. If the
currently indexed type is a struct type, the struct offset corresponding to the
@@ -12630,50 +12253,50 @@ type width, with silently-wrapping two's complement arithmetic. If the pointer
size is larger than the index size, this means that the bits outside the index
type width will not be affected.
-The result value of the ``getelementptr`` may be outside the object pointed
+The result value of the `getelementptr` may be outside the object pointed
to by the base pointer. The result value may not necessarily be used to access
memory though, even if it happens to point into allocated storage. See the
-:ref:`Pointer Aliasing Rules <pointeraliasing>` section for more
+{ref}`Pointer Aliasing Rules <pointeraliasing>` section for more
information.
-The ``getelementptr`` instruction may have a number of attributes that impose
+The `getelementptr` instruction may have a number of attributes that impose
additional rules. If any of the rules are violated, the result value is a
-:ref:`poison value <poisonvalues>`. In cases where the base is a vector of
+{ref}`poison value <poisonvalues>`. In cases where the base is a vector of
pointers, the attributes apply to each computation element-wise.
-For ``nusw`` (no unsigned signed wrap):
+For `nusw` (no unsigned signed wrap):
* If the type of an index is larger than the pointer index type, the
truncation to the pointer index type preserves the signed value
- (``trunc nsw``).
+ (`trunc nsw`).
* The multiplication of an index by the type size does not wrap the pointer
- index type in a signed sense (``mul nsw``).
+ index type in a signed sense (`mul nsw`).
* The successive addition of each offset (without adding the base address)
- does not wrap the pointer index type in a signed sense (``add nsw``).
+ does not wrap the pointer index type in a signed sense (`add nsw`).
* The successive addition of the current address, truncated to the pointer
index type and interpreted as an unsigned number, and each offset,
interpreted as a signed number, does not wrap the pointer index type.
-For ``nuw`` (no unsigned wrap):
+For `nuw` (no unsigned wrap):
* If the type of an index is larger than the pointer index type, the
truncation to the pointer index type preserves the unsigned value
- (``trunc nuw``).
+ (`trunc nuw`).
* The multiplication of an index by the type size does not wrap the pointer
- index type in an unsigned sense (``mul nuw``).
+ index type in an unsigned sense (`mul nuw`).
* The successive addition of each offset (without adding the base address)
- does not wrap the pointer index type in an unsigned sense (``add nuw``).
+ does not wrap the pointer index type in an unsigned sense (`add nuw`).
* The successive addition of the current address, truncated to the pointer
index type and interpreted as an unsigned number, and each offset, also
interpreted as an unsigned number, does not wrap the pointer index type
- (``add nuw``).
+ (`add nuw`).
-For ``inbounds`` all rules of the ``nusw`` attribute apply. Additionally,
-if the ``getelementptr`` has any non-zero indices, the following rules apply:
+For `inbounds` all rules of the `nusw` attribute apply. Additionally,
+if the `getelementptr` has any non-zero indices, the following rules apply:
* The base pointer has an *in bounds* address of the
- :ref:`allocated object<allocatedobjects>` that it is
- :ref:`based <pointeraliasing>` on. This means that it points into that
+ {ref}`allocated object<allocatedobjects>` that it is
+ {ref}`based <pointeraliasing>` on. This means that it points into that
allocated object, or to its end. Note that the object does not have to be
live anymore; being in-bounds of a deallocated object is sufficient.
If the allocated object can grow, then the relevant size for being *in
@@ -12682,284 +12305,256 @@ if the ``getelementptr`` has any non-zero indices, the following rules apply:
* During the successive addition of offsets to the address, the resulting
pointer must remain *in bounds* of the allocated object at each step.
-Note that ``getelementptr`` with all-zero indices is always considered to be
-``inbounds``, even if the base pointer does not point to an allocated object.
+Note that `getelementptr` with all-zero indices is always considered to be
+`inbounds`, even if the base pointer does not point to an allocated object.
As a corollary, the only pointer in bounds of the null pointer in the default
address space is the null pointer itself.
-If ``inbounds`` is present on a ``getelementptr`` instruction, the ``nusw``
-attribute will be automatically set as well. For this reason, the ``nusw``
-will also not be printed in textual IR if ``inbounds`` is already present.
+If `inbounds` is present on a `getelementptr` instruction, the `nusw`
+attribute will be automatically set as well. For this reason, the `nusw`
+will also not be printed in textual IR if `inbounds` is already present.
-If the ``inrange(Start, End)`` attribute is present, loading from or
-storing to any pointer derived from the ``getelementptr`` has undefined
+If the `inrange(Start, End)` attribute is present, loading from or
+storing to any pointer derived from the `getelementptr` has undefined
behavior if the load or store would access memory outside the half-open range
-``[Start, End)`` from the ``getelementptr`` expression result. The result of
-a pointer comparison or ``ptrtoint`` (including ``ptrtoint``-like operations
-involving memory) involving a pointer derived from a ``getelementptr`` with
-the ``inrange`` keyword is undefined, with the exception of comparisons
-in the case where both operands are in the closed range ``[Start, End]``.
-Note that the ``inrange`` keyword is currently only allowed
-in constant ``getelementptr`` expressions.
+`[Start, End)` from the `getelementptr` expression result. The result of
+a pointer comparison or `ptrtoint` (including `ptrtoint`-like operations
+involving memory) involving a pointer derived from a `getelementptr` with
+the `inrange` keyword is undefined, with the exception of comparisons
+in the case where both operands are in the closed range `[Start, End]`.
+Note that the `inrange` keyword is currently only allowed
+in constant `getelementptr` expressions.
The getelementptr instruction is often confusing. For some more insight
-into how it works, see :doc:`the getelementptr FAQ <GetElementPtr>`.
+into how it works, see {doc}`the getelementptr FAQ <GetElementPtr>`.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %aptr = getelementptr {i32, [12 x i8]}, ptr %saptr, i64 0, i32 1
- %vptr = getelementptr {i32, <2 x i8>}, ptr %svptr, i64 0, i32 1, i32 1
- %eptr = getelementptr [12 x i8], ptr %aptr, i64 0, i32 1
- %iptr = getelementptr [10 x i32], ptr @arr, i16 0, i16 0
+```llvm
+%aptr = getelementptr {i32, [12 x i8]}, ptr %saptr, i64 0, i32 1
+%vptr = getelementptr {i32, <2 x i8>}, ptr %svptr, i64 0, i32 1, i32 1
+%eptr = getelementptr [12 x i8], ptr %aptr, i64 0, i32 1
+%iptr = getelementptr [10 x i32], ptr @arr, i16 0, i16 0
+```
-Vector of pointers:
-"""""""""""""""""""
+##### Vector of pointers:
-The ``getelementptr`` returns a vector of pointers, instead of a single address,
+The `getelementptr` returns a vector of pointers, instead of a single address,
when one or more of its arguments is a vector. In such cases, all vector
arguments should have the same number of elements, and every scalar argument
will be effectively broadcast into a vector during address calculation.
-.. code-block:: llvm
+```llvm
+; All arguments are vectors:
+; A[i] = ptrs[i] + offsets[i]*sizeof(i8)
+%A = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets
- ; All arguments are vectors:
- ; A[i] = ptrs[i] + offsets[i]*sizeof(i8)
- %A = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets
+; Add the same scalar offset to each pointer of a vector:
+; A[i] = ptrs[i] + offset*sizeof(i8)
+%A = getelementptr i8, <4 x ptr> %ptrs, i64 %offset
- ; Add the same scalar offset to each pointer of a vector:
- ; A[i] = ptrs[i] + offset*sizeof(i8)
- %A = getelementptr i8, <4 x ptr> %ptrs, i64 %offset
+; Add distinct offsets to the same pointer:
+; A[i] = ptr + offsets[i]*sizeof(i8)
+%A = getelementptr i8, ptr %ptr, <4 x i64> %offsets
- ; Add distinct offsets to the same pointer:
- ; A[i] = ptr + offsets[i]*sizeof(i8)
- %A = getelementptr i8, ptr %ptr, <4 x i64> %offsets
-
- ; In all cases described above the type of the result is <4 x ptr>
+; In all cases described above the type of the result is <4 x ptr>
+```
The two following instructions are equivalent:
-.. code-block:: llvm
-
- getelementptr %struct.ST, <4 x ptr> %s, <4 x i64> %ind1,
- <4 x i32> <i32 2, i32 2, i32 2, i32 2>,
- <4 x i32> <i32 1, i32 1, i32 1, i32 1>,
- <4 x i32> %ind4,
- <4 x i64> <i64 13, i64 13, i64 13, i64 13>
+```llvm
+getelementptr %struct.ST, <4 x ptr> %s, <4 x i64> %ind1,
+ <4 x i32> <i32 2, i32 2, i32 2, i32 2>,
+ <4 x i32> <i32 1, i32 1, i32 1, i32 1>,
+ <4 x i32> %ind4,
+ <4 x i64> <i64 13, i64 13, i64 13, i64 13>
- getelementptr %struct.ST, <4 x ptr> %s, <4 x i64> %ind1,
- i32 2, i32 1, <4 x i32> %ind4, i64 13
+getelementptr %struct.ST, <4 x ptr> %s, <4 x i64> %ind1,
+ i32 2, i32 1, <4 x i32> %ind4, i64 13
+```
-Let's look at the C code, where the vector version of ``getelementptr``
+Let's look at the C code, where the vector version of `getelementptr`
makes sense:
-.. code-block:: c
+```c
+// Let's assume that we vectorize the following loop:
+double *A, *B; int *C;
+for (int i = 0; i < size; ++i) {
+ A[i] = B[C[i]];
+}
+```
- // Let's assume that we vectorize the following loop:
- double *A, *B; int *C;
- for (int i = 0; i < size; ++i) {
- A[i] = B[C[i]];
- }
+```llvm
+; get pointers for 8 elements from array B
+%ptrs = getelementptr double, ptr %B, <8 x i32> %C
+; load 8 elements from array B into A
+%A = call <8 x double> @llvm.masked.gather.v8f64.v8p0f64(
+ <8 x ptr> align 8 %ptrs, <8 x i1> %mask, <8 x double> %passthru)
+```
-.. code-block:: llvm
-
- ; get pointers for 8 elements from array B
- %ptrs = getelementptr double, ptr %B, <8 x i32> %C
- ; load 8 elements from array B into A
- %A = call <8 x double> @llvm.masked.gather.v8f64.v8p0f64(
- <8 x ptr> align 8 %ptrs, <8 x i1> %mask, <8 x double> %passthru)
-
-Conversion Operations
----------------------
+### Conversion Operations
The instructions in this category are the conversion instructions
(casting) which all take a single operand and a type. They perform
various bit conversions on the operand.
-.. _i_trunc:
+(i_trunc)=
-'``trunc .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`trunc .. to`' Instruction
-::
+##### Syntax:
- <result> = trunc <ty> <value> to <ty2> ; yields ty2
- <result> = trunc nsw <ty> <value> to <ty2> ; yields ty2
- <result> = trunc nuw <ty> <value> to <ty2> ; yields ty2
- <result> = trunc nuw nsw <ty> <value> to <ty2> ; yields ty2
+```
+<result> = trunc <ty> <value> to <ty2> ; yields ty2
+<result> = trunc nsw <ty> <value> to <ty2> ; yields ty2
+<result> = trunc nuw <ty> <value> to <ty2> ; yields ty2
+<result> = trunc nuw nsw <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``trunc``' instruction truncates its operand to the type ``ty2``.
+The '`trunc`' instruction truncates its operand to the type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``trunc``' instruction takes a value to trunc, and a type to trunc
-it to. Both types must be of :ref:`integer <t_integer>` types, or vectors
-of the same number of integers. The bit size of the ``value`` must be
-larger than the bit size of the destination type, ``ty2``. Equal sized
+The '`trunc`' instruction takes a value to trunc, and a type to trunc
+it to. Both types must be of {ref}`integer <t_integer>` types, or vectors
+of the same number of integers. The bit size of the `value` must be
+larger than the bit size of the destination type, `ty2`. Equal sized
types are not allowed.
-Semantics:
-""""""""""
+##### Semantics:
-The '``trunc``' instruction truncates the high order bits in ``value``
-and converts the remaining bits to ``ty2``. Since the source size must
-be larger than the destination size, ``trunc`` cannot be a *no-op cast*.
+The '`trunc`' instruction truncates the high order bits in `value`
+and converts the remaining bits to `ty2`. Since the source size must
+be larger than the destination size, `trunc` cannot be a *no-op cast*.
It will always truncate bits.
-If the ``nuw`` keyword is present, and any of the truncated bits are non-zero,
-the result is a :ref:`poison value <poisonvalues>`. If the ``nsw`` keyword
+If the `nuw` keyword is present, and any of the truncated bits are non-zero,
+the result is a {ref}`poison value <poisonvalues>`. If the `nsw` keyword
is present, and any of the truncated bits are not the same as the top bit
-of the truncation result, the result is a :ref:`poison value <poisonvalues>`.
+of the truncation result, the result is a {ref}`poison value <poisonvalues>`.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = trunc i32 257 to i8 ; yields i8:1
- %Y = trunc i32 123 to i1 ; yields i1:true
- %Z = trunc i32 122 to i1 ; yields i1:false
- %W = trunc <2 x i16> <i16 8, i16 7> to <2 x i8> ; yields <i8 8, i8 7>
+```llvm
+%X = trunc i32 257 to i8 ; yields i8:1
+%Y = trunc i32 123 to i1 ; yields i1:true
+%Z = trunc i32 122 to i1 ; yields i1:false
+%W = trunc <2 x i16> <i16 8, i16 7> to <2 x i8> ; yields <i8 8, i8 7>
+```
-.. _i_zext:
+(i_zext)=
-'``zext .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`zext .. to`' Instruction
-::
+##### Syntax:
- <result> = zext <ty> <value> to <ty2> ; yields ty2
+```
+<result> = zext <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``zext``' instruction zero extends its operand to type ``ty2``.
+The '`zext`' instruction zero extends its operand to type `ty2`.
-The ``nneg`` (non-negative) flag, if present, specifies that the operand is
+The `nneg` (non-negative) flag, if present, specifies that the operand is
non-negative. This property may be used by optimization passes to later
-convert the ``zext`` into a ``sext``.
+convert the `zext` into a `sext`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``zext``' instruction takes a value to cast, and a type to cast it
-to. Both types must be of :ref:`integer <t_integer>` types, or vectors of
-the same number of integers. The bit size of the ``value`` must be
-smaller than the bit size of the destination type, ``ty2``.
+The '`zext`' instruction takes a value to cast, and a type to cast it
+to. Both types must be of {ref}`integer <t_integer>` types, or vectors of
+the same number of integers. The bit size of the `value` must be
+smaller than the bit size of the destination type, `ty2`.
-Semantics:
-""""""""""
+##### Semantics:
-The ``zext`` fills the high order bits of the ``value`` with zero bits
-until it reaches the size of the destination type, ``ty2``.
+The `zext` fills the high order bits of the `value` with zero bits
+until it reaches the size of the destination type, `ty2`.
When zero extending from i1, the result will always be either 0 or 1.
-If the ``nneg`` flag is set, and the ``zext`` argument is negative, the result
+If the `nneg` flag is set, and the `zext` argument is negative, the result
is a poison value.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = zext i32 257 to i64 ; yields i64:257
- %Y = zext i1 true to i32 ; yields i32:1
- %Z = zext <2 x i16> <i16 8, i16 7> to <2 x i32> ; yields <i32 8, i32 7>
+```llvm
+%X = zext i32 257 to i64 ; yields i64:257
+%Y = zext i1 true to i32 ; yields i32:1
+%Z = zext <2 x i16> <i16 8, i16 7> to <2 x i32> ; yields <i32 8, i32 7>
- %a = zext nneg i8 127 to i16 ; yields i16 127
- %b = zext nneg i8 -1 to i16 ; yields i16 poison
+%a = zext nneg i8 127 to i16 ; yields i16 127
+%b = zext nneg i8 -1 to i16 ; yields i16 poison
+```
-.. _i_sext:
+(i_sext)=
-'``sext .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`sext .. to`' Instruction
-::
+##### Syntax:
- <result> = sext <ty> <value> to <ty2> ; yields ty2
+```
+<result> = sext <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``sext``' sign extends ``value`` to the type ``ty2``.
+The '`sext`' sign extends `value` to the type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``sext``' instruction takes a value to cast, and a type to cast it
-to. Both types must be of :ref:`integer <t_integer>` types, or vectors of
-the same number of integers. The bit size of the ``value`` must be
-smaller than the bit size of the destination type, ``ty2``.
+The '`sext`' instruction takes a value to cast, and a type to cast it
+to. Both types must be of {ref}`integer <t_integer>` types, or vectors of
+the same number of integers. The bit size of the `value` must be
+smaller than the bit size of the destination type, `ty2`.
-Semantics:
-""""""""""
+##### Semantics:
-The '``sext``' instruction performs a sign extension by copying the sign
-bit (highest order bit) of the ``value`` until it reaches the bit size
-of the type ``ty2``.
+The '`sext`' instruction performs a sign extension by copying the sign
+bit (highest order bit) of the `value` until it reaches the bit size
+of the type `ty2`.
When sign extending from i1, the extension always results in -1 or 0.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = sext i8 -1 to i16 ; yields i16 :65535
- %Y = sext i1 true to i32 ; yields i32:-1
- %Z = sext <2 x i16> <i16 8, i16 7> to <2 x i32> ; yields <i32 8, i32 7>
+```llvm
+%X = sext i8 -1 to i16 ; yields i16 :65535
+%Y = sext i1 true to i32 ; yields i32:-1
+%Z = sext <2 x i16> <i16 8, i16 7> to <2 x i32> ; yields <i32 8, i32 7>
+```
-.. _i_fptrunc:
+(i_fptrunc)=
-'``fptrunc .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`fptrunc .. to`' Instruction
-::
+##### Syntax:
- <result> = fptrunc [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
+<result> = fptrunc [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fptrunc``' instruction truncates ``value`` to type ``ty2``.
+The '`fptrunc`' instruction truncates `value` to type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``fptrunc``' instruction takes a :ref:`floating-point <t_floating>`
-value to cast and a :ref:`floating-point <t_floating>` type to cast it to.
-The size of ``value`` must be larger than the size of ``ty2``. This
-implies that ``fptrunc`` cannot be used to make a *no-op cast*.
+The '`fptrunc`' instruction takes a {ref}`floating-point <t_floating>`
+value to cast and a {ref}`floating-point <t_floating>` type to cast it to.
+The size of `value` must be larger than the size of `ty2`. This
+implies that `fptrunc` cannot be used to make a *no-op cast*.
-Semantics:
-""""""""""
+##### Semantics:
-The '``fptrunc``' instruction casts a ``value`` from a larger
-:ref:`floating-point <t_floating>` type to a smaller :ref:`floating-point
-<t_floating>` type.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`.
+The '`fptrunc`' instruction casts a `value` from a larger
+{ref}`floating-point <t_floating>` type to a smaller {ref}`floating-point <t_floating>` type.
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`.
-NaN values follow the usual :ref:`NaN behaviors <floatnan>`, except that _if_ a
+NaN values follow the usual {ref}`NaN behaviors <floatnan>`, except that _if_ a
NaN payload is propagated from the input ("Quieting NaN propagation" or
"Unchanged NaN propagation" cases), then the low order bits of the NaN payload
which cannot fit in the resulting type are discarded. Note that if discarding
@@ -12967,819 +12562,734 @@ the low order bits leads to an all-0 payload, this cannot be represented as a
signaling NaN (it would represent an infinity instead), so in that case
"Unchanged NaN propagation" is not possible.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = fptrunc double 16777217.0 to float ; yields float:16777216.0
- %Y = fptrunc double 1.0E+300 to half ; yields half:+infinity
+```llvm
+%X = fptrunc double 16777217.0 to float ; yields float:16777216.0
+%Y = fptrunc double 1.0E+300 to half ; yields half:+infinity
+```
-.. _i_fpext:
+(i_fpext)=
-'``fpext .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`fpext .. to`' Instruction
-::
+##### Syntax:
- <result> = fpext [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
+<result> = fpext [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fpext``' extends a floating-point ``value`` to a larger floating-point
+The '`fpext`' extends a floating-point `value` to a larger floating-point
value.
-Arguments:
-""""""""""
+##### Arguments:
-The '``fpext``' instruction takes a :ref:`floating-point <t_floating>`
-``value`` to cast, and a :ref:`floating-point <t_floating>` type to cast it
+The '`fpext`' instruction takes a {ref}`floating-point <t_floating>`
+`value` to cast, and a {ref}`floating-point <t_floating>` type to cast it
to. The source type must be smaller than the destination type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``fpext``' instruction extends the ``value`` from a smaller
-:ref:`floating-point <t_floating>` type to a larger :ref:`floating-point
-<t_floating>` type. The ``fpext`` cannot be used to make a
-*no-op cast* because it always changes bits. Use ``bitcast`` to make a
+The '`fpext`' instruction extends the `value` from a smaller
+{ref}`floating-point <t_floating>` type to a larger {ref}`floating-point <t_floating>` type. The `fpext` cannot be used to make a
+*no-op cast* because it always changes bits. Use `bitcast` to make a
*no-op cast* for a floating-point cast.
-NaN values follow the usual :ref:`NaN behaviors <floatnan>`, except that _if_ a
+NaN values follow the usual {ref}`NaN behaviors <floatnan>`, except that _if_ a
NaN payload is propagated from the input ("Quieting NaN propagation" or
"Unchanged NaN propagation" cases), then it is copied to the high order bits of
the resulting payload, and the remaining low order bits are zero.
-This instruction can also take any number of :ref:`fast-math
-flags <fastmath>`, which are optimization hints to enable otherwise
+This instruction can also take any number of {ref}`fast-math flags <fastmath>`, which are optimization hints to enable otherwise
unsafe floating-point optimizations.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %X = fpext float 3.125 to double ; yields double:3.125000e+00
- %Y = fpext double %X to fp128 ; yields fp128:0xL00000000000000004000900000000000
-
-'``fptoui .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-
-::
-
- <result> = fptoui <ty> <value> to <ty2> ; yields ty2
+##### Example:
-Overview:
-"""""""""
+```llvm
+%X = fpext float 3.125 to double ; yields double:3.125000e+00
+%Y = fpext double %X to fp128 ; yields fp128:0xL00000000000000004000900000000000
+```
-The '``fptoui``' converts a floating-point ``value`` to its unsigned
-integer equivalent of type ``ty2``.
+#### '`fptoui .. to`' Instruction
-Arguments:
-""""""""""
+##### Syntax:
-The '``fptoui``' instruction takes a value to cast, which must be a
-scalar or vector :ref:`floating-point <t_floating>` value, and a type to
-cast it to ``ty2``, which must be an :ref:`integer <t_integer>` type. If
-``ty`` is a vector floating-point type, ``ty2`` must be a vector integer
-type with the same number of elements as ``ty``
+```
+<result> = fptoui <ty> <value> to <ty2> ; yields ty2
+```
-Semantics:
-""""""""""
+##### Overview:
-The '``fptoui``' instruction converts its :ref:`floating-point
-<t_floating>` operand into the nearest (rounding towards zero)
-unsigned integer value. If the value cannot fit in ``ty2``, the result
-is a :ref:`poison value <poisonvalues>`.
+The '`fptoui`' converts a floating-point `value` to its unsigned
+integer equivalent of type `ty2`.
-Example:
-""""""""
+##### Arguments:
-.. code-block:: llvm
+The '`fptoui`' instruction takes a value to cast, which must be a
+scalar or vector {ref}`floating-point <t_floating>` value, and a type to
+cast it to `ty2`, which must be an {ref}`integer <t_integer>` type. If
+`ty` is a vector floating-point type, `ty2` must be a vector integer
+type with the same number of elements as `ty`
- %X = fptoui double 123.0 to i32 ; yields i32:123
- %Y = fptoui float 1.0E+300 to i1 ; yields undefined:1
- %Z = fptoui float 1.04E+17 to i8 ; yields undefined:1
+##### Semantics:
-'``fptosi .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The '`fptoui`' instruction converts its {ref}`floating-point <t_floating>` operand into the nearest (rounding towards zero)
+unsigned integer value. If the value cannot fit in `ty2`, the result
+is a {ref}`poison value <poisonvalues>`.
-Syntax:
-"""""""
+##### Example:
-::
+```llvm
+%X = fptoui double 123.0 to i32 ; yields i32:123
+%Y = fptoui float 1.0E+300 to i1 ; yields undefined:1
+%Z = fptoui float 1.04E+17 to i8 ; yields undefined:1
+```
- <result> = fptosi <ty> <value> to <ty2> ; yields ty2
+#### '`fptosi .. to`' Instruction
-Overview:
-"""""""""
+##### Syntax:
-The '``fptosi``' instruction converts :ref:`floating-point <t_floating>`
-``value`` to type ``ty2``.
+```
+<result> = fptosi <ty> <value> to <ty2> ; yields ty2
+```
-Arguments:
-""""""""""
+##### Overview:
-The '``fptosi``' instruction takes a value to cast, which must be a
-scalar or vector :ref:`floating-point <t_floating>` value, and a type to
-cast it to ``ty2``, which must be an :ref:`integer <t_integer>` type. If
-``ty`` is a vector floating-point type, ``ty2`` must be a vector integer
-type with the same number of elements as ``ty``
+The '`fptosi`' instruction converts {ref}`floating-point <t_floating>`
+`value` to type `ty2`.
-Semantics:
-""""""""""
+##### Arguments:
-The '``fptosi``' instruction converts its :ref:`floating-point
-<t_floating>` operand into the nearest (rounding towards zero)
-signed integer value. If the value cannot fit in ``ty2``, the result
-is a :ref:`poison value <poisonvalues>`.
+The '`fptosi`' instruction takes a value to cast, which must be a
+scalar or vector {ref}`floating-point <t_floating>` value, and a type to
+cast it to `ty2`, which must be an {ref}`integer <t_integer>` type. If
+`ty` is a vector floating-point type, `ty2` must be a vector integer
+type with the same number of elements as `ty`
-Example:
-""""""""
+##### Semantics:
-.. code-block:: llvm
+The '`fptosi`' instruction converts its {ref}`floating-point <t_floating>` operand into the nearest (rounding towards zero)
+signed integer value. If the value cannot fit in `ty2`, the result
+is a {ref}`poison value <poisonvalues>`.
- %X = fptosi double -123.0 to i32 ; yields i32:-123
- %Y = fptosi float 1.0E-247 to i1 ; yields undefined:1
- %Z = fptosi float 1.04E+17 to i8 ; yields undefined:1
+##### Example:
-.. _i_uitofp:
+```llvm
+%X = fptosi double -123.0 to i32 ; yields i32:-123
+%Y = fptosi float 1.0E-247 to i1 ; yields undefined:1
+%Z = fptosi float 1.04E+17 to i8 ; yields undefined:1
+```
-'``uitofp .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_uitofp)=
-Syntax:
-"""""""
+#### '`uitofp .. to`' Instruction
-::
+##### Syntax:
- <result> = uitofp [fast-math flags]* [nneg] <ty> <value> to <ty2> ; yields ty2
+```
+<result> = uitofp [fast-math flags]* [nneg] <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``uitofp``' instruction regards ``value`` as an unsigned integer
-and converts that value to the ``ty2`` type.
+The '`uitofp`' instruction regards `value` as an unsigned integer
+and converts that value to the `ty2` type.
-The ``nneg`` (non-negative) flag, if present, specifies that the
+The `nneg` (non-negative) flag, if present, specifies that the
operand is non-negative. This property may be used by optimization
-passes to later convert the ``uitofp`` into a ``sitofp``.
+passes to later convert the `uitofp` into a `sitofp`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``uitofp``' instruction takes a value to cast, which must be a
-scalar or vector :ref:`integer <t_integer>` value, and a type to cast it to
-``ty2``, which must be an :ref:`floating-point <t_floating>` type. If
-``ty`` is a vector integer type, ``ty2`` must be a vector floating-point
-type with the same number of elements as ``ty``
+The '`uitofp`' instruction takes a value to cast, which must be a
+scalar or vector {ref}`integer <t_integer>` value, and a type to cast it to
+`ty2`, which must be an {ref}`floating-point <t_floating>` type. If
+`ty` is a vector integer type, `ty2` must be a vector floating-point
+type with the same number of elements as `ty`
-Semantics:
-""""""""""
+##### Semantics:
-The '``uitofp``' instruction interprets its operand as an unsigned
+The '`uitofp`' instruction interprets its operand as an unsigned
integer quantity and converts it to the corresponding floating-point
value. If the value cannot be exactly represented, it is rounded using
the default rounding mode.
-If the ``nneg`` flag is set, and the ``uitofp`` argument is negative,
+If the `nneg` flag is set, and the `uitofp` argument is negative,
the result is a poison value.
If the '``nsz``' flag is set and the input value is 0, the sign bit of
the result is non-deterministic.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = uitofp i32 257 to float ; yields float:257.0
- %Y = uitofp i8 -1 to double ; yields double:255.0
+```llvm
+%X = uitofp i32 257 to float ; yields float:257.0
+%Y = uitofp i8 -1 to double ; yields double:255.0
- %a = uitofp nneg i32 256 to float ; yields float:256.0
- %b = uitofp nneg i32 -256 to float ; yields float poison
+%a = uitofp nneg i32 256 to float ; yields float:256.0
+%b = uitofp nneg i32 -256 to float ; yields float poison
+```
-.. _i_sitofp:
+(i_sitofp)=
-'``sitofp .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`sitofp .. to`' Instruction
-::
+##### Syntax:
- <result> = sitofp [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
+<result> = sitofp [fast-math flags]* <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``sitofp``' instruction regards ``value`` as a signed integer and
-converts that value to the ``ty2`` type.
+The '`sitofp`' instruction regards `value` as a signed integer and
+converts that value to the `ty2` type.
-Arguments:
-""""""""""
+##### Arguments:
-The '``sitofp``' instruction takes a value to cast, which must be a
-scalar or vector :ref:`integer <t_integer>` value, and a type to cast it to
-``ty2``, which must be an :ref:`floating-point <t_floating>` type. If
-``ty`` is a vector integer type, ``ty2`` must be a vector floating-point
-type with the same number of elements as ``ty``
+The '`sitofp`' instruction takes a value to cast, which must be a
+scalar or vector {ref}`integer <t_integer>` value, and a type to cast it to
+`ty2`, which must be an {ref}`floating-point <t_floating>` type. If
+`ty` is a vector integer type, `ty2` must be a vector floating-point
+type with the same number of elements as `ty`
-Semantics:
-""""""""""
+##### Semantics:
-The '``sitofp``' instruction interprets its operand as a signed integer
+The '`sitofp`' instruction interprets its operand as a signed integer
quantity and converts it to the corresponding floating-point value. If the
value cannot be exactly represented, it is rounded using the default rounding
mode.
-If the '``nsz``' flag is set and the input value is 0, the sign bit of
+If the '`nsz`' flag is set and the input value is 0, the sign bit of
the result is non-deterministic.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %X = sitofp i32 257 to float ; yields float:257.0
- %Y = sitofp i8 -1 to double ; yields double:-1.0
+##### Example:
-.. _i_ptrtoint:
+```llvm
+%X = sitofp i32 257 to float ; yields float:257.0
+%Y = sitofp i8 -1 to double ; yields double:-1.0
+```
-'``ptrtoint .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_ptrtoint)=
-Syntax:
-"""""""
+#### '`ptrtoint .. to`' Instruction
-::
+##### Syntax:
- <result> = ptrtoint <ty> <value> to <ty2> ; yields ty2
+```
+<result> = ptrtoint <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``ptrtoint``' instruction converts the pointer or a vector of
-pointers ``value`` to the integer (or vector of integers) type ``ty2``.
+The '`ptrtoint`' instruction converts the pointer or a vector of
+pointers `value` to the integer (or vector of integers) type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``ptrtoint``' instruction takes a ``value`` to cast, which must be
-a value of type :ref:`pointer <t_pointer>` or a vector of pointers, and a
-type to cast it to ``ty2``, which must be an :ref:`integer <t_integer>` or
+The '`ptrtoint`' instruction takes a `value` to cast, which must be
+a value of type {ref}`pointer <t_pointer>` or a vector of pointers, and a
+type to cast it to `ty2`, which must be an {ref}`integer <t_integer>` or
a vector of integers type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``ptrtoint``' instruction converts ``value`` to integer type
-``ty2`` by interpreting all the pointer representation bits as an integer
-(equivalent to a ``bitcast``) and either truncating or zero extending that value
+The '`ptrtoint`' instruction converts `value` to integer type
+`ty2` by interpreting all the pointer representation bits as an integer
+(equivalent to a `bitcast`) and either truncating or zero extending that value
to the size of the integer type.
-If ``value`` is smaller than ``ty2`` then a zero extension is done. If
-``value`` is larger than ``ty2`` then a truncation is done. If they are
+If `value` is smaller than `ty2` then a zero extension is done. If
+`value` is larger than `ty2` then a truncation is done. If they are
the same size, then nothing is done (*no-op cast*) other than a type
change.
-The ``ptrtoint`` always :ref:`captures address and provenance <pointercapture>`
+The `ptrtoint` always {ref}`captures address and provenance <pointercapture>`
of the pointer argument.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %X = ptrtoint ptr %P to i8 ; yields truncation on 32-bit architecture
- %Y = ptrtoint ptr %P to i64 ; yields zero extension on 32-bit architecture
- %Z = ptrtoint <4 x ptr> %P to <4 x i64>; yields vector zero extension for a vector of addresses on 32-bit architecture
+##### Example:
-.. _i_ptrtoaddr:
+```llvm
+%X = ptrtoint ptr %P to i8 ; yields truncation on 32-bit architecture
+%Y = ptrtoint ptr %P to i64 ; yields zero extension on 32-bit architecture
+%Z = ptrtoint <4 x ptr> %P to <4 x i64>; yields vector zero extension for a vector of addresses on 32-bit architecture
+```
-'``ptrtoaddr .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_ptrtoaddr)=
-Syntax:
-"""""""
+#### '`ptrtoaddr .. to`' Instruction
-::
+##### Syntax:
- <result> = ptrtoaddr <ty> <value> to <ty2> ; yields ty2
+```
+<result> = ptrtoaddr <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``ptrtoaddr``' instruction converts the pointer or a vector of
-pointers ``value`` to the underlying integer address (or vector of addresses) of
-type ``ty2``. This is different from :ref:`ptrtoint <i_ptrtoint>` in that it
+The '`ptrtoaddr`' instruction converts the pointer or a vector of
+pointers `value` to the underlying integer address (or vector of addresses) of
+type `ty2`. This is different from {ref}`ptrtoint <i_ptrtoint>` in that it
only operates on the index bits of the pointer and ignores all other bits, and
does not capture the provenance of the pointer.
-Arguments:
-""""""""""
+##### Arguments:
-The '``ptrtoaddr``' instruction takes a ``value`` to cast, which must be
-a value of type :ref:`pointer <t_pointer>` or a vector of pointers, and a
-type to cast it to ``ty2``, which must be must be the :ref:`integer <t_integer>`
+The '`ptrtoaddr`' instruction takes a `value` to cast, which must be
+a value of type {ref}`pointer <t_pointer>` or a vector of pointers, and a
+type to cast it to `ty2`, which must be must be the {ref}`integer <t_integer>`
type (or vector of integers) matching the pointer index width of the address
-space of ``ty``.
+space of `ty`.
-Semantics:
-""""""""""
+##### Semantics:
-The '``ptrtoaddr``' instruction converts ``value`` to integer type ``ty2`` by
+The '`ptrtoaddr`' instruction converts `value` to integer type `ty2` by
interpreting the lowest index-width pointer representation bits as an integer.
If the address size and the pointer representation size are the same and
-``value`` and ``ty2`` are the same size, then nothing is done (*no-op cast*)
+`value` and `ty2` are the same size, then nothing is done (*no-op cast*)
other than a type change.
-The ``ptrtoaddr`` instruction always :ref:`captures the address but not the provenance <pointercapture>`
+The `ptrtoaddr` instruction always {ref}`captures the address but not the provenance <pointercapture>`
of the pointer argument.
-Example:
-""""""""
+##### Example:
This example assumes pointers in address space 1 are 64 bits in size with an
-address width of 32 bits (``p1:64:64:64:32`` :ref:`datalayout string<langref_datalayout>`)
-
-.. code-block:: llvm
-
- %X = ptrtoaddr ptr addrspace(1) %P to i32 ; extracts low 32 bits of pointer
- %Y = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i32> ; yields vector of low 32 bits for each pointer
+address width of 32 bits (`p1:64:64:64:32` {ref}`datalayout string<langref_datalayout>`)
+```llvm
+%X = ptrtoaddr ptr addrspace(1) %P to i32 ; extracts low 32 bits of pointer
+%Y = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i32> ; yields vector of low 32 bits for each pointer
+```
-.. _i_inttoptr:
+(i_inttoptr)=
-'``inttoptr .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`inttoptr .. to`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = inttoptr <ty> <value> to <ty2>[, !dereferenceable !<deref_bytes_node>][, !dereferenceable_or_null !<deref_bytes_node>][, !nofree !<empty_node>] ; yields ty2
+```
+<result> = inttoptr <ty> <value> to <ty2>[, !dereferenceable !<deref_bytes_node>][, !dereferenceable_or_null !<deref_bytes_node>][, !nofree !<empty_node>] ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``inttoptr``' instruction converts an integer ``value`` to a
-pointer type, ``ty2``.
+The '`inttoptr`' instruction converts an integer `value` to a
+pointer type, `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``inttoptr``' instruction takes an :ref:`integer <t_integer>` value to
-cast, and a type to cast it to, which must be a :ref:`pointer <t_pointer>`
+The '`inttoptr`' instruction takes an {ref}`integer <t_integer>` value to
+cast, and a type to cast it to, which must be a {ref}`pointer <t_pointer>`
type.
-The optional ``!dereferenceable`` metadata must reference a single metadata
-name ``<deref_bytes_node>`` corresponding to a metadata node with one ``i64``
+The optional `!dereferenceable` metadata must reference a single metadata
+name `<deref_bytes_node>` corresponding to a metadata node with one `i64`
entry.
-See ``dereferenceable`` metadata.
+See `dereferenceable` metadata.
-The optional ``!dereferenceable_or_null`` metadata must reference a single
-metadata name ``<deref_bytes_node>`` corresponding to a metadata node with one
-``i64`` entry.
-See ``dereferenceable_or_null`` metadata.
+The optional `!dereferenceable_or_null` metadata must reference a single
+metadata name `<deref_bytes_node>` corresponding to a metadata node with one
+`i64` entry.
+See `dereferenceable_or_null` metadata.
-The optional ``!nofree`` metadata must reference a single metadata name
-``<empty_node>`` corresponding to a metadata node with no entries.
-The existence of the ``!nofree`` metadata on the instruction tells the optimizer
+The optional `!nofree` metadata must reference a single metadata name
+`<empty_node>` corresponding to a metadata node with no entries.
+The existence of the `!nofree` metadata on the instruction tells the optimizer
that the memory pointed by the pointer will not be freed after this point.
-Semantics:
-""""""""""
+##### Semantics:
-The '``inttoptr``' instruction converts ``value`` to type ``ty2`` by
+The '`inttoptr`' instruction converts `value` to type `ty2` by
applying either a zero extension or a truncation depending on the size
-of the integer ``value``. If ``value`` is larger than the size of a
-pointer then a truncation is done. If ``value`` is smaller than the size
+of the integer `value`. If `value` is larger than the size of a
+pointer then a truncation is done. If `value` is smaller than the size
of a pointer then a zero extension is done. If they are the same size,
nothing is done (*no-op cast*).
-The behavior is equivalent to a ``bitcast``, however, the resulting value is not
+The behavior is equivalent to a `bitcast`, however, the resulting value is not
guaranteed to be dereferenceable (e.g., if the result type is a
-:ref:`non-integral pointers <nointptrtype>`).
-
-Example:
-""""""""
+{ref}`non-integral pointers <nointptrtype>`).
-.. code-block:: llvm
+##### Example:
- %X = inttoptr i32 255 to ptr ; yields zero extension on 64-bit architecture
- %Y = inttoptr i32 255 to ptr ; yields no-op on 32-bit architecture
- %Z = inttoptr i64 0 to ptr ; yields truncation on 32-bit architecture
- %Z = inttoptr <4 x i32> %G to <4 x ptr>; yields truncation of vector G to four pointers
+```llvm
+%X = inttoptr i32 255 to ptr ; yields zero extension on 64-bit architecture
+%Y = inttoptr i32 255 to ptr ; yields no-op on 32-bit architecture
+%Z = inttoptr i64 0 to ptr ; yields truncation on 32-bit architecture
+%Z = inttoptr <4 x i32> %G to <4 x ptr>; yields truncation of vector G to four pointers
+```
-.. _i_bitcast:
+(i_bitcast)=
-'``bitcast .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`bitcast .. to`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = bitcast <ty> <value> to <ty2> ; yields ty2
+```
+<result> = bitcast <ty> <value> to <ty2> ; yields ty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``bitcast``' instruction converts ``value`` to type ``ty2`` without
+The '`bitcast`' instruction converts `value` to type `ty2` without
changing any bits.
-Arguments:
-""""""""""
+##### Arguments:
-The '``bitcast``' instruction takes a value to cast, which must be a
+The '`bitcast`' instruction takes a value to cast, which must be a
non-aggregate first class value, and a type to cast it to, which must
-also be a non-aggregate :ref:`first class <t_firstclass>` type. The
-bit sizes of ``value`` and the destination type, ``ty2``, must be
+also be a non-aggregate {ref}`first class <t_firstclass>` type. The
+bit sizes of `value` and the destination type, `ty2`, must be
identical. If the source type is a pointer, the destination type must also be a
pointer or a byte (vector of bytes) of the same size. This instruction supports
bitwise conversion of vectors to integers and to vectors of other types (as long
as they have the same size).
-Semantics:
-""""""""""
+##### Semantics:
-The '``bitcast``' instruction converts ``value`` to type ``ty2``. It
+The '`bitcast`' instruction converts `value` to type `ty2`. It
is always a *no-op cast* because no bits change with this
-conversion. The conversion is done as if the ``value`` had been stored
-to memory and read back as type ``ty2``. Pointer (or vector of
+conversion. The conversion is done as if the `value` had been stored
+to memory and read back as type `ty2`. Pointer (or vector of
pointers) types may only be converted to other pointer (or vector of
pointers) types with the same address space or byte (or vector of bytes) types
through this instruction. To convert pointers to other types, use the
-:ref:`inttoptr <i_inttoptr>` or :ref:`ptrtoint <i_ptrtoint>` instructions first.
+{ref}`inttoptr <i_inttoptr>` or {ref}`ptrtoint <i_ptrtoint>` instructions first.
There is a caveat for bitcasts involving vector types in relation to
-endianness. For example ``bitcast <2 x i8> <value> to i16`` puts element zero
+endianness. For example `bitcast <2 x i8> <value> to i16` puts element zero
of the vector in the least significant bits of the i16 for little-endian while
element zero ends up in the most significant bits for big-endian.
-If ``value`` is of the :ref:`byte type <t_byte>`:
+If `value` is of the {ref}`byte type <t_byte>`:
-* If ``ty2`` is a scalar type:
+* If `ty2` is a scalar type:
- * If ``ty2`` is a byte type, the original bits are unchanged.
+ * If `ty2` is a byte type, the original bits are unchanged.
- * If ``ty2`` is a pointer type:
+ * If `ty2` is a pointer type:
- * If at least one bit of ``value`` is ``poison``, the result is
- ``poison``.
+ * If at least one bit of `value` is `poison`, the result is
+ `poison`.
- * If all bits of ``value`` are from the same pointer and are correctly
+ * If all bits of `value` are from the same pointer and are correctly
ordered (there were no pointer bit swaps), the result is that pointer.
* Otherwise, the result is a pointer with the address given by the
integer value of the input, and without provenance.
- * If ``ty2`` is an integer or floating-point type:
+ * If `ty2` is an integer or floating-point type:
- * If at least one bit of ``value`` is ``poison``, the result is
- ``poison``.
+ * If at least one bit of `value` is `poison`, the result is
+ `poison`.
* Otherwise, the result is the value encoded by the input bits with
their provenance stripped without being exposed.
-* If ``ty2`` is a vector type, the input bits get sliced into chunks
+* If `ty2` is a vector type, the input bits get sliced into chunks
corresponding to lanes of the output. Each lane is then converted using the
rules for scalar types above.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- %X = bitcast i8 255 to i8 ; yields i8 :-1
- %Y = bitcast i32* %x to i16* ; yields i16*:%x
- %Z = bitcast <2 x i32> %V to i64; ; yields i64: %V (depends on endianness)
- %Z = bitcast <2 x i32*> %V to <2 x i64*> ; yields <2 x i64*>
+```text
+%X = bitcast i8 255 to i8 ; yields i8 :-1
+%Y = bitcast i32* %x to i16* ; yields i16*:%x
+%Z = bitcast <2 x i32> %V to i64; ; yields i64: %V (depends on endianness)
+%Z = bitcast <2 x i32*> %V to <2 x i64*> ; yields <2 x i64*>
- ; considering %bi to hold an integer and %bp to hold a pointer,
- %a = bitcast b64 %bi to i64 ; returns an integer, no-op cast
- %b = bitcast b64 %bp to i64 ; reinterprets the pointer as an integer, returning its address without exposing provenance
- %c = bitcast b64 %bp to ptr ; returns a pointer, no-op cast
- %d = bitcast b64 %bi to ptr ; reinterprets the integer as a pointer, returning a pointer with no provenance
+; considering %bi to hold an integer and %bp to hold a pointer,
+%a = bitcast b64 %bi to i64 ; returns an integer, no-op cast
+%b = bitcast b64 %bp to i64 ; reinterprets the pointer as an integer, returning its address without exposing provenance
+%c = bitcast b64 %bp to ptr ; returns a pointer, no-op cast
+%d = bitcast b64 %bi to ptr ; reinterprets the integer as a pointer, returning a pointer with no provenance
- %e = bitcast <2 x b32> %v to i64 ; reinterprets the raw bytes as an integer
- %f = bitcast <2 x b32> %v to ptr ; reinterprets the raw bytes as a pointer
+%e = bitcast <2 x b32> %v to i64 ; reinterprets the raw bytes as an integer
+%f = bitcast <2 x b32> %v to ptr ; reinterprets the raw bytes as a pointer
- %g = bitcast <2 x b32> %v to <4 x i16> ; reinterprets the raw bytes as integers
+%g = bitcast <2 x b32> %v to <4 x i16> ; reinterprets the raw bytes as integers
+```
-.. _i_addrspacecast:
+(i_addrspacecast)=
-'``addrspacecast .. to``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`addrspacecast .. to`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = addrspacecast <pty> <ptrval> to <pty2> ; yields pty2
+```
+<result> = addrspacecast <pty> <ptrval> to <pty2> ; yields pty2
+```
-Overview:
-"""""""""
+##### Overview:
-The '``addrspacecast``' instruction converts ``ptrval`` from ``pty`` in
-address space ``n`` to type ``pty2`` in address space ``m``.
+The '`addrspacecast`' instruction converts `ptrval` from `pty` in
+address space `n` to type `pty2` in address space `m`.
-Arguments:
-""""""""""
+##### Arguments:
-The '``addrspacecast``' instruction takes a pointer or vector of pointer value
+The '`addrspacecast`' instruction takes a pointer or vector of pointer value
to cast and a pointer type to cast it to, which must have a different
address space.
-Semantics:
-""""""""""
+##### Semantics:
-The '``addrspacecast``' instruction converts the pointer value
-``ptrval`` to type ``pty2``. It can be a *no-op cast* or a complex
+The '`addrspacecast`' instruction converts the pointer value
+`ptrval` to type `pty2`. It can be a *no-op cast* or a complex
value modification, depending on the target and the address space
pair. Pointer conversions within the same address space must be
-performed with the ``bitcast`` instruction. Note that if the address
+performed with the `bitcast` instruction. Note that if the address
space conversion produces a dereferenceable result then both result
and operand refer to the same memory location. The conversion must
have no side effects, and must not capture the value of the pointer.
-If the source is :ref:`poison <poisonvalues>`, the result is
-:ref:`poison <poisonvalues>`.
+If the source is {ref}`poison <poisonvalues>`, the result is
+{ref}`poison <poisonvalues>`.
-If the source is not :ref:`poison <poisonvalues>`, and both source and
-destination are :ref:`integral pointers <nointptrtype>`, and the
+If the source is not {ref}`poison <poisonvalues>`, and both source and
+destination are {ref}`integral pointers <nointptrtype>`, and the
result pointer is dereferenceable, the cast is assumed to be
reversible (i.e., casting the result back to the original address space
should yield the original bit pattern).
Which address space casts are supported depends on the target. Unsupported
-address space casts return :ref:`poison <poisonvalues>`.
-
-Example:
-""""""""
+address space casts return {ref}`poison <poisonvalues>`.
-.. code-block:: llvm
+##### Example:
- %X = addrspacecast ptr %x to ptr addrspace(1)
- %Y = addrspacecast ptr addrspace(1) %y to ptr addrspace(2)
- %Z = addrspacecast <4 x ptr> %z to <4 x ptr addrspace(3)>
+```llvm
+%X = addrspacecast ptr %x to ptr addrspace(1)
+%Y = addrspacecast ptr addrspace(1) %y to ptr addrspace(2)
+%Z = addrspacecast <4 x ptr> %z to <4 x ptr addrspace(3)>
+```
-.. _otherops:
+(otherops)=
-Other Operations
-----------------
+### Other Operations
The instructions in this category are the "miscellaneous" instructions,
which defy better classification.
-.. _i_icmp:
+(i_icmp)=
-'``icmp``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+#### '`icmp`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = icmp <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
- <result> = icmp samesign <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
+```
+<result> = icmp <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
+<result> = icmp samesign <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``icmp``' instruction returns a boolean value or a vector of
+The '`icmp`' instruction returns a boolean value or a vector of
boolean values based on comparison of its two integer, integer vector,
pointer, or pointer vector operands.
-Arguments:
-""""""""""
+##### Arguments:
-The '``icmp``' instruction takes three operands. The first operand is
+The '`icmp`' instruction takes three operands. The first operand is
the condition code indicating the kind of comparison to perform. It is
not a value, just a keyword. The possible condition codes are:
-.. _icmp_md_cc:
-
-#. ``eq``: equal
-#. ``ne``: not equal
-#. ``ugt``: unsigned greater than
-#. ``uge``: unsigned greater or equal
-#. ``ult``: unsigned less than
-#. ``ule``: unsigned less or equal
-#. ``sgt``: signed greater than
-#. ``sge``: signed greater or equal
-#. ``slt``: signed less than
-#. ``sle``: signed less or equal
-
-The remaining two arguments must be :ref:`integer <t_integer>` or
-:ref:`pointer <t_pointer>` or integer :ref:`vector <t_vector>` typed. They
+(icmp_md_cc)=
+
+1. `eq`: equal
+1. `ne`: not equal
+1. `ugt`: unsigned greater than
+1. `uge`: unsigned greater or equal
+1. `ult`: unsigned less than
+1. `ule`: unsigned less or equal
+1. `sgt`: signed greater than
+1. `sge`: signed greater or equal
+1. `slt`: signed less than
+1. `sle`: signed less or equal
+
+The remaining two arguments must be {ref}`integer <t_integer>` or
+{ref}`pointer <t_pointer>` or integer {ref}`vector <t_vector>` typed. They
must also be identical types.
-Semantics:
-""""""""""
+##### Semantics:
-The '``icmp``' compares ``op1`` and ``op2`` according to the condition
-code given as ``cond``. The comparison performed always yields either an
-:ref:`i1 <t_integer>` or vector of ``i1`` result, as follows:
+The '`icmp`' compares `op1` and `op2` according to the condition
+code given as `cond`. The comparison performed always yields either an
+{ref}`i1 <t_integer>` or vector of `i1` result, as follows:
-.. _icmp_md_cc_sem:
+(icmp_md_cc_sem)=
-#. ``eq``: yields ``true`` if the operands are equal, ``false``
+1. `eq`: yields `true` if the operands are equal, `false`
otherwise. No sign interpretation is necessary or performed.
-#. ``ne``: yields ``true`` if the operands are unequal, ``false``
+1. `ne`: yields `true` if the operands are unequal, `false`
otherwise. No sign interpretation is necessary or performed.
-#. ``ugt``: interprets the operands as unsigned values and yields
- ``true`` if ``op1`` is greater than ``op2``.
-#. ``uge``: interprets the operands as unsigned values and yields
- ``true`` if ``op1`` is greater than or equal to ``op2``.
-#. ``ult``: interprets the operands as unsigned values and yields
- ``true`` if ``op1`` is less than ``op2``.
-#. ``ule``: interprets the operands as unsigned values and yields
- ``true`` if ``op1`` is less than or equal to ``op2``.
-#. ``sgt``: interprets the operands as signed values and yields ``true``
- if ``op1`` is greater than ``op2``.
-#. ``sge``: interprets the operands as signed values and yields ``true``
- if ``op1`` is greater than or equal to ``op2``.
-#. ``slt``: interprets the operands as signed values and yields ``true``
- if ``op1`` is less than ``op2``.
-#. ``sle``: interprets the operands as signed values and yields ``true``
- if ``op1`` is less than or equal to ``op2``.
-
-If the operands are :ref:`pointer <t_pointer>` typed, the address bits of the
+1. `ugt`: interprets the operands as unsigned values and yields
+ `true` if `op1` is greater than `op2`.
+1. `uge`: interprets the operands as unsigned values and yields
+ `true` if `op1` is greater than or equal to `op2`.
+1. `ult`: interprets the operands as unsigned values and yields
+ `true` if `op1` is less than `op2`.
+1. `ule`: interprets the operands as unsigned values and yields
+ `true` if `op1` is less than or equal to `op2`.
+1. `sgt`: interprets the operands as signed values and yields `true`
+ if `op1` is greater than `op2`.
+1. `sge`: interprets the operands as signed values and yields `true`
+ if `op1` is greater than or equal to `op2`.
+1. `slt`: interprets the operands as signed values and yields `true`
+ if `op1` is less than `op2`.
+1. `sle`: interprets the operands as signed values and yields `true`
+ if `op1` is less than or equal to `op2`.
+
+If the operands are {ref}`pointer <t_pointer>` typed, the address bits of the
pointers are compared as if they were integers. Non-address bits or external
-state are not compared. That is, ``icmp`` on pointers is equivalent to ``icmp``
-on the ``ptrtoaddr`` of the pointers.
+state are not compared. That is, `icmp` on pointers is equivalent to `icmp`
+on the `ptrtoaddr` of the pointers.
If the operands are integer vectors, then they are compared element by
-element. The result is an ``i1`` vector with the same number of elements
-as the values being compared. Otherwise, the result is an ``i1``.
-
-If the ``samesign`` keyword is present and the operands are not of the
-same sign then the result is a :ref:`poison value <poisonvalues>`.
-
-Example:
-""""""""
+element. The result is an `i1` vector with the same number of elements
+as the values being compared. Otherwise, the result is an `i1`.
-.. code-block:: text
+If the `samesign` keyword is present and the operands are not of the
+same sign then the result is a {ref}`poison value <poisonvalues>`.
- <result> = icmp eq i32 4, 5 ; yields: result=false
- <result> = icmp ne ptr %X, %X ; yields: result=false
- <result> = icmp ult i16 4, 5 ; yields: result=true
- <result> = icmp sgt i16 4, 5 ; yields: result=false
- <result> = icmp ule i16 -4, 5 ; yields: result=false
- <result> = icmp sge i16 4, 5 ; yields: result=false
+##### Example:
-.. _i_fcmp:
+```text
+<result> = icmp eq i32 4, 5 ; yields: result=false
+<result> = icmp ne ptr %X, %X ; yields: result=false
+<result> = icmp ult i16 4, 5 ; yields: result=true
+<result> = icmp sgt i16 4, 5 ; yields: result=false
+<result> = icmp ule i16 -4, 5 ; yields: result=false
+<result> = icmp sge i16 4, 5 ; yields: result=false
+```
-'``fcmp``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
+(i_fcmp)=
-Syntax:
-"""""""
+#### '`fcmp`' Instruction
-::
+##### Syntax:
- <result> = fcmp [fast-math flags]* <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
+```
+<result> = fcmp [fast-math flags]* <cond> <ty> <op1>, <op2> ; yields i1 or <N x i1>:result
+```
-Overview:
-"""""""""
+##### Overview:
-The '``fcmp``' instruction returns a boolean value or vector of boolean
+The '`fcmp`' instruction returns a boolean value or vector of boolean
values based on comparison of its operands.
If the operands are floating-point scalars, then the result type is a
-boolean (:ref:`i1 <t_integer>`).
+boolean ({ref}`i1 <t_integer>`).
If the operands are floating-point vectors, then the result type is a
vector of boolean with the same number of elements as the operands being
compared.
-Arguments:
-""""""""""
+##### Arguments:
-The '``fcmp``' instruction takes three operands. The first operand is
+The '`fcmp`' instruction takes three operands. The first operand is
the condition code indicating the kind of comparison to perform. It is
not a value, just a keyword. The possible condition codes are:
-#. ``false``: no comparison, always returns false
-#. ``oeq``: ordered and equal
-#. ``ogt``: ordered and greater than
-#. ``oge``: ordered and greater than or equal
-#. ``olt``: ordered and less than
-#. ``ole``: ordered and less than or equal
-#. ``one``: ordered and not equal
-#. ``ord``: ordered (no nans)
-#. ``ueq``: unordered or equal
-#. ``ugt``: unordered or greater than
-#. ``uge``: unordered or greater than or equal
-#. ``ult``: unordered or less than
-#. ``ule``: unordered or less than or equal
-#. ``une``: unordered or not equal
-#. ``uno``: unordered (either nans)
-#. ``true``: no comparison, always returns true
+1. `false`: no comparison, always returns false
+1. `oeq`: ordered and equal
+1. `ogt`: ordered and greater than
+1. `oge`: ordered and greater than or equal
+1. `olt`: ordered and less than
+1. `ole`: ordered and less than or equal
+1. `one`: ordered and not equal
+1. `ord`: ordered (no nans)
+1. `ueq`: unordered or equal
+1. `ugt`: unordered or greater than
+1. `uge`: unordered or greater than or equal
+1. `ult`: unordered or less than
+1. `ule`: unordered or less than or equal
+1. `une`: unordered or not equal
+1. `uno`: unordered (either nans)
+1. `true`: no comparison, always returns true
*Ordered* means that neither operand is a QNAN while *unordered* means
that either operand may be a QNAN.
-Each of ``val1`` and ``val2`` arguments must be either a :ref:`floating-point
-<t_floating>` type or a :ref:`vector <t_vector>` of floating-point type.
+Each of `val1` and `val2` arguments must be either a {ref}`floating-point <t_floating>` type or a {ref}`vector <t_vector>` of floating-point type.
They must have identical types.
-Semantics:
-""""""""""
+##### Semantics:
-The '``fcmp``' instruction compares ``op1`` and ``op2`` according to the
-condition code given as ``cond``. If the operands are vectors, then the
+The '`fcmp`' instruction compares `op1` and `op2` according to the
+condition code given as `cond`. If the operands are vectors, then the
vectors are compared element by element. Each comparison performed
-always yields an :ref:`i1 <t_integer>` result, as follows:
-
-#. ``false``: always yields ``false``, regardless of operands.
-#. ``oeq``: yields ``true`` if both operands are not a QNAN and ``op1``
- is equal to ``op2``.
-#. ``ogt``: yields ``true`` if both operands are not a QNAN and ``op1``
- is greater than ``op2``.
-#. ``oge``: yields ``true`` if both operands are not a QNAN and ``op1``
- is greater than or equal to ``op2``.
-#. ``olt``: yields ``true`` if both operands are not a QNAN and ``op1``
- is less than ``op2``.
-#. ``ole``: yields ``true`` if both operands are not a QNAN and ``op1``
- is less than or equal to ``op2``.
-#. ``one``: yields ``true`` if both operands are not a QNAN and ``op1``
- is not equal to ``op2``.
-#. ``ord``: yields ``true`` if both operands are not a QNAN.
-#. ``ueq``: yields ``true`` if either operand is a QNAN or ``op1`` is
- equal to ``op2``.
-#. ``ugt``: yields ``true`` if either operand is a QNAN or ``op1`` is
- greater than ``op2``.
-#. ``uge``: yields ``true`` if either operand is a QNAN or ``op1`` is
- greater than or equal to ``op2``.
-#. ``ult``: yields ``true`` if either operand is a QNAN or ``op1`` is
- less than ``op2``.
-#. ``ule``: yields ``true`` if either operand is a QNAN or ``op1`` is
- less than or equal to ``op2``.
-#. ``une``: yields ``true`` if either operand is a QNAN or ``op1`` is
- not equal to ``op2``.
-#. ``uno``: yields ``true`` if either operand is a QNAN.
-#. ``true``: always yields ``true``, regardless of operands.
-
-The ``fcmp`` instruction can also optionally take any number of
-:ref:`fast-math flags <fastmath>`, which are optimization hints to enable
+always yields an {ref}`i1 <t_integer>` result, as follows:
+
+1. `false`: always yields `false`, regardless of operands.
+1. `oeq`: yields `true` if both operands are not a QNAN and `op1`
+ is equal to `op2`.
+1. `ogt`: yields `true` if both operands are not a QNAN and `op1`
+ is greater than `op2`.
+1. `oge`: yields `true` if both operands are not a QNAN and `op1`
+ is greater than or equal to `op2`.
+1. `olt`: yields `true` if both operands are not a QNAN and `op1`
+ is less than `op2`.
+1. `ole`: yields `true` if both operands are not a QNAN and `op1`
+ is less than or equal to `op2`.
+1. `one`: yields `true` if both operands are not a QNAN and `op1`
+ is not equal to `op2`.
+1. `ord`: yields `true` if both operands are not a QNAN.
+1. `ueq`: yields `true` if either operand is a QNAN or `op1` is
+ equal to `op2`.
+1. `ugt`: yields `true` if either operand is a QNAN or `op1` is
+ greater than `op2`.
+1. `uge`: yields `true` if either operand is a QNAN or `op1` is
+ greater than or equal to `op2`.
+1. `ult`: yields `true` if either operand is a QNAN or `op1` is
+ less than `op2`.
+1. `ule`: yields `true` if either operand is a QNAN or `op1` is
+ less than or equal to `op2`.
+1. `une`: yields `true` if either operand is a QNAN or `op1` is
+ not equal to `op2`.
+1. `uno`: yields `true` if either operand is a QNAN.
+1. `true`: always yields `true`, regardless of operands.
+
+The `fcmp` instruction can also optionally take any number of
+{ref}`fast-math flags <fastmath>`, which are optimization hints to enable
otherwise unsafe floating-point optimizations.
-Any set of fast-math flags are legal on an ``fcmp`` instruction, but the
+Any set of fast-math flags are legal on an `fcmp` instruction, but the
only flags that have any effect on its semantics are those that allow
assumptions to be made about the values of input arguments; namely
-``nnan``, ``ninf``, and ``reassoc``. See :ref:`fastmath` for more information.
-
-Example:
-""""""""
+`nnan`, `ninf`, and `reassoc`. See {ref}`fastmath` for more information.
-.. code-block:: text
+##### Example:
- <result> = fcmp oeq float 4.0, 5.0 ; yields: result=false
- <result> = fcmp one float 4.0, 5.0 ; yields: result=true
- <result> = fcmp olt float 4.0, 5.0 ; yields: result=true
- <result> = fcmp ueq double 1.0, 2.0 ; yields: result=false
+```text
+<result> = fcmp oeq float 4.0, 5.0 ; yields: result=false
+<result> = fcmp one float 4.0, 5.0 ; yields: result=true
+<result> = fcmp olt float 4.0, 5.0 ; yields: result=true
+<result> = fcmp ueq double 1.0, 2.0 ; yields: result=false
+```
-.. _i_phi:
+(i_phi)=
-'``phi``' Instruction
-^^^^^^^^^^^^^^^^^^^^^
+#### '`phi`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = phi [fast-math-flags] <ty> [ <val0>, <label0>], ...
+```
+<result> = phi [fast-math-flags] <ty> [ <val0>, <label0>], ...
+```
-Overview:
-"""""""""
+##### Overview:
-The '``phi``' instruction is used to implement the φ node in the SSA
+The '`phi`' instruction is used to implement the φ node in the SSA
graph representing the function.
-Arguments:
-""""""""""
+##### Arguments:
The type of the incoming values is specified with the first type field.
-After this, the '``phi``' instruction takes a list of pairs as
+After this, the '`phi`' instruction takes a list of pairs as
arguments, with one pair for each predecessor basic block of the current
-block. Only values of :ref:`first class <t_firstclass>` type may be used as
+block. Only values of {ref}`first class <t_firstclass>` type may be used as
the value arguments to the PHI node. Only labels may be used as the
label arguments.
@@ -13789,70 +13299,60 @@ block.
For the purposes of the SSA form, the use of each incoming value is
deemed to occur on the edge from the corresponding predecessor block to
-the current block (but after any definition of an '``invoke``'
+the current block (but after any definition of an '`invoke`'
instruction's return value on the same edge).
-The optional ``fast-math-flags`` marker indicates that the phi has one
-or more :ref:`fast-math-flags <fastmath>`. These are optimization hints
+The optional `fast-math-flags` marker indicates that the phi has one
+or more {ref}`fast-math-flags <fastmath>`. These are optimization hints
to enable otherwise unsafe floating-point optimizations. Fast-math-flags
-are only valid for phis that return :ref:`supported floating-point types
-<fastmath_return_types>`.
+are only valid for phis that return {ref}`supported floating-point types <fastmath_return_types>`.
-Semantics:
-""""""""""
+##### Semantics:
-At runtime, the '``phi``' instruction logically takes on the value
+At runtime, the '`phi`' instruction logically takes on the value
specified by the pair corresponding to the predecessor basic block that
executed just prior to the current block.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- Loop: ; Infinite loop that counts from 0 on up...
- %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
- %nextindvar = add i32 %indvar, 1
- br label %Loop
+```llvm
+Loop: ; Infinite loop that counts from 0 on up...
+ %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
+ %nextindvar = add i32 %indvar, 1
+ br label %Loop
+```
-.. _i_select:
+(i_select)=
-'``select``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`select`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <result> = select [fast-math flags] selty <cond>, <ty> <val1>, <ty> <val2> ; yields ty
+```
+<result> = select [fast-math flags] selty <cond>, <ty> <val1>, <ty> <val2> ; yields ty
- selty is either i1 or {<N x i1>}
+selty is either i1 or {<N x i1>}
+```
-Overview:
-"""""""""
+##### Overview:
-The '``select``' instruction is used to choose one value based on a
+The '`select`' instruction is used to choose one value based on a
condition, without IR-level branching.
-Arguments:
-""""""""""
+##### Arguments:
-The '``select``' instruction requires an 'i1' value or a vector of 'i1'
-values indicating the condition, and two values of the same :ref:`first
-class <t_firstclass>` type.
+The '`select`' instruction requires an 'i1' value or a vector of 'i1'
+values indicating the condition, and two values of the same {ref}`first class <t_firstclass>` type.
-#. The optional ``fast-math flags`` marker indicates that the select has one or more
- :ref:`fast-math flags <fastmath>`. These are optimization hints to enable
+1. The optional `fast-math flags` marker indicates that the select has one or more
+ {ref}`fast-math flags <fastmath>`. These are optimization hints to enable
otherwise unsafe floating-point optimizations. Fast-math flags are only valid
- for selects that return :ref:`supported floating-point types
- <fastmath_return_types>`. Note that the presence of value which would otherwise result
+ for selects that return {ref}`supported floating-point types <fastmath_return_types>`. Note that the presence of value which would otherwise result
in poison does not cause the result to be poison if the value is on the non-selected arm.
- If :ref:`fast-math flags <fastmath>` are present, they are only applied to the result,
+ If {ref}`fast-math flags <fastmath>` are present, they are only applied to the result,
not both arms.
-Semantics:
-""""""""""
+##### Semantics:
If the condition is an i1 and it evaluates to 1, the instruction returns
the first value argument; otherwise, it returns the second value
@@ -13864,126 +13364,113 @@ vectors of the same size, and the selection is done element by element.
If the condition is an i1 and the value arguments are vectors of the
same size, then an entire vector is selected.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %X = select i1 true, i8 17, i8 42 ; yields i8:17
- %Y = select nnan i1 true, float 0.0, float NaN ; yields float:0.0
- %Z = select nnan i1 false, float 0.0, float NaN ; yields float:poison
+```llvm
+%X = select i1 true, i8 17, i8 42 ; yields i8:17
+%Y = select nnan i1 true, float 0.0, float NaN ; yields float:0.0
+%Z = select nnan i1 false, float 0.0, float NaN ; yields float:poison
+```
+(i_freeze)=
-.. _i_freeze:
+#### '`freeze`' Instruction
-'``freeze``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+<result> = freeze ty <val> ; yields ty:result
+```
- <result> = freeze ty <val> ; yields ty:result
+##### Overview:
-Overview:
-"""""""""
+The '`freeze`' instruction is used to stop propagation of
+{ref}`undef <undefvalues>` and {ref}`poison <poisonvalues>` values.
-The '``freeze``' instruction is used to stop propagation of
-:ref:`undef <undefvalues>` and :ref:`poison <poisonvalues>` values.
+##### Arguments:
-Arguments:
-""""""""""
+The '`freeze`' instruction takes a single argument.
-The '``freeze``' instruction takes a single argument.
+##### Semantics:
-Semantics:
-""""""""""
-
-If the argument is ``undef`` or ``poison``, '``freeze``' returns an
-arbitrary, but fixed, value of type '``ty``'.
+If the argument is `undef` or `poison`, '`freeze`' returns an
+arbitrary, but fixed, value of type '`ty`'.
Otherwise, this instruction is a no-op and returns the input argument.
-All uses of a value returned by the same '``freeze``' instruction are
-guaranteed to always observe the same value, while different '``freeze``'
+All uses of a value returned by the same '`freeze`' instruction are
+guaranteed to always observe the same value, while different '`freeze`'
instructions may yield different values.
-While ``undef`` and ``poison`` pointers can be frozen, the result is a
+While `undef` and `poison` pointers can be frozen, the result is a
non-dereferenceable pointer. See the
-:ref:`Pointer Aliasing Rules <pointeraliasing>` section for more information.
-Values of the :ref:`byte type <t_byte>` are frozen on a per-bit basis.
+{ref}`Pointer Aliasing Rules <pointeraliasing>` section for more information.
+Values of the {ref}`byte type <t_byte>` are frozen on a per-bit basis.
If an aggregate value or vector is frozen, the operand is frozen element-wise.
The padding of an aggregate isn't considered, since it isn't visible
without storing it into memory and loading it with a different type.
-Example:
-""""""""
-
-.. code-block:: text
-
- %w = i32 undef
- %x = freeze i32 %w
- %y = add i32 %w, %w ; undef
- %z = add i32 %x, %x ; even number because all uses of %x observe
- ; the same value
- %x2 = freeze i32 %w
- %cmp = icmp eq i32 %x, %x2 ; can be true or false
+##### Example:
- ; example with vectors
- %v = <2 x i32> <i32 undef, i32 poison>
- %a = extractelement <2 x i32> %v, i32 0 ; undef
- %b = extractelement <2 x i32> %v, i32 1 ; poison
- %add = add i32 %a, %a ; undef
+```text
+%w = i32 undef
+%x = freeze i32 %w
+%y = add i32 %w, %w ; undef
+%z = add i32 %x, %x ; even number because all uses of %x observe
+ ; the same value
+%x2 = freeze i32 %w
+%cmp = icmp eq i32 %x, %x2 ; can be true or false
- %v.fr = freeze <2 x i32> %v ; element-wise freeze
- %d = extractelement <2 x i32> %v.fr, i32 0 ; not undef
- %add.f = add i32 %d, %d ; even number
+; example with vectors
+%v = <2 x i32> <i32 undef, i32 poison>
+%a = extractelement <2 x i32> %v, i32 0 ; undef
+%b = extractelement <2 x i32> %v, i32 1 ; poison
+%add = add i32 %a, %a ; undef
- %l = load b32, ptr %p ; may be uninitialized
- %f = freeze b32 %l ; freezes on a per-bit basis
+%v.fr = freeze <2 x i32> %v ; element-wise freeze
+%d = extractelement <2 x i32> %v.fr, i32 0 ; not undef
+%add.f = add i32 %d, %d ; even number
- ; branching on frozen value
- %poison = add nsw i1 %k, undef ; poison
- %c = freeze i1 %poison
- br i1 %c, label %foo, label %bar ; non-deterministic branch to %foo or %bar
+%l = load b32, ptr %p ; may be uninitialized
+%f = freeze b32 %l ; freezes on a per-bit basis
+; branching on frozen value
+%poison = add nsw i1 %k, undef ; poison
+%c = freeze i1 %poison
+br i1 %c, label %foo, label %bar ; non-deterministic branch to %foo or %bar
+```
-.. _i_call:
+(i_call)=
-'``call``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`call`' Instruction
-::
+##### Syntax:
- <result> = [tail | musttail | notail ] call [fast-math flags] [cconv] [ret attrs] [addrspace(<num>)]
- <ty>|<fnty> <fnptrval>(<function args>) [fn attrs] [ operand bundles ]
+```
+<result> = [tail | musttail | notail ] call [fast-math flags] [cconv] [ret attrs] [addrspace(<num>)]
+ <ty>|<fnty> <fnptrval>(<function args>) [fn attrs] [ operand bundles ]
+```
-Overview:
-"""""""""
+##### Overview:
-The '``call``' instruction represents a simple function call.
+The '`call`' instruction represents a simple function call.
-Arguments:
-""""""""""
+##### Arguments:
This instruction requires several arguments:
-#. The optional ``tail`` and ``musttail`` markers indicate that the optimizers
- should perform tail call optimization. The ``tail`` marker is a hint that
- `can be ignored <CodeGenerator.html#tail-call-optimization>`_. The
- ``musttail`` marker means that the call must be tail call optimized in order
+1. The optional `tail` and `musttail` markers indicate that the optimizers
+ should perform tail call optimization. The `tail` marker is a hint that
+ {ref}`can be ignored <tail call section>`. The
+ `musttail` marker means that the call must be tail call optimized in order
for the program to be correct. This is true even in the presence of
- attributes like "disable-tail-calls". The ``musttail`` marker provides these
+ attributes like "disable-tail-calls". The `musttail` marker provides these
guarantees:
- The call will not cause unbounded stack growth if it is part of a
recursive cycle in the call graph.
- - Arguments with the :ref:`inalloca <attr_inalloca>` or
- :ref:`preallocated <attr_preallocated>` attribute are forwarded in place.
- - If the musttail call appears in a function with the ``"thunk"`` attribute
+ - Arguments with the {ref}`inalloca <attr_inalloca>` or
+ {ref}`preallocated <attr_preallocated>` attribute are forwarded in place.
+ - If the musttail call appears in a function with the `"thunk"` attribute
and the caller and callee both have varargs, then any unprototyped
arguments in register or memory are forwarded to the callee. Similarly,
the return value of the callee is returned to the caller's caller, even
@@ -13994,63 +13481,63 @@ This instruction requires several arguments:
argument may be passed to the callee as a byval argument, which can be
dereferenced inside the callee. For example:
- .. code-block:: llvm
-
- declare void @take_byval(ptr byval(i64))
- declare void @take_ptr(ptr)
-
- ; Invalid (assuming @take_ptr dereferences the pointer), because %local
- ; may be de-allocated before the call to @take_ptr.
- define void @invalid_alloca() {
- entry:
- %local = alloca i64
- tail call void @take_ptr(ptr %local)
- ret void
- }
-
- ; Valid, the byval attribute causes the memory allocated by %local to be
- ; copied into @take_byval's stack frame.
- define void @byval_alloca() {
- entry:
- %local = alloca i64
- tail call void @take_byval(ptr byval(i64) %local)
- ret void
- }
-
- ; Invalid, because @use_global_va_list uses the variadic arguments from
- ; @invalid_va_list.
- %struct.va_list = type { ptr }
- @va_list = external global %struct.va_list
- define void @use_global_va_list() {
- entry:
- %arg = va_arg ptr @va_list, i64
- ret void
- }
- define void @invalid_va_list(i32 %a, ...) {
- entry:
- call void @llvm.va_start.p0(ptr @va_list)
- tail call void @use_global_va_list()
- ret void
- }
-
- ; Valid, byval argument forwarded to tail call as another byval argument.
- define void @forward_byval(ptr byval(i64) %x) {
- entry:
- tail call void @take_byval(ptr byval(i64) %x)
- ret void
- }
-
- ; Invalid (assuming @take_ptr dereferences the pointer), byval argument
- ; passed to tail callee as non-byval ptr.
- define void @invalid_byval(ptr byval(i64) %x) {
- entry:
- tail call void @take_ptr(ptr %x)
- ret void
- }
-
- Calls marked ``musttail`` must obey the following additional rules:
-
- - The call must immediately precede a :ref:`ret <i_ret>` instruction,
+ ```llvm
+ declare void @take_byval(ptr byval(i64))
+ declare void @take_ptr(ptr)
+
+ ; Invalid (assuming @take_ptr dereferences the pointer), because %local
+ ; may be de-allocated before the call to @take_ptr.
+ define void @invalid_alloca() {
+ entry:
+ %local = alloca i64
+ tail call void @take_ptr(ptr %local)
+ ret void
+ }
+
+ ; Valid, the byval attribute causes the memory allocated by %local to be
+ ; copied into @take_byval's stack frame.
+ define void @byval_alloca() {
+ entry:
+ %local = alloca i64
+ tail call void @take_byval(ptr byval(i64) %local)
+ ret void
+ }
+
+ ; Invalid, because @use_global_va_list uses the variadic arguments from
+ ; @invalid_va_list.
+ %struct.va_list = type { ptr }
+ @va_list = external global %struct.va_list
+ define void @use_global_va_list() {
+ entry:
+ %arg = va_arg ptr @va_list, i64
+ ret void
+ }
+ define void @invalid_va_list(i32 %a, ...) {
+ entry:
+ call void @llvm.va_start.p0(ptr @va_list)
+ tail call void @use_global_va_list()
+ ret void
+ }
+
+ ; Valid, byval argument forwarded to tail call as another byval argument.
+ define void @forward_byval(ptr byval(i64) %x) {
+ entry:
+ tail call void @take_byval(ptr byval(i64) %x)
+ ret void
+ }
+
+ ; Invalid (assuming @take_ptr dereferences the pointer), byval argument
+ ; passed to tail callee as non-byval ptr.
+ define void @invalid_byval(ptr byval(i64) %x) {
+ entry:
+ tail call void @take_ptr(ptr %x)
+ ret void
+ }
+ ```
+
+ Calls marked `musttail` must obey the following additional rules:
+
+ - The call must immediately precede a {ref}`ret <i_ret>` instruction,
or a pointer bitcast followed by a ret instruction.
- The ret instruction must return the (possibly bitcasted) value
produced by the call, undef, or void.
@@ -14073,62 +13560,59 @@ This instruction requires several arguments:
swiftself, and swiftasync.
- Prototypes are not required to match.
- Tail call optimization for calls marked ``tail`` is guaranteed to occur if
+ Tail call optimization for calls marked `tail` is guaranteed to occur if
the following conditions are met:
- - Caller and callee both have the calling convention ``fastcc`` or ``tailcc``.
+ - Caller and callee both have the calling convention `fastcc` or `tailcc`.
- The call is in tail position (ret immediately follows call and ret
uses value of call or is void).
- - Option ``-tailcallopt`` is enabled, ``llvm::GuaranteedTailCallOpt`` is
- ``true``, or the calling convention is ``tailcc``.
- - `Platform-specific constraints are met.
- <CodeGenerator.html#tail-call-optimization>`_
+ - Option `-tailcallopt` is enabled, `llvm::GuaranteedTailCallOpt` is
+ `true`, or the calling convention is `tailcc`.
+ - {ref}`Platform-specific constraints are met. <tail call section>`
-#. The optional ``notail`` marker indicates that the optimizers should not add
- ``tail`` or ``musttail`` markers to the call. It is used to prevent tail
+1. The optional `notail` marker indicates that the optimizers should not add
+ `tail` or `musttail` markers to the call. It is used to prevent tail
call optimization from being performed on the call.
-#. The optional ``fast-math flags`` marker indicates that the call has one or more
- :ref:`fast-math flags <fastmath>`, which are optimization hints to enable
+1. The optional `fast-math flags` marker indicates that the call has one or more
+ {ref}`fast-math flags <fastmath>`, which are optimization hints to enable
otherwise unsafe floating-point optimizations. Fast-math flags are only valid
- for calls that return :ref:`supported floating-point types <fastmath_return_types>`.
+ for calls that return {ref}`supported floating-point types <fastmath_return_types>`.
-#. The optional "cconv" marker indicates which :ref:`calling
- convention <callingconv>` the call should use. If none is
+1. The optional "cconv" marker indicates which {ref}`calling convention <callingconv>` the call should use. If none is
specified, the call defaults to using C calling conventions. The
calling convention of the call must match the calling convention of
the target function, or else the behavior is undefined.
-#. The optional :ref:`Parameter Attributes <paramattrs>` list for return
- values. Only '``zeroext``', '``signext``', '``noext``', and '``inreg``'
+1. The optional {ref}`Parameter Attributes <paramattrs>` list for return
+ values. Only '`zeroext`', '`signext`', '`noext`', and '`inreg`'
attributes are valid here.
-#. The optional addrspace attribute can be used to indicate the address space
+1. The optional addrspace attribute can be used to indicate the address space
of the called function. If it is not specified, the program address space
- from the :ref:`datalayout string<langref_datalayout>` will be used.
-#. '``ty``': the type of the call instruction itself which is also the
+ from the {ref}`datalayout string<langref_datalayout>` will be used.
+1. '`ty`': the type of the call instruction itself which is also the
type of the return value. Functions that return no value are marked
- ``void``. The signature is computed based on the return type and argument
+ `void`. The signature is computed based on the return type and argument
types.
-#. '``fnty``': shall be the signature of the function being called. The
+1. '`fnty`': shall be the signature of the function being called. The
argument types must match the types implied by this signature. This
is only required if the signature specifies a varargs type.
-#. '``fnptrval``': An LLVM value containing a pointer to a function to
+1. '`fnptrval`': An LLVM value containing a pointer to a function to
be called. In most cases, this is a direct function call, but
- indirect ``call``'s are just as possible, calling an arbitrary pointer
+ indirect `call`'s are just as possible, calling an arbitrary pointer
to function value.
-#. '``function args``': argument list whose types match the function
+1. '`function args`': argument list whose types match the function
signature argument types and parameter attributes. All arguments must
- be of :ref:`first class <t_firstclass>` type. If the function signature
+ be of {ref}`first class <t_firstclass>` type. If the function signature
indicates the function accepts a variable number of arguments, the
extra arguments can be specified.
-#. The optional :ref:`function attributes <fnattrs>` list.
-#. The optional :ref:`operand bundles <opbundles>` list.
+1. The optional {ref}`function attributes <fnattrs>` list.
+1. The optional {ref}`operand bundles <opbundles>` list.
-Semantics:
-""""""""""
+##### Semantics:
-The '``call``' instruction is used to cause control flow to transfer to
+The '`call`' instruction is used to cause control flow to transfer to
a specified function, with its incoming arguments bound to the specified
-values. Upon a '``ret``' instruction in the called function, control
+values. Upon a '`ret`' instruction in the called function, control
flow continues with the instruction after the function call, and the
return value of the function is bound to the result argument.
@@ -14140,25 +13624,24 @@ behavior. LLVM interprocedural optimizations generally only optimize calls
where the signature of the caller matches the signature of the callee.
Note that it is possible for the signatures to mismatch even if a call appears
-to be a "direct" call, like ``call void @f()``.
-
-Example:
-""""""""
+to be a "direct" call, like `call void @f()`.
-.. code-block:: llvm
+##### Example:
- %retval = call i32 @test(i32 %argc)
- call i32 (ptr, ...) @printf(ptr %msg, i32 12, i8 42) ; yields i32
- %X = tail call i32 @foo() ; yields i32
- %Y = tail call fastcc i32 @foo() ; yields i32
- call void %foo(i8 signext 97)
+```llvm
+%retval = call i32 @test(i32 %argc)
+call i32 (ptr, ...) @printf(ptr %msg, i32 12, i8 42) ; yields i32
+%X = tail call i32 @foo() ; yields i32
+%Y = tail call fastcc i32 @foo() ; yields i32
+call void %foo(i8 signext 97)
- %struct.A = type { i32, i8 }
- %r = call %struct.A @foo() ; yields { i32, i8 }
- %gr = extractvalue %struct.A %r, 0 ; yields i32
- %gr1 = extractvalue %struct.A %r, 1 ; yields i8
- %Z = call void @foo() noreturn ; indicates that %foo never returns normally
- %ZZ = call zeroext i32 @bar() ; Return value is %zero extended
+%struct.A = type { i32, i8 }
+%r = call %struct.A @foo() ; yields { i32, i8 }
+%gr = extractvalue %struct.A %r, 0 ; yields i32
+%gr1 = extractvalue %struct.A %r, 1 ; yields i8
+%Z = call void @foo() noreturn ; indicates that %foo never returns normally
+%ZZ = call zeroext i32 @bar() ; Return value is %zero extended
+```
llvm treats calls to some functions with names and arguments that match
the standard C99 library as being the C99 library functions, and may
@@ -14166,303 +13649,275 @@ perform optimizations or generate code for them under that assumption.
This implies that undefined behavior in C standard library functions recognized
by LLVM is also undefined behavior at the IR level.
-.. _i_va_arg:
+(i_va_arg)=
-'``va_arg``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`va_arg`' Instruction
-Syntax:
-"""""""
-
-::
+##### Syntax:
- <resultval> = va_arg <va_list*> <arglist>, <argty>
+```
+<resultval> = va_arg <va_list*> <arglist>, <argty>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``va_arg``' instruction is used to access arguments passed through
+The '`va_arg`' instruction is used to access arguments passed through
the "variable argument" area of a function call. It is used to implement
-the ``va_arg`` macro in C.
+the `va_arg` macro in C.
-Arguments:
-""""""""""
+##### Arguments:
-This instruction takes a ``va_list*`` value and the type of the
+This instruction takes a `va_list*` value and the type of the
argument. It returns a value of the specified argument type and
-increments the ``va_list`` to point to the next argument. The actual
-type of ``va_list`` is target specific.
+increments the `va_list` to point to the next argument. The actual
+type of `va_list` is target specific.
-Semantics:
-""""""""""
+##### Semantics:
-The '``va_arg``' instruction loads an argument of the specified type
-from the specified ``va_list`` and causes the ``va_list`` to point to
+The '`va_arg`' instruction loads an argument of the specified type
+from the specified `va_list` and causes the `va_list` to point to
the next argument. For more information, see the variable argument
-handling :ref:`Intrinsic Functions <int_varargs>`.
+handling {ref}`Intrinsic Functions <int_varargs>`.
It is legal for this instruction to be called in a function which does
-not take a variable number of arguments, for example, the ``vfprintf``
+not take a variable number of arguments, for example, the `vfprintf`
function.
-``va_arg`` is an LLVM instruction instead of an :ref:`intrinsic
-function <intrinsics>` because it takes a type as an argument.
+`va_arg` is an LLVM instruction instead of an {ref}`intrinsic function <intrinsics>` because it takes a type as an argument.
-Example:
-""""""""
+##### Example:
-See the :ref:`variable argument processing <int_varargs>` section.
+See the {ref}`variable argument processing <int_varargs>` section.
-Note that the code generator does not yet fully support va\_arg on many
-targets. Also, it does not currently support va\_arg with aggregate
+Note that the code generator does not yet fully support `va_arg` on many
+targets. Also, it does not currently support `va_arg` with aggregate
types on any target.
-.. _i_landingpad:
-
-'``landingpad``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_landingpad)=
-Syntax:
-"""""""
+#### '`landingpad`' Instruction
-::
+##### Syntax:
- <resultval> = landingpad <resultty> <clause>+
- <resultval> = landingpad <resultty> cleanup <clause>*
+```
+<resultval> = landingpad <resultty> <clause>+
+<resultval> = landingpad <resultty> cleanup <clause>*
- <clause> := catch <type> <value>
- <clause> := filter <array constant type> <array constant>
+<clause> := catch <type> <value>
+<clause> := filter <array constant type> <array constant>
+```
-Overview:
-"""""""""
+##### Overview:
-The '``landingpad``' instruction is used by `LLVM's exception handling
-system <ExceptionHandling.html#overview>`_ to specify that a basic block
+The '`landingpad`' instruction is used by [LLVM's exception handling
+system](ExceptionHandling.md#overview) to specify that a basic block
is a landing pad --- one where the exception lands, and corresponds to the
-code found in the ``catch`` portion of a ``try``/``catch`` sequence. It
-defines values supplied by the :ref:`personality function <personalityfn>` upon
-re-entry to the function. The ``resultval`` has the type ``resultty``.
+code found in the `catch` portion of a `try`/`catch` sequence. It
+defines values supplied by the {ref}`personality function <personalityfn>` upon
+re-entry to the function. The `resultval` has the type `resultty`.
-Arguments:
-""""""""""
+##### Arguments:
The optional
-``cleanup`` flag indicates that the landing pad block is a cleanup.
+`cleanup` flag indicates that the landing pad block is a cleanup.
-A ``clause`` begins with the clause type --- ``catch`` or ``filter`` --- and
+A `clause` begins with the clause type --- `catch` or `filter` --- and
contains the global variable representing the "type" that may be caught
-or filtered respectively. Unlike the ``catch`` clause, the ``filter``
+or filtered respectively. Unlike the `catch` clause, the `filter`
clause takes an array constant as its argument. Use
-"``[0 x ptr] undef``" for a filter which cannot throw. The
-'``landingpad``' instruction must contain *at least* one ``clause`` or
-the ``cleanup`` flag.
+"`[0 x ptr] undef`" for a filter which cannot throw. The
+'`landingpad`' instruction must contain *at least* one `clause` or
+the `cleanup` flag.
-Semantics:
-""""""""""
+##### Semantics:
-The '``landingpad``' instruction defines the values which are set by the
-:ref:`personality function <personalityfn>` upon re-entry to the function, and
-therefore the "result type" of the ``landingpad`` instruction. As with
+The '`landingpad`' instruction defines the values which are set by the
+{ref}`personality function <personalityfn>` upon re-entry to the function, and
+therefore the "result type" of the `landingpad` instruction. As with
calling conventions, how the personality function results are
represented in LLVM IR is target specific.
The clauses are applied in order from top to bottom. If two
-``landingpad`` instructions are merged together through inlining, the
+`landingpad` instructions are merged together through inlining, the
clauses from the calling function are appended to the list of clauses.
When the call stack is being unwound due to an exception being thrown,
-the exception is compared against each ``clause`` in turn. If it doesn't
-match any of the clauses, and the ``cleanup`` flag is not set, then
+the exception is compared against each `clause` in turn. If it doesn't
+match any of the clauses, and the `cleanup` flag is not set, then
unwinding continues further up the call stack.
-The ``landingpad`` instruction has several restrictions:
+The `landingpad` instruction has several restrictions:
- A landing pad block is a basic block which is the unwind destination
- of an '``invoke``' instruction.
-- A landing pad block must have a '``landingpad``' instruction as its
+ of an '`invoke`' instruction.
+- A landing pad block must have a '`landingpad`' instruction as its
first non-PHI instruction.
-- There can be only one '``landingpad``' instruction within the landing
+- There can be only one '`landingpad`' instruction within the landing
pad block.
- A basic block that is not a landing pad block may not include a
- '``landingpad``' instruction.
-
-Example:
-""""""""
-
-.. code-block:: llvm
+ '`landingpad`' instruction.
- ;; A landing pad which can catch an integer.
- %res = landingpad { ptr, i32 }
- catch ptr @_ZTIi
- ;; A landing pad that is a cleanup.
- %res = landingpad { ptr, i32 }
- cleanup
- ;; A landing pad which can catch an integer and can only throw a double.
- %res = landingpad { ptr, i32 }
- catch ptr @_ZTIi
- filter [1 x ptr] [ptr @_ZTId]
+##### Example:
-.. _i_catchpad:
+```llvm
+;; A landing pad which can catch an integer.
+%res = landingpad { ptr, i32 }
+ catch ptr @_ZTIi
+;; A landing pad that is a cleanup.
+%res = landingpad { ptr, i32 }
+ cleanup
+;; A landing pad which can catch an integer and can only throw a double.
+%res = landingpad { ptr, i32 }
+ catch ptr @_ZTIi
+ filter [1 x ptr] [ptr @_ZTId]
+```
-'``catchpad``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_catchpad)=
-Syntax:
-"""""""
+#### '`catchpad`' Instruction
-::
+##### Syntax:
- <resultval> = catchpad within <catchswitch> [<args>*]
+```
+<resultval> = catchpad within <catchswitch> [<args>*]
+```
-Overview:
-"""""""""
+##### Overview:
-The '``catchpad``' instruction is used by `LLVM's exception handling
-system <ExceptionHandling.html#overview>`_ to specify that a basic block
+The '`catchpad`' instruction is used by [LLVM's exception handling
+system](ExceptionHandling.md#overview) to specify that a basic block
begins a catch handler --- one where a personality routine attempts to transfer
control to catch an exception.
-Arguments:
-""""""""""
+##### Arguments:
-The ``catchswitch`` operand must always be a token produced by a
-:ref:`catchswitch <i_catchswitch>` instruction in a predecessor block. This
-ensures that each ``catchpad`` has exactly one predecessor block, and it always
-terminates in a ``catchswitch``.
+The `catchswitch` operand must always be a token produced by a
+{ref}`catchswitch <i_catchswitch>` instruction in a predecessor block. This
+ensures that each `catchpad` has exactly one predecessor block, and it always
+terminates in a `catchswitch`.
-The ``args`` correspond to whatever information the personality routine
+The `args` correspond to whatever information the personality routine
requires to determine if this is an appropriate handler for the exception.
Each operand must be an alloca or a constant.
-Control will transfer to the ``catchpad`` if this is the first appropriate handler for
+Control will transfer to the `catchpad` if this is the first appropriate handler for
the exception.
-The ``resultval`` has the type :ref:`token <t_token>` and is used to match the
-``catchpad`` to corresponding :ref:`catchrets <i_catchret>` and other nested EH
+The `resultval` has the type {ref}`token <t_token>` and is used to match the
+`catchpad` to corresponding {ref}`catchrets <i_catchret>` and other nested EH
pads.
-Semantics:
-""""""""""
+##### Semantics:
When the call stack is being unwound due to an exception being thrown, the
-exception is compared against the ``args``. If it doesn't match, control will
-not reach the ``catchpad`` instruction. The representation of ``args`` is
+exception is compared against the `args`. If it doesn't match, control will
+not reach the `catchpad` instruction. The representation of `args` is
entirely target and personality function-specific.
-Like the :ref:`landingpad <i_landingpad>` instruction, the ``catchpad``
+Like the {ref}`landingpad <i_landingpad>` instruction, the `catchpad`
instruction must be the first non-phi of its parent basic block.
-The meaning of the tokens produced and consumed by ``catchpad`` and other "pad"
+The meaning of the tokens produced and consumed by `catchpad` and other "pad"
instructions is described in the
-`Windows exception handling documentation\ <ExceptionHandling.html#wineh>`_.
-
-When a ``catchpad`` has been "entered" but not yet "exited" (as
-described in the `EH documentation\ <ExceptionHandling.html#wineh-constraints>`_),
-it is undefined behavior to execute a :ref:`call <i_call>` or :ref:`invoke <i_invoke>`
-that does not carry an appropriate :ref:`"funclet" bundle <ob_funclet>`.
-
-Example:
-""""""""
+{ref}`Windows exception handling documentation <wineh>`.
-.. code-block:: text
+When a `catchpad` has been "entered" but not yet "exited" (as
+described in the {ref}`EH documentation <wineh-constraints>`),
+it is undefined behavior to execute a {ref}`call <i_call>` or {ref}`invoke <i_invoke>`
+that does not carry an appropriate {ref}`"funclet" bundle <ob_funclet>`.
- dispatch:
- %cs = catchswitch within none [label %handler0] unwind to caller
- ;; A catch block which can catch an integer.
- handler0:
- %tok = catchpad within %cs [ptr @_ZTIi]
+##### Example:
-.. _i_cleanuppad:
+```text
+dispatch:
+ %cs = catchswitch within none [label %handler0] unwind to caller
+ ;; A catch block which can catch an integer.
+handler0:
+ %tok = catchpad within %cs [ptr @_ZTIi]
+```
-'``cleanuppad``' Instruction
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(i_cleanuppad)=
-Syntax:
-"""""""
+#### '`cleanuppad`' Instruction
-::
+##### Syntax:
- <resultval> = cleanuppad within <parent> [<args>*]
+```
+<resultval> = cleanuppad within <parent> [<args>*]
+```
-Overview:
-"""""""""
+##### Overview:
-The '``cleanuppad``' instruction is used by `LLVM's exception handling
-system <ExceptionHandling.html#overview>`_ to specify that a basic block
+The '`cleanuppad`' instruction is used by [LLVM's exception handling
+system](ExceptionHandling.md#overview) to specify that a basic block
is a cleanup block --- one where a personality routine attempts to
transfer control to run cleanup actions.
-The ``args`` correspond to whatever additional
-information the :ref:`personality function <personalityfn>` requires to
+The `args` correspond to whatever additional
+information the {ref}`personality function <personalityfn>` requires to
execute the cleanup.
-The ``resultval`` has the type :ref:`token <t_token>` and is used to
-match the ``cleanuppad`` to corresponding :ref:`cleanuprets <i_cleanupret>`.
-The ``parent`` argument is the token of the funclet that contains the
-``cleanuppad`` instruction. If the ``cleanuppad`` is not inside a funclet,
-this operand may be the token ``none``.
+The `resultval` has the type {ref}`token <t_token>` and is used to
+match the `cleanuppad` to corresponding {ref}`cleanuprets <i_cleanupret>`.
+The `parent` argument is the token of the funclet that contains the
+`cleanuppad` instruction. If the `cleanuppad` is not inside a funclet,
+this operand may be the token `none`.
-Arguments:
-""""""""""
+##### Arguments:
The instruction takes a list of arbitrary values which are interpreted
-by the :ref:`personality function <personalityfn>`.
+by the {ref}`personality function <personalityfn>`.
-Semantics:
-""""""""""
+##### Semantics:
When the call stack is being unwound due to an exception being thrown,
-the :ref:`personality function <personalityfn>` transfers control to the
-``cleanuppad`` with the aid of the personality-specific arguments.
+the {ref}`personality function <personalityfn>` transfers control to the
+`cleanuppad` with the aid of the personality-specific arguments.
As with calling conventions, how the personality function results are
represented in LLVM IR is target specific.
-The ``cleanuppad`` instruction has several restrictions:
+The `cleanuppad` instruction has several restrictions:
- A cleanup block is a basic block which is the unwind destination of
an exceptional instruction.
-- A cleanup block must have a '``cleanuppad``' instruction as its
+- A cleanup block must have a '`cleanuppad`' instruction as its
first non-PHI instruction.
-- There can be only one '``cleanuppad``' instruction within the
+- There can be only one '`cleanuppad`' instruction within the
cleanup block.
- A basic block that is not a cleanup block may not include a
- '``cleanuppad``' instruction.
-
-When a ``cleanuppad`` has been "entered" but not yet "exited" (as
-described in the `EH documentation\ <ExceptionHandling.html#wineh-constraints>`_),
-it is undefined behavior to execute a :ref:`call <i_call>` or :ref:`invoke <i_invoke>`
-that does not carry an appropriate :ref:`"funclet" bundle <ob_funclet>`.
+ '`cleanuppad`' instruction.
-Example:
-""""""""
+When a `cleanuppad` has been "entered" but not yet "exited" (as
+described in the {ref}`EH documentation <wineh-constraints>`),
+it is undefined behavior to execute a {ref}`call <i_call>` or {ref}`invoke <i_invoke>`
+that does not carry an appropriate {ref}`"funclet" bundle <ob_funclet>`.
-.. code-block:: text
+##### Example:
- %tok = cleanuppad within %cs []
+```text
+%tok = cleanuppad within %cs []
+```
-.. _debugrecords:
+(debugrecords)=
-Debug Records
------------------------
+### Debug Records
Debug records appear interleaved with instructions, but are not instructions;
they are used only to define debug information, and have no effect on generated
code. They are distinguished from instructions by the use of a leading `#` and
an extra level of indentation. As an example:
-.. code-block:: llvm
-
- %inst1 = op1 %a, %b
- #dbg_value(%inst1, !10, !DIExpression(), !11)
- %inst2 = op2 %inst1, %c
+```llvm
+%inst1 = op1 %a, %b
+ #dbg_value(%inst1, !10, !DIExpression(), !11)
+%inst2 = op2 %inst1, %c
+```
-These debug records replace the prior :ref:`debug intrinsics<dbg_intrinsics>`.
-Debug records will be disabled if ``--experimental-debuginfo-iterators=false`` is
+These debug records replace the prior {ref}`debug intrinsics<dbg_intrinsics>`.
+Debug records will be disabled if `--experimental-debuginfo-iterators=false` is
passed to LLVM; it is an error for both records and intrinsics to appear in the
-same module. More information about debug records can be found in the `LLVM
-Source Level Debugging <SourceLevelDebugging.html#format-common-intrinsics>`_
-document.
+same module. More information about debug records can be found in the
+{ref}`LLVM Source Level Debugging <format_common_intrinsics>` document.
-.. _intrinsics:
+(intrinsics)=
-Intrinsic Functions
-===================
+## Intrinsic Functions
LLVM supports the notion of an "intrinsic function". These functions
have well known names and semantics and are required to follow certain
@@ -14471,7 +13926,7 @@ for the LLVM language that does not require changing all of the
transformations in LLVM when adding to the language (or the bitcode
reader/writer, the parser, etc...).
-Intrinsic function names must all start with an "``llvm.``" prefix. This
+Intrinsic function names must all start with an "`llvm.`" prefix. This
prefix is reserved in LLVM for intrinsic names; thus, function names may
not begin with this prefix. Intrinsic functions must always be external
functions: you cannot define the body of intrinsic functions. Intrinsic
@@ -14496,19 +13951,19 @@ Overloaded intrinsics will have the names of its overloaded argument
types encoded into its function name, each preceded by a period. Only
those types which are overloaded result in a name suffix. Arguments
whose type is matched against another type do not. For example, the
-``llvm.ctpop`` function can take an integer of any width and returns an
+`llvm.ctpop` function can take an integer of any width and returns an
integer of exactly the same integer width. This leads to a family of
-functions such as ``i8 @llvm.ctpop.i8(i8 %val)`` and
-``i29 @llvm.ctpop.i29(i29 %val)``. Only one type, the return type, is
+functions such as `i8 @llvm.ctpop.i8(i8 %val)` and
+`i29 @llvm.ctpop.i29(i29 %val)`. Only one type, the return type, is
overloaded, and only one type suffix is required. Because the argument's
type is matched against the return type, it does not require its own
name suffix.
-:ref:`Unnamed types <t_opaque>` are encoded as ``s_s``. Overloaded intrinsics
+{ref}`Unnamed types <t_opaque>` are encoded as `s_s`. Overloaded intrinsics
that depend on an unnamed type in one of its overloaded argument types get an
-additional ``.<number>`` suffix. This allows differentiating intrinsics with
+additional `.<number>` suffix. This allows differentiating intrinsics with
different unnamed types as arguments. (For example:
-``llvm.ssa.copy.p0s_s.2(%42*)``) The number is tracked in the LLVM module and
+`llvm.ssa.copy.p0s_s.2(%42*)`) The number is tracked in the LLVM module and
it ensures unique names in the module. While linking together two modules, it is
still possible to get a name clash. In that case one of the names will be
changed by getting a new number.
@@ -14519,331 +13974,292 @@ integer or floating point types should not be relied upon for correct
code generation. In such cases, the recommended approach for target
maintainers when defining intrinsics is to create separate integer and
FP intrinsics rather than rely on overloading. For example, if different
-codegen is required for ``llvm.target.foo(<4 x i32>)`` and
-``llvm.target.foo(<4 x float>)`` then these should be split into
+codegen is required for `llvm.target.foo(<4 x i32>)` and
+`llvm.target.foo(<4 x float>)` then these should be split into
different intrinsics.
-To learn how to add an intrinsic function, please see the `Extending
-LLVM Guide <ExtendingLLVM.html>`_.
+To learn how to add an intrinsic function, please see the
+{doc}`Extending LLVM Guide <ExtendingLLVM>`.
-.. _int_varargs:
+(int_varargs)=
-Variable Argument Handling Intrinsics
--------------------------------------
+### Variable Argument Handling Intrinsics
Variable argument support is defined in LLVM with the
-:ref:`va_arg <i_va_arg>` instruction and these three intrinsic
+{ref}`va_arg <i_va_arg>` instruction and these three intrinsic
functions. These functions are related to the similarly named macros
-defined in the ``<stdarg.h>`` header file.
+defined in the `<stdarg.h>` header file.
All of these functions take as arguments pointers to a target-specific
-value type "``va_list``". The LLVM assembly language reference manual
+value type "`va_list`". The LLVM assembly language reference manual
does not define what this type is, so all transformations should be
prepared to handle these functions regardless of the type used. The intrinsics
are overloaded, and can be used for pointers to different address spaces.
The underlying argument list is destroyed when a function returns, so
-a ``va_list`` must not outlive the function that created it.
+a `va_list` must not outlive the function that created it.
-This example shows how the :ref:`va_arg <i_va_arg>` instruction and the
+This example shows how the {ref}`va_arg <i_va_arg>` instruction and the
variable argument handling intrinsic functions are used.
-.. code-block:: llvm
+```llvm
+; This struct is different for every platform. For most platforms,
+; it is merely a ptr.
+%struct.va_list = type { ptr }
- ; This struct is different for every platform. For most platforms,
- ; it is merely a ptr.
- %struct.va_list = type { ptr }
+; For Unix x86_64 platforms, va_list is the following struct:
+; %struct.va_list = type { i32, i32, ptr, ptr }
- ; For Unix x86_64 platforms, va_list is the following struct:
- ; %struct.va_list = type { i32, i32, ptr, ptr }
+define i32 @test(i32 %X, ...) {
+ ; Initialize variable argument processing
+ %ap = alloca %struct.va_list
+ call void @llvm.va_start.p0(ptr %ap)
- define i32 @test(i32 %X, ...) {
- ; Initialize variable argument processing
- %ap = alloca %struct.va_list
- call void @llvm.va_start.p0(ptr %ap)
+ ; Read a single integer argument
+ %tmp = va_arg ptr %ap, i32
- ; Read a single integer argument
- %tmp = va_arg ptr %ap, i32
+ ; Demonstrate usage of llvm.va_copy and llvm.va_end
+ %aq = alloca ptr
+ call void @llvm.va_copy.p0(ptr %aq, ptr %ap)
+ call void @llvm.va_end.p0(ptr %aq)
- ; Demonstrate usage of llvm.va_copy and llvm.va_end
- %aq = alloca ptr
- call void @llvm.va_copy.p0(ptr %aq, ptr %ap)
- call void @llvm.va_end.p0(ptr %aq)
+ ; Stop processing of arguments.
+ call void @llvm.va_end.p0(ptr %ap)
+ ret i32 %tmp
+}
- ; Stop processing of arguments.
- call void @llvm.va_end.p0(ptr %ap)
- ret i32 %tmp
- }
+declare void @llvm.va_start.p0(ptr)
+declare void @llvm.va_copy.p0(ptr, ptr)
+declare void @llvm.va_end.p0(ptr)
+```
- declare void @llvm.va_start.p0(ptr)
- declare void @llvm.va_copy.p0(ptr, ptr)
- declare void @llvm.va_end.p0(ptr)
+(int_va_start)=
-.. _int_va_start:
+#### '`llvm.va_start`' Intrinsic
-'``llvm.va_start``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+declare void @llvm.va_start.p0(ptr <arglist>)
+declare void @llvm.va_start.p5(ptr addrspace(5) <arglist>)
+```
- declare void @llvm.va_start.p0(ptr <arglist>)
- declare void @llvm.va_start.p5(ptr addrspace(5) <arglist>)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.va_start`' intrinsic initializes `<arglist>` for
+subsequent use by `va_arg`.
-The '``llvm.va_start``' intrinsic initializes ``<arglist>`` for
-subsequent use by ``va_arg``.
+##### Arguments:
-Arguments:
-""""""""""
+The argument is a pointer to a `va_list` element to initialize.
-The argument is a pointer to a ``va_list`` element to initialize.
+##### Semantics:
-Semantics:
-""""""""""
-
-The '``llvm.va_start``' intrinsic works just like the ``va_start`` macro
+The '`llvm.va_start`' intrinsic works just like the `va_start` macro
available in C. In a target-dependent way, it initializes the
-``va_list`` element to which the argument points, so that the next call
-to ``va_arg`` will produce the first variable argument passed to the
-function. Unlike the C ``va_start`` macro, this intrinsic does not need
+`va_list` element to which the argument points, so that the next call
+to `va_arg` will produce the first variable argument passed to the
+function. Unlike the C `va_start` macro, this intrinsic does not need
to know the last argument of the function as the compiler can figure
that out.
-'``llvm.va_end``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-
-::
+#### '`llvm.va_end`' Intrinsic
- declare void @llvm.va_end.p0(ptr <arglist>)
- declare void @llvm.va_end.p5(ptr addrspace(5) <arglist>)
+##### Syntax:
-Overview:
-"""""""""
+```
+declare void @llvm.va_end.p0(ptr <arglist>)
+declare void @llvm.va_end.p5(ptr addrspace(5) <arglist>)
+```
-The '``llvm.va_end``' intrinsic destroys ``<arglist>``, which has been
-initialized previously with ``llvm.va_start`` or ``llvm.va_copy``.
+##### Overview:
-Arguments:
-""""""""""
+The '`llvm.va_end`' intrinsic destroys `<arglist>`, which has been
+initialized previously with `llvm.va_start` or `llvm.va_copy`.
-The argument is a pointer to a ``va_list`` to destroy.
+##### Arguments:
-Semantics:
-""""""""""
+The argument is a pointer to a `va_list` to destroy.
-The '``llvm.va_end``' intrinsic works just like the ``va_end`` macro
-available in C. In a target-dependent way, it destroys the ``va_list``
-element to which the argument points. Calls to ``llvm.va_end`` can be
-omitted when they are a no-op for the given target. ``llvm.va_end``
-is a no-op for all currently supported targets.
+##### Semantics:
-When used, calls to ``llvm.va_end`` must be matched exactly with calls to
-:ref:`llvm.va_start <int_va_start>` and
-:ref:`llvm.va_copy <int_va_copy>`.
+The '`llvm.va_end`' intrinsic works just like the `va_end` macro
+available in C. In a target-dependent way, it destroys the `va_list`
+element to which the argument points. Calls to
+{ref}`llvm.va_start <int_va_start>` and
+{ref}`llvm.va_copy <int_va_copy>` must be matched exactly with calls to
+`llvm.va_end`.
-.. _int_va_copy:
+When used, calls to `llvm.va_end` must be matched exactly with calls to
+{ref}`llvm.va_start <int_va_start>` and
+{ref}`llvm.va_copy <int_va_copy>`.
-'``llvm.va_copy``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_va_copy)=
-Syntax:
-"""""""
+#### '`llvm.va_copy`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.va_copy.p0(ptr <destarglist>, ptr <srcarglist>)
- declare void @llvm.va_copy.p5(ptr addrspace(5) <destarglist>, ptr addrspace(5) <srcarglist>)
+```
+declare void @llvm.va_copy.p0(ptr <destarglist>, ptr <srcarglist>)
+declare void @llvm.va_copy.p5(ptr addrspace(5) <destarglist>, ptr addrspace(5) <srcarglist>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.va_copy``' intrinsic copies the current argument position
+The '`llvm.va_copy`' intrinsic copies the current argument position
from the source argument list to the destination argument list.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is a pointer to a ``va_list`` element to initialize.
-The second argument is a pointer to a ``va_list`` element to copy from.
+The first argument is a pointer to a `va_list` element to initialize.
+The second argument is a pointer to a `va_list` element to copy from.
The address spaces of the two arguments must match.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.va_copy``' intrinsic works just like the ``va_copy`` macro
+The '`llvm.va_copy`' intrinsic works just like the `va_copy` macro
available in C. In a target-dependent way, it copies the source
-``va_list`` element into the destination ``va_list`` element. This
-intrinsic is necessary because the ``llvm.va_start`` intrinsic may be
+`va_list` element into the destination `va_list` element. This
+intrinsic is necessary because the `llvm.va_start` intrinsic may be
arbitrarily complex and require, for example, memory allocation.
-On targets where ``llvm.va_copy`` is equivalent to ``memcpy``, ``memcpy``
-can be used instead to duplicate a ``va_list``. ``llvm.va_copy`` is
-equivalent to ``memcpy`` on all currently supported targets.
+On targets where `llvm.va_copy` is equivalent to `memcpy`, `memcpy`
+can be used instead to duplicate a `va_list`. `llvm.va_copy` is
+equivalent to `memcpy` on all currently supported targets.
-Accurate Garbage Collection Intrinsics
---------------------------------------
+### Accurate Garbage Collection Intrinsics
-LLVM's support for `Accurate Garbage Collection <GarbageCollection.html>`_
+LLVM's support for {doc}`Accurate Garbage Collection <GarbageCollection>`
(GC) requires the frontend to generate code containing appropriate intrinsic
calls and select an appropriate GC strategy which knows how to lower these
intrinsics in a manner which is appropriate for the target collector.
-These intrinsics allow identification of :ref:`GC roots on the
-stack <int_gcroot>`, as well as garbage collector implementations that
-require :ref:`read <int_gcread>` and :ref:`write <int_gcwrite>` barriers.
+These intrinsics allow identification of {ref}`GC roots on the stack <int_gcroot>`, as well as garbage collector implementations that
+require {ref}`read <int_gcread>` and {ref}`write <int_gcwrite>` barriers.
Frontends for type-safe garbage collected languages should generate
these intrinsics to make use of the LLVM garbage collectors. For more
-details, see `Garbage Collection with LLVM <GarbageCollection.html>`_.
+details, see {doc}`Garbage Collection with LLVM <GarbageCollection>`.
LLVM provides an second experimental set of intrinsics for describing garbage
collection safepoints in compiled code. These intrinsics are an alternative
-to the ``llvm.gcroot`` intrinsics, but are compatible with the ones for
-:ref:`read <int_gcread>` and :ref:`write <int_gcwrite>` barriers. The
-differences in approach are covered in the `Garbage Collection with LLVM
-<GarbageCollection.html>`_ documentation. The intrinsics themselves are
-described in :doc:`Statepoints`.
-
-.. _int_gcroot:
+to the `llvm.gcroot` intrinsics, but are compatible with the ones for
+{ref}`read <int_gcread>` and {ref}`write <int_gcwrite>` barriers. The
+differences in approach are covered in the {doc}`Garbage Collection with LLVM <GarbageCollection>` documentation. The intrinsics themselves are
+described in {doc}`Statepoints`.
-'``llvm.gcroot``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_gcroot)=
-Syntax:
-"""""""
+#### '`llvm.gcroot`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.gcroot(ptr %ptrloc, ptr %metadata)
+```
+declare void @llvm.gcroot(ptr %ptrloc, ptr %metadata)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.gcroot``' intrinsic declares the existence of a GC root to
+The '`llvm.gcroot`' intrinsic declares the existence of a GC root to
the code generator, and allows some metadata to be associated with it.
-Arguments:
-""""""""""
+##### Arguments:
The first argument specifies the address of a stack object that contains
the root pointer. The second pointer (which must be either a constant or
a global value address) contains the meta-data to be associated with the
root.
-Semantics:
-""""""""""
+##### Semantics:
At runtime, a call to this intrinsic stores a null pointer into the
"ptrloc" location. At compile-time, the code generator generates
information to allow the runtime to find the pointer at GC safe points.
-The '``llvm.gcroot``' intrinsic may only be used in a function which
-:ref:`specifies a GC algorithm <gc>`.
-
-.. _int_gcread:
+The '`llvm.gcroot`' intrinsic may only be used in a function which
+{ref}`specifies a GC algorithm <gc>`.
-'``llvm.gcread``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_gcread)=
-Syntax:
-"""""""
+#### '`llvm.gcread`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.gcread(ptr %ObjPtr, ptr %Ptr)
+```
+declare ptr @llvm.gcread(ptr %ObjPtr, ptr %Ptr)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.gcread``' intrinsic identifies reads of references from heap
+The '`llvm.gcread`' intrinsic identifies reads of references from heap
locations, allowing garbage collector implementations that require read
barriers.
-Arguments:
-""""""""""
+##### Arguments:
The second argument is the address to read from, which should be an
address allocated from the garbage collector. The first object is a
pointer to the start of the referenced object, if needed by the language
runtime (otherwise null).
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.gcread``' intrinsic has the same semantics as a load
+The '`llvm.gcread`' intrinsic has the same semantics as a load
instruction, but may be replaced with substantially more complex code by
-the garbage collector runtime, as needed. The '``llvm.gcread``'
-intrinsic may only be used in a function which :ref:`specifies a GC
-algorithm <gc>`.
-
-.. _int_gcwrite:
+the garbage collector runtime, as needed. The '`llvm.gcread`'
+intrinsic may only be used in a function which {ref}`specifies a GC algorithm <gc>`.
-'``llvm.gcwrite``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_gcwrite)=
-Syntax:
-"""""""
+#### '`llvm.gcwrite`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.gcwrite(ptr %P1, ptr %Obj, ptr %P2)
+```
+declare void @llvm.gcwrite(ptr %P1, ptr %Obj, ptr %P2)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.gcwrite``' intrinsic identifies writes of references to heap
+The '`llvm.gcwrite`' intrinsic identifies writes of references to heap
locations, allowing garbage collector implementations that require write
barriers (such as generational or reference counting collectors).
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the reference to store, the second is the start of
the object to store it to, and the third is the address of the field of
Obj to store to. If the runtime does not require a pointer to the
object, Obj may be null.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.gcwrite``' intrinsic has the same semantics as a store
+The '`llvm.gcwrite`' intrinsic has the same semantics as a store
instruction, but may be replaced with substantially more complex code by
-the garbage collector runtime, as needed. The '``llvm.gcwrite``'
-intrinsic may only be used in a function which :ref:`specifies a GC
-algorithm <gc>`.
-
+the garbage collector runtime, as needed. The '`llvm.gcwrite`'
+intrinsic may only be used in a function which {ref}`specifies a GC algorithm <gc>`.
-.. _gc_statepoint:
-'``llvm.experimental.gc.statepoint``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(gc_statepoint)=
-Syntax:
-"""""""
+#### '`llvm.experimental.gc.statepoint`' Intrinsic
-::
+##### Syntax:
- declare token
- @llvm.experimental.gc.statepoint(i64 <id>, i32 <num patch bytes>,
- ptr elementtype(func_type) <target>,
- i64 <#call args>, i64 <flags>,
- ... (call parameters),
- i64 0, i64 0)
+```
+declare token
+ @llvm.experimental.gc.statepoint(i64 <id>, i32 <num patch bytes>,
+ ptr elementtype(func_type) <target>,
+ i64 <#call args>, i64 <flags>,
+ ... (call parameters),
+ i64 0, i64 0)
+```
-Overview:
-"""""""""
+##### Overview:
The statepoint intrinsic represents a call which is parse-able by the
runtime.
-Operands:
-"""""""""
+##### Operands:
The 'id' operand is a constant integer that is reported as the ID
field in the generated stackmap. LLVM does not interpret this
@@ -14861,14 +14277,14 @@ sequence and the latter after the nop sequence. It is expected that
the user will patch over the 'num patch bytes' bytes of nops with a
calling sequence specific to their runtime before executing the
generated machine code. There are no guarantees with respect to the
-alignment of the nop sequence. Unlike :doc:`StackMaps` statepoints do
+alignment of the nop sequence. Unlike {doc}`StackMaps` statepoints do
not have a concept of shadow bytes. Note that semantically the
statepoint still represents a call or invoke to 'target', and the nop
sequence after patching is expected to represent an operation
equivalent to a call or invoke to 'target'.
The 'target' operand is the function actually being called. The operand
-must have an :ref:`elementtype <attr_elementtype>` attribute specifying
+must have an {ref}`elementtype <attr_elementtype>` attribute specifying
the function type of the target. The target can be specified as either
a symbolic LLVM function, or as an arbitrary Value of pointer type. Note
that the function type must match the signature of the callee and the
@@ -14883,14 +14299,17 @@ statepoint. This is currently only used to mark certain statepoints
as GC transitions. This operand is a 64-bit integer with the following
layout, where bit 0 is the least significant bit:
- +-------+---------------------------------------------------+
- | Bit # | Usage |
- +=======+===================================================+
- | 0 | Set if the statepoint is a GC transition, cleared |
- | | otherwise. |
- +-------+---------------------------------------------------+
- | 1-63 | Reserved for future use; must be cleared. |
- +-------+---------------------------------------------------+
+ ```{list-table}
+ :header-rows: 1
+
+ * - Bit #
+ - Usage
+ * - 0
+ - Set if the statepoint is a GC transition, cleared
+ otherwise.
+ * - 1-63
+ - Reserved for future use; must be cleared.
+ ```
The 'call parameters' arguments are simply the arguments which need to
be passed to the call target. They will be lowered according to the
@@ -14905,8 +14324,7 @@ These were originally the length prefixes for 'gc transition parameter' and
entirely replaced with the corresponding operand bundles. In a future
revision, these now redundant arguments will be removed.
-Semantics:
-""""""""""
+##### Semantics:
A statepoint is assumed to read and write all memory. As a result,
memory operations can not be reordered past a statepoint. It is
@@ -14915,77 +14333,68 @@ illegal to mark a statepoint as being either 'readonly' or 'readnone'.
Note that legal IR can not perform any memory operation on a 'gc
pointer' argument of the statepoint in a location statically reachable
from the statepoint. Instead, the explicitly relocated value (from a
-``gc.relocate``) must be used.
+`gc.relocate`) must be used.
-'``llvm.experimental.gc.result``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.gc.result`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare type
- @llvm.experimental.gc.result(token %statepoint_token)
+```
+declare type
+ @llvm.experimental.gc.result(token %statepoint_token)
+```
-Overview:
-"""""""""
+##### Overview:
-``gc.result`` extracts the result of the original call instruction
-which was replaced by the ``gc.statepoint``. The ``gc.result``
+`gc.result` extracts the result of the original call instruction
+which was replaced by the `gc.statepoint`. The `gc.result`
intrinsic is actually a family of three intrinsics due to an
implementation limitation. Other than the type of the return value,
the semantics are the same.
-Operands:
-"""""""""
+##### Operands:
-The first and only argument is the ``gc.statepoint`` which starts
-the safepoint sequence of which this ``gc.result`` is a part.
+The first and only argument is the `gc.statepoint` which starts
+the safepoint sequence of which this `gc.result` is a part.
Despite the typing of this as a generic token, *only* the value defined
-by a ``gc.statepoint`` is legal here.
+by a `gc.statepoint` is legal here.
-Semantics:
-""""""""""
+##### Semantics:
-The ``gc.result`` represents the return value of the call target of
-the ``statepoint``. The type of the ``gc.result`` must exactly match
+The `gc.result` represents the return value of the call target of
+the `statepoint`. The type of the `gc.result` must exactly match
the type of the target. If the call target returns void, there will
-be no ``gc.result``.
+be no `gc.result`.
-A ``gc.result`` is modeled as a 'readnone' pure function. It has no
+A `gc.result` is modeled as a 'readnone' pure function. It has no
side effects since it is just a projection of the return value of the
-previous call represented by the ``gc.statepoint``.
+previous call represented by the `gc.statepoint`.
-'``llvm.experimental.gc.relocate``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.gc.relocate`' Intrinsic
-::
+##### Syntax:
- declare <pointer type>
- @llvm.experimental.gc.relocate(token %statepoint_token,
- i32 %base_offset,
- i32 %pointer_offset)
+```
+declare <pointer type>
+ @llvm.experimental.gc.relocate(token %statepoint_token,
+ i32 %base_offset,
+ i32 %pointer_offset)
+```
-Overview:
-"""""""""
+##### Overview:
-A ``gc.relocate`` returns the potentially relocated value of a pointer
+A `gc.relocate` returns the potentially relocated value of a pointer
at the safepoint.
-Operands:
-"""""""""
+##### Operands:
-The first argument is the ``gc.statepoint`` which starts the
-safepoint sequence of which this ``gc.relocation`` is a part.
+The first argument is the `gc.statepoint` which starts the
+safepoint sequence of which this `gc.relocation` is a part.
Despite the typing of this as a generic token, *only* the value defined
-by a ``gc.statepoint`` is legal here.
+by a `gc.statepoint` is legal here.
The second and third arguments are both indices into operands of the
-corresponding statepoint's :ref:`gc-live <ob_gc_live>` operand bundle.
+corresponding statepoint's {ref}`gc-live <ob_gc_live>` operand bundle.
The second argument is an index which specifies the allocation for the pointer
being relocated. The associated value must be within the object with which the
@@ -14999,55 +14408,49 @@ The third argument is an index which specify the (potentially) derived pointer
being relocated. It is legal for this index to be the same as the second
argument if and only if a base pointer is being relocated.
-Semantics:
-""""""""""
+##### Semantics:
-The return value of ``gc.relocate`` is the potentially relocated value
+The return value of `gc.relocate` is the potentially relocated value
of the pointer specified by its arguments. It is unspecified how the
value of the returned pointer relates to the argument to the
-``gc.statepoint`` other than that a) it points to the same source
+`gc.statepoint` other than that a) it points to the same source
language object with the same offset, and b) the 'based-on'
relationship of the newly relocated pointers is a projection of the
unrelocated pointers. In particular, the integer value of the pointer
returned is unspecified.
-A ``gc.relocate`` is modeled as a ``readnone`` pure function. It has no
+A `gc.relocate` is modeled as a `readnone` pure function. It has no
side effects since it is just a way to extract information about work
-done during the actual call modeled by the ``gc.statepoint``.
+done during the actual call modeled by the `gc.statepoint`.
-.. _gc.get.pointer.base:
+(gc.get.pointer.base)=
-'``llvm.experimental.gc.get.pointer.base``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.gc.get.pointer.base`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <pointer type>
- @llvm.experimental.gc.get.pointer.base(
- <pointer type> readnone captures(none) %derived_ptr)
- nounwind willreturn memory(none)
+```
+declare <pointer type>
+ @llvm.experimental.gc.get.pointer.base(
+ <pointer type> readnone captures(none) %derived_ptr)
+ nounwind willreturn memory(none)
+```
-Overview:
-"""""""""
+##### Overview:
-``gc.get.pointer.base`` for a derived pointer returns its base pointer.
+`gc.get.pointer.base` for a derived pointer returns its base pointer.
-Operands:
-"""""""""
+##### Operands:
The only argument is a pointer which is based on some object with
an unknown offset from the base of said object.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is used in the abstract machine model for GC to represent
the base pointer for an arbitrary derived pointer.
-This intrinsic is inlined by the :ref:`RewriteStatepointsForGC` pass by
+This intrinsic is inlined by the {ref}`RewriteStatepointsForGC` pass by
replacing all uses of this callsite with the offset of a derived pointer from
its base pointer value. The replacement is done as part of the lowering to the
explicit statepoint model.
@@ -15055,83 +14458,72 @@ explicit statepoint model.
The return pointer type must be the same as the type of the parameter.
-'``llvm.experimental.gc.get.pointer.offset``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.gc.get.pointer.offset`' Intrinsic
-::
+##### Syntax:
- declare i64
- @llvm.experimental.gc.get.pointer.offset(
- <pointer type> readnone captures(none) %derived_ptr)
- nounwind willreturn memory(none)
+```
+declare i64
+ @llvm.experimental.gc.get.pointer.offset(
+ <pointer type> readnone captures(none) %derived_ptr)
+ nounwind willreturn memory(none)
+```
-Overview:
-"""""""""
+##### Overview:
-``gc.get.pointer.offset`` for a derived pointer returns the offset from its
+`gc.get.pointer.offset` for a derived pointer returns the offset from its
base pointer.
-Operands:
-"""""""""
+##### Operands:
The only argument is a pointer which is based on some object with
an unknown offset from the base of said object.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is used in the abstract machine model for GC to represent
the offset of an arbitrary derived pointer from its base pointer.
-This intrinsic is inlined by the :ref:`RewriteStatepointsForGC` pass by
+This intrinsic is inlined by the {ref}`RewriteStatepointsForGC` pass by
replacing all uses of this callsite with the offset of a derived pointer from
its base pointer value. The replacement is done as part of the lowering to the
explicit statepoint model.
Basically this call calculates difference between the derived pointer and its
-base pointer (see :ref:`gc.get.pointer.base`) both ptrtoint casted. But
-this cast done outside the :ref:`RewriteStatepointsForGC` pass could result
+base pointer (see {ref}`gc.get.pointer.base`) both ptrtoint casted. But
+this cast done outside the {ref}`RewriteStatepointsForGC` pass could result
in the pointers lost for further lowering from the abstract model to the
explicit physical one.
-Code Generator Intrinsics
--------------------------
+### Code Generator Intrinsics
These intrinsics are provided by LLVM to expose special features that
may only be implemented with code generator support.
-'``llvm.returnaddress``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.returnaddress`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare ptr @llvm.returnaddress(i32 <level>)
+```
+declare ptr @llvm.returnaddress(i32 <level>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.returnaddress``' intrinsic attempts to compute a
+The '`llvm.returnaddress`' intrinsic attempts to compute a
target-specific value indicating the return address of the current
function or one of its callers.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic indicates which function to return the
address for. Zero indicates the calling function, one indicates its
caller, etc. The argument is **required** to be a constant integer
value.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.returnaddress``' intrinsic either returns a pointer
+The '`llvm.returnaddress`' intrinsic either returns a pointer
indicating the return address of the specified call frame, or zero if it
cannot be identified. The value returned by this intrinsic is likely to
be incorrect or 0 for arguments other than zero, so it should only be
@@ -15141,25 +14533,21 @@ Note that calling this intrinsic does not prevent function inlining or
other aggressive transformations, so the value returned may not be that
of the obvious source-language caller.
-'``llvm.addressofreturnaddress``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.addressofreturnaddress`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.addressofreturnaddress()
+```
+declare ptr @llvm.addressofreturnaddress()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.addressofreturnaddress``' intrinsic returns a target-specific
+The '`llvm.addressofreturnaddress`' intrinsic returns a target-specific
pointer to the place in the stack frame where the return address of the
current function is stored.
-Semantics:
-""""""""""
+##### Semantics:
Note that calling this intrinsic does not prevent function inlining or
other aggressive transformations, so the value returned may not be that
@@ -15167,86 +14555,73 @@ of the obvious source-language caller.
This intrinsic is only implemented for x86 and aarch64.
-'``llvm.sponentry``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sponentry`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare ptr @llvm.sponentry()
+```
+declare ptr @llvm.sponentry()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sponentry``' intrinsic returns the stack pointer value at
+The '`llvm.sponentry`' intrinsic returns the stack pointer value at
the entry of the current function calling this intrinsic.
-Semantics:
-""""""""""
+##### Semantics:
Note this intrinsic is only verified on AArch64 and ARM.
-'``llvm.stackaddress``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.stackaddress`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.stackaddress.p0()
+```
+declare ptr @llvm.stackaddress.p0()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.stackaddress``' intrinsic returns the starting address of the
+The '`llvm.stackaddress`' intrinsic returns the starting address of the
stack region that may be used by called functions.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic returns the *logical* value of the stack pointer register, that
is, the address separating the stack space of the current function from the
stack space that may be modified by called functions. It corresponds to the
-address returned by '``llvm.sponentry``', offset by the size of the current
+address returned by '`llvm.sponentry`', offset by the size of the current
function's stack frame.
On certain targets (e.g. x86), the logical and actual (or physical) values of
the stack pointer register are the same. However, on other architectures (e.g.
SPARCv9), the logical value of the stack pointer register may differ from the
-physical value. '``llvm.stackaddress``' handles this discrepancy and returns
+physical value. '`llvm.stackaddress`' handles this discrepancy and returns
the correct boundary address.
-'``llvm.frameaddress``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.frameaddress`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare ptr @llvm.frameaddress(i32 <level>)
+```
+declare ptr @llvm.frameaddress(i32 <level>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.frameaddress``' intrinsic attempts to return the
+The '`llvm.frameaddress`' intrinsic attempts to return the
target-specific frame pointer value for the specified stack frame.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic indicates which function to return the
frame pointer for. Zero indicates the calling function, one indicates
its caller, etc. The argument is **required** to be a constant integer
value.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.frameaddress``' intrinsic either returns a pointer
+The '`llvm.frameaddress`' intrinsic either returns a pointer
indicating the frame address of the specified call frame, or zero if it
cannot be identified. The value returned by this intrinsic is likely to
be incorrect or 0 for arguments other than zero, so it should only be
@@ -15256,98 +14631,85 @@ Note that calling this intrinsic does not prevent function inlining or
other aggressive transformations, so the value returned may not be that
of the obvious source-language caller.
-'``llvm.swift.async.context.addr``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.swift.async.context.addr`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.swift.async.context.addr()
+```
+declare ptr @llvm.swift.async.context.addr()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.swift.async.context.addr``' intrinsic returns a pointer to
+The '`llvm.swift.async.context.addr`' intrinsic returns a pointer to
the part of the extended frame record containing the asynchronous
context of a Swift execution.
-Semantics:
-""""""""""
+##### Semantics:
-If the caller has a ``swiftasync`` parameter, that argument will initially
+If the caller has a `swiftasync` parameter, that argument will initially
be stored at the returned address. If not, it will be initialized to null.
-'``llvm.localescape``' and '``llvm.localrecover``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.localescape`' and '`llvm.localrecover`' Intrinsics
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.localescape(...)
- declare ptr @llvm.localrecover(ptr %func, ptr %fp, i32 %idx)
+```
+declare void @llvm.localescape(...)
+declare ptr @llvm.localrecover(ptr %func, ptr %fp, i32 %idx)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.localescape``' intrinsic escapes offsets of a collection of static
-allocas, and the '``llvm.localrecover``' intrinsic applies those offsets to a
+The '`llvm.localescape`' intrinsic escapes offsets of a collection of static
+allocas, and the '`llvm.localrecover`' intrinsic applies those offsets to a
live frame pointer to recover the address of the allocation. The offset is
-computed during frame layout of the caller of ``llvm.localescape``.
+computed during frame layout of the caller of `llvm.localescape`.
-Arguments:
-""""""""""
+##### Arguments:
-All arguments to '``llvm.localescape``' must be pointers to static allocas or
-casts of static allocas. Each function can only call '``llvm.localescape``'
+All arguments to '`llvm.localescape`' must be pointers to static allocas or
+casts of static allocas. Each function can only call '`llvm.localescape`'
once, and it can only do so from the entry block.
-The ``func`` argument to '``llvm.localrecover``' must be a constant
+The `func` argument to '`llvm.localrecover`' must be a constant
bitcasted pointer to a function defined in the current module. The code
generator cannot determine the frame allocation offset of functions defined in
other modules.
-The ``fp`` argument to '``llvm.localrecover``' must be a frame pointer of a
-call frame that is currently live. The return value of '``llvm.localaddress``'
+The `fp` argument to '`llvm.localrecover`' must be a frame pointer of a
+call frame that is currently live. The return value of '`llvm.localaddress`'
is one way to produce such a value, but various runtimes also expose a suitable
pointer in platform-specific ways.
-The ``idx`` argument to '``llvm.localrecover``' indicates which alloca passed to
-'``llvm.localescape``' to recover. It is zero-indexed.
+The `idx` argument to '`llvm.localrecover`' indicates which alloca passed to
+'`llvm.localescape`' to recover. It is zero-indexed.
-Semantics:
-""""""""""
+##### Semantics:
These intrinsics allow a group of functions to share access to a set of local
stack allocations of a one parent function. The parent function may call the
-'``llvm.localescape``' intrinsic once from the function entry block, and the
-child functions can use '``llvm.localrecover``' to access the escaped allocas.
-The '``llvm.localescape``' intrinsic blocks inlining, as inlining changes where
+'`llvm.localescape`' intrinsic once from the function entry block, and the
+child functions can use '`llvm.localrecover`' to access the escaped allocas.
+The '`llvm.localescape`' intrinsic blocks inlining, as inlining changes where
the escaped allocas are allocated, which would break attempts to use
-'``llvm.localrecover``'.
+'`llvm.localrecover`'.
-'``llvm.seh.try.begin``' and '``llvm.seh.try.end``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.seh.try.begin`' and '`llvm.seh.try.end`' Intrinsics
-::
+##### Syntax:
- declare void @llvm.seh.try.begin()
- declare void @llvm.seh.try.end()
+```
+declare void @llvm.seh.try.begin()
+declare void @llvm.seh.try.end()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.seh.try.begin``' and '``llvm.seh.try.end``' intrinsics mark
+The '`llvm.seh.try.begin`' and '`llvm.seh.try.end`' intrinsics mark
the boundary of a _try region for Windows SEH Asynchronous Exception Handling.
-Semantics:
-""""""""""
+##### Semantics:
When a C-function is compiled with Windows SEH Asynchronous Exception option,
-feh_asynch (aka MSVC -EHa), these two intrinsics are injected to mark _try
@@ -15355,84 +14717,76 @@ boundary and to prevent potential exceptions from being moved across boundary.
Any set of operations can then be confined to the region by reading their leaf
inputs via volatile loads and writing their root outputs via volatile stores.
-'``llvm.seh.scope.begin``' and '``llvm.seh.scope.end``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.seh.scope.begin`' and '`llvm.seh.scope.end`' Intrinsics
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.seh.scope.begin()
- declare void @llvm.seh.scope.end()
+```
+declare void @llvm.seh.scope.begin()
+declare void @llvm.seh.scope.end()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.seh.scope.begin``' and '``llvm.seh.scope.end``' intrinsics mark
+The '`llvm.seh.scope.begin`' and '`llvm.seh.scope.end`' intrinsics mark
the boundary of a CPP object lifetime for Windows SEH Asynchronous Exception
Handling (MSVC option -EHa).
-Semantics:
-""""""""""
+##### Semantics:
LLVM's ordinary exception-handling representation associates EH cleanups and
-handlers only with ``invoke``s, which normally correspond only to call sites. To
+handlers only with `invoke`s, which normally correspond only to call sites. To
support arbitrary faulting instructions, it must be possible to recover the current
EH scope for any instruction. Turning every operation in LLVM that could fault
-into an ``invoke`` of a new, potentially-throwing intrinsic would require adding a
+into an `invoke` of a new, potentially-throwing intrinsic would require adding a
large number of intrinsics, impede optimization of those operations, and make
compilation slower by introducing many extra basic blocks. These intrinsics can
be used instead to mark the region protected by a cleanup, such as for a local
-C++ object with a non-trivial destructor. ``llvm.seh.scope.begin`` is used to mark
-the start of the region; it is always called with ``invoke``, with the unwind block
+C++ object with a non-trivial destructor. `llvm.seh.scope.begin` is used to mark
+the start of the region; it is always called with `invoke`, with the unwind block
being the desired unwind destination for any potentially-throwing instructions
within the region. `llvm.seh.scope.end` is used to mark when the scope ends
and the EH cleanup is no longer required (e.g., because the destructor is being
called).
-.. _int_read_register:
-.. _int_read_volatile_register:
-.. _int_write_register:
-.. _int_write_volatile_register:
+(int_read_register)=
+(int_read_volatile_register)=
+(int_write_register)=
+(int_write_volatile_register)=
-'``llvm.read_register``', '``llvm.read_volatile_register``', '``llvm.write_register``', and '``llvm.write_volatile_register``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.read_register`', '`llvm.read_volatile_register`', '`llvm.write_register`', and '`llvm.write_volatile_register`' Intrinsics
-::
+##### Syntax:
- declare i32 @llvm.read_register.i32(metadata)
- declare i64 @llvm.read_register.i64(metadata)
- declare i32 @llvm.read_volatile_register.i32(metadata)
- declare i64 @llvm.read_volatile_register.i64(metadata)
- declare void @llvm.write_register.i32(metadata, i32 @value)
- declare void @llvm.write_register.i64(metadata, i64 @value)
- declare void @llvm.write_volatile_register.i32(metadata, i32 @value)
- declare void @llvm.write_volatile_register.i64(metadata, i64 @value)
- !0 = !{!"sp\00"}
+```
+declare i32 @llvm.read_register.i32(metadata)
+declare i64 @llvm.read_register.i64(metadata)
+declare i32 @llvm.read_volatile_register.i32(metadata)
+declare i64 @llvm.read_volatile_register.i64(metadata)
+declare void @llvm.write_register.i32(metadata, i32 @value)
+declare void @llvm.write_register.i64(metadata, i64 @value)
+declare void @llvm.write_volatile_register.i32(metadata, i32 @value)
+declare void @llvm.write_volatile_register.i64(metadata, i64 @value)
+!0 = !{!"sp\00"}
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.read_register``', '``llvm.read_volatile_register``',
-'``llvm.write_register``', and '``llvm.write_volatile_register``' intrinsics
+The '`llvm.read_register`', '`llvm.read_volatile_register`',
+'`llvm.write_register`', and '`llvm.write_volatile_register`' intrinsics
provide access to the named register. The register must be valid on the
architecture being compiled to. The type needs to be compatible with the
register being accessed.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.read_register``' and '``llvm.read_volatile_register``' intrinsics
+The '`llvm.read_register`' and '`llvm.read_volatile_register`' intrinsics
return the current value of the register, where possible. The
-'``llvm.write_register``' and '``llvm.write_volatile_register``' intrinsics
+'`llvm.write_register`' and '`llvm.write_volatile_register`' intrinsics
set the current value of the register, where possible.
-A call to '``llvm.read_volatile_register``' or
-'``llvm.write_volatile_register``' is assumed to have side-effects and will
+A call to '`llvm.read_volatile_register`' or
+'`llvm.write_volatile_register`' is assumed to have side-effects and will
not be reordered or eliminated by the optimizer.
This is useful to implement named register global variables that need
@@ -15441,148 +14795,134 @@ bare-metal programs including OS kernels.
The compiler doesn't check for register availability or use of the used
register in surrounding code, including inline assembly. Because of that,
-allocatable registers are not supported by '``llvm.read_register``',
-'``llvm.read_volatile_register``', or '``llvm.write_register``'.
+allocatable registers are not supported by '`llvm.read_register`',
+'`llvm.read_volatile_register`', or '`llvm.write_register`'.
-'``llvm.write_volatile_register``' supports allocatable registers. Writing
+'`llvm.write_volatile_register`' supports allocatable registers. Writing
to an allocatable register means the value is copied into that physical
register at the point of the call; the register may subsequently be
reused by the register allocator for other purposes. The backend emits a
-``FAKE_USE`` of the physical register after the write to prevent the store
+`FAKE_USE` of the physical register after the write to prevent the store
from being dead-eliminated before register allocation.
Warning: Register support is target-specific. The IR-level verifier does
not validate register names; an unsupported name results in a fatal error
during code generation. Supported registers vary by target and can be
-found in each target's ``getRegisterByName`` implementation.
-'``llvm.write_volatile_register``' support for allocatable registers is
+found in each target's `getRegisterByName` implementation.
+'`llvm.write_volatile_register`' support for allocatable registers is
currently only implemented on AArch64.
-.. _int_stacksave:
+(int_stacksave)=
-'``llvm.stacksave``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.stacksave`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare ptr @llvm.stacksave.p0()
- declare ptr addrspace(5) @llvm.stacksave.p5()
+```
+declare ptr @llvm.stacksave.p0()
+declare ptr addrspace(5) @llvm.stacksave.p5()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.stacksave``' intrinsic is used to remember the current state
+The '`llvm.stacksave`' intrinsic is used to remember the current state
of the function stack, for use with
-:ref:`llvm.stackrestore <int_stackrestore>`. This is useful for
+{ref}`llvm.stackrestore <int_stackrestore>`. This is useful for
implementing language features like scoped automatic variable sized
arrays in C99.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic returns an opaque pointer value that can be passed to
-:ref:`llvm.stackrestore <int_stackrestore>`. When an
-``llvm.stackrestore`` intrinsic is executed with a value saved from
-``llvm.stacksave``, it effectively restores the state of the stack to
-the state it was in when the ``llvm.stacksave`` intrinsic executed. In
-practice, this pops any :ref:`alloca <i_alloca>` blocks from the stack
-that were allocated after the ``llvm.stacksave`` was executed. The
+{ref}`llvm.stackrestore <int_stackrestore>`. When an
+`llvm.stackrestore` intrinsic is executed with a value saved from
+`llvm.stacksave`, it effectively restores the state of the stack to
+the state it was in when the `llvm.stacksave` intrinsic executed. In
+practice, this pops any {ref}`alloca <i_alloca>` blocks from the stack
+that were allocated after the `llvm.stacksave` was executed. The
address space should typically be the
-:ref:`alloca address space <alloca_addrspace>`.
+{ref}`alloca address space <alloca_addrspace>`.
-.. _int_stackrestore:
+(int_stackrestore)=
-'``llvm.stackrestore``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.stackrestore`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.stackrestore.p0(ptr %ptr)
- declare void @llvm.stackrestore.p5(ptr addrspace(5) %ptr)
+```
+declare void @llvm.stackrestore.p0(ptr %ptr)
+declare void @llvm.stackrestore.p5(ptr addrspace(5) %ptr)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.stackrestore``' intrinsic is used to restore the state of
+The '`llvm.stackrestore`' intrinsic is used to restore the state of
the function stack to the state it was in when the corresponding
-:ref:`llvm.stacksave <int_stacksave>` intrinsic executed. This is
+{ref}`llvm.stacksave <int_stacksave>` intrinsic executed. This is
useful for implementing language features like scoped automatic
variable sized arrays in C99. The address space should typically be
-the :ref:`alloca address space <alloca_addrspace>`.
+the {ref}`alloca address space <alloca_addrspace>`.
-Semantics:
-""""""""""
+##### Semantics:
-See the description for :ref:`llvm.stacksave <int_stacksave>`.
+See the description for {ref}`llvm.stacksave <int_stacksave>`.
-.. _i_structured_gep:
+(i_structured_gep)=
-'``llvm.structured.gep``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.structured.gep`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <ret_type>
- @llvm.structured.gep(ptr elementtype(<basetype>) <source>
- {, [i32/i64] <index> }*)
+```
+declare <ret_type>
+ at llvm.structured.gep(ptr elementtype(<basetype>) <source>
+ {, [i32/i64] <index> }*)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.structured.gep``' intrinsic (structured
-**G**\ et\ **E**\ lement\ **P**\ tr) computes a new pointer address resulting
-from a logical indexing into the ``<source>`` pointer. The returned address
-depends on the indices and may depend on the layout of ``<basetype>``
+The '`llvm.structured.gep`' intrinsic (structured
+**G**et**E**lement**P**tr) computes a new pointer address resulting
+from a logical indexing into the `<source>` pointer. The returned address
+depends on the indices and may depend on the layout of `<basetype>`
at runtime.
-Arguments:
-""""""""""
+##### Arguments:
-``ptr elementtype(<basetype>) <source>``:
+`ptr elementtype(<basetype>) <source>`:
A pointer to the memory location used as base for the address computation.
-The ``source`` argument must be annotated with an :ref:`elementtype
-<attr_elementtype>` attribute at the call-site. This attribute specifies the
+The `source` argument must be annotated with an {ref}`elementtype <attr_elementtype>` attribute at the call-site. This attribute specifies the
type of the element pointed to by the pointer source. This type will be
used along with the provided indices and source operand to compute a new
pointer representing the result of a logical indexing into the basetype
pointed by source.
-The ``basetype`` is only associated with ``<source>`` for this particular
+The `basetype` is only associated with `<source>` for this particular
call. A frontend could possibly emit multiple structured
-GEP with the same source pointer but a different ``basetype``.
+GEP with the same source pointer but a different `basetype`.
-``[i32/i64] index, ...``:
-Indices used to traverse into the ``basetype`` and compute a pointer to the
+`[i32/i64] index, ...`:
+Indices used to traverse into the `basetype` and compute a pointer to the
target element. Indices can be 32-bit or 64-bit unsigned integers. Indices being
handled one by one, both sizes can be mixed in the same instruction. The
precision used to compute the resulting pointer is target-dependent.
When used to index into a struct, only integer constants are allowed.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.structured.gep`` performs a logical traversal of the type
-``basetype`` using the list of provided indices, computing the pointer
-addressing the targeted element/field assuming ``source`` points to a
-physically laid out ``basetype``. The physical layout of the source depends
+The `llvm.structured.gep` performs a logical traversal of the type
+`basetype` using the list of provided indices, computing the pointer
+addressing the targeted element/field assuming `source` points to a
+physically laid out `basetype`. The physical layout of the source depends
on the target and does not necessarily match the one described by the
datalayout.
-The first index determines which element/field of ``basetype`` is selected,
-computes the pointer to access this element/field assuming ``source`` points
-to the start of ``basetype``.
-This pointer becomes the new ``source``, the current type the new
-``basetype``, and the next indices is consumed until a scalar type is
+The first index determines which element/field of `basetype` is selected,
+computes the pointer to access this element/field assuming `source` points
+to the start of `basetype`.
+This pointer becomes the new `source`, the current type the new
+`basetype`, and the next indices is consumed until a scalar type is
reached or all indices are consumed.
All indices must be consumed, and it is illegal to index into a scalar type.
@@ -15593,12 +14933,12 @@ assumed to be inbounds. This means it is not possible to access the next
element in the logical layout by overflowing:
- If the indexed type is a struct with N fields, the index must be an
- immediate/constant value in the range ``[0; N[``.
+ immediate/constant value in the range `[0; N[`.
- If indexing into an array or vector, the index can be a variable, but
is assumed to be inbounds with regards to the current basetype logical layout.
-- If the traversed type is an array or vector of N elements with ``N > 0``,
- the index is assumed to belong to ``[0; N[``.
-- If the traversed type is an array of size ``0``, the array size is assumed
+- If the traversed type is an array or vector of N elements with `N > 0`,
+ the index is assumed to belong to `[0; N[`.
+- If the traversed type is an array of size `0`, the array size is assumed
to be known at runtime, and the instruction assumes the index is always
inbounds.
@@ -15606,26 +14946,25 @@ In all cases **except** when the accessed type is a 0-sized array, indexing
out of bounds yields `poison`. When the index value is unknown, optimizations
can use the type bounds to determine the range of values the index can have.
If the source pointer is poison, the instruction returns poison.
-The resulting pointer belongs to the same address space as ``source``.
+The resulting pointer belongs to the same address space as `source`.
This instruction does not dereference the pointer.
-Example:
-""""""""
+##### Example:
**Simple case: logical access of a struct field**
-.. code-block:: cpp
-
- struct A { int a, int b, int c, int d };
- int val = my_struct->b;
+```cpp
+struct A { int a, int b, int c, int d };
+int val = my_struct->b;
+```
Could be translated to:
-.. code-block:: llvm
-
- %A = type { i32, i32, i32, i32 }
- %src = call ptr @llvm.structured.gep(ptr elementtype(%A) %my_struct, i32 1)
- %val = load i32, ptr %src
+```llvm
+%A = type { i32, i32, i32, i32 }
+%src = call ptr @llvm.structured.gep(ptr elementtype(%A) %my_struct, i32 1)
+%val = load i32, ptr %src
+```
**A more complex case**
@@ -15633,78 +14972,72 @@ This instruction can also be used on the same pointer with different
basetypes, as long as codegen knows how those are physically laid out.
Let’s consider the following code:
-.. code-block:: cpp
-
- struct S {
- uint a;
- uint b;
- uint c;
- uint d;
- }
-
- int val = my_struct->b;
+```cpp
+struct S {
+ uint a;
+ uint b;
+ uint c;
+ uint d;
+}
+int val = my_struct->b;
+```
In this example, the frontend doesn't know the exact physical layout, but
knows those logical layouts are lowered to the same physical layout:
- - `{ i32, i32, i32, i32 }`
- - `[ i32 x 4 ]`
+- `{ i32, i32, i32, i32 }`
+- `[ i32 x 4 ]`
This means is is valid to lower the following code to either:
-.. code-block:: llvm
-
- %S = type { i32, i32, i32, i32 }
- %src = call ptr @llvm.structured.gep(ptr elementtype(%S) %my_struct, i32 1)
- load i32, ptr %src
+```llvm
+%S = type { i32, i32, i32, i32 }
+%src = call ptr @llvm.structured.gep(ptr elementtype(%S) %my_struct, i32 1)
+load i32, ptr %src
+```
Or:
-.. code-block:: llvm
-
- %src = call ptr @llvm.structured.gep(ptr elementtype([ 4 x i32 ]) %my_struct, i32 1)
- load i32, ptr %src
+```llvm
+%src = call ptr @llvm.structured.gep(ptr elementtype([ 4 x i32 ]) %my_struct, i32 1)
+load i32, ptr %src
+```
This is, however, dependent on context that codegen has an insight on. The
fact that `[ i32 x 4 ]` and `%S` are equivalent depends on the target.
-.. _i_structured_alloca:
+(i_structured_alloca)=
-'``llvm.structured.alloca``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.structured.alloca`' Intrinsic
-::
+##### Syntax:
- declare elementtype(<allocated_type>) ptr
- @llvm.structured.alloca()
+```
+declare elementtype(<allocated_type>) ptr
+ at llvm.structured.alloca()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.structured.alloca``' intrinsic allocates uninitialized memory on
+The '`llvm.structured.alloca`' intrinsic allocates uninitialized memory on
the stack for a logical type, such as an aggregate, an array, or a scalar.
-Unlike the standard :ref:`alloca <i_alloca>` instruction, the physical memory
-layout of a ``llvm.structured.alloca`` is completely opaque to the IR.
+Unlike the standard {ref}`alloca <i_alloca>` instruction, the physical memory
+layout of a `llvm.structured.alloca` is completely opaque to the IR.
Exact padding, size, alignment and subtype offsets is target-dependent and
-may differ from the standard ``DataLayout``.
+may differ from the standard `DataLayout`.
-Arguments:
-""""""""""
+##### Arguments:
-The intrinsic must be annotated with an :ref:`elementtype <attr_elementtype>`
+The intrinsic must be annotated with an {ref}`elementtype <attr_elementtype>`
attribute at the call-site on the return value. This attribute specifies the
type of the allocated element.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.structured.alloca`` intrinsic allocates uninitialized memory for a
+The `llvm.structured.alloca` intrinsic allocates uninitialized memory for a
logical type. Loading from uninitialized memory produces an undefined value.
This intrinsic does not guarantee that the allocated memory will store a value
of the given type, only that it allocates enough space for it on the destination
@@ -15712,139 +15045,125 @@ target. While the type's size and layout are constant (independent of location),
the exact padding and offsets between subtypes are opaque to the IR and are
determined by the target's backend.
-The resulting pointer is in the :ref:`alloca address space <alloca_addrspace>`
-defined in the :ref:`datalayout string <langref_datalayout>`.
+The resulting pointer is in the {ref}`alloca address space <alloca_addrspace>`
+defined in the {ref}`datalayout string <langref_datalayout>`.
-Standard pointer arithmetic (``getelementptr``, ``ptradd``) and lifetime
-intrinsics (:ref:`llvm.lifetime.start <int_lifestart>`,
-:ref:`llvm.lifetime.end <int_lifeend>`) are permitted on the returned pointer.
+Standard pointer arithmetic (`getelementptr`, `ptradd`) and lifetime
+intrinsics ({ref}`llvm.lifetime.start <int_lifestart>`,
+{ref}`llvm.lifetime.end <int_lifeend>`) are permitted on the returned pointer.
However, because the physical layout is opaque, using physical pointer
arithmetic requires the frontend or emitting pass to have explicit knowledge of
the backend's layout rules.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %S = type { i32, i32, i32, i32 }
-
- ; Allocate one instance of %S on the stack
- %ptr = call elementtype(%S) ptr @llvm.structured.alloca()
+##### Example:
- ; Access the second field of the allocated struct
- %field_ptr = call ptr @llvm.structured.gep(ptr elementtype(%S) %ptr, i32 1)
- %val = load i32, ptr %field_ptr
+```llvm
+%S = type { i32, i32, i32, i32 }
- ; Allocate an array of 10 i32s on the stack
- %array_ptr = call elementtype([10 x i32]) ptr @llvm.structured.alloca()
+; Allocate one instance of %S on the stack
+%ptr = call elementtype(%S) ptr @llvm.structured.alloca()
- ; Allocate a single i32 on the stack
- %scalar_ptr = call elementtype(i32) ptr @llvm.structured.alloca()
+; Access the second field of the allocated struct
+%field_ptr = call ptr @llvm.structured.gep(ptr elementtype(%S) %ptr, i32 1)
+%val = load i32, ptr %field_ptr
- ; Although the exact size of 'i32' or '%S' is opaque, it is constant
- ; for the duration of the module. This allows, for example, reusing
- ; an allocation slot for two different values of the same type.
- %a = call elementtype(float) ptr @llvm.structured.alloca()
- %b = call elementtype(float) ptr @llvm.structured.alloca()
- ; %a and %b are guaranteed to have the same allocation size.
+; Allocate an array of 10 i32s on the stack
+%array_ptr = call elementtype([10 x i32]) ptr @llvm.structured.alloca()
+; Allocate a single i32 on the stack
+%scalar_ptr = call elementtype(i32) ptr @llvm.structured.alloca()
-.. _int_get_dynamic_area_offset:
+; Although the exact size of 'i32' or '%S' is opaque, it is constant
+; for the duration of the module. This allows, for example, reusing
+; an allocation slot for two different values of the same type.
+%a = call elementtype(float) ptr @llvm.structured.alloca()
+%b = call elementtype(float) ptr @llvm.structured.alloca()
+; %a and %b are guaranteed to have the same allocation size.
+```
-'``llvm.get.dynamic.area.offset``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_get_dynamic_area_offset)=
-Syntax:
-"""""""
-
-::
+#### '`llvm.get.dynamic.area.offset`' Intrinsic
- declare i32 @llvm.get.dynamic.area.offset.i32()
- declare i64 @llvm.get.dynamic.area.offset.i64()
+##### Syntax:
-Overview:
-"""""""""
+```
+declare i32 @llvm.get.dynamic.area.offset.i32()
+declare i64 @llvm.get.dynamic.area.offset.i64()
+```
- The '``llvm.get.dynamic.area.offset.*``' intrinsic family is used to
- get the offset from native stack pointer to the address of the most
- recent dynamic alloca on the caller's stack. These intrinsics are
- intended for use in combination with
- :ref:`llvm.stacksave <int_stacksave>` to get a
- pointer to the most recent dynamic alloca. This is useful, for example,
- for AddressSanitizer's stack unpoisoning routines.
+##### Overview:
-Semantics:
-""""""""""
+The '`llvm.get.dynamic.area.offset.*`' intrinsic family is used to
+get the offset from native stack pointer to the address of the most
+recent dynamic alloca on the caller's stack. These intrinsics are
+intended for use in combination with
+{ref}`llvm.stacksave <int_stacksave>` to get a
+pointer to the most recent dynamic alloca. This is useful, for example,
+for AddressSanitizer's stack unpoisoning routines.
- These intrinsics return a non-negative integer value that can be used to
- get the address of the most recent dynamic alloca, allocated by :ref:`alloca <i_alloca>`
- on the caller's stack. In particular, for targets where stack grows downwards,
- adding this offset to the native stack pointer would get the address of the most
- recent dynamic alloca. For targets where stack grows upwards, the situation is a bit more
- complicated, because subtracting this value from stack pointer would get the address
- one past the end of the most recent dynamic alloca.
+##### Semantics:
- Although for most targets `llvm.get.dynamic.area.offset <int_get_dynamic_area_offset>`
- returns just a zero, for others, such as PowerPC and PowerPC64, it returns a
- compile-time-known constant value.
+These intrinsics return a non-negative integer value that can be used to
+get the address of the most recent dynamic alloca, allocated by {ref}`alloca <i_alloca>`
+on the caller's stack. In particular, for targets where stack grows downwards,
+adding this offset to the native stack pointer would get the address of the most
+recent dynamic alloca. For targets where stack grows upwards, the situation is a bit more
+complicated, because subtracting this value from stack pointer would get the address
+one past the end of the most recent dynamic alloca.
- The return value type of :ref:`llvm.get.dynamic.area.offset <int_get_dynamic_area_offset>`
- must match the target's :ref:`alloca address space <alloca_addrspace>` type.
+Although for most targets `llvm.get.dynamic.area.offset <int_get_dynamic_area_offset>`
+returns just a zero, for others, such as PowerPC and PowerPC64, it returns a
+compile-time-known constant value.
-.. _int_prefetch:
+The return value type of {ref}`llvm.get.dynamic.area.offset <int_get_dynamic_area_offset>`
+must match the target's {ref}`alloca address space <alloca_addrspace>` type.
-'``llvm.prefetch``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_prefetch)=
-Syntax:
-"""""""
+#### '`llvm.prefetch`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.prefetch(ptr <address>, i32 <rw>, i32 <locality>, i32 <cache type>)
+```
+declare void @llvm.prefetch(ptr <address>, i32 <rw>, i32 <locality>, i32 <cache type>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.prefetch``' intrinsic is a hint to the code generator to
+The '`llvm.prefetch`' intrinsic is a hint to the code generator to
insert a prefetch instruction if supported; otherwise, it is a noop.
Prefetches have no effect on the behavior of the program but can change
its performance characteristics.
-Arguments:
-""""""""""
+##### Arguments:
-``address`` is the address to be prefetched, ``rw`` is the specifier
+`address` is the address to be prefetched, `rw` is the specifier
determining if the fetch should be for a read (0) or write (1), and
-``locality`` is a temporal locality specifier ranging from (0) - no
-locality, to (3) - extremely local keep in cache. The ``cache type``
+`locality` is a temporal locality specifier ranging from (0) - no
+locality, to (3) - extremely local keep in cache. The `cache type`
specifies whether the prefetch is performed on the data (1) or
-instruction (0) cache. The ``rw``, ``locality`` and ``cache type``
+instruction (0) cache. The `rw`, `locality` and `cache type`
arguments must be constant integers.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic does not modify the behavior of the program. In
particular, prefetches cannot trap and do not produce a value. On
targets that support this intrinsic, the prefetch can provide hints to
the processor cache for better performance.
-'``llvm.pcmarker``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.pcmarker`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.pcmarker(i32 <id>)
+```
+declare void @llvm.pcmarker(i32 <id>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.pcmarker``' intrinsic is a method to export a Program
+The '`llvm.pcmarker`' intrinsic is a method to export a Program
Counter (PC) in a region of code to simulators and other tools. The
method is target specific, but it is expected that the marker will use
exported symbols to transmit the PC of the marker. The marker makes no
@@ -15853,39 +15172,33 @@ optimizations. It is possible that the presence of a marker will inhibit
optimizations. The intended use is to be inserted after optimizations to
allow correlations of simulation runs.
-Arguments:
-""""""""""
+##### Arguments:
-``id`` is a numerical id identifying the marker.
+`id` is a numerical id identifying the marker.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic does not modify the behavior of the program. Backends
that do not support this intrinsic may ignore it.
-'``llvm.readcyclecounter``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.readcyclecounter`' Intrinsic
-::
+##### Syntax:
- declare i64 @llvm.readcyclecounter()
+```
+declare i64 @llvm.readcyclecounter()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.readcyclecounter``' intrinsic provides access to the cycle
+The '`llvm.readcyclecounter`' intrinsic provides access to the cycle
counter register (or similar low latency, high accuracy clocks) on those
targets that support it. On X86, it should map to RDTSC. On Alpha, it
should map to RPCC. As the backing counters overflow quickly (on the
order of 9 seconds on alpha), this should only be used for small
timings.
-Semantics:
-""""""""""
+##### Semantics:
When directly supported, reading the cycle counter should not modify any
memory. Implementations are allowed to either return an application
@@ -15895,53 +15208,45 @@ is lowered to a constant 0.
Note that runtime support may be conditional on the privilege-level code is
running at and the host platform.
-'``llvm.readsteadycounter``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.readsteadycounter`' Intrinsic
-::
+##### Syntax:
- declare i64 @llvm.readsteadycounter()
+```
+declare i64 @llvm.readsteadycounter()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.readsteadycounter``' intrinsic provides access to the fixed
-frequency clock on targets that support it. Unlike '``llvm.readcyclecounter``',
+The '`llvm.readsteadycounter`' intrinsic provides access to the fixed
+frequency clock on targets that support it. Unlike '`llvm.readcyclecounter`',
this clock is expected to tick at a constant rate, making it suitable for
measuring elapsed time. The actual frequency of the clock is implementation
defined.
-Semantics:
-""""""""""
+##### Semantics:
When directly supported, reading the steady counter should not modify any
memory. Implementations are allowed to either return an application
specific value or a system wide value. On backends without support, this
is lowered to a constant 0.
-'``llvm.clear_cache``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.clear_cache`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.clear_cache(ptr, ptr)
+```
+declare void @llvm.clear_cache(ptr, ptr)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.clear_cache``' intrinsic ensures visibility of modifications
+The '`llvm.clear_cache`' intrinsic ensures visibility of modifications
in the specified range to the execution unit of the processor. On
targets with non-unified instruction and data cache, the implementation
flushes the instruction cache.
-Semantics:
-""""""""""
+##### Semantics:
On platforms with coherent instruction and data caches (e.g., x86), this
intrinsic is a nop. On platforms with non-coherent instruction and data
@@ -15949,33 +15254,29 @@ cache (e.g., ARM, MIPS), the intrinsic is lowered either to appropriate
instructions or a system call, if cache flushing requires special
privileges.
-The default behavior is to emit a call to ``__clear_cache`` from the run
+The default behavior is to emit a call to `__clear_cache` from the run
time library.
This intrinsic does *not* empty the instruction pipeline. Modifications
of the current function are outside the scope of the intrinsic.
-'``llvm.instrprof.increment``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.increment`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.increment(ptr <name>, i64 <hash>,
- i32 <num-counters>, i32 <index>)
+```
+declare void @llvm.instrprof.increment(ptr <name>, i64 <hash>,
+ i32 <num-counters>, i32 <index>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.increment``' intrinsic can be emitted by a
+The '`llvm.instrprof.increment`' intrinsic can be emitted by a
frontend for use with instrumentation-based profiling. These will be
-lowered by the ``-instrprof`` pass to generate execution counts of a
+lowered by the `-instrprof` pass to generate execution counts of a
program at runtime.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to a global variable containing the
name of the entity being instrumented. This should generally be the
@@ -15983,248 +15284,218 @@ name of the entity being instrumented. This should generally be the
The second argument is a hash value that can be used by the consumer
of the profile data to detect changes to the instrumented source, and
-the third is the number of counters associated with ``name``. It is an
-error if ``hash`` or ``num-counters`` differ between two instances of
-``instrprof.increment`` that refer to the same name.
+the third is the number of counters associated with `name`. It is an
+error if `hash` or `num-counters` differ between two instances of
+`instrprof.increment` that refer to the same name.
-The last argument refers to which of the counters for ``name`` should
-be incremented. It should be a value between 0 and ``num-counters``.
+The last argument refers to which of the counters for `name` should
+be incremented. It should be a value between 0 and `num-counters`.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic represents an increment of a profiling counter. It will
-cause the ``-instrprof`` pass to generate the appropriate data
+cause the `-instrprof` pass to generate the appropriate data
structures and the code to increment the appropriate value, in a
format that can be written out by a compiler runtime and consumed via
-the ``llvm-profdata`` tool.
+the `llvm-profdata` tool.
-.. FIXME: write complete doc on contextual instrumentation and link from here
-.. and from llvm.instrprof.callsite.
+% FIXME: write complete doc on contextual instrumentation and link from here
+% and from llvm.instrprof.callsite.
The intrinsic is lowered differently for contextual profiling by the
-``-ctx-instr-lower`` pass. Here:
+`-ctx-instr-lower` pass. Here:
* the entry basic block increment counter is lowered as a call to compiler-rt,
- to either ``__llvm_ctx_profile_start_context`` or
- ``__llvm_ctx_profile_get_context``. Either returns a pointer to a context object
+ to either `__llvm_ctx_profile_start_context` or
+ `__llvm_ctx_profile_get_context`. Either returns a pointer to a context object
which contains a buffer into which counter increments can happen. Note that the
pointer value returned by compiler-rt may have its LSB set - counter increments
happen offset from the address with the LSB cleared.
-* all the other lowerings of ``llvm.instrprof.increment[.step]`` happen within
+* all the other lowerings of `llvm.instrprof.increment[.step]` happen within
that context.
* the context is assumed to be a local value to the function, and no concurrency
concerns need to be handled by LLVM.
-'``llvm.instrprof.increment.step``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.increment.step`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.increment.step(ptr <name>, i64 <hash>,
- i32 <num-counters>,
- i32 <index>, i64 <step>)
+```
+declare void @llvm.instrprof.increment.step(ptr <name>, i64 <hash>,
+ i32 <num-counters>,
+ i32 <index>, i64 <step>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.increment.step``' intrinsic is an extension to
-the '``llvm.instrprof.increment``' intrinsic with an additional fifth
+The '`llvm.instrprof.increment.step`' intrinsic is an extension to
+the '`llvm.instrprof.increment`' intrinsic with an additional fifth
argument to specify the step of the increment.
-Arguments:
-""""""""""
-The first four arguments are the same as '``llvm.instrprof.increment``'
+##### Arguments:
+The first four arguments are the same as '`llvm.instrprof.increment`'
intrinsic.
The last argument specifies the value of the increment of the counter variable.
-Semantics:
-""""""""""
-See description of '``llvm.instrprof.increment``' intrinsic.
+##### Semantics:
+See description of '`llvm.instrprof.increment`' intrinsic.
-'``llvm.instrprof.callsite``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.instrprof.callsite`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.instrprof.callsite(ptr <name>, i64 <hash>,
- i32 <num-counters>,
- i32 <index>, ptr <callsite>)
+```
+declare void @llvm.instrprof.callsite(ptr <name>, i64 <hash>,
+ i32 <num-counters>,
+ i32 <index>, ptr <callsite>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.callsite``' intrinsic should be emitted before a callsite
+The '`llvm.instrprof.callsite`' intrinsic should be emitted before a callsite
that's not to a "fake" callee (like another intrinsic or asm). It is used by
contextual profiling and has side-effects. Its lowering happens in IR, and
target-specific backends should never encounter it.
-Arguments:
-""""""""""
-The first 4 arguments are similar to ``llvm.instrprof.increment``. The indexing
+##### Arguments:
+The first 4 arguments are similar to `llvm.instrprof.increment`. The indexing
is specific to callsites, meaning callsites are indexed from 0, independent from
the indexes used by the other intrinsics (such as
-``llvm.instrprof.increment[.step]``).
+`llvm.instrprof.increment[.step]`).
The last argument is the called value of the callsite this intrinsic precedes.
-Semantics:
-""""""""""
+##### Semantics:
This is lowered by contextual profiling. In contextual profiling, functions get,
from compiler-rt, a pointer to a context object. The context object consists of
a buffer LLVM can use to perform counter increments (i.e., the lowering of
-``llvm.instrprof.increment[.step]``. The address range following the counter
-buffer, ``<num-counters>`` x ``sizeof(ptr)`` - sized, is expected to contain
+`llvm.instrprof.increment[.step]`. The address range following the counter
+buffer, `<num-counters>` x `sizeof(ptr)` - sized, is expected to contain
pointers to contexts of functions called from this function ("subcontexts").
LLVM does not dereference into that memory region, just calculates GEPs.
-The lowering of ``llvm.instrprof.callsite`` consists of:
+The lowering of `llvm.instrprof.callsite` consists of:
-* write to ``__llvm_ctx_profile_expected_callee`` the ``<callsite>`` value;
+* write to `__llvm_ctx_profile_expected_callee` the `<callsite>` value;
-* write to ``__llvm_ctx_profile_callsite`` the address into this function's
- context of the ``<index>`` position into the subcontexts region.
+* write to `__llvm_ctx_profile_callsite` the address into this function's
+ context of the `<index>` position into the subcontexts region.
-``__llvm_ctx_profile_{expected_callee|callsite}`` are initialized by compiler-rt
+`__llvm_ctx_profile_{expected_callee|callsite}` are initialized by compiler-rt
and are TLS. They are both vectors of pointers of size 2. The index into each is
determined when the current function obtains the pointer to its context from
compiler-rt. The pointer's LSB gives the index.
-'``llvm.instrprof.timestamp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.timestamp`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.timestamp(i8* <name>, i64 <hash>,
- i32 <num-counters>, i32 <index>)
+```
+declare void @llvm.instrprof.timestamp(i8* <name>, i64 <hash>,
+ i32 <num-counters>, i32 <index>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.timestamp``' intrinsic is used to implement temporal
+The '`llvm.instrprof.timestamp`' intrinsic is used to implement temporal
profiling.
-Arguments:
-""""""""""
-The arguments are the same as '``llvm.instrprof.increment``'. The ``index`` is
+##### Arguments:
+The arguments are the same as '`llvm.instrprof.increment`'. The `index` is
expected to always be zero.
-Semantics:
-""""""""""
-Similar to the '``llvm.instrprof.increment``' intrinsic, but it stores a
+##### Semantics:
+Similar to the '`llvm.instrprof.increment`' intrinsic, but it stores a
timestamp representing when this function was executed for the first time.
-'``llvm.instrprof.cover``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.cover`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.cover(ptr <name>, i64 <hash>,
- i32 <num-counters>, i32 <index>)
+```
+declare void @llvm.instrprof.cover(ptr <name>, i64 <hash>,
+ i32 <num-counters>, i32 <index>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.cover``' intrinsic is used to implement coverage
+The '`llvm.instrprof.cover`' intrinsic is used to implement coverage
instrumentation.
-Arguments:
-""""""""""
+##### Arguments:
The arguments are the same as the first four arguments of
-'``llvm.instrprof.increment``'.
+'`llvm.instrprof.increment`'.
-Semantics:
-""""""""""
-Similar to the '``llvm.instrprof.increment``' intrinsic, but it stores zero to
+##### Semantics:
+Similar to the '`llvm.instrprof.increment`' intrinsic, but it stores zero to
the profiling variable to signify that the function has been covered. We store
zero because this is more efficient on some targets.
-'``llvm.instrprof.value.profile``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.value.profile`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.value.profile(ptr <name>, i64 <hash>,
- i64 <value>, i32 <value_kind>,
- i32 <index>)
+```
+declare void @llvm.instrprof.value.profile(ptr <name>, i64 <hash>,
+ i64 <value>, i32 <value_kind>,
+ i32 <index>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.value.profile``' intrinsic can be emitted by a
+The '`llvm.instrprof.value.profile`' intrinsic can be emitted by a
frontend for use with instrumentation-based profiling. This will be
-lowered by the ``-instrprof`` pass to find out the target values,
+lowered by the `-instrprof` pass to find out the target values,
instrumented expressions take in a program at runtime.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to a global variable containing the
-name of the entity being instrumented. ``name`` should generally be the
+name of the entity being instrumented. `name` should generally be the
(mangled) function name for a set of counters.
The second argument is a hash value that can be used by the consumer
of the profile data to detect changes to the instrumented source. It
-is an error if ``hash`` differs between two instances of
-``llvm.instrprof.*`` that refer to the same name.
+is an error if `hash` differs between two instances of
+`llvm.instrprof.*` that refer to the same name.
The third argument is the value of the expression being profiled. The profiled
expression's value should be representable as an unsigned 64-bit value. The
fourth argument represents the kind of value profiling that is being done. The
supported value profiling kinds are enumerated through the
-``InstrProfValueKind`` type declared in the
-``<include/llvm/ProfileData/InstrProf.h>`` header file. The last argument is the
-index of the instrumented expression within ``name``. It should be >= 0.
+`InstrProfValueKind` type declared in the
+`<include/llvm/ProfileData/InstrProf.h>` header file. The last argument is the
+index of the instrumented expression within `name`. It should be >= 0.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic represents the point where a call to a runtime routine
-should be inserted for value profiling of target expressions. ``-instrprof``
+should be inserted for value profiling of target expressions. `-instrprof`
pass will generate the appropriate data structures and replace the
-``llvm.instrprof.value.profile`` intrinsic with the call to the profile
+`llvm.instrprof.value.profile` intrinsic with the call to the profile
runtime library with proper arguments.
-'``llvm.instrprof.mcdc.parameters``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.instrprof.mcdc.parameters`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.mcdc.parameters(ptr <name>, i64 <hash>,
- i32 <bitmap-bits>)
+```
+declare void @llvm.instrprof.mcdc.parameters(ptr <name>, i64 <hash>,
+ i32 <bitmap-bits>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.mcdc.parameters``' intrinsic is used to initiate MC/DC
+The '`llvm.instrprof.mcdc.parameters`' intrinsic is used to initiate MC/DC
code coverage instrumentation for a function.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to a global variable containing the
name of the entity being instrumented. This should generally be the
@@ -16236,39 +15507,34 @@ of the profile data to detect changes to the instrumented source.
The third argument is the number of bitmap bits required by the function to
record the number of test vectors executed for each boolean expression.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic represents basic MC/DC parameters initiating one or more MC/DC
-instrumentation sequences in a function. It will cause the ``-instrprof`` pass
+instrumentation sequences in a function. It will cause the `-instrprof` pass
to generate the appropriate data structures and the code to instrument MC/DC
test vectors in a format that can be written out by a compiler runtime and
-consumed via the ``llvm-profdata`` tool.
-
-'``llvm.instrprof.mcdc.tvbitmap.update``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+consumed via the `llvm-profdata` tool.
-Syntax:
-"""""""
+#### '`llvm.instrprof.mcdc.tvbitmap.update`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.instrprof.mcdc.tvbitmap.update(ptr <name>, i64 <hash>,
- i32 <bitmap-index>,
- ptr <mcdc-temp-addr>)
+```
+declare void @llvm.instrprof.mcdc.tvbitmap.update(ptr <name>, i64 <hash>,
+ i32 <bitmap-index>,
+ ptr <mcdc-temp-addr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.instrprof.mcdc.tvbitmap.update``' intrinsic is used to track MC/DC
+The '`llvm.instrprof.mcdc.tvbitmap.update`' intrinsic is used to track MC/DC
test vector execution after each boolean expression has been fully executed.
The overall value of the condition bitmap, after it has been successively
updated with the true or false evaluation of each condition, uniquely identifies
an executed MC/DC test vector and is used as a bit index into the global test
vector bitmap.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to a global variable containing the
name of the entity being instrumented. This should generally be the
@@ -16284,1272 +15550,1127 @@ The fourth argument is the address of the condition bitmap, which contains a
value representing an executed MC/DC test vector. It is loaded and used as the
bit index of the test vector bitmap.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic represents the final operation of an MC/DC instrumentation
-sequence and will cause the ``-instrprof`` pass to generate the code to
+sequence and will cause the `-instrprof` pass to generate the code to
instrument an update of a function's global test vector bitmap to indicate that
a test vector has been executed. The global test vector bitmap can be consumed
-by the ``llvm-profdata`` and ``llvm-cov`` tools.
-
-'``llvm.thread.pointer``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+by the `llvm-profdata` and `llvm-cov` tools.
-Syntax:
-"""""""
+#### '`llvm.thread.pointer`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.thread.pointer.p0()
- declare ptr addrspace(5) @llvm.thread.pointer.p5()
+```
+declare ptr @llvm.thread.pointer.p0()
+declare ptr addrspace(5) @llvm.thread.pointer.p5()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.thread.pointer``' intrinsic returns the value of the thread
+The '`llvm.thread.pointer`' intrinsic returns the value of the thread
pointer.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.thread.pointer``' intrinsic returns a pointer to the TLS area
+The '`llvm.thread.pointer`' intrinsic returns a pointer to the TLS area
for the current thread. The exact semantics of this value are target
specific: it may point to the start of TLS area, to the end, or somewhere
in the middle. Depending on the target, this intrinsic may read a register,
call a helper function, read from an alternate memory space, or perform
other operations necessary to locate the TLS area. Not all targets support
-this intrinsic. The address space must be the :ref:`globals address space
-<globals_addrspace>`.
-
-'``llvm.call.preallocated.setup``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+this intrinsic. The address space must be the {ref}`globals address space <globals_addrspace>`.
-Syntax:
-"""""""
+#### '`llvm.call.preallocated.setup`' Intrinsic
-::
+##### Syntax:
- declare token @llvm.call.preallocated.setup(i32 %num_args)
+```
+declare token @llvm.call.preallocated.setup(i32 %num_args)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.call.preallocated.setup``' intrinsic returns a token which can
-be used with a call's ``"preallocated"`` operand bundle to indicate that
+The '`llvm.call.preallocated.setup`' intrinsic returns a token which can
+be used with a call's `"preallocated"` operand bundle to indicate that
certain arguments are allocated and initialized before the call.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.call.preallocated.setup``' intrinsic returns a token which is
+The '`llvm.call.preallocated.setup`' intrinsic returns a token which is
associated with at most one call. The token can be passed to
-'``@llvm.call.preallocated.arg``' to get a pointer to get that
+'`@llvm.call.preallocated.arg`' to get a pointer to get that
corresponding argument. The token must be the parameter to a
-``"preallocated"`` operand bundle for the corresponding call.
+`"preallocated"` operand bundle for the corresponding call.
-Nested calls to '``llvm.call.preallocated.setup``' are allowed, but must
+Nested calls to '`llvm.call.preallocated.setup`' are allowed, but must
be properly nested. e.g.
-:: code-block:: llvm
-
- %t1 = call token @llvm.call.preallocated.setup(i32 0)
- %t2 = call token @llvm.call.preallocated.setup(i32 0)
- call void foo() ["preallocated"(token %t2)]
- call void foo() ["preallocated"(token %t1)]
+```llvm
+%t1 = call token @llvm.call.preallocated.setup(i32 0)
+%t2 = call token @llvm.call.preallocated.setup(i32 0)
+call void foo() ["preallocated"(token %t2)]
+call void foo() ["preallocated"(token %t1)]
+```
is allowed, but not
-:: code-block:: llvm
-
- %t1 = call token @llvm.call.preallocated.setup(i32 0)
- %t2 = call token @llvm.call.preallocated.setup(i32 0)
- call void foo() ["preallocated"(token %t1)]
- call void foo() ["preallocated"(token %t2)]
-
-.. _int_call_preallocated_arg:
+```llvm
+%t1 = call token @llvm.call.preallocated.setup(i32 0)
+%t2 = call token @llvm.call.preallocated.setup(i32 0)
+call void foo() ["preallocated"(token %t1)]
+call void foo() ["preallocated"(token %t2)]
+```
-'``llvm.call.preallocated.arg``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_call_preallocated_arg)=
-Syntax:
-"""""""
+#### '`llvm.call.preallocated.arg`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.call.preallocated.arg(token %setup_token, i32 %arg_index)
+```
+declare ptr @llvm.call.preallocated.arg(token %setup_token, i32 %arg_index)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.call.preallocated.arg``' intrinsic returns a pointer to the
+The '`llvm.call.preallocated.arg`' intrinsic returns a pointer to the
corresponding preallocated argument for the preallocated call.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.call.preallocated.arg``' intrinsic returns a pointer to the
-``%arg_index``th argument with the ``preallocated`` attribute for
-the call associated with the ``%setup_token``, which must be from
-'``llvm.call.preallocated.setup``'.
+The '`llvm.call.preallocated.arg`' intrinsic returns a pointer to the
+`%arg_index`th argument with the `preallocated` attribute for
+the call associated with the `%setup_token`, which must be from
+'`llvm.call.preallocated.setup`'.
-A call to '``llvm.call.preallocated.arg``' must have a call site
-``preallocated`` attribute. The type of the ``preallocated`` attribute must
-match the type used by the ``preallocated`` attribute of the corresponding
+A call to '`llvm.call.preallocated.arg`' must have a call site
+`preallocated` attribute. The type of the `preallocated` attribute must
+match the type used by the `preallocated` attribute of the corresponding
argument at the preallocated call. The type is used in the case that an
-``llvm.call.preallocated.setup`` does not have a corresponding call (e.g., due
+`llvm.call.preallocated.setup` does not have a corresponding call (e.g., due
to DCE), where otherwise we cannot know how large the arguments are.
It is undefined behavior if this is called with a token from an
-'``llvm.call.preallocated.setup``' if another
-'``llvm.call.preallocated.setup``' has already been called or if the
-preallocated call corresponding to the '``llvm.call.preallocated.setup``'
+'`llvm.call.preallocated.setup`' if another
+'`llvm.call.preallocated.setup`' has already been called or if the
+preallocated call corresponding to the '`llvm.call.preallocated.setup`'
has already been called.
-.. _int_call_preallocated_teardown:
-
-'``llvm.call.preallocated.teardown``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_call_preallocated_teardown)=
-Syntax:
-"""""""
+#### '`llvm.call.preallocated.teardown`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.call.preallocated.teardown(token %setup_token)
+```
+declare ptr @llvm.call.preallocated.teardown(token %setup_token)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.call.preallocated.teardown``' intrinsic cleans up the stack
-created by a '``llvm.call.preallocated.setup``'.
+The '`llvm.call.preallocated.teardown`' intrinsic cleans up the stack
+created by a '`llvm.call.preallocated.setup`'.
-Semantics:
-""""""""""
+##### Semantics:
-The token argument must be a '``llvm.call.preallocated.setup``'.
+The token argument must be a '`llvm.call.preallocated.setup`'.
-The '``llvm.call.preallocated.teardown``' intrinsic cleans up the stack
-allocated by the corresponding '``llvm.call.preallocated.setup``'. Exactly
+The '`llvm.call.preallocated.teardown`' intrinsic cleans up the stack
+allocated by the corresponding '`llvm.call.preallocated.setup`'. Exactly
one of this or the preallocated call must be called to prevent stack leaks.
-It is undefined behavior to call both a '``llvm.call.preallocated.teardown``'
-and the preallocated call for a given '``llvm.call.preallocated.setup``'.
+It is undefined behavior to call both a '`llvm.call.preallocated.teardown`'
+and the preallocated call for a given '`llvm.call.preallocated.setup`'.
For example, if the stack is allocated for a preallocated call by a
-'``llvm.call.preallocated.setup``', then an initializer function called on an
+'`llvm.call.preallocated.setup`', then an initializer function called on an
allocated argument throws an exception, there should be a
-'``llvm.call.preallocated.teardown``' in the exception handler to prevent
+'`llvm.call.preallocated.teardown`' in the exception handler to prevent
stack leaks.
-Following the nesting rules in '``llvm.call.preallocated.setup``', nested
-calls to '``llvm.call.preallocated.setup``' and
-'``llvm.call.preallocated.teardown``' are allowed but must be properly
+Following the nesting rules in '`llvm.call.preallocated.setup`', nested
+calls to '`llvm.call.preallocated.setup`' and
+'`llvm.call.preallocated.teardown`' are allowed but must be properly
nested.
-Example:
-""""""""
-
-.. code-block:: llvm
-
- %cs = call token @llvm.call.preallocated.setup(i32 1)
- %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
- invoke void @constructor(ptr %x) to label %conta unwind label %contb
- conta:
- call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
- ret void
- contb:
- %s = catchswitch within none [label %catch] unwind to caller
- catch:
- %p = catchpad within %s []
- call void @llvm.call.preallocated.teardown(token %cs)
- ret void
-
-Standard C/C++ Library Intrinsics
----------------------------------
+##### Example:
+
+```llvm
+ %cs = call token @llvm.call.preallocated.setup(i32 1)
+ %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
+ invoke void @constructor(ptr %x) to label %conta unwind label %contb
+conta:
+ call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
+ ret void
+contb:
+ %s = catchswitch within none [label %catch] unwind to caller
+catch:
+ %p = catchpad within %s []
+ call void @llvm.call.preallocated.teardown(token %cs)
+ ret void
+```
+
+### Standard C/C++ Library Intrinsics
LLVM provides intrinsics for a few important standard C/C++ library
functions. These intrinsics allow source-language front-ends to pass
information about the alignment of the pointer arguments to the code
generator, providing opportunity for more efficient code generation.
-.. _int_abs:
+(int_abs)=
-'``llvm.abs.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.abs.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.abs`` on any
+This is an overloaded intrinsic. You can use `llvm.abs` on any
integer bit width or any vector of integer elements.
-::
-
- declare i32 @llvm.abs.i32(i32 <src>, i1 <is_int_min_poison>)
- declare <4 x i32> @llvm.abs.v4i32(<4 x i32> <src>, i1 <is_int_min_poison>)
+```
+declare i32 @llvm.abs.i32(i32 <src>, i1 <is_int_min_poison>)
+declare <4 x i32> @llvm.abs.v4i32(<4 x i32> <src>, i1 <is_int_min_poison>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.abs``' family of intrinsic functions returns the absolute value
+The '`llvm.abs`' family of intrinsic functions returns the absolute value
of an argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the value for which the absolute value is to be returned.
This argument may be of any integer type or a vector with integer element type.
The return type must match the first argument type.
The second argument must be a constant and is a flag to indicate whether the
-result value of the '``llvm.abs``' intrinsic is a
-:ref:`poison value <poisonvalues>` if the first argument is statically or
-dynamically an ``INT_MIN`` value.
+result value of the '`llvm.abs`' intrinsic is a
+{ref}`poison value <poisonvalues>` if the first argument is statically or
+dynamically an `INT_MIN` value.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.abs``' intrinsic returns the magnitude (always positive) of the
+The '`llvm.abs`' intrinsic returns the magnitude (always positive) of the
first argument or each element of a vector argument.". If the first argument is
-``INT_MIN``, then the result is also ``INT_MIN`` if ``is_int_min_poison == 0``
-and ``poison`` otherwise.
+`INT_MIN`, then the result is also `INT_MIN` if `is_int_min_poison == 0`
+and `poison` otherwise.
-.. _int_smax:
+(int_smax)=
-'``llvm.smax.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.smax.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.smax`` on any
+This is an overloaded intrinsic. You can use `@llvm.smax` on any
integer bit width or any vector of integer elements.
-::
-
- declare i32 @llvm.smax.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i32 @llvm.smax.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return the larger of ``%a`` and ``%b`` comparing the values as signed integers.
-Vector intrinsics operate on a per-element basis. The larger element of ``%a``
-and ``%b`` at a given index is returned for that index.
+Return the larger of `%a` and `%b` comparing the values as signed integers.
+Vector intrinsics operate on a per-element basis. The larger element of `%a`
+and `%b` at a given index is returned for that index.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
type must match the argument type.
-.. _int_smin:
+(int_smin)=
-'``llvm.smin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.smin.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.smin`` on any
+This is an overloaded intrinsic. You can use `@llvm.smin` on any
integer bit width or any vector of integer elements.
-::
-
- declare i32 @llvm.smin.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.smin.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i32 @llvm.smin.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.smin.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return the smaller of ``%a`` and ``%b`` comparing the values as signed integers.
-Vector intrinsics operate on a per-element basis. The smaller element of ``%a``
-and ``%b`` at a given index is returned for that index.
+Return the smaller of `%a` and `%b` comparing the values as signed integers.
+Vector intrinsics operate on a per-element basis. The smaller element of `%a`
+and `%b` at a given index is returned for that index.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
type must match the argument type.
-.. _int_umax:
+(int_umax)=
-'``llvm.umax.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.umax.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.umax`` on any
+This is an overloaded intrinsic. You can use `@llvm.umax` on any
integer bit width or any vector of integer elements.
-::
-
- declare i32 @llvm.umax.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i32 @llvm.umax.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return the larger of ``%a`` and ``%b`` comparing the values as unsigned
+Return the larger of `%a` and `%b` comparing the values as unsigned
integers. Vector intrinsics operate on a per-element basis. The larger element
-of ``%a`` and ``%b`` at a given index is returned for that index.
+of `%a` and `%b` at a given index is returned for that index.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
type must match the argument type.
-.. _int_umin:
+(int_umin)=
-'``llvm.umin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.umin.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.umin`` on any
+This is an overloaded intrinsic. You can use `@llvm.umin` on any
integer bit width or any vector of integer elements.
-::
-
- declare i32 @llvm.umin.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.umin.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i32 @llvm.umin.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.umin.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return the smaller of ``%a`` and ``%b`` comparing the values as unsigned
+Return the smaller of `%a` and `%b` comparing the values as unsigned
integers. Vector intrinsics operate on a per-element basis. The smaller element
-of ``%a`` and ``%b`` at a given index is returned for that index.
+of `%a` and `%b` at a given index is returned for that index.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
type must match the argument type.
-.. _int_scmp:
+(int_scmp)=
-'``llvm.scmp.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.scmp.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.scmp`` on any
+This is an overloaded intrinsic. You can use `@llvm.scmp` on any
integer bit width or any vector of integer elements.
-::
-
- declare i2 @llvm.scmp.i2.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.scmp.v4i32.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i2 @llvm.scmp.i2.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.scmp.v4i32.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return ``-1`` if ``%a`` is signed less than ``%b``, ``0`` if they are equal, and
-``1`` if ``%a`` is signed greater than ``%b``. Vector intrinsics operate on a per-element basis.
+Return `-1` if `%a` is signed less than `%b`, `0` if they are equal, and
+`1` if `%a` is signed greater than `%b`. Vector intrinsics operate on a per-element basis.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
-type must be at least as wide as ``i2``, to hold the three possible return values.
+type must be at least as wide as `i2`, to hold the three possible return values.
-.. _int_ucmp:
+(int_ucmp)=
-'``llvm.ucmp.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ucmp.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``@llvm.ucmp`` on any
+This is an overloaded intrinsic. You can use `@llvm.ucmp` on any
integer bit width or any vector of integer elements.
-::
-
- declare i2 @llvm.ucmp.i2.i32(i32 %a, i32 %b)
- declare <4 x i32> @llvm.ucmp.v4i32.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i2 @llvm.ucmp.i2.i32(i32 %a, i32 %b)
+declare <4 x i32> @llvm.ucmp.v4i32.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-Return ``-1`` if ``%a`` is unsigned less than ``%b``, ``0`` if they are equal, and
-``1`` if ``%a`` is unsigned greater than ``%b``. Vector intrinsics operate on a per-element basis.
+Return `-1` if `%a` is unsigned less than `%b`, `0` if they are equal, and
+`1` if `%a` is unsigned greater than `%b`. Vector intrinsics operate on a per-element basis.
-Arguments:
-""""""""""
+##### Arguments:
-The arguments (``%a`` and ``%b``) may be of any integer type or a vector with
+The arguments (`%a` and `%b`) may be of any integer type or a vector with
integer element type. The argument types must match each other, and the return
-type must be at least as wide as ``i2``, to hold the three possible return values.
+type must be at least as wide as `i2`, to hold the three possible return values.
-.. _int_memcpy:
+(int_memcpy)=
-'``llvm.memcpy``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memcpy`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memcpy`` on any
+This is an overloaded intrinsic. You can use `llvm.memcpy` on any
integer bit width and for different address spaces. Not all targets
support all bit widths however.
-::
-
- declare void @llvm.memcpy.p0.p0.i32(ptr <dest>, ptr <src>,
- i32 <len>, i1 <isvolatile>)
- declare void @llvm.memcpy.p0.p0.i64(ptr <dest>, ptr <src>,
- i64 <len>, i1 <isvolatile>)
+```
+declare void @llvm.memcpy.p0.p0.i32(ptr <dest>, ptr <src>,
+ i32 <len>, i1 <isvolatile>)
+declare void @llvm.memcpy.p0.p0.i64(ptr <dest>, ptr <src>,
+ i64 <len>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.memcpy.*``' intrinsics copy a block of memory from the
+The '`llvm.memcpy.*`' intrinsics copy a block of memory from the
source location to the destination location.
-Note that, unlike the standard libc function, the ``llvm.memcpy.*``
+Note that, unlike the standard libc function, the `llvm.memcpy.*`
intrinsics do not return a value, takes extra isvolatile
arguments and the pointers can be in specified address spaces.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination, the second is a
pointer to the source. The third argument is an integer argument
specifying the number of bytes to copy, and the fourth is a
boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first and second arguments.
-If the ``isvolatile`` parameter is ``true``, the ``llvm.memcpy`` call is
-a :ref:`volatile operation <volatile>`. The detailed access behavior is not
+If the `isvolatile` parameter is `true`, the `llvm.memcpy` call is
+a {ref}`volatile operation <volatile>`. The detailed access behavior is not
very cleanly specified and it is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memcpy.*``' intrinsics copy a block of memory from the source
+The '`llvm.memcpy.*`' intrinsics copy a block of memory from the source
location to the destination location, which must either be equal or
non-overlapping. It copies "len" bytes of memory over. If the argument is known
to be aligned to some boundary, this can be specified as an attribute on the
argument.
-If ``<len>`` is 0, it is no-op modulo the behavior of attributes attached to
+If `<len>` is 0, it is no-op modulo the behavior of attributes attached to
the arguments.
-If ``<len>`` is not a well-defined value, the behavior is undefined.
-If ``<len>`` is not zero, both ``<dest>`` and ``<src>`` should be well-defined,
+If `<len>` is not a well-defined value, the behavior is undefined.
+If `<len>` is not zero, both `<dest>` and `<src>` should be well-defined,
otherwise the behavior is undefined.
-.. _int_memcpy_inline:
+(int_memcpy_inline)=
-'``llvm.memcpy.inline``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memcpy.inline`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memcpy.inline`` on any
+This is an overloaded intrinsic. You can use `llvm.memcpy.inline` on any
integer bit width and for different address spaces. Not all targets
support all bit widths however.
-::
-
- declare void @llvm.memcpy.inline.p0.p0.i32(ptr <dest>, ptr <src>,
- i32 <len>, i1 <isvolatile>)
- declare void @llvm.memcpy.inline.p0.p0.i64(ptr <dest>, ptr <src>,
- i64 <len>, i1 <isvolatile>)
+```
+declare void @llvm.memcpy.inline.p0.p0.i32(ptr <dest>, ptr <src>,
+ i32 <len>, i1 <isvolatile>)
+declare void @llvm.memcpy.inline.p0.p0.i64(ptr <dest>, ptr <src>,
+ i64 <len>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.memcpy.inline.*``' intrinsics copy a block of memory from the
+The '`llvm.memcpy.inline.*`' intrinsics copy a block of memory from the
source location to the destination location and guarantees that no external
functions are called.
-Note that, unlike the standard libc function, the ``llvm.memcpy.inline.*``
+Note that, unlike the standard libc function, the `llvm.memcpy.inline.*`
intrinsics do not return a value, takes extra isvolatile
arguments and the pointers can be in specified address spaces.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination, the second is a
pointer to the source. The third argument is an integer argument
specifying the number of bytes to copy, and the fourth is a
boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first and second arguments.
-If the ``isvolatile`` parameter is ``true``, the ``llvm.memcpy.inline`` call is
-a :ref:`volatile operation <volatile>`. The detailed access behavior is not
+If the `isvolatile` parameter is `true`, the `llvm.memcpy.inline` call is
+a {ref}`volatile operation <volatile>`. The detailed access behavior is not
very cleanly specified and it is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memcpy.inline.*``' intrinsics copy a block of memory from the
+The '`llvm.memcpy.inline.*`' intrinsics copy a block of memory from the
source location to the destination location, which are not allowed to
overlap. It copies "len" bytes of memory over. If the argument is known
to be aligned to some boundary, this can be specified as an attribute on
the argument.
-The behavior of '``llvm.memcpy.inline.*``' is equivalent to the behavior of
-'``llvm.memcpy.*``', but the generated code is guaranteed not to call any
+The behavior of '`llvm.memcpy.inline.*`' is equivalent to the behavior of
+'`llvm.memcpy.*`', but the generated code is guaranteed not to call any
external functions.
-.. _int_memmove:
+(int_memmove)=
-'``llvm.memmove``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memmove`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memmove`` on any integer
+This is an overloaded intrinsic. You can use `llvm.memmove` on any integer
bit width and for different address space. Not all targets support all
bit widths however.
-::
-
- declare void @llvm.memmove.p0.p0.i32(ptr <dest>, ptr <src>,
- i32 <len>, i1 <isvolatile>)
- declare void @llvm.memmove.p0.p0.i64(ptr <dest>, ptr <src>,
- i64 <len>, i1 <isvolatile>)
+```
+declare void @llvm.memmove.p0.p0.i32(ptr <dest>, ptr <src>,
+ i32 <len>, i1 <isvolatile>)
+declare void @llvm.memmove.p0.p0.i64(ptr <dest>, ptr <src>,
+ i64 <len>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.memmove.*``' intrinsics move a block of memory from the
+The '`llvm.memmove.*`' intrinsics move a block of memory from the
source location to the destination location. It is similar to the
-'``llvm.memcpy``' intrinsic but allows the two memory locations to
+'`llvm.memcpy`' intrinsic but allows the two memory locations to
overlap.
-Note that, unlike the standard libc function, the ``llvm.memmove.*``
+Note that, unlike the standard libc function, the `llvm.memmove.*`
intrinsics do not return a value, takes an extra isvolatile
argument and the pointers can be in specified address spaces.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination, the second is a
pointer to the source. The third argument is an integer argument
specifying the number of bytes to copy, and the fourth is a
boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first and second arguments.
-If the ``isvolatile`` parameter is ``true``, the ``llvm.memmove`` call
-is a :ref:`volatile operation <volatile>`. The detailed access behavior is
+If the `isvolatile` parameter is `true`, the `llvm.memmove` call
+is a {ref}`volatile operation <volatile>`. The detailed access behavior is
not very cleanly specified and it is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memmove.*``' intrinsics copy a block of memory from the
+The '`llvm.memmove.*`' intrinsics copy a block of memory from the
source location to the destination location, which may overlap. It
copies "len" bytes of memory over. If the argument is known to be
aligned to some boundary, this can be specified as an attribute on
the argument.
-If ``<len>`` is 0, it is no-op modulo the behavior of attributes attached to
+If `<len>` is 0, it is no-op modulo the behavior of attributes attached to
the arguments.
-If ``<len>`` is not a well-defined value, the behavior is undefined.
-If ``<len>`` is not zero, both ``<dest>`` and ``<src>`` should be well-defined,
+If `<len>` is not a well-defined value, the behavior is undefined.
+If `<len>` is not zero, both `<dest>` and `<src>` should be well-defined,
otherwise the behavior is undefined.
-.. _int_memset:
+(int_memset)=
-'``llvm.memset.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memset.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memset`` on any integer
+This is an overloaded intrinsic. You can use `llvm.memset` on any integer
bit width and for different address spaces. However, not all targets
support all bit widths.
-::
-
- declare void @llvm.memset.p0.i32(ptr <dest>, i8 <val>,
- i32 <len>, i1 <isvolatile>)
- declare void @llvm.memset.p0.i64(ptr <dest>, i8 <val>,
- i64 <len>, i1 <isvolatile>)
+```
+declare void @llvm.memset.p0.i32(ptr <dest>, i8 <val>,
+ i32 <len>, i1 <isvolatile>)
+declare void @llvm.memset.p0.i64(ptr <dest>, i8 <val>,
+ i64 <len>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.memset.*``' intrinsics fill a block of memory with a
+The '`llvm.memset.*`' intrinsics fill a block of memory with a
particular byte value.
-Note that, unlike the standard libc function, the ``llvm.memset``
+Note that, unlike the standard libc function, the `llvm.memset`
intrinsic does not return a value and takes an extra volatile
argument. Also, the destination can be in an arbitrary address space.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination to fill, the second
is the byte value with which to fill it, the third argument is an
integer argument specifying the number of bytes to fill, and the fourth
is a boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first arguments.
-If the ``isvolatile`` parameter is ``true``, the ``llvm.memset`` call is
-a :ref:`volatile operation <volatile>`. The detailed access behavior is not
+If the `isvolatile` parameter is `true`, the `llvm.memset` call is
+a {ref}`volatile operation <volatile>`. The detailed access behavior is not
very cleanly specified and it is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memset.*``' intrinsics fill "len" bytes of memory starting
+The '`llvm.memset.*`' intrinsics fill "len" bytes of memory starting
at the destination location. If the argument is known to be
aligned to some boundary, this can be specified as an attribute on
the argument.
-If ``<len>`` is 0, it is no-op modulo the behavior of attributes attached to
+If `<len>` is 0, it is no-op modulo the behavior of attributes attached to
the arguments.
-If ``<len>`` is not a well-defined value, the behavior is undefined.
-If ``<len>`` is not zero, ``<dest>`` should be well-defined, otherwise the
+If `<len>` is not a well-defined value, the behavior is undefined.
+If `<len>` is not zero, `<dest>` should be well-defined, otherwise the
behavior is undefined.
-.. _int_memset_inline:
+(int_memset_inline)=
-'``llvm.memset.inline``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memset.inline`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memset.inline`` on any
+This is an overloaded intrinsic. You can use `llvm.memset.inline` on any
integer bit width and for different address spaces. Not all targets
support all bit widths however.
-::
-
- declare void @llvm.memset.inline.p0.i32(ptr <dest>, i8 <val>,
- i32 <len>, i1 <isvolatile>)
- declare void @llvm.memset.inline.p0.i64(ptr <dest>, i8 <val>,
- i64 <len>, i1 <isvolatile>)
+```
+declare void @llvm.memset.inline.p0.i32(ptr <dest>, i8 <val>,
+ i32 <len>, i1 <isvolatile>)
+declare void @llvm.memset.inline.p0.i64(ptr <dest>, i8 <val>,
+ i64 <len>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.memset.inline.*``' intrinsics fill a block of memory with a
+The '`llvm.memset.inline.*`' intrinsics fill a block of memory with a
particular byte value and guarantees that no external functions are called.
-Note that, unlike the standard libc function, the ``llvm.memset.inline.*``
+Note that, unlike the standard libc function, the `llvm.memset.inline.*`
intrinsics do not return a value, take an extra isvolatile argument and the
pointer can be in specified address spaces.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination to fill, the second
is the byte value with which to fill it, the third argument is an
integer argument specifying the number of bytes to fill, and the fourth
is a boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first argument.
-If the ``isvolatile`` parameter is ``true``, the ``llvm.memset.inline`` call is
-a :ref:`volatile operation <volatile>`. The detailed access behavior is not
+If the `isvolatile` parameter is `true`, the `llvm.memset.inline` call is
+a {ref}`volatile operation <volatile>`. The detailed access behavior is not
very cleanly specified and it is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memset.inline.*``' intrinsics fill "len" bytes of memory starting
+The '`llvm.memset.inline.*`' intrinsics fill "len" bytes of memory starting
at the destination location. If the argument is known to be
aligned to some boundary, this can be specified as an attribute on
the argument.
-If ``<len>`` is 0, it is no-op modulo the behavior of attributes attached to
+If `<len>` is 0, it is no-op modulo the behavior of attributes attached to
the arguments.
-If ``<len>`` is not a well-defined value, the behavior is undefined.
-If ``<len>`` is not zero, ``<dest>`` should be well-defined, otherwise the
+If `<len>` is not a well-defined value, the behavior is undefined.
+If `<len>` is not zero, `<dest>` should be well-defined, otherwise the
behavior is undefined.
-The behavior of '``llvm.memset.inline.*``' is equivalent to the behavior of
-'``llvm.memset.*``', but the generated code is guaranteed not to call any
+The behavior of '`llvm.memset.inline.*`' is equivalent to the behavior of
+'`llvm.memset.*`', but the generated code is guaranteed not to call any
external functions.
-.. _int_experimental_memset_pattern:
+(int_experimental_memset_pattern)=
-'``llvm.experimental.memset.pattern``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.memset.pattern`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. You can use
-``llvm.experimental.memset.pattern`` on any sized type and for different
+`llvm.experimental.memset.pattern` on any sized type and for different
address spaces.
-::
-
- declare void @llvm.experimental.memset.pattern.p0.i128.i64(ptr <dest>, i128 <val>,
- i64 <count>, i1 <isvolatile>)
+```
+declare void @llvm.experimental.memset.pattern.p0.i128.i64(ptr <dest>, i128 <val>,
+ i64 <count>, i1 <isvolatile>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.memset.pattern.*``' intrinsics fill a block of memory
+The '`llvm.experimental.memset.pattern.*`' intrinsics fill a block of memory
with a particular value. This may be expanded to an inline loop, a sequence of
stores, or a libcall depending on what is available for the target and the
expected performance and code size impact.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to the destination to fill, the second
is the value with which to fill it, the third argument is an integer
argument specifying the number of times to fill the value, and the fourth is a
boolean indicating a volatile access.
-The :ref:`align <attr_align>` parameter attribute can be provided
+The {ref}`align <attr_align>` parameter attribute can be provided
for the first argument.
-If the ``isvolatile`` parameter is ``true``, the
-``llvm.experimental.memset.pattern`` call is a :ref:`volatile operation
-<volatile>`. The detailed access behavior is not very cleanly specified and it
+If the `isvolatile` parameter is `true`, the
+`llvm.experimental.memset.pattern` call is a {ref}`volatile operation <volatile>`. The detailed access behavior is not very cleanly specified and it
is unwise to depend on it.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.memset.pattern*``' intrinsic fills memory starting at
-the destination location with the given pattern ``<count>`` times,
+The '`llvm.experimental.memset.pattern*`' intrinsic fills memory starting at
+the destination location with the given pattern `<count>` times,
incrementing by the allocation size of the type each time. The stores follow
the usual semantics of store instructions, including regarding endianness and
padding. If the argument is known to be aligned to some boundary, this can be
specified as an attribute on the argument.
-If ``<count>`` is 0, it is no-op modulo the behavior of attributes attached to
+If `<count>` is 0, it is no-op modulo the behavior of attributes attached to
the arguments.
-If ``<count>`` is not a well-defined value, the behavior is undefined.
-If ``<count>`` is not zero, ``<dest>`` should be well-defined, otherwise the
+If `<count>` is not a well-defined value, the behavior is undefined.
+If `<count>` is not zero, `<dest>` should be well-defined, otherwise the
behavior is undefined.
-.. _int_sqrt:
+(int_sqrt)=
-'``llvm.sqrt.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sqrt.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sqrt`` on any
+This is an overloaded intrinsic. You can use `llvm.sqrt` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.sqrt.f32(float %Val)
- declare double @llvm.sqrt.f64(double %Val)
- declare x86_fp80 @llvm.sqrt.f80(x86_fp80 %Val)
- declare fp128 @llvm.sqrt.f128(fp128 %Val)
- declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.sqrt.f32(float %Val)
+declare double @llvm.sqrt.f64(double %Val)
+declare x86_fp80 @llvm.sqrt.f80(x86_fp80 %Val)
+declare fp128 @llvm.sqrt.f128(fp128 %Val)
+declare ppc_fp128 @llvm.sqrt.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sqrt``' intrinsics return the square root of the specified value.
+The '`llvm.sqrt`' intrinsics return the square root of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``sqrt``' function but without
-trapping or setting ``errno``. For types specified by IEEE 754, the result
+Return the same value as a corresponding libm '`sqrt`' function but without
+trapping or setting `errno`. For types specified by IEEE 754, the result
matches a conforming libm implementation.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.powi.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.powi.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.powi`` on any
+This is an overloaded intrinsic. You can use `llvm.powi` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
Generally, the only supported type for the exponent is the one matching
-with the C type ``int``.
-
-::
+with the C type `int`.
- declare float @llvm.powi.f32.i32(float %Val, i32 %power)
- declare double @llvm.powi.f64.i16(double %Val, i16 %power)
- declare x86_fp80 @llvm.powi.f80.i32(x86_fp80 %Val, i32 %power)
- declare fp128 @llvm.powi.f128.i32(fp128 %Val, i32 %power)
- declare ppc_fp128 @llvm.powi.ppcf128.i32(ppc_fp128 %Val, i32 %power)
+```
+declare float @llvm.powi.f32.i32(float %Val, i32 %power)
+declare double @llvm.powi.f64.i16(double %Val, i16 %power)
+declare x86_fp80 @llvm.powi.f80.i32(x86_fp80 %Val, i32 %power)
+declare fp128 @llvm.powi.f128.i32(fp128 %Val, i32 %power)
+declare ppc_fp128 @llvm.powi.ppcf128.i32(ppc_fp128 %Val, i32 %power)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.powi.*``' intrinsics return the first operand raised to the
+The '`llvm.powi.*`' intrinsics return the first operand raised to the
specified (positive or negative) power. The order of evaluation of
multiplications is not defined. When a vector of floating-point type is
used, the second argument remains a scalar integer value.
-Arguments:
-""""""""""
+##### Arguments:
The second argument is an integer power, and the first is a value to
raise to that power.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the first value raised to the second power with an
unspecified sequence of rounding operations.
Note that the `powi` function is unusual in that NaN inputs can lead to non-NaN
results, and this depends on the kind of NaN (quiet vs signaling). Due to how
-:ref:`LLVM treats NaN values <floatnan>` in non-constrained functions, the
+{ref}`LLVM treats NaN values <floatnan>` in non-constrained functions, the
function may non-deterministically treat signaling NaNs as quiet NaNs. For
example, `powi(QNaN, 0)` returns `1.0`, and `powi(SNaN, 0)` may
non-deterministically return `1.0` or a NaN.
-.. _t_llvm_sin:
+(t_llvm_sin)=
-'``llvm.sin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sin.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sin`` on any
+This is an overloaded intrinsic. You can use `llvm.sin` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.sin.f32(float %Val)
- declare double @llvm.sin.f64(double %Val)
- declare x86_fp80 @llvm.sin.f80(x86_fp80 %Val)
- declare fp128 @llvm.sin.f128(fp128 %Val)
- declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.sin.f32(float %Val)
+declare double @llvm.sin.f64(double %Val)
+declare x86_fp80 @llvm.sin.f80(x86_fp80 %Val)
+declare fp128 @llvm.sin.f128(fp128 %Val)
+declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sin.*``' intrinsics return the sine of the operand.
+The '`llvm.sin.*`' intrinsics return the sine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``sin``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`sin`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _t_llvm_cos:
+(t_llvm_cos)=
-'``llvm.cos.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.cos.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.cos`` on any
+This is an overloaded intrinsic. You can use `llvm.cos` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.cos.f32(float %Val)
- declare double @llvm.cos.f64(double %Val)
- declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val)
- declare fp128 @llvm.cos.f128(fp128 %Val)
- declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.cos.f32(float %Val)
+declare double @llvm.cos.f64(double %Val)
+declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val)
+declare fp128 @llvm.cos.f128(fp128 %Val)
+declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.cos.*``' intrinsics return the cosine of the operand.
+The '`llvm.cos.*`' intrinsics return the cosine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``cos``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`cos`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.tan.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.tan.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.tan`` on any
+This is an overloaded intrinsic. You can use `llvm.tan` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.tan.f32(float %Val)
- declare double @llvm.tan.f64(double %Val)
- declare x86_fp80 @llvm.tan.f80(x86_fp80 %Val)
- declare fp128 @llvm.tan.f128(fp128 %Val)
- declare ppc_fp128 @llvm.tan.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.tan.f32(float %Val)
+declare double @llvm.tan.f64(double %Val)
+declare x86_fp80 @llvm.tan.f80(x86_fp80 %Val)
+declare fp128 @llvm.tan.f128(fp128 %Val)
+declare ppc_fp128 @llvm.tan.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.tan.*``' intrinsics return the tangent of the operand.
+The '`llvm.tan.*`' intrinsics return the tangent of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``tan``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`tan`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.asin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.asin.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.asin`` on any
+This is an overloaded intrinsic. You can use `llvm.asin` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.asin.f32(float %Val)
- declare double @llvm.asin.f64(double %Val)
- declare x86_fp80 @llvm.asin.f80(x86_fp80 %Val)
- declare fp128 @llvm.asin.f128(fp128 %Val)
- declare ppc_fp128 @llvm.asin.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.asin.f32(float %Val)
+declare double @llvm.asin.f64(double %Val)
+declare x86_fp80 @llvm.asin.f80(x86_fp80 %Val)
+declare fp128 @llvm.asin.f128(fp128 %Val)
+declare ppc_fp128 @llvm.asin.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.asin.*``' intrinsics return the arcsine of the operand.
+The '`llvm.asin.*`' intrinsics return the arcsine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``asin``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`asin`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.acos.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.acos.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.acos`` on any
+This is an overloaded intrinsic. You can use `llvm.acos` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.acos.f32(float %Val)
- declare double @llvm.acos.f64(double %Val)
- declare x86_fp80 @llvm.acos.f80(x86_fp80 %Val)
- declare fp128 @llvm.acos.f128(fp128 %Val)
- declare ppc_fp128 @llvm.acos.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.acos.f32(float %Val)
+declare double @llvm.acos.f64(double %Val)
+declare x86_fp80 @llvm.acos.f80(x86_fp80 %Val)
+declare fp128 @llvm.acos.f128(fp128 %Val)
+declare ppc_fp128 @llvm.acos.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.acos.*``' intrinsics return the arccosine of the operand.
+The '`llvm.acos.*`' intrinsics return the arccosine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``acos``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`acos`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.atan.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.atan.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.atan`` on any
+This is an overloaded intrinsic. You can use `llvm.atan` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.atan.f32(float %Val)
- declare double @llvm.atan.f64(double %Val)
- declare x86_fp80 @llvm.atan.f80(x86_fp80 %Val)
- declare fp128 @llvm.atan.f128(fp128 %Val)
- declare ppc_fp128 @llvm.atan.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.atan.f32(float %Val)
+declare double @llvm.atan.f64(double %Val)
+declare x86_fp80 @llvm.atan.f80(x86_fp80 %Val)
+declare fp128 @llvm.atan.f128(fp128 %Val)
+declare ppc_fp128 @llvm.atan.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.atan.*``' intrinsics return the arctangent of the operand.
+The '`llvm.atan.*`' intrinsics return the arctangent of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``atan``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`atan`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.atan2.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.atan2.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.atan2`` on any
+This is an overloaded intrinsic. You can use `llvm.atan2` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.atan2.f32(float %Y, float %X)
- declare double @llvm.atan2.f64(double %Y, double %X)
- declare x86_fp80 @llvm.atan2.f80(x86_fp80 %Y, x86_fp80 %X)
- declare fp128 @llvm.atan2.f128(fp128 %Y, fp128 %X)
- declare ppc_fp128 @llvm.atan2.ppcf128(ppc_fp128 %Y, ppc_fp128 %X)
+```
+declare float @llvm.atan2.f32(float %Y, float %X)
+declare double @llvm.atan2.f64(double %Y, double %X)
+declare x86_fp80 @llvm.atan2.f80(x86_fp80 %Y, x86_fp80 %X)
+declare fp128 @llvm.atan2.f128(fp128 %Y, fp128 %X)
+declare ppc_fp128 @llvm.atan2.ppcf128(ppc_fp128 %Y, ppc_fp128 %X)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.atan2.*``' intrinsics return the arctangent of ``Y/X`` accounting
+The '`llvm.atan2.*`' intrinsics return the arctangent of `Y/X` accounting
for the quadrant.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``atan2``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`atan2`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.sinh.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sinh.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sinh`` on any
+This is an overloaded intrinsic. You can use `llvm.sinh` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.sinh.f32(float %Val)
- declare double @llvm.sinh.f64(double %Val)
- declare x86_fp80 @llvm.sinh.f80(x86_fp80 %Val)
- declare fp128 @llvm.sinh.f128(fp128 %Val)
- declare ppc_fp128 @llvm.sinh.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.sinh.f32(float %Val)
+declare double @llvm.sinh.f64(double %Val)
+declare x86_fp80 @llvm.sinh.f80(x86_fp80 %Val)
+declare fp128 @llvm.sinh.f128(fp128 %Val)
+declare ppc_fp128 @llvm.sinh.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sinh.*``' intrinsics return the hyperbolic sine of the operand.
+The '`llvm.sinh.*`' intrinsics return the hyperbolic sine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``sinh``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`sinh`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.cosh.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.cosh.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.cosh`` on any
+This is an overloaded intrinsic. You can use `llvm.cosh` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.cosh.f32(float %Val)
- declare double @llvm.cosh.f64(double %Val)
- declare x86_fp80 @llvm.cosh.f80(x86_fp80 %Val)
- declare fp128 @llvm.cosh.f128(fp128 %Val)
- declare ppc_fp128 @llvm.cosh.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.cosh.f32(float %Val)
+declare double @llvm.cosh.f64(double %Val)
+declare x86_fp80 @llvm.cosh.f80(x86_fp80 %Val)
+declare fp128 @llvm.cosh.f128(fp128 %Val)
+declare ppc_fp128 @llvm.cosh.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.cosh.*``' intrinsics return the hyperbolic cosine of the operand.
+The '`llvm.cosh.*`' intrinsics return the hyperbolic cosine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``cosh``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`cosh`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.tanh.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.tanh.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.tanh`` on any
+This is an overloaded intrinsic. You can use `llvm.tanh` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.tanh.f32(float %Val)
- declare double @llvm.tanh.f64(double %Val)
- declare x86_fp80 @llvm.tanh.f80(x86_fp80 %Val)
- declare fp128 @llvm.tanh.f128(fp128 %Val)
- declare ppc_fp128 @llvm.tanh.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.tanh.f32(float %Val)
+declare double @llvm.tanh.f64(double %Val)
+declare x86_fp80 @llvm.tanh.f80(x86_fp80 %Val)
+declare fp128 @llvm.tanh.f128(fp128 %Val)
+declare ppc_fp128 @llvm.tanh.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.tanh.*``' intrinsics return the hyperbolic tangent of the operand.
+The '`llvm.tanh.*`' intrinsics return the hyperbolic tangent of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``tanh``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`tanh`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.sincos.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sincos.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sincos`` on any
+This is an overloaded intrinsic. You can use `llvm.sincos` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare { float, float } @llvm.sincos.f32(float %Val)
- declare { double, double } @llvm.sincos.f64(double %Val)
- declare { x86_fp80, x86_fp80 } @llvm.sincos.f80(x86_fp80 %Val)
- declare { fp128, fp128 } @llvm.sincos.f128(fp128 %Val)
- declare { ppc_fp128, ppc_fp128 } @llvm.sincos.ppcf128(ppc_fp128 %Val)
- declare { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> %Val)
+```
+declare { float, float } @llvm.sincos.f32(float %Val)
+declare { double, double } @llvm.sincos.f64(double %Val)
+declare { x86_fp80, x86_fp80 } @llvm.sincos.f80(x86_fp80 %Val)
+declare { fp128, fp128 } @llvm.sincos.f128(fp128 %Val)
+declare { ppc_fp128, ppc_fp128 } @llvm.sincos.ppcf128(ppc_fp128 %Val)
+declare { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float> %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sincos.*``' intrinsics returns the sine and cosine of the operand.
+The '`llvm.sincos.*`' intrinsics returns the sine and cosine of the operand.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is a :ref:`floating-point <t_floating>` value or
-:ref:`vector <t_vector>` of floating-point values. Returns two values matching
+The argument is a {ref}`floating-point <t_floating>` value or
+{ref}`vector <t_vector>` of floating-point values. Returns two values matching
the argument type in a struct.
-Semantics:
-""""""""""
+##### Semantics:
-This intrinsic is equivalent to a calling both :ref:`llvm.sin <t_llvm_sin>`
-and :ref:`llvm.cos <t_llvm_cos>` on the argument.
+This intrinsic is equivalent to a calling both {ref}`llvm.sin <t_llvm_sin>`
+and {ref}`llvm.cos <t_llvm_cos>` on the argument.
The first result is the sine of the argument and the second result is the cosine
of the argument.
@@ -17557,99 +16678,89 @@ of the argument.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.sincospi.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sincospi.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sincospi`` on any
+This is an overloaded intrinsic. You can use `llvm.sincospi` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare { float, float } @llvm.sincospi.f32(float %Val)
- declare { double, double } @llvm.sincospi.f64(double %Val)
- declare { x86_fp80, x86_fp80 } @llvm.sincospi.f80(x86_fp80 %Val)
- declare { fp128, fp128 } @llvm.sincospi.f128(fp128 %Val)
- declare { ppc_fp128, ppc_fp128 } @llvm.sincospi.ppcf128(ppc_fp128 %Val)
- declare { <4 x float>, <4 x float> } @llvm.sincospi.v4f32(<4 x float> %Val)
+```
+declare { float, float } @llvm.sincospi.f32(float %Val)
+declare { double, double } @llvm.sincospi.f64(double %Val)
+declare { x86_fp80, x86_fp80 } @llvm.sincospi.f80(x86_fp80 %Val)
+declare { fp128, fp128 } @llvm.sincospi.f128(fp128 %Val)
+declare { ppc_fp128, ppc_fp128 } @llvm.sincospi.ppcf128(ppc_fp128 %Val)
+declare { <4 x float>, <4 x float> } @llvm.sincospi.v4f32(<4 x float> %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sincospi.*``' intrinsics returns the sine and cosine of pi*operand.
+The '`llvm.sincospi.*`' intrinsics returns the sine and cosine of pi*operand.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is a :ref:`floating-point <t_floating>` value or
-:ref:`vector <t_vector>` of floating-point values. Returns two values matching
+The argument is a {ref}`floating-point <t_floating>` value or
+{ref}`vector <t_vector>` of floating-point values. Returns two values matching
the argument type in a struct.
-Semantics:
-""""""""""
+##### Semantics:
-This is equivalent to the ``llvm.sincos.*`` intrinsic where the argument has been
+This is equivalent to the `llvm.sincos.*` intrinsic where the argument has been
multiplied by pi, however, it computes the result more accurately especially
for large input values.
-.. note::
-
- Currently, the default lowering of this intrinsic relies on the ``sincospi[f|l]``
- functions being available in the target's runtime (e.g., libc).
+```{note}
+Currently, the default lowering of this intrinsic relies on the `sincospi[f|l]`
+functions being available in the target's runtime (e.g., libc).
+```
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.modf.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.modf.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.modf`` on any floating-point
+This is an overloaded intrinsic. You can use `llvm.modf` on any floating-point
or vector of floating-point type. However, not all targets support all types.
-::
+```
+declare { float, float } @llvm.modf.f32(float %Val)
+declare { double, double } @llvm.modf.f64(double %Val)
+declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80 %Val)
+declare { fp128, fp128 } @llvm.modf.f128(fp128 %Val)
+declare { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %Val)
+declare { <4 x float>, <4 x float> } @llvm.modf.v4f32(<4 x float> %Val)
+```
- declare { float, float } @llvm.modf.f32(float %Val)
- declare { double, double } @llvm.modf.f64(double %Val)
- declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80 %Val)
- declare { fp128, fp128 } @llvm.modf.f128(fp128 %Val)
- declare { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %Val)
- declare { <4 x float>, <4 x float> } @llvm.modf.v4f32(<4 x float> %Val)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.modf.*``' intrinsics return the operand's integral and fractional
+The '`llvm.modf.*`' intrinsics return the operand's integral and fractional
parts.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is a :ref:`floating-point <t_floating>` value or
-:ref:`vector <t_vector>` of floating-point values. Returns two values matching
+The argument is a {ref}`floating-point <t_floating>` value or
+{ref}`vector <t_vector>` of floating-point values. Returns two values matching
the argument type in a struct.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same values as a corresponding libm '``modf``' function without
-trapping or setting ``errno``.
+Return the same values as a corresponding libm '`modf`' function without
+trapping or setting `errno`.
The first result is the fractional part of the operand and the second result is
the integral part of the operand. Both results have the same sign as the operand.
-Not including exceptional inputs (listed below), ``llvm.modf.*`` is semantically
+Not including exceptional inputs (listed below), `llvm.modf.*` is semantically
equivalent to:
-::
-
- %fp = frem <fptype> %x, 1.0 ; Fractional part
- %ip = fsub <fptype> %x, %fp ; Integral part
+```
+%fp = frem <fptype> %x, 1.0 ; Fractional part
+%ip = fsub <fptype> %x, %fp ; Integral part
+```
(assuming no floating-point precision errors)
@@ -17662,206 +16773,180 @@ sign, and infinity with the same sign as the integral part.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.pow.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.pow.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.pow`` on any
+This is an overloaded intrinsic. You can use `llvm.pow` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.pow.f32(float %Val, float %Power)
- declare double @llvm.pow.f64(double %Val, double %Power)
- declare x86_fp80 @llvm.pow.f80(x86_fp80 %Val, x86_fp80 %Power)
- declare fp128 @llvm.pow.f128(fp128 %Val, fp128 %Power)
- declare ppc_fp128 @llvm.pow.ppcf128(ppc_fp128 %Val, ppc_fp128 Power)
+```
+declare float @llvm.pow.f32(float %Val, float %Power)
+declare double @llvm.pow.f64(double %Val, double %Power)
+declare x86_fp80 @llvm.pow.f80(x86_fp80 %Val, x86_fp80 %Power)
+declare fp128 @llvm.pow.f128(fp128 %Val, fp128 %Power)
+declare ppc_fp128 @llvm.pow.ppcf128(ppc_fp128 %Val, ppc_fp128 Power)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.pow.*``' intrinsics return the first operand raised to the
+The '`llvm.pow.*`' intrinsics return the first operand raised to the
specified (positive or negative) power.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``pow``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`pow`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
Note that the `pow` function is unusual in that NaN inputs can lead to non-NaN
results, and this depends on the kind of NaN (quiet vs signaling). Due to how
-:ref:`LLVM treats NaN values <floatnan>` in non-constrained functions, the
+{ref}`LLVM treats NaN values <floatnan>` in non-constrained functions, the
function may non-deterministically treat signaling NaNs as quiet NaNs. For
example, `pow(QNaN, 0.0)` returns `1.0`, and `pow(SNaN, 0.0)` may
non-deterministically return `1.0` or a NaN.
-.. _int_exp:
+(int_exp)=
-'``llvm.exp.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.exp.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.exp`` on any
+This is an overloaded intrinsic. You can use `llvm.exp` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.exp.f32(float %Val)
- declare double @llvm.exp.f64(double %Val)
- declare x86_fp80 @llvm.exp.f80(x86_fp80 %Val)
- declare fp128 @llvm.exp.f128(fp128 %Val)
- declare ppc_fp128 @llvm.exp.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.exp.f32(float %Val)
+declare double @llvm.exp.f64(double %Val)
+declare x86_fp80 @llvm.exp.f80(x86_fp80 %Val)
+declare fp128 @llvm.exp.f128(fp128 %Val)
+declare ppc_fp128 @llvm.exp.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.exp.*``' intrinsics compute the base-e exponential of the specified
+The '`llvm.exp.*`' intrinsics compute the base-e exponential of the specified
value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``exp``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`exp`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_exp2:
+(int_exp2)=
-'``llvm.exp2.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.exp2.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.exp2`` on any
+This is an overloaded intrinsic. You can use `llvm.exp2` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.exp2.f32(float %Val)
- declare double @llvm.exp2.f64(double %Val)
- declare x86_fp80 @llvm.exp2.f80(x86_fp80 %Val)
- declare fp128 @llvm.exp2.f128(fp128 %Val)
- declare ppc_fp128 @llvm.exp2.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.exp2.f32(float %Val)
+declare double @llvm.exp2.f64(double %Val)
+declare x86_fp80 @llvm.exp2.f80(x86_fp80 %Val)
+declare fp128 @llvm.exp2.f128(fp128 %Val)
+declare ppc_fp128 @llvm.exp2.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.exp2.*``' intrinsics compute the base-2 exponential of the
+The '`llvm.exp2.*`' intrinsics compute the base-2 exponential of the
specified value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``exp2``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`exp2`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_exp10:
+(int_exp10)=
-'``llvm.exp10.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.exp10.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.exp10`` on any
+This is an overloaded intrinsic. You can use `llvm.exp10` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.exp10.f32(float %Val)
- declare double @llvm.exp10.f64(double %Val)
- declare x86_fp80 @llvm.exp10.f80(x86_fp80 %Val)
- declare fp128 @llvm.exp10.f128(fp128 %Val)
- declare ppc_fp128 @llvm.exp10.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.exp10.f32(float %Val)
+declare double @llvm.exp10.f64(double %Val)
+declare x86_fp80 @llvm.exp10.f80(x86_fp80 %Val)
+declare fp128 @llvm.exp10.f128(fp128 %Val)
+declare ppc_fp128 @llvm.exp10.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.exp10.*``' intrinsics compute the base-10 exponential of the
+The '`llvm.exp10.*`' intrinsics compute the base-10 exponential of the
specified value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``exp10``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`exp10`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-'``llvm.ldexp.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ldexp.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.ldexp`` on any
+This is an overloaded intrinsic. You can use `llvm.ldexp` on any
floating point or vector of floating point type. Not all targets support
all types however.
-::
-
- declare float @llvm.ldexp.f32.i32(float %Val, i32 %Exp)
- declare double @llvm.ldexp.f64.i32(double %Val, i32 %Exp)
- declare x86_fp80 @llvm.ldexp.f80.i32(x86_fp80 %Val, i32 %Exp)
- declare fp128 @llvm.ldexp.f128.i32(fp128 %Val, i32 %Exp)
- declare ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 %Val, i32 %Exp)
- declare <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float> %Val, <2 x i32> %Exp)
+```
+declare float @llvm.ldexp.f32.i32(float %Val, i32 %Exp)
+declare double @llvm.ldexp.f64.i32(double %Val, i32 %Exp)
+declare x86_fp80 @llvm.ldexp.f80.i32(x86_fp80 %Val, i32 %Exp)
+declare fp128 @llvm.ldexp.f128.i32(fp128 %Val, i32 %Exp)
+declare ppc_fp128 @llvm.ldexp.ppcf128.i32(ppc_fp128 %Val, i32 %Exp)
+declare <2 x float> @llvm.ldexp.v2f32.v2i32(<2 x float> %Val, <2 x i32> %Exp)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ldexp.*``' intrinsics perform the ldexp function.
+The '`llvm.ldexp.*`' intrinsics perform the ldexp function.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument and the return value are :ref:`floating-point
-<t_floating>` or :ref:`vector <t_vector>` of floating-point values of
+The first argument and the return value are {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of floating-point values of
the same type. The second argument is an integer with the same number
of elements.
-Semantics:
-""""""""""
+##### Semantics:
This function multiplies the first argument by 2 raised to the second
argument's power. If the first argument is NaN or infinite, the same
@@ -17869,43 +16954,38 @@ value is returned. If the result underflows a zero with the same sign
is returned. If the result overflows, the result is an infinity with
the same sign.
-.. _int_frexp:
+(int_frexp)=
-'``llvm.frexp.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.frexp.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.frexp`` on any
+This is an overloaded intrinsic. You can use `llvm.frexp` on any
floating point or vector of floating point type. Not all targets support
all types however.
-::
-
- declare { float, i32 } @llvm.frexp.f32.i32(float %Val)
- declare { double, i32 } @llvm.frexp.f64.i32(double %Val)
- declare { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80 %Val)
- declare { fp128, i32 } @llvm.frexp.f128.i32(fp128 %Val)
- declare { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 %Val)
- declare { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> %Val)
+```
+declare { float, i32 } @llvm.frexp.f32.i32(float %Val)
+declare { double, i32 } @llvm.frexp.f64.i32(double %Val)
+declare { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80 %Val)
+declare { fp128, i32 } @llvm.frexp.f128.i32(fp128 %Val)
+declare { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 %Val)
+declare { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.frexp.*``' intrinsics perform the frexp function.
+The '`llvm.frexp.*`' intrinsics perform the frexp function.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is a :ref:`floating-point <t_floating>` or
-:ref:`vector <t_vector>` of floating-point values. Returns two values
+The argument is a {ref}`floating-point <t_floating>` or
+{ref}`vector <t_vector>` of floating-point values. Returns two values
in a struct. The first struct field matches the argument type, and the
second field is an integer or a vector of integer values with the same
number of elements as the argument.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic splits a floating point value into a normalized
fractional component and integral exponent.
@@ -17925,286 +17005,255 @@ is unspecified.
If the argument is an infinity, returns an infinity with the same sign
and an unspecified exponent.
-.. _int_log:
+(int_log)=
-'``llvm.log.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.log.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.log`` on any
+This is an overloaded intrinsic. You can use `llvm.log` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.log.f32(float %Val)
- declare double @llvm.log.f64(double %Val)
- declare x86_fp80 @llvm.log.f80(x86_fp80 %Val)
- declare fp128 @llvm.log.f128(fp128 %Val)
- declare ppc_fp128 @llvm.log.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.log.f32(float %Val)
+declare double @llvm.log.f64(double %Val)
+declare x86_fp80 @llvm.log.f80(x86_fp80 %Val)
+declare fp128 @llvm.log.f128(fp128 %Val)
+declare ppc_fp128 @llvm.log.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.log.*``' intrinsics compute the base-e logarithm of the specified
+The '`llvm.log.*`' intrinsics compute the base-e logarithm of the specified
value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``log``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`log`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_log10:
+(int_log10)=
-'``llvm.log10.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.log10.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.log10`` on any
+This is an overloaded intrinsic. You can use `llvm.log10` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.log10.f32(float %Val)
- declare double @llvm.log10.f64(double %Val)
- declare x86_fp80 @llvm.log10.f80(x86_fp80 %Val)
- declare fp128 @llvm.log10.f128(fp128 %Val)
- declare ppc_fp128 @llvm.log10.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.log10.f32(float %Val)
+declare double @llvm.log10.f64(double %Val)
+declare x86_fp80 @llvm.log10.f80(x86_fp80 %Val)
+declare fp128 @llvm.log10.f128(fp128 %Val)
+declare ppc_fp128 @llvm.log10.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.log10.*``' intrinsics compute the base-10 logarithm of the
+The '`llvm.log10.*`' intrinsics compute the base-10 logarithm of the
specified value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``log10``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`log10`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_log2:
+(int_log2)=
-'``llvm.log2.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.log2.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.log2`` on any
+This is an overloaded intrinsic. You can use `llvm.log2` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.log2.f32(float %Val)
- declare double @llvm.log2.f64(double %Val)
- declare x86_fp80 @llvm.log2.f80(x86_fp80 %Val)
- declare fp128 @llvm.log2.f128(fp128 %Val)
- declare ppc_fp128 @llvm.log2.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.log2.f32(float %Val)
+declare double @llvm.log2.f64(double %Val)
+declare x86_fp80 @llvm.log2.f80(x86_fp80 %Val)
+declare fp128 @llvm.log2.f128(fp128 %Val)
+declare ppc_fp128 @llvm.log2.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.log2.*``' intrinsics compute the base-2 logarithm of the specified
+The '`llvm.log2.*`' intrinsics compute the base-2 logarithm of the specified
value.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-Return the same value as a corresponding libm '``log2``' function but without
-trapping or setting ``errno``.
+Return the same value as a corresponding libm '`log2`' function but without
+trapping or setting `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_fma:
+(int_fma)=
-'``llvm.fma.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fma.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fma`` on any
+This is an overloaded intrinsic. You can use `llvm.fma` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.fma.f32(float %a, float %b, float %c)
- declare double @llvm.fma.f64(double %a, double %b, double %c)
- declare x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c)
- declare fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c)
- declare ppc_fp128 @llvm.fma.ppcf128(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c)
+```
+declare float @llvm.fma.f32(float %a, float %b, float %c)
+declare double @llvm.fma.f64(double %a, double %b, double %c)
+declare x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c)
+declare fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c)
+declare ppc_fp128 @llvm.fma.ppcf128(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fma.*``' intrinsics perform the fused multiply-add operation.
+The '`llvm.fma.*`' intrinsics perform the fused multiply-add operation.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
Return the same value as the IEEE 754 fusedMultiplyAdd operation. This
-is assumed to not trap or set ``errno``.
+is assumed to not trap or set `errno`.
When specified with the fast-math-flag 'afn', the result may be approximated
using a less accurate calculation.
-.. _int_fabs:
+(int_fabs)=
-'``llvm.fabs.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fabs.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fabs`` on any
+This is an overloaded intrinsic. You can use `llvm.fabs` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.fabs.f32(float %Val)
- declare double @llvm.fabs.f64(double %Val)
- declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val)
- declare fp128 @llvm.fabs.f128(fp128 %Val)
- declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.fabs.f32(float %Val)
+declare double @llvm.fabs.f64(double %Val)
+declare x86_fp80 @llvm.fabs.f80(x86_fp80 %Val)
+declare fp128 @llvm.fabs.f128(fp128 %Val)
+declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fabs.*``' intrinsics return the absolute value of the
+The '`llvm.fabs.*`' intrinsics return the absolute value of the
operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``fabs`` functions
+This function returns the same values as the libm `fabs` functions
would, and handles error conditions in the same way.
The returned value is completely identical to the input except for the sign bit;
in particular, if the input is a NaN, then the quiet/signaling bit and payload
are perfectly preserved.
-.. _i_fminmax_family:
+(i_fminmax_family)=
-Floating-point min/max intrinsics comparison
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### Floating-point min/max intrinsics comparison
LLVM supports three pairs of floating-point min/max intrinsics, which differ
-in their handling of :ref:`NaN values <floatnan>`:
+in their handling of {ref}`NaN values <floatnan>`:
- * ``llvm.minimum`` and ``llvm.maximum``: Return NaN if one the arguments is
+ * `llvm.minimum` and `llvm.maximum`: Return NaN if one the arguments is
NaN.
- * ``llvm.minimumnum`` and ``llvm.maximumnum``: Return the other argument if
+ * `llvm.minimumnum` and `llvm.maximumnum`: Return the other argument if
one of the arguments is NaN.
- * ``llvm.minnum`` and ``llvm.maxnum``: For quiet NaNs behaves like
+ * `llvm.minnum` and `llvm.maxnum`: For quiet NaNs behaves like
minimumnum/maximumnum. For signaling NaNs, non-deterministically returns
NaN or the other operand.
Additionally, each of these intrinsics supports two behaviors for signed zeros.
-By default, -0.0 is considered smaller than +0.0. If the ``nsz`` flag is
+By default, -0.0 is considered smaller than +0.0. If the `nsz` flag is
specified, the order is non-deterministic: If the two inputs are zeros with
opposite sign, either input may be returned.
The mapping between the LLVM intrinsics, C functions and IEEE 754 functions is
as follows (up to divergences permitted by the usual `NaN rules <floatnan>`):
-.. list-table::
- :header-rows: 1
-
- * - LLVM intrinsic
- - llvm.minnum with nsz flag
- - llvm.minimum
- - llvm.minimumnum
+```{list-table}
+:header-rows: 1
+* - LLVM intrinsic
+ - llvm.minnum with nsz flag
+ - llvm.minimum
+ - llvm.minimumnum
- * - C function
- - fmin
- - fminimum
- - fminimum_num
+* - C function
+ - fmin
+ - fminimum
+ - fminimum_num
- * - IEEE 754 function
- - minNum (2008)
- - minimum (2019)
- - minimumNumber (2019)
+* - IEEE 754 function
+ - minNum (2008)
+ - minimum (2019)
+ - minimumNumber (2019)
+```
-.. _i_minnum:
+(i_minnum)=
-'``llvm.minnum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.minnum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.minnum`` on any
+This is an overloaded intrinsic. You can use `llvm.minnum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.minnum.f32(float %Val0, float %Val1)
- declare double @llvm.minnum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.minnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.minnum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.minnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
+declare float @llvm.minnum.f32(float %Val0, float %Val1)
+declare double @llvm.minnum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.minnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.minnum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.minnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.minnum.*``' intrinsics return the minimum of the two
+The '`llvm.minnum.*`' intrinsics return the minimum of the two
arguments.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-If both operands are qNaNs, returns a :ref:`NaN <floatnan>`. If one operand is
+If both operands are qNaNs, returns a {ref}`NaN <floatnan>`. If one operand is
qNaN and another operand is a number, returns the number. If both operands are
numbers, returns the lesser of the two arguments. -0.0 is considered to be less
than +0.0 for this intrinsic.
@@ -18212,65 +17261,59 @@ than +0.0 for this intrinsic.
If an operand is a signaling NaN, then the intrinsic will non-deterministically
either:
- * Return a :ref:`NaN <floatnan>`.
+ * Return a {ref}`NaN <floatnan>`.
* Or treat the signaling NaN as a quiet NaN.
-If the ``nsz`` flag is specified, ``llvm.minnum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.minnum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-When used with the ``nsz`` flag, this intrinsic follows the semantics of
-``fmin`` in C and ``minNum`` in IEEE 754-2008, except for signaling NaN inputs,
-which follow :ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+When used with the `nsz` flag, this intrinsic follows the semantics of
+`fmin` in C and `minNum` in IEEE 754-2008, except for signaling NaN inputs,
+which follow {ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-The ``llvm.minnum`` intrinsic can be refined into ``llvm.minimumnum``, as the
+The `llvm.minnum` intrinsic can be refined into `llvm.minimumnum`, as the
latter exhibits a subset of behaviors of the former.
-.. warning::
+```{warning}
+If the intrinsic is used without nsz, not all backends currently respect the
+specified signed zero ordering. Do not rely on it until this warning has
+been removed. See [issue #174730](https://github.com/llvm/llvm-project/issues/174730).
+```
- If the intrinsic is used without nsz, not all backends currently respect the
- specified signed zero ordering. Do not rely on it until this warning has
- been removed. See `issue #174730
- <https://github.com/llvm/llvm-project/issues/174730>`_.
+(i_maxnum)=
-.. _i_maxnum:
+#### '`llvm.maxnum.*`' Intrinsic
-'``llvm.maxnum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.maxnum`` on any
+This is an overloaded intrinsic. You can use `llvm.maxnum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
+```
+declare float @llvm.maxnum.f32(float %Val0, float %Val1)
+declare double @llvm.maxnum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.maxnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.maxnum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.maxnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
- declare float @llvm.maxnum.f32(float %Val0, float %Val1)
- declare double @llvm.maxnum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.maxnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.maxnum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.maxnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.maxnum.*``' intrinsics return the maximum of the two
+The '`llvm.maxnum.*`' intrinsics return the maximum of the two
arguments.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-If both operands are qNaNs, returns a :ref:`NaN <floatnan>`. If one operand is
+If both operands are qNaNs, returns a {ref}`NaN <floatnan>`. If one operand is
qNaN and another operand is a number, returns the number. If both operands are
numbers, returns the greater of the two arguments. -0.0 is considered to be
less than +0.0 for this intrinsic.
@@ -18278,859 +17321,760 @@ less than +0.0 for this intrinsic.
If an operand is a signaling NaN, then the intrinsic will non-deterministically
either:
- * Return a :ref:`NaN <floatnan>`.
+ * Return a {ref}`NaN <floatnan>`.
* Or treat the signaling NaN as a quiet NaN.
-If the ``nsz`` flag is specified, ``llvm.maxnum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.maxnum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-When used with the ``nsz`` flag, this intrinsic follows the semantics of
-``fmax`` in C and ``maxNum`` in IEEE 754-2008, except for signaling NaN inputs,
-which follow :ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+When used with the `nsz` flag, this intrinsic follows the semantics of
+`fmax` in C and `maxNum` in IEEE 754-2008, except for signaling NaN inputs,
+which follow {ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-The ``llvm.maxnum`` intrinsic can be refined into ``llvm.maximumnum``, as the
+The `llvm.maxnum` intrinsic can be refined into `llvm.maximumnum`, as the
latter exhibits a subset of behaviors of the former.
-.. warning::
-
- If the intrinsic is used without nsz, not all backends currently respect the
- specified signed zero ordering. Do not rely on it until this warning has
- been removed. See `issue #174730
- <https://github.com/llvm/llvm-project/issues/174730>`_.
+```{warning}
+If the intrinsic is used without nsz, not all backends currently respect the
+specified signed zero ordering. Do not rely on it until this warning has
+been removed. See [issue #174730](https://github.com/llvm/llvm-project/issues/174730).
+```
-.. _i_minimum:
+(i_minimum)=
-'``llvm.minimum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.minimum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.minimum`` on any
+This is an overloaded intrinsic. You can use `llvm.minimum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.minimum.f32(float %Val0, float %Val1)
- declare double @llvm.minimum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.minimum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.minimum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.minimum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
+declare float @llvm.minimum.f32(float %Val0, float %Val1)
+declare double @llvm.minimum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.minimum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.minimum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.minimum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.minimum.*``' intrinsics return the minimum of the two
+The '`llvm.minimum.*`' intrinsics return the minimum of the two
arguments, propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
-If either operand is a NaN, returns a :ref:`NaN <floatnan>`. Otherwise returns
+##### Semantics:
+If either operand is a NaN, returns a {ref}`NaN <floatnan>`. Otherwise returns
the lesser of the two arguments. -0.0 is considered to be less than +0.0 for
this intrinsic.
-This intrinsic follows the semantics of ``fminimum`` in C23 and ``minimum`` in
+This intrinsic follows the semantics of `fminimum` in C23 and `minimum` in
IEEE 754-2019, except for signaling NaN inputs, which follow
-:ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+{ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-If the ``nsz`` flag is specified, ``llvm.maximum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.maximum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-.. _i_maximum:
+(i_maximum)=
-'``llvm.maximum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.maximum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.maximum`` on any
+This is an overloaded intrinsic. You can use `llvm.maximum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.maximum.f32(float %Val0, float %Val1)
- declare double @llvm.maximum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.maximum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.maximum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.maximum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
+declare float @llvm.maximum.f32(float %Val0, float %Val1)
+declare double @llvm.maximum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.maximum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.maximum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.maximum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.maximum.*``' intrinsics return the maximum of the two
+The '`llvm.maximum.*`' intrinsics return the maximum of the two
arguments, propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
-If either operand is a NaN, returns a :ref:`NaN <floatnan>`. Otherwise returns
+##### Semantics:
+If either operand is a NaN, returns a {ref}`NaN <floatnan>`. Otherwise returns
the greater of the two arguments. -0.0 is considered to be less than +0.0 for
this intrinsic.
-This intrinsic follows the semantics of ``fmaximum`` in C23 and ``maximum`` in
+This intrinsic follows the semantics of `fmaximum` in C23 and `maximum` in
IEEE 754-2019, except for signaling NaN inputs, which follow
-:ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+{ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-If the ``nsz`` flag is specified, ``llvm.maximum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.maximum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-.. _i_minimumnum:
+(i_minimumnum)=
-'``llvm.minimumnum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.minimumnum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.minimumnum`` on any
+This is an overloaded intrinsic. You can use `llvm.minimumnum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.minimumnum.f32(float %Val0, float %Val1)
- declare double @llvm.minimumnum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.minimumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.minimumnum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.minimumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
+declare float @llvm.minimumnum.f32(float %Val0, float %Val1)
+declare double @llvm.minimumnum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.minimumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.minimumnum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.minimumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.minimumnum.*``' intrinsics return the minimum of the two
+The '`llvm.minimumnum.*`' intrinsics return the minimum of the two
arguments, not propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-If both operands are NaNs (including sNaN), returns a :ref:`NaN <floatnan>`. If
+If both operands are NaNs (including sNaN), returns a {ref}`NaN <floatnan>`. If
one operand is NaN (including sNaN) and another operand is a number,
return the number. Otherwise returns the lesser of the two
arguments. -0.0 is considered to be less than +0.0 for this intrinsic.
-If the ``nsz`` flag is specified, ``llvm.minimumnum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.minimumnum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-This intrinsic follows the semantics of ``fminimum_num`` in C23 and
-``minimumNumber`` in IEEE 754-2019, except for signaling NaN inputs, which
-follow :ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+This intrinsic follows the semantics of `fminimum_num` in C23 and
+`minimumNumber` in IEEE 754-2019, except for signaling NaN inputs, which
+follow {ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-This intrinsic behaves the same as ``llvm.minnum`` other than its treatment of
+This intrinsic behaves the same as `llvm.minnum` other than its treatment of
sNaN inputs.
-.. _i_maximumnum:
+(i_maximumnum)=
-'``llvm.maximumnum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.maximumnum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.maximumnum`` on any
+This is an overloaded intrinsic. You can use `llvm.maximumnum` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.maximumnum.f32(float %Val0, float %Val1)
- declare double @llvm.maximumnum.f64(double %Val0, double %Val1)
- declare x86_fp80 @llvm.maximumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
- declare fp128 @llvm.maximumnum.f128(fp128 %Val0, fp128 %Val1)
- declare ppc_fp128 @llvm.maximumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
+declare float @llvm.maximumnum.f32(float %Val0, float %Val1)
+declare double @llvm.maximumnum.f64(double %Val0, double %Val1)
+declare x86_fp80 @llvm.maximumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+declare fp128 @llvm.maximumnum.f128(fp128 %Val0, fp128 %Val1)
+declare ppc_fp128 @llvm.maximumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 %Val1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.maximumnum.*``' intrinsics return the maximum of the two
+The '`llvm.maximumnum.*`' intrinsics return the maximum of the two
arguments, not propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
If both operands are NaNs (including sNaN), returns a
-:ref:`NaN <floatnan>`. If one operand is NaN (including sNaN) and
+{ref}`NaN <floatnan>`. If one operand is NaN (including sNaN) and
another operand is a number, return the number. Otherwise returns the
greater of the two arguments. -0.0 is considered to be less than +0.0
for this intrinsic.
-If the ``nsz`` flag is specified, ``llvm.maximumnum`` with one +0.0 and one
+If the `nsz` flag is specified, `llvm.maximumnum` with one +0.0 and one
-0.0 operand may non-deterministically return either operand. Contrary to normal
-``nsz`` semantics, if both operands have the same sign, the result must also
+`nsz` semantics, if both operands have the same sign, the result must also
have the same sign.
-This intrinsic follows the semantics of ``fmaximum_num`` in C23 and
-``maximumNumber`` in IEEE 754-2019, except for signaling NaN inputs, which
-follow :ref:`LLVM's usual signaling NaN behavior <floatnan>` instead.
+This intrinsic follows the semantics of `fmaximum_num` in C23 and
+`maximumNumber` in IEEE 754-2019, except for signaling NaN inputs, which
+follow {ref}`LLVM's usual signaling NaN behavior <floatnan>` instead.
-This intrinsic behaves the same as ``llvm.maxnum`` other than its treatment of
+This intrinsic behaves the same as `llvm.maxnum` other than its treatment of
sNaN inputs.
-.. _int_copysign:
+(int_copysign)=
-'``llvm.copysign.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.copysign.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.copysign`` on any
+This is an overloaded intrinsic. You can use `llvm.copysign` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.copysign.f32(float %Mag, float %Sgn)
- declare double @llvm.copysign.f64(double %Mag, double %Sgn)
- declare x86_fp80 @llvm.copysign.f80(x86_fp80 %Mag, x86_fp80 %Sgn)
- declare fp128 @llvm.copysign.f128(fp128 %Mag, fp128 %Sgn)
- declare ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128 %Mag, ppc_fp128 %Sgn)
+```
+declare float @llvm.copysign.f32(float %Mag, float %Sgn)
+declare double @llvm.copysign.f64(double %Mag, double %Sgn)
+declare x86_fp80 @llvm.copysign.f80(x86_fp80 %Mag, x86_fp80 %Sgn)
+declare fp128 @llvm.copysign.f128(fp128 %Mag, fp128 %Sgn)
+declare ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128 %Mag, ppc_fp128 %Sgn)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.copysign.*``' intrinsics return a value with the magnitude of the
+The '`llvm.copysign.*`' intrinsics return a value with the magnitude of the
first operand and the sign of the second operand.
-Arguments:
-""""""""""
+##### Arguments:
The arguments and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``copysign``
+This function returns the same values as the libm `copysign`
functions would, and handles error conditions in the same way.
The returned value is completely identical to the first operand except for the
sign bit; in particular, if the input is a NaN, then the quiet/signaling bit and
payload are perfectly preserved.
-.. _int_floor:
+(int_floor)=
-'``llvm.floor.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.floor.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.floor`` on any
+This is an overloaded intrinsic. You can use `llvm.floor` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.floor.f32(float %Val)
- declare double @llvm.floor.f64(double %Val)
- declare x86_fp80 @llvm.floor.f80(x86_fp80 %Val)
- declare fp128 @llvm.floor.f128(fp128 %Val)
- declare ppc_fp128 @llvm.floor.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.floor.f32(float %Val)
+declare double @llvm.floor.f64(double %Val)
+declare x86_fp80 @llvm.floor.f80(x86_fp80 %Val)
+declare fp128 @llvm.floor.f128(fp128 %Val)
+declare ppc_fp128 @llvm.floor.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.floor.*``' intrinsics return the floor of the operand.
+The '`llvm.floor.*`' intrinsics return the floor of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``floor`` functions
+This function returns the same values as the libm `floor` functions
would, and handles error conditions in the same way.
-.. _int_ceil:
+(int_ceil)=
-'``llvm.ceil.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ceil.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.ceil`` on any
+This is an overloaded intrinsic. You can use `llvm.ceil` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.ceil.f32(float %Val)
- declare double @llvm.ceil.f64(double %Val)
- declare x86_fp80 @llvm.ceil.f80(x86_fp80 %Val)
- declare fp128 @llvm.ceil.f128(fp128 %Val)
- declare ppc_fp128 @llvm.ceil.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.ceil.f32(float %Val)
+declare double @llvm.ceil.f64(double %Val)
+declare x86_fp80 @llvm.ceil.f80(x86_fp80 %Val)
+declare fp128 @llvm.ceil.f128(fp128 %Val)
+declare ppc_fp128 @llvm.ceil.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ceil.*``' intrinsics return the ceiling of the operand.
+The '`llvm.ceil.*`' intrinsics return the ceiling of the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``ceil`` functions
+This function returns the same values as the libm `ceil` functions
would, and handles error conditions in the same way.
-.. _int_llvm_trunc:
+(int_llvm_trunc)=
-'``llvm.trunc.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.trunc.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.trunc`` on any
+This is an overloaded intrinsic. You can use `llvm.trunc` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.trunc.f32(float %Val)
- declare double @llvm.trunc.f64(double %Val)
- declare x86_fp80 @llvm.trunc.f80(x86_fp80 %Val)
- declare fp128 @llvm.trunc.f128(fp128 %Val)
- declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.trunc.f32(float %Val)
+declare double @llvm.trunc.f64(double %Val)
+declare x86_fp80 @llvm.trunc.f80(x86_fp80 %Val)
+declare fp128 @llvm.trunc.f128(fp128 %Val)
+declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.trunc.*``' intrinsics returns the operand rounded to the
+The '`llvm.trunc.*`' intrinsics returns the operand rounded to the
nearest integer not larger in magnitude than the operand.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``trunc`` functions
+This function returns the same values as the libm `trunc` functions
would, and handles error conditions in the same way.
-.. _int_rint:
+(int_rint)=
-'``llvm.rint.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.rint.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.rint`` on any
+This is an overloaded intrinsic. You can use `llvm.rint` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.rint.f32(float %Val)
- declare double @llvm.rint.f64(double %Val)
- declare x86_fp80 @llvm.rint.f80(x86_fp80 %Val)
- declare fp128 @llvm.rint.f128(fp128 %Val)
- declare ppc_fp128 @llvm.rint.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.rint.f32(float %Val)
+declare double @llvm.rint.f64(double %Val)
+declare x86_fp80 @llvm.rint.f80(x86_fp80 %Val)
+declare fp128 @llvm.rint.f128(fp128 %Val)
+declare ppc_fp128 @llvm.rint.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.rint.*``' intrinsics returns the operand rounded to the
+The '`llvm.rint.*`' intrinsics returns the operand rounded to the
nearest integer. It may raise an inexact floating-point exception if the
operand isn't an integer.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``rint`` functions
+This function returns the same values as the libm `rint` functions
would, and handles error conditions in the same way. Since LLVM assumes the
-:ref:`default floating-point environment <floatenv>`, the rounding mode is
+{ref}`default floating-point environment <floatenv>`, the rounding mode is
assumed to be set to "nearest", so halfway cases are rounded to the even
-integer. Use :ref:`Constrained Floating-Point Intrinsics <constrainedfp>`
+integer. Use {ref}`Constrained Floating-Point Intrinsics <constrainedfp>`
to avoid that assumption.
-.. _int_nearbyint:
+(int_nearbyint)=
-'``llvm.nearbyint.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.nearbyint.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.nearbyint`` on any
+This is an overloaded intrinsic. You can use `llvm.nearbyint` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.nearbyint.f32(float %Val)
- declare double @llvm.nearbyint.f64(double %Val)
- declare x86_fp80 @llvm.nearbyint.f80(x86_fp80 %Val)
- declare fp128 @llvm.nearbyint.f128(fp128 %Val)
- declare ppc_fp128 @llvm.nearbyint.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.nearbyint.f32(float %Val)
+declare double @llvm.nearbyint.f64(double %Val)
+declare x86_fp80 @llvm.nearbyint.f80(x86_fp80 %Val)
+declare fp128 @llvm.nearbyint.f128(fp128 %Val)
+declare ppc_fp128 @llvm.nearbyint.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.nearbyint.*``' intrinsics returns the operand rounded to the
+The '`llvm.nearbyint.*`' intrinsics returns the operand rounded to the
nearest integer.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``nearbyint``
+This function returns the same values as the libm `nearbyint`
functions would, and handles error conditions in the same way. Since LLVM
-assumes the :ref:`default floating-point environment <floatenv>`, the rounding
+assumes the {ref}`default floating-point environment <floatenv>`, the rounding
mode is assumed to be set to "nearest", so halfway cases are rounded to the even
-integer. Use :ref:`Constrained Floating-Point Intrinsics <constrainedfp>` to
+integer. Use {ref}`Constrained Floating-Point Intrinsics <constrainedfp>` to
avoid that assumption.
-.. _int_round:
+(int_round)=
-'``llvm.round.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.round.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.round`` on any
+This is an overloaded intrinsic. You can use `llvm.round` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.round.f32(float %Val)
- declare double @llvm.round.f64(double %Val)
- declare x86_fp80 @llvm.round.f80(x86_fp80 %Val)
- declare fp128 @llvm.round.f128(fp128 %Val)
- declare ppc_fp128 @llvm.round.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.round.f32(float %Val)
+declare double @llvm.round.f64(double %Val)
+declare x86_fp80 @llvm.round.f80(x86_fp80 %Val)
+declare fp128 @llvm.round.f128(fp128 %Val)
+declare ppc_fp128 @llvm.round.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.round.*``' intrinsics returns the operand rounded to the
+The '`llvm.round.*`' intrinsics returns the operand rounded to the
nearest integer.
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``round``
+This function returns the same values as the libm `round`
functions would, and handles error conditions in the same way.
-.. _int_roundeven:
+(int_roundeven)=
-'``llvm.roundeven.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.roundeven.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.roundeven`` on any
+This is an overloaded intrinsic. You can use `llvm.roundeven` on any
floating-point or vector of floating-point type. Not all targets support
all types however.
-::
-
- declare float @llvm.roundeven.f32(float %Val)
- declare double @llvm.roundeven.f64(double %Val)
- declare x86_fp80 @llvm.roundeven.f80(x86_fp80 %Val)
- declare fp128 @llvm.roundeven.f128(fp128 %Val)
- declare ppc_fp128 @llvm.roundeven.ppcf128(ppc_fp128 %Val)
+```
+declare float @llvm.roundeven.f32(float %Val)
+declare double @llvm.roundeven.f64(double %Val)
+declare x86_fp80 @llvm.roundeven.f80(x86_fp80 %Val)
+declare fp128 @llvm.roundeven.f128(fp128 %Val)
+declare ppc_fp128 @llvm.roundeven.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.roundeven.*``' intrinsics returns the operand rounded to the nearest
+The '`llvm.roundeven.*`' intrinsics returns the operand rounded to the nearest
integer in floating-point format rounding halfway cases to even (that is, to the
nearest value that is an even integer).
-Arguments:
-""""""""""
+##### Arguments:
The argument and return value are floating-point numbers of the same type.
-Semantics:
-""""""""""
+##### Semantics:
-This function implements IEEE 754 operation ``roundToIntegralTiesToEven``. It
-also behaves in the same way as C standard function ``roundeven``, including
+This function implements IEEE 754 operation `roundToIntegralTiesToEven`. It
+also behaves in the same way as C standard function `roundeven`, including
that it disregards rounding mode and does not raise floating point exceptions.
-'``llvm.lround.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.lround.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.lround`` on any
+This is an overloaded intrinsic. You can use `llvm.lround` on any
floating-point type or vector of floating-point type. Not all targets
support all types however.
-::
-
- declare i32 @llvm.lround.i32.f32(float %Val)
- declare i32 @llvm.lround.i32.f64(double %Val)
- declare i32 @llvm.lround.i32.f80(x86_fp80 %Val)
- declare i32 @llvm.lround.i32.f128(fp128 %Val)
- declare i32 @llvm.lround.i32.ppcf128(ppc_fp128 %Val)
+```
+declare i32 @llvm.lround.i32.f32(float %Val)
+declare i32 @llvm.lround.i32.f64(double %Val)
+declare i32 @llvm.lround.i32.f80(x86_fp80 %Val)
+declare i32 @llvm.lround.i32.f128(fp128 %Val)
+declare i32 @llvm.lround.i32.ppcf128(ppc_fp128 %Val)
- declare i64 @llvm.lround.i64.f32(float %Val)
- declare i64 @llvm.lround.i64.f64(double %Val)
- declare i64 @llvm.lround.i64.f80(x86_fp80 %Val)
- declare i64 @llvm.lround.i64.f128(fp128 %Val)
- declare i64 @llvm.lround.i64.ppcf128(ppc_fp128 %Val)
+declare i64 @llvm.lround.i64.f32(float %Val)
+declare i64 @llvm.lround.i64.f64(double %Val)
+declare i64 @llvm.lround.i64.f80(x86_fp80 %Val)
+declare i64 @llvm.lround.i64.f128(fp128 %Val)
+declare i64 @llvm.lround.i64.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.lround.*``' intrinsics return the operand rounded to the nearest
+The '`llvm.lround.*`' intrinsics return the operand rounded to the nearest
integer with ties away from zero.
-Arguments:
-""""""""""
+##### Arguments:
The argument is a floating-point number and the return value is an integer
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``lround`` functions
+This function returns the same values as the libm `lround` functions
would, but without setting errno. If the rounded value is too large to
be stored in the result type, the return value is a non-deterministic
value (equivalent to `freeze poison`).
-'``llvm.llround.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.llround.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.llround`` on any
+This is an overloaded intrinsic. You can use `llvm.llround` on any
floating-point type. Not all targets support all types however.
-::
-
- declare i64 @llvm.llround.i64.f32(float %Val)
- declare i64 @llvm.llround.i64.f64(double %Val)
- declare i64 @llvm.llround.i64.f80(x86_fp80 %Val)
- declare i64 @llvm.llround.i64.f128(fp128 %Val)
- declare i64 @llvm.llround.i64.ppcf128(ppc_fp128 %Val)
+```
+declare i64 @llvm.llround.i64.f32(float %Val)
+declare i64 @llvm.llround.i64.f64(double %Val)
+declare i64 @llvm.llround.i64.f80(x86_fp80 %Val)
+declare i64 @llvm.llround.i64.f128(fp128 %Val)
+declare i64 @llvm.llround.i64.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.llround.*``' intrinsics return the operand rounded to the nearest
+The '`llvm.llround.*`' intrinsics return the operand rounded to the nearest
integer with ties away from zero.
-Arguments:
-""""""""""
+##### Arguments:
The argument is a floating-point number and the return value is an integer
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``llround``
+This function returns the same values as the libm `llround`
functions would, but without setting errno. If the rounded value is
too large to be stored in the result type, the return value is a
non-deterministic value (equivalent to `freeze poison`).
-.. _int_lrint:
+(int_lrint)=
-'``llvm.lrint.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.lrint.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.lrint`` on any
+This is an overloaded intrinsic. You can use `llvm.lrint` on any
floating-point type or vector of floating-point type. Not all targets
support all types however.
-::
-
- declare i32 @llvm.lrint.i32.f32(float %Val)
- declare i32 @llvm.lrint.i32.f64(double %Val)
- declare i32 @llvm.lrint.i32.f80(x86_fp80 %Val)
- declare i32 @llvm.lrint.i32.f128(fp128 %Val)
- declare i32 @llvm.lrint.i32.ppcf128(ppc_fp128 %Val)
+```
+declare i32 @llvm.lrint.i32.f32(float %Val)
+declare i32 @llvm.lrint.i32.f64(double %Val)
+declare i32 @llvm.lrint.i32.f80(x86_fp80 %Val)
+declare i32 @llvm.lrint.i32.f128(fp128 %Val)
+declare i32 @llvm.lrint.i32.ppcf128(ppc_fp128 %Val)
- declare i64 @llvm.lrint.i64.f32(float %Val)
- declare i64 @llvm.lrint.i64.f64(double %Val)
- declare i64 @llvm.lrint.i64.f80(x86_fp80 %Val)
- declare i64 @llvm.lrint.i64.f128(fp128 %Val)
- declare i64 @llvm.lrint.i64.ppcf128(ppc_fp128 %Val)
+declare i64 @llvm.lrint.i64.f32(float %Val)
+declare i64 @llvm.lrint.i64.f64(double %Val)
+declare i64 @llvm.lrint.i64.f80(x86_fp80 %Val)
+declare i64 @llvm.lrint.i64.f128(fp128 %Val)
+declare i64 @llvm.lrint.i64.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.lrint.*``' intrinsics return the operand rounded to the nearest
+The '`llvm.lrint.*`' intrinsics return the operand rounded to the nearest
integer.
-Arguments:
-""""""""""
+##### Arguments:
The argument is a floating-point number and the return value is an integer
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``lrint`` functions
+This function returns the same values as the libm `lrint` functions
would, but without setting errno. If the rounded value is too large to
be stored in the result type, the return value is a non-deterministic
value (equivalent to `freeze poison`).
-.. _int_llrint:
+(int_llrint)=
-'``llvm.llrint.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.llrint.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.llrint`` on any
+This is an overloaded intrinsic. You can use `llvm.llrint` on any
floating-point type or vector of floating-point type. Not all targets
support all types however.
-::
-
- declare i64 @llvm.llrint.i64.f32(float %Val)
- declare i64 @llvm.llrint.i64.f64(double %Val)
- declare i64 @llvm.llrint.i64.f80(x86_fp80 %Val)
- declare i64 @llvm.llrint.i64.f128(fp128 %Val)
- declare i64 @llvm.llrint.i64.ppcf128(ppc_fp128 %Val)
+```
+declare i64 @llvm.llrint.i64.f32(float %Val)
+declare i64 @llvm.llrint.i64.f64(double %Val)
+declare i64 @llvm.llrint.i64.f80(x86_fp80 %Val)
+declare i64 @llvm.llrint.i64.f128(fp128 %Val)
+declare i64 @llvm.llrint.i64.ppcf128(ppc_fp128 %Val)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.llrint.*``' intrinsics return the operand rounded to the nearest
+The '`llvm.llrint.*`' intrinsics return the operand rounded to the nearest
integer.
-Arguments:
-""""""""""
+##### Arguments:
The argument is a floating-point number and the return value is an integer
type.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``llrint`` functions
+This function returns the same values as the libm `llrint` functions
would, but without setting errno. If the rounded value is too large to
be stored in the result type, the return value is a non-deterministic
value (equivalent to `freeze poison`).
-Bit Manipulation Intrinsics
----------------------------
+### Bit Manipulation Intrinsics
LLVM provides intrinsics for a few important bit manipulation
operations. These allow efficient code generation for some algorithms.
-.. _int_bitreverse:
+(int_bitreverse)=
-'``llvm.bitreverse.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.bitreverse.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic function. You can use bitreverse on any
integer type.
-::
-
- declare i16 @llvm.bitreverse.i16(i16 <id>)
- declare i32 @llvm.bitreverse.i32(i32 <id>)
- declare i64 @llvm.bitreverse.i64(i64 <id>)
- declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> <id>)
+```
+declare i16 @llvm.bitreverse.i16(i16 <id>)
+declare i32 @llvm.bitreverse.i32(i32 <id>)
+declare i64 @llvm.bitreverse.i64(i64 <id>)
+declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> <id>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.bitreverse``' family of intrinsics is used to reverse the
+The '`llvm.bitreverse`' family of intrinsics is used to reverse the
bitpattern of an integer value or vector of integer values; for example
-``0b10110110`` becomes ``0b01101101``.
+`0b10110110` becomes `0b01101101`.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.bitreverse.iN`` intrinsic returns an iN value that has bit
-``M`` in the input moved to bit ``N-M-1`` in the output. The vector
-intrinsics, such as ``llvm.bitreverse.v4i32``, operate on a per-element
+The `llvm.bitreverse.iN` intrinsic returns an iN value that has bit
+`M` in the input moved to bit `N-M-1` in the output. The vector
+intrinsics, such as `llvm.bitreverse.v4i32`, operate on a per-element
basis and the element order is not affected.
-.. _int_bswap:
+(int_bswap)=
-'``llvm.bswap.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.bswap.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic function. You can use bswap on any
integer type that is an even number of bytes (i.e., BitWidth % 16 == 0).
-::
-
- declare i16 @llvm.bswap.i16(i16 <id>)
- declare i32 @llvm.bswap.i32(i32 <id>)
- declare i64 @llvm.bswap.i64(i64 <id>)
- declare <4 x i32> @llvm.bswap.v4i32(<4 x i32> <id>)
+```
+declare i16 @llvm.bswap.i16(i16 <id>)
+declare i32 @llvm.bswap.i32(i32 <id>)
+declare i64 @llvm.bswap.i64(i64 <id>)
+declare <4 x i32> @llvm.bswap.v4i32(<4 x i32> <id>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.bswap``' family of intrinsics is used to byte swap an integer
+The '`llvm.bswap`' family of intrinsics is used to byte swap an integer
value or vector of integer values with an even number of bytes (positive
multiple of 16 bits).
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.bswap.i16`` intrinsic returns an i16 value that has the high
-and low byte of the input i16 swapped. Similarly, the ``llvm.bswap.i32``
+The `llvm.bswap.i16` intrinsic returns an i16 value that has the high
+and low byte of the input i16 swapped. Similarly, the `llvm.bswap.i32`
intrinsic returns an i32 value that has the four bytes of the input i32
swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the
returned i32 will have its bytes in 3, 2, 1, 0 order. The
-``llvm.bswap.i48``, ``llvm.bswap.i64`` and other intrinsics extend this
+`llvm.bswap.i48`, `llvm.bswap.i64` and other intrinsics extend this
concept to additional even-byte lengths (6 bytes, 8 bytes and more,
-respectively). The vector intrinsics, such as ``llvm.bswap.v4i32``,
+respectively). The vector intrinsics, such as `llvm.bswap.v4i32`,
operate on a per-element basis and the element order is not affected.
-.. _int_ctpop:
+(int_ctpop)=
-'``llvm.ctpop.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ctpop.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.ctpop`` on any integer
+This is an overloaded intrinsic. You can use `llvm.ctpop` on any integer
bit width, or on any vector with integer elements. Not all targets
support all bit widths or vector types, however.
-::
-
- declare i8 @llvm.ctpop.i8(i8 <src>)
- declare i16 @llvm.ctpop.i16(i16 <src>)
- declare i32 @llvm.ctpop.i32(i32 <src>)
- declare i64 @llvm.ctpop.i64(i64 <src>)
- declare i256 @llvm.ctpop.i256(i256 <src>)
- declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>)
+```
+declare i8 @llvm.ctpop.i8(i8 <src>)
+declare i16 @llvm.ctpop.i16(i16 <src>)
+declare i32 @llvm.ctpop.i32(i32 <src>)
+declare i64 @llvm.ctpop.i64(i64 <src>)
+declare i256 @llvm.ctpop.i256(i256 <src>)
+declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ctpop``' family of intrinsics counts the number of bits set
+The '`llvm.ctpop`' family of intrinsics counts the number of bits set
in a value.
-Arguments:
-""""""""""
+##### Arguments:
The only argument is the value to be counted. The argument may be of any
integer type, or a vector with integer elements. The return type must
match the argument type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.ctpop``' intrinsic counts the 1's in a variable, or within
+The '`llvm.ctpop`' intrinsic counts the 1's in a variable, or within
each element of a vector.
-.. _int_ctlz:
+(int_ctlz)=
-'``llvm.ctlz.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ctlz.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.ctlz`` on any
+This is an overloaded intrinsic. You can use `llvm.ctlz` on any
integer bit width, or any vector whose elements are integers. Not all
targets support all bit widths or vector types, however.
-::
-
- declare i8 @llvm.ctlz.i8 (i8 <src>, i1 <is_zero_poison>)
- declare <2 x i37> @llvm.ctlz.v2i37(<2 x i37> <src>, i1 <is_zero_poison>)
+```
+declare i8 @llvm.ctlz.i8 (i8 <src>, i1 <is_zero_poison>)
+declare <2 x i37> @llvm.ctlz.v2i37(<2 x i37> <src>, i1 <is_zero_poison>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ctlz``' family of intrinsic functions counts the number of
+The '`llvm.ctlz`' family of intrinsic functions counts the number of
leading zeros in a variable.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the value to be counted. This argument may be of
any integer type, or a vector with integer element type. The return
@@ -19143,40 +18087,35 @@ Historically some architectures did not provide a defined result for zero
values as efficiently, and many algorithms are now predicated on avoiding
zero-value inputs.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.ctlz``' intrinsic counts the leading (most significant)
+The '`llvm.ctlz`' intrinsic counts the leading (most significant)
zeros in a variable, or within each element of the vector. If
-``src == 0`` then the result is the size in bits of the type of ``src``
-if ``is_zero_poison == 0`` and ``poison`` otherwise. For example,
-``llvm.ctlz(i32 2) = 30``.
+`src == 0` then the result is the size in bits of the type of `src`
+if `is_zero_poison == 0` and `poison` otherwise. For example,
+`llvm.ctlz(i32 2) = 30`.
-.. _int_cttz:
+(int_cttz)=
-'``llvm.cttz.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.cttz.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.cttz`` on any
+This is an overloaded intrinsic. You can use `llvm.cttz` on any
integer bit width, or any vector of integer elements. Not all targets
support all bit widths or vector types, however.
-::
-
- declare i42 @llvm.cttz.i42 (i42 <src>, i1 <is_zero_poison>)
- declare <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>, i1 <is_zero_poison>)
+```
+declare i42 @llvm.cttz.i42 (i42 <src>, i1 <is_zero_poison>)
+declare <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>, i1 <is_zero_poison>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.cttz``' family of intrinsic functions counts the number of
+The '`llvm.cttz`' family of intrinsic functions counts the number of
trailing zeros.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the value to be counted. This argument may be of
any integer type, or a vector with integer element type. The return
@@ -19189,37 +18128,33 @@ Historically some architectures did not provide a defined result for zero
values as efficiently, and many algorithms are now predicated on avoiding
zero-value inputs.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.cttz``' intrinsic counts the trailing (least significant)
-zeros in a variable, or within each element of a vector. If ``src == 0``
-then the result is the size in bits of the type of ``src`` if
-``is_zero_poison == 0`` and ``poison`` otherwise. For example,
-``llvm.cttz(2) = 1``.
+The '`llvm.cttz`' intrinsic counts the trailing (least significant)
+zeros in a variable, or within each element of a vector. If `src == 0`
+then the result is the size in bits of the type of `src` if
+`is_zero_poison == 0` and `poison` otherwise. For example,
+`llvm.cttz(2) = 1`.
-.. _int_fshl:
+(int_fshl)=
-'``llvm.fshl.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fshl.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fshl`` on any
+This is an overloaded intrinsic. You can use `llvm.fshl` on any
integer bit width or any vector of integer elements. Not all targets
support all bit widths or vector types, however.
-::
-
- declare i8 @llvm.fshl.i8 (i8 %a, i8 %b, i8 %c)
- declare i64 @llvm.fshl.i64(i64 %a, i64 %b, i64 %c)
- declare <2 x i32> @llvm.fshl.v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c)
+```
+declare i8 @llvm.fshl.i8 (i8 %a, i8 %b, i8 %c)
+declare i64 @llvm.fshl.i64(i64 %a, i64 %b, i64 %c)
+declare <2 x i32> @llvm.fshl.v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fshl``' family of intrinsic functions performs a funnel shift left:
+The '`llvm.fshl`' family of intrinsic functions performs a funnel shift left:
the first two values are concatenated as { %a : %b } (%a is the most significant
bits of the wide value), the combined value is shifted left, and the most
significant bits are extracted to produce a result that is the same size as the
@@ -19228,46 +18163,41 @@ to a rotate left operation. For vector types, the operation occurs for each
element of the vector. The shift argument is treated as an unsigned amount
modulo the element size of the arguments.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments are the values to be concatenated. The third
argument is the shift amount. The arguments may be any integer type or a
vector with integer element type. All arguments and the return value must
have the same type.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- %r = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z) ; %r = i8: msb_extract((concat(x, y) << (z % 8)), 8)
- %r = call i8 @llvm.fshl.i8(i8 255, i8 0, i8 15) ; %r = i8: 128 (0b10000000)
- %r = call i8 @llvm.fshl.i8(i8 15, i8 15, i8 11) ; %r = i8: 120 (0b01111000)
- %r = call i8 @llvm.fshl.i8(i8 0, i8 255, i8 8) ; %r = i8: 0 (0b00000000)
+```text
+%r = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z) ; %r = i8: msb_extract((concat(x, y) << (z % 8)), 8)
+%r = call i8 @llvm.fshl.i8(i8 255, i8 0, i8 15) ; %r = i8: 128 (0b10000000)
+%r = call i8 @llvm.fshl.i8(i8 15, i8 15, i8 11) ; %r = i8: 120 (0b01111000)
+%r = call i8 @llvm.fshl.i8(i8 0, i8 255, i8 8) ; %r = i8: 0 (0b00000000)
+```
-.. _int_fshr:
+(int_fshr)=
-'``llvm.fshr.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fshr.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fshr`` on any
+This is an overloaded intrinsic. You can use `llvm.fshr` on any
integer bit width or any vector of integer elements. Not all targets
support all bit widths or vector types, however.
-::
-
- declare i8 @llvm.fshr.i8 (i8 %a, i8 %b, i8 %c)
- declare i64 @llvm.fshr.i64(i64 %a, i64 %b, i64 %c)
- declare <2 x i32> @llvm.fshr.v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c)
+```
+declare i8 @llvm.fshr.i8 (i8 %a, i8 %b, i8 %c)
+declare i64 @llvm.fshr.i64(i64 %a, i64 %b, i64 %c)
+declare <2 x i32> @llvm.fshr.v2i32(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fshr``' family of intrinsic functions performs a funnel shift right:
+The '`llvm.fshr`' family of intrinsic functions performs a funnel shift right:
the first two values are concatenated as { %a : %b } (%a is the most significant
bits of the wide value), the combined value is shifted right, and the least
significant bits are extracted to produce a result that is the same size as the
@@ -19276,502 +18206,446 @@ to a rotate right operation. For vector types, the operation occurs for each
element of the vector. The shift argument is treated as an unsigned amount
modulo the element size of the arguments.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments are the values to be concatenated. The third
argument is the shift amount. The arguments may be any integer type or a
vector with integer element type. All arguments and the return value must
have the same type.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- %r = call i8 @llvm.fshr.i8(i8 %x, i8 %y, i8 %z) ; %r = i8: lsb_extract((concat(x, y) >> (z % 8)), 8)
- %r = call i8 @llvm.fshr.i8(i8 255, i8 0, i8 15) ; %r = i8: 254 (0b11111110)
- %r = call i8 @llvm.fshr.i8(i8 15, i8 15, i8 11) ; %r = i8: 225 (0b11100001)
- %r = call i8 @llvm.fshr.i8(i8 0, i8 255, i8 8) ; %r = i8: 255 (0b11111111)
+```text
+%r = call i8 @llvm.fshr.i8(i8 %x, i8 %y, i8 %z) ; %r = i8: lsb_extract((concat(x, y) >> (z % 8)), 8)
+%r = call i8 @llvm.fshr.i8(i8 255, i8 0, i8 15) ; %r = i8: 254 (0b11111110)
+%r = call i8 @llvm.fshr.i8(i8 15, i8 15, i8 11) ; %r = i8: 225 (0b11100001)
+%r = call i8 @llvm.fshr.i8(i8 0, i8 255, i8 8) ; %r = i8: 255 (0b11111111)
+```
-.. _int_clmul:
+(int_clmul)=
-'``llvm.clmul.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.clmul.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.clmul`` on any integer
+This is an overloaded intrinsic. You can use `llvm.clmul` on any integer
or vectors of integer elements.
-::
-
- declare i16 @llvm.clmul.i16(i16 %a, i16 %b)
- declare i32 @llvm.clmul.i32(i32 %a, i32 %b)
- declare i64 @llvm.clmul.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.clmul.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i16 @llvm.clmul.i16(i16 %a, i16 %b)
+declare i32 @llvm.clmul.i32(i32 %a, i32 %b)
+declare i64 @llvm.clmul.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.clmul.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.clmul``' family of intrinsic functions performs carry-less
+The '`llvm.clmul`' family of intrinsic functions performs carry-less
multiplication, or XOR multiplication, on the two arguments, and returns
the low-bits.
-Arguments:
-""""""""""
+##### Arguments:
The arguments may be any integer type or vector of integer type. Both
arguments and result must have the same type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.clmul``' intrinsic computes carry-less multiply of its arguments,
+The '`llvm.clmul`' intrinsic computes carry-less multiply of its arguments,
which is the result of applying the standard multiplication algorithm, where
all of the additions are replaced with XORs, and returns the low-bits.
The vector variants operate lane-wise.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %r = call i4 @llvm.clmul.i4(i4 1, i4 2) ; %r = 2
- %r = call i4 @llvm.clmul.i4(i4 5, i4 6) ; %r = 14
- %r = call i4 @llvm.clmul.i4(i4 -4, i4 2) ; %r = -8
- %r = call i4 @llvm.clmul.i4(i4 -4, i4 -5) ; %r = 4
+```llvm
+%r = call i4 @llvm.clmul.i4(i4 1, i4 2) ; %r = 2
+%r = call i4 @llvm.clmul.i4(i4 5, i4 6) ; %r = 14
+%r = call i4 @llvm.clmul.i4(i4 -4, i4 2) ; %r = -8
+%r = call i4 @llvm.clmul.i4(i4 -4, i4 -5) ; %r = 4
+```
-.. _int_pext:
+(int_pext)=
-'``llvm.pext.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.pext.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.pext`` on any integer
+This is an overloaded intrinsic. You can use `llvm.pext` on any integer
or integer vector type.
-::
-
- declare i32 @llvm.pext.i32(i32 %val, i32 %mask)
- declare i64 @llvm.pext.i64(i64 %val, i64 %mask)
- declare <4 x i32> @llvm.pext.v4i32(<4 x i32> %val, <4 x i32> %mask)
+```llvm
+declare i32 @llvm.pext.i32(i32 %val, i32 %mask)
+declare i64 @llvm.pext.i64(i64 %val, i64 %mask)
+declare <4 x i32> @llvm.pext.v4i32(<4 x i32> %val, <4 x i32> %mask)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.pext``' family of intrinsic functions extracts the bits from ``val``
-where the ``mask`` has bits set and packs them contiguously in the low bits
-of the result, same as the x86 ``PEXT`` instruction.
+The '`llvm.pext`' family of intrinsic functions extracts the bits from `val`
+where the `mask` has bits set and packs them contiguously in the low bits
+of the result, same as the x86 `PEXT` instruction.
-Arguments:
-""""""""""
+##### Arguments:
The arguments may be any integer type or vector of integer type. Both
arguments and result must have the same type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.pext``' intrinsic extracts bits from the first argument
-``val`` at the positions indicated by set bits in ``mask``, and packs
+The '`llvm.pext`' intrinsic extracts bits from the first argument
+`val` at the positions indicated by set bits in `mask`, and packs
them contiguously into the low bits of the result. The remaining high
bits of the result are zero.
-Equivalently, if the set bit positions in ``mask`` (from LSB to MSB)
-are ``p0, p1, ..., pk``, then the result bit ``i`` equals bit ``pi``
-of ``val``.
+Equivalently, if the set bit positions in `mask` (from LSB to MSB)
+are `p0, p1, ..., pk`, then the result bit `i` equals bit `pi`
+of `val`.
-.. code-block:: text
+```llvm
+%r = call i8 @llvm.pext.i8(i8 0b10101010, i8 0b11001100) ; %r = 0b00001010
+%r = call i8 @llvm.pext.i8(i8 0b11111111, i8 0b10101010) ; %r = 0b00001111
+```
- %r = call i8 @llvm.pext.i8(i8 0b10101010, i8 0b11001100) ; %r = 0b00001010
- %r = call i8 @llvm.pext.i8(i8 0b11111111, i8 0b10101010) ; %r = 0b00001111
+(int_pdep)=
-.. _int_pdep:
+#### '`llvm.pdep.*`' Intrinsic
-'``llvm.pdep.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.pdep`` on any integer or
+This is an overloaded intrinsic. You can use `llvm.pdep` on any integer or
integer vector type.
-::
+```llvm
+declare i32 @llvm.pdep.i32(i32 %val, i32 %mask)
+declare i64 @llvm.pdep.i64(i64 %val, i64 %mask)
+declare <4 x i32> @llvm.pdep.v4i32(<4 x i32> %val, <4 x i32> %mask)
+```
- declare i32 @llvm.pdep.i32(i32 %val, i32 %mask)
- declare i64 @llvm.pdep.i64(i64 %val, i64 %mask)
- declare <4 x i32> @llvm.pdep.v4i32(<4 x i32> %val, <4 x i32> %mask)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.pdep`' family of intrinsic functions deposits the low bits of
+`val` into the result at the positions where `mask` has bits set, same as
+the x86 `PDEP` instruction.
-The '``llvm.pdep``' family of intrinsic functions deposits the low bits of
-``val`` into the result at the positions where ``mask`` has bits set, same as
-the x86 ``PDEP`` instruction.
-
-Arguments:
-""""""""""
+##### Arguments:
The arguments may be any integer type or vector of integer type. Both
arguments and result must have the same type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.pdep``' intrinsic takes the low bits of the first argument
-``val`` and scatters them to the bit positions in the result indicated by
-set bits in ``mask``. Bits in the result at positions where ``mask`` is
+The '`llvm.pdep`' intrinsic takes the low bits of the first argument
+`val` and scatters them to the bit positions in the result indicated by
+set bits in `mask`. Bits in the result at positions where `mask` is
zero are zero.
-Equivalently, if the set bit positions in ``mask`` (from LSB to MSB) are
-``p0, p1, ..., pk``, then result bit ``pi`` equals bit ``i`` of ``val``.
+Equivalently, if the set bit positions in `mask` (from LSB to MSB) are
+`p0, p1, ..., pk`, then result bit `pi` equals bit `i` of `val`.
The operations satisfy the round-trip identity:
-``pdep(pext(val, mask), mask) == val & mask``.
-
-.. code-block:: text
+`pdep(pext(val, mask), mask) == val & mask`.
- %r = call i8 @llvm.pdep.i8(i8 0b00001010, i8 0b11001100) ; %r = 0b10001000
- %r = call i8 @llvm.pdep.i8(i8 0b00001111, i8 0b10101010) ; %r = 0b10101010
+```llvm
+%r = call i8 @llvm.pdep.i8(i8 0b00001010, i8 0b11001100) ; %r = 0b10001000
+%r = call i8 @llvm.pdep.i8(i8 0b00001111, i8 0b10101010) ; %r = 0b10101010
+```
-.. _int_overflow:
+(int_overflow)=
-Arithmetic with Overflow Intrinsics
------------------------------------
+### Arithmetic with Overflow Intrinsics
LLVM provides intrinsics for fast arithmetic overflow checking.
Each of these intrinsics returns a two-element struct. The first
element of this struct contains the result of the corresponding
-arithmetic operation modulo 2\ :sup:`n`\ , where n is the bit width of
+arithmetic operation modulo 2{sup}`n`, where n is the bit width of
the result. Therefore, for example, the first element of the struct
-returned by ``llvm.sadd.with.overflow.i32`` is always the same as the
-result of a 32-bit ``add`` instruction with the same operands, where
-the ``add`` is *not* modified by an ``nsw`` or ``nuw`` flag.
+returned by `llvm.sadd.with.overflow.i32` is always the same as the
+result of a 32-bit `add` instruction with the same operands, where
+the `add` is *not* modified by an `nsw` or `nuw` flag.
-The second element of the result is an ``i1`` that is 1 if the
+The second element of the result is an `i1` that is 1 if the
arithmetic operation overflowed and 0 otherwise. An operation
-overflows if, for any values of its operands ``A`` and ``B`` and for
-any ``N`` larger than the operands' width, ``ext(A op B) to iN`` is
-not equal to ``(ext(A) to iN) op (ext(B) to iN)`` where ``ext`` is
-``sext`` for signed overflow and ``zext`` for unsigned overflow, and
-``op`` is the underlying arithmetic operation.
+overflows if, for any values of its operands `A` and `B` and for
+any `N` larger than the operands' width, `ext(A op B) to iN` is
+not equal to `(ext(A) to iN) op (ext(B) to iN)` where `ext` is
+`sext` for signed overflow and `zext` for unsigned overflow, and
+`op` is the underlying arithmetic operation.
The behavior of these intrinsics is well-defined for all argument
values.
-'``llvm.sadd.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sadd.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.sadd.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.sadd.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.sadd.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.sadd.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.sadd.with.overflow``' family of intrinsic functions perform
+The '`llvm.sadd.with.overflow`' family of intrinsic functions perform
a signed addition of the two arguments, and indicate whether an overflow
occurred during the signed summation.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
+`i1`. `%a` and `%b` are the two values that will undergo signed
addition.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.sadd.with.overflow``' family of intrinsic functions perform
+The '`llvm.sadd.with.overflow`' family of intrinsic functions perform
a signed addition of the two variables. They return a structure --- the
first element of which is the signed summation, and the second element
of which is a bit specifying if the signed summation resulted in an
overflow.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %overflow, label %normal
+```llvm
+%res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %overflow, label %normal
+```
-'``llvm.uadd.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.uadd.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.uadd.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.uadd.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.uadd.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.uadd.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.uadd.with.overflow``' family of intrinsic functions perform
+The '`llvm.uadd.with.overflow`' family of intrinsic functions perform
an unsigned addition of the two arguments, and indicate whether a carry
occurred during the unsigned summation.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
+`i1`. `%a` and `%b` are the two values that will undergo unsigned
addition.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.uadd.with.overflow``' family of intrinsic functions perform
+The '`llvm.uadd.with.overflow`' family of intrinsic functions perform
an unsigned addition of the two arguments. They return a structure --- the
first element of which is the sum, and the second element of which is a
bit specifying if the unsigned summation resulted in a carry.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %carry, label %normal
+```llvm
+%res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %carry, label %normal
+```
-'``llvm.ssub.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ssub.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.ssub.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.ssub.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.ssub.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.ssub.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ssub.with.overflow``' family of intrinsic functions perform
+The '`llvm.ssub.with.overflow`' family of intrinsic functions perform
a signed subtraction of the two arguments, and indicate whether an
overflow occurred during the signed subtraction.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
+`i1`. `%a` and `%b` are the two values that will undergo signed
subtraction.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.ssub.with.overflow``' family of intrinsic functions perform
+The '`llvm.ssub.with.overflow`' family of intrinsic functions perform
a signed subtraction of the two arguments. They return a structure --- the
first element of which is the subtraction, and the second element of
which is a bit specifying if the signed subtraction resulted in an
overflow.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %overflow, label %normal
+```llvm
+%res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %overflow, label %normal
+```
-'``llvm.usub.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.usub.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.usub.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.usub.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.usub.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.usub.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.usub.with.overflow``' family of intrinsic functions perform
+The '`llvm.usub.with.overflow`' family of intrinsic functions perform
an unsigned subtraction of the two arguments, and indicate whether an
overflow occurred during the unsigned subtraction.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
+`i1`. `%a` and `%b` are the two values that will undergo unsigned
subtraction.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.usub.with.overflow``' family of intrinsic functions perform
+The '`llvm.usub.with.overflow`' family of intrinsic functions perform
an unsigned subtraction of the two arguments. They return a structure ---
the first element of which is the subtraction, and the second element of
which is a bit specifying if the unsigned subtraction resulted in an
overflow.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %overflow, label %normal
+```llvm
+%res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %overflow, label %normal
+```
-'``llvm.smul.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.smul.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.smul.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.smul.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.smul.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.smul.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.smul.with.overflow``' family of intrinsic functions perform
+The '`llvm.smul.with.overflow`' family of intrinsic functions perform
a signed multiplication of the two arguments, and indicate whether an
overflow occurred during the signed multiplication.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
+`i1`. `%a` and `%b` are the two values that will undergo signed
multiplication.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.smul.with.overflow``' family of intrinsic functions perform
+The '`llvm.smul.with.overflow`' family of intrinsic functions perform
a signed multiplication of the two arguments. They return a structure ---
the first element of which is the multiplication, and the second element
of which is a bit specifying if the signed multiplication resulted in an
overflow.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %overflow, label %normal
+```llvm
+%res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %overflow, label %normal
+```
-'``llvm.umul.with.overflow.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.umul.with.overflow.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.umul.with.overflow``
+This is an overloaded intrinsic. You can use `llvm.umul.with.overflow`
on any integer bit width or vectors of integers.
-::
-
- declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
- declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
- declare {i64, i1} @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
- declare {<4 x i32>, <4 x i1>} @llvm.umul.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
+declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
+declare {i64, i1} @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
+declare {<4 x i32>, <4 x i1>} @llvm.umul.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.umul.with.overflow``' family of intrinsic functions perform
+The '`llvm.umul.with.overflow`' family of intrinsic functions perform
an unsigned multiplication of the two arguments, and indicate whether an
overflow occurred during the unsigned multiplication.
-Arguments:
-""""""""""
+##### Arguments:
The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
-``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
+`i1`. `%a` and `%b` are the two values that will undergo unsigned
multiplication.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.umul.with.overflow``' family of intrinsic functions perform
+The '`llvm.umul.with.overflow`' family of intrinsic functions perform
an unsigned multiplication of the two arguments. They return a structure ---
the first element of which is the multiplication, and the second
element of which is a bit specifying if the unsigned multiplication
resulted in an overflow.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
- %sum = extractvalue {i32, i1} %res, 0
- %obit = extractvalue {i32, i1} %res, 1
- br i1 %obit, label %overflow, label %normal
+```llvm
+%res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
+%sum = extractvalue {i32, i1} %res, 0
+%obit = extractvalue {i32, i1} %res, 1
+br i1 %obit, label %overflow, label %normal
+```
-Saturation Arithmetic Intrinsics
----------------------------------
+### Saturation Arithmetic Intrinsics
Saturation arithmetic is a version of arithmetic in which operations are
limited to a fixed range between a minimum and maximum value. If the result of
@@ -19779,188 +18653,162 @@ an operation is greater than the maximum value, the result is set (or
"clamped") to this maximum. If it is below the minimum, it is clamped to this
minimum.
-.. _int_sadd_sat:
+(int_sadd_sat)=
-'``llvm.sadd.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sadd.sat.*`' Intrinsics
-Syntax
-"""""""
+##### Syntax
-This is an overloaded intrinsic. You can use ``llvm.sadd.sat``
+This is an overloaded intrinsic. You can use `llvm.sadd.sat`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.sadd.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.sadd.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.sadd.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
- declare i16 @llvm.sadd.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.sadd.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.sadd.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.sadd.sat``' family of intrinsic functions perform signed
+The '`llvm.sadd.sat`' family of intrinsic functions perform signed
saturating addition on the 2 arguments.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo signed addition.
-Semantics:
-""""""""""
+##### Semantics:
The maximum value this operation can clamp to is the largest signed value
representable by the bit width of the arguments. The minimum value is the
smallest signed value representable by this bit width.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.sadd.sat.i4(i4 1, i4 2) ; %res = 3
- %res = call i4 @llvm.sadd.sat.i4(i4 5, i4 6) ; %res = 7
- %res = call i4 @llvm.sadd.sat.i4(i4 -4, i4 2) ; %res = -2
- %res = call i4 @llvm.sadd.sat.i4(i4 -4, i4 -5) ; %res = -8
+```llvm
+%res = call i4 @llvm.sadd.sat.i4(i4 1, i4 2) ; %res = 3
+%res = call i4 @llvm.sadd.sat.i4(i4 5, i4 6) ; %res = 7
+%res = call i4 @llvm.sadd.sat.i4(i4 -4, i4 2) ; %res = -2
+%res = call i4 @llvm.sadd.sat.i4(i4 -4, i4 -5) ; %res = -8
+```
+(int_uadd_sat)=
-.. _int_uadd_sat:
+#### '`llvm.uadd.sat.*`' Intrinsics
-'``llvm.uadd.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.uadd.sat``
+This is an overloaded intrinsic. You can use `llvm.uadd.sat`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.uadd.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.uadd.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.uadd.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i16 @llvm.uadd.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.uadd.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.uadd.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.uadd.sat``' family of intrinsic functions perform unsigned
+The '`llvm.uadd.sat`' family of intrinsic functions perform unsigned
saturating addition on the 2 arguments.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo unsigned addition.
-Semantics:
-""""""""""
+##### Semantics:
The maximum value this operation can clamp to is the largest unsigned value
representable by the bit width of the arguments. Because this is an unsigned
operation, the result will never saturate towards zero.
-Examples
-"""""""""
+##### Examples
-.. code-block:: llvm
+```llvm
+%res = call i4 @llvm.uadd.sat.i4(i4 1, i4 2) ; %res = 3
+%res = call i4 @llvm.uadd.sat.i4(i4 5, i4 6) ; %res = 11
+%res = call i4 @llvm.uadd.sat.i4(i4 8, i4 8) ; %res = 15
+```
- %res = call i4 @llvm.uadd.sat.i4(i4 1, i4 2) ; %res = 3
- %res = call i4 @llvm.uadd.sat.i4(i4 5, i4 6) ; %res = 11
- %res = call i4 @llvm.uadd.sat.i4(i4 8, i4 8) ; %res = 15
+(int_ssub_sat)=
+#### '`llvm.ssub.sat.*`' Intrinsics
-.. _int_ssub_sat:
+##### Syntax
-'``llvm.ssub.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.ssub.sat``
+This is an overloaded intrinsic. You can use `llvm.ssub.sat`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.ssub.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.ssub.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.ssub.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
- declare i16 @llvm.ssub.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.ssub.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.ssub.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.ssub.sat``' family of intrinsic functions perform signed
+The '`llvm.ssub.sat`' family of intrinsic functions perform signed
saturating subtraction on the 2 arguments.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo signed subtraction.
-Semantics:
-""""""""""
+##### Semantics:
The maximum value this operation can clamp to is the largest signed value
representable by the bit width of the arguments. The minimum value is the
smallest signed value representable by this bit width.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.ssub.sat.i4(i4 2, i4 1) ; %res = 1
- %res = call i4 @llvm.ssub.sat.i4(i4 2, i4 6) ; %res = -4
- %res = call i4 @llvm.ssub.sat.i4(i4 -4, i4 5) ; %res = -8
- %res = call i4 @llvm.ssub.sat.i4(i4 4, i4 -5) ; %res = 7
+```llvm
+%res = call i4 @llvm.ssub.sat.i4(i4 2, i4 1) ; %res = 1
+%res = call i4 @llvm.ssub.sat.i4(i4 2, i4 6) ; %res = -4
+%res = call i4 @llvm.ssub.sat.i4(i4 -4, i4 5) ; %res = -8
+%res = call i4 @llvm.ssub.sat.i4(i4 4, i4 -5) ; %res = 7
+```
+(int_usub_sat)=
-.. _int_usub_sat:
+#### '`llvm.usub.sat.*`' Intrinsics
-'``llvm.usub.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.usub.sat``
+This is an overloaded intrinsic. You can use `llvm.usub.sat`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.usub.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.usub.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.usub.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i16 @llvm.usub.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.usub.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.usub.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.usub.sat``' family of intrinsic functions perform unsigned
+The '`llvm.usub.sat`' family of intrinsic functions perform unsigned
saturating subtraction on the 2 arguments.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo unsigned subtraction.
-Semantics:
-""""""""""
+##### Semantics:
The minimum value this operation can clamp to is 0, which is the smallest
unsigned value representable by the bit width of the unsigned arguments.
@@ -19968,119 +18816,102 @@ Because this is an unsigned operation, the result will never saturate towards
the largest possible value representable by this bit width.
-Examples
-"""""""""
-
-.. code-block:: llvm
-
- %res = call i4 @llvm.usub.sat.i4(i4 2, i4 1) ; %res = 1
- %res = call i4 @llvm.usub.sat.i4(i4 2, i4 6) ; %res = 0
+##### Examples
+```llvm
+%res = call i4 @llvm.usub.sat.i4(i4 2, i4 1) ; %res = 1
+%res = call i4 @llvm.usub.sat.i4(i4 2, i4 6) ; %res = 0
+```
-'``llvm.sshl.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sshl.sat.*`' Intrinsics
-Syntax
-"""""""
+##### Syntax
-This is an overloaded intrinsic. You can use ``llvm.sshl.sat``
+This is an overloaded intrinsic. You can use `llvm.sshl.sat`
on integers or vectors of integers of any bit width.
-::
+```
+declare i16 @llvm.sshl.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.sshl.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.sshl.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.sshl.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
- declare i16 @llvm.sshl.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.sshl.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.sshl.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.sshl.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.sshl.sat``' family of intrinsic functions perform signed
+The '`llvm.sshl.sat`' family of intrinsic functions perform signed
saturating left shift on the first argument.
-Arguments
-""""""""""
+##### Arguments
-The arguments (``%a`` and ``%b``) and the result may be of integer types of any
-bit width, but they must have the same bit width. ``%a`` is the value to be
-shifted, and ``%b`` is the amount to shift by. If ``b`` is (statically or
+The arguments (`%a` and `%b`) and the result may be of integer types of any
+bit width, but they must have the same bit width. `%a` is the value to be
+shifted, and `%b` is the amount to shift by. If `b` is (statically or
dynamically) equal to or larger than the integer bit width of the arguments,
-the result is a :ref:`poison value <poisonvalues>`. If the arguments are
-vectors, each vector element of ``a`` is shifted by the corresponding shift
-amount in ``b``.
+the result is a {ref}`poison value <poisonvalues>`. If the arguments are
+vectors, each vector element of `a` is shifted by the corresponding shift
+amount in `b`.
-Semantics:
-""""""""""
+##### Semantics:
The maximum value this operation can clamp to is the largest signed value
representable by the bit width of the arguments. The minimum value is the
smallest signed value representable by this bit width.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.sshl.sat.i4(i4 2, i4 1) ; %res = 4
- %res = call i4 @llvm.sshl.sat.i4(i4 2, i4 2) ; %res = 7
- %res = call i4 @llvm.sshl.sat.i4(i4 -5, i4 1) ; %res = -8
- %res = call i4 @llvm.sshl.sat.i4(i4 -1, i4 1) ; %res = -2
+```llvm
+%res = call i4 @llvm.sshl.sat.i4(i4 2, i4 1) ; %res = 4
+%res = call i4 @llvm.sshl.sat.i4(i4 2, i4 2) ; %res = 7
+%res = call i4 @llvm.sshl.sat.i4(i4 -5, i4 1) ; %res = -8
+%res = call i4 @llvm.sshl.sat.i4(i4 -1, i4 1) ; %res = -2
+```
+#### '`llvm.ushl.sat.*`' Intrinsics
-'``llvm.ushl.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.ushl.sat``
+This is an overloaded intrinsic. You can use `llvm.ushl.sat`
on integers or vectors of integers of any bit width.
-::
-
- declare i16 @llvm.ushl.sat.i16(i16 %a, i16 %b)
- declare i32 @llvm.ushl.sat.i32(i32 %a, i32 %b)
- declare i64 @llvm.ushl.sat.i64(i64 %a, i64 %b)
- declare <4 x i32> @llvm.ushl.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
+declare i16 @llvm.ushl.sat.i16(i16 %a, i16 %b)
+declare i32 @llvm.ushl.sat.i32(i32 %a, i32 %b)
+declare i64 @llvm.ushl.sat.i64(i64 %a, i64 %b)
+declare <4 x i32> @llvm.ushl.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.ushl.sat``' family of intrinsic functions perform unsigned
+The '`llvm.ushl.sat`' family of intrinsic functions perform unsigned
saturating left shift on the first argument.
-Arguments
-""""""""""
+##### Arguments
-The arguments (``%a`` and ``%b``) and the result may be of integer types of any
-bit width, but they must have the same bit width. ``%a`` is the value to be
-shifted, and ``%b`` is the amount to shift by. If ``b`` is (statically or
+The arguments (`%a` and `%b`) and the result may be of integer types of any
+bit width, but they must have the same bit width. `%a` is the value to be
+shifted, and `%b` is the amount to shift by. If `b` is (statically or
dynamically) equal to or larger than the integer bit width of the arguments,
-the result is a :ref:`poison value <poisonvalues>`. If the arguments are
-vectors, each vector element of ``a`` is shifted by the corresponding shift
-amount in ``b``.
+the result is a {ref}`poison value <poisonvalues>`. If the arguments are
+vectors, each vector element of `a` is shifted by the corresponding shift
+amount in `b`.
-Semantics:
-""""""""""
+##### Semantics:
The maximum value this operation can clamp to is the largest unsigned value
representable by the bit width of the arguments.
-Examples
-"""""""""
+##### Examples
-.. code-block:: llvm
+```llvm
+%res = call i4 @llvm.ushl.sat.i4(i4 2, i4 1) ; %res = 4
+%res = call i4 @llvm.ushl.sat.i4(i4 3, i4 3) ; %res = 15
+```
- %res = call i4 @llvm.ushl.sat.i4(i4 2, i4 1) ; %res = 4
- %res = call i4 @llvm.ushl.sat.i4(i4 3, i4 3) ; %res = 15
-
-
-Fixed Point Arithmetic Intrinsics
----------------------------------
+### Fixed Point Arithmetic Intrinsics
A fixed point number represents a real data type for a number that has a fixed
number of digits after a radix point (equivalent to the decimal point '.').
@@ -20089,37 +18920,37 @@ are useful for representing fractional values to a specific precision. The
following intrinsics perform fixed point arithmetic operations on 2 operands
of the same scale, specified as the third argument.
-The ``llvm.*mul.fix`` family of intrinsic functions represents a multiplication
+The `llvm.*mul.fix` family of intrinsic functions represents a multiplication
of fixed point numbers through scaled integers. Therefore, fixed point
multiplication can be represented as
-.. code-block:: llvm
+```llvm
+%result = call i4 @llvm.smul.fix.i4(i4 %a, i4 %b, i32 %scale)
- %result = call i4 @llvm.smul.fix.i4(i4 %a, i4 %b, i32 %scale)
+; Expands to
+%a2 = sext i4 %a to i8
+%b2 = sext i4 %b to i8
+%mul = mul nsw nuw i8 %a2, %b2
+%scale2 = trunc i32 %scale to i8
+%r = ashr i8 %mul, i8 %scale2 ; this is for a target rounding down towards negative infinity
+%result = trunc i8 %r to i4
+```
- ; Expands to
- %a2 = sext i4 %a to i8
- %b2 = sext i4 %b to i8
- %mul = mul nsw nuw i8 %a2, %b2
- %scale2 = trunc i32 %scale to i8
- %r = ashr i8 %mul, i8 %scale2 ; this is for a target rounding down towards negative infinity
- %result = trunc i8 %r to i4
-
-The ``llvm.*div.fix`` family of intrinsic functions represents a division of
+The `llvm.*div.fix` family of intrinsic functions represents a division of
fixed point numbers through scaled integers. Fixed point division can be
represented as:
-.. code-block:: llvm
-
- %result call i4 @llvm.sdiv.fix.i4(i4 %a, i4 %b, i32 %scale)
+```llvm
+%result call i4 @llvm.sdiv.fix.i4(i4 %a, i4 %b, i32 %scale)
- ; Expands to
- %a2 = sext i4 %a to i8
- %b2 = sext i4 %b to i8
- %scale2 = trunc i32 %scale to i8
- %a3 = shl i8 %a2, %scale2
- %r = sdiv i8 %a3, %b2 ; this is for a target rounding towards zero
- %result = trunc i8 %r to i4
+; Expands to
+%a2 = sext i4 %a to i8
+%b2 = sext i4 %b to i8
+%scale2 = trunc i32 %scale to i8
+%a3 = shl i8 %a2, %scale2
+%r = sdiv i8 %a3, %b2 ; this is for a target rounding towards zero
+%result = trunc i8 %r to i4
+```
For each of these functions, if the result cannot be represented exactly with
the provided scale, the result is rounded. Rounding is unspecified since
@@ -20133,40 +18964,35 @@ result. That is, the error between the returned result and the true result must
be less than 1/2^(scale).
-'``llvm.smul.fix.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.smul.fix.*`' Intrinsics
-Syntax
-"""""""
+##### Syntax
-This is an overloaded intrinsic. You can use ``llvm.smul.fix``
+This is an overloaded intrinsic. You can use `llvm.smul.fix`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.smul.fix.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.smul.fix.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.smul.fix.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.smul.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
- declare i16 @llvm.smul.fix.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.smul.fix.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.smul.fix.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.smul.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.smul.fix``' family of intrinsic functions perform signed
+The '`llvm.smul.fix`' family of intrinsic functions perform signed
fixed point multiplication on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
width, but they must have the same bit width. The arguments may also work with
-int vectors of the same length and int size. ``%a`` and ``%b`` are the two
+int vectors of the same length and int size. `%a` and `%b` are the two
values that will undergo signed fixed point multiplication. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point multiplication on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20180,53 +19006,46 @@ It is undefined behavior if the result value does not fit within the range of
the fixed point type.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
- %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
- %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5)
+```llvm
+%res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
+%res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
+%res = call i4 @llvm.smul.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5)
- ; The result in the following could be rounded up to -2 or down to -2.5
- %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25)
+; The result in the following could be rounded up to -2 or down to -2.5
+%res = call i4 @llvm.smul.fix.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25)
+```
+#### '`llvm.umul.fix.*`' Intrinsics
-'``llvm.umul.fix.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.umul.fix``
+This is an overloaded intrinsic. You can use `llvm.umul.fix`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.umul.fix.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.umul.fix.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.umul.fix.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.umul.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
+declare i16 @llvm.umul.fix.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.umul.fix.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.umul.fix.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.umul.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.umul.fix``' family of intrinsic functions perform unsigned
+The '`llvm.umul.fix`' family of intrinsic functions perform unsigned
fixed point multiplication on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
width, but they must have the same bit width. The arguments may also work with
-int vectors of the same length and int size. ``%a`` and ``%b`` are the two
+int vectors of the same length and int size. `%a` and `%b` are the two
values that will undergo unsigned fixed point multiplication. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs unsigned fixed point multiplication on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20240,51 +19059,44 @@ It is undefined behavior if the result value does not fit within the range of
the fixed point type.
-Examples
-"""""""""
+##### Examples
-.. code-block:: llvm
+```llvm
+%res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
+%res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
- %res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
- %res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
+; The result in the following could be rounded down to 3.5 or up to 4
+%res = call i4 @llvm.umul.fix.i4(i4 15, i4 1, i32 1) ; %res = 7 (or 8) (7.5 x 0.5 = 3.75)
+```
- ; The result in the following could be rounded down to 3.5 or up to 4
- %res = call i4 @llvm.umul.fix.i4(i4 15, i4 1, i32 1) ; %res = 7 (or 8) (7.5 x 0.5 = 3.75)
+#### '`llvm.smul.fix.sat.*`' Intrinsics
+##### Syntax
-'``llvm.smul.fix.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.smul.fix.sat``
+This is an overloaded intrinsic. You can use `llvm.smul.fix.sat`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.smul.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.smul.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.smul.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
- declare i16 @llvm.smul.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.smul.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.smul.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.smul.fix.sat``' family of intrinsic functions perform signed
+The '`llvm.smul.fix.sat`' family of intrinsic functions perform signed
fixed point saturating multiplication on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo signed fixed point multiplication. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point multiplication on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20299,62 +19111,55 @@ representable by the bit width of the first 2 arguments. The minimum value is th
smallest signed value representable by this bit width.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
- %res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
- %res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5)
+```llvm
+%res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
+%res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
+%res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5)
- ; The result in the following could be rounded up to -2 or down to -2.5
- %res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25)
+; The result in the following could be rounded up to -2 or down to -2.5
+%res = call i4 @llvm.smul.fix.sat.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25)
- ; Saturation
- %res = call i4 @llvm.smul.fix.sat.i4(i4 7, i4 2, i32 0) ; %res = 7
- %res = call i4 @llvm.smul.fix.sat.i4(i4 7, i4 4, i32 2) ; %res = 7
- %res = call i4 @llvm.smul.fix.sat.i4(i4 -8, i4 5, i32 2) ; %res = -8
- %res = call i4 @llvm.smul.fix.sat.i4(i4 -8, i4 -2, i32 1) ; %res = 7
+; Saturation
+%res = call i4 @llvm.smul.fix.sat.i4(i4 7, i4 2, i32 0) ; %res = 7
+%res = call i4 @llvm.smul.fix.sat.i4(i4 7, i4 4, i32 2) ; %res = 7
+%res = call i4 @llvm.smul.fix.sat.i4(i4 -8, i4 5, i32 2) ; %res = -8
+%res = call i4 @llvm.smul.fix.sat.i4(i4 -8, i4 -2, i32 1) ; %res = 7
- ; Scale can affect the saturation result
- %res = call i4 @llvm.smul.fix.sat.i4(i4 2, i4 4, i32 0) ; %res = 7 (2 x 4 -> clamped to 7)
- %res = call i4 @llvm.smul.fix.sat.i4(i4 2, i4 4, i32 1) ; %res = 4 (1 x 2 = 2)
+; Scale can affect the saturation result
+%res = call i4 @llvm.smul.fix.sat.i4(i4 2, i4 4, i32 0) ; %res = 7 (2 x 4 -> clamped to 7)
+%res = call i4 @llvm.smul.fix.sat.i4(i4 2, i4 4, i32 1) ; %res = 4 (1 x 2 = 2)
+```
+#### '`llvm.umul.fix.sat.*`' Intrinsics
-'``llvm.umul.fix.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.umul.fix.sat``
+This is an overloaded intrinsic. You can use `llvm.umul.fix.sat`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.umul.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.umul.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.umul.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.umul.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
+declare i16 @llvm.umul.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.umul.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.umul.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.umul.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.umul.fix.sat``' family of intrinsic functions perform unsigned
+The '`llvm.umul.fix.sat`' family of intrinsic functions perform unsigned
fixed point saturating multiplication on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo unsigned fixed point multiplication. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point multiplication on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20369,60 +19174,53 @@ representable by the bit width of the first 2 arguments. The minimum value is th
smallest unsigned value representable by this bit width (zero).
-Examples
-"""""""""
-
-.. code-block:: llvm
-
- %res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
- %res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
+##### Examples
- ; The result in the following could be rounded down to 2 or up to 2.5
- %res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 3, i32 1) ; %res = 4 (or 5) (1.5 x 1.5 = 2.25)
+```llvm
+%res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6)
+%res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5)
- ; Saturation
- %res = call i4 @llvm.umul.fix.sat.i4(i4 8, i4 2, i32 0) ; %res = 15 (8 x 2 -> clamped to 15)
- %res = call i4 @llvm.umul.fix.sat.i4(i4 8, i4 8, i32 2) ; %res = 15 (2 x 2 -> clamped to 3.75)
+; The result in the following could be rounded down to 2 or up to 2.5
+%res = call i4 @llvm.umul.fix.sat.i4(i4 3, i4 3, i32 1) ; %res = 4 (or 5) (1.5 x 1.5 = 2.25)
- ; Scale can affect the saturation result
- %res = call i4 @llvm.umul.fix.sat.i4(i4 2, i4 4, i32 0) ; %res = 7 (2 x 4 -> clamped to 7)
- %res = call i4 @llvm.umul.fix.sat.i4(i4 2, i4 4, i32 1) ; %res = 4 (1 x 2 = 2)
+; Saturation
+%res = call i4 @llvm.umul.fix.sat.i4(i4 8, i4 2, i32 0) ; %res = 15 (8 x 2 -> clamped to 15)
+%res = call i4 @llvm.umul.fix.sat.i4(i4 8, i4 8, i32 2) ; %res = 15 (2 x 2 -> clamped to 3.75)
+; Scale can affect the saturation result
+%res = call i4 @llvm.umul.fix.sat.i4(i4 2, i4 4, i32 0) ; %res = 7 (2 x 4 -> clamped to 7)
+%res = call i4 @llvm.umul.fix.sat.i4(i4 2, i4 4, i32 1) ; %res = 4 (1 x 2 = 2)
+```
-'``llvm.sdiv.fix.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.sdiv.fix.*`' Intrinsics
-Syntax
-"""""""
+##### Syntax
-This is an overloaded intrinsic. You can use ``llvm.sdiv.fix``
+This is an overloaded intrinsic. You can use `llvm.sdiv.fix`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.sdiv.fix.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.sdiv.fix.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.sdiv.fix.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.sdiv.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
- declare i16 @llvm.sdiv.fix.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.sdiv.fix.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.sdiv.fix.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.sdiv.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.sdiv.fix``' family of intrinsic functions perform signed
+The '`llvm.sdiv.fix`' family of intrinsic functions perform signed
fixed point division on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
width, but they must have the same bit width. The arguments may also work with
-int vectors of the same length and int size. ``%a`` and ``%b`` are the two
+int vectors of the same length and int size. `%a` and `%b` are the two
values that will undergo signed fixed point division. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point division on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20436,53 +19234,46 @@ It is undefined behavior if the result value does not fit within the range of
the fixed point type, or if the second argument is zero.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.sdiv.fix.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
- %res = call i4 @llvm.sdiv.fix.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
- %res = call i4 @llvm.sdiv.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 / -1 = -1.5)
+```llvm
+%res = call i4 @llvm.sdiv.fix.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
+%res = call i4 @llvm.sdiv.fix.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
+%res = call i4 @llvm.sdiv.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 / -1 = -1.5)
- ; The result in the following could be rounded up to 1 or down to 0.5
- %res = call i4 @llvm.sdiv.fix.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
+; The result in the following could be rounded up to 1 or down to 0.5
+%res = call i4 @llvm.sdiv.fix.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
+```
+#### '`llvm.udiv.fix.*`' Intrinsics
-'``llvm.udiv.fix.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.udiv.fix``
+This is an overloaded intrinsic. You can use `llvm.udiv.fix`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.udiv.fix.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.udiv.fix.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.udiv.fix.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.udiv.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
+declare i16 @llvm.udiv.fix.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.udiv.fix.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.udiv.fix.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.udiv.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.udiv.fix``' family of intrinsic functions perform unsigned
+The '`llvm.udiv.fix`' family of intrinsic functions perform unsigned
fixed point division on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
width, but they must have the same bit width. The arguments may also work with
-int vectors of the same length and int size. ``%a`` and ``%b`` are the two
+int vectors of the same length and int size. `%a` and `%b` are the two
values that will undergo unsigned fixed point division. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point division on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20496,52 +19287,45 @@ It is undefined behavior if the result value does not fit within the range of
the fixed point type, or if the second argument is zero.
-Examples
-"""""""""
+##### Examples
-.. code-block:: llvm
+```llvm
+%res = call i4 @llvm.udiv.fix.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
+%res = call i4 @llvm.udiv.fix.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
+%res = call i4 @llvm.udiv.fix.i4(i4 1, i4 -8, i32 4) ; %res = 2 (0.0625 / 0.5 = 0.125)
- %res = call i4 @llvm.udiv.fix.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
- %res = call i4 @llvm.udiv.fix.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
- %res = call i4 @llvm.udiv.fix.i4(i4 1, i4 -8, i32 4) ; %res = 2 (0.0625 / 0.5 = 0.125)
+; The result in the following could be rounded up to 1 or down to 0.5
+%res = call i4 @llvm.udiv.fix.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
+```
- ; The result in the following could be rounded up to 1 or down to 0.5
- %res = call i4 @llvm.udiv.fix.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
+#### '`llvm.sdiv.fix.sat.*`' Intrinsics
+##### Syntax
-'``llvm.sdiv.fix.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.sdiv.fix.sat``
+This is an overloaded intrinsic. You can use `llvm.sdiv.fix.sat`
on any integer bit width or vectors of integers.
-::
+```
+declare i16 @llvm.sdiv.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.sdiv.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.sdiv.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.sdiv.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
- declare i16 @llvm.sdiv.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.sdiv.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.sdiv.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.sdiv.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+##### Overview
-Overview
-"""""""""
-
-The '``llvm.sdiv.fix.sat``' family of intrinsic functions perform signed
+The '`llvm.sdiv.fix.sat`' family of intrinsic functions perform signed
fixed point saturating division on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo signed fixed point division. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point division on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20558,57 +19342,50 @@ smallest signed value representable by this bit width.
It is undefined behavior if the second argument is zero.
-Examples
-"""""""""
-
-.. code-block:: llvm
+##### Examples
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 / -1 = -1.5)
+```llvm
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 / -1 = -1.5)
- ; The result in the following could be rounded up to 1 or down to 0.5
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
+; The result in the following could be rounded up to 1 or down to 0.5
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 3, i4 4, i32 1) ; %res = 2 (or 1) (1.5 / 2 = 0.75)
- ; Saturation
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 -8, i4 -1, i32 0) ; %res = 7 (-8 / -1 = 8 => 7)
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 4, i4 2, i32 2) ; %res = 7 (1 / 0.5 = 2 => 1.75)
- %res = call i4 @llvm.sdiv.fix.sat.i4(i4 -4, i4 1, i32 2) ; %res = -8 (-1 / 0.25 = -4 => -2)
+; Saturation
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 -8, i4 -1, i32 0) ; %res = 7 (-8 / -1 = 8 => 7)
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 4, i4 2, i32 2) ; %res = 7 (1 / 0.5 = 2 => 1.75)
+%res = call i4 @llvm.sdiv.fix.sat.i4(i4 -4, i4 1, i32 2) ; %res = -8 (-1 / 0.25 = -4 => -2)
+```
+#### '`llvm.udiv.fix.sat.*`' Intrinsics
-'``llvm.udiv.fix.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax
-Syntax
-"""""""
-
-This is an overloaded intrinsic. You can use ``llvm.udiv.fix.sat``
+This is an overloaded intrinsic. You can use `llvm.udiv.fix.sat`
on any integer bit width or vectors of integers.
-::
-
- declare i16 @llvm.udiv.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
- declare i32 @llvm.udiv.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
- declare i64 @llvm.udiv.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
- declare <4 x i32> @llvm.udiv.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
+declare i16 @llvm.udiv.fix.sat.i16(i16 %a, i16 %b, i32 %scale)
+declare i32 @llvm.udiv.fix.sat.i32(i32 %a, i32 %b, i32 %scale)
+declare i64 @llvm.udiv.fix.sat.i64(i64 %a, i64 %b, i32 %scale)
+declare <4 x i32> @llvm.udiv.fix.sat.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale)
+```
-Overview
-"""""""""
+##### Overview
-The '``llvm.udiv.fix.sat``' family of intrinsic functions perform unsigned
+The '`llvm.udiv.fix.sat`' family of intrinsic functions perform unsigned
fixed point saturating division on 2 arguments of the same scale.
-Arguments
-""""""""""
+##### Arguments
The arguments (%a and %b) and the result may be of integer types of any bit
-width, but they must have the same bit width. ``%a`` and ``%b`` are the two
+width, but they must have the same bit width. `%a` and `%b` are the two
values that will undergo unsigned fixed point division. The argument
-``%scale`` represents the scale of both operands, and must be a constant
+`%scale` represents the scale of both operands, and must be a constant
integer.
-Semantics:
-""""""""""
+##### Semantics:
This operation performs fixed point division on the 2 arguments of a
specified scale. The result will also be returned in the same scale specified
@@ -20624,50 +19401,44 @@ smallest unsigned value representable by this bit width (zero).
It is undefined behavior if the second argument is zero.
-Examples
-"""""""""
-
-.. code-block:: llvm
-
- %res = call i4 @llvm.udiv.fix.sat.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
- %res = call i4 @llvm.udiv.fix.sat.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
+##### Examples
- ; The result in the following could be rounded down to 0.5 or up to 1
- %res = call i4 @llvm.udiv.fix.sat.i4(i4 3, i4 4, i32 1) ; %res = 1 (or 2) (1.5 / 2 = 0.75)
+```llvm
+%res = call i4 @llvm.udiv.fix.sat.i4(i4 6, i4 2, i32 0) ; %res = 3 (6 / 2 = 3)
+%res = call i4 @llvm.udiv.fix.sat.i4(i4 6, i4 4, i32 1) ; %res = 3 (3 / 2 = 1.5)
- ; Saturation
- %res = call i4 @llvm.udiv.fix.sat.i4(i4 8, i4 2, i32 2) ; %res = 15 (2 / 0.5 = 4 => 3.75)
+; The result in the following could be rounded down to 0.5 or up to 1
+%res = call i4 @llvm.udiv.fix.sat.i4(i4 3, i4 4, i32 1) ; %res = 1 (or 2) (1.5 / 2 = 0.75)
+; Saturation
+%res = call i4 @llvm.udiv.fix.sat.i4(i4 8, i4 2, i32 2) ; %res = 15 (2 / 0.5 = 4 => 3.75)
+```
-Specialized Arithmetic Intrinsics
----------------------------------
+### Specialized Arithmetic Intrinsics
-.. _i_intr_llvm_canonicalize:
+(i_intr_llvm_canonicalize)=
-'``llvm.canonicalize.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.canonicalize.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare float @llvm.canonicalize.f32(float %a)
- declare double @llvm.canonicalize.f64(double %b)
+```
+declare float @llvm.canonicalize.f32(float %a)
+declare double @llvm.canonicalize.f64(double %b)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.canonicalize.*``' intrinsic returns the platform-specific canonical
+The '`llvm.canonicalize.*`' intrinsic returns the platform-specific canonical
encoding of a floating-point number. This canonicalization is useful for
implementing certain numeric primitives such as frexp. The canonical encoding is
defined by IEEE 754-2008 to be:
-::
-
- 2.1.8 canonical encoding: The preferred encoding of a floating-point
- representation in a format. Applied to declets, significands of finite
- numbers, infinities, and NaNs, especially in decimal formats.
+```
+2.1.8 canonical encoding: The preferred encoding of a floating-point
+representation in a format. Applied to declets, significands of finite
+numbers, infinities, and NaNs, especially in decimal formats.
+```
This operation can also be considered equivalent to the IEEE 754-2008
conversion of a floating-point value to the same format. NaNs are handled
@@ -20689,17 +19460,17 @@ quiet NaN result.
This function should always be implementable as multiplication by 1.0, provided
that the compiler does not constant fold the operation. Likewise, division by
-1.0 and ``llvm.minnum(x, x)`` are possible implementations. Addition with
+1.0 and `llvm.minnum(x, x)` are possible implementations. Addition with
-0.0 is also sufficient provided that the rounding mode is not -Infinity.
-``@llvm.canonicalize`` must preserve the equality relation. That is:
+`@llvm.canonicalize` must preserve the equality relation. That is:
-- ``(@llvm.canonicalize(x) == x)`` is equivalent to ``(x == x)``
-- ``(@llvm.canonicalize(x) == @llvm.canonicalize(y))`` is equivalent
- to ``(x == y)``
+- `(@llvm.canonicalize(x) == x)` is equivalent to `(x == x)`
+- `(@llvm.canonicalize(x) == @llvm.canonicalize(y))` is equivalent
+ to `(x == y)`
Additionally, the sign of zero must be conserved:
-``@llvm.canonicalize(-0.0) = -0.0`` and ``@llvm.canonicalize(+0.0) = +0.0``
+`@llvm.canonicalize(-0.0) = -0.0` and `@llvm.canonicalize(+0.0) = +0.0`
The payload bits of a NaN must be conserved, with two exceptions.
First, environments which use only a single canonical representation of NaN
@@ -20713,60 +19484,52 @@ The canonicalization operation may be optimized away if:
- The result is consumed only by (or fused with) other floating-point
operations. That is, the bits of the floating-point value are not examined.
-.. _int_fmuladd:
-
-'``llvm.fmuladd.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_fmuladd)=
-Syntax:
-"""""""
+#### '`llvm.fmuladd.*`' Intrinsic
-::
+##### Syntax:
- declare float @llvm.fmuladd.f32(float %a, float %b, float %c)
- declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
+```
+declare float @llvm.fmuladd.f32(float %a, float %b, float %c)
+declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fmuladd.*``' intrinsic functions represent multiply-add
+The '`llvm.fmuladd.*`' intrinsic functions represent multiply-add
expressions that can be fused if the code generator determines that (a) the
target instruction set has support for a fused operation, and (b) that the
fused operation is more efficient than the equivalent, separate pair of mul
and add instructions.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.fmuladd.*``' intrinsics each take three arguments: two
+The '`llvm.fmuladd.*`' intrinsics each take three arguments: two
multiplicands, a and b, and an addend c.
-Semantics:
-""""""""""
+##### Semantics:
The expression:
-::
-
- %0 = call float @llvm.fmuladd.f32(%a, %b, %c)
+```
+%0 = call float @llvm.fmuladd.f32(%a, %b, %c)
+```
is equivalent to the expression a \* b + c, except that it is unspecified
whether rounding will be performed between the multiplication and addition
steps. Fusion is not guaranteed, even if the target platform supports it.
If a fused multiply-add is required, the corresponding
-:ref:`llvm.fma <int_fma>` intrinsic function should be used instead.
-This never sets errno, just as '``llvm.fma.*``'.
-
-Examples:
-"""""""""
+{ref}`llvm.fma <int_fma>` intrinsic function should be used instead.
+This never sets errno, just as '`llvm.fma.*`'.
-.. code-block:: llvm
+##### Examples:
- %r2 = call float @llvm.fmuladd.f32(float %a, float %b, float %c) ; yields float:r2 = (a * b) + c
+```llvm
+%r2 = call float @llvm.fmuladd.f32(float %a, float %b, float %c) ; yields float:r2 = (a * b) + c
+```
-
-Hardware-Loop Intrinsics
-------------------------
+### Hardware-Loop Intrinsics
LLVM support several intrinsics to mark a loop as a hardware-loop. They are
hints to the backend which are required to lower these intrinsics further to target
@@ -20778,150 +19541,130 @@ outside the backend. Thus, front-end and mid-level optimizations should not be
generating these intrinsics.
-'``llvm.set.loop.iterations.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.set.loop.iterations.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare void @llvm.set.loop.iterations.i32(i32)
+declare void @llvm.set.loop.iterations.i64(i64)
+```
- declare void @llvm.set.loop.iterations.i32(i32)
- declare void @llvm.set.loop.iterations.i64(i64)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.set.loop.iterations.*``' intrinsics are used to specify the
+The '`llvm.set.loop.iterations.*`' intrinsics are used to specify the
hardware-loop trip count. They are placed in the loop preheader basic block and
-are marked as ``IntrNoDuplicate`` to avoid optimizers duplicating these
+are marked as `IntrNoDuplicate` to avoid optimizers duplicating these
instructions.
-Arguments:
-""""""""""
+##### Arguments:
The integer operand is the loop trip count of the hardware-loop, and thus
not e.g., the loop back-edge taken count.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.set.loop.iterations.*``' intrinsics do not perform any arithmetic
+The '`llvm.set.loop.iterations.*`' intrinsics do not perform any arithmetic
on their operand. It's a hint to the backend that can use this to set up the
hardware-loop count with a target-specific instruction, usually a move of this
value to a special register or a hardware-loop instruction.
-'``llvm.start.loop.iterations.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.start.loop.iterations.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.start.loop.iterations.i32(i32)
+declare i64 @llvm.start.loop.iterations.i64(i64)
+```
- declare i32 @llvm.start.loop.iterations.i32(i32)
- declare i64 @llvm.start.loop.iterations.i64(i64)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.start.loop.iterations.*``' intrinsics are similar to the
-'``llvm.set.loop.iterations.*``' intrinsics, used to specify the
+The '`llvm.start.loop.iterations.*`' intrinsics are similar to the
+'`llvm.set.loop.iterations.*`' intrinsics, used to specify the
hardware-loop trip count but also produce a value identical to the input
that can be used as the input to the loop. They are placed in the loop
preheader basic block and the output is expected to be the input to the
phi for the induction variable of the loop, decremented by the
-'``llvm.loop.decrement.reg.*``'.
+'`llvm.loop.decrement.reg.*`'.
-Arguments:
-""""""""""
+##### Arguments:
The integer operand is the loop trip count of the hardware-loop, and thus
not e.g., the loop back-edge taken count.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.start.loop.iterations.*``' intrinsics do not perform any arithmetic
+The '`llvm.start.loop.iterations.*`' intrinsics do not perform any arithmetic
on their operand. It's a hint to the backend that can use this to set up the
hardware-loop count with a target-specific instruction, usually a move of this
value to a special register or a hardware-loop instruction.
-'``llvm.test.set.loop.iterations.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.test.set.loop.iterations.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i1 @llvm.test.set.loop.iterations.i32(i32)
+declare i1 @llvm.test.set.loop.iterations.i64(i64)
+```
- declare i1 @llvm.test.set.loop.iterations.i32(i32)
- declare i1 @llvm.test.set.loop.iterations.i64(i64)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.test.set.loop.iterations.*``' intrinsics are used to specify the
+The '`llvm.test.set.loop.iterations.*`' intrinsics are used to specify the
the loop trip count, and also test that the given count is not zero, allowing
it to control entry to a while-loop. They are placed in the loop preheader's
-predecessor basic block, and are marked as ``IntrNoDuplicate`` to avoid
+predecessor basic block, and are marked as `IntrNoDuplicate` to avoid
optimizers duplicating these instructions.
-Arguments:
-""""""""""
+##### Arguments:
The integer operand is the loop trip count of the hardware-loop, and thus
not e.g., the loop back-edge taken count.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.test.set.loop.iterations.*``' intrinsics do not perform any
+The '`llvm.test.set.loop.iterations.*`' intrinsics do not perform any
arithmetic on their operand. It's a hint to the backend that can use this to
set up the hardware-loop count with a target-specific instruction, usually a
move of this value to a special register or a hardware-loop instruction.
The result is the conditional value of whether the given count is not zero.
-'``llvm.test.start.loop.iterations.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.test.start.loop.iterations.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare {i32, i1} @llvm.test.start.loop.iterations.i32(i32)
+declare {i64, i1} @llvm.test.start.loop.iterations.i64(i64)
+```
- declare {i32, i1} @llvm.test.start.loop.iterations.i32(i32)
- declare {i64, i1} @llvm.test.start.loop.iterations.i64(i64)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.test.start.loop.iterations.*``' intrinsics are similar to the
-'``llvm.test.set.loop.iterations.*``' and '``llvm.start.loop.iterations.*``'
+The '`llvm.test.start.loop.iterations.*`' intrinsics are similar to the
+'`llvm.test.set.loop.iterations.*`' and '`llvm.start.loop.iterations.*`'
intrinsics, used to specify the hardware-loop trip count, but also produce a
value identical to the input that can be used as the input to the loop. The
second i1 output controls entry to a while-loop.
-Arguments:
-""""""""""
+##### Arguments:
The integer operand is the loop trip count of the hardware-loop, and thus
not e.g., the loop back-edge taken count.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.test.start.loop.iterations.*``' intrinsics do not perform any
+The '`llvm.test.start.loop.iterations.*`' intrinsics do not perform any
arithmetic on their operand. It's a hint to the backend that can use this to
set up the hardware-loop count with a target-specific instruction, usually a
move of this value to a special register or a hardware-loop instruction.
@@ -20929,135 +19672,117 @@ The result is a pair of the input and a conditional value of whether the
given count is not zero.
-'``llvm.loop.decrement.reg.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.decrement.reg.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.loop.decrement.reg.i32(i32, i32)
+declare i64 @llvm.loop.decrement.reg.i64(i64, i64)
+```
- declare i32 @llvm.loop.decrement.reg.i32(i32, i32)
- declare i64 @llvm.loop.decrement.reg.i64(i64, i64)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.loop.decrement.reg.*``' intrinsics are used to lower the loop
+The '`llvm.loop.decrement.reg.*`' intrinsics are used to lower the loop
iteration counter and return an updated value that will be used in the next
loop test check.
-Arguments:
-""""""""""
+##### Arguments:
Both arguments must have identical integer types. The first operand is the
loop iteration counter. The second operand is the maximum number of elements
processed in an iteration.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.loop.decrement.reg.*``' intrinsics do an integer ``SUB`` of its
+The '`llvm.loop.decrement.reg.*`' intrinsics do an integer `SUB` of its
two operands, which is not allowed to wrap. They return the remaining number of
-iterations still to be executed, and can be used together with a ``PHI``,
-``ICMP`` and ``BR`` to control the number of loop iterations executed. Any
-optimizations are allowed to treat it is a ``SUB``, and it is supported by
+iterations still to be executed, and can be used together with a `PHI`,
+`ICMP` and `BR` to control the number of loop iterations executed. Any
+optimizations are allowed to treat it is a `SUB`, and it is supported by
SCEV, so it's the backends responsibility to handle cases where it may be
-optimized. These intrinsics are marked as ``IntrNoDuplicate`` to avoid
+optimized. These intrinsics are marked as `IntrNoDuplicate` to avoid
optimizers duplicating these instructions.
-'``llvm.loop.decrement.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.loop.decrement.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i1 @llvm.loop.decrement.i32(i32)
+declare i1 @llvm.loop.decrement.i64(i64)
+```
- declare i1 @llvm.loop.decrement.i32(i32)
- declare i1 @llvm.loop.decrement.i64(i64)
-
-Overview:
-"""""""""
+##### Overview:
The HardwareLoops pass allows the loop decrement value to be specified with an
option. It defaults to a loop decrement value of 1, but it can be an unsigned
-integer value provided by this option. The '``llvm.loop.decrement.*``'
+integer value provided by this option. The '`llvm.loop.decrement.*`'
intrinsics decrement the loop iteration counter with this value, and return a
false predicate if the loop should exit, and true otherwise.
-This is emitted if the loop counter is not updated via a ``PHI`` node, which
+This is emitted if the loop counter is not updated via a `PHI` node, which
can also be controlled with an option.
-Arguments:
-""""""""""
+##### Arguments:
The integer argument is the loop decrement value used to decrement the loop
iteration counter.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.loop.decrement.*``' intrinsics do a ``SUB`` of the loop iteration
+The '`llvm.loop.decrement.*`' intrinsics do a `SUB` of the loop iteration
counter with the given loop decrement value, and return false if the loop
-should exit, this ``SUB`` is not allowed to wrap. The result is a condition
+should exit, this `SUB` is not allowed to wrap. The result is a condition
that is used by the conditional branch controlling the loop.
-Vector Reduction Intrinsics
----------------------------
+### Vector Reduction Intrinsics
Horizontal reductions of vectors can be expressed using the following
intrinsics. Each one takes a vector operand as an input and applies its
respective operation across all elements of the vector, returning a single
scalar result of the same element type.
-.. _int_vector_reduce_add:
-
-'``llvm.vector.reduce.add.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_vector_reduce_add)=
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.add.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %a)
- declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %a)
+```
+declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %a)
+declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.add.*``' intrinsics do an integer ``ADD``
+The '`llvm.vector.reduce.add.*`' intrinsics do an integer `ADD`
reduction of a vector, returning the result as a scalar. The return type matches
the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_fadd:
-
-'``llvm.vector.reduce.fadd.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_vector_reduce_fadd)=
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.fadd.*`' Intrinsic
-::
+##### Syntax:
- declare float @llvm.vector.reduce.fadd.v4f32(float %start_value, <4 x float> %a)
- declare double @llvm.vector.reduce.fadd.v2f64(double %start_value, <2 x double> %a)
+```
+declare float @llvm.vector.reduce.fadd.v4f32(float %start_value, <4 x float> %a)
+declare double @llvm.vector.reduce.fadd.v2f64(double %start_value, <2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fadd.*``' intrinsics do a floating-point
-``ADD`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fadd.*`' intrinsics do a floating-point
+`ADD` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
If the intrinsic call has the 'reassoc' flag set, then the reduction will not
@@ -21067,75 +19792,64 @@ the associativity of a scalarized reduction. That is, the reduction begins with
the start value and performs an fadd operation with consecutively increasing
vector element indices. See the following pseudocode:
-::
-
- float sequential_fadd(start_value, input_vector)
- result = start_value
- for i = 0 to length(input_vector)
- result = result + input_vector[i]
- return result
+```
+float sequential_fadd(start_value, input_vector)
+ result = start_value
+ for i = 0 to length(input_vector)
+ result = result + input_vector[i]
+ return result
+```
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument to this intrinsic is a scalar start value for the reduction.
The type of the start value matches the element-type of the vector input.
The second argument must be a vector of floating-point values.
-To ignore the start value, negative zero (``-0.0``) can be used, as it is
+To ignore the start value, negative zero (`-0.0`) can be used, as it is
the neutral value of floating point addition.
-Examples:
-"""""""""
-
-::
-
- %unord = call reassoc float @llvm.vector.reduce.fadd.v4f32(float -0.0, <4 x float> %input) ; relaxed reduction
- %ord = call float @llvm.vector.reduce.fadd.v4f32(float %start_value, <4 x float> %input) ; sequential reduction
+##### Examples:
+```
+%unord = call reassoc float @llvm.vector.reduce.fadd.v4f32(float -0.0, <4 x float> %input) ; relaxed reduction
+%ord = call float @llvm.vector.reduce.fadd.v4f32(float %start_value, <4 x float> %input) ; sequential reduction
+```
-.. _int_vector_reduce_mul:
+(int_vector_reduce_mul)=
-'``llvm.vector.reduce.mul.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.mul.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %a)
- declare i64 @llvm.vector.reduce.mul.v2i64(<2 x i64> %a)
+```
+declare i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %a)
+declare i64 @llvm.vector.reduce.mul.v2i64(<2 x i64> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.mul.*``' intrinsics do an integer ``MUL``
+The '`llvm.vector.reduce.mul.*`' intrinsics do an integer `MUL`
reduction of a vector, returning the result as a scalar. The return type matches
the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_fmul:
+(int_vector_reduce_fmul)=
-'``llvm.vector.reduce.fmul.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.fmul.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare float @llvm.vector.reduce.fmul.v4f32(float %start_value, <4 x float> %a)
- declare double @llvm.vector.reduce.fmul.v2f64(double %start_value, <2 x double> %a)
+```
+declare float @llvm.vector.reduce.fmul.v4f32(float %start_value, <4 x float> %a)
+declare double @llvm.vector.reduce.fmul.v2f64(double %start_value, <2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fmul.*``' intrinsics do a floating-point
-``MUL`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fmul.*`' intrinsics do a floating-point
+`MUL` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
If the intrinsic call has the 'reassoc' flag set, then the reduction will not
@@ -21145,322 +19859,274 @@ the associativity of a scalarized reduction. That is, the reduction begins with
the start value and performs an fmul operation with consecutively increasing
vector element indices. See the following pseudocode:
-::
-
- float sequential_fmul(start_value, input_vector)
- result = start_value
- for i = 0 to length(input_vector)
- result = result * input_vector[i]
- return result
-
+```
+float sequential_fmul(start_value, input_vector)
+ result = start_value
+ for i = 0 to length(input_vector)
+ result = result * input_vector[i]
+ return result
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument to this intrinsic is a scalar start value for the reduction.
The type of the start value matches the element-type of the vector input.
The second argument must be a vector of floating-point values.
-To ignore the start value, one (``1.0``) can be used, as it is the neutral
+To ignore the start value, one (`1.0`) can be used, as it is the neutral
value of floating point multiplication.
-Examples:
-"""""""""
-
-::
+##### Examples:
- %unord = call reassoc float @llvm.vector.reduce.fmul.v4f32(float 1.0, <4 x float> %input) ; relaxed reduction
- %ord = call float @llvm.vector.reduce.fmul.v4f32(float %start_value, <4 x float> %input) ; sequential reduction
+```
+%unord = call reassoc float @llvm.vector.reduce.fmul.v4f32(float 1.0, <4 x float> %input) ; relaxed reduction
+%ord = call float @llvm.vector.reduce.fmul.v4f32(float %start_value, <4 x float> %input) ; sequential reduction
+```
-.. _int_vector_reduce_and:
+(int_vector_reduce_and)=
-'``llvm.vector.reduce.and.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.and.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.and.*``' intrinsics do a bitwise ``AND``
+The '`llvm.vector.reduce.and.*`' intrinsics do a bitwise `AND`
reduction of a vector, returning the result as a scalar. The return type matches
the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_or:
+(int_vector_reduce_or)=
-'``llvm.vector.reduce.or.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.or.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.or.*``' intrinsics do a bitwise ``OR`` reduction
+The '`llvm.vector.reduce.or.*`' intrinsics do a bitwise `OR` reduction
of a vector, returning the result as a scalar. The return type matches the
element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_xor:
+(int_vector_reduce_xor)=
-'``llvm.vector.reduce.xor.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.xor.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.xor.*``' intrinsics do a bitwise ``XOR``
+The '`llvm.vector.reduce.xor.*`' intrinsics do a bitwise `XOR`
reduction of a vector, returning the result as a scalar. The return type matches
the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_smax:
+(int_vector_reduce_smax)=
-'``llvm.vector.reduce.smax.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.smax.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.smax.*``' intrinsics do a signed integer
-``MAX`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.smax.*`' intrinsics do a signed integer
+`MAX` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_smin:
+(int_vector_reduce_smin)=
-'``llvm.vector.reduce.smin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.smin.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.smin.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.smin.*``' intrinsics do a signed integer
-``MIN`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.smin.*`' intrinsics do a signed integer
+`MIN` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_umax:
+(int_vector_reduce_umax)=
-'``llvm.vector.reduce.umax.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.umax.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.umax.*``' intrinsics do an unsigned
-integer ``MAX`` reduction of a vector, returning the result as a scalar. The
+The '`llvm.vector.reduce.umax.*`' intrinsics do an unsigned
+integer `MAX` reduction of a vector, returning the result as a scalar. The
return type matches the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_umin:
+(int_vector_reduce_umin)=
-'``llvm.vector.reduce.umin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.vector.reduce.umin.*`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> %a)
+```
+declare i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.umin.*``' intrinsics do an unsigned
-integer ``MIN`` reduction of a vector, returning the result as a scalar. The
+The '`llvm.vector.reduce.umin.*`' intrinsics do an unsigned
+integer `MIN` reduction of a vector, returning the result as a scalar. The
return type matches the element-type of the vector input.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of integer values.
-.. _int_vector_reduce_fmax:
+(int_vector_reduce_fmax)=
-'``llvm.vector.reduce.fmax.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.fmax.*`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare float @llvm.vector.reduce.fmax.v4f32(<4 x float> %a)
- declare double @llvm.vector.reduce.fmax.v2f64(<2 x double> %a)
+```
+declare float @llvm.vector.reduce.fmax.v4f32(<4 x float> %a)
+declare double @llvm.vector.reduce.fmax.v2f64(<2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fmax.*``' intrinsics do a floating-point
-``MAX`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fmax.*`' intrinsics do a floating-point
+`MAX` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-This instruction has the same comparison and ``nsz`` semantics as the
-'``llvm.maxnum.*``' intrinsic.
+This instruction has the same comparison and `nsz` semantics as the
+'`llvm.maxnum.*`' intrinsic.
The reduction is performed in a non-deterministic order. This is only observable
if one of the inputs is a signaling NaN.
-For example, if a reduction is performed over ``<sNaN, 0.0, 1.0>``, then all of
-:ref:`NaN <floatnan>`, ``0.0`` and ``1.0`` are possible results, depending on
+For example, if a reduction is performed over `<sNaN, 0.0, 1.0>`, then all of
+{ref}`NaN <floatnan>`, `0.0` and `1.0` are possible results, depending on
which order is picked.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of floating-point values.
-.. _int_vector_reduce_fmin:
+(int_vector_reduce_fmin)=
-'``llvm.vector.reduce.fmin.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.fmin.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare float @llvm.vector.reduce.fmin.v4f32(<4 x float> %a)
- declare double @llvm.vector.reduce.fmin.v2f64(<2 x double> %a)
+```
+declare float @llvm.vector.reduce.fmin.v4f32(<4 x float> %a)
+declare double @llvm.vector.reduce.fmin.v2f64(<2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fmin.*``' intrinsics do a floating-point
-``MIN`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fmin.*`' intrinsics do a floating-point
+`MIN` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-This instruction has the same comparison and ``nsz`` semantics as the
-'``llvm.minnum.*``' intrinsic.
+This instruction has the same comparison and `nsz` semantics as the
+'`llvm.minnum.*`' intrinsic.
The reduction is performed in a non-deterministic order. This is only observable
if one of the inputs is a signaling NaN.
-For example, if a reduction is performed over ``<sNaN, 0.0, 1.0>``, then all of
-:ref:`NaN <floatnan>`, ``0.0`` and ``1.0`` are possible results, depending on
+For example, if a reduction is performed over `<sNaN, 0.0, 1.0>`, then all of
+{ref}`NaN <floatnan>`, `0.0` and `1.0` are possible results, depending on
which order is picked.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of floating-point values.
-.. _int_vector_reduce_fmaximum:
+(int_vector_reduce_fmaximum)=
-'``llvm.vector.reduce.fmaximum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.fmaximum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare float @llvm.vector.reduce.fmaximum.v4f32(<4 x float> %a)
- declare double @llvm.vector.reduce.fmaximum.v2f64(<2 x double> %a)
+```
+declare float @llvm.vector.reduce.fmaximum.v4f32(<4 x float> %a)
+declare double @llvm.vector.reduce.fmaximum.v2f64(<2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fmaximum.*``' intrinsics do a floating-point
-``MAX`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fmaximum.*`' intrinsics do a floating-point
+`MAX` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-This instruction has the same comparison semantics as the '``llvm.maximum.*``'
+This instruction has the same comparison semantics as the '`llvm.maximum.*`'
intrinsic. That is, this intrinsic propagates NaNs and +0.0 is considered
greater than -0.0. If any element of the vector is a NaN, the result is NaN.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of floating-point values.
-.. _int_vector_reduce_fminimum:
+(int_vector_reduce_fminimum)=
-'``llvm.vector.reduce.fminimum.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reduce.fminimum.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %a)
- declare double @llvm.vector.reduce.fminimum.v2f64(<2 x double> %a)
+```
+declare float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %a)
+declare double @llvm.vector.reduce.fminimum.v2f64(<2 x double> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reduce.fminimum.*``' intrinsics do a floating-point
-``MIN`` reduction of a vector, returning the result as a scalar. The return type
+The '`llvm.vector.reduce.fminimum.*`' intrinsics do a floating-point
+`MIN` reduction of a vector, returning the result as a scalar. The return type
matches the element-type of the vector input.
-This instruction has the same comparison semantics as the '``llvm.minimum.*``'
+This instruction has the same comparison semantics as the '`llvm.minimum.*`'
intrinsic. That is, this intrinsic propagates NaNs and -0.0 is considered less
than +0.0. If any element of the vector is a NaN, the result is NaN.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector of floating-point values.
-Vector Partial Reduction Intrinsics
------------------------------------
+### Vector Partial Reduction Intrinsics
Partial reductions of vectors can be expressed using the intrinsics described in
this section. Each one reduces the concatenation of the two vector arguments
@@ -21479,50 +20145,43 @@ result.
By avoiding the introduction of new ordering constraints, these intrinsics
enhance the ability to leverage a target's accumulation instructions.
-'``llvm.vector.partial.reduce.add.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.partial.reduce.add.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <4 x i32> @llvm.vector.partial.reduce.add.v4i32.v4i32.v8i32(<4 x i32> %a, <8 x i32> %b)
- declare <4 x i32> @llvm.vector.partial.reduce.add.v4i32.v4i32.v16i32(<4 x i32> %a, <16 x i32> %b)
- declare <vscale x 4 x i32> @llvm.vector.partial.reduce.add.nxv4i32.nxv4i32.nxv8i32(<vscale x 4 x i32> %a, <vscale x 8 x i32> %b)
- declare <vscale x 4 x i32> @llvm.vector.partial.reduce.add.nxv4i32.nxv4i32.nxv16i32(<vscale x 4 x i32> %a, <vscale x 16 x i32> %b)
+```
+declare <4 x i32> @llvm.vector.partial.reduce.add.v4i32.v4i32.v8i32(<4 x i32> %a, <8 x i32> %b)
+declare <4 x i32> @llvm.vector.partial.reduce.add.v4i32.v4i32.v16i32(<4 x i32> %a, <16 x i32> %b)
+declare <vscale x 4 x i32> @llvm.vector.partial.reduce.add.nxv4i32.nxv4i32.nxv8i32(<vscale x 4 x i32> %a, <vscale x 8 x i32> %b)
+declare <vscale x 4 x i32> @llvm.vector.partial.reduce.add.nxv4i32.nxv4i32.nxv16i32(<vscale x 4 x i32> %a, <vscale x 16 x i32> %b)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is an integer vector with the same type as the result.
The second argument is a vector with a length that is a known integer multiple
of the result's type, while maintaining the same element type.
-'``llvm.vector.partial.reduce.fadd.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.partial.reduce.fadd.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <4 x f32> @llvm.vector.partial.reduce.fadd.v4f32.v8f32(<4 x f32> %a, <8 x f32> %b)
- declare <vscale x 4 x f32> @llvm.vector.partial.reduce.fadd.nxv4f32.nxv8f32(<vscale x 4 x f32> %a, <vscale x 8 x f32> %b)
+```
+declare <4 x f32> @llvm.vector.partial.reduce.fadd.v4f32.v8f32(<4 x f32> %a, <8 x f32> %b)
+declare <vscale x 4 x f32> @llvm.vector.partial.reduce.fadd.nxv4f32.nxv8f32(<vscale x 4 x f32> %a, <vscale x 8 x f32> %b)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point vector with the same type as the result.
The second argument is a vector with a length that is a known integer multiple
of the result's type, while maintaining the same element type.
-Semantics:
-""""""""""
+##### Semantics:
As the way in which the arguments to this floating-point intrinsic are reduced
is unspecified, this intrinsic will assume floating-point reassociation and
@@ -21530,32 +20189,28 @@ contraction can be leveraged to implement the reduction, which may result in
variations to the results due to reordering or by lowering to different
instructions (including combining multiple instructions into a single one).
-Vector Manipulation Intrinsics
-------------------------------
+### Vector Manipulation Intrinsics
-'``llvm.vector.insert``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.insert`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- ; Insert fixed type into scalable type
- declare <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v4f32(<vscale x 4 x float> %vec, <4 x float> %subvec, i64 <idx>)
- declare <vscale x 2 x double> @llvm.vector.insert.nxv2f64.v2f64(<vscale x 2 x double> %vec, <2 x double> %subvec, i64 <idx>)
+```
+; Insert fixed type into scalable type
+declare <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v4f32(<vscale x 4 x float> %vec, <4 x float> %subvec, i64 <idx>)
+declare <vscale x 2 x double> @llvm.vector.insert.nxv2f64.v2f64(<vscale x 2 x double> %vec, <2 x double> %subvec, i64 <idx>)
- ; Insert scalable type into scalable type
- declare <vscale x 4 x float> @llvm.vector.insert.nxv4f64.nxv2f64(<vscale x 4 x float> %vec, <vscale x 2 x float> %subvec, i64 <idx>)
+; Insert scalable type into scalable type
+declare <vscale x 4 x float> @llvm.vector.insert.nxv4f64.nxv2f64(<vscale x 4 x float> %vec, <vscale x 2 x float> %subvec, i64 <idx>)
- ; Insert fixed type into fixed type
- declare <4 x double> @llvm.vector.insert.v4f64.v2f64(<4 x double> %vec, <2 x double> %subvec, i64 <idx>)
+; Insert fixed type into fixed type
+declare <4 x double> @llvm.vector.insert.v4f64.v2f64(<4 x double> %vec, <2 x double> %subvec, i64 <idx>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.insert.*``' intrinsics insert a vector into another vector
+The '`llvm.vector.insert.*`' intrinsics insert a vector into another vector
starting from a given index. The return type matches the type of the vector we
insert into. Conceptually, this can be used to build a scalable vector out of
non-scalable vectors, however this intrinsic can also be used on purely fixed
@@ -21563,45 +20218,41 @@ types.
Scalable vectors can only be inserted into other scalable vectors.
-Arguments:
-""""""""""
+##### Arguments:
-The ``vec`` is the vector which ``subvec`` will be inserted into.
-The ``subvec`` is the vector that will be inserted.
+The `vec` is the vector which `subvec` will be inserted into.
+The `subvec` is the vector that will be inserted.
-``idx`` represents the starting element number at which ``subvec`` will be
-inserted. ``idx`` must be a constant multiple of ``subvec``'s known minimum
-vector length. If ``subvec`` is a scalable vector, ``idx`` is first scaled by
-the runtime scaling factor of ``subvec``. The elements of ``vec`` starting at
-``idx`` are overwritten with ``subvec``. Elements ``idx`` through (``idx`` +
-num_elements(``subvec``) - 1) must be valid ``vec`` indices. If this condition
+`idx` represents the starting element number at which `subvec` will be
+inserted. `idx` must be a constant multiple of `subvec`'s known minimum
+vector length. If `subvec` is a scalable vector, `idx` is first scaled by
+the runtime scaling factor of `subvec`. The elements of `vec` starting at
+`idx` are overwritten with `subvec`. Elements `idx` through (`idx` +
+num_elements(`subvec`) - 1) must be valid `vec` indices. If this condition
cannot be determined statically but is false at runtime, then the result vector
-is a :ref:`poison value <poisonvalues>`.
+is a {ref}`poison value <poisonvalues>`.
-'``llvm.vector.extract``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.extract`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- ; Extract fixed type from scalable type
- declare <4 x float> @llvm.vector.extract.v4f32.nxv4f32(<vscale x 4 x float> %vec, i64 <idx>)
- declare <2 x double> @llvm.vector.extract.v2f64.nxv2f64(<vscale x 2 x double> %vec, i64 <idx>)
+```
+; Extract fixed type from scalable type
+declare <4 x float> @llvm.vector.extract.v4f32.nxv4f32(<vscale x 4 x float> %vec, i64 <idx>)
+declare <2 x double> @llvm.vector.extract.v2f64.nxv2f64(<vscale x 2 x double> %vec, i64 <idx>)
- ; Extract scalable type from scalable type
- declare <vscale x 2 x float> @llvm.vector.extract.nxv2f32.nxv4f32(<vscale x 4 x float> %vec, i64 <idx>)
+; Extract scalable type from scalable type
+declare <vscale x 2 x float> @llvm.vector.extract.nxv2f32.nxv4f32(<vscale x 4 x float> %vec, i64 <idx>)
- ; Extract fixed type from fixed type
- declare <2 x double> @llvm.vector.extract.v2f64.v4f64(<4 x double> %vec, i64 <idx>)
+; Extract fixed type from fixed type
+declare <2 x double> @llvm.vector.extract.v2f64.v4f64(<4 x double> %vec, i64 <idx>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.extract.*``' intrinsics extract a vector from within another
+The '`llvm.vector.extract.*`' intrinsics extract a vector from within another
vector starting from a given index. The return type must be explicitly
specified. Conceptually, this can be used to decompose a scalable vector into
non-scalable parts, however this intrinsic can also be used on purely fixed
@@ -21609,37 +20260,33 @@ types.
Scalable vectors can only be extracted from other scalable vectors.
-Arguments:
-""""""""""
+##### Arguments:
-The ``vec`` is the vector from which we will extract a subvector.
+The `vec` is the vector from which we will extract a subvector.
-The ``idx`` specifies the starting element number within ``vec`` from which a
-subvector is extracted. ``idx`` must be a constant multiple of the known-minimum
+The `idx` specifies the starting element number within `vec` from which a
+subvector is extracted. `idx` must be a constant multiple of the known-minimum
vector length of the result type. If the result type is a scalable vector,
-``idx`` is first scaled by the result type's runtime scaling factor. Elements
-``idx`` through (``idx`` + num_elements(result_type) - 1) must be valid vector
+`idx` is first scaled by the result type's runtime scaling factor. Elements
+`idx` through (`idx` + num_elements(result_type) - 1) must be valid vector
indices. If this condition cannot be determined statically but is false at
-runtime, then the result vector is a :ref:`poison value <poisonvalues>`. The
-``idx`` parameter must be a vector index constant type (for most targets this
+runtime, then the result vector is a {ref}`poison value <poisonvalues>`. The
+`idx` parameter must be a vector index constant type (for most targets this
will be an integer pointer type).
-'``llvm.vector.reverse``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.reverse`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <2 x i8> @llvm.vector.reverse.v2i8(<2 x i8> %a)
- declare <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)
+```
+declare <2 x i8> @llvm.vector.reverse.v2i8(<2 x i8> %a)
+declare <vscale x 4 x i32> @llvm.vector.reverse.nxv4i32(<vscale x 4 x i32> %a)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.reverse.*``' intrinsics reverse a vector.
+The '`llvm.vector.reverse.*`' intrinsics reverse a vector.
The intrinsic takes a single vector and returns a vector of matching type but
with the original lane order reversed. These intrinsics work for both fixed
and scalable vectors. While this intrinsic supports all vector types
@@ -21647,30 +20294,26 @@ the recommended way to express this operation for fixed-width vectors is
still to use a shufflevector, as that may allow for more optimization
opportunities.
-Arguments:
-""""""""""
+##### Arguments:
The argument to this intrinsic must be a vector.
-'``llvm.vector.deinterleave2/3/4/5/6/7/8``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.deinterleave2/3/4/5/6/7/8`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare {<2 x double>, <2 x double>} @llvm.vector.deinterleave2.v4f64(<4 x double> %vec1)
- declare {<vscale x 4 x i32>, <vscale x 4 x i32>} @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %vec1)
- declare {<vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>} @llvm.vector.deinterleave3.nxv6i8(<vscale x 6 x i8> %vec1)
- declare {<2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>} @llvm.vector.deinterleave5.v10i32(<10 x i32> %vec1)
- declare {<2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>} @llvm.vector.deinterleave7.v14i32(<14 x i32> %vec1)
+```
+declare {<2 x double>, <2 x double>} @llvm.vector.deinterleave2.v4f64(<4 x double> %vec1)
+declare {<vscale x 4 x i32>, <vscale x 4 x i32>} @llvm.vector.deinterleave2.nxv8i32(<vscale x 8 x i32> %vec1)
+declare {<vscale x 2 x i8>, <vscale x 2 x i8>, <vscale x 2 x i8>} @llvm.vector.deinterleave3.nxv6i8(<vscale x 6 x i8> %vec1)
+declare {<2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>} @llvm.vector.deinterleave5.v10i32(<10 x i32> %vec1)
+declare {<2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32>} @llvm.vector.deinterleave7.v14i32(<14 x i32> %vec1)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.deinterleave2/3/4/5/6/7/8``' intrinsics deinterleave adjacent lanes
+The '`llvm.vector.deinterleave2/3/4/5/6/7/8`' intrinsics deinterleave adjacent lanes
into 2 through to 8 separate vectors, respectively, and return them as the
result.
@@ -21681,37 +20324,33 @@ may allow for more optimization opportunities.
For example:
-.. code-block:: text
+```text
+{<2 x i64>, <2 x i64>} llvm.vector.deinterleave2.v4i64(<4 x i64> <i64 0, i64 1, i64 2, i64 3>); ==> {<2 x i64> <i64 0, i64 2>, <2 x i64> <i64 1, i64 3>}
+{<2 x i32>, <2 x i32>, <2 x i32>} llvm.vector.deinterleave3.v6i32(<6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>)
+ ; ==> {<2 x i32> <i32 0, i32 3>, <2 x i32> <i32 1, i32 4>, <2 x i32> <i32 2, i32 5>}
+```
- {<2 x i64>, <2 x i64>} llvm.vector.deinterleave2.v4i64(<4 x i64> <i64 0, i64 1, i64 2, i64 3>); ==> {<2 x i64> <i64 0, i64 2>, <2 x i64> <i64 1, i64 3>}
- {<2 x i32>, <2 x i32>, <2 x i32>} llvm.vector.deinterleave3.v6i32(<6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>)
- ; ==> {<2 x i32> <i32 0, i32 3>, <2 x i32> <i32 1, i32 4>, <2 x i32> <i32 2, i32 5>}
-
-Arguments:
-""""""""""
+##### Arguments:
The argument is a vector whose type corresponds to the logical concatenation of
the aggregated result types.
-'``llvm.vector.interleave2/3/4/5/6/7/8``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.interleave2/3/4/5/6/7/8`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <4 x double> @llvm.vector.interleave2.v4f64(<2 x double> %vec1, <2 x double> %vec2)
+declare <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2)
+declare <vscale x 6 x i8> @llvm.vector.interleave3.nxv6i8(<vscale x 2 x i8> %vec0, <vscale x 2 x i8> %vec1, <vscale x 2 x i8> %vec2)
+declare <10 x i32> @llvm.vector.interleave5.v10i32(<2 x i32> %vec0, <2 x i32> %vec1, <2 x i32> %vec2, <2 x i32> %vec3, <2 x i32> %vec4)
+declare <14 x i32> @llvm.vector.interleave7.v14i32(<2 x i32> %vec0, <2 x i32> %vec1, <2 x i32> %vec2, <2 x i32> %vec3, <2 x i32> %vec4, <2 x i32> %vec5, <2 x i32> %vec6)
+```
- declare <4 x double> @llvm.vector.interleave2.v4f64(<2 x double> %vec1, <2 x double> %vec2)
- declare <vscale x 8 x i32> @llvm.vector.interleave2.nxv8i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2)
- declare <vscale x 6 x i8> @llvm.vector.interleave3.nxv6i8(<vscale x 2 x i8> %vec0, <vscale x 2 x i8> %vec1, <vscale x 2 x i8> %vec2)
- declare <10 x i32> @llvm.vector.interleave5.v10i32(<2 x i32> %vec0, <2 x i32> %vec1, <2 x i32> %vec2, <2 x i32> %vec3, <2 x i32> %vec4)
- declare <14 x i32> @llvm.vector.interleave7.v14i32(<2 x i32> %vec0, <2 x i32> %vec1, <2 x i32> %vec2, <2 x i32> %vec3, <2 x i32> %vec4, <2 x i32> %vec5, <2 x i32> %vec6)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vector.interleave2/3/4/5/6/7/8``' intrinsic constructs a vector
+The '`llvm.vector.interleave2/3/4/5/6/7/8`' intrinsic constructs a vector
by interleaving all the input vectors.
This intrinsic works for both fixed and scalable vectors. While this intrinsic
@@ -21721,34 +20360,30 @@ may allow for more optimization opportunities.
For example:
-.. code-block:: text
-
- <4 x i64> llvm.vector.interleave2.v4i64(<2 x i64> <i64 0, i64 2>, <2 x i64> <i64 1, i64 3>); ==> <4 x i64> <i64 0, i64 1, i64 2, i64 3>
- <6 x i32> llvm.vector.interleave3.v6i32(<2 x i32> <i32 0, i32 3>, <2 x i32> <i32 1, i32 4>, <2 x i32> <i32 2, i32 5>)
- ; ==> <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>
+```text
+<4 x i64> llvm.vector.interleave2.v4i64(<2 x i64> <i64 0, i64 2>, <2 x i64> <i64 1, i64 3>); ==> <4 x i64> <i64 0, i64 1, i64 2, i64 3>
+<6 x i32> llvm.vector.interleave3.v6i32(<2 x i32> <i32 0, i32 3>, <2 x i32> <i32 1, i32 4>, <2 x i32> <i32 2, i32 5>)
+ ; ==> <6 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5>
+```
-Arguments:
-""""""""""
+##### Arguments:
All arguments must be vectors of the same type whereby their logical
concatenation matches the result type.
-'``llvm.vector.splice.left``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.splice.left`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <2 x double> @llvm.vector.splice.left.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %offset)
- declare <vscale x 4 x i32> @llvm.vector.splice.left.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %offset)
+```
+declare <2 x double> @llvm.vector.splice.left.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %offset)
+declare <vscale x 4 x i32> @llvm.vector.splice.left.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %offset)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vector.splice.left.*``' intrinsics construct a vector by
-concatenating two vectors together, shifting the elements left by ``offset``,
+The '`llvm.vector.splice.left.*`' intrinsics construct a vector by
+concatenating two vectors together, shifting the elements left by `offset`,
and extracting the lower half.
These intrinsics work for both fixed and scalable vectors. While this intrinsic
@@ -21758,41 +20393,35 @@ that may allow for more optimization opportunities.
For example:
-.. code-block:: text
-
- llvm.vector.splice.left(<A,B,C,D>, <E,F,G,H>, 1);
- ==> <A,B,C,D,E,F,G,H>
- ==> <B,C,D,E,F,G,H,_>
- ==> <B,C,D,E>
-
+```text
+llvm.vector.splice.left(<A,B,C,D>, <E,F,G,H>, 1);
+ ==> <A,B,C,D,E,F,G,H>
+ ==> <B,C,D,E,F,G,H,_>
+ ==> <B,C,D,E>
+```
-Arguments:
-""""""""""
-The first two operands are vectors with the same type. ``offset`` is an unsigned
+##### Arguments:
+The first two operands are vectors with the same type. `offset` is an unsigned
scalar i32 that determines how many elements to shift left by.
-Semantics:
-""""""""""
-For a vector type with a runtime length of N, if ``offset`` > N then the result
-is a :ref:`poison value <poisonvalues>`.
+##### Semantics:
+For a vector type with a runtime length of N, if `offset` > N then the result
+is a {ref}`poison value <poisonvalues>`.
-'``llvm.vector.splice.right``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vector.splice.right`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <2 x double> @llvm.vector.splice.right.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %offset)
+declare <vscale x 4 x i32> @llvm.vector.splice.right.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %offset)
+```
- declare <2 x double> @llvm.vector.splice.right.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %offset)
- declare <vscale x 4 x i32> @llvm.vector.splice.right.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %offset)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vector.splice.right.*``' intrinsics construct a vector by
-concatenating two vectors together, shifting the elements right by ``offset``,
+The '`llvm.vector.splice.right.*`' intrinsics construct a vector by
+concatenating two vectors together, shifting the elements right by `offset`,
and extracting the upper half.
These intrinsics work for both fixed and scalable vectors. While this intrinsic
@@ -21802,37 +20431,33 @@ that may allow for more optimization opportunities.
For example:
-.. code-block:: text
-
- llvm.vector.splice.right(<A,B,C,D>, <E,F,G,H>, 1);
- ==> <A,B,C,D,E,F,G,H>
- ==> <_,A,B,C,D,E,F,G>
- ==> <D,E,F,G>
-
+```text
+llvm.vector.splice.right(<A,B,C,D>, <E,F,G,H>, 1);
+ ==> <A,B,C,D,E,F,G,H>
+ ==> <_,A,B,C,D,E,F,G>
+ ==> <D,E,F,G>
+```
-Arguments:
-""""""""""
-The first two operands are vectors with the same type. ``offset`` is an unsigned
+##### Arguments:
+The first two operands are vectors with the same type. `offset` is an unsigned
scalar i32 that determines how many elements to shift right by.
-Semantics:
-""""""""""
-For a vector type with a runtime length of N, if ``offset`` > N then the result
-is a :ref:`poison value <poisonvalues>`.
+##### Semantics:
+For a vector type with a runtime length of N, if `offset` > N then the result
+is a {ref}`poison value <poisonvalues>`.
-'``llvm.stepvector``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.stepvector`' Intrinsic
-This is an overloaded intrinsic. You can use ``llvm.stepvector``
+This is an overloaded intrinsic. You can use `llvm.stepvector`
to generate a vector whose lane values comprise the linear sequence
<0, 1, 2, ...>. It is primarily intended for scalable vectors.
-::
+```
+declare <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
+declare <vscale x 8 x i16> @llvm.stepvector.nxv8i16()
+```
- declare <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
- declare <vscale x 8 x i16> @llvm.stepvector.nxv8i16()
-
-The '``llvm.stepvector``' intrinsics are used to create vectors
+The '`llvm.stepvector`' intrinsics are used to create vectors
of integers whose elements contain a linear sequence of values starting from 0
with a step of 1. This intrinsic can only be used for vectors with integer
elements that are at least 8 bits in size. If the sequence value exceeds
@@ -21844,67 +20469,59 @@ supports all vector types, the recommended way to express this operation for
fixed-width vectors is still to generate a constant vector instead.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Vector Mask Intrinsics
-----------------------
+### Vector Mask Intrinsics
-.. _int_get_active_lane_mask:
+(int_get_active_lane_mask)=
-'``llvm.get.active.lane.mask.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.get.active.lane.mask.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %base, i32 %n)
+declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i64(i64 %base, i64 %n)
+declare <16 x i1> @llvm.get.active.lane.mask.v16i1.i64(i64 %base, i64 %n)
+declare <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64 %base, i64 %n)
+```
- declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %base, i32 %n)
- declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i64(i64 %base, i64 %n)
- declare <16 x i1> @llvm.get.active.lane.mask.v16i1.i64(i64 %base, i64 %n)
- declare <vscale x 16 x i1> @llvm.get.active.lane.mask.nxv16i1.i64(i64 %base, i64 %n)
-
-
-Overview:
-"""""""""
+##### Overview:
Create a mask representing active and inactive vector lanes.
-Arguments:
-""""""""""
+##### Arguments:
Both arguments have the same scalar integer type. The result is a vector with
the i1 element type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.get.active.lane.mask.*``' intrinsics are semantically equivalent
+The '`llvm.get.active.lane.mask.*`' intrinsics are semantically equivalent
to:
-::
+```
+%m[i] = icmp ult (%base + i), %n
+```
- %m[i] = icmp ult (%base + i), %n
-
-where ``%m`` is a vector (mask) of active/inactive lanes with its elements
-indexed by ``i``, and ``%base``, ``%n`` are the two arguments to
-``llvm.get.active.lane.mask.*``, ``%icmp`` is an integer compare and ``ult``
+where `%m` is a vector (mask) of active/inactive lanes with its elements
+indexed by `i`, and `%base`, `%n` are the two arguments to
+`llvm.get.active.lane.mask.*`, `%icmp` is an integer compare and `ult`
the unsigned less-than comparison operator. Overflow cannot occur in
-``(%base + i)`` and its comparison against ``%n`` as it is performed in integer
+`(%base + i)` and its comparison against `%n` as it is performed in integer
numbers and not in machine numbers. The above is equivalent to:
-::
-
- %m = @llvm.get.active.lane.mask(%base, %n)
+```
+%m = @llvm.get.active.lane.mask(%base, %n)
+```
This can, for example, be emitted by the loop vectorizer in which case
-``%base`` is the first element of the vector induction variable (VIV) and
-``%n`` is the loop tripcount. Thus, these intrinsics perform an element-wise
+`%base` is the first element of the vector induction variable (VIV) and
+`%n` is the loop tripcount. Thus, these intrinsics perform an element-wise
less than comparison of VIV with the loop tripcount, producing a mask of
true/false values representing active/inactive vector lanes, except if the VIV
overflows in which case they return false in the lanes where the VIV overflows.
@@ -21912,43 +20529,37 @@ The arguments are scalar types to accommodate scalable vector types, for which
it is unknown what the type of the step vector needs to be that enumerate its
lanes without overflow.
-This mask ``%m`` can e.g., be used in masked load/store instructions. These
+This mask `%m` can e.g., be used in masked load/store instructions. These
intrinsics provide a hint to the backend. I.e., for a vector loop, the
back-edge taken count of the original scalar loop is explicit as the second
argument.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i64(i64 %elem0, i64 429)
- %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(ptr align 4 %3, <4 x i1> %active.lane.mask, <4 x i32> poison)
+```llvm
+%active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i64(i64 %elem0, i64 429)
+%wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(ptr align 4 %3, <4 x i1> %active.lane.mask, <4 x i32> poison)
+```
+(int_loop_dependence_war_mask)=
-.. _int_loop_dependence_war_mask:
+#### '`llvm.loop.dependence.war.mask.*`' Intrinsics
-'``llvm.loop.dependence.war.mask.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <4 x i1> @llvm.loop.dependence.war.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+declare <8 x i1> @llvm.loop.dependence.war.mask.v8i1.i32(i32 %addrA, i32 %addrB, i32 immarg %elementSize)
+declare <16 x i1> @llvm.loop.dependence.war.mask.v16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+declare <vscale x 16 x i1> @llvm.loop.dependence.war.mask.nxv16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+```
- declare <4 x i1> @llvm.loop.dependence.war.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
- declare <8 x i1> @llvm.loop.dependence.war.mask.v8i1.i32(i32 %addrA, i32 %addrB, i32 immarg %elementSize)
- declare <16 x i1> @llvm.loop.dependence.war.mask.v16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
- declare <vscale x 16 x i1> @llvm.loop.dependence.war.mask.nxv16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+##### Overview:
-
-Overview:
-"""""""""
-
-Given a vector load from address %addrA followed by a vector store to address
-%addrB, this instruction generates a mask where an active lane indicates that
+Given a vector load from address `%addrA` followed by a vector store to address
+`%addrB`, this instruction generates a mask where an active lane indicates that
the write-after-read sequence can be performed safely for that lane, without the
danger of a write-after-read hazard occurring.
@@ -21956,89 +20567,83 @@ A write-after-read hazard occurs when a write-after-read sequence for a given
lane in a vector ends up being executed as a read-after-write sequence due to
the aliasing of pointers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments are integers and the last argument is an immediate.
The result is a vector with the i1 element type.
-Semantics:
-""""""""""
+##### Semantics:
-``%elementSize`` is the size of the accessed elements in bytes.
-The intrinsic returns ``poison`` if the distance between ``%addrA`` and ``%addrB``
-is smaller than ``VF * %elementsize`` and either ``%addrA + VF * %elementSize``
-or ``%addrB + VF * %elementSize`` wrap.
+`%elementSize` is the size of the accessed elements in bytes.
+The intrinsic returns `poison` if the distance between `%addrA` and `%addrB`
+is smaller than `VF * %elementsize` and either `%addrA + VF * %elementSize`
+or `%addrB + VF * %elementSize` wrap.
-The element of the result mask is active when loading from %addrA then storing to
-%addrB is safe and doesn't result in a write-after-read hazard, meaning that:
+The element of the result mask is active when loading from `%addrA` then
+storing to `%addrB` is safe and doesn't result in a write-after-read hazard,
+meaning that:
* (addrB - addrA) <= 0 (guarantees that all lanes are loaded before any stores), or
* elementSize * lane < (addrB - addrA) (guarantees that this lane is loaded
before the store to the same address)
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %addrA = ptrtoaddr ptr %ptrA to i64
- %addrB = ptrtoaddr ptr %ptrB to i64
- %loop.dependence.mask = call <4 x i1> @llvm.loop.dependence.war.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 4)
- %vecA = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 %ptrA, <4 x i1> %loop.dependence.mask, <4 x i32> poison)
- [...]
- call @llvm.masked.store.v4i32.p0(<4 x i32> %vecA, ptr align 4 %ptrB, <4 x i1> %loop.dependence.mask)
-
- ; For the above example, consider the following cases:
- ;
- ; 1. addrA >= addrB
- ;
- ; load = <0,1,2,3> ; uint32_t load = array[i+2];
- ; store = <0,1,2,3> ; array[i] = store;
- ;
- ; This results in an all-true mask, as the load always occurs before the
- ; store, so it does not depend on any values to be stored.
- ;
- ; 2. addrB - addrA = 2 * elementSize:
- ;
- ; load = <0,1,2,3> ; uint32_t load = array[i];
- ; store = <0,1,2,3> ; array[i+2] = store;
- ;
- ; This results in a mask with the first two lanes active. This is because
- ; we can only read two lanes before we would read values that have yet to
- ; be written.
- ;
- ; 3. addrB - addrA = 4 * elementSize
- ;
- ; load = <0,1,2,3> ; uint32_t load = array[i];
- ; store = <0,1,2,3> ; array[i+4] = store;
- ;
- ; This results in an all-true mask, as the store is a full vector ahead
- ; of the load, so all values will be written before any lane is read.
-
-.. _int_loop_dependence_raw_mask:
-
-'``llvm.loop.dependence.raw.mask.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Examples:
+
+```llvm
+%addrA = ptrtoaddr ptr %ptrA to i64
+%addrB = ptrtoaddr ptr %ptrB to i64
+%loop.dependence.mask = call <4 x i1> @llvm.loop.dependence.war.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 4)
+%vecA = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 %ptrA, <4 x i1> %loop.dependence.mask, <4 x i32> poison)
+[...]
+call @llvm.masked.store.v4i32.p0(<4 x i32> %vecA, ptr align 4 %ptrB, <4 x i1> %loop.dependence.mask)
+
+; For the above example, consider the following cases:
+;
+; 1. addrA >= addrB
+;
+; load = <0,1,2,3> ; uint32_t load = array[i+2];
+; store = <0,1,2,3> ; array[i] = store;
+;
+; This results in an all-true mask, as the load always occurs before the
+; store, so it does not depend on any values to be stored.
+;
+; 2. addrB - addrA = 2 * elementSize:
+;
+; load = <0,1,2,3> ; uint32_t load = array[i];
+; store = <0,1,2,3> ; array[i+2] = store;
+;
+; This results in a mask with the first two lanes active. This is because
+; we can only read two lanes before we would read values that have yet to
+; be written.
+;
+; 3. addrB - addrA = 4 * elementSize
+;
+; load = <0,1,2,3> ; uint32_t load = array[i];
+; store = <0,1,2,3> ; array[i+4] = store;
+;
+; This results in an all-true mask, as the store is a full vector ahead
+; of the load, so all values will be written before any lane is read.
+```
+
+(int_loop_dependence_raw_mask)=
+
+#### '`llvm.loop.dependence.raw.mask.*`' Intrinsics
+
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <4 x i1> @llvm.loop.dependence.raw.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
- declare <8 x i1> @llvm.loop.dependence.raw.mask.v8i1.i32(i32 %addrA, i32 %addrB, i32 immarg %elementSize)
- declare <16 x i1> @llvm.loop.dependence.raw.mask.v16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
- declare <vscale x 16 x i1> @llvm.loop.dependence.raw.mask.nxv16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+```
+declare <4 x i1> @llvm.loop.dependence.raw.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+declare <8 x i1> @llvm.loop.dependence.raw.mask.v8i1.i32(i32 %addrA, i32 %addrB, i32 immarg %elementSize)
+declare <16 x i1> @llvm.loop.dependence.raw.mask.v16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+declare <vscale x 16 x i1> @llvm.loop.dependence.raw.mask.nxv16i1.i64(i64 %addrA, i64 %addrB, i64 immarg %elementSize)
+```
+##### Overview:
-Overview:
-"""""""""
-
-Given a vector store to address %addrA followed by a vector load from address
-%addrB, this instruction generates a mask where an active lane indicates that the
-read-after-write sequence can be performed safely for that lane, without a
+Given a vector store to address `%addrA` followed by a vector load from address
+`%addrB`, this instruction generates a mask where an active lane indicates that
+the read-after-write sequence can be performed safely for that lane, without a
read-after-write hazard or a store-to-load forwarding hazard being introduced.
A read-after-write hazard occurs when a read-after-write sequence for a given
@@ -22050,90 +20655,82 @@ address that partially overlaps with the address of a subsequent vector load,
meaning that the vector load can't be performed until the vector store is
complete.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments are integers and the last argument is an immediate.
The result is a vector with the i1 element type.
-Semantics:
-""""""""""
+##### Semantics:
-``%elementSize`` is the size of the accessed elements in bytes.
-The intrinsic returns ``poison`` if the distance between ``%addrA`` and ``%addrB``
-is smaller than ``VF * %elementsize`` and either ``%addrA + VF * %elementSize``
-or ``%addrB + VF * %elementSize`` wrap.
+`%elementSize` is the size of the accessed elements in bytes.
+The intrinsic returns `poison` if the distance between `%addrA` and `%addrB`
+is smaller than `VF * %elementsize` and either `%addrA + VF * %elementSize`
+or `%addrB + VF * %elementSize` wrap.
-The element of the result mask is active when storing to %addrA then loading from
-%addrB is safe and doesn't result in aliasing, meaning that:
+The element of the result mask is active when storing to `%addrA` then
+loading from `%addrB` is safe and doesn't result in aliasing, meaning that:
* elementSize * lane < abs(addrB - addrA) (guarantees that the store of this lane
occurs before loading from this address), or
* addrA == addrB (doesn't introduce any new hazards that weren't in the scalar
code)
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %addrA = ptrtoaddr ptr %ptrA to i64
- %addrB = ptrtoaddr ptr %ptrB to i64
- %loop.dependence.mask = call <4 x i1> @llvm.loop.dependence.raw.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 4)
- call @llvm.masked.store.v4i32.p0(<4 x i32> %vecA, ptr align 4 %ptrA, <4 x i1> %loop.dependence.mask)
- [...]
- %vecB = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 %ptrB, <4 x i1> %loop.dependence.mask, <4 x i32> poison)
-
- ; For the above example, consider the following cases:
- ;
- ; 1. addrA == addrB
- ;
- ; store = <0,1,2,3> ; array[i] = store;
- ; load = <0,1,2,3> ; uint32_t load = array[i];
- ;
- ; This results in a all-true mask. There is no conflict.
- ;
- ; 2. addrB - addrA = 2 * elementSize
- ;
- ; store = <0,1,2,3> ; array[i] = store;
- ; load = <0,1,2,3> ; uint32_t load = array[i+2];
- ;
- ; This results in a mask with the first two lanes active. In this case,
- ; only two lanes can be written without overwriting values yet to be read.
- ;
- ; 3. addrB - addrA = -2 * elementSize
- ;
- ; store = <0,1,2,3> ; array[i+2] = store;
- ; load = <0,1,2,3> ; uint32_t load = array[i];
- ;
- ; This also results in a mask with the first two lanes active. This is
- ; because if any more lanes were active the load would be dependent on the
- ; completion of the store.
-
-Experimental Vector Intrinsics
-------------------------------
-
-'``llvm.experimental.cttz.elts``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-
-This is an overloaded intrinsic. You can use ```llvm.experimental.cttz.elts```
+##### Examples:
+
+```llvm
+%addrA = ptrtoaddr ptr %ptrA to i64
+%addrB = ptrtoaddr ptr %ptrB to i64
+%loop.dependence.mask = call <4 x i1> @llvm.loop.dependence.raw.mask.v4i1.i64(i64 %addrA, i64 %addrB, i64 4)
+call @llvm.masked.store.v4i32.p0(<4 x i32> %vecA, ptr align 4 %ptrA, <4 x i1> %loop.dependence.mask)
+[...]
+%vecB = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 %ptrB, <4 x i1> %loop.dependence.mask, <4 x i32> poison)
+
+; For the above example, consider the following cases:
+;
+; 1. addrA == addrB
+;
+; store = <0,1,2,3> ; array[i] = store;
+; load = <0,1,2,3> ; uint32_t load = array[i];
+;
+; This results in a all-true mask. There is no conflict.
+;
+; 2. addrB - addrA = 2 * elementSize
+;
+; store = <0,1,2,3> ; array[i] = store;
+; load = <0,1,2,3> ; uint32_t load = array[i+2];
+;
+; This results in a mask with the first two lanes active. In this case,
+; only two lanes can be written without overwriting values yet to be read.
+;
+; 3. addrB - addrA = -2 * elementSize
+;
+; store = <0,1,2,3> ; array[i+2] = store;
+; load = <0,1,2,3> ; uint32_t load = array[i];
+;
+; This also results in a mask with the first two lanes active. This is
+; because if any more lanes were active the load would be dependent on the
+; completion of the store.
+```
+
+### Experimental Vector Intrinsics
+
+#### '`llvm.experimental.cttz.elts`' Intrinsic
+
+##### Syntax:
+
+This is an overloaded intrinsic. You can use `llvm.experimental.cttz.elts`
on any vector of integer elements, both fixed width and scalable.
-::
-
- declare i8 @llvm.experimental.cttz.elts.i8.v8i1(<8 x i1> <src>, i1 <is_zero_poison>)
+```
+declare i8 @llvm.experimental.cttz.elts.i8.v8i1(<8 x i1> <src>, i1 <is_zero_poison>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.cttz.elts``' intrinsic counts the number of trailing
+The '`llvm.experimental.cttz.elts`' intrinsic counts the number of trailing
zero elements of a vector.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the vector to be counted. This argument must be a vector
with integer element type. The return type must also be an integer type which is
@@ -22145,61 +20742,55 @@ The second argument is a constant flag that indicates whether the intrinsic
returns a valid result if the first argument is all zero. If the first argument
is all zero and the second argument is true, the result is poison.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.cttz.elts``' intrinsic counts the trailing (least
-significant) zero elements in a vector. If ``src == 0`` the result is the
+The '`llvm.experimental.cttz.elts`' intrinsic counts the trailing (least
+significant) zero elements in a vector. If `src == 0` the result is the
number of elements in the input vector.
-'``llvm.experimental.get.vector.length``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.get.vector.length`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.experimental.get.vector.length.i32(i32 %cnt, i32 immarg %vf, i1 immarg %scalable)
- declare i32 @llvm.experimental.get.vector.length.i64(i64 %cnt, i32 immarg %vf, i1 immarg %scalable)
+```
+declare i32 @llvm.experimental.get.vector.length.i32(i32 %cnt, i32 immarg %vf, i1 immarg %scalable)
+declare i32 @llvm.experimental.get.vector.length.i64(i64 %cnt, i32 immarg %vf, i1 immarg %scalable)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.get.vector.length.*``' intrinsics take a number of
+The '`llvm.experimental.get.vector.length.*`' intrinsics take a number of
elements to process and returns how many of the elements can be processed
with the requested vectorization factor.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is an unsigned value of any scalar integer type and specifies
the total number of elements to be processed. The second argument is an i32
immediate for the vectorization factor. The third argument indicates if the
vectorization factor should be multiplied by vscale.
-Semantics:
-""""""""""
+##### Semantics:
Returns a non-negative i32 value (explicit vector length) that is unknown at compile
time and depends on the hardware specification.
If the result value does not fit in the result type, then the result is
-a :ref:`poison value <poisonvalues>`.
+a {ref}`poison value <poisonvalues>`.
This intrinsic is intended to be used by loop vectorization with VP intrinsics
in order to get the number of elements to process on each loop iteration. The
result should be used to decrease the count for the next iteration until the
count reaches zero.
-Let ``%max_lanes`` be the number of lanes in the type described by ``%vf`` and
-``%scalable``, here are the constraints on the returned value:
+Let `%max_lanes` be the number of lanes in the type described by `%vf` and
+`%scalable`, here are the constraints on the returned value:
-- If ``%cnt`` equals to 0, returns 0.
-- The returned value is always less than or equal to ``%max_lanes``.
-- The returned value is always greater than or equal to ``ceil(%cnt / ceil(%cnt / %max_lanes))``,
- if ``%cnt`` is non-zero.
+- If `%cnt` equals to 0, returns 0.
+- The returned value is always less than or equal to `%max_lanes`.
+- The returned value is always greater than or equal to `ceil(%cnt / ceil(%cnt / %max_lanes))`,
+ if `%cnt` is non-zero.
- The returned values are monotonically non-increasing in each loop iteration. That is,
the returned value of an iteration is at least as large as that of any later
iteration.
@@ -22207,12 +20798,11 @@ Let ``%max_lanes`` be the number of lanes in the type described by ``%vf`` and
Note that it has the following implications:
- For a loop that uses this intrinsic, the number of iterations is equal to
- ``ceil(%C / %max_lanes)`` where ``%C`` is the initial ``%cnt`` value.
-- If ``%cnt`` is non-zero, the return value is non-zero as well.
-- If ``%cnt`` is less than or equal to ``%max_lanes``, the return value is equal to ``%cnt``.
+ `ceil(%C / %max_lanes)` where `%C` is the initial `%cnt` value.
+- If `%cnt` is non-zero, the return value is non-zero as well.
+- If `%cnt` is less than or equal to `%max_lanes`, the return value is equal to `%cnt`.
-'``llvm.experimental.vector.histogram.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vector.histogram.*`' Intrinsic
These intrinsics are overloaded.
@@ -22221,65 +20811,61 @@ in memory that may not be contiguous, and where multiple elements within a
single vector may be updating the same value in memory.
The update operation must be specified as part of the intrinsic name. For a
-simple histogram like the following the ``add`` operation would be used.
+simple histogram like the following the `add` operation would be used.
-.. code-block:: c
-
- void simple_histogram(int *restrict buckets, unsigned *indices, int N, int inc) {
- for (int i = 0; i < N; ++i)
- buckets[indices[i]] += inc;
- }
+```c
+void simple_histogram(int *restrict buckets, unsigned *indices, int N, int inc) {
+ for (int i = 0; i < N; ++i)
+ buckets[indices[i]] += inc;
+}
+```
More update operation types may be added in the future.
-::
-
- declare void @llvm.experimental.vector.histogram.add.v8p0.i32(<8 x ptr> %ptrs, i32 %inc, <8 x i1> %mask)
- declare void @llvm.experimental.vector.histogram.add.nxv2p0.i64(<vscale x 2 x ptr> %ptrs, i64 %inc, <vscale x 2 x i1> %mask)
- declare void @llvm.experimental.vector.histogram.uadd.sat.v8p0.i32(<8 x ptr> %ptrs, i32 %inc, <8 x i1> %mask)
- declare void @llvm.experimental.vector.histogram.umax.v8p0.i32(<8 x ptr> %ptrs, i32 %val, <8 x i1> %mask)
- declare void @llvm.experimental.vector.histogram.umin.v8p0.i32(<8 x ptr> %ptrs, i32 %val, <8 x i1> %mask)
+```
+declare void @llvm.experimental.vector.histogram.add.v8p0.i32(<8 x ptr> %ptrs, i32 %inc, <8 x i1> %mask)
+declare void @llvm.experimental.vector.histogram.add.nxv2p0.i64(<vscale x 2 x ptr> %ptrs, i64 %inc, <vscale x 2 x i1> %mask)
+declare void @llvm.experimental.vector.histogram.uadd.sat.v8p0.i32(<8 x ptr> %ptrs, i32 %inc, <8 x i1> %mask)
+declare void @llvm.experimental.vector.histogram.umax.v8p0.i32(<8 x ptr> %ptrs, i32 %val, <8 x i1> %mask)
+declare void @llvm.experimental.vector.histogram.umin.v8p0.i32(<8 x ptr> %ptrs, i32 %val, <8 x i1> %mask)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a vector of pointers to the memory locations to be
updated. The second argument is a scalar used to update the value from
memory; it must match the type of value to be updated. The final argument
is a mask value to exclude locations from being modified.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.vector.histogram.*``' intrinsics are used to perform
+The '`llvm.experimental.vector.histogram.*`' intrinsics are used to perform
updates on potentially overlapping values in memory. The intrinsics represent
the following sequence of operations:
-1. Gather load from the ``ptrs`` operand, with element type matching that of
- the ``inc`` operand.
-2. Update of the values loaded from memory. In the case of the ``add``
+1. Gather load from the `ptrs` operand, with element type matching that of
+ the `inc` operand.
+2. Update of the values loaded from memory. In the case of the `add`
update operation, this means:
- 1. Perform a cross-vector histogram operation on the ``ptrs`` operand.
- 2. Multiply the result by the ``inc`` operand.
+ 1. Perform a cross-vector histogram operation on the `ptrs` operand.
+ 2. Multiply the result by the `inc` operand.
3. Add the result to the values loaded from memory
3. Scatter the result of the update operation to the memory locations from
- the ``ptrs`` operand.
+ the `ptrs` operand.
-The ``mask`` operand will apply to at least the gather and scatter operations.
+The `mask` operand will apply to at least the gather and scatter operations.
-'``llvm.experimental.vector.extract.last.active``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vector.extract.last.active`' Intrinsic
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.experimental.vector.extract.last.active.v4i32(<4 x i32> %data, <4 x i1> %mask, i32 %passthru)
+declare i16 @llvm.experimental.vector.extract.last.active.nxv8i16(<vscale x 8 x i16> %data, <vscale x 8 x i1> %mask, i16 %passthru)
+```
- declare i32 @llvm.experimental.vector.extract.last.active.v4i32(<4 x i32> %data, <4 x i1> %mask, i32 %passthru)
- declare i16 @llvm.experimental.vector.extract.last.active.nxv8i16(<vscale x 8 x i16> %data, <vscale x 8 x i1> %mask, i16 %passthru)
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the data vector to extract a lane from. The second is a
mask vector controlling the extraction. The third argument is a passthru
@@ -22288,57 +20874,52 @@ value.
The two input vectors must have the same number of elements, and the type of
the passthru value must match that of the elements of the data vector.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.vector.extract.last.active``' intrinsic will extract an
+The '`llvm.experimental.vector.extract.last.active`' intrinsic will extract an
element from the data vector at the index matching the highest active lane of
the mask vector. If no mask lanes are active then the passthru value is
returned instead.
-.. _int_vector_compress:
+(int_vector_compress)=
-'``llvm.experimental.vector.compress.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vector.compress.*`' Intrinsics
LLVM provides an intrinsic for compressing data within a vector based on a selection mask.
-Semantically, this is similar to :ref:`llvm.masked.compressstore <int_compressstore>` but with weaker assumptions
+Semantically, this is similar to {ref}`llvm.masked.compressstore <int_compressstore>` but with weaker assumptions
and without storing the results to memory, i.e., the data remains in the vector.
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. A number of scalar values of integer, floating point or pointer data type are collected
from an input vector and placed adjacently within the result vector. A mask defines which elements to collect from the vector.
-The remaining lanes are filled with values from ``passthru``.
+The remaining lanes are filled with values from `passthru`.
-.. code-block:: llvm
+```llvm
+declare <8 x i32> @llvm.experimental.vector.compress.v8i32(<8 x i32> <value>, <8 x i1> <mask>, <8 x i32> <passthru>)
+declare <16 x float> @llvm.experimental.vector.compress.v16f32(<16 x float> <value>, <16 x i1> <mask>, <16 x float> undef)
+```
- declare <8 x i32> @llvm.experimental.vector.compress.v8i32(<8 x i32> <value>, <8 x i1> <mask>, <8 x i32> <passthru>)
- declare <16 x float> @llvm.experimental.vector.compress.v16f32(<16 x float> <value>, <16 x i1> <mask>, <16 x float> undef)
+##### Overview:
-Overview:
-"""""""""
-
-Selects elements from input vector ``value`` according to the ``mask``.
+Selects elements from input vector `value` according to the `mask`.
All selected elements are written into adjacent lanes in the result vector,
from lower to higher.
The mask holds an entry for each vector lane, and is used to select elements
to be kept.
-If a ``passthru`` vector is given, all remaining lanes are filled with the
-corresponding lane's value from ``passthru``.
-The main difference to :ref:`llvm.masked.compressstore <int_compressstore>` is
+If a `passthru` vector is given, all remaining lanes are filled with the
+corresponding lane's value from `passthru`.
+The main difference to {ref}`llvm.masked.compressstore <int_compressstore>` is
that the we do not need to guard against memory access for unselected lanes.
This allows for branchless code and better optimization for all targets that
do not support or have inefficient
instructions of the explicit semantics of
-:ref:`llvm.masked.compressstore <int_compressstore>` but still have some form
+{ref}`llvm.masked.compressstore <int_compressstore>` but still have some form
of compress operations.
The result vector can be written with a similar effect, as all the selected
values are at the lower positions of the vector, but without requiring
-branches to avoid writes where the mask is ``false``.
+branches to avoid writes where the mask is `false`.
-Arguments:
-""""""""""
+##### Arguments:
The first operand is the input vector, from which elements are selected.
The second operand is the mask, a vector of boolean values.
@@ -22347,61 +20928,55 @@ into remaining lanes.
The mask and the input vector must have the same number of vector elements.
The input and passthru vectors must have the same type.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.experimental.vector.compress`` intrinsic compresses data within a vector.
+The `llvm.experimental.vector.compress` intrinsic compresses data within a vector.
It collects elements from possibly non-adjacent lanes of a vector and places
them contiguously in the result vector based on a selection mask, filling the
-remaining lanes with values from ``passthru``.
+remaining lanes with values from `passthru`.
This intrinsic performs the logic of the following C++ example.
-All values in ``out`` after the last selected one are undefined if
-``passthru`` is undefined.
-If all entries in the ``mask`` are 0, the ``out`` vector is ``passthru``.
+All values in `out` after the last selected one are undefined if
+`passthru` is undefined.
+If all entries in the `mask` are 0, the `out` vector is `passthru`.
If any element of the mask is poison, all elements of the result are poison.
Otherwise, if any element of the mask is undef, all elements of the result are undef.
-If ``passthru`` is undefined, the number of valid lanes is equal to the number
-of ``true`` entries in the mask, i.e., all lanes >= number-of-selected-values
+If `passthru` is undefined, the number of valid lanes is equal to the number
+of `true` entries in the mask, i.e., all lanes >= number-of-selected-values
are undefined.
-.. code-block:: cpp
-
- // Consecutively place selected values in a vector.
- using VecT __attribute__((vector_size(N))) = int;
- VecT compress(VecT vec, VecT mask, VecT passthru) {
- VecT out;
- int idx = 0;
- for (int i = 0; i < N / sizeof(int); ++i) {
- out[idx] = vec[i];
- idx += static_cast<bool>(mask[i]);
- }
- for (; idx < N / sizeof(int); ++idx) {
- out[idx] = passthru[idx];
- }
- return out;
- }
-
+```cpp
+// Consecutively place selected values in a vector.
+using VecT __attribute__((vector_size(N))) = int;
+VecT compress(VecT vec, VecT mask, VecT passthru) {
+ VecT out;
+ int idx = 0;
+ for (int i = 0; i < N / sizeof(int); ++i) {
+ out[idx] = vec[i];
+ idx += static_cast<bool>(mask[i]);
+ }
+ for (; idx < N / sizeof(int); ++idx) {
+ out[idx] = passthru[idx];
+ }
+ return out;
+}
+```
-'``llvm.experimental.vector.match.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vector.match.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <<n> x i1> @llvm.experimental.vector.match(<<n> x <ty>> %op1, <<m> x <ty>> %op2, <<n> x i1> %mask)
+declare <vscale x <n> x i1> @llvm.experimental.vector.match(<vscale x <n> x <ty>> %op1, <<m> x <ty>> %op2, <vscale x <n> x i1> %mask)
+```
- declare <<n> x i1> @llvm.experimental.vector.match(<<n> x <ty>> %op1, <<m> x <ty>> %op2, <<n> x i1> %mask)
- declare <vscale x <n> x i1> @llvm.experimental.vector.match(<vscale x <n> x <ty>> %op1, <<m> x <ty>> %op2, <vscale x <n> x i1> %mask)
-
-Overview:
-"""""""""
+##### Overview:
Find active elements of the first argument matching any elements of the second.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the search vector, the second argument the vector of
elements we are searching for (i.e., for which we consider a match successful),
@@ -22411,213 +20986,189 @@ integer element types. The first and third arguments and the result type must
have matching element counts (fixed or scalable). The second argument must be a
fixed vector, but its length may be different from the remaining arguments.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.vector.match``' intrinsic compares each active element
+The '`llvm.experimental.vector.match`' intrinsic compares each active element
in the first argument against the elements of the second argument, placing
-``1`` in the corresponding element of the output vector if any equality
-comparison is successful, and ``0`` otherwise. Inactive elements in the mask
-are set to ``0`` in the output.
+`1` in the corresponding element of the output vector if any equality
+comparison is successful, and `0` otherwise. Inactive elements in the mask
+are set to `0` in the output.
-Matrix Intrinsics
------------------
+### Matrix Intrinsics
Operations on matrixes requiring shape information (like number of rows/columns
or the memory layout) can be expressed using the matrix intrinsics. These
intrinsics require matrix dimensions to be passed as immediate arguments, and
-matrixes are passed and returned as vectors. This means that for a ``R`` x
-``C`` matrix, element ``i`` of column ``j`` is at index ``j * R + i`` in the
+matrixes are passed and returned as vectors. This means that for a `R` x
+`C` matrix, element `i` of column `j` is at index `j * R + i` in the
corresponding vector, with indices starting at 0. Currently column-major layout
is assumed. The intrinsics support both integer and floating point matrixes.
-'``llvm.matrix.transpose.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.matrix.transpose.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare vectorty @llvm.matrix.transpose.*(vectorty %In, i32 <Rows>, i32 <Cols>)
+```
- declare vectorty @llvm.matrix.transpose.*(vectorty %In, i32 <Rows>, i32 <Cols>)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.matrix.transpose.*`' intrinsics treat `%In` as a
+`<Rows> x <Cols>` matrix and return the transposed matrix in the result vector.
-The '``llvm.matrix.transpose.*``' intrinsics treat ``%In`` as a ``<Rows> x
-<Cols>`` matrix and return the transposed matrix in the result vector.
+##### Arguments:
-Arguments:
-""""""""""
-
-The first argument ``%In`` is a vector that corresponds to a ``<Rows> x
-<Cols>`` matrix. Thus, arguments ``<Rows>`` and ``<Cols>`` correspond to the
+The first argument `%In` is a vector that corresponds to a
+`<Rows> x <Cols>` matrix. Thus, arguments `<Rows>` and `<Cols>` correspond to the
number of rows and columns, respectively, and must be positive, constant
-integers. The returned vector must have ``<Rows> * <Cols>`` elements, and have
-the same float or integer element type as ``%In``.
+integers. The returned vector must have `<Rows> * <Cols>` elements, and have
+the same float or integer element type as `%In`.
-'``llvm.matrix.multiply.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.matrix.multiply.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare vectorty @llvm.matrix.multiply.*(vectorty %A, vectorty %B, i32 <OuterRows>, i32 <Inner>, i32 <OuterColumns>)
+```
- declare vectorty @llvm.matrix.multiply.*(vectorty %A, vectorty %B, i32 <OuterRows>, i32 <Inner>, i32 <OuterColumns>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.matrix.multiply.*``' intrinsics treat ``%A`` as a ``<OuterRows> x
-<Inner>`` matrix, ``%B`` as a ``<Inner> x <OuterColumns>`` matrix, and
+The '`llvm.matrix.multiply.*`' intrinsics treat `%A` as a
+`<OuterRows> x <Inner>` matrix, `%B` as a `<Inner> x <OuterColumns>` matrix, and
multiplies them. The result matrix is returned in the result vector.
-Arguments:
-""""""""""
+##### Arguments:
-The first vector argument ``%A`` corresponds to a matrix with ``<OuterRows> *
-<Inner>`` elements, and the second argument ``%B`` to a matrix with
-``<Inner> * <OuterColumns>`` elements. Arguments ``<OuterRows>``,
-``<Inner>`` and ``<OuterColumns>`` must be positive, constant integers. The
-returned vector must have ``<OuterRows> * <OuterColumns>`` elements.
-Vectors ``%A``, ``%B``, and the returned vector all have the same float or
+The first vector argument `%A` corresponds to a matrix with
+`<OuterRows> * <Inner>` elements, and the second argument `%B` to a matrix with
+`<Inner> * <OuterColumns>` elements. Arguments `<OuterRows>`,
+`<Inner>` and `<OuterColumns>` must be positive, constant integers. The
+returned vector must have `<OuterRows> * <OuterColumns>` elements.
+Vectors `%A`, `%B`, and the returned vector all have the same float or
integer element type.
-'``llvm.matrix.column.major.load.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.matrix.column.major.load.*`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. You can use ``llvm.matrix.column.major.load``
+##### Syntax:
+This is an overloaded intrinsic. You can use `llvm.matrix.column.major.load`
to load any vector type with a stride of any bitwidth up to 64.
-::
+```
+declare <4 x i32> @llvm.matrix.column.major.load.v4i32.i64(
+ ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
+declare <9 x double> @llvm.matrix.column.major.load.v9f64.i32(
+ ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
+```
- declare <4 x i32> @llvm.matrix.column.major.load.v4i32.i64(
- ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
- declare <9 x double> @llvm.matrix.column.major.load.v9f64.i32(
- ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32 <Rows>, i32 <Cols>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.matrix.column.major.load.*``' intrinsics load a ``<Rows> x <Cols>``
-matrix using a stride of ``%Stride`` to compute the start address of the
+The '`llvm.matrix.column.major.load.*`' intrinsics load a `<Rows> x <Cols>`
+matrix using a stride of `%Stride` to compute the start address of the
different columns. This allows for convenient loading of sub matrixes.
-Independent of ``%Stride``'s bitwidth, the offset is computed using the target
-daya layout's pointer index type. If ``<IsVolatile>`` is true, the intrinsic is
-considered a :ref:`volatile memory access <volatile>`. The result matrix is
-returned in the result vector. If the ``%Ptr`` argument is known to be aligned
+Independent of `%Stride`'s bitwidth, the offset is computed using the target
+daya layout's pointer index type. If `<IsVolatile>` is true, the intrinsic is
+considered a {ref}`volatile memory access <volatile>`. The result matrix is
+returned in the result vector. If the `%Ptr` argument is known to be aligned
to some boundary, this can be specified as an attribute on the argument.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument ``%Ptr`` is a pointer type to the returned vector type, and
-corresponds to the start address to load from. The second argument ``%Stride``
-is a positive integer for which ``%Stride >= <Rows>``. ``%Stride`` is used to
-compute the column memory addresses. I.e., for a column ``C``, its start memory
-addresses is calculated with ``%Ptr + C * %Stride``. The third Argument
-``<IsVolatile>`` is a boolean value. The fourth and fifth arguments,
-``<Rows>`` and ``<Cols>``, correspond to the number of rows and columns,
+The first argument `%Ptr` is a pointer type to the returned vector type, and
+corresponds to the start address to load from. The second argument `%Stride`
+is a positive integer for which `%Stride >= <Rows>`. `%Stride` is used to
+compute the column memory addresses. I.e., for a column `C`, its start memory
+addresses is calculated with `%Ptr + C * %Stride`. The third Argument
+`<IsVolatile>` is a boolean value. The fourth and fifth arguments,
+`<Rows>` and `<Cols>`, correspond to the number of rows and columns,
respectively, and must be positive, constant integers. The returned vector must
-have ``<Rows> * <Cols>`` elements.
+have `<Rows> * <Cols>` elements.
-The :ref:`align <attr_align>` parameter attribute can be provided for the
-``%Ptr`` arguments.
+The {ref}`align <attr_align>` parameter attribute can be provided for the
+`%Ptr` arguments.
-'``llvm.matrix.column.major.store.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.matrix.column.major.store.*`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. ``llvm.matrix.column.major.store`` to store
+##### Syntax:
+This is an overloaded intrinsic. `llvm.matrix.column.major.store` to store
any vector type with a stride of any bitwidth up to 64.
-::
+```
+declare void @llvm.matrix.column.major.store.v4i32.i64(
+ <4 x i32> %In, ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>,
+ i32 <Cols>)
+declare void @llvm.matrix.column.major.store.v9f64.i32(
+ <9 x double> %In, ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32
+ <Rows>, i32 <Cols>)
+```
- declare void @llvm.matrix.column.major.store.v4i32.i64(
- <4 x i32> %In, ptrty %Ptr, i64 %Stride, i1 <IsVolatile>, i32 <Rows>,
- i32 <Cols>)
- declare void @llvm.matrix.column.major.store.v9f64.i32(
- <9 x double> %In, ptrty %Ptr, i32 %Stride, i1 <IsVolatile>, i32
- <Rows>, i32 <Cols>)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.matrix.column.major.store.*`' intrinsics store the
+`<Rows> x <Cols>` matrix in `%In` to memory using a stride of `%Stride` between
+columns. Independent of `%Stride`'s bitwidth, the offset is computed using
+the target daya layout's pointer index type. If `<IsVolatile>` is true, the
+intrinsic is considered a {ref}`volatile memory access <volatile>`.
-The '``llvm.matrix.column.major.store.*``' intrinsics store the ``<Rows> x
-<Cols>`` matrix in ``%In`` to memory using a stride of ``%Stride`` between
-columns. Independent of ``%Stride``'s bitwidth, the offset is computed using
-the target daya layout's pointer index type. If ``<IsVolatile>`` is true, the
-intrinsic is considered a :ref:`volatile memory access <volatile>`.
-
-If the ``%Ptr`` argument is known to be aligned to some boundary, this can be
+If the `%Ptr` argument is known to be aligned to some boundary, this can be
specified as an attribute on the argument.
-Arguments:
-""""""""""
-
-The first argument ``%In`` is a vector that corresponds to a ``<Rows> x
-<Cols>`` matrix to be stored to memory. The second argument ``%Ptr`` is a
-pointer to the vector type of ``%In``, and is the start address of the matrix
-in memory. The third argument ``%Stride`` is a positive integer for which
-``%Stride >= <Rows>``. ``%Stride`` is used to compute the column memory
-addresses. I.e., for a column ``C``, its start memory addresses is calculated
-with ``%Ptr + C * %Stride``. The fourth argument ``<IsVolatile>`` is a boolean
-value. The arguments ``<Rows>`` and ``<Cols>`` correspond to the number of rows
+##### Arguments:
+
+The first argument `%In` is a vector that corresponds to a
+`<Rows> x <Cols>` matrix to be stored to memory. The second argument `%Ptr` is a
+pointer to the vector type of `%In`, and is the start address of the matrix
+in memory. The third argument `%Stride` is a positive integer for which
+`%Stride >= <Rows>`. `%Stride` is used to compute the column memory
+addresses. I.e., for a column `C`, its start memory addresses is calculated
+with `%Ptr + C * %Stride`. The fourth argument `<IsVolatile>` is a boolean
+value. The arguments `<Rows>` and `<Cols>` correspond to the number of rows
and columns, respectively, and must be positive, constant integers.
-The :ref:`align <attr_align>` parameter attribute can be provided
-for the ``%Ptr`` arguments.
+The {ref}`align <attr_align>` parameter attribute can be provided
+for the `%Ptr` arguments.
-Saturating floating-point to integer conversions
-------------------------------------------------
+### Saturating floating-point to integer conversions
-The ``fptoui`` and ``fptosi`` instructions return a
-:ref:`poison value <poisonvalues>` if the rounded-towards-zero value is not
+The `fptoui` and `fptosi` instructions return a
+{ref}`poison value <poisonvalues>` if the rounded-towards-zero value is not
representable by the result type. These intrinsics provide an alternative
conversion, which will saturate towards the smallest and largest representable
integer values instead.
-'``llvm.fptoui.sat.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fptoui.sat.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fptoui.sat`` on any
+This is an overloaded intrinsic. You can use `llvm.fptoui.sat` on any
floating-point argument type and any integer result type, or vectors thereof.
Not all targets may support all types, however.
-::
-
- declare i32 @llvm.fptoui.sat.i32.f32(float %f)
- declare i19 @llvm.fptoui.sat.i19.f64(double %f)
- declare <4 x i100> @llvm.fptoui.sat.v4i100.v4f128(<4 x fp128> %f)
+```
+declare i32 @llvm.fptoui.sat.i32.f32(float %f)
+declare i19 @llvm.fptoui.sat.i19.f64(double %f)
+declare <4 x i100> @llvm.fptoui.sat.v4i100.v4f128(<4 x fp128> %f)
+```
-Overview:
-"""""""""
+##### Overview:
This intrinsic converts the argument into an unsigned integer using saturating
semantics.
-Arguments:
-""""""""""
+##### Arguments:
The argument may be any floating-point or vector of floating-point type. The
return value may be any integer or vector of integer type. The number of vector
elements in argument and return must be the same.
-Semantics:
-""""""""""
+##### Semantics:
The conversion to integer is performed subject to the following rules:
@@ -22629,47 +21180,41 @@ The conversion to integer is performed subject to the following rules:
unsigned integer is returned.
- Otherwise, the result of rounding the argument towards zero is returned.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- %a = call i8 @llvm.fptoui.sat.i8.f32(float 123.875) ; yields i8: 123
- %b = call i8 @llvm.fptoui.sat.i8.f32(float -5.75) ; yields i8: 0
- %c = call i8 @llvm.fptoui.sat.i8.f32(float 377.0) ; yields i8: 255
- %d = call i8 @llvm.fptoui.sat.i8.f32(float 0xFFF8000000000000) ; yields i8: 0
+```text
+%a = call i8 @llvm.fptoui.sat.i8.f32(float 123.875) ; yields i8: 123
+%b = call i8 @llvm.fptoui.sat.i8.f32(float -5.75) ; yields i8: 0
+%c = call i8 @llvm.fptoui.sat.i8.f32(float 377.0) ; yields i8: 255
+%d = call i8 @llvm.fptoui.sat.i8.f32(float 0xFFF8000000000000) ; yields i8: 0
+```
-'``llvm.fptosi.sat.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.fptosi.sat.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.fptosi.sat`` on any
+This is an overloaded intrinsic. You can use `llvm.fptosi.sat` on any
floating-point argument type and any integer result type, or vectors thereof.
Not all targets may support all types, however.
-::
-
- declare i32 @llvm.fptosi.sat.i32.f32(float %f)
- declare i19 @llvm.fptosi.sat.i19.f64(double %f)
- declare <4 x i100> @llvm.fptosi.sat.v4i100.v4f128(<4 x fp128> %f)
+```
+declare i32 @llvm.fptosi.sat.i32.f32(float %f)
+declare i19 @llvm.fptosi.sat.i19.f64(double %f)
+declare <4 x i100> @llvm.fptosi.sat.v4i100.v4f128(<4 x fp128> %f)
+```
-Overview:
-"""""""""
+##### Overview:
This intrinsic converts the argument into a signed integer using saturating
semantics.
-Arguments:
-""""""""""
+##### Arguments:
The argument may be any floating-point or vector of floating-point type. The
return value may be any integer or vector of integer type. The number of vector
elements in argument and return must be the same.
-Semantics:
-""""""""""
+##### Semantics:
The conversion to integer is performed subject to the following rules:
@@ -22682,259 +21227,229 @@ The conversion to integer is performed subject to the following rules:
signed integer is returned.
- Otherwise, the result of rounding the argument towards zero is returned.
-Example:
-""""""""
-
-.. code-block:: text
+##### Example:
- %a = call i8 @llvm.fptosi.sat.i8.f32(float 23.875) ; yields i8: 23
- %b = call i8 @llvm.fptosi.sat.i8.f32(float -130.75) ; yields i8: -128
- %c = call i8 @llvm.fptosi.sat.i8.f32(float 999.0) ; yields i8: 127
- %d = call i8 @llvm.fptosi.sat.i8.f32(float 0xFFF8000000000000) ; yields i8: 0
+```text
+%a = call i8 @llvm.fptosi.sat.i8.f32(float 23.875) ; yields i8: 23
+%b = call i8 @llvm.fptosi.sat.i8.f32(float -130.75) ; yields i8: -128
+%c = call i8 @llvm.fptosi.sat.i8.f32(float 999.0) ; yields i8: 127
+%d = call i8 @llvm.fptosi.sat.i8.f32(float 0xFFF8000000000000) ; yields i8: 0
+```
-Floating-Point Conversion Intrinsics
-------------------------------------
+### Floating-Point Conversion Intrinsics
This class of intrinsics is designed for floating-point conversions that do
not fall into other categories. For example conversions with specified rounding
mode or mini-float conversions.
-'``llvm.fptrunc.round``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.fptrunc.round`' Intrinsic
-::
+##### Syntax:
- declare <ty2>
- @llvm.fptrunc.round(<type> <value>, metadata <rounding mode>)
+```
+declare <ty2>
+ at llvm.fptrunc.round(<type> <value>, metadata <rounding mode>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.fptrunc.round``' intrinsic truncates
-:ref:`floating-point <t_floating>` ``value`` to type ``ty2``
+The '`llvm.fptrunc.round`' intrinsic truncates
+{ref}`floating-point <t_floating>` `value` to type `ty2`
with a specified rounding mode.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.fptrunc.round``' intrinsic takes a :ref:`floating-point
-<t_floating>` value to cast and a :ref:`floating-point <t_floating>` type
+The '`llvm.fptrunc.round`' intrinsic takes a {ref}`floating-point <t_floating>` value to cast and a {ref}`floating-point <t_floating>` type
to cast it to. This argument must be larger in size than the result.
The second argument specifies the rounding mode as described in the constrained
intrinsics section.
For this intrinsic, the "round.dynamic" mode is not supported.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.fptrunc.round``' intrinsic casts a ``value`` from a larger
-:ref:`floating-point <t_floating>` type to a smaller :ref:`floating-point
-<t_floating>` type.
-This intrinsic is assumed to execute in the default :ref:`floating-point
-environment <floatenv>` *except* for the rounding mode.
+The '`llvm.fptrunc.round`' intrinsic casts a `value` from a larger
+{ref}`floating-point <t_floating>` type to a smaller {ref}`floating-point <t_floating>` type.
+This intrinsic is assumed to execute in the default {ref}`floating-point environment <floatenv>` *except* for the rounding mode.
This intrinsic is not supported on all targets. Some targets may not support
all rounding modes.
-'``llvm.convert.to.arbitrary.fp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.convert.to.arbitrary.fp`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <iNxM> @llvm.convert.to.arbitrary.fp.<iNxM>.<fNxM>(
- <fNxM> <value>, metadata <interpretation>,
- metadata <rounding mode>, i1 <saturation>)
+```
+declare <iNxM> @llvm.convert.to.arbitrary.fp.<iNxM>.<fNxM>(
+ <fNxM> <value>, metadata <interpretation>,
+ metadata <rounding mode>, i1 <saturation>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.convert.to.arbitrary.fp`` intrinsic converts a native LLVM
+The `llvm.convert.to.arbitrary.fp` intrinsic converts a native LLVM
floating-point value to an arbitrary FP format, returning the result as an integer
containing the arbitrary FP bits. This intrinsic is overloaded on both its return
type and first argument.
-Arguments:
-""""""""""
+##### Arguments:
-``value``
- The native LLVM floating-point value to convert (e.g., ``half``, ``float``, ``double``).
+`value`
+: The native LLVM floating-point value to convert (e.g., `half`, `float`, `double`).
-``interpretation``
- A metadata string describing the target arbitrary FP format. Supported format names include:
+`interpretation`
+: A metadata string describing the target arbitrary FP format. Supported format names include:
- - FP8 formats: ``"Float8E5M2"``, ``"Float8E5M2FNUZ"``, ``"Float8E4M3"``,
- ``"Float8E4M3FN"``, ``"Float8E4M3FNUZ"``, ``"Float8E4M3B11FNUZ"``, ``"Float8E3M4"``,
- ``"Float8E8M0FNU"``
- - FP6 formats: ``"Float6E3M2FN"``, ``"Float6E2M3FN"``
- - FP4 formats: ``"Float4E2M1FN"``
+ - FP8 formats: `"Float8E5M2"`, `"Float8E5M2FNUZ"`, `"Float8E4M3"`,
+ `"Float8E4M3FN"`, `"Float8E4M3FNUZ"`, `"Float8E4M3B11FNUZ"`, `"Float8E3M4"`,
+ `"Float8E8M0FNU"`
+ - FP6 formats: `"Float6E3M2FN"`, `"Float6E2M3FN"`
+ - FP4 formats: `"Float4E2M1FN"`
-``rounding mode``
- A metadata string specifying the rounding mode. The permitted strings match those
- accepted by ``llvm.fptrunc.round`` (for example,
- ``"round.tonearest"`` or ``"round.towardzero"``).
+`rounding mode`
+: A metadata string specifying the rounding mode. The permitted strings match those
+ accepted by `llvm.fptrunc.round` (for example,
+ `"round.tonearest"` or `"round.towardzero"`).
- The rounding mode is only consulted when ``value`` is not exactly representable in the target format.
+ The rounding mode is only consulted when `value` is not exactly representable in the target format.
If the value is exactly representable, all rounding modes produce the same result.
-``saturation``
- A compile-time constant boolean value (``i1``). This parameter controls how overflow is handled
+`saturation`
+: A compile-time constant boolean value (`i1`). This parameter controls how overflow is handled
when values exceed the representable finite range of the target format:
- - When ``true``: overflowing values are clamped to the minimum or maximum representable finite value
+ - When `true`: overflowing values are clamped to the minimum or maximum representable finite value
(saturating to the largest negative finite value or largest positive finite value).
- - When ``false``: overflowing values are converted to infinity (preserving sign of the original value) if the
+ - When `false`: overflowing values are converted to infinity (preserving sign of the original value) if the
target format supports infinity, or return a poison value if infinity is not supported
by the target format.
This parameter must be an immediate constant.
-Semantics:
-""""""""""
+##### Semantics:
The intrinsic converts the native LLVM floating-point value to the arbitrary FP
-format specified by ``interpretation``, applying the requested rounding mode and
+format specified by `interpretation`, applying the requested rounding mode and
saturation behavior. The conversion is performed in two steps: first, the value is
rounded according to the specified rounding mode to fit the target format's precision;
then, if the rounded result exceeds the target format's representable range, saturation
-is applied according to the ``saturation`` parameter. The result is returned as an
-integer (e.g., ``i8`` for FP8, ``i6`` for FP6) containing the encoded arbitrary FP bits.
+is applied according to the `saturation` parameter. The result is returned as an
+integer (e.g., `i8` for FP8, `i6` for FP6) containing the encoded arbitrary FP bits.
**Handling of special values:**
-- **NaN**: NaN values follow LLVM's standard :ref:`NaN rules <floatnan>`. When the target
+- **NaN**: NaN values follow LLVM's standard {ref}`NaN rules <floatnan>`. When the target
format supports NaN, the NaN representation is preserved (quiet NaNs remain quiet, signaling
NaNs remain signaling). The exact NaN payload may be truncated or extended to fit the target
format's payload size. If the target format does not support NaN, the intrinsic returns a
poison value.
- **Infinity and Overflow**: If the input is +/-Inf or a finite value that exceeds the representable range:
- - When ``saturation`` is ``false`` and the target format supports infinity, the result is +/-Inf (preserving the sign).
- - When ``saturation`` is ``false`` and the target format does not support infinity (e.g., formats
+ - When `saturation` is `false` and the target format supports infinity, the result is +/-Inf (preserving the sign).
+ - When `saturation` is `false` and the target format does not support infinity (e.g., formats
with "FN" suffix), the intrinsic returns a poison value.
- - When ``saturation`` is ``true``, the value is clamped to the maximum/minimum representable finite value.
-
-For FP6/FP4 interpretations, producers are expected to use ``saturation`` = ``true``; using ``saturation`` = ``false`` and generating NaN/Inf/overflowing values results in a poison value.
-
-Example:
-""""""""
+ - When `saturation` is `true`, the value is clamped to the maximum/minimum representable finite value.
-::
+For FP6/FP4 interpretations, producers are expected to use `saturation` = `true`; using `saturation` = `false` and generating NaN/Inf/overflowing values results in a poison value.
- ; Convert half to FP8 E4M3 format
- %fp8bits = call i8 @llvm.convert.to.arbitrary.fp.i8.f16(
- half %value, metadata !"Float8E4M3",
- metadata !"round.tonearest", i1 false)
+##### Example:
- ; Convert vector of float to FP8 E5M2 with saturation
- %vec_fp8 = call <4 x i8> @llvm.convert.to.arbitrary.fp.v4i8.v4f32(
- <4 x float> %values, metadata !"Float8E5M2",
- metadata !"round.towardzero", i1 true)
+```
+; Convert half to FP8 E4M3 format
+%fp8bits = call i8 @llvm.convert.to.arbitrary.fp.i8.f16(
+ half %value, metadata !"Float8E4M3",
+ metadata !"round.tonearest", i1 false)
-'``llvm.convert.from.arbitrary.fp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+; Convert vector of float to FP8 E5M2 with saturation
+%vec_fp8 = call <4 x i8> @llvm.convert.to.arbitrary.fp.v4i8.v4f32(
+ <4 x float> %values, metadata !"Float8E5M2",
+ metadata !"round.towardzero", i1 true)
+```
-Syntax:
-"""""""
+#### '`llvm.convert.from.arbitrary.fp`' Intrinsic
-::
+##### Syntax:
- declare <fNxM> @llvm.convert.from.arbitrary.fp.<fNxM>.<iNxM>(
- <iNxM> <value>, metadata <interpretation>)
+```
+declare <fNxM> @llvm.convert.from.arbitrary.fp.<fNxM>.<iNxM>(
+ <iNxM> <value>, metadata <interpretation>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.convert.from.arbitrary.fp`` intrinsic converts an integer containing
+The `llvm.convert.from.arbitrary.fp` intrinsic converts an integer containing
arbitrary FP bits to a native LLVM floating-point value. This intrinsic is
overloaded on both its return type and first argument.
-Arguments:
-""""""""""
+##### Arguments:
-``value``
- An integer value containing the arbitrary FP bits (e.g., ``i8`` for FP8, ``i6`` for FP6).
+`value`
+: An integer value containing the arbitrary FP bits (e.g., `i8` for FP8, `i6` for FP6).
-``interpretation``
- A metadata string describing the source arbitrary FP format. Supported format names include:
+`interpretation`
+: A metadata string describing the source arbitrary FP format. Supported format names include:
- - FP8 formats: ``"Float8E5M2"``, ``"Float8E5M2FNUZ"``, ``"Float8E4M3"``,
- ``"Float8E4M3FN"``, ``"Float8E4M3FNUZ"``, ``"Float8E4M3B11FNUZ"``, ``"Float8E3M4"``,
- ``"Float8E8M0FNU"``
- - FP6 formats: ``"Float6E3M2FN"``, ``"Float6E2M3FN"``
- - FP4 formats: ``"Float4E2M1FN"``
+ - FP8 formats: `"Float8E5M2"`, `"Float8E5M2FNUZ"`, `"Float8E4M3"`,
+ `"Float8E4M3FN"`, `"Float8E4M3FNUZ"`, `"Float8E4M3B11FNUZ"`, `"Float8E3M4"`,
+ `"Float8E8M0FNU"`
+ - FP6 formats: `"Float6E3M2FN"`, `"Float6E2M3FN"`
+ - FP4 formats: `"Float4E2M1FN"`
-Semantics:
-""""""""""
+##### Semantics:
The intrinsic interprets the integer value as arbitrary FP bits according to
-``interpretation``, then converts to the native LLVM floating-point result type.
+`interpretation`, then converts to the native LLVM floating-point result type.
Conversions from arbitrary FP formats to native LLVM floating-point types are
widening conversions (e.g., FP8 to FP16 or FP32), which are exact and require no rounding.
-Normal finite values are converted exactly. NaN values follow LLVM's standard :ref:`NaN rules
-<floatnan>`; the NaN representation is preserved (quiet NaNs remain quiet, signaling NaNs
+Normal finite values are converted exactly. NaN values follow LLVM's standard {ref}`NaN rules <floatnan>`; the NaN representation is preserved (quiet NaNs remain quiet, signaling NaNs
remain signaling), and the NaN payload may be truncated or extended to fit the target format's
payload size. Infinity values are preserved as infinity. If a value exceeds the representable
-range of the target type (for example, converting ``Float8E8M0FNU`` with large exponents to
-``half``), the result is converted to infinity with the appropriate sign.
-
-Example:
-""""""""
+range of the target type (for example, converting `Float8E8M0FNU` with large exponents to
+`half`), the result is converted to infinity with the appropriate sign.
-::
+##### Example:
- ; Convert FP8 E4M3 bits to half
- %half_val = call half @llvm.convert.from.arbitrary.fp.f16.i8(
- i8 %fp8bits, metadata !"Float8E4M3")
+```
+; Convert FP8 E4M3 bits to half
+%half_val = call half @llvm.convert.from.arbitrary.fp.f16.i8(
+ i8 %fp8bits, metadata !"Float8E4M3")
- ; Convert vector of FP8 E5M2 bits to float
- %vec_float = call <4 x float> @llvm.convert.from.arbitrary.fp.v4f32.v4i8(
- <4 x i8> %fp8_values, metadata !"Float8E5M2")
+; Convert vector of FP8 E5M2 bits to float
+%vec_float = call <4 x float> @llvm.convert.from.arbitrary.fp.v4f32.v4i8(
+ <4 x i8> %fp8_values, metadata !"Float8E5M2")
+```
-Convergence Intrinsics
-----------------------
+### Convergence Intrinsics
-The LLVM convergence intrinsics for controlling the semantics of ``convergent``
-operations, which all start with the ``llvm.experimental.convergence.``
-prefix, are described in the :doc:`ConvergentOperations` document.
+The LLVM convergence intrinsics for controlling the semantics of `convergent`
+operations, which all start with the `llvm.experimental.convergence.`
+prefix, are described in the {doc}`ConvergentOperations` document.
-.. _dbg_intrinsics:
+(dbg_intrinsics)=
-Debugger Intrinsics
--------------------
+### Debugger Intrinsics
-The LLVM debugger intrinsics (which all start with ``llvm.dbg.``
-prefix), are described in the `LLVM Source Level
-Debugging <SourceLevelDebugging.html#format-common-intrinsics>`_
-document.
+The LLVM debugger intrinsics (which all start with `llvm.dbg.`
+prefix), are described in the
+{ref}`LLVM Source Level Debugging <format_common_intrinsics>` document.
-Exception Handling Intrinsics
------------------------------
+### Exception Handling Intrinsics
The LLVM exception handling intrinsics (which all start with
-``llvm.eh.`` prefix), are described in the `LLVM Exception
-Handling <ExceptionHandling.html#format-common-intrinsics>`_ document.
+`llvm.eh.` prefix), are described in the [LLVM Exception
+Handling](ExceptionHandling.md#exception-handling-intrinsics) document.
-Pointer Authentication Intrinsics
----------------------------------
+### Pointer Authentication Intrinsics
The LLVM pointer authentication intrinsics (which all start with
-``llvm.ptrauth.`` prefix), are described in the `Pointer Authentication
-<PointerAuth.html#intrinsics>`_ document.
+`llvm.ptrauth.` prefix), are described in the [Pointer Authentication](PointerAuth.md#intrinsics) document.
-.. _int_trampoline:
+(int_trampoline)=
-Trampoline Intrinsics
----------------------
+### Trampoline Intrinsics
These intrinsics make it possible to excise one parameter, marked with
-the :ref:`nest <nest>` attribute, from a function. The result is a
+the {ref}`nest <nest>` attribute, from a function. The result is a
callable function pointer lacking the nest parameter - the caller does
not need to provide a value for it. Instead, the value to use is stored
in advance in a "trampoline", a block of memory usually allocated on the
@@ -22942,1900 +21457,1634 @@ stack, which also contains code to splice the nest value into the
argument list. This is used to implement the GCC nested function address
extension.
-For example, if the function is ``i32 f(ptr nest %c, i32 %x, i32 %y)``
-then the resulting function pointer has signature ``i32 (i32, i32)``.
+For example, if the function is `i32 f(ptr nest %c, i32 %x, i32 %y)`
+then the resulting function pointer has signature `i32 (i32, i32)`.
It can be created as follows:
-.. code-block:: llvm
+```llvm
+%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
+call ptr @llvm.init.trampoline(ptr %tramp, ptr @f, ptr %nval)
+%fp = call ptr @llvm.adjust.trampoline(ptr %tramp)
+```
- %tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
- call ptr @llvm.init.trampoline(ptr %tramp, ptr @f, ptr %nval)
- %fp = call ptr @llvm.adjust.trampoline(ptr %tramp)
+The call `%val = call i32 %fp(i32 %x, i32 %y)` is then equivalent to
+`%val = call i32 %f(ptr %nval, i32 %x, i32 %y)`.
-The call ``%val = call i32 %fp(i32 %x, i32 %y)`` is then equivalent to
-``%val = call i32 %f(ptr %nval, i32 %x, i32 %y)``.
+(int_it)=
-.. _int_it:
+#### '`llvm.init.trampoline`' Intrinsic
-'``llvm.init.trampoline``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+declare void @llvm.init.trampoline(ptr <tramp>, ptr <func>, ptr <nval>)
+```
- declare void @llvm.init.trampoline(ptr <tramp>, ptr <func>, ptr <nval>)
+##### Overview:
-Overview:
-"""""""""
-
-This fills the memory pointed to by ``tramp`` with executable code,
+This fills the memory pointed to by `tramp` with executable code,
turning it into a trampoline.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.init.trampoline`` intrinsic takes three arguments, all
-pointers. The ``tramp`` argument must point to a sufficiently large and
+The `llvm.init.trampoline` intrinsic takes three arguments, all
+pointers. The `tramp` argument must point to a sufficiently large and
sufficiently aligned block of memory; this memory is written to by the
intrinsic. Note that the size and the alignment are target-specific -
LLVM currently provides no portable way of determining them, so a
front-end that generates this intrinsic needs to have some
target-specific knowledge.
-The ``func`` argument must be a constant (potentially bitcasted) pointer to a
+The `func` argument must be a constant (potentially bitcasted) pointer to a
function declaration or definition, since the calling convention may affect the
content of the trampoline that is created.
-Semantics:
-""""""""""
+##### Semantics:
-The block of memory pointed to by ``tramp`` is filled with target
-dependent code, turning it into a function. Then ``tramp`` needs to be
-passed to :ref:`llvm.adjust.trampoline <int_at>` to get a pointer which can
-be :ref:`bitcast (to a new function) and called <int_trampoline>`. The new
-function's signature is the same as that of ``func`` with any arguments
-marked with the ``nest`` attribute removed. At most one such ``nest``
+The block of memory pointed to by `tramp` is filled with target
+dependent code, turning it into a function. Then `tramp` needs to be
+passed to {ref}`llvm.adjust.trampoline <int_at>` to get a pointer which can
+be {ref}`bitcast (to a new function) and called <int_trampoline>`. The new
+function's signature is the same as that of `func` with any arguments
+marked with the `nest` attribute removed. At most one such `nest`
argument is allowed, and it must be of pointer type. Calling the new
-function is equivalent to calling ``func`` with the same argument list,
-but with ``nval`` used for the missing ``nest`` argument. If, after
-calling ``llvm.init.trampoline``, the memory pointed to by ``tramp`` is
+function is equivalent to calling `func` with the same argument list,
+but with `nval` used for the missing `nest` argument. If, after
+calling `llvm.init.trampoline`, the memory pointed to by `tramp` is
modified, then the effect of any later call to the returned function
pointer is undefined.
-.. _int_at:
+(int_at)=
-'``llvm.adjust.trampoline``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.adjust.trampoline`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-::
+```
+declare ptr @llvm.adjust.trampoline(ptr <tramp>)
+```
- declare ptr @llvm.adjust.trampoline(ptr <tramp>)
-
-Overview:
-"""""""""
+##### Overview:
This performs any required machine-specific adjustment to the address of
-a trampoline (passed as ``tramp``).
+a trampoline (passed as `tramp`).
-Arguments:
-""""""""""
+##### Arguments:
-``tramp`` must point to a block of memory which already has trampoline
+`tramp` must point to a block of memory which already has trampoline
code filled in by a previous call to
-:ref:`llvm.init.trampoline <int_it>`.
+{ref}`llvm.init.trampoline <int_it>`.
-Semantics:
-""""""""""
+##### Semantics:
On some architectures the address of the code to be executed needs to be
different than the address where the trampoline is actually stored. This
-intrinsic returns the executable address corresponding to ``tramp``
+intrinsic returns the executable address corresponding to `tramp`
after performing the required machine-specific adjustments. The pointer
-returned can then be :ref:`bitcast and executed <int_trampoline>`.
+returned can then be {ref}`bitcast and executed <int_trampoline>`.
-.. _int_vp:
+(int_vp)=
-Vector Predication Intrinsics
------------------------------
+### Vector Predication Intrinsics
VP intrinsics are intended for predicated SIMD/vector code. A typical VP
operation takes a vector mask and an explicit vector length parameter as in:
-::
-
- <W x T> llvm.vp.<opcode>.*(<W x T> %x, <W x T> %y, <W x i1> %mask, i32 %evl)
+```
+<W x T> llvm.vp.<opcode>.*(<W x T> %x, <W x T> %y, <W x i1> %mask, i32 %evl)
+```
The vector mask parameter (%mask) always has a vector of `i1` type, for example
`<32 x i1>`. The explicit vector length parameter always has the type `i32` and
is an unsigned integer value. The explicit vector length parameter (%evl) is in
the range:
-::
-
- 0 <= %evl <= W, where W is the number of vector elements
+```
+0 <= %evl <= W, where W is the number of vector elements
+```
-Note that for :ref:`scalable vector types <t_vector>` ``W`` is the runtime
+Note that for {ref}`scalable vector types <t_vector>` `W` is the runtime
length of the vector.
-The VP intrinsic has undefined behavior if ``%evl > W``. The explicit vector
-length (%evl) creates a mask, %EVLmask, with all elements ``0 <= i < %evl`` set
-to True, and all other lanes ``%evl <= i < W`` to False. A new mask %M is
+The VP intrinsic has undefined behavior if `%evl > W`. The explicit vector
+length (%evl) creates a mask, %EVLmask, with all elements `0 <= i < %evl` set
+to True, and all other lanes `%evl <= i < W` to False. A new mask %M is
calculated with an element-wise AND from %mask and %EVLmask:
-::
-
- M = %mask AND %EVLmask
-
-A vector operation ``<opcode>`` on vectors ``A`` and ``B`` calculates:
+```
+M = %mask AND %EVLmask
+```
-::
+A vector operation `<opcode>` on vectors `A` and `B` calculates:
- A <opcode> B = { A[i] <opcode> B[i] M[i] = True, and
- { undef otherwise
+```
+A <opcode> B = { A[i] <opcode> B[i] M[i] = True, and
+ { undef otherwise
+```
-Optimization Hint
-^^^^^^^^^^^^^^^^^
+#### Optimization Hint
Some targets, such as AVX512, do not support the %evl parameter in hardware.
The use of an effective %evl is discouraged for those targets. The function
-``TargetTransformInfo::hasActiveVectorLength()`` returns true when the target
+`TargetTransformInfo::hasActiveVectorLength()` returns true when the target
has native support for %evl.
-.. _int_vp_select:
+(int_vp_select)=
-'``llvm.vp.select.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.select.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.select.v16i32 (<16 x i1> <condition>, <16 x i32> <on_true>, <16 x i32> <on_false>, i32 <evl>)
- declare <vscale x 4 x i64> @llvm.vp.select.nxv4i64 (<vscale x 4 x i1> <condition>, <vscale x 4 x i64> <on_true>, <vscale x 4 x i64> <on_false>, i32 <evl>)
+```
+declare <16 x i32> @llvm.vp.select.v16i32 (<16 x i1> <condition>, <16 x i32> <on_true>, <16 x i32> <on_false>, i32 <evl>)
+declare <vscale x 4 x i64> @llvm.vp.select.nxv4i64 (<vscale x 4 x i1> <condition>, <vscale x 4 x i64> <on_true>, <vscale x 4 x i64> <on_false>, i32 <evl>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.select``' intrinsic is used to choose one value based on a
+The '`llvm.vp.select`' intrinsic is used to choose one value based on a
condition vector, without IR-level branching.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is a vector of ``i1`` and indicates the condition. The
+The first argument is a vector of `i1` and indicates the condition. The
second argument is the value that is selected where the condition vector is
true. The third argument is the value that is selected where the condition
vector is false. The vectors must be of the same size. The fourth argument is
the explicit vector length.
-#. The optional ``fast-math flags`` marker indicates that the select has one or
- more :ref:`fast-math flags <fastmath>`. These are optimization hints to
+1. The optional `fast-math flags` marker indicates that the select has one or
+ more {ref}`fast-math flags <fastmath>`. These are optimization hints to
enable otherwise unsafe floating-point optimizations. Fast-math flags are
- only valid for selects that return :ref:`supported floating-point types
- <fastmath_return_types>`.
+ only valid for selects that return {ref}`supported floating-point types <fastmath_return_types>`.
-Semantics:
-""""""""""
+##### Semantics:
The intrinsic selects lanes from the second and third argument depending on a
condition vector.
-All result lanes at positions greater or equal than ``%evl`` are undefined.
-For all lanes below ``%evl`` where the condition vector is true the lane is
+All result lanes at positions greater or equal than `%evl` are undefined.
+For all lanes below `%evl` where the condition vector is true the lane is
taken from the second argument. Otherwise, the lane is taken from the third
argument.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %r = call <4 x i32> @llvm.vp.select.v4i32(<4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false, i32 %evl)
+```llvm
+%r = call <4 x i32> @llvm.vp.select.v4i32(<4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false, i32 %evl)
- ;;; Expansion.
- ;; Any result is legal on lanes at and above %evl.
- %also.r = select <4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false
+;;; Expansion.
+;; Any result is legal on lanes at and above %evl.
+%also.r = select <4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false
+```
+(int_vp_merge)=
-.. _int_vp_merge:
+#### '`llvm.vp.merge.*`' Intrinsics
-'``llvm.vp.merge.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.merge.v16i32 (<16 x i1> <condition>, <16 x i32> <on_true>, <16 x i32> <on_false>, i32 <pivot>)
- declare <vscale x 4 x i64> @llvm.vp.merge.nxv4i64 (<vscale x 4 x i1> <condition>, <vscale x 4 x i64> <on_true>, <vscale x 4 x i64> <on_false>, i32 <pivot>)
+```
+declare <16 x i32> @llvm.vp.merge.v16i32 (<16 x i1> <condition>, <16 x i32> <on_true>, <16 x i32> <on_false>, i32 <pivot>)
+declare <vscale x 4 x i64> @llvm.vp.merge.nxv4i64 (<vscale x 4 x i1> <condition>, <vscale x 4 x i64> <on_true>, <vscale x 4 x i64> <on_false>, i32 <pivot>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.merge``' intrinsic is used to choose one value based on a
+The '`llvm.vp.merge`' intrinsic is used to choose one value based on a
condition vector and an index argument, without IR-level branching.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is a vector of ``i1`` and indicates the condition. The
+The first argument is a vector of `i1` and indicates the condition. The
second argument is the value that is merged where the condition vector is true.
The third argument is the value that is selected where the condition vector is
false or the lane position is greater equal than the pivot. The fourth argument
is the pivot.
-#. The optional ``fast-math flags`` marker indicates that the merge has one or
- more :ref:`fast-math flags <fastmath>`. These are optimization hints to
+1. The optional `fast-math flags` marker indicates that the merge has one or
+ more {ref}`fast-math flags <fastmath>`. These are optimization hints to
enable otherwise unsafe floating-point optimizations. Fast-math flags are
- only valid for merges that return :ref:`supported floating-point types
- <fastmath_return_types>`.
+ only valid for merges that return {ref}`supported floating-point types <fastmath_return_types>`.
-Semantics:
-""""""""""
+##### Semantics:
The intrinsic selects lanes from the second and third argument depending on a
condition vector and pivot value.
For all lanes where the condition vector is true and the lane position is less
-than ``%pivot`` the lane is taken from the second argument. Otherwise, the lane
+than `%pivot` the lane is taken from the second argument. Otherwise, the lane
is taken from the third argument.
-Example:
-""""""""
-
-.. code-block:: llvm
+##### Example:
- %r = call <4 x i32> @llvm.vp.merge.v4i32(<4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false, i32 %pivot)
+```llvm
+%r = call <4 x i32> @llvm.vp.merge.v4i32(<4 x i1> %cond, <4 x i32> %on_true, <4 x i32> %on_false, i32 %pivot)
- ;;; Expansion.
- ;; Lanes at and above %pivot are taken from %on_false
- %atfirst = insertelement <4 x i32> poison, i32 %pivot, i32 0
- %splat = shufflevector <4 x i32> %atfirst, <4 x i32> poison, <4 x i32> zeroinitializer
- %pivotmask = icmp ult <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> %splat
- %mergemask = and <4 x i1> %cond, <4 x i1> %pivotmask
- %also.r = select <4 x i1> %mergemask, <4 x i32> %on_true, <4 x i32> %on_false
+;;; Expansion.
+;; Lanes at and above %pivot are taken from %on_false
+%atfirst = insertelement <4 x i32> poison, i32 %pivot, i32 0
+%splat = shufflevector <4 x i32> %atfirst, <4 x i32> poison, <4 x i32> zeroinitializer
+%pivotmask = icmp ult <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> %splat
+%mergemask = and <4 x i1> %cond, <4 x i1> %pivotmask
+%also.r = select <4 x i1> %mergemask, <4 x i32> %on_true, <4 x i32> %on_false
+```
+(int_vp_add)=
+#### '`llvm.vp.add.*`' Intrinsics
-.. _int_vp_add:
-
-'``llvm.vp.add.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.add.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.add.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.add.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.add.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.add.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.add.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated integer addition of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.add``' intrinsic performs integer addition (:ref:`add <i_add>`)
+The '`llvm.vp.add`' intrinsic performs integer addition ({ref}`add <i_add>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.add.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.add.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = add <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = add <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_sub:
+(int_vp_sub)=
-'``llvm.vp.sub.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.sub.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.sub.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.sub.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.sub.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.sub.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.sub.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.sub.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated integer subtraction of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sub``' intrinsic performs integer subtraction
-(:ref:`sub <i_sub>`) of the first and second vector arguments on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+The '`llvm.vp.sub`' intrinsic performs integer subtraction
+({ref}`sub <i_sub>`) of the first and second vector arguments on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: llvm
+```llvm
+%r = call <4 x i32> @llvm.vp.sub.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %r = call <4 x i32> @llvm.vp.sub.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = sub <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
- %t = sub <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+(int_vp_mul)=
+#### '`llvm.vp.mul.*`' Intrinsics
-
-.. _int_vp_mul:
-
-'``llvm.vp.mul.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.mul.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.mul.nxv46i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.mul.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.mul.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.mul.nxv46i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.mul.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated integer multiplication of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-The '``llvm.vp.mul``' intrinsic performs integer multiplication
-(:ref:`mul <i_mul>`) of the first and second vector arguments on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Semantics:
+The '`llvm.vp.mul`' intrinsic performs integer multiplication
+({ref}`mul <i_mul>`) of the first and second vector arguments on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.mul.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = mul <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.mul.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = mul <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_sdiv:
+(int_vp_sdiv)=
-'``llvm.vp.sdiv.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.sdiv.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.sdiv.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.sdiv.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.sdiv.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.sdiv.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.sdiv.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.sdiv.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated, signed division of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sdiv``' intrinsic performs signed division (:ref:`sdiv <i_sdiv>`)
+The '`llvm.vp.sdiv`' intrinsic performs signed division ({ref}`sdiv <i_sdiv>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.sdiv.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.sdiv.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = sdiv <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = sdiv <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_udiv)=
-.. _int_vp_udiv:
+#### '`llvm.vp.udiv.*`' Intrinsics
-'``llvm.vp.udiv.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.udiv.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.udiv.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.udiv.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.udiv.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.udiv.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.udiv.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated, unsigned division of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.udiv``' intrinsic performs unsigned division
-(:ref:`udiv <i_udiv>`) of the first and second vector arguments on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.udiv`' intrinsic performs unsigned division
+({ref}`udiv <i_udiv>`) of the first and second vector arguments on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.udiv.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.udiv.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = udiv <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = udiv <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_srem)=
+#### '`llvm.vp.srem.*`' Intrinsics
-.. _int_vp_srem:
-
-'``llvm.vp.srem.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.srem.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.srem.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.srem.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.srem.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.srem.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.srem.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated computations of the signed remainder of two integer vectors.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.srem``' intrinsic computes the remainder of the signed division
-(:ref:`srem <i_srem>`) of the first and second vector arguments on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+The '`llvm.vp.srem`' intrinsic computes the remainder of the signed division
+({ref}`srem <i_srem>`) of the first and second vector arguments on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x i32> @llvm.vp.srem.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = srem <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.srem.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = srem <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_urem)=
-.. _int_vp_urem:
+#### '`llvm.vp.urem.*`' Intrinsics
-'``llvm.vp.urem.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.urem.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.urem.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.urem.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.urem.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.urem.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.urem.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated computation of the unsigned remainder of two integer vectors.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.urem``' intrinsic computes the remainder of the unsigned division
-(:ref:`urem <i_urem>`) of the first and second vector arguments on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+##### Semantics:
-.. code-block:: llvm
+The '`llvm.vp.urem`' intrinsic computes the remainder of the unsigned division
+({ref}`urem <i_urem>`) of the first and second vector arguments on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.urem.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = urem <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.urem.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = urem <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_ashr:
+(int_vp_ashr)=
-'``llvm.vp.ashr.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.ashr.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.ashr.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.ashr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.ashr.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.ashr.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.ashr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.ashr.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Vector-predicated arithmetic right-shift.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.ashr``' intrinsic computes the arithmetic right shift
-(:ref:`ashr <i_ashr>`) of the first argument by the second argument on each
+The '`llvm.vp.ashr`' intrinsic computes the arithmetic right shift
+({ref}`ashr <i_ashr>`) of the first argument by the second argument on each
enabled lane. The result on disabled lanes is a
-:ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+{ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.ashr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = ashr <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.ashr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = ashr <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_lshr:
+(int_vp_lshr)=
-'``llvm.vp.lshr.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.lshr.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.lshr.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.lshr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.lshr.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.lshr.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.lshr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.lshr.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Vector-predicated logical right-shift.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.lshr``' intrinsic computes the logical right shift
-(:ref:`lshr <i_lshr>`) of the first argument by the second argument on each
+The '`llvm.vp.lshr`' intrinsic computes the logical right shift
+({ref}`lshr <i_lshr>`) of the first argument by the second argument on each
enabled lane. The result on disabled lanes is a
-:ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+{ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.lshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.lshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = lshr <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = lshr <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_shl)=
-.. _int_vp_shl:
+#### '`llvm.vp.shl.*`' Intrinsics
-'``llvm.vp.shl.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.shl.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.shl.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.shl.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.shl.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.shl.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.shl.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Vector-predicated left shift.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.shl``' intrinsic computes the left shift (:ref:`shl <i_shl>`) of
+The '`llvm.vp.shl`' intrinsic computes the left shift ({ref}`shl <i_shl>`) of
the first argument by the second argument on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.shl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = shl <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.shl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = shl <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_or:
+(int_vp_or)=
-'``llvm.vp.or.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.or.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.or.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.or.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.or.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.or.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.or.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.or.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Vector-predicated or.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.or``' intrinsic performs a bitwise or (:ref:`or <i_or>`) of the
+The '`llvm.vp.or`' intrinsic performs a bitwise or ({ref}`or <i_or>`) of the
first two arguments on each enabled lane. The result on disabled lanes is
-a :ref:`poison value <poisonvalues>`.
+a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x i32> @llvm.vp.or.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = or <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.or.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = or <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_and:
+(int_vp_and)=
-'``llvm.vp.and.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.and.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.and.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.and.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.and.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.and.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.and.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.and.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Vector-predicated and.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.and``' intrinsic performs a bitwise and (:ref:`and <i_or>`) of
+The '`llvm.vp.and`' intrinsic performs a bitwise and ({ref}`and <i_or>`) of
the first two arguments on each enabled lane. The result on disabled lanes is
-a :ref:`poison value <poisonvalues>`.
+a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.and.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.and.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = and <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = and <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_xor)=
-.. _int_vp_xor:
+#### '`llvm.vp.xor.*`' Intrinsics
-'``llvm.vp.xor.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.xor.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.xor.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.xor.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.xor.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.xor.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.xor.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Vector-predicated, bitwise xor.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.xor``' intrinsic performs a bitwise xor (:ref:`xor <i_xor>`) of
+The '`llvm.vp.xor`' intrinsic performs a bitwise xor ({ref}`xor <i_xor>`) of
the first two arguments on each enabled lane.
-The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.xor.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.xor.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = xor <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = xor <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_abs:
+(int_vp_abs)=
-'``llvm.vp.abs.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.abs.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.abs.v16i32 (<16 x i32> <op>, i1 <is_int_min_poison>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.abs.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_int_min_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.abs.v256i64 (<256 x i64> <op>, i1 <is_int_min_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.abs.v16i32 (<16 x i32> <op>, i1 <is_int_min_poison>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.abs.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_int_min_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.abs.v256i64 (<256 x i64> <op>, i1 <is_int_min_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated abs of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument must be a constant and is a flag to indicate whether the result
-value of the '``llvm.vp.abs``' intrinsic is a :ref:`poison value <poisonvalues>`
-if the first argument is statically or dynamically an ``INT_MIN`` value. The
+value of the '`llvm.vp.abs`' intrinsic is a {ref}`poison value <poisonvalues>`
+if the first argument is statically or dynamically an `INT_MIN` value. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.abs``' intrinsic performs abs (:ref:`abs <int_abs>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Semantics:
- %r = call <4 x i32> @llvm.vp.abs.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+The '`llvm.vp.abs`' intrinsic performs abs ({ref}`abs <int_abs>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %t = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %a, i1 false)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+##### Examples:
+```llvm
+%r = call <4 x i32> @llvm.vp.abs.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %a, i1 false)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_smax:
+(int_vp_smax)=
-'``llvm.vp.smax.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.smax.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.smax.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.smax.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.smax.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.smax.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.smax.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.smax.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated integer signed maximum of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.smax``' intrinsic performs integer signed maximum (:ref:`smax <int_smax>`)
+The '`llvm.vp.smax`' intrinsic performs integer signed maximum ({ref}`smax <int_smax>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.smax.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.smax.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_smin:
+(int_vp_smin)=
-'``llvm.vp.smin.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.smin.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.smin.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.smin.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.smin.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.smin.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.smin.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.smin.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated integer signed minimum of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.smin``' intrinsic performs integer signed minimum (:ref:`smin <int_smin>`)
+The '`llvm.vp.smin`' intrinsic performs integer signed minimum ({ref}`smin <int_smin>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.smin.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.smin.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_umax)=
-.. _int_vp_umax:
+#### '`llvm.vp.umax.*`' Intrinsics
-'``llvm.vp.umax.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.umax.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.umax.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.umax.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.umax.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.umax.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.umax.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated integer unsigned maximum of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.umax``' intrinsic performs integer unsigned maximum (:ref:`umax <int_umax>`)
+The '`llvm.vp.umax`' intrinsic performs integer unsigned maximum ({ref}`umax <int_umax>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.umax.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.umax.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_umin:
+(int_vp_umin)=
-'``llvm.vp.umin.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.umin.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.umin.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.umin.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.umin.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.umin.v16i32 (<16 x i32> <left_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.umin.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.umin.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated integer unsigned minimum of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.umin``' intrinsic performs integer unsigned minimum (:ref:`umin <int_umin>`)
+The '`llvm.vp.umin`' intrinsic performs integer unsigned minimum ({ref}`umin <int_umin>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x i32> @llvm.vp.umin.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.umin.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.umin.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.umin.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_copysign:
+(int_vp_copysign)=
-'``llvm.vp.copysign.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.copysign.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.copysign.v16f32 (<16 x float> <mag_op>, <16 x float> <sign_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.copysign.nxv4f32 (<vscale x 4 x float> <mag_op>, <vscale x 4 x float> <sign_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.copysign.v256f64 (<256 x double> <mag_op>, <256 x double> <sign_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.copysign.v16f32 (<16 x float> <mag_op>, <16 x float> <sign_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.copysign.nxv4f32 (<vscale x 4 x float> <mag_op>, <vscale x 4 x float> <sign_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.copysign.v256f64 (<256 x double> <mag_op>, <256 x double> <sign_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point copysign of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.copysign``' intrinsic performs floating-point copysign (:ref:`copysign <int_copysign>`)
+The '`llvm.vp.copysign`' intrinsic performs floating-point copysign ({ref}`copysign <int_copysign>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.copysign.v4f32(<4 x float> %mag, <4 x float> %sign, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.copysign.v4f32(<4 x float> %mag, <4 x float> %sign, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.copysign.v4f32(<4 x float> %mag, <4 x float> %sign)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.copysign.v4f32(<4 x float> %mag, <4 x float> %sign)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_minnum)=
-.. _int_vp_minnum:
+#### '`llvm.vp.minnum.*`' Intrinsics
-'``llvm.vp.minnum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.minnum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.minnum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.minnum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.minnum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.minnum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.minnum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point IEEE 754-2008 minNum of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.minnum``' intrinsic performs floating-point minimum (:ref:`minnum <i_minnum>`)
+The '`llvm.vp.minnum`' intrinsic performs floating-point minimum ({ref}`minnum <i_minnum>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.minnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.minnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %b)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %b)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_maxnum)=
-.. _int_vp_maxnum:
+#### '`llvm.vp.maxnum.*`' Intrinsics
-'``llvm.vp.maxnum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.maxnum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.maxnum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.maxnum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.maxnum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.maxnum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.maxnum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point IEEE 754-2008 maxNum of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.maxnum``' intrinsic performs floating-point maximum (:ref:`maxnum <i_maxnum>`)
+The '`llvm.vp.maxnum`' intrinsic performs floating-point maximum ({ref}`maxnum <i_maxnum>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.maxnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.maxnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_minimum:
+(int_vp_minimum)=
-'``llvm.vp.minimum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.minimum.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.minimum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.minimum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.minimum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.minimum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.minimum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.minimum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point minimum of two vectors of floating-point values,
propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.minimum``' intrinsic performs floating-point minimum (:ref:`minimum <i_minimum>`)
+The '`llvm.vp.minimum`' intrinsic performs floating-point minimum ({ref}`minimum <i_minimum>`)
of the first and second vector arguments on each enabled lane, the result being
NaN if either argument is a NaN. -0.0 is considered to be less than +0.0 for this
-intrinsic. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+intrinsic. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
The operation is performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.minimum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x float> @llvm.minimum.v4f32(<4 x float> %a, <4 x float> %b)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.minimum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x float> @llvm.minimum.v4f32(<4 x float> %a, <4 x float> %b)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_maximum:
+(int_vp_maximum)=
-'``llvm.vp.maximum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.maximum.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.maximum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.maximum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.maximum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.maximum.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.maximum.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.maximum.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point maximum of two vectors of floating-point values,
propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.maximum``' intrinsic performs floating-point maximum (:ref:`maximum <i_maximum>`)
+The '`llvm.vp.maximum`' intrinsic performs floating-point maximum ({ref}`maximum <i_maximum>`)
of the first and second vector arguments on each enabled lane, the result being
NaN if either argument is a NaN. -0.0 is considered to be less than +0.0 for this
-intrinsic. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+intrinsic. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
The operation is performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.maximum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.maximum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.maximum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.maximum.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_fadd)=
-.. _int_vp_fadd:
+#### '`llvm.vp.fadd.*`' Intrinsics
-'``llvm.vp.fadd.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.fadd.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fadd.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fadd.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.fadd.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fadd.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fadd.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point addition of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fadd``' intrinsic performs floating-point addition (:ref:`fadd <i_fadd>`)
+The '`llvm.vp.fadd`' intrinsic performs floating-point addition ({ref}`fadd <i_fadd>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.fadd.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fadd <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.fadd.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fadd <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fsub:
+(int_vp_fsub)=
-'``llvm.vp.fsub.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fsub.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fsub.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fsub.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fsub.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fsub.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fsub.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fsub.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point subtraction of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fsub``' intrinsic performs floating-point subtraction (:ref:`fsub <i_fsub>`)
+The '`llvm.vp.fsub`' intrinsic performs floating-point subtraction ({ref}`fsub <i_fsub>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.fsub.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fsub <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.fsub.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fsub <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fmul:
+(int_vp_fmul)=
-'``llvm.vp.fmul.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fmul.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fmul.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fmul.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fmul.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fmul.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fmul.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fmul.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point multiplication of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fmul``' intrinsic performs floating-point multiplication (:ref:`fmul <i_fmul>`)
+The '`llvm.vp.fmul`' intrinsic performs floating-point multiplication ({ref}`fmul <i_fmul>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.fmul.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.fmul.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = fmul <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = fmul <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_fdiv)=
-.. _int_vp_fdiv:
+#### '`llvm.vp.fdiv.*`' Intrinsics
-'``llvm.vp.fdiv.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.fdiv.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fdiv.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fdiv.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.fdiv.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fdiv.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fdiv.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point division of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fdiv``' intrinsic performs floating-point division (:ref:`fdiv <i_fdiv>`)
+The '`llvm.vp.fdiv`' intrinsic performs floating-point division ({ref}`fdiv <i_fdiv>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.fdiv.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.fdiv.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = fdiv <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = fdiv <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_frem)=
-.. _int_vp_frem:
+#### '`llvm.vp.frem.*`' Intrinsics
-'``llvm.vp.frem.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.frem.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.frem.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.frem.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.frem.v16f32 (<16 x float> <left_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.frem.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.frem.v256f64 (<256 x double> <left_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point remainder of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of floating-point type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.frem``' intrinsic performs floating-point remainder (:ref:`frem <i_frem>`)
+The '`llvm.vp.frem`' intrinsic performs floating-point remainder ({ref}`frem <i_frem>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.frem.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = frem <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.frem.v4f32(<4 x float> %a, <4 x float> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = frem <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fneg:
+(int_vp_fneg)=
-'``llvm.vp.fneg.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fneg.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fneg.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fneg.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fneg.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fneg.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fneg.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fneg.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point negation of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fneg``' intrinsic performs floating-point negation (:ref:`fneg <i_fneg>`)
+The '`llvm.vp.fneg`' intrinsic performs floating-point negation ({ref}`fneg <i_fneg>`)
of the first vector argument on each enabled lane. The result on disabled lanes
-is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x float> @llvm.vp.fneg.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fneg <4 x float> %a
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.fneg.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fneg <4 x float> %a
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fabs:
+(int_vp_fabs)=
-'``llvm.vp.fabs.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fabs.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fabs.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fabs.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fabs.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fabs.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fabs.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fabs.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point absolute value of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fabs``' intrinsic performs floating-point absolute value
-(:ref:`fabs <int_fabs>`) of the first vector argument on each enabled lane. The
-result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.fabs`' intrinsic performs floating-point absolute value
+({ref}`fabs <int_fabs>`) of the first vector argument on each enabled lane. The
+result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.fabs.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.fabs.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_sqrt)=
-.. _int_vp_sqrt:
+#### '`llvm.vp.sqrt.*`' Intrinsics
-'``llvm.vp.sqrt.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.sqrt.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.sqrt.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.sqrt.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.sqrt.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.sqrt.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.sqrt.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point square root of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sqrt``' intrinsic performs floating-point square root (:ref:`sqrt <int_sqrt>`) of
+The '`llvm.vp.sqrt`' intrinsic performs floating-point square root ({ref}`sqrt <int_sqrt>`) of
the first vector argument on each enabled lane. The result on disabled lanes is
-a :ref:`poison value <poisonvalues>`. The operation is performed in the default
+a {ref}`poison value <poisonvalues>`. The operation is performed in the default
floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.sqrt.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.sqrt.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fma:
+(int_vp_fma)=
-'``llvm.vp.fma.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fma.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fma.v16f32 (<16 x float> <left_op>, <16 x float> <middle_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fma.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <middle_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fma.v256f64 (<256 x double> <left_op>, <256 x double> <middle_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fma.v16f32 (<16 x float> <left_op>, <16 x float> <middle_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fma.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <middle_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fma.v256f64 (<256 x double> <left_op>, <256 x double> <middle_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point fused multiply-add of two vectors of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first three arguments and the result have the same vector of floating-point type. The
fourth argument is the vector mask and has the same number of elements as the
result vector type. The fifth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fma``' intrinsic performs floating-point fused multiply-add (:ref:`llvm.fma <int_fma>`)
+The '`llvm.vp.fma`' intrinsic performs floating-point fused multiply-add ({ref}`llvm.fma <int_fma>`)
of the first, second, and third vector argument on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call <4 x float> @llvm.vp.fma.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x float> @llvm.fma(<4 x float> %a, <4 x float> %b, <4 x float> %c)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.fma.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x float> @llvm.fma(<4 x float> %a, <4 x float> %b, <4 x float> %c)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fmuladd:
+(int_vp_fmuladd)=
-'``llvm.vp.fmuladd.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fmuladd.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.fmuladd.v16f32 (<16 x float> <left_op>, <16 x float> <middle_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.fmuladd.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <middle_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.fmuladd.v256f64 (<256 x double> <left_op>, <256 x double> <middle_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.fmuladd.v16f32 (<16 x float> <left_op>, <16 x float> <middle_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.fmuladd.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <middle_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.fmuladd.v256f64 (<256 x double> <left_op>, <256 x double> <middle_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point multiply-add of two vectors of floating-point values
that can be fused if code generator determines that (a) the target instruction
set has support for a fused operation, and (b) that the fused operation is more
efficient than the equivalent, separate pair of mul and add instructions.
-Arguments:
-""""""""""
+##### Arguments:
The first three arguments and the result have the same vector of floating-point
type. The fourth argument is the vector mask and has the same number of elements
as the result vector type. The fifth argument is the explicit vector length of
the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fmuladd``' intrinsic performs floating-point multiply-add (:ref:`llvm.fuladd <int_fmuladd>`)
+The '`llvm.vp.fmuladd`' intrinsic performs floating-point multiply-add ({ref}`llvm.fuladd <int_fmuladd>`)
of the first, second, and third vector argument on each enabled lane. The result
-on disabled lanes is a :ref:`poison value <poisonvalues>`. The operation is
+on disabled lanes is a {ref}`poison value <poisonvalues>`. The operation is
performed in the default floating-point environment.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.fmuladd.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.fmuladd.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.fmuladd(<4 x float> %a, <4 x float> %b, <4 x float> %c)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.fmuladd(<4 x float> %a, <4 x float> %b, <4 x float> %c)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_reduce_add)=
-.. _int_vp_reduce_add:
+#### '`llvm.vp.reduce.add.*`' Intrinsics
-'``llvm.vp.reduce.add.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.vp.reduce.add.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.add.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare i32 @llvm.vp.reduce.add.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.add.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated integer ``ADD`` reduction of a vector and a scalar starting value,
+Predicated integer `ADD` reduction of a vector and a scalar starting value,
returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -24844,54 +23093,47 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.add``' intrinsic performs the integer ``ADD`` reduction
-(:ref:`llvm.vector.reduce.add <int_vector_reduce_add>`) of the vector argument
-``val`` on each enabled lane, adding it to the scalar ``start_value``. Disabled
-lanes are treated as containing the neutral value ``0`` (i.e., having no effect
+The '`llvm.vp.reduce.add`' intrinsic performs the integer `ADD` reduction
+({ref}`llvm.vector.reduce.add <int_vector_reduce_add>`) of the vector argument
+`val` on each enabled lane, adding it to the scalar `start_value`. Disabled
+lanes are treated as containing the neutral value `0` (i.e., having no effect
on the reduction operation). If the vector length is zero, the result is equal
-to ``start_value``.
+to `start_value`.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call i32 @llvm.vp.reduce.add.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call i32 @llvm.vp.reduce.add.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> zeroinitializer
- %reduction = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %masked.a)
- %also.r = add i32 %reduction, %start
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> zeroinitializer
+%reduction = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %masked.a)
+%also.r = add i32 %reduction, %start
+```
+(int_vp_reduce_fadd)=
-.. _int_vp_reduce_fadd:
+#### '`llvm.vp.reduce.fadd.*`' Intrinsics
-'``llvm.vp.reduce.fadd.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare float @llvm.vp.reduce.fadd.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fadd.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare float @llvm.vp.reduce.fadd.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fadd.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated floating-point ``ADD`` reduction of a vector and a scalar starting
+Predicated floating-point `ADD` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -24901,57 +23143,49 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fadd``' intrinsic performs the floating-point ``ADD``
-reduction (:ref:`llvm.vector.reduce.fadd <int_vector_reduce_fadd>`) of the
-vector argument ``val`` on each enabled lane, adding it to the scalar
-``start_value``. Disabled lanes are treated as containing the neutral value
-``-0.0`` (i.e., having no effect on the reduction operation). If no lanes are
-enabled, the resulting value will be equal to ``start_value``.
+The '`llvm.vp.reduce.fadd`' intrinsic performs the floating-point `ADD`
+reduction ({ref}`llvm.vector.reduce.fadd <int_vector_reduce_fadd>`) of the
+vector argument `val` on each enabled lane, adding it to the scalar
+`start_value`. Disabled lanes are treated as containing the neutral value
+`-0.0` (i.e., having no effect on the reduction operation). If no lanes are
+enabled, the resulting value will be equal to `start_value`.
To ignore the start value, the neutral value can be used.
-See the unpredicated version (:ref:`llvm.vector.reduce.fadd
-<int_vector_reduce_fadd>`) for more detail on the semantics of the reduction.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+See the unpredicated version ({ref}`llvm.vector.reduce.fadd <int_vector_reduce_fadd>`) for more detail on the semantics of the reduction.
- %r = call float @llvm.vp.reduce.fadd.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+##### Examples:
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>
- %also.r = call float @llvm.vector.reduce.fadd.v4f32(float %start, <4 x float> %masked.a)
+```llvm
+%r = call float @llvm.vp.reduce.fadd.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>
+%also.r = call float @llvm.vector.reduce.fadd.v4f32(float %start, <4 x float> %masked.a)
+```
-.. _int_vp_reduce_mul:
+(int_vp_reduce_mul)=
-'``llvm.vp.reduce.mul.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.mul.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.vp.reduce.mul.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.mul.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.reduce.mul.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.mul.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated integer ``MUL`` reduction of a vector and a scalar starting value,
+Predicated integer `MUL` reduction of a vector and a scalar starting value,
returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -24960,54 +23194,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.mul``' intrinsic performs the integer ``MUL`` reduction
-(:ref:`llvm.vector.reduce.mul <int_vector_reduce_mul>`) of the vector argument ``val``
-on each enabled lane, multiplying it by the scalar ``start_value``. Disabled
-lanes are treated as containing the neutral value ``1`` (i.e., having no effect
+The '`llvm.vp.reduce.mul`' intrinsic performs the integer `MUL` reduction
+({ref}`llvm.vector.reduce.mul <int_vector_reduce_mul>`) of the vector argument `val`
+on each enabled lane, multiplying it by the scalar `start_value`. Disabled
+lanes are treated as containing the neutral value `1` (i.e., having no effect
on the reduction operation). If the vector length is zero, the result is the
start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: llvm
+```llvm
+%r = call i32 @llvm.vp.reduce.mul.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %r = call i32 @llvm.vp.reduce.mul.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+%reduction = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %masked.a)
+%also.r = mul i32 %reduction, %start
+```
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
- %reduction = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %masked.a)
- %also.r = mul i32 %reduction, %start
+(int_vp_reduce_fmul)=
-.. _int_vp_reduce_fmul:
+#### '`llvm.vp.reduce.fmul.*`' Intrinsics
-'``llvm.vp.reduce.fmul.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare float @llvm.vp.reduce.fmul.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fmul.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare float @llvm.vp.reduce.fmul.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fmul.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated floating-point ``MUL`` reduction of a vector and a scalar starting
+Predicated floating-point `MUL` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -25017,57 +23245,49 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fmul``' intrinsic performs the floating-point ``MUL``
-reduction (:ref:`llvm.vector.reduce.fmul <int_vector_reduce_fmul>`) of the
-vector argument ``val`` on each enabled lane, multiplying it by the scalar
-`start_value``. Disabled lanes are treated as containing the neutral value
-``1.0`` (i.e., having no effect on the reduction operation). If no lanes are
+The '`llvm.vp.reduce.fmul`' intrinsic performs the floating-point `MUL`
+reduction ({ref}`llvm.vector.reduce.fmul <int_vector_reduce_fmul>`) of the
+vector argument `val` on each enabled lane, multiplying it by the scalar
+`start_value`. Disabled lanes are treated as containing the neutral value
+`1.0` (i.e., having no effect on the reduction operation). If no lanes are
enabled, the resulting value will be equal to the starting value.
To ignore the start value, the neutral value can be used.
-See the unpredicated version (:ref:`llvm.vector.reduce.fmul
-<int_vector_reduce_fmul>`) for more detail on the semantics.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+See the unpredicated version ({ref}`llvm.vector.reduce.fmul <int_vector_reduce_fmul>`) for more detail on the semantics.
- %r = call float @llvm.vp.reduce.fmul.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+##### Examples:
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>
- %also.r = call float @llvm.vector.reduce.fmul.v4f32(float %start, <4 x float> %masked.a)
+```llvm
+%r = call float @llvm.vp.reduce.fmul.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>
+%also.r = call float @llvm.vector.reduce.fmul.v4f32(float %start, <4 x float> %masked.a)
+```
-.. _int_vp_reduce_and:
+(int_vp_reduce_and)=
-'``llvm.vp.reduce.and.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.and.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.vp.reduce.and.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.and.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.reduce.and.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.and.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated integer ``AND`` reduction of a vector and a scalar starting value,
+Predicated integer `AND` reduction of a vector and a scalar starting value,
returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25076,55 +23296,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.and``' intrinsic performs the integer ``AND`` reduction
-(:ref:`llvm.vector.reduce.and <int_vector_reduce_and>`) of the vector argument
-``val`` on each enabled lane, performing an '``and``' of that with with the
-scalar ``start_value``. Disabled lanes are treated as containing the neutral
-value ``UINT_MAX``, or ``-1`` (i.e., having no effect on the reduction
+The '`llvm.vp.reduce.and`' intrinsic performs the integer `AND` reduction
+({ref}`llvm.vector.reduce.and <int_vector_reduce_and>`) of the vector argument
+`val` on each enabled lane, performing an '`and`' of that with with the
+scalar `start_value`. Disabled lanes are treated as containing the neutral
+value `UINT_MAX`, or `-1` (i.e., having no effect on the reduction
operation). If the vector length is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call i32 @llvm.vp.reduce.and.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call i32 @llvm.vp.reduce.and.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
- %reduction = call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %masked.a)
- %also.r = and i32 %reduction, %start
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
+%reduction = call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %masked.a)
+%also.r = and i32 %reduction, %start
+```
+(int_vp_reduce_or)=
-.. _int_vp_reduce_or:
+#### '`llvm.vp.reduce.or.*`' Intrinsics
-'``llvm.vp.reduce.or.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.vp.reduce.or.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.or.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare i32 @llvm.vp.reduce.or.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.or.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated integer ``OR`` reduction of a vector and a scalar starting value,
+Predicated integer `OR` reduction of a vector and a scalar starting value,
returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25133,54 +23346,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.or``' intrinsic performs the integer ``OR`` reduction
-(:ref:`llvm.vector.reduce.or <int_vector_reduce_or>`) of the vector argument
-``val`` on each enabled lane, performing an '``or``' of that with the scalar
-``start_value``. Disabled lanes are treated as containing the neutral value
-``0`` (i.e., having no effect on the reduction operation). If the vector length
+The '`llvm.vp.reduce.or`' intrinsic performs the integer `OR` reduction
+({ref}`llvm.vector.reduce.or <int_vector_reduce_or>`) of the vector argument
+`val` on each enabled lane, performing an '`or`' of that with the scalar
+`start_value`. Disabled lanes are treated as containing the neutral value
+`0` (i.e., having no effect on the reduction operation). If the vector length
is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call i32 @llvm.vp.reduce.or.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call i32 @llvm.vp.reduce.or.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
- %reduction = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %masked.a)
- %also.r = or i32 %reduction, %start
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
+%reduction = call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %masked.a)
+%also.r = or i32 %reduction, %start
+```
-.. _int_vp_reduce_xor:
+(int_vp_reduce_xor)=
-'``llvm.vp.reduce.xor.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.xor.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.vp.reduce.xor.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.xor.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.reduce.xor.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.xor.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated integer ``XOR`` reduction of a vector and a scalar starting value,
+Predicated integer `XOR` reduction of a vector and a scalar starting value,
returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25189,55 +23396,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.xor``' intrinsic performs the integer ``XOR`` reduction
-(:ref:`llvm.vector.reduce.xor <int_vector_reduce_xor>`) of the vector argument
-``val`` on each enabled lane, performing an '``xor``' of that with the scalar
-``start_value``. Disabled lanes are treated as containing the neutral value
-``0`` (i.e., having no effect on the reduction operation). If the vector length
+The '`llvm.vp.reduce.xor`' intrinsic performs the integer `XOR` reduction
+({ref}`llvm.vector.reduce.xor <int_vector_reduce_xor>`) of the vector argument
+`val` on each enabled lane, performing an '`xor`' of that with the scalar
+`start_value`. Disabled lanes are treated as containing the neutral value
+`0` (i.e., having no effect on the reduction operation). If the vector length
is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call i32 @llvm.vp.reduce.xor.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call i32 @llvm.vp.reduce.xor.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
- %reduction = call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %masked.a)
- %also.r = xor i32 %reduction, %start
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
+%reduction = call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> %masked.a)
+%also.r = xor i32 %reduction, %start
+```
+(int_vp_reduce_smax)=
-.. _int_vp_reduce_smax:
+#### '`llvm.vp.reduce.smax.*`' Intrinsics
-'``llvm.vp.reduce.smax.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.vp.reduce.smax.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.smax.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare i32 @llvm.vp.reduce.smax.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.smax.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated signed-integer ``MAX`` reduction of a vector and a scalar starting
+Predicated signed-integer `MAX` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25246,55 +23446,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.smax``' intrinsic performs the signed-integer ``MAX``
-reduction (:ref:`llvm.vector.reduce.smax <int_vector_reduce_smax>`) of the
-vector argument ``val`` on each enabled lane, and taking the maximum of that and
-the scalar ``start_value``. Disabled lanes are treated as containing the
-neutral value ``INT_MIN`` (i.e., having no effect on the reduction operation).
+The '`llvm.vp.reduce.smax`' intrinsic performs the signed-integer `MAX`
+reduction ({ref}`llvm.vector.reduce.smax <int_vector_reduce_smax>`) of the
+vector argument `val` on each enabled lane, and taking the maximum of that and
+the scalar `start_value`. Disabled lanes are treated as containing the
+neutral value `INT_MIN` (i.e., having no effect on the reduction operation).
If the vector length is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call i8 @llvm.vp.reduce.smax.v4i8(i8 %start, <4 x i8> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+##### Examples:
- %masked.a = select <4 x i1> %mask, <4 x i8> %a, <4 x i8> <i8 -128, i8 -128, i8 -128, i8 -128>
- %reduction = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> %masked.a)
- %also.r = call i8 @llvm.smax.i8(i8 %reduction, i8 %start)
+```llvm
+%r = call i8 @llvm.vp.reduce.smax.v4i8(i8 %start, <4 x i8> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x i8> %a, <4 x i8> <i8 -128, i8 -128, i8 -128, i8 -128>
+%reduction = call i8 @llvm.vector.reduce.smax.v4i8(<4 x i8> %masked.a)
+%also.r = call i8 @llvm.smax.i8(i8 %reduction, i8 %start)
+```
-.. _int_vp_reduce_smin:
+(int_vp_reduce_smin)=
-'``llvm.vp.reduce.smin.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.smin.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare i32 @llvm.vp.reduce.smin.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.smin.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare i32 @llvm.vp.reduce.smin.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.smin.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated signed-integer ``MIN`` reduction of a vector and a scalar starting
+Predicated signed-integer `MIN` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25303,55 +23496,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.smin``' intrinsic performs the signed-integer ``MIN``
-reduction (:ref:`llvm.vector.reduce.smin <int_vector_reduce_smin>`) of the
-vector argument ``val`` on each enabled lane, and taking the minimum of that and
-the scalar ``start_value``. Disabled lanes are treated as containing the
-neutral value ``INT_MAX`` (i.e., having no effect on the reduction operation).
+The '`llvm.vp.reduce.smin`' intrinsic performs the signed-integer `MIN`
+reduction ({ref}`llvm.vector.reduce.smin <int_vector_reduce_smin>`) of the
+vector argument `val` on each enabled lane, and taking the minimum of that and
+the scalar `start_value`. Disabled lanes are treated as containing the
+neutral value `INT_MAX` (i.e., having no effect on the reduction operation).
If the vector length is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: llvm
+```llvm
+%r = call i8 @llvm.vp.reduce.smin.v4i8(i8 %start, <4 x i8> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %r = call i8 @llvm.vp.reduce.smin.v4i8(i8 %start, <4 x i8> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x i8> %a, <4 x i8> <i8 127, i8 127, i8 127, i8 127>
+%reduction = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> %masked.a)
+%also.r = call i8 @llvm.smin.i8(i8 %reduction, i8 %start)
+```
- %masked.a = select <4 x i1> %mask, <4 x i8> %a, <4 x i8> <i8 127, i8 127, i8 127, i8 127>
- %reduction = call i8 @llvm.vector.reduce.smin.v4i8(<4 x i8> %masked.a)
- %also.r = call i8 @llvm.smin.i8(i8 %reduction, i8 %start)
+(int_vp_reduce_umax)=
+#### '`llvm.vp.reduce.umax.*`' Intrinsics
-.. _int_vp_reduce_umax:
-
-'``llvm.vp.reduce.umax.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.vp.reduce.umax.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.umax.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.reduce.umax.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.umax.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated unsigned-integer ``MAX`` reduction of a vector and a scalar starting
+Predicated unsigned-integer `MAX` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25360,55 +23546,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.umax``' intrinsic performs the unsigned-integer ``MAX``
-reduction (:ref:`llvm.vector.reduce.umax <int_vector_reduce_umax>`) of the
-vector argument ``val`` on each enabled lane, and taking the maximum of that and
-the scalar ``start_value``. Disabled lanes are treated as containing the
-neutral value ``0`` (i.e., having no effect on the reduction operation). If the
+The '`llvm.vp.reduce.umax`' intrinsic performs the unsigned-integer `MAX`
+reduction ({ref}`llvm.vector.reduce.umax <int_vector_reduce_umax>`) of the
+vector argument `val` on each enabled lane, and taking the maximum of that and
+the scalar `start_value`. Disabled lanes are treated as containing the
+neutral value `0` (i.e., having no effect on the reduction operation). If the
vector length is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call i32 @llvm.vp.reduce.umax.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+##### Examples:
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
- %reduction = call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> %masked.a)
- %also.r = call i32 @llvm.umax.i32(i32 %reduction, i32 %start)
+```llvm
+%r = call i32 @llvm.vp.reduce.umax.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
+%reduction = call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> %masked.a)
+%also.r = call i32 @llvm.umax.i32(i32 %reduction, i32 %start)
+```
-.. _int_vp_reduce_umin:
+(int_vp_reduce_umin)=
-'``llvm.vp.reduce.umin.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.umin.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare i32 @llvm.vp.reduce.umin.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare i16 @llvm.vp.reduce.umin.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.reduce.umin.v4i32(i32 <start_value>, <4 x i32> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare i16 @llvm.vp.reduce.umin.nxv8i16(i16 <start_value>, <vscale x 8 x i16> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated unsigned-integer ``MIN`` reduction of a vector and a scalar starting
+Predicated unsigned-integer `MIN` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
integer type equal to the result type. The second argument is the vector on
@@ -25417,55 +23596,48 @@ element type is the result/start type. The third argument is the vector mask and
is a vector of boolean values with the same number of elements as the vector
argument. The fourth argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.umin``' intrinsic performs the unsigned-integer ``MIN``
-reduction (:ref:`llvm.vector.reduce.umin <int_vector_reduce_umin>`) of the
-vector argument ``val`` on each enabled lane, taking the minimum of that and the
-scalar ``start_value``. Disabled lanes are treated as containing the neutral
-value ``UINT_MAX``, or ``-1`` (i.e., having no effect on the reduction
+The '`llvm.vp.reduce.umin`' intrinsic performs the unsigned-integer `MIN`
+reduction ({ref}`llvm.vector.reduce.umin <int_vector_reduce_umin>`) of the
+vector argument `val` on each enabled lane, taking the minimum of that and the
+scalar `start_value`. Disabled lanes are treated as containing the neutral
+value `UINT_MAX`, or `-1` (i.e., having no effect on the reduction
operation). If the vector length is zero, the result is the start value.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call i32 @llvm.vp.reduce.umin.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call i32 @llvm.vp.reduce.umin.v4i32(i32 %start, <4 x i32> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
- %reduction = call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> %masked.a)
- %also.r = call i32 @llvm.umin.i32(i32 %reduction, i32 %start)
+%masked.a = select <4 x i1> %mask, <4 x i32> %a, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
+%reduction = call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> %masked.a)
+%also.r = call i32 @llvm.umin.i32(i32 %reduction, i32 %start)
+```
+(int_vp_reduce_fmax)=
-.. _int_vp_reduce_fmax:
+#### '`llvm.vp.reduce.fmax.*`' Intrinsics
-'``llvm.vp.reduce.fmax.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare float @llvm.vp.reduce.fmax.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fmax.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare float @llvm.vp.reduce.fmax.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fmax.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated floating-point ``MAX`` reduction of a vector and a scalar starting
+Predicated floating-point `MAX` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -25475,64 +23647,57 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fmax``' intrinsic performs the floating-point ``MAX``
-reduction (:ref:`llvm.vector.reduce.fmax <int_vector_reduce_fmax>`) of the
-vector argument ``val`` on each enabled lane, taking the maximum of that and the
-scalar ``start_value``. Disabled lanes are treated as containing the neutral
+The '`llvm.vp.reduce.fmax`' intrinsic performs the floating-point `MAX`
+reduction ({ref}`llvm.vector.reduce.fmax <int_vector_reduce_fmax>`) of the
+vector argument `val` on each enabled lane, taking the maximum of that and the
+scalar `start_value`. Disabled lanes are treated as containing the neutral
value (i.e., having no effect on the reduction operation). If the vector length
is zero, the result is the start value.
-The neutral value is dependent on the :ref:`fast-math flags <fastmath>`. If no
-flags are set, the neutral value is ``-QNAN``. If ``nnan`` and ``ninf`` are
+The neutral value is dependent on the {ref}`fast-math flags <fastmath>`. If no
+flags are set, the neutral value is `-QNAN`. If `nnan` and `ninf` are
both set, then the neutral value is the smallest floating-point value for the
-result type. If only ``nnan`` is set then the neutral value is ``-Infinity``.
+result type. If only `nnan` is set then the neutral value is `-Infinity`.
This instruction has the same comparison semantics as the
-:ref:`llvm.vector.reduce.fmax <int_vector_reduce_fmax>` intrinsic (and thus the
-'``llvm.maxnum.*``' intrinsic).
+{ref}`llvm.vector.reduce.fmax <int_vector_reduce_fmax>` intrinsic (and thus the
+'`llvm.maxnum.*`' intrinsic).
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
-
- %r = call float @llvm.vp.reduce.fmax.v4f32(float %float, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+##### Examples:
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float QNAN, float QNAN, float QNAN, float QNAN>
- %reduction = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> %masked.a)
- %also.r = call float @llvm.maxnum.f32(float %reduction, float %start)
+```llvm
+%r = call float @llvm.vp.reduce.fmax.v4f32(float %float, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float QNAN, float QNAN, float QNAN, float QNAN>
+%reduction = call float @llvm.vector.reduce.fmax.v4f32(<4 x float> %masked.a)
+%also.r = call float @llvm.maxnum.f32(float %reduction, float %start)
+```
-.. _int_vp_reduce_fmin:
+(int_vp_reduce_fmin)=
-'``llvm.vp.reduce.fmin.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.reduce.fmin.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare float @llvm.vp.reduce.fmin.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fmin.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare float @llvm.vp.reduce.fmin.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fmin.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated floating-point ``MIN`` reduction of a vector and a scalar starting
+Predicated floating-point `MIN` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -25542,64 +23707,57 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fmin``' intrinsic performs the floating-point ``MIN``
-reduction (:ref:`llvm.vector.reduce.fmin <int_vector_reduce_fmin>`) of the
-vector argument ``val`` on each enabled lane, taking the minimum of that and the
-scalar ``start_value``. Disabled lanes are treated as containing the neutral
+The '`llvm.vp.reduce.fmin`' intrinsic performs the floating-point `MIN`
+reduction ({ref}`llvm.vector.reduce.fmin <int_vector_reduce_fmin>`) of the
+vector argument `val` on each enabled lane, taking the minimum of that and the
+scalar `start_value`. Disabled lanes are treated as containing the neutral
value (i.e., having no effect on the reduction operation). If the vector length
is zero, the result is the start value.
-The neutral value is dependent on the :ref:`fast-math flags <fastmath>`. If no
-flags are set, the neutral value is ``+QNAN``. If ``nnan`` and ``ninf`` are
+The neutral value is dependent on the {ref}`fast-math flags <fastmath>`. If no
+flags are set, the neutral value is `+QNAN`. If `nnan` and `ninf` are
both set, then the neutral value is the largest floating-point value for the
-result type. If only ``nnan`` is set then the neutral value is ``+Infinity``.
+result type. If only `nnan` is set then the neutral value is `+Infinity`.
This instruction has the same comparison semantics as the
-:ref:`llvm.vector.reduce.fmin <int_vector_reduce_fmin>` intrinsic (and thus the
-'``llvm.minnum.*``' intrinsic).
+{ref}`llvm.vector.reduce.fmin <int_vector_reduce_fmin>` intrinsic (and thus the
+'`llvm.minnum.*`' intrinsic).
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call float @llvm.vp.reduce.fmin.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call float @llvm.vp.reduce.fmin.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float QNAN, float QNAN, float QNAN, float QNAN>
- %reduction = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> %masked.a)
- %also.r = call float @llvm.minnum.f32(float %reduction, float %start)
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float QNAN, float QNAN, float QNAN, float QNAN>
+%reduction = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> %masked.a)
+%also.r = call float @llvm.minnum.f32(float %reduction, float %start)
+```
+(int_vp_reduce_fmaximum)=
-.. _int_vp_reduce_fmaximum:
+#### '`llvm.vp.reduce.fmaximum.*`' Intrinsics
-'``llvm.vp.reduce.fmaximum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare float @llvm.vp.reduce.fmaximum.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fmaximum.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
+declare float @llvm.vp.reduce.fmaximum.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fmaximum.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-Predicated floating-point ``MAX`` reduction of a vector and a scalar starting
+Predicated floating-point `MAX` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -25609,67 +23767,60 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fmaximum``' intrinsic performs the floating-point ``MAX``
-reduction (:ref:`llvm.vector.reduce.fmaximum <int_vector_reduce_fmaximum>`) of
-the vector argument ``val`` on each enabled lane, taking the maximum of that and
-the scalar ``start_value``. Disabled lanes are treated as containing the
+The '`llvm.vp.reduce.fmaximum`' intrinsic performs the floating-point `MAX`
+reduction ({ref}`llvm.vector.reduce.fmaximum <int_vector_reduce_fmaximum>`) of
+the vector argument `val` on each enabled lane, taking the maximum of that and
+the scalar `start_value`. Disabled lanes are treated as containing the
neutral value (i.e., having no effect on the reduction operation). If the vector
length is zero, the result is the start value.
-The neutral value is dependent on the :ref:`fast-math flags <fastmath>`. If no
-flags are set or only the ``nnan`` is set, the neutral value is ``-Infinity``.
-If ``ninf`` is set, then the neutral value is the smallest floating-point value
+The neutral value is dependent on the {ref}`fast-math flags <fastmath>`. If no
+flags are set or only the `nnan` is set, the neutral value is `-Infinity`.
+If `ninf` is set, then the neutral value is the smallest floating-point value
for the result type.
This instruction has the same comparison semantics as the
-:ref:`llvm.vector.reduce.fmaximum <int_vector_reduce_fmaximum>` intrinsic (and
-thus the '``llvm.maximum.*``' intrinsic). That is, the result will always be a
+{ref}`llvm.vector.reduce.fmaximum <int_vector_reduce_fmaximum>` intrinsic (and
+thus the '`llvm.maximum.*`' intrinsic). That is, the result will always be a
number unless any of the elements in the vector or the starting value is
-``NaN``. Namely, this intrinsic propagates ``NaN``. Also, -0.0 is considered
+`NaN`. Namely, this intrinsic propagates `NaN`. Also, -0.0 is considered
less than +0.0.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call float @llvm.vp.reduce.fmaximum.v4f32(float %float, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call float @llvm.vp.reduce.fmaximum.v4f32(float %float, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float -infinity, float -infinity, float -infinity, float -infinity>
- %reduction = call float @llvm.vector.reduce.fmaximum.v4f32(<4 x float> %masked.a)
- %also.r = call float @llvm.maximum.f32(float %reduction, float %start)
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float -infinity, float -infinity, float -infinity, float -infinity>
+%reduction = call float @llvm.vector.reduce.fmaximum.v4f32(<4 x float> %masked.a)
+%also.r = call float @llvm.maximum.f32(float %reduction, float %start)
+```
+(int_vp_reduce_fminimum)=
-.. _int_vp_reduce_fminimum:
+#### '`llvm.vp.reduce.fminimum.*`' Intrinsics
-'``llvm.vp.reduce.fminimum.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare float @llvm.vp.reduce.fminimum.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
+declare double @llvm.vp.reduce.fminimum.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+```
- declare float @llvm.vp.reduce.fminimum.v4f32(float <start_value>, <4 x float> <val>, <4 x i1> <mask>, i32 <vector_length>)
- declare double @llvm.vp.reduce.fminimum.nxv8f64(double <start_value>, <vscale x 8 x double> <val>, <vscale x 8 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-Predicated floating-point ``MIN`` reduction of a vector and a scalar starting
+Predicated floating-point `MIN` reduction of a vector and a scalar starting
value, returning the result as a scalar.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the start value of the reduction, which must be a scalar
floating-point type equal to the result type. The second argument is the vector
@@ -25679,261 +23830,236 @@ vector mask and is a vector of boolean values with the same number of elements
as the vector argument. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.reduce.fminimum``' intrinsic performs the floating-point ``MIN``
-reduction (:ref:`llvm.vector.reduce.fminimum <int_vector_reduce_fminimum>`) of
-the vector argument ``val`` on each enabled lane, taking the minimum of that and
-the scalar ``start_value``. Disabled lanes are treated as containing the neutral
+The '`llvm.vp.reduce.fminimum`' intrinsic performs the floating-point `MIN`
+reduction ({ref}`llvm.vector.reduce.fminimum <int_vector_reduce_fminimum>`) of
+the vector argument `val` on each enabled lane, taking the minimum of that and
+the scalar `start_value`. Disabled lanes are treated as containing the neutral
value (i.e., having no effect on the reduction operation). If the vector length
is zero, the result is the start value.
-The neutral value is dependent on the :ref:`fast-math flags <fastmath>`. If no
-flags are set or only the ``nnan`` is set, the neutral value is ``+Infinity``.
-If ``ninf`` is set, then the neutral value is the largest floating-point value
+The neutral value is dependent on the {ref}`fast-math flags <fastmath>`. If no
+flags are set or only the `nnan` is set, the neutral value is `+Infinity`.
+If `ninf` is set, then the neutral value is the largest floating-point value
for the result type.
This instruction has the same comparison semantics as the
-:ref:`llvm.vector.reduce.fminimum <int_vector_reduce_fminimum>` intrinsic (and
-thus the '``llvm.minimum.*``' intrinsic). That is, the result will always be a
+{ref}`llvm.vector.reduce.fminimum <int_vector_reduce_fminimum>` intrinsic (and
+thus the '`llvm.minimum.*`' intrinsic). That is, the result will always be a
number unless any of the elements in the vector or the starting value is
-``NaN``. Namely, this intrinsic propagates ``NaN``. Also, -0.0 is considered
+`NaN`. Namely, this intrinsic propagates `NaN`. Also, -0.0 is considered
less than +0.0.
To ignore the start value, the neutral value can be used.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call float @llvm.vp.reduce.fminimum.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
- ; %r is equivalent to %also.r, where lanes greater than or equal to %evl
- ; are treated as though %mask were false for those lanes.
+```llvm
+%r = call float @llvm.vp.reduce.fminimum.v4f32(float %start, <4 x float> %a, <4 x i1> %mask, i32 %evl)
+; %r is equivalent to %also.r, where lanes greater than or equal to %evl
+; are treated as though %mask were false for those lanes.
- %masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float infinity, float infinity, float infinity, float infinity>
- %reduction = call float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %masked.a)
- %also.r = call float @llvm.minimum.f32(float %reduction, float %start)
+%masked.a = select <4 x i1> %mask, <4 x float> %a, <4 x float> <float infinity, float infinity, float infinity, float infinity>
+%reduction = call float @llvm.vector.reduce.fminimum.v4f32(<4 x float> %masked.a)
+%also.r = call float @llvm.minimum.f32(float %reduction, float %start)
+```
-.. _int_experimental_vp_splice:
+(int_experimental_vp_splice)=
-'``llvm.experimental.vp.splice``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vp.splice`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <2 x double> @llvm.experimental.vp.splice.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %imm, <2 x i1> %mask, i32 %evl1, i32 %evl2)
- declare <vscale x 4 x i32> @llvm.experimental.vp.splice.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %imm, <vscale x 4 x i1> %mask, i32 %evl1, i32 %evl2)
+```
+declare <2 x double> @llvm.experimental.vp.splice.v2f64(<2 x double> %vec1, <2 x double> %vec2, i32 %imm, <2 x i1> %mask, i32 %evl1, i32 %evl2)
+declare <vscale x 4 x i32> @llvm.experimental.vp.splice.nxv4i32(<vscale x 4 x i32> %vec1, <vscale x 4 x i32> %vec2, i32 %imm, <vscale x 4 x i1> %mask, i32 %evl1, i32 %evl2)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.vp.splice.*``' intrinsic is the vector length
-predicated version of the '``llvm.vector.splice.*``' intrinsic.
+The '`llvm.experimental.vp.splice.*`' intrinsic is the vector length
+predicated version of the '`llvm.vector.splice.*`' intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
-The result and the first two arguments ``vec1`` and ``vec2`` are vectors with
-the same type. The third argument ``imm`` is an immediate signed integer that
-indicates the offset index. The fourth argument ``mask`` is a vector mask and
-has the same number of elements as the result. The last two arguments ``evl1``
-and ``evl2`` are unsigned integers indicating the explicit vector lengths of
-``vec1`` and ``vec2`` respectively. ``imm``, ``evl1`` and ``evl2`` should
-respect the following constraints: ``-evl1 <= imm < evl1``, ``0 <= evl1 <= VL``
-and ``0 <= evl2 <= VL``, where ``VL`` is the runtime vector factor. If these
+The result and the first two arguments `vec1` and `vec2` are vectors with
+the same type. The third argument `imm` is an immediate signed integer that
+indicates the offset index. The fourth argument `mask` is a vector mask and
+has the same number of elements as the result. The last two arguments `evl1`
+and `evl2` are unsigned integers indicating the explicit vector lengths of
+`vec1` and `vec2` respectively. `imm`, `evl1` and `evl2` should
+respect the following constraints: `-evl1 <= imm < evl1`, `0 <= evl1 <= VL`
+and `0 <= evl2 <= VL`, where `VL` is the runtime vector factor. If these
constraints are not satisfied the intrinsic has undefined behavior.
-Semantics:
-""""""""""
-
-Effectively, this intrinsic concatenates ``vec1[0..evl1-1]`` and
-``vec2[0..evl2-1]`` and creates the result vector by selecting the elements in a
-window of size ``evl2``, starting at index ``imm`` (for a positive immediate) of
-the concatenated vector. Elements in the result vector beyond ``evl2`` are
-``undef``. If ``imm`` is negative the starting index is ``evl1 + imm``. The result
-vector of active vector length ``evl2`` contains ``evl1 - imm`` (``-imm`` for
-negative ``imm``) elements from indices ``[imm..evl1 - 1]``
-(``[evl1 + imm..evl1 -1]`` for negative ``imm``) of ``vec1`` followed by the
-first ``evl2 - (evl1 - imm)`` (``evl2 + imm`` for negative ``imm``) elements of
-``vec2``. If ``evl1 - imm`` (``-imm``) >= ``evl2``, only the first ``evl2``
-elements are considered and the remaining are ``undef``. The lanes in the result
-vector disabled by ``mask`` are ``poison``.
+##### Semantics:
-Examples:
-"""""""""
+Effectively, this intrinsic concatenates `vec1[0..evl1-1]` and
+`vec2[0..evl2-1]` and creates the result vector by selecting the elements in a
+window of size `evl2`, starting at index `imm` (for a positive immediate) of
+the concatenated vector. Elements in the result vector beyond `evl2` are
+`undef`. If `imm` is negative the starting index is `evl1 + imm`. The result
+vector of active vector length `evl2` contains `evl1 - imm` (`-imm` for
+negative `imm`) elements from indices `[imm..evl1 - 1]`
+(`[evl1 + imm..evl1 -1]` for negative `imm`) of `vec1` followed by the
+first `evl2 - (evl1 - imm)` (`evl2 + imm` for negative `imm`) elements of
+`vec2`. If `evl1 - imm` (`-imm`) >= `evl2`, only the first `evl2`
+elements are considered and the remaining are `undef`. The lanes in the result
+vector disabled by `mask` are `poison`.
-.. code-block:: text
+##### Examples:
- llvm.experimental.vp.splice(<A,B,C,D>, <E,F,G,H>, 1, 2, 3); ==> <B, E, F, poison> index
- llvm.experimental.vp.splice(<A,B,C,D>, <E,F,G,H>, -2, 3, 2); ==> <B, C, poison, poison> trailing elements
+```text
+llvm.experimental.vp.splice(<A,B,C,D>, <E,F,G,H>, 1, 2, 3); ==> <B, E, F, poison> index
+llvm.experimental.vp.splice(<A,B,C,D>, <E,F,G,H>, -2, 3, 2); ==> <B, C, poison, poison> trailing elements
+```
-.. _int_experimental_vp_reverse:
+(int_experimental_vp_reverse)=
-'``llvm.experimental.vp.reverse``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vp.reverse`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <2 x double> @llvm.experimental.vp.reverse.v2f64(<2 x double> %vec, <2 x i1> %mask, i32 %evl)
+declare <vscale x 4 x i32> @llvm.experimental.vp.reverse.nxv4i32(<vscale x 4 x i32> %vec, <vscale x 4 x i1> %mask, i32 %evl)
+```
- declare <2 x double> @llvm.experimental.vp.reverse.v2f64(<2 x double> %vec, <2 x i1> %mask, i32 %evl)
- declare <vscale x 4 x i32> @llvm.experimental.vp.reverse.nxv4i32(<vscale x 4 x i32> %vec, <vscale x 4 x i1> %mask, i32 %evl)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.experimental.vp.reverse.*`' intrinsic is the vector length
+predicated version of the '`llvm.vector.reverse.*`' intrinsic.
-The '``llvm.experimental.vp.reverse.*``' intrinsic is the vector length
-predicated version of the '``llvm.vector.reverse.*``' intrinsic.
+##### Arguments:
-Arguments:
-""""""""""
-
-The result and the first argument ``vec`` are vectors with the same type.
-The second argument ``mask`` is a vector mask and has the same number of
+The result and the first argument `vec` are vectors with the same type.
+The second argument `mask` is a vector mask and has the same number of
elements as the result. The third argument is the explicit vector length of
the operation.
-Semantics:
-""""""""""
+##### Semantics:
-This intrinsic reverses the order of the first ``evl`` elements in a vector.
-The lanes in the result vector disabled by ``mask`` are ``poison``. The
-elements past ``evl`` are poison.
+This intrinsic reverses the order of the first `evl` elements in a vector.
+The lanes in the result vector disabled by `mask` are `poison`. The
+elements past `evl` are poison.
-.. _int_vp_load:
+(int_vp_load)=
-'``llvm.vp.load``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.load`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <4 x float> @llvm.vp.load.v4f32.p0(ptr %ptr, <4 x i1> %mask, i32 %evl)
+declare <vscale x 2 x i16> @llvm.vp.load.nxv2i16.p0(ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
+declare <8 x float> @llvm.vp.load.v8f32.p1(ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
+declare <vscale x 1 x i64> @llvm.vp.load.nxv1i64.p6(ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+```
- declare <4 x float> @llvm.vp.load.v4f32.p0(ptr %ptr, <4 x i1> %mask, i32 %evl)
- declare <vscale x 2 x i16> @llvm.vp.load.nxv2i16.p0(ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
- declare <8 x float> @llvm.vp.load.v8f32.p1(ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
- declare <vscale x 1 x i64> @llvm.vp.load.nxv1i64.p6(ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.vp.load.*`' intrinsic is the vector length predicated version of
+the {ref}`llvm.masked.load <int_mload>` intrinsic.
-The '``llvm.vp.load.*``' intrinsic is the vector length predicated version of
-the :ref:`llvm.masked.load <int_mload>` intrinsic.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the base pointer for the load. The second argument is a
vector of boolean values with the same number of elements as the return type.
The third is the explicit vector length of the operation. The return type and
underlying type of the base pointer are the same vector types.
-The :ref:`align <attr_align>` parameter attribute can be provided for the first
+The {ref}`align <attr_align>` parameter attribute can be provided for the first
argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.load``' intrinsic reads a vector from memory in the same way as
-the '``llvm.masked.load``' intrinsic, where the mask is taken from the
-combination of the '``mask``' and '``evl``' arguments in the usual VP way.
-Certain '``llvm.masked.load``' arguments do not have corresponding arguments in
-'``llvm.vp.load``': the '``passthru``' argument is implicitly ``poison``; the
-'``alignment``' argument is taken as the ``align`` parameter attribute, if
+The '`llvm.vp.load`' intrinsic reads a vector from memory in the same way as
+the '`llvm.masked.load`' intrinsic, where the mask is taken from the
+combination of the '`mask`' and '`evl`' arguments in the usual VP way.
+Certain '`llvm.masked.load`' arguments do not have corresponding arguments in
+'`llvm.vp.load`': the '`passthru`' argument is implicitly `poison`; the
+'`alignment`' argument is taken as the `align` parameter attribute, if
provided. The default alignment is taken as the ABI alignment of the return
-type as specified by the :ref:`datalayout string<langref_datalayout>`.
+type as specified by the {ref}`datalayout string<langref_datalayout>`.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: text
+```text
+%r = call <8 x i8> @llvm.vp.load.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %r = call <8 x i8> @llvm.vp.load.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%also.r = call <8 x i8> @llvm.masked.load.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, <8 x i8> poison)
+```
- %also.r = call <8 x i8> @llvm.masked.load.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, <8 x i8> poison)
+(int_vp_load_ff)=
+#### '`llvm.vp.load.ff`' Intrinsic
-.. _int_vp_load_ff:
-
-'``llvm.vp.load.ff``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare {<4 x float>, i32} @llvm.vp.load.ff.v4f32.p0(ptr %ptr, <4 x i1> %mask, i32 %evl)
+declare {<vscale x 2 x i16>, i32} @llvm.vp.load.ff.nxv2i16.p0(ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
+declare {<8 x float>, i32} @llvm.vp.load.ff.v8f32.p1(ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
+declare {<vscale x 1 x i64>, i32} @llvm.vp.load.ff.nxv1i64.p6(ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+```
- declare {<4 x float>, i32} @llvm.vp.load.ff.v4f32.p0(ptr %ptr, <4 x i1> %mask, i32 %evl)
- declare {<vscale x 2 x i16>, i32} @llvm.vp.load.ff.nxv2i16.p0(ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
- declare {<8 x float>, i32} @llvm.vp.load.ff.v8f32.p1(ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
- declare {<vscale x 1 x i64>, i32} @llvm.vp.load.ff.nxv1i64.p6(ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.vp.load.ff.*`' intrinsic is similar to
+'`llvm.vp.load.*`', but will not trap if there are not `evl` readable
+lanes at the pointer. '`ff`' stands for first-fault or fault-only-first.
-The '``llvm.vp.load.ff.*``' intrinsic is similar to
-'``llvm.vp.load.*``', but will not trap if there are not ``evl`` readable
-lanes at the pointer. '``ff``' stands for first-fault or fault-only-first.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the base pointer for the load. The second argument is a
vector of boolean values with the same number of elements as the first return
type. The third is the explicit vector length of the operation. The first
return type and underlying type of the base pointer are the same vector types.
-The :ref:`align <attr_align>` parameter attribute can be provided for the first
+The {ref}`align <attr_align>` parameter attribute can be provided for the first
argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.load.ff``' is designed for reading vector lanes in a single
+The '`llvm.vp.load.ff`' is designed for reading vector lanes in a single
IR operation where the number of lanes that can be read is not known and can
only be determined by looking at the data. This is useful for vectorizing
strcmp or strlen like loops where the data contains a null terminator. Some
targets have a fault-only-first load instruction that this intrinsic can be
lowered to. Other targets may support this intrinsic differently, for example by
-lowering to a single scalar load guarded by ``evl!=0`` and ``mask[0]==1`` and
+lowering to a single scalar load guarded by `evl!=0` and `mask[0]==1` and
indicating only 1 lane could be read.
-Like '``llvm.vp.load``', this intrinsic reads memory based on a ``mask`` and an
-``evl``. If ``evl`` is non-zero and the first lane is masked-on, then the
+Like '`llvm.vp.load`', this intrinsic reads memory based on a `mask` and an
+`evl`. If `evl` is non-zero and the first lane is masked-on, then the
first lane of the vector needs to be inbounds of an allocation. The remaining
-masked-on lanes with index less than ``evl`` do not need to be inbounds of
+masked-on lanes with index less than `evl` do not need to be inbounds of
an the same allocation or any allocation.
The second return value from the intrinsic indicates the index of the first
-lane that could not be read for some reason or ``evl`` if all lanes could be
+lane that could not be read for some reason or `evl` if all lanes could be
be read. Lanes at this index or higher in the first return value are
-:ref:`poison value <poisonvalues>`. If ``evl`` is non-zero, the result in the
+{ref}`poison value <poisonvalues>`. If `evl` is non-zero, the result in the
second return value must be at least 1, even if the first lane is masked-off.
-The second result is usually less than ``evl`` when an exception would occur
+The second result is usually less than `evl` when an exception would occur
for reading that lane, but it can be reduced for any reason. This facilitates
emulating this intrinsic when the hardware only supports narrower vector
types natively or when when hardware does not support fault-only-first loads.
Masked-on lanes that are not inbounds of the allocation that contains the first
-lane are :ref:`poison value <poisonvalues>`. There should be a marker in the
+lane are {ref}`poison value <poisonvalues>`. There should be a marker in the
allocation that indicates where valid data stops such as a null terminator. The
terminator should be checked for after calling this intrinsic to prevent using
any lanes past the terminator. Even if second return value is less than
-``evl``, the terminator value may not have been read.
+`evl`, the terminator value may not have been read.
This intrinsic will typically be called in a loop until a terminator is
found. The second result should be used to indicates how many elements are
@@ -25942,39 +24068,34 @@ pointer should be advanced by the number of elements in the second result and
the intrinsic called again.
The default alignment is taken as the ABI alignment of the first return
-type as specified by the :ref:`datalayout string<langref_datalayout>`.
+type as specified by the {ref}`datalayout string<langref_datalayout>`.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: text
+```text
+%r = call {<8 x i8>, i32} @llvm.vp.load.ff.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, i32 %evl)
+```
- %r = call {<8 x i8>, i32} @llvm.vp.load.ff.v8i8.p0(ptr align 2 %ptr, <8 x i1> %mask, i32 %evl)
+(int_vp_store)=
-.. _int_vp_store:
+#### '`llvm.vp.store`' Intrinsic
-'``llvm.vp.store``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare void @llvm.vp.store.v4f32.p0(<4 x float> %val, ptr %ptr, <4 x i1> %mask, i32 %evl)
+declare void @llvm.vp.store.nxv2i16.p0(<vscale x 2 x i16> %val, ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
+declare void @llvm.vp.store.v8f32.p1(<8 x float> %val, ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
+declare void @llvm.vp.store.nxv1i64.p6(<vscale x 1 x i64> %val, ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+```
- declare void @llvm.vp.store.v4f32.p0(<4 x float> %val, ptr %ptr, <4 x i1> %mask, i32 %evl)
- declare void @llvm.vp.store.nxv2i16.p0(<vscale x 2 x i16> %val, ptr %ptr, <vscale x 2 x i1> %mask, i32 %evl)
- declare void @llvm.vp.store.v8f32.p1(<8 x float> %val, ptr addrspace(1) %ptr, <8 x i1> %mask, i32 %evl)
- declare void @llvm.vp.store.nxv1i64.p6(<vscale x 1 x i64> %val, ptr addrspace(6) %ptr, <vscale x 1 x i1> %mask, i32 %evl)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.vp.store.*`' intrinsic is the vector length predicated version of
+the {ref}`llvm.masked.store <int_mstore>` intrinsic.
-The '``llvm.vp.store.*``' intrinsic is the vector length predicated version of
-the :ref:`llvm.masked.store <int_mstore>` intrinsic.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the vector value to be written to memory. The second
argument is the base pointer for the store. It has the same underlying type as
@@ -25982,54 +24103,46 @@ the value argument. The third argument is a vector of boolean values with the
same number of elements as the return type. The fourth is the explicit vector
length of the operation.
-The :ref:`align <attr_align>` parameter attribute can be provided for the
+The {ref}`align <attr_align>` parameter attribute can be provided for the
second argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.store``' intrinsic reads a vector from memory in the same way as
-the '``llvm.masked.store``' intrinsic, where the mask is taken from the
-combination of the '``mask``' and '``evl``' arguments in the usual VP way. The
-alignment of the operation (corresponding to the '``alignment``' argument of
-'``llvm.masked.store``') is specified by the ``align`` parameter attribute (see
+The '`llvm.vp.store`' intrinsic reads a vector from memory in the same way as
+the '`llvm.masked.store`' intrinsic, where the mask is taken from the
+combination of the '`mask`' and '`evl`' arguments in the usual VP way. The
+alignment of the operation (corresponding to the '`alignment`' argument of
+'`llvm.masked.store`') is specified by the `align` parameter attribute (see
above). If it is not provided then the ABI alignment of the type of the
-'``value``' argument as specified by the :ref:`datalayout
-string<langref_datalayout>` is used instead.
+'`value`' argument as specified by the {ref}`datalayout string<langref_datalayout>` is used instead.
-Examples:
-"""""""""
+##### Examples:
-.. code-block:: text
+```text
+call void @llvm.vp.store.v8i8.p0(<8 x i8> %val, ptr align 4 %ptr, <8 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, the call above is lane-wise equivalent to the call below.
- call void @llvm.vp.store.v8i8.p0(<8 x i8> %val, ptr align 4 %ptr, <8 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, the call above is lane-wise equivalent to the call below.
+call void @llvm.masked.store.v8i8.p0(<8 x i8> %val, ptr %ptr, i32 4, <8 x i1> %mask)
+```
- call void @llvm.masked.store.v8i8.p0(<8 x i8> %val, ptr %ptr, i32 4, <8 x i1> %mask)
+(int_experimental_vp_strided_load)=
+#### '`llvm.experimental.vp.strided.load`' Intrinsic
-.. _int_experimental_vp_strided_load:
-
-'``llvm.experimental.vp.strided.load``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <4 x float> @llvm.experimental.vp.strided.load.v4f32.i64(ptr %ptr, i64 %stride, <4 x i1> %mask, i32 %evl)
- declare <vscale x 2 x i16> @llvm.experimental.vp.strided.load.nxv2i16.i64(ptr %ptr, i64 %stride, <vscale x 2 x i1> %mask, i32 %evl)
+```
+declare <4 x float> @llvm.experimental.vp.strided.load.v4f32.i64(ptr %ptr, i64 %stride, <4 x i1> %mask, i32 %evl)
+declare <vscale x 2 x i16> @llvm.experimental.vp.strided.load.nxv2i16.i64(ptr %ptr, i64 %stride, <vscale x 2 x i1> %mask, i32 %evl)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.vp.strided.load``' intrinsic loads, into a vector, scalar values from
-memory locations evenly spaced apart by '``stride``' number of bytes, starting from '``ptr``'.
+The '`llvm.experimental.vp.strided.load`' intrinsic loads, into a vector, scalar values from
+memory locations evenly spaced apart by '`stride`' number of bytes, starting from '`ptr`'.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the base pointer for the load. The second argument is the stride
value expressed in bytes. The third argument is a vector of boolean values
@@ -26037,59 +24150,53 @@ with the same number of elements as the return type. The fourth is the explicit
vector length of the operation. The base pointer underlying type matches the type of the scalar
elements of the return argument.
-The :ref:`align <attr_align>` parameter attribute can be provided for the first
+The {ref}`align <attr_align>` parameter attribute can be provided for the first
argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.vp.strided.load``' intrinsic loads, into a vector, multiple scalar
-values from memory in the same way as the :ref:`llvm.vp.gather <int_vp_gather>` intrinsic,
+The '`llvm.experimental.vp.strided.load`' intrinsic loads, into a vector, multiple scalar
+values from memory in the same way as the {ref}`llvm.vp.gather <int_vp_gather>` intrinsic,
where the vector of pointers is in the form:
- ``%ptrs = <%ptr, %ptr + %stride, %ptr + 2 * %stride, ... >``,
+`%ptrs = <%ptr, %ptr + %stride, %ptr + 2 * %stride, ... >`,
-with '``ptr``' previously casted to a pointer '``i8``', '``stride``' always interpreted as a signed
+with '`ptr`' previously casted to a pointer '`i8`', '`stride`' always interpreted as a signed
integer and all arithmetic occurring in the pointer type.
-Examples:
-"""""""""
-
-.. code-block:: text
+##### Examples:
- %r = call <8 x i64> @llvm.experimental.vp.strided.load.v8i64.i64(i64* %ptr, i64 %stride, <8 x i64> %mask, i32 %evl)
- ;; The operation can also be expressed like this:
+```text
+%r = call <8 x i64> @llvm.experimental.vp.strided.load.v8i64.i64(i64* %ptr, i64 %stride, <8 x i64> %mask, i32 %evl)
+;; The operation can also be expressed like this:
- %addr = bitcast i64* %ptr to i8*
- ;; Create a vector of pointers %addrs in the form:
- ;; %addrs = <%addr, %addr + %stride, %addr + 2 * %stride, ...>
- %ptrs = bitcast <8 x i8* > %addrs to <8 x i64* >
- %also.r = call <8 x i64> @llvm.vp.gather.v8i64.v8p0i64(<8 x i64* > %ptrs, <8 x i64> %mask, i32 %evl)
+%addr = bitcast i64* %ptr to i8*
+;; Create a vector of pointers %addrs in the form:
+;; %addrs = <%addr, %addr + %stride, %addr + 2 * %stride, ...>
+%ptrs = bitcast <8 x i8* > %addrs to <8 x i64* >
+%also.r = call <8 x i64> @llvm.vp.gather.v8i64.v8p0i64(<8 x i64* > %ptrs, <8 x i64> %mask, i32 %evl)
+```
-.. _int_experimental_vp_strided_store:
+(int_experimental_vp_strided_store)=
-'``llvm.experimental.vp.strided.store``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.vp.strided.store`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare void @llvm.experimental.vp.strided.store.v4f32.i64(<4 x float> %val, ptr %ptr, i64 %stride, <4 x i1> %mask, i32 %evl)
- declare void @llvm.experimental.vp.strided.store.nxv2i16.i64(<vscale x 2 x i16> %val, ptr %ptr, i64 %stride, <vscale x 2 x i1> %mask, i32 %evl)
+```
+declare void @llvm.experimental.vp.strided.store.v4f32.i64(<4 x float> %val, ptr %ptr, i64 %stride, <4 x i1> %mask, i32 %evl)
+declare void @llvm.experimental.vp.strided.store.nxv2i16.i64(<vscale x 2 x i16> %val, ptr %ptr, i64 %stride, <vscale x 2 x i1> %mask, i32 %evl)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``@llvm.experimental.vp.strided.store``' intrinsic stores the elements of
-'``val``' into memory locations evenly spaced apart by '``stride``' number of
-bytes, starting from '``ptr``'.
+The '`@llvm.experimental.vp.strided.store`' intrinsic stores the elements of
+'`val`' into memory locations evenly spaced apart by '`stride`' number of
+bytes, starting from '`ptr`'.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the vector value to be written to memory. The second
argument is the base pointer for the store. Its underlying type matches the
@@ -26098,60 +24205,54 @@ expressed in bytes. The fourth argument is a vector of boolean values with the
same number of elements as the return type. The fifth is the explicit vector
length of the operation.
-The :ref:`align <attr_align>` parameter attribute can be provided for the
+The {ref}`align <attr_align>` parameter attribute can be provided for the
second argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.experimental.vp.strided.store``' intrinsic stores the elements of
-'``val``' in the same way as the :ref:`llvm.vp.scatter <int_vp_scatter>` intrinsic,
+The '`llvm.experimental.vp.strided.store`' intrinsic stores the elements of
+'`val`' in the same way as the {ref}`llvm.vp.scatter <int_vp_scatter>` intrinsic,
where the vector of pointers is in the form:
- ``%ptrs = <%ptr, %ptr + %stride, %ptr + 2 * %stride, ... >``,
+`%ptrs = <%ptr, %ptr + %stride, %ptr + 2 * %stride, ... >`,
-with '``ptr``' previously casted to a pointer '``i8``', '``stride``' always interpreted as a signed
+with '`ptr`' previously casted to a pointer '`i8`', '`stride`' always interpreted as a signed
integer and all arithmetic occurring in the pointer type.
-Examples:
-"""""""""
-
-.. code-block:: text
+##### Examples:
- call void @llvm.experimental.vp.strided.store.v8i64.i64(<8 x i64> %val, i64* %ptr, i64 %stride, <8 x i1> %mask, i32 %evl)
- ;; The operation can also be expressed like this:
+```text
+call void @llvm.experimental.vp.strided.store.v8i64.i64(<8 x i64> %val, i64* %ptr, i64 %stride, <8 x i1> %mask, i32 %evl)
+;; The operation can also be expressed like this:
- %addr = bitcast i64* %ptr to i8*
- ;; Create a vector of pointers %addrs in the form:
- ;; %addrs = <%addr, %addr + %stride, %addr + 2 * %stride, ...>
- %ptrs = bitcast <8 x i8* > %addrs to <8 x i64* >
- call void @llvm.vp.scatter.v8i64.v8p0i64(<8 x i64> %val, <8 x i64*> %ptrs, <8 x i1> %mask, i32 %evl)
+%addr = bitcast i64* %ptr to i8*
+;; Create a vector of pointers %addrs in the form:
+;; %addrs = <%addr, %addr + %stride, %addr + 2 * %stride, ...>
+%ptrs = bitcast <8 x i8* > %addrs to <8 x i64* >
+call void @llvm.vp.scatter.v8i64.v8p0i64(<8 x i64> %val, <8 x i64*> %ptrs, <8 x i1> %mask, i32 %evl)
+```
-.. _int_vp_gather:
+(int_vp_gather)=
-'``llvm.vp.gather``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.gather`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <4 x double> @llvm.vp.gather.v4f64.v4p0(<4 x ptr> %ptrs, <4 x i1> %mask, i32 %evl)
- declare <vscale x 2 x i8> @llvm.vp.gather.nxv2i8.nxv2p0(<vscale x 2 x ptr> %ptrs, <vscale x 2 x i1> %mask, i32 %evl)
- declare <2 x float> @llvm.vp.gather.v2f32.v2p2(<2 x ptr addrspace(2)> %ptrs, <2 x i1> %mask, i32 %evl)
- declare <vscale x 4 x i32> @llvm.vp.gather.nxv4i32.nxv4p4(<vscale x 4 x ptr addrspace(4)> %ptrs, <vscale x 4 x i1> %mask, i32 %evl)
+```
+declare <4 x double> @llvm.vp.gather.v4f64.v4p0(<4 x ptr> %ptrs, <4 x i1> %mask, i32 %evl)
+declare <vscale x 2 x i8> @llvm.vp.gather.nxv2i8.nxv2p0(<vscale x 2 x ptr> %ptrs, <vscale x 2 x i1> %mask, i32 %evl)
+declare <2 x float> @llvm.vp.gather.v2f32.v2p2(<2 x ptr addrspace(2)> %ptrs, <2 x i1> %mask, i32 %evl)
+declare <vscale x 4 x i32> @llvm.vp.gather.nxv4i32.nxv4p4(<vscale x 4 x ptr addrspace(4)> %ptrs, <vscale x 4 x i1> %mask, i32 %evl)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.gather.*``' intrinsic is the vector length predicated version of
-the :ref:`llvm.masked.gather <int_mgather>` intrinsic.
+The '`llvm.vp.gather.*`' intrinsic is the vector length predicated version of
+the {ref}`llvm.masked.gather <int_mgather>` intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a vector of pointers which holds all memory addresses to
read. The second argument is a vector of boolean values with the same number of
@@ -26159,56 +24260,49 @@ elements as the return type. The third is the explicit vector length of the
operation. The return type and underlying type of the vector of pointers are
the same vector types.
-The :ref:`align <attr_align>` parameter attribute can be provided for the first
+The {ref}`align <attr_align>` parameter attribute can be provided for the first
argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.gather``' intrinsic reads multiple scalar values from memory in
-the same way as the '``llvm.masked.gather``' intrinsic, where the mask is taken
-from the combination of the '``mask``' and '``evl``' arguments in the usual VP
-way. Certain '``llvm.masked.gather``' arguments do not have corresponding
-arguments in '``llvm.vp.gather``': the '``passthru``' argument is implicitly
-``poison``; the '``alignment``' argument is taken as the ``align`` parameter, if
+The '`llvm.vp.gather`' intrinsic reads multiple scalar values from memory in
+the same way as the '`llvm.masked.gather`' intrinsic, where the mask is taken
+from the combination of the '`mask`' and '`evl`' arguments in the usual VP
+way. Certain '`llvm.masked.gather`' arguments do not have corresponding
+arguments in '`llvm.vp.gather`': the '`passthru`' argument is implicitly
+`poison`; the '`alignment`' argument is taken as the `align` parameter, if
provided. The default alignment is taken as the ABI alignment of the source
-addresses as specified by the :ref:`datalayout string<langref_datalayout>`.
+addresses as specified by the {ref}`datalayout string<langref_datalayout>`.
-Examples:
-"""""""""
-
-.. code-block:: text
+##### Examples:
- %r = call <8 x i8> @llvm.vp.gather.v8i8.v8p0(<8 x ptr> align 8 %ptrs, <8 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```text
+%r = call <8 x i8> @llvm.vp.gather.v8i8.v8p0(<8 x ptr> align 8 %ptrs, <8 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %also.r = call <8 x i8> @llvm.masked.gather.v8i8.v8p0(<8 x ptr> align 8 %ptrs, <8 x i1> %mask, <8 x i8> poison)
+%also.r = call <8 x i8> @llvm.masked.gather.v8i8.v8p0(<8 x ptr> align 8 %ptrs, <8 x i1> %mask, <8 x i8> poison)
+```
+(int_vp_scatter)=
-.. _int_vp_scatter:
+#### '`llvm.vp.scatter`' Intrinsic
-'``llvm.vp.scatter``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare void @llvm.vp.scatter.v4f64.v4p0(<4 x double> %val, <4 x ptr> %ptrs, <4 x i1> %mask, i32 %evl)
+declare void @llvm.vp.scatter.nxv2i8.nxv2p0(<vscale x 2 x i8> %val, <vscale x 2 x ptr> %ptrs, <vscale x 2 x i1> %mask, i32 %evl)
+declare void @llvm.vp.scatter.v2f32.v2p2(<2 x float> %val, <2 x ptr addrspace(2)> %ptrs, <2 x i1> %mask, i32 %evl)
+declare void @llvm.vp.scatter.nxv4i32.nxv4p4(<vscale x 4 x i32> %val, <vscale x 4 x ptr addrspace(4)> %ptrs, <vscale x 4 x i1> %mask, i32 %evl)
+```
- declare void @llvm.vp.scatter.v4f64.v4p0(<4 x double> %val, <4 x ptr> %ptrs, <4 x i1> %mask, i32 %evl)
- declare void @llvm.vp.scatter.nxv2i8.nxv2p0(<vscale x 2 x i8> %val, <vscale x 2 x ptr> %ptrs, <vscale x 2 x i1> %mask, i32 %evl)
- declare void @llvm.vp.scatter.v2f32.v2p2(<2 x float> %val, <2 x ptr addrspace(2)> %ptrs, <2 x i1> %mask, i32 %evl)
- declare void @llvm.vp.scatter.nxv4i32.nxv4p4(<vscale x 4 x i32> %val, <vscale x 4 x ptr addrspace(4)> %ptrs, <vscale x 4 x i1> %mask, i32 %evl)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.vp.scatter.*`' intrinsic is the vector length predicated version of
+the {ref}`llvm.masked.scatter <int_mscatter>` intrinsic.
-The '``llvm.vp.scatter.*``' intrinsic is the vector length predicated version of
-the :ref:`llvm.masked.scatter <int_mscatter>` intrinsic.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a vector value to be written to memory. The second argument
is a vector of pointers, pointing to where the value elements should be stored.
@@ -26216,1340 +24310,1155 @@ The third argument is a vector of boolean values with the same number of
elements as the return type. The fourth is the explicit vector length of the
operation.
-The :ref:`align <attr_align>` parameter attribute can be provided for the
+The {ref}`align <attr_align>` parameter attribute can be provided for the
second argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.scatter``' intrinsic writes multiple scalar values to memory in
-the same way as the '``llvm.masked.scatter``' intrinsic, where the mask is
-taken from the combination of the '``mask``' and '``evl``' arguments in the
-usual VP way. The '``alignment``' argument of the '``llvm.masked.scatter``' does
-not have a corresponding argument in '``llvm.vp.scatter``': it is instead
-provided via the optional ``align`` parameter attribute on the
+The '`llvm.vp.scatter`' intrinsic writes multiple scalar values to memory in
+the same way as the '`llvm.masked.scatter`' intrinsic, where the mask is
+taken from the combination of the '`mask`' and '`evl`' arguments in the
+usual VP way. The '`alignment`' argument of the '`llvm.masked.scatter`' does
+not have a corresponding argument in '`llvm.vp.scatter`': it is instead
+provided via the optional `align` parameter attribute on the
vector-of-pointers argument. Otherwise it is taken as the ABI alignment of the
-destination addresses as specified by the :ref:`datalayout
-string<langref_datalayout>`.
-
-Examples:
-"""""""""
-
-.. code-block:: text
+destination addresses as specified by the {ref}`datalayout string<langref_datalayout>`.
- call void @llvm.vp.scatter.v8i8.v8p0(<8 x i8> %val, <8 x ptr> align 1 %ptrs, <8 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, the call above is lane-wise equivalent to the call below.
+##### Examples:
- call void @llvm.masked.scatter.v8i8.v8p0(<8 x i8> %val, <8 x ptr> align 1 %ptrs, <8 x i1> %mask)
+```text
+call void @llvm.vp.scatter.v8i8.v8p0(<8 x i8> %val, <8 x ptr> align 1 %ptrs, <8 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, the call above is lane-wise equivalent to the call below.
+call void @llvm.masked.scatter.v8i8.v8p0(<8 x i8> %val, <8 x ptr> align 1 %ptrs, <8 x i1> %mask)
+```
-.. _int_vp_trunc:
+(int_vp_trunc)=
-'``llvm.vp.trunc.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.trunc.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i16> @llvm.vp.trunc.v16i16.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i16> @llvm.vp.trunc.nxv4i16.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i16> @llvm.vp.trunc.v16i16.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i16> @llvm.vp.trunc.nxv4i16.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.trunc``' intrinsic truncates its first argument to the return
+The '`llvm.vp.trunc`' intrinsic truncates its first argument to the return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.trunc``' intrinsic takes a value to cast as its first argument.
+The '`llvm.vp.trunc`' intrinsic takes a value to cast as its first argument.
The return type is the type to cast the value to. Both types must be vector of
-:ref:`integer <t_integer>` type. The bit size of the value must be larger than
+{ref}`integer <t_integer>` type. The bit size of the value must be larger than
the bit size of the return type. The second argument is the vector mask. The
return type, the value to cast, and the vector mask have the same number of
elements. The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.trunc``' intrinsic truncates the high order bits in value and
+The '`llvm.vp.trunc`' intrinsic truncates the high order bits in value and
converts the remaining bits to return type. Since the source size must be larger
-than the destination size, '``llvm.vp.trunc``' cannot be a *no-op cast*. It will
+than the destination size, '`llvm.vp.trunc`' cannot be a *no-op cast*. It will
always truncate bits. The conversion is performed on lane positions below the
explicit vector length and where the vector mask is true. Masked-off lanes are
-``poison``.
-
-Examples:
-"""""""""
+`poison`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i16> @llvm.vp.trunc.v4i16.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i16> @llvm.vp.trunc.v4i16.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = trunc <4 x i32> %a to <4 x i16>
- %also.r = select <4 x i1> %mask, <4 x i16> %t, <4 x i16> poison
+%t = trunc <4 x i32> %a to <4 x i16>
+%also.r = select <4 x i1> %mask, <4 x i16> %t, <4 x i16> poison
+```
+(int_vp_zext)=
-.. _int_vp_zext:
+#### '`llvm.vp.zext.*`' Intrinsics
-'``llvm.vp.zext.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.zext.v16i32.v16i16 (<16 x i16> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.zext.nxv4i32.nxv4i16 (<vscale x 4 x i16> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.zext.v16i32.v16i16 (<16 x i16> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.zext.nxv4i32.nxv4i16 (<vscale x 4 x i16> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.zext``' intrinsic zero extends its first argument to the return
+The '`llvm.vp.zext`' intrinsic zero extends its first argument to the return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.zext``' intrinsic takes a value to cast as its first argument.
+The '`llvm.vp.zext`' intrinsic takes a value to cast as its first argument.
The return type is the type to cast the value to. Both types must be vectors of
-:ref:`integer <t_integer>` type. The bit size of the value must be smaller than
+{ref}`integer <t_integer>` type. The bit size of the value must be smaller than
the bit size of the return type. The second argument is the vector mask. The
return type, the value to cast, and the vector mask have the same number of
elements. The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.zext``' intrinsic fill the high order bits of the value with zero
+The '`llvm.vp.zext`' intrinsic fill the high order bits of the value with zero
bits until it reaches the size of the return type. When zero extending from i1,
the result will always be either 0 or 1. The conversion is performed on lane
positions below the explicit vector length and where the vector mask is true.
-Masked-off lanes are ``poison``.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+Masked-off lanes are `poison`.
- %r = call <4 x i32> @llvm.vp.zext.v4i32.v4i16(<4 x i16> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = zext <4 x i16> %a to <4 x i32>
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.zext.v4i32.v4i16(<4 x i16> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = zext <4 x i16> %a to <4 x i32>
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_sext:
+(int_vp_sext)=
-'``llvm.vp.sext.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.sext.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.sext.v16i32.v16i16 (<16 x i16> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.sext.nxv4i32.nxv4i16 (<vscale x 4 x i16> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.sext.v16i32.v16i16 (<16 x i16> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.sext.nxv4i32.nxv4i16 (<vscale x 4 x i16> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.sext``' intrinsic sign extends its first argument to the return
+The '`llvm.vp.sext`' intrinsic sign extends its first argument to the return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.sext``' intrinsic takes a value to cast as its first argument.
+The '`llvm.vp.sext`' intrinsic takes a value to cast as its first argument.
The return type is the type to cast the value to. Both types must be vectors of
-:ref:`integer <t_integer>` type. The bit size of the value must be smaller than
+{ref}`integer <t_integer>` type. The bit size of the value must be smaller than
the bit size of the return type. The second argument is the vector mask. The
return type, the value to cast, and the vector mask have the same number of
elements. The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sext``' intrinsic performs a sign extension by copying the sign
+The '`llvm.vp.sext`' intrinsic performs a sign extension by copying the sign
bit (highest order bit) of the value until it reaches the size of the return
type. When sign extending from i1, the result will always be either -1 or 0.
The conversion is performed on lane positions below the explicit vector length
-and where the vector mask is true. Masked-off lanes are ``poison``.
+and where the vector mask is true. Masked-off lanes are `poison`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.sext.v4i32.v4i16(<4 x i16> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.sext.v4i32.v4i16(<4 x i16> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = sext <4 x i16> %a to <4 x i32>
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = sext <4 x i16> %a to <4 x i32>
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_fptrunc)=
-.. _int_vp_fptrunc:
+#### '`llvm.vp.fptrunc.*`' Intrinsics
-'``llvm.vp.fptrunc.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.fptrunc.v16f32.v16f64 (<16 x double> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.trunc.nxv4f32.nxv4f64 (<vscale x 4 x double> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.fptrunc.v16f32.v16f64 (<16 x double> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.trunc.nxv4f32.nxv4f64 (<vscale x 4 x double> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.fptrunc``' intrinsic truncates its first argument to the return
+The '`llvm.vp.fptrunc`' intrinsic truncates its first argument to the return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.fptrunc``' intrinsic takes a value to cast as its first argument.
+The '`llvm.vp.fptrunc`' intrinsic takes a value to cast as its first argument.
The return type is the type to cast the value to. Both types must be vector of
-:ref:`floating-point <t_floating>` type. The bit size of the value must be
+{ref}`floating-point <t_floating>` type. The bit size of the value must be
larger than the bit size of the return type. This implies that
-'``llvm.vp.fptrunc``' cannot be used to make a *no-op cast*. The second argument
+'`llvm.vp.fptrunc`' cannot be used to make a *no-op cast*. The second argument
is the vector mask. The return type, the value to cast, and the vector mask have
the same number of elements. The third argument is the explicit vector length of
the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fptrunc``' intrinsic casts a ``value`` from a larger
-:ref:`floating-point <t_floating>` type to a smaller :ref:`floating-point
-<t_floating>` type.
-This instruction is assumed to execute in the default :ref:`floating-point
-environment <floatenv>`. The conversion is performed on lane positions below the
+The '`llvm.vp.fptrunc`' intrinsic casts a `value` from a larger
+{ref}`floating-point <t_floating>` type to a smaller {ref}`floating-point <t_floating>` type.
+This instruction is assumed to execute in the default {ref}`floating-point environment <floatenv>`. The conversion is performed on lane positions below the
explicit vector length and where the vector mask is true. Masked-off lanes are
-``poison``.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+`poison`.
- %r = call <4 x float> @llvm.vp.fptrunc.v4f32.v4f64(<4 x double> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fptrunc <4 x double> %a to <4 x float>
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.fptrunc.v4f32.v4f64(<4 x double> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fptrunc <4 x double> %a to <4 x float>
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_fpext:
+(int_vp_fpext)=
-'``llvm.vp.fpext.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fpext.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x double> @llvm.vp.fpext.v16f64.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x double> @llvm.vp.fpext.nxv4f64.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x double> @llvm.vp.fpext.v16f64.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x double> @llvm.vp.fpext.nxv4f64.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.fpext``' intrinsic extends its first argument to the return
+The '`llvm.vp.fpext`' intrinsic extends its first argument to the return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.fpext``' intrinsic takes a value to cast as its first argument.
+The '`llvm.vp.fpext`' intrinsic takes a value to cast as its first argument.
The return type is the type to cast the value to. Both types must be vector of
-:ref:`floating-point <t_floating>` type. The bit size of the value must be
+{ref}`floating-point <t_floating>` type. The bit size of the value must be
smaller than the bit size of the return type. This implies that
-'``llvm.vp.fpext``' cannot be used to make a *no-op cast*. The second argument
+'`llvm.vp.fpext`' cannot be used to make a *no-op cast*. The second argument
is the vector mask. The return type, the value to cast, and the vector mask have
the same number of elements. The third argument is the explicit vector length of
the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fpext``' intrinsic extends the ``value`` from a smaller
-:ref:`floating-point <t_floating>` type to a larger :ref:`floating-point
-<t_floating>` type. The '``llvm.vp.fpext``' cannot be used to make a
-*no-op cast* because it always changes bits. Use ``bitcast`` to make a
+The '`llvm.vp.fpext`' intrinsic extends the `value` from a smaller
+{ref}`floating-point <t_floating>` type to a larger {ref}`floating-point <t_floating>` type. The '`llvm.vp.fpext`' cannot be used to make a
+*no-op cast* because it always changes bits. Use `bitcast` to make a
*no-op cast* for a floating-point cast.
The conversion is performed on lane positions below the explicit vector length
-and where the vector mask is true. Masked-off lanes are ``poison``.
-
-Examples:
-"""""""""
+and where the vector mask is true. Masked-off lanes are `poison`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x double> @llvm.vp.fpext.v4f64.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x double> @llvm.vp.fpext.v4f64.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = fpext <4 x float> %a to <4 x double>
- %also.r = select <4 x i1> %mask, <4 x double> %t, <4 x double> poison
+%t = fpext <4 x float> %a to <4 x double>
+%also.r = select <4 x i1> %mask, <4 x double> %t, <4 x double> poison
+```
+(int_vp_fptoui)=
-.. _int_vp_fptoui:
+#### '`llvm.vp.fptoui.*`' Intrinsics
-'``llvm.vp.fptoui.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.fptoui.v16i32.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.fptoui.nxv4i32.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.fptoui.v256i64.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.fptoui.v16i32.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.fptoui.nxv4i32.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.fptoui.v256i64.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.fptoui``' intrinsic converts the :ref:`floating-point
-<t_floating>` argument to the unsigned integer return type.
+The '`llvm.vp.fptoui`' intrinsic converts the {ref}`floating-point <t_floating>` argument to the unsigned integer return type.
The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.fptoui``' intrinsic takes a value to cast as its first argument.
-The value to cast must be a vector of :ref:`floating-point <t_floating>` type.
+The '`llvm.vp.fptoui`' intrinsic takes a value to cast as its first argument.
+The value to cast must be a vector of {ref}`floating-point <t_floating>` type.
The return type is the type to cast the value to. The return type must be
-vector of :ref:`integer <t_integer>` type. The second argument is the vector
+vector of {ref}`integer <t_integer>` type. The second argument is the vector
mask. The return type, the value to cast, and the vector mask have the same
number of elements. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fptoui``' intrinsic converts its :ref:`floating-point
-<t_floating>` argument into the nearest (rounding towards zero) unsigned integer
+The '`llvm.vp.fptoui`' intrinsic converts its {ref}`floating-point <t_floating>` argument into the nearest (rounding towards zero) unsigned integer
value where the lane position is below the explicit vector length and the
-vector mask is true. Masked-off lanes are ``poison``. On enabled lanes where
+vector mask is true. Masked-off lanes are `poison`. On enabled lanes where
conversion takes place and the value cannot fit in the return type, the result
-on that lane is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+on that lane is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.fptoui.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fptoui <4 x float> %a to <4 x i32>
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.fptoui.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fptoui <4 x float> %a to <4 x i32>
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_fptosi:
+(int_vp_fptosi)=
-'``llvm.vp.fptosi.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fptosi.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.fptosi.v16i32.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.fptosi.nxv4i32.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.fptosi.v256i64.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.fptosi.v16i32.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.fptosi.nxv4i32.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.fptosi.v256i64.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.fptosi``' intrinsic converts the :ref:`floating-point
-<t_floating>` argument to the signed integer return type.
+The '`llvm.vp.fptosi`' intrinsic converts the {ref}`floating-point <t_floating>` argument to the signed integer return type.
The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.fptosi``' intrinsic takes a value to cast as its first argument.
-The value to cast must be a vector of :ref:`floating-point <t_floating>` type.
+The '`llvm.vp.fptosi`' intrinsic takes a value to cast as its first argument.
+The value to cast must be a vector of {ref}`floating-point <t_floating>` type.
The return type is the type to cast the value to. The return type must be
-vector of :ref:`integer <t_integer>` type. The second argument is the vector
+vector of {ref}`integer <t_integer>` type. The second argument is the vector
mask. The return type, the value to cast, and the vector mask have the same
number of elements. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fptosi``' intrinsic converts its :ref:`floating-point
-<t_floating>` argument into the nearest (rounding towards zero) signed integer
+The '`llvm.vp.fptosi`' intrinsic converts its {ref}`floating-point <t_floating>` argument into the nearest (rounding towards zero) signed integer
value where the lane position is below the explicit vector length and the
-vector mask is true. Masked-off lanes are ``poison``. On enabled lanes where
+vector mask is true. Masked-off lanes are `poison`. On enabled lanes where
conversion takes place and the value cannot fit in the return type, the result
-on that lane is a :ref:`poison value <poisonvalues>`.
+on that lane is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.fptosi.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.fptosi.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = fptosi <4 x float> %a to <4 x i32>
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = fptosi <4 x float> %a to <4 x i32>
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_uitofp)=
-.. _int_vp_uitofp:
+#### '`llvm.vp.uitofp.*`' Intrinsics
-'``llvm.vp.uitofp.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x float> @llvm.vp.uitofp.v16f32.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.uitofp.nxv4f32.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.uitofp.v256f64.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x float> @llvm.vp.uitofp.v16f32.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.uitofp.nxv4f32.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.uitofp.v256f64.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.uitofp``' intrinsic converts its unsigned integer argument to the
-:ref:`floating-point <t_floating>` return type. The operation has a mask and
+The '`llvm.vp.uitofp`' intrinsic converts its unsigned integer argument to the
+{ref}`floating-point <t_floating>` return type. The operation has a mask and
an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.uitofp``' intrinsic takes a value to cast as its first argument.
-The value to cast must be vector of :ref:`integer <t_integer>` type. The
+The '`llvm.vp.uitofp`' intrinsic takes a value to cast as its first argument.
+The value to cast must be vector of {ref}`integer <t_integer>` type. The
return type is the type to cast the value to. The return type must be a vector
-of :ref:`floating-point <t_floating>` type. The second argument is the vector
+of {ref}`floating-point <t_floating>` type. The second argument is the vector
mask. The return type, the value to cast, and the vector mask have the same
number of elements. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.uitofp``' intrinsic interprets its first argument as an unsigned
+The '`llvm.vp.uitofp`' intrinsic interprets its first argument as an unsigned
integer quantity and converts it to the corresponding floating-point value. If
the value cannot be exactly represented, it is rounded using the default
rounding mode. The conversion is performed on lane positions below the
explicit vector length and where the vector mask is true. Masked-off lanes are
-``poison``.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+`poison`.
- %r = call <4 x float> @llvm.vp.uitofp.v4f32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = uitofp <4 x i32> %a to <4 x float>
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```llvm
+%r = call <4 x float> @llvm.vp.uitofp.v4f32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = uitofp <4 x i32> %a to <4 x float>
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_sitofp:
+(int_vp_sitofp)=
-'``llvm.vp.sitofp.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.sitofp.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.sitofp.v16f32.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.sitofp.nxv4f32.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.sitofp.v256f64.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.sitofp.v16f32.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.sitofp.nxv4f32.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.sitofp.v256f64.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.sitofp``' intrinsic converts its signed integer argument to the
-:ref:`floating-point <t_floating>` return type. The operation has a mask and
+The '`llvm.vp.sitofp`' intrinsic converts its signed integer argument to the
+{ref}`floating-point <t_floating>` return type. The operation has a mask and
an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.sitofp``' intrinsic takes a value to cast as its first argument.
-The value to cast must be vector of :ref:`integer <t_integer>` type. The
+The '`llvm.vp.sitofp`' intrinsic takes a value to cast as its first argument.
+The value to cast must be vector of {ref}`integer <t_integer>` type. The
return type is the type to cast the value to. The return type must be a vector
-of :ref:`floating-point <t_floating>` type. The second argument is the vector
+of {ref}`floating-point <t_floating>` type. The second argument is the vector
mask. The return type, the value to cast, and the vector mask have the same
number of elements. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sitofp``' intrinsic interprets its first argument as a signed
+The '`llvm.vp.sitofp`' intrinsic interprets its first argument as a signed
integer quantity and converts it to the corresponding floating-point value. If
the value cannot be exactly represented, it is rounded using the default
rounding mode. The conversion is performed on lane positions below the
explicit vector length and where the vector mask is true. Masked-off lanes are
-``poison``.
-
-Examples:
-"""""""""
+`poison`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.sitofp.v4f32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.sitofp.v4f32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = sitofp <4 x i32> %a to <4 x float>
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = sitofp <4 x i32> %a to <4 x float>
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
+(int_vp_ptrtoint)=
-.. _int_vp_ptrtoint:
+#### '`llvm.vp.ptrtoint.*`' Intrinsics
-'``llvm.vp.ptrtoint.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i8> @llvm.vp.ptrtoint.v16i8.v16p0(<16 x ptr> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i8> @llvm.vp.ptrtoint.nxv4i8.nxv4p0(<vscale x 4 x ptr> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.ptrtoint.v16i64.v16p0(<256 x ptr> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i8> @llvm.vp.ptrtoint.v16i8.v16p0(<16 x ptr> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i8> @llvm.vp.ptrtoint.nxv4i8.nxv4p0(<vscale x 4 x ptr> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.ptrtoint.v16i64.v16p0(<256 x ptr> <op>, <256 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.ptrtoint``' intrinsic converts its pointer to the integer return
+The '`llvm.vp.ptrtoint`' intrinsic converts its pointer to the integer return
type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.ptrtoint``' intrinsic takes a value to cast as its first argument
+The '`llvm.vp.ptrtoint`' intrinsic takes a value to cast as its first argument
, which must be a vector of pointers, and a type to cast it to return type,
-which must be a vector of :ref:`integer <t_integer>` type.
+which must be a vector of {ref}`integer <t_integer>` type.
The second argument is the vector mask. The return type, the value to cast, and
the vector mask have the same number of elements.
The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.ptrtoint``' intrinsic converts value to return type by
+The '`llvm.vp.ptrtoint`' intrinsic converts value to return type by
interpreting the pointer value as an integer and either truncating or zero
extending that value to the size of the integer type.
-If ``value`` is smaller than return type, then a zero extension is done. If
-``value`` is larger than return type, then a truncation is done. If they are
+If `value` is smaller than return type, then a zero extension is done. If
+`value` is larger than return type, then a truncation is done. If they are
the same size, then nothing is done (*no-op cast*) other than a type
change.
The conversion is performed on lane positions below the explicit vector length
-and where the vector mask is true. Masked-off lanes are ``poison``.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+and where the vector mask is true. Masked-off lanes are `poison`.
- %r = call <4 x i8> @llvm.vp.ptrtoint.v4i8.v4p0i32(<4 x ptr> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = ptrtoint <4 x ptr> %a to <4 x i8>
- %also.r = select <4 x i1> %mask, <4 x i8> %t, <4 x i8> poison
+```llvm
+%r = call <4 x i8> @llvm.vp.ptrtoint.v4i8.v4p0i32(<4 x ptr> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = ptrtoint <4 x ptr> %a to <4 x i8>
+%also.r = select <4 x i1> %mask, <4 x i8> %t, <4 x i8> poison
+```
-.. _int_vp_inttoptr:
+(int_vp_inttoptr)=
-'``llvm.vp.inttoptr.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.inttoptr.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x ptr> @llvm.vp.inttoptr.v16p0.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x ptr> @llvm.vp.inttoptr.nxv4p0.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x ptr> @llvm.vp.inttoptr.v256p0.v256i32 (<256 x i32> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x ptr> @llvm.vp.inttoptr.v16p0.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x ptr> @llvm.vp.inttoptr.nxv4p0.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x ptr> @llvm.vp.inttoptr.v256p0.v256i32 (<256 x i32> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.inttoptr``' intrinsic converts its integer value to the point
+The '`llvm.vp.inttoptr`' intrinsic converts its integer value to the point
return type. The operation has a mask and an explicit vector length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.inttoptr``' intrinsic takes a value to cast as its first argument
-, which must be a vector of :ref:`integer <t_integer>` type, and a type to cast
+The '`llvm.vp.inttoptr`' intrinsic takes a value to cast as its first argument
+, which must be a vector of {ref}`integer <t_integer>` type, and a type to cast
it to return type, which must be a vector of pointers type.
The second argument is the vector mask. The return type, the value to cast, and
the vector mask have the same number of elements.
The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.inttoptr``' intrinsic converts ``value`` to return type by
+The '`llvm.vp.inttoptr`' intrinsic converts `value` to return type by
applying either a zero extension or a truncation depending on the size of the
-integer ``value``. If ``value`` is larger than the size of a pointer, then a
-truncation is done. If ``value`` is smaller than the size of a pointer, then a
+integer `value`. If `value` is larger than the size of a pointer, then a
+truncation is done. If `value` is smaller than the size of a pointer, then a
zero extension is done. If they are the same size, nothing is done (*no-op cast*).
The conversion is performed on lane positions below the explicit vector length
-and where the vector mask is true. Masked-off lanes are ``poison``.
+and where the vector mask is true. Masked-off lanes are `poison`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x ptr> @llvm.vp.inttoptr.v4p0i32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x ptr> @llvm.vp.inttoptr.v4p0i32.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = inttoptr <4 x i32> %a to <4 x ptr>
- %also.r = select <4 x i1> %mask, <4 x ptr> %t, <4 x ptr> poison
+%t = inttoptr <4 x i32> %a to <4 x ptr>
+%also.r = select <4 x i1> %mask, <4 x ptr> %t, <4 x ptr> poison
+```
+(int_vp_fcmp)=
-.. _int_vp_fcmp:
+#### '`llvm.vp.fcmp.*`' Intrinsics
-'``llvm.vp.fcmp.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i1> @llvm.vp.fcmp.v16f32(<16 x float> <left_op>, <16 x float> <right_op>, metadata <condition code>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i1> @llvm.vp.fcmp.nxv4f32(<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, metadata <condition code>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i1> @llvm.vp.fcmp.v256f64(<256 x double> <left_op>, <256 x double> <right_op>, metadata <condition code>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i1> @llvm.vp.fcmp.v16f32(<16 x float> <left_op>, <16 x float> <right_op>, metadata <condition code>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i1> @llvm.vp.fcmp.nxv4f32(<vscale x 4 x float> <left_op>, <vscale x 4 x float> <right_op>, metadata <condition code>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i1> @llvm.vp.fcmp.v256f64(<256 x double> <left_op>, <256 x double> <right_op>, metadata <condition code>, <256 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.vp.fcmp``' intrinsic returns a vector of boolean values based on
+The '`llvm.vp.fcmp`' intrinsic returns a vector of boolean values based on
the comparison of its arguments. The operation has a mask and an explicit vector
length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.fcmp``' intrinsic takes the two values to compare as its first
-and second arguments. These two values must be vectors of :ref:`floating-point
-<t_floating>` types.
+The '`llvm.vp.fcmp`' intrinsic takes the two values to compare as its first
+and second arguments. These two values must be vectors of {ref}`floating-point <t_floating>` types.
The return type is the result of the comparison. The return type must be a
-vector of :ref:`i1 <t_integer>` type. The fourth argument is the vector mask.
+vector of {ref}`i1 <t_integer>` type. The fourth argument is the vector mask.
The return type, the values to compare, and the vector mask have the same
number of elements. The third argument is the condition code indicating the kind
-of comparison to perform. It must be a metadata string with :ref:`one of the
-supported floating-point condition code values <fcmp_md_cc>`. The fifth argument
+of comparison to perform. It must be a metadata string with {ref}`one of the supported floating-point condition code values <fcmp_md_cc>`. The fifth argument
is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.fcmp``' compares its first two arguments according to the
+The '`llvm.vp.fcmp`' compares its first two arguments according to the
condition code given as the third argument. The arguments are compared element by
element on each enabled lane, where the semantics of the comparison are
-defined :ref:`according to the condition code <fcmp_md_cc_sem>`. Masked-off
-lanes are ``poison``.
-
-Examples:
-"""""""""
-
-.. code-block:: llvm
+defined {ref}`according to the condition code <fcmp_md_cc_sem>`. Masked-off
+lanes are `poison`.
- %r = call <4 x i1> @llvm.vp.fcmp.v4f32(<4 x float> %a, <4 x float> %b, metadata !"oeq", <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = fcmp oeq <4 x float> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i1> %t, <4 x i1> poison
+```llvm
+%r = call <4 x i1> @llvm.vp.fcmp.v4f32(<4 x float> %a, <4 x float> %b, metadata !"oeq", <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = fcmp oeq <4 x float> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i1> %t, <4 x i1> poison
+```
-.. _int_vp_icmp:
+(int_vp_icmp)=
-'``llvm.vp.icmp.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.icmp.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <32 x i1> @llvm.vp.icmp.v32i32(<32 x i32> <left_op>, <32 x i32> <right_op>, metadata <condition code>, <32 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 2 x i1> @llvm.vp.icmp.nxv2i32(<vscale x 2 x i32> <left_op>, <vscale x 2 x i32> <right_op>, metadata <condition code>, <vscale x 2 x i1> <mask>, i32 <vector_length>)
- declare <128 x i1> @llvm.vp.icmp.v128i8(<128 x i8> <left_op>, <128 x i8> <right_op>, metadata <condition code>, <128 x i1> <mask>, i32 <vector_length>)
+```
+declare <32 x i1> @llvm.vp.icmp.v32i32(<32 x i32> <left_op>, <32 x i32> <right_op>, metadata <condition code>, <32 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 2 x i1> @llvm.vp.icmp.nxv2i32(<vscale x 2 x i32> <left_op>, <vscale x 2 x i32> <right_op>, metadata <condition code>, <vscale x 2 x i1> <mask>, i32 <vector_length>)
+declare <128 x i1> @llvm.vp.icmp.v128i8(<128 x i8> <left_op>, <128 x i8> <right_op>, metadata <condition code>, <128 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.vp.icmp``' intrinsic returns a vector of boolean values based on
+The '`llvm.vp.icmp`' intrinsic returns a vector of boolean values based on
the comparison of its arguments. The operation has a mask and an explicit vector
length parameter.
-Arguments:
-""""""""""
+##### Arguments:
-The '``llvm.vp.icmp``' intrinsic takes the two values to compare as its first
-and second arguments. These two values must be vectors of :ref:`integer
-<t_integer>` types.
+The '`llvm.vp.icmp`' intrinsic takes the two values to compare as its first
+and second arguments. These two values must be vectors of {ref}`integer <t_integer>` types.
The return type is the result of the comparison. The return type must be a
-vector of :ref:`i1 <t_integer>` type. The fourth argument is the vector mask.
+vector of {ref}`i1 <t_integer>` type. The fourth argument is the vector mask.
The return type, the values to compare, and the vector mask have the same
number of elements. The third argument is the condition code indicating the kind
-of comparison to perform. It must be a metadata string with :ref:`one of the
-supported integer condition code values <icmp_md_cc>`. The fifth argument is the
+of comparison to perform. It must be a metadata string with {ref}`one of the supported integer condition code values <icmp_md_cc>`. The fifth argument is the
explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.icmp``' compares its first two arguments according to the
+The '`llvm.vp.icmp`' compares its first two arguments according to the
condition code given as the third argument. The arguments are compared element by
element on each enabled lane, where the semantics of the comparison are
-defined :ref:`according to the condition code <icmp_md_cc_sem>`. Masked-off
-lanes are ``poison``.
-
-Examples:
-"""""""""
+defined {ref}`according to the condition code <icmp_md_cc_sem>`. Masked-off
+lanes are `poison`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i1> @llvm.vp.icmp.v4i32(<4 x i32> %a, <4 x i32> %b, metadata !"ne", <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i1> @llvm.vp.icmp.v4i32(<4 x i32> %a, <4 x i32> %b, metadata !"ne", <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = icmp ne <4 x i32> %a, %b
- %also.r = select <4 x i1> %mask, <4 x i1> %t, <4 x i1> poison
+%t = icmp ne <4 x i32> %a, %b
+%also.r = select <4 x i1> %mask, <4 x i1> %t, <4 x i1> poison
+```
-.. _int_vp_ceil:
+(int_vp_ceil)=
-'``llvm.vp.ceil.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.ceil.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.ceil.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.ceil.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.ceil.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.ceil.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.ceil.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.ceil.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point ceiling of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.ceil``' intrinsic performs floating-point ceiling
-(:ref:`ceil <int_ceil>`) of the first vector argument on each enabled lane. The
-result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.ceil`' intrinsic performs floating-point ceiling
+({ref}`ceil <int_ceil>`) of the first vector argument on each enabled lane. The
+result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.ceil.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.ceil.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.ceil.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.ceil.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_floor:
+(int_vp_floor)=
-'``llvm.vp.floor.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.floor.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.floor.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.floor.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.floor.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.floor.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.floor.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.floor.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point floor of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.floor``' intrinsic performs floating-point floor
-(:ref:`floor <int_floor>`) of the first vector argument on each enabled lane.
-The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.floor`' intrinsic performs floating-point floor
+({ref}`floor <int_floor>`) of the first vector argument on each enabled lane.
+The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.floor.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.floor.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.floor.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.floor.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_rint:
+(int_vp_rint)=
-'``llvm.vp.rint.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.rint.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.rint.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.rint.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.rint.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.rint.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.rint.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.rint.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point rint of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.rint``' intrinsic performs floating-point rint
-(:ref:`rint <int_rint>`) of the first vector argument on each enabled lane.
-The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.rint`' intrinsic performs floating-point rint
+({ref}`rint <int_rint>`) of the first vector argument on each enabled lane.
+The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.rint.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.rint.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.rint.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.rint.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_nearbyint:
+(int_vp_nearbyint)=
-'``llvm.vp.nearbyint.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.nearbyint.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.nearbyint.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.nearbyint.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.nearbyint.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.nearbyint.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.nearbyint.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.nearbyint.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point nearbyint of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.nearbyint``' intrinsic performs floating-point nearbyint
-(:ref:`nearbyint <int_nearbyint>`) of the first vector argument on each enabled lane.
-The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.nearbyint`' intrinsic performs floating-point nearbyint
+({ref}`nearbyint <int_nearbyint>`) of the first vector argument on each enabled lane.
+The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_round:
+(int_vp_round)=
-'``llvm.vp.round.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.round.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.round.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.round.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.round.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.round.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.round.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.round.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point round of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.round``' intrinsic performs floating-point round
-(:ref:`round <int_round>`) of the first vector argument on each enabled lane.
-The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.round`' intrinsic performs floating-point round
+({ref}`round <int_round>`) of the first vector argument on each enabled lane.
+The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.round.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.round.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.round.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.round.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_roundeven:
+(int_vp_roundeven)=
-'``llvm.vp.roundeven.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.roundeven.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.roundeven.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.roundeven.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.roundeven.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.roundeven.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.roundeven.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.roundeven.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point roundeven of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.roundeven``' intrinsic performs floating-point roundeven
-(:ref:`roundeven <int_roundeven>`) of the first vector argument on each enabled
-lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.roundeven`' intrinsic performs floating-point roundeven
+({ref}`roundeven <int_roundeven>`) of the first vector argument on each enabled
+lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.roundeven.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.roundeven.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.roundeven.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.roundeven.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_roundtozero:
+(int_vp_roundtozero)=
-'``llvm.vp.roundtozero.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.roundtozero.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x float> @llvm.vp.roundtozero.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x float> @llvm.vp.roundtozero.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x double> @llvm.vp.roundtozero.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x float> @llvm.vp.roundtozero.v16f32 (<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x float> @llvm.vp.roundtozero.nxv4f32 (<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x double> @llvm.vp.roundtozero.v256f64 (<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated floating-point round-to-zero of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of floating-point type.
The second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.roundtozero``' intrinsic performs floating-point roundeven
-(:ref:`llvm.trunc <int_llvm_trunc>`) of the first vector argument on each enabled lane. The
-result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+The '`llvm.vp.roundtozero`' intrinsic performs floating-point roundeven
+({ref}`llvm.trunc <int_llvm_trunc>`) of the first vector argument on each enabled lane. The
+result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x float> @llvm.vp.roundtozero.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x float> @llvm.vp.roundtozero.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x float> @llvm.trunc.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+%t = call <4 x float> @llvm.trunc.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison
+```
-.. _int_vp_lrint:
+(int_vp_lrint)=
-'``llvm.vp.lrint.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.lrint.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.lrint.v16i32.v16f32(<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.lrint.nxv4i32.nxv4f32(<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.lrint.v256i64.v256f64(<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.lrint.v16i32.v16f32(<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.lrint.nxv4i32.nxv4f32(<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.lrint.v256i64.v256f64(<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated lrint of a vector of floating-point values.
-Arguments:
-""""""""""
+##### Arguments:
-The result is an integer vector and the first argument is a vector of :ref:`floating-point <t_floating>`
+The result is an integer vector and the first argument is a vector of {ref}`floating-point <t_floating>`
type with the same number of elements as the result vector type. The second
argument is the vector mask and has the same number of elements as the result
vector type. The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.lrint``' intrinsic performs lrint (:ref:`lrint <int_lrint>`) of
+The '`llvm.vp.lrint`' intrinsic performs lrint ({ref}`lrint <int_lrint>`) of
the first vector argument on each enabled lane. The result on disabled lanes is a
-:ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+{ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.lrint.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.lrint.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.lrint.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.lrint.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_llrint:
+(int_vp_llrint)=
-'``llvm.vp.llrint.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.llrint.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.llrint.v16i32.v16f32(<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.llrint.nxv4i32.nxv4f32(<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.llrint.v256i64.v256f64(<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.llrint.v16i32.v16f32(<16 x float> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.llrint.nxv4i32.nxv4f32(<vscale x 4 x float> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.llrint.v256i64.v256f64(<256 x double> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated llrint of a vector of floating-point values.
-Arguments:
-""""""""""
-The result is an integer vector and the first argument is a vector of :ref:`floating-point <t_floating>`
+##### Arguments:
+The result is an integer vector and the first argument is a vector of {ref}`floating-point <t_floating>`
type with the same number of elements as the result vector type. The second
argument is the vector mask and has the same number of elements as the result
vector type. The third argument is the explicit vector length of the operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.llrint``' intrinsic performs lrint (:ref:`llrint <int_llrint>`) of
+The '`llvm.vp.llrint`' intrinsic performs lrint ({ref}`llrint <int_llrint>`) of
the first vector argument on each enabled lane. The result on disabled lanes is a
-:ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+{ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.llrint.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.llrint.v4i32.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.llrint.v4f32(<4 x float> %a)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.llrint.v4f32(<4 x float> %a)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_bitreverse)=
-.. _int_vp_bitreverse:
+#### '`llvm.vp.bitreverse.*`' Intrinsics
-'``llvm.vp.bitreverse.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.bitreverse.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.bitreverse.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.bitreverse.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.bitreverse.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.bitreverse.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.bitreverse.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated bitreverse of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.bitreverse``' intrinsic performs bitreverse (:ref:`bitreverse <int_bitreverse>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+##### Semantics:
-Examples:
-"""""""""
-
-.. code-block:: llvm
+The '`llvm.vp.bitreverse`' intrinsic performs bitreverse ({ref}`bitreverse <int_bitreverse>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.bitreverse.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.bitreverse.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_bswap:
+(int_vp_bswap)=
-'``llvm.vp.bswap.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.bswap.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.bswap.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.bswap.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.bswap.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.bswap.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.bswap.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.bswap.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated bswap of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.bswap``' intrinsic performs bswap (:ref:`bswap <int_bswap>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+The '`llvm.vp.bswap`' intrinsic performs bswap ({ref}`bswap <int_bswap>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.bswap.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.bswap.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_ctpop)=
-.. _int_vp_ctpop:
+#### '`llvm.vp.ctpop.*`' Intrinsics
-'``llvm.vp.ctpop.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.ctpop.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.ctpop.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.ctpop.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.ctpop.v16i32 (<16 x i32> <op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.ctpop.nxv4i32 (<vscale x 4 x i32> <op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.ctpop.v256i64 (<256 x i64> <op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated ctpop of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument is the vector mask and has the same number of elements as the
result vector type. The third argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.ctpop``' intrinsic performs ctpop (:ref:`ctpop <int_ctpop>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+##### Semantics:
-.. code-block:: llvm
+The '`llvm.vp.ctpop`' intrinsic performs ctpop ({ref}`ctpop <int_ctpop>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.ctpop.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.ctpop.v4i32(<4 x i32> %a, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_ctlz:
+(int_vp_ctlz)=
-'``llvm.vp.ctlz.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.ctlz.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.ctlz.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.ctlz.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.ctlz.v256i64 (<256 x i64> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.ctlz.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.ctlz.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.ctlz.v256i64 (<256 x i64> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated ctlz of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument is a constant flag that indicates whether the intrinsic returns
@@ -27558,47 +25467,40 @@ mask and has the same number of elements as the result vector type. the fourth
argument is the explicit vector length of the operation. If the first argument
is zero and the second argument is true, the result is poison.
-Semantics:
-""""""""""
-
-The '``llvm.vp.ctlz``' intrinsic performs ctlz (:ref:`ctlz <int_ctlz>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-Examples:
-"""""""""
+##### Semantics:
-.. code-block:: llvm
+The '`llvm.vp.ctlz`' intrinsic performs ctlz ({ref}`ctlz <int_ctlz>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.ctlz.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 false)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.ctlz.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 false)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_cttz:
+(int_vp_cttz)=
-'``llvm.vp.cttz.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.cttz.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.cttz.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.cttz.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.cttz.v256i64 (<256 x i64> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.cttz.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.cttz.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.cttz.v256i64 (<256 x i64> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated cttz of a vector of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the result have the same vector of integer type. The
second argument is a constant flag that indicates whether the intrinsic
@@ -27607,49 +25509,42 @@ the vector mask and has the same number of elements as the result vector type.
The fourth argument is the explicit vector length of the operation. If the
first argument is zero and the second argument is true, the result is poison.
-Semantics:
-""""""""""
-
-The '``llvm.vp.cttz``' intrinsic performs cttz (:ref:`cttz <int_cttz>`) of the first argument on each
-enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+##### Semantics:
-Examples:
-"""""""""
-
-.. code-block:: llvm
+The '`llvm.vp.cttz`' intrinsic performs cttz ({ref}`cttz <int_cttz>`) of the first argument on each
+enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
- %r = call <4 x i32> @llvm.vp.cttz.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 false)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.cttz.v4i32(<4 x i32> %a, i1 false, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 false)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_cttz_elts:
+(int_vp_cttz_elts)=
-'``llvm.vp.cttz.elts.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.cttz.elts.*`' Intrinsics
-Syntax:
-"""""""
-This is an overloaded intrinsic. You can use ```llvm.vp.cttz.elts``` on any
+##### Syntax:
+This is an overloaded intrinsic. You can use `llvm.vp.cttz.elts` on any
vector of integer elements, both fixed width and scalable.
-::
-
- declare i32 @llvm.vp.cttz.elts.i32.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
- declare i64 @llvm.vp.cttz.elts.i64.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare i64 @llvm.vp.cttz.elts.i64.v256i1 (<256 x i1> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare i32 @llvm.vp.cttz.elts.i32.v16i32 (<16 x i32> <op>, i1 <is_zero_poison>, <16 x i1> <mask>, i32 <vector_length>)
+declare i64 @llvm.vp.cttz.elts.i64.nxv4i32 (<vscale x 4 x i32> <op>, i1 <is_zero_poison>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare i64 @llvm.vp.cttz.elts.i64.v256i1 (<256 x i1> <op>, i1 <is_zero_poison>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
-This '```llvm.vp.cttz.elts```' intrinsic counts the number of trailing zero
+This '`llvm.vp.cttz.elts`' intrinsic counts the number of trailing zero
elements of a vector. This is basically the vector-predicated version of
-'```llvm.experimental.cttz.elts```'.
+'`llvm.experimental.cttz.elts`'.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the vector to be counted. This argument must be a vector
with integer element type. The return type must also be an integer type which is
@@ -27664,1021 +25559,881 @@ The third argument is the vector mask and has the same number of elements as the
input vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.cttz.elts``' intrinsic counts the trailing (least
+The '`llvm.vp.cttz.elts`' intrinsic counts the trailing (least
significant / lowest-numbered) zero elements in the first argument on each
enabled lane. If the first argument is all zero and the second argument is true,
the result is poison. Otherwise, it returns the explicit vector length (i.e., the
fourth argument).
-.. _int_vp_sadd_sat:
+(int_vp_sadd_sat)=
-'``llvm.vp.sadd.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.sadd.sat.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.sadd.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.sadd.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.sadd.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.sadd.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.sadd.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.sadd.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated signed saturating addition of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.sadd.sat``' intrinsic performs sadd.sat (:ref:`sadd.sat <int_sadd_sat>`)
+The '`llvm.vp.sadd.sat`' intrinsic performs sadd.sat ({ref}`sadd.sat <int_sadd_sat>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-
-Examples:
-"""""""""
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
- %r = call <4 x i32> @llvm.vp.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_uadd_sat:
+(int_vp_uadd_sat)=
-'``llvm.vp.uadd.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.uadd.sat.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.uadd.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.uadd.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.uadd.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.uadd.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.uadd.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.uadd.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated unsigned saturating addition of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.uadd.sat``' intrinsic performs uadd.sat (:ref:`uadd.sat <int_uadd_sat>`)
+The '`llvm.vp.uadd.sat`' intrinsic performs uadd.sat ({ref}`uadd.sat <int_uadd_sat>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
- %r = call <4 x i32> @llvm.vp.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_ssub_sat:
+(int_vp_ssub_sat)=
-'``llvm.vp.ssub.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.ssub.sat.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.ssub.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.ssub.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.ssub.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.ssub.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.ssub.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.ssub.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated signed saturating subtraction of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.ssub.sat``' intrinsic performs ssub.sat (:ref:`ssub.sat <int_ssub_sat>`)
+The '`llvm.vp.ssub.sat`' intrinsic performs ssub.sat ({ref}`ssub.sat <int_ssub_sat>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
+(int_vp_usub_sat)=
-.. _int_vp_usub_sat:
+#### '`llvm.vp.usub.sat.*`' Intrinsics
-'``llvm.vp.usub.sat.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.usub.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.usub.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.usub.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.usub.sat.v16i32 (<16 x i32> <left_op> <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.usub.sat.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.usub.sat.v256i64 (<256 x i64> <left_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated unsigned saturating subtraction of two vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The
third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.vp.usub.sat``' intrinsic performs usub.sat (:ref:`usub.sat <int_usub_sat>`)
+The '`llvm.vp.usub.sat`' intrinsic performs usub.sat ({ref}`usub.sat <int_usub_sat>`)
of the first and second vector arguments on each enabled lane. The result on
-disabled lanes is a :ref:`poison value <poisonvalues>`.
-
-
-Examples:
-"""""""""
+disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
- %r = call <4 x i32> @llvm.vp.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %a, <4 x i32> %b)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-.. _int_vp_fshl:
+(int_vp_fshl)=
-'``llvm.vp.fshl.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fshl.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <16 x i32> @llvm.vp.fshl.v16i32 (<16 x i32> <left_op>, <16 x i32> <middle_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.fshl.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <middle_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.fshl.v256i64 (<256 x i64> <left_op>, <256 x i64> <middle_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
+declare <16 x i32> @llvm.vp.fshl.v16i32 (<16 x i32> <left_op>, <16 x i32> <middle_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.fshl.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <middle_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.fshl.v256i64 (<256 x i64> <left_op>, <256 x i64> <middle_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
-Overview:
-"""""""""
+##### Overview:
Predicated fshl of three vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first three arguments and the result have the same vector of integer type. The
fourth argument is the vector mask and has the same number of elements as the
result vector type. The fifth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.fshl``' intrinsic performs fshl (:ref:`fshl <int_fshl>`) of the first, second, and third
-vector argument on each enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
-
+##### Semantics:
-Examples:
-"""""""""
+The '`llvm.vp.fshl`' intrinsic performs fshl ({ref}`fshl <int_fshl>`) of the first, second, and third
+vector argument on each enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-.. code-block:: llvm
- %r = call <4 x i32> @llvm.vp.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+##### Examples:
- %t = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```llvm
+%r = call <4 x i32> @llvm.vp.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+%t = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-'``llvm.vp.fshr.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.fshr.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <16 x i32> @llvm.vp.fshr.v16i32 (<16 x i32> <left_op>, <16 x i32> <middle_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
+declare <vscale x 4 x i32> @llvm.vp.fshr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <middle_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
+declare <256 x i64> @llvm.vp.fshr.v256i64 (<256 x i64> <left_op>, <256 x i64> <middle_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
+```
- declare <16 x i32> @llvm.vp.fshr.v16i32 (<16 x i32> <left_op>, <16 x i32> <middle_op>, <16 x i32> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
- declare <vscale x 4 x i32> @llvm.vp.fshr.nxv4i32 (<vscale x 4 x i32> <left_op>, <vscale x 4 x i32> <middle_op>, <vscale x 4 x i32> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
- declare <256 x i64> @llvm.vp.fshr.v256i64 (<256 x i64> <left_op>, <256 x i64> <middle_op>, <256 x i64> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
-
-Overview:
-"""""""""
+##### Overview:
Predicated fshr of three vectors of integers.
-Arguments:
-""""""""""
+##### Arguments:
The first three arguments and the result have the same vector of integer type. The
fourth argument is the vector mask and has the same number of elements as the
result vector type. The fifth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.fshr``' intrinsic performs fshr (:ref:`fshr <int_fshr>`) of the first, second, and third
-vector argument on each enabled lane. The result on disabled lanes is a :ref:`poison value <poisonvalues>`.
+##### Semantics:
+The '`llvm.vp.fshr`' intrinsic performs fshr ({ref}`fshr <int_fshr>`) of the first, second, and third
+vector argument on each enabled lane. The result on disabled lanes is a {ref}`poison value <poisonvalues>`.
-Examples:
-"""""""""
-.. code-block:: llvm
+##### Examples:
- %r = call <4 x i32> @llvm.vp.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i1> %mask, i32 %evl)
- ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
+```llvm
+%r = call <4 x i32> @llvm.vp.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, <4 x i1> %mask, i32 %evl)
+;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
- %t = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
- %also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+%t = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
+%also.r = select <4 x i1> %mask, <4 x i32> %t, <4 x i32> poison
+```
-'``llvm.vp.is.fpclass.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vp.is.fpclass.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
+```
+declare <vscale x 2 x i1> @llvm.vp.is.fpclass.nxv2f32(<vscale x 2 x float> <op>, i32 <test>, <vscale x 2 x i1> <mask>, i32 <vector_length>)
+declare <2 x i1> @llvm.vp.is.fpclass.v2f16(<2 x half> <op>, i32 <test>, <2 x i1> <mask>, i32 <vector_length>)
+```
- declare <vscale x 2 x i1> @llvm.vp.is.fpclass.nxv2f32(<vscale x 2 x float> <op>, i32 <test>, <vscale x 2 x i1> <mask>, i32 <vector_length>)
- declare <2 x i1> @llvm.vp.is.fpclass.v2f16(<2 x half> <op>, i32 <test>, <2 x i1> <mask>, i32 <vector_length>)
+##### Overview:
-Overview:
-"""""""""
+Predicated `llvm.is.fpclass` {ref}`llvm.is.fpclass <llvm.is.fpclass>`
-Predicated ``llvm.is.fpclass`` :ref:`llvm.is.fpclass <llvm.is.fpclass>`
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point vector, the result type is a vector of
boolean with the same number of elements as the first argument. The second
-argument specifies, which tests to perform :ref:`llvm.is.fpclass <llvm.is.fpclass>`.
+argument specifies, which tests to perform {ref}`llvm.is.fpclass <llvm.is.fpclass>`.
The third argument is the vector mask and has the same number of elements as the
result vector type. The fourth argument is the explicit vector length of the
operation.
-Semantics:
-""""""""""
-
-The '``llvm.vp.is.fpclass``' intrinsic performs ``llvm.is.fpclass`` (:ref:`llvm.is.fpclass <llvm.is.fpclass>`).
+##### Semantics:
+The '`llvm.vp.is.fpclass`' intrinsic performs `llvm.is.fpclass` ({ref}`llvm.is.fpclass <llvm.is.fpclass>`).
-Examples:
-"""""""""
-.. code-block:: llvm
+##### Examples:
- %r = call <2 x i1> @llvm.vp.is.fpclass.v2f16(<2 x half> %x, i32 3, <2 x i1> %m, i32 %evl)
- %t = call <vscale x 2 x i1> @llvm.vp.is.fpclass.nxv2f16(<vscale x 2 x half> %x, i32 3, <vscale x 2 x i1> %m, i32 %evl)
+```llvm
+%r = call <2 x i1> @llvm.vp.is.fpclass.v2f16(<2 x half> %x, i32 3, <2 x i1> %m, i32 %evl)
+%t = call <vscale x 2 x i1> @llvm.vp.is.fpclass.nxv2f16(<vscale x 2 x half> %x, i32 3, <vscale x 2 x i1> %m, i32 %evl)
+```
-.. _int_mload_mstore:
+(int_mload_mstore)=
-Masked Vector Load and Store Intrinsics
----------------------------------------
+### Masked Vector Load and Store Intrinsics
LLVM provides intrinsics for predicated vector load and store operations. The predicate is specified by a mask argument, which holds one bit per vector element, switching the associated vector lane on or off. The memory addresses corresponding to the "off" lanes are not accessed. When all bits of the mask are on, the intrinsic is identical to a regular vector load or store. When all bits are off, no memory is accessed.
-.. _int_mload:
+(int_mload)=
-'``llvm.masked.load.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.load.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. The loaded data is a vector of any integer, floating-point or pointer data type.
-::
+```
+declare <16 x float> @llvm.masked.load.v16f32.p0(ptr <ptr>, <16 x i1> <mask>, <16 x float> <passthru>)
+declare <2 x double> @llvm.masked.load.v2f64.p0(ptr <ptr>, <2 x i1> <mask>, <2 x double> <passthru>)
+;; The data is a vector of pointers
+declare <8 x ptr> @llvm.masked.load.v8p0.p0(ptr <ptr>, <8 x i1> <mask>, <8 x ptr> <passthru>)
+```
- declare <16 x float> @llvm.masked.load.v16f32.p0(ptr <ptr>, <16 x i1> <mask>, <16 x float> <passthru>)
- declare <2 x double> @llvm.masked.load.v2f64.p0(ptr <ptr>, <2 x i1> <mask>, <2 x double> <passthru>)
- ;; The data is a vector of pointers
- declare <8 x ptr> @llvm.masked.load.v8p0.p0(ptr <ptr>, <8 x i1> <mask>, <8 x ptr> <passthru>)
+##### Overview:
-Overview:
-"""""""""
+Reads a vector from memory according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes. The masked-off lanes in the result vector are taken from the corresponding lanes of the '`passthru`' argument.
-Reads a vector from memory according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes. The masked-off lanes in the result vector are taken from the corresponding lanes of the '``passthru``' argument.
+##### Arguments:
-Arguments:
-""""""""""
+The first argument is the base pointer for the load. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type, underlying type of the base pointer and the type of the '`passthru`' argument are the same vector types.
-The first argument is the base pointer for the load. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type, underlying type of the base pointer and the type of the '``passthru``' argument are the same vector types.
+The alignment of the base pointer can be specified using the `align` attribute on the first argument.
-The alignment of the base pointer can be specified using the ``align`` attribute on the first argument.
+##### Semantics:
-Semantics:
-""""""""""
-
-The '``llvm.masked.load``' intrinsic is designed for conditional reading of selected vector elements in a single IR operation. It is useful for targets that support vector masked loads and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar load operations.
+The '`llvm.masked.load`' intrinsic is designed for conditional reading of selected vector elements in a single IR operation. It is useful for targets that support vector masked loads and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar load operations.
The result of this operation is equivalent to a regular vector load instruction followed by a 'select' between the loaded and the passthru values, predicated on the same mask, except that the masked-off lanes are not accessed.
Only the masked-on lanes of the vector need to be inbounds of an allocation (but all these lanes need to be inbounds of the same allocation).
In particular, using this intrinsic prevents exceptions on memory accesses to masked-off lanes.
-Masked-off lanes are also not considered accessed for the purpose of data races or ``noalias`` constraints.
-
+Masked-off lanes are also not considered accessed for the purpose of data races or `noalias` constraints.
-::
- %res = call <16 x float> @llvm.masked.load.v16f32.p0(ptr align 4 %ptr, <16 x i1>%mask, <16 x float> %passthru)
+```
+%res = call <16 x float> @llvm.masked.load.v16f32.p0(ptr align 4 %ptr, <16 x i1>%mask, <16 x float> %passthru)
- ;; The result of the two following instructions is identical aside from potential memory access exception
- %loadlal = load <16 x float>, ptr %ptr, align 4
- %res = select <16 x i1> %mask, <16 x float> %loadlal, <16 x float> %passthru
+;; The result of the two following instructions is identical aside from potential memory access exception
+%loadlal = load <16 x float>, ptr %ptr, align 4
+%res = select <16 x i1> %mask, <16 x float> %loadlal, <16 x float> %passthru
+```
-.. _int_mstore:
+(int_mstore)=
-'``llvm.masked.store.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.store.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. The data stored in memory is a vector of any integer, floating-point or pointer data type.
-::
-
- declare void @llvm.masked.store.v8i32.p0 (<8 x i32> <value>, ptr <ptr>, <8 x i1> <mask>)
- declare void @llvm.masked.store.v16f32.p0(<16 x float> <value>, ptr <ptr>, <16 x i1> <mask>)
- ;; The data is a vector of pointers
- declare void @llvm.masked.store.v8p0.p0 (<8 x ptr> <value>, ptr <ptr>, <8 x i1> <mask>)
+```
+declare void @llvm.masked.store.v8i32.p0 (<8 x i32> <value>, ptr <ptr>, <8 x i1> <mask>)
+declare void @llvm.masked.store.v16f32.p0(<16 x float> <value>, ptr <ptr>, <16 x i1> <mask>)
+;; The data is a vector of pointers
+declare void @llvm.masked.store.v8p0.p0 (<8 x ptr> <value>, ptr <ptr>, <8 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
Writes a vector to memory according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the vector value to be written to memory. The second argument is the base pointer for the store, it has the same underlying type as the value argument. The third argument, mask, is a vector of boolean values. The types of the mask and the value argument must have the same number of vector elements.
-The alignment of the base pointer can be specified using the ``align`` attribute on the second argument.
+The alignment of the base pointer can be specified using the `align` attribute on the second argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.masked.store``' intrinsics is designed for conditional writing of selected vector elements in a single IR operation. It is useful for targets that support vector masked store and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar store operations.
+The '`llvm.masked.store`' intrinsics is designed for conditional writing of selected vector elements in a single IR operation. It is useful for targets that support vector masked store and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar store operations.
The result of this operation is equivalent to a load-modify-store sequence, except that the masked-off lanes are not accessed.
Only the masked-on lanes of the vector need to be inbounds of an allocation (but all these lanes need to be inbounds of the same allocation).
In particular, using this intrinsic prevents exceptions on memory accesses to masked-off lanes.
-Masked-off lanes are also not considered accessed for the purpose of data races or ``noalias`` constraints.
-
-::
-
- call void @llvm.masked.store.v16f32.p0(<16 x float> %value, ptr align 4 %ptr, <16 x i1> %mask)
+Masked-off lanes are also not considered accessed for the purpose of data races or `noalias` constraints.
- ;; The result of the following instructions is identical aside from potential data races and memory access exceptions
- %oldval = load <16 x float>, ptr %ptr, align 4
- %res = select <16 x i1> %mask, <16 x float> %value, <16 x float> %oldval
- store <16 x float> %res, ptr %ptr, align 4
+```
+call void @llvm.masked.store.v16f32.p0(<16 x float> %value, ptr align 4 %ptr, <16 x i1> %mask)
+;; The result of the following instructions is identical aside from potential data races and memory access exceptions
+%oldval = load <16 x float>, ptr %ptr, align 4
+%res = select <16 x i1> %mask, <16 x float> %value, <16 x float> %oldval
+store <16 x float> %res, ptr %ptr, align 4
+```
-Masked Vector Gather and Scatter Intrinsics
--------------------------------------------
+### Masked Vector Gather and Scatter Intrinsics
-LLVM provides intrinsics for vector gather and scatter operations. They are similar to :ref:`Masked Vector Load and Store <int_mload_mstore>`, except they are designed for arbitrary memory accesses, rather than sequential memory accesses. Gather and scatter also employ a mask argument, which holds one bit per vector element, switching the associated vector lane on or off. The memory addresses corresponding to the "off" lanes are not accessed. When all bits are off, no memory is accessed.
+LLVM provides intrinsics for vector gather and scatter operations. They are similar to {ref}`Masked Vector Load and Store <int_mload_mstore>`, except they are designed for arbitrary memory accesses, rather than sequential memory accesses. Gather and scatter also employ a mask argument, which holds one bit per vector element, switching the associated vector lane on or off. The memory addresses corresponding to the "off" lanes are not accessed. When all bits are off, no memory is accessed.
-.. _int_mgather:
+(int_mgather)=
-'``llvm.masked.gather.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.gather.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. The loaded data are multiple scalar values of any integer, floating-point or pointer data type gathered together into one vector.
-::
-
- declare <16 x float> @llvm.masked.gather.v16f32.v16p0(<16 x ptr> <ptrs>, <16 x i1> <mask>, <16 x float> <passthru>)
- declare <2 x double> @llvm.masked.gather.v2f64.v2p1(<2 x ptr addrspace(1)> <ptrs>, <2 x i1> <mask>, <2 x double> <passthru>)
- declare <8 x ptr> @llvm.masked.gather.v8p0.v8p0(<8 x ptr> <ptrs>, <8 x i1> <mask>, <8 x ptr> <passthru>)
+```
+declare <16 x float> @llvm.masked.gather.v16f32.v16p0(<16 x ptr> <ptrs>, <16 x i1> <mask>, <16 x float> <passthru>)
+declare <2 x double> @llvm.masked.gather.v2f64.v2p1(<2 x ptr addrspace(1)> <ptrs>, <2 x i1> <mask>, <2 x double> <passthru>)
+declare <8 x ptr> @llvm.masked.gather.v8p0.v8p0(<8 x ptr> <ptrs>, <8 x i1> <mask>, <8 x ptr> <passthru>)
+```
-Overview:
-"""""""""
+##### Overview:
-Reads scalar values from arbitrary memory locations and gathers them into one vector. The memory locations are provided in the vector of pointers '``ptrs``'. The memory is accessed according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes. The masked-off lanes in the result vector are taken from the corresponding lanes of the '``passthru``' argument.
+Reads scalar values from arbitrary memory locations and gathers them into one vector. The memory locations are provided in the vector of pointers '`ptrs`'. The memory is accessed according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes. The masked-off lanes in the result vector are taken from the corresponding lanes of the '`passthru`' argument.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is a vector of pointers which holds all memory addresses to read. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type, underlying type of the vector of pointers and the type of the '``passthru``' argument are the same vector types.
+The first argument is a vector of pointers which holds all memory addresses to read. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type, underlying type of the vector of pointers and the type of the '`passthru`' argument are the same vector types.
-The alignment of the pointers can be specified using the ``align`` attribute on the first argument.
+The alignment of the pointers can be specified using the `align` attribute on the first argument.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.masked.gather``' intrinsic is designed for conditional reading of multiple scalar values from arbitrary memory locations in a single IR operation. It is useful for targets that support vector masked gathers and allows vectorizing basic blocks with data and control divergence. Other targets may support this intrinsic differently, for example by lowering it into a sequence of scalar load operations.
+The '`llvm.masked.gather`' intrinsic is designed for conditional reading of multiple scalar values from arbitrary memory locations in a single IR operation. It is useful for targets that support vector masked gathers and allows vectorizing basic blocks with data and control divergence. Other targets may support this intrinsic differently, for example by lowering it into a sequence of scalar load operations.
The semantics of this operation are equivalent to a sequence of conditional scalar loads with subsequent gathering all loaded values into a single vector. The mask restricts memory access to certain lanes and facilitates vectorization of predicated basic blocks.
-::
+```
+%res = call <4 x double> @llvm.masked.gather.v4f64.v4p0(<4 x ptr> align 8 %ptrs, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x double> poison)
- %res = call <4 x double> @llvm.masked.gather.v4f64.v4p0(<4 x ptr> align 8 %ptrs, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x double> poison)
+;; The gather with all-true mask is equivalent to the following instruction sequence
+%ptr0 = extractelement <4 x ptr> %ptrs, i32 0
+%ptr1 = extractelement <4 x ptr> %ptrs, i32 1
+%ptr2 = extractelement <4 x ptr> %ptrs, i32 2
+%ptr3 = extractelement <4 x ptr> %ptrs, i32 3
- ;; The gather with all-true mask is equivalent to the following instruction sequence
- %ptr0 = extractelement <4 x ptr> %ptrs, i32 0
- %ptr1 = extractelement <4 x ptr> %ptrs, i32 1
- %ptr2 = extractelement <4 x ptr> %ptrs, i32 2
- %ptr3 = extractelement <4 x ptr> %ptrs, i32 3
+%val0 = load double, ptr %ptr0, align 8
+%val1 = load double, ptr %ptr1, align 8
+%val2 = load double, ptr %ptr2, align 8
+%val3 = load double, ptr %ptr3, align 8
- %val0 = load double, ptr %ptr0, align 8
- %val1 = load double, ptr %ptr1, align 8
- %val2 = load double, ptr %ptr2, align 8
- %val3 = load double, ptr %ptr3, align 8
+%vec0 = insertelement <4 x double> poison, %val0, 0
+%vec01 = insertelement <4 x double> %vec0, %val1, 1
+%vec012 = insertelement <4 x double> %vec01, %val2, 2
+%vec0123 = insertelement <4 x double> %vec012, %val3, 3
+```
- %vec0 = insertelement <4 x double> poison, %val0, 0
- %vec01 = insertelement <4 x double> %vec0, %val1, 1
- %vec012 = insertelement <4 x double> %vec01, %val2, 2
- %vec0123 = insertelement <4 x double> %vec012, %val3, 3
+(int_mscatter)=
-.. _int_mscatter:
+#### '`llvm.masked.scatter.*`' Intrinsics
-'``llvm.masked.scatter.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. The data stored in memory is a vector of any integer, floating-point or pointer data type. Each vector element is stored in an arbitrary memory address. Scatter with overlapping addresses is guaranteed to be ordered from least-significant to most-significant element.
-::
+```
+declare void @llvm.masked.scatter.v8i32.v8p0 (<8 x i32> <value>, <8 x ptr> <ptrs>, <8 x i1> <mask>)
+declare void @llvm.masked.scatter.v16f32.v16p1(<16 x float> <value>, <16 x ptr addrspace(1)> <ptrs>, <16 x i1> <mask>)
+declare void @llvm.masked.scatter.v4p0.v4p0 (<4 x ptr> <value>, <4 x ptr> <ptrs>, <4 x i1> <mask>)
+```
- declare void @llvm.masked.scatter.v8i32.v8p0 (<8 x i32> <value>, <8 x ptr> <ptrs>, <8 x i1> <mask>)
- declare void @llvm.masked.scatter.v16f32.v16p1(<16 x float> <value>, <16 x ptr addrspace(1)> <ptrs>, <16 x i1> <mask>)
- declare void @llvm.masked.scatter.v4p0.v4p0 (<4 x ptr> <value>, <4 x ptr> <ptrs>, <4 x i1> <mask>)
-
-Overview:
-"""""""""
+##### Overview:
Writes each element from the value vector to the corresponding memory address. The memory addresses are represented as a vector of pointers. Writing is done according to the provided mask. The mask holds a bit for each vector lane, and is used to prevent memory accesses to the masked-off lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a vector value to be written to memory. The second argument is a vector of pointers, pointing to where the value elements should be stored. It has the same underlying type as the value argument. The third argument, mask, is a vector of boolean values. The types of the mask and the value argument must have the same number of vector elements.
-The alignment of the pointers can be specified using the ``align`` attribute on the second argument.
-
-Semantics:
-""""""""""
+The alignment of the pointers can be specified using the `align` attribute on the second argument.
-The '``llvm.masked.scatter``' intrinsics is designed for writing selected vector elements to arbitrary memory addresses in a single IR operation. The operation may be conditional, when not all bits in the mask are switched on. It is useful for targets that support vector masked scatter and allows vectorizing basic blocks with data and control divergence. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar store operations.
+##### Semantics:
-::
+The '`llvm.masked.scatter`' intrinsics is designed for writing selected vector elements to arbitrary memory addresses in a single IR operation. The operation may be conditional, when not all bits in the mask are switched on. It is useful for targets that support vector masked scatter and allows vectorizing basic blocks with data and control divergence. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar store operations.
- ;; This instruction unconditionally stores data vector in multiple addresses
- call @llvm.masked.scatter.v8i32.v8p0(<8 x i32> %value, <8 x ptr> align 4 %ptrs, <8 x i1> <true, true, .. true>)
-
- ;; It is equivalent to a list of scalar stores
- %val0 = extractelement <8 x i32> %value, i32 0
- %val1 = extractelement <8 x i32> %value, i32 1
- ..
- %val7 = extractelement <8 x i32> %value, i32 7
- %ptr0 = extractelement <8 x ptr> %ptrs, i32 0
- %ptr1 = extractelement <8 x ptr> %ptrs, i32 1
- ..
- %ptr7 = extractelement <8 x ptr> %ptrs, i32 7
- ;; Note: the order of the following stores is important when they overlap:
- store i32 %val0, ptr %ptr0, align 4
- store i32 %val1, ptr %ptr1, align 4
- ..
- store i32 %val7, ptr %ptr7, align 4
+```
+;; This instruction unconditionally stores data vector in multiple addresses
+call @llvm.masked.scatter.v8i32.v8p0(<8 x i32> %value, <8 x ptr> align 4 %ptrs, <8 x i1> <true, true, .. true>)
+;; It is equivalent to a list of scalar stores
+%val0 = extractelement <8 x i32> %value, i32 0
+%val1 = extractelement <8 x i32> %value, i32 1
+..
+%val7 = extractelement <8 x i32> %value, i32 7
+%ptr0 = extractelement <8 x ptr> %ptrs, i32 0
+%ptr1 = extractelement <8 x ptr> %ptrs, i32 1
+..
+%ptr7 = extractelement <8 x ptr> %ptrs, i32 7
+;; Note: the order of the following stores is important when they overlap:
+store i32 %val0, ptr %ptr0, align 4
+store i32 %val1, ptr %ptr1, align 4
+..
+store i32 %val7, ptr %ptr7, align 4
+```
-Masked Vector Expanding Load and Compressing Store Intrinsics
--------------------------------------------------------------
+### Masked Vector Expanding Load and Compressing Store Intrinsics
-LLVM provides intrinsics for expanding load and compressing store operations. Data selected from a vector according to a mask is stored in consecutive memory addresses (compressed store), and vice-versa (expanding load). These operations effective map to "if (cond.i) a[j++] = v.i" and "if (cond.i) v.i = a[j++]" patterns, respectively. Note that when the mask starts with '1' bits followed by '0' bits, these operations are identical to :ref:`llvm.masked.store <int_mstore>` and :ref:`llvm.masked.load <int_mload>`.
+LLVM provides intrinsics for expanding load and compressing store operations. Data selected from a vector according to a mask is stored in consecutive memory addresses (compressed store), and vice-versa (expanding load). These operations effective map to "if (cond.i) a[j++] = v.i" and "if (cond.i) v.i = a[j++]" patterns, respectively. Note that when the mask starts with '1' bits followed by '0' bits, these operations are identical to {ref}`llvm.masked.store <int_mstore>` and {ref}`llvm.masked.load <int_mload>`.
-.. _int_expandload:
+(int_expandload)=
-'``llvm.masked.expandload.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.expandload.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. Several values of integer, floating point or pointer data type are loaded from consecutive memory addresses and stored into the elements of a vector according to the mask.
-::
-
- declare <16 x float> @llvm.masked.expandload.v16f32 (ptr <ptr>, <16 x i1> <mask>, <16 x float> <passthru>)
- declare <2 x i64> @llvm.masked.expandload.v2i64 (ptr <ptr>, <2 x i1> <mask>, <2 x i64> <passthru>)
+```
+declare <16 x float> @llvm.masked.expandload.v16f32 (ptr <ptr>, <16 x i1> <mask>, <16 x float> <passthru>)
+declare <2 x i64> @llvm.masked.expandload.v2i64 (ptr <ptr>, <2 x i1> <mask>, <2 x i64> <passthru>)
+```
-Overview:
-"""""""""
+##### Overview:
-Reads a number of scalar values sequentially from memory location provided in '``ptr``' and spreads them in a vector. The '``mask``' holds a bit for each vector lane. The number of elements read from memory is equal to the number of '1' bits in the mask. The loaded elements are positioned in the destination vector according to the sequence of '1' and '0' bits in the mask. E.g., if the mask vector is '10010001', "expandload" reads 3 values from memory addresses ptr, ptr+1, ptr+2 and places them in lanes 0, 3 and 7 accordingly. The masked-off lanes are filled by elements from the corresponding lanes of the '``passthru``' argument.
+Reads a number of scalar values sequentially from memory location provided in '`ptr`' and spreads them in a vector. The '`mask`' holds a bit for each vector lane. The number of elements read from memory is equal to the number of '1' bits in the mask. The loaded elements are positioned in the destination vector according to the sequence of '1' and '0' bits in the mask. E.g., if the mask vector is '10010001', "expandload" reads 3 values from memory addresses ptr, ptr+1, ptr+2 and places them in lanes 0, 3 and 7 accordingly. The masked-off lanes are filled by elements from the corresponding lanes of the '`passthru`' argument.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is the base pointer for the load. It has the same underlying type as the element of the returned vector. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type and the type of the '``passthru``' argument have the same vector type.
+The first argument is the base pointer for the load. It has the same underlying type as the element of the returned vector. The second argument, mask, is a vector of boolean values with the same number of elements as the return type. The third is a pass-through value that is used to fill the masked-off lanes of the result. The return type and the type of the '`passthru`' argument have the same vector type.
-The :ref:`align <attr_align>` parameter attribute can be provided for the first
+The {ref}`align <attr_align>` parameter attribute can be provided for the first
argument. The pointer alignment defaults to 1.
-Semantics:
-""""""""""
-
-The '``llvm.masked.expandload``' intrinsic is designed for reading multiple scalar values from adjacent memory addresses into possibly non-adjacent vector lanes. It is useful for targets that support vector expanding loads and allows vectorizing loop with cross-iteration dependency like in the following example:
-
-.. code-block:: c
-
- // In this loop we load from B and spread the elements into array A.
- double *A, B; int *C;
- for (int i = 0; i < size; ++i) {
- if (C[i] != 0)
- A[i] = B[j++];
- }
-
-
-.. code-block:: llvm
-
- ; Load several elements from array B and expand them in a vector.
- ; The number of loaded elements is equal to the number of '1' elements in the Mask.
- %Tmp = call <8 x double> @llvm.masked.expandload.v8f64(ptr %Bptr, <8 x i1> %Mask, <8 x double> poison)
- ; Store the result in A
- call void @llvm.masked.store.v8f64.p0(<8 x double> %Tmp, ptr %Aptr, i32 8, <8 x i1> %Mask)
-
- ; %Bptr should be increased on each iteration according to the number of '1' elements in the Mask.
- %MaskI = bitcast <8 x i1> %Mask to i8
- %MaskIPopcnt = call i8 @llvm.ctpop.i8(i8 %MaskI)
- %MaskI64 = zext i8 %MaskIPopcnt to i64
- %BNextInd = add i64 %BInd, %MaskI64
-
+##### Semantics:
+
+The '`llvm.masked.expandload`' intrinsic is designed for reading multiple scalar values from adjacent memory addresses into possibly non-adjacent vector lanes. It is useful for targets that support vector expanding loads and allows vectorizing loop with cross-iteration dependency like in the following example:
+
+```c
+// In this loop we load from B and spread the elements into array A.
+double *A, B; int *C;
+for (int i = 0; i < size; ++i) {
+ if (C[i] != 0)
+ A[i] = B[j++];
+}
+```
+
+```llvm
+; Load several elements from array B and expand them in a vector.
+; The number of loaded elements is equal to the number of '1' elements in the Mask.
+%Tmp = call <8 x double> @llvm.masked.expandload.v8f64(ptr %Bptr, <8 x i1> %Mask, <8 x double> poison)
+; Store the result in A
+call void @llvm.masked.store.v8f64.p0(<8 x double> %Tmp, ptr %Aptr, i32 8, <8 x i1> %Mask)
+
+; %Bptr should be increased on each iteration according to the number of '1' elements in the Mask.
+%MaskI = bitcast <8 x i1> %Mask to i8
+%MaskIPopcnt = call i8 @llvm.ctpop.i8(i8 %MaskI)
+%MaskI64 = zext i8 %MaskIPopcnt to i64
+%BNextInd = add i64 %BInd, %MaskI64
+```
Other targets may support this intrinsic differently, for example, by lowering it into a sequence of conditional scalar load operations and shuffles.
If all mask elements are '1', the intrinsic behavior is equivalent to the regular unmasked vector load.
-.. _int_compressstore:
+(int_compressstore)=
-'``llvm.masked.compressstore.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.compressstore.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. A number of scalar values of integer, floating point or pointer data type are collected from an input vector and stored into adjacent memory addresses. A mask defines which elements to collect from the vector.
-::
-
- declare void @llvm.masked.compressstore.v8i32 (<8 x i32> <value>, ptr <ptr>, <8 x i1> <mask>)
- declare void @llvm.masked.compressstore.v16f32 (<16 x float> <value>, ptr <ptr>, <16 x i1> <mask>)
+```
+declare void @llvm.masked.compressstore.v8i32 (<8 x i32> <value>, ptr <ptr>, <8 x i1> <mask>)
+declare void @llvm.masked.compressstore.v16f32 (<16 x float> <value>, ptr <ptr>, <16 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
-Selects elements from input vector '``value``' according to the '``mask``'. All selected elements are written into adjacent memory addresses starting at address '`ptr`', from lower to higher. The mask holds a bit for each vector lane, and is used to select elements to be stored. The number of elements to be stored is equal to the number of active bits in the mask.
+Selects elements from input vector '`value`' according to the '`mask`'. All selected elements are written into adjacent memory addresses starting at address '`ptr`', from lower to higher. The mask holds a bit for each vector lane, and is used to select elements to be stored. The number of elements to be stored is equal to the number of active bits in the mask.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the input vector, from which elements are collected and written to memory. The second argument is the base pointer for the store, it has the same underlying type as the element of the input vector argument. The third argument is the mask, a vector of boolean values. The mask and the input vector must have the same number of vector elements.
-The :ref:`align <attr_align>` parameter attribute can be provided for the second
+The {ref}`align <attr_align>` parameter attribute can be provided for the second
argument. The pointer alignment defaults to 1.
-Semantics:
-""""""""""
-
-The '``llvm.masked.compressstore``' intrinsic is designed for compressing data in memory. It allows to collect elements from possibly non-adjacent lanes of a vector and store them contiguously in memory in one IR operation. It is useful for targets that support compressing store operations and allows vectorizing loops with cross-iteration dependencies like in the following example:
-
-.. code-block:: c
+##### Semantics:
- // In this loop we load elements from A and store them consecutively in B
- double *A, B; int *C;
- for (int i = 0; i < size; ++i) {
- if (C[i] != 0)
- B[j++] = A[i]
- }
+The '`llvm.masked.compressstore`' intrinsic is designed for compressing data in memory. It allows to collect elements from possibly non-adjacent lanes of a vector and store them contiguously in memory in one IR operation. It is useful for targets that support compressing store operations and allows vectorizing loops with cross-iteration dependencies like in the following example:
+```c
+// In this loop we load elements from A and store them consecutively in B
+double *A, B; int *C;
+for (int i = 0; i < size; ++i) {
+ if (C[i] != 0)
+ B[j++] = A[i]
+}
+```
-.. code-block:: llvm
-
- ; Load elements from A.
- %Tmp = call <8 x double> @llvm.masked.load.v8f64.p0(ptr %Aptr, i32 8, <8 x i1> %Mask, <8 x double> poison)
- ; Store all selected elements consecutively in array B
- call <void> @llvm.masked.compressstore.v8f64(<8 x double> %Tmp, ptr %Bptr, <8 x i1> %Mask)
-
- ; %Bptr should be increased on each iteration according to the number of '1' elements in the Mask.
- %MaskI = bitcast <8 x i1> %Mask to i8
- %MaskIPopcnt = call i8 @llvm.ctpop.i8(i8 %MaskI)
- %MaskI64 = zext i8 %MaskIPopcnt to i64
- %BNextInd = add i64 %BInd, %MaskI64
+```llvm
+; Load elements from A.
+%Tmp = call <8 x double> @llvm.masked.load.v8f64.p0(ptr %Aptr, i32 8, <8 x i1> %Mask, <8 x double> poison)
+; Store all selected elements consecutively in array B
+call <void> @llvm.masked.compressstore.v8f64(<8 x double> %Tmp, ptr %Bptr, <8 x i1> %Mask)
+; %Bptr should be increased on each iteration according to the number of '1' elements in the Mask.
+%MaskI = bitcast <8 x i1> %Mask to i8
+%MaskIPopcnt = call i8 @llvm.ctpop.i8(i8 %MaskI)
+%MaskI64 = zext i8 %MaskIPopcnt to i64
+%BNextInd = add i64 %BInd, %MaskI64
+```
Other targets may support this intrinsic differently, for example, by lowering it into a sequence of branches that guard scalar store operations.
-Masked Vector Arithmetic Intrinsics
------------------------------------
+### Masked Vector Arithmetic Intrinsics
-'``llvm.masked.udiv.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.udiv.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <8 x i32> @llvm.masked.udiv.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
- declare <vscale x 2 x i64> @llvm.masked.udiv.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
+declare <8 x i32> @llvm.masked.udiv.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
+declare <vscale x 2 x i64> @llvm.masked.udiv.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
-Performs unsigned division (:ref:`udiv <i_udiv>`) of two vectors of integers, but only on enabled lanes.
+Performs unsigned division ({ref}`udiv <i_udiv>`) of two vectors of integers, but only on enabled lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The third argument is the vector mask and has the same number of elements as the result vector type.
-Semantics:
-""""""""""
+##### Semantics:
-Follows the same semantics as :ref:`udiv <i_udiv>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
+Follows the same semantics as {ref}`udiv <i_udiv>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
-'``llvm.masked.sdiv.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.sdiv.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <8 x i32> @llvm.masked.sdiv.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
- declare <vscale x 2 x i64> @llvm.masked.sdiv.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
+declare <8 x i32> @llvm.masked.sdiv.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
+declare <vscale x 2 x i64> @llvm.masked.sdiv.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
-Performs signed division (:ref:`sdiv <i_sdiv>`) of two vectors of integers, but only on enabled lanes.
+Performs signed division ({ref}`sdiv <i_sdiv>`) of two vectors of integers, but only on enabled lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The third argument is the vector mask and has the same number of elements as the result vector type.
-Semantics:
-""""""""""
+##### Semantics:
-Follows the same semantics as :ref:`sdiv <i_sdiv>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
+Follows the same semantics as {ref}`sdiv <i_sdiv>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
-'``llvm.masked.urem.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.urem.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <8 x i32> @llvm.masked.urem.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
- declare <vscale x 2 x i64> @llvm.masked.urem.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
+declare <8 x i32> @llvm.masked.urem.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
+declare <vscale x 2 x i64> @llvm.masked.urem.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
-Computes the remainder from the unsigned division (:ref:`urem <i_urem>`) of two vectors of integers, but only on enabled lanes.
+Computes the remainder from the unsigned division ({ref}`urem <i_urem>`) of two vectors of integers, but only on enabled lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The third argument is the vector mask and has the same number of elements as the result vector type.
-Semantics:
-""""""""""
+##### Semantics:
-Follows the same semantics as :ref:`urem <i_urem>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
+Follows the same semantics as {ref}`urem <i_urem>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
-'``llvm.masked.srem.*``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.masked.srem.*`' Intrinsics
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic.
-::
-
- declare <8 x i32> @llvm.masked.srem.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
- declare <vscale x 2 x i64> @llvm.masked.srem.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
+declare <8 x i32> @llvm.masked.srem.v8i32(<8 x i32> <op1>, <8 x i32> <op2>, <8 x i1> <mask>)
+declare <vscale x 2 x i64> @llvm.masked.srem.nxv2i64(<vscale x 2 x i64> <op1>, <vscale x 2 x i64> <op2>, <vscale x 2 x i1> <mask>)
+```
-Overview:
-"""""""""
+##### Overview:
-Computes the remainder from the signed division (:ref:`srem <i_srem>`) of two vectors of integers, but only on enabled lanes.
+Computes the remainder from the signed division ({ref}`srem <i_srem>`) of two vectors of integers, but only on enabled lanes.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the result have the same vector of integer type. The third argument is the vector mask and has the same number of elements as the result vector type.
-Semantics:
-""""""""""
+##### Semantics:
-Follows the same semantics as :ref:`srem <i_srem>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
+Follows the same semantics as {ref}`srem <i_srem>` with the exception that disabled lanes cannot produce undefined behaviour and always result in poison.
-Memory Use Markers
-------------------
+### Memory Use Markers
This class of intrinsics provides information about the
-:ref:`lifetime of allocated objects <objectlifetime>` and ranges where variables
+{ref}`lifetime of allocated objects <objectlifetime>` and ranges where variables
are immutable.
-.. _int_lifestart:
+(int_lifestart)=
-'``llvm.lifetime.start``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.lifetime.start`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.lifetime.start(ptr captures(none) <ptr>)
+```
+declare void @llvm.lifetime.start(ptr captures(none) <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.lifetime.start``' intrinsic specifies the start of a memory
+The '`llvm.lifetime.start`' intrinsic specifies the start of a memory
object's lifetime.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is either a ``poison`` value or an SSA variable whose defining
-instruction is ``alloca`` or a call of the ``llvm.structured.alloca``
+The argument is either a `poison` value or an SSA variable whose defining
+instruction is `alloca` or a call of the `llvm.structured.alloca`
intrinsics. Otherwise, the IR is considered ill-formed.
-Semantics:
-""""""""""
+##### Semantics:
-If ``ptr`` is a ``poison`` value, the intrinsic has no effect.
+If `ptr` is a `poison` value, the intrinsic has no effect.
-Otherwise, the stack-allocated object that ``ptr`` points to is initially
-marked as dead. After '``llvm.lifetime.start``', the stack object is marked as
+Otherwise, the stack-allocated object that `ptr` points to is initially
+marked as dead. After '`llvm.lifetime.start`', the stack object is marked as
alive and has an uninitialized value.
-Calling ``llvm.lifetime.start`` when the stack object is already alive just
+Calling `llvm.lifetime.start` when the stack object is already alive just
resets its contents to be uninitialized.
The stack object is marked as dead again when either
-:ref:`llvm.lifetime.end <int_lifeend>` to the alloca/structured.alloca is executed or the
+{ref}`llvm.lifetime.end <int_lifeend>` to the alloca/structured.alloca is executed or the
function returns.
-After :ref:`llvm.lifetime.end <int_lifeend>` is called,
-'``llvm.lifetime.start``' on the stack object can be called again.
-The second '``llvm.lifetime.start``' call marks the object as alive, but it
+After {ref}`llvm.lifetime.end <int_lifeend>` is called,
+'`llvm.lifetime.start`' on the stack object can be called again.
+The second '`llvm.lifetime.start`' call marks the object as alive, but it
does not change the address of the object.
-.. _int_lifeend:
+(int_lifeend)=
-'``llvm.lifetime.end``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.lifetime.end`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.lifetime.end(ptr captures(none) <ptr>)
+```
+declare void @llvm.lifetime.end(ptr captures(none) <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.lifetime.end``' intrinsic specifies the end of a
-:ref:`allocated object's lifetime<objectlifetime>`.
+The '`llvm.lifetime.end`' intrinsic specifies the end of a
+{ref}`allocated object's lifetime<objectlifetime>`.
-Arguments:
-""""""""""
+##### Arguments:
-The argument is either a ``poison`` value or an SSA variable whose defining
-instruction is ``alloca`` or a call of the ``llvm.structured.alloca``
+The argument is either a `poison` value or an SSA variable whose defining
+instruction is `alloca` or a call of the `llvm.structured.alloca`
intrinsics. Otherwise, the IR is considered ill-formed.
-Semantics:
-""""""""""
+##### Semantics:
-If ``ptr`` is a ``poison`` value, the intrinsic has no effect.
+If `ptr` is a `poison` value, the intrinsic has no effect.
-Otherwise, the stack-allocated object that ``ptr`` points to becomes dead after
+Otherwise, the stack-allocated object that `ptr` points to becomes dead after
the call to this intrinsic.
-Calling ``llvm.lifetime.end`` on an already dead alloca/structured.alloca is
+Calling `llvm.lifetime.end` on an already dead alloca/structured.alloca is
no-op.
-'``llvm.invariant.start``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.invariant.start`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
+##### Syntax:
+This is an overloaded intrinsic. The {ref}`allocated object<allocatedobjects>`
can belong to any address space.
-::
-
- declare ptr @llvm.invariant.start.p0(i64 <size>, ptr captures(none) <ptr>)
+```
+declare ptr @llvm.invariant.start.p0(i64 <size>, ptr captures(none) <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.invariant.start``' intrinsic specifies that the contents of
-an :ref:`allocated object<allocatedobjects>` will not change.
+The '`llvm.invariant.start`' intrinsic specifies that the contents of
+an {ref}`allocated object<allocatedobjects>` will not change.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a constant integer representing the size of the
object, or -1 if it is variable sized. The second argument is a pointer
to the object.
-Semantics:
-""""""""""
+##### Semantics:
-This intrinsic indicates that until an ``llvm.invariant.end`` that uses
+This intrinsic indicates that until an `llvm.invariant.end` that uses
the return value, the referenced memory location is constant and
unchanging.
-'``llvm.invariant.end``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.invariant.end`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
+##### Syntax:
+This is an overloaded intrinsic. The {ref}`allocated object<allocatedobjects>`
can belong to any address space.
-::
-
- declare void @llvm.invariant.end.p0(ptr <start>, i64 <size>, ptr captures(none) <ptr>)
+```
+declare void @llvm.invariant.end.p0(ptr <start>, i64 <size>, ptr captures(none) <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.invariant.end``' intrinsic specifies that the contents of an
-:ref:`allocated object<allocatedobjects>` are mutable.
+The '`llvm.invariant.end`' intrinsic specifies that the contents of an
+{ref}`allocated object<allocatedobjects>` are mutable.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument is the matching ``llvm.invariant.start`` intrinsic.
+The first argument is the matching `llvm.invariant.start` intrinsic.
The second argument is a constant integer representing the size of the
object, or -1 if it is variable sized and the third argument is a
pointer to the object.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic indicates that the memory is mutable again.
-'``llvm.launder.invariant.group``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.launder.invariant.group`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
+##### Syntax:
+This is an overloaded intrinsic. The {ref}`allocated object<allocatedobjects>`
can belong to any address space. The returned pointer must belong to the same
address space as the argument.
-::
-
- declare ptr @llvm.launder.invariant.group.p0(ptr <ptr>)
+```
+declare ptr @llvm.launder.invariant.group.p0(ptr <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.launder.invariant.group``' intrinsic can be used when an invariant
-established by ``invariant.group`` metadata no longer holds, to obtain a new
+The '`llvm.launder.invariant.group`' intrinsic can be used when an invariant
+established by `invariant.group` metadata no longer holds, to obtain a new
pointer value that carries fresh invariant group information. It is an
experimental intrinsic, which means that its semantics might change in the
future.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.launder.invariant.group`` takes only one argument, which is a pointer
+The `llvm.launder.invariant.group` takes only one argument, which is a pointer
to the memory.
-Semantics:
-""""""""""
+##### Semantics:
Returns another pointer that aliases its argument but which is considered different
-for the purposes of ``load``/``store`` ``invariant.group`` metadata.
+for the purposes of `load`/`store` `invariant.group` metadata.
It does not read any accessible memory and the execution can be speculated.
-'``llvm.strip.invariant.group``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.strip.invariant.group`' Intrinsic
-Syntax:
-"""""""
-This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
+##### Syntax:
+This is an overloaded intrinsic. The {ref}`allocated object<allocatedobjects>`
can belong to any address space. The returned pointer must belong to the same
address space as the argument.
-::
-
- declare ptr @llvm.strip.invariant.group.p0(ptr <ptr>)
+```
+declare ptr @llvm.strip.invariant.group.p0(ptr <ptr>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.strip.invariant.group``' intrinsic can be used when an invariant
-established by ``invariant.group`` metadata no longer holds, to obtain a new pointer
+The '`llvm.strip.invariant.group`' intrinsic can be used when an invariant
+established by `invariant.group` metadata no longer holds, to obtain a new pointer
value that does not carry the invariant information. It is an experimental
intrinsic, which means that its semantics might change in the future.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.strip.invariant.group`` takes only one argument, which is a pointer
+The `llvm.strip.invariant.group` takes only one argument, which is a pointer
to the memory.
-Semantics:
-""""""""""
+##### Semantics:
Returns another pointer that aliases its argument but which has no associated
-``invariant.group`` metadata.
+`invariant.group` metadata.
It does not read any memory and can be speculated.
-.. _constrainedfp:
+(constrainedfp)=
-Constrained Floating-Point Intrinsics
--------------------------------------
+### Constrained Floating-Point Intrinsics
These intrinsics are used to provide special handling of floating-point
operations when specific rounding mode or floating-point exception behavior is
@@ -28704,14 +26459,14 @@ assumptions, if any, the optimizer can make when transforming constant
values. Some constrained FP intrinsics omit this argument. If required
by the intrinsic, this argument must be one of the following strings:
-::
-
- "round.dynamic"
- "round.tonearest"
- "round.downward"
- "round.upward"
- "round.towardzero"
- "round.tonearestaway"
+```
+"round.dynamic"
+"round.tonearest"
+"round.downward"
+"round.upward"
+"round.towardzero"
+"round.tonearestaway"
+```
If this argument is "round.dynamic" optimization passes must assume that the
rounding mode is unknown and may change at runtime. No transformations that
@@ -28737,11 +26492,11 @@ The exception behavior argument is a metadata string describing the floating
point exception semantics that required for the intrinsic. This argument
must be one of the following strings:
-::
-
- "fpexcept.ignore"
- "fpexcept.maytrap"
- "fpexcept.strict"
+```
+"fpexcept.ignore"
+"fpexcept.maytrap"
+"fpexcept.strict"
+```
If this argument is "fpexcept.ignore" optimization passes may assume that the
exception status flags will not be read and that floating-point exceptions will
@@ -28771,190 +26526,166 @@ example, a series of FP operations that each may raise exceptions may be
vectorized into a single instruction that raises each unique exception a single
time.
-Proper :ref:`function attributes <fnattrs>` usage is required for the
+Proper {ref}`function attributes <fnattrs>` usage is required for the
constrained intrinsics to function correctly.
All function *calls* done in a function that uses constrained floating
-point intrinsics must have the ``strictfp`` attribute either on the
+point intrinsics must have the `strictfp` attribute either on the
calling instruction or on the declaration or definition of the function
being called.
All function *definitions* that use constrained floating point intrinsics
-must have the ``strictfp`` attribute.
+must have the `strictfp` attribute.
-'``llvm.experimental.constrained.fadd``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.fadd`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fadd(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fadd(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fadd``' intrinsic returns the sum of its
+The '`llvm.experimental.constrained.fadd`' intrinsic returns the sum of its
two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.fadd``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.fadd`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point sum of the two value arguments and has
the same type as the arguments.
-'``llvm.experimental.constrained.fsub``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fsub`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fsub(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fsub(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fsub``' intrinsic returns the difference
+The '`llvm.experimental.constrained.fsub`' intrinsic returns the difference
of its two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.fsub``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.fsub`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point difference of the two value arguments
and has the same type as the arguments.
-'``llvm.experimental.constrained.fmul``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.fmul`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fmul(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fmul(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fmul``' intrinsic returns the product of
+The '`llvm.experimental.constrained.fmul`' intrinsic returns the product of
its two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.fmul``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.fmul`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point product of the two value arguments and
has the same type as the arguments.
-'``llvm.experimental.constrained.fdiv``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fdiv`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fdiv(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fdiv(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fdiv``' intrinsic returns the quotient of
+The '`llvm.experimental.constrained.fdiv`' intrinsic returns the quotient of
its two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.fdiv``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.fdiv`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point quotient of the two value arguments and
has the same type as the arguments.
-'``llvm.experimental.constrained.frem``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.frem`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.frem(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.frem(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.frem``' intrinsic returns the remainder
+The '`llvm.experimental.constrained.frem`' intrinsic returns the remainder
from the division of its two arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.frem``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.frem`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third and fourth arguments specify the rounding mode and exception
@@ -28962,438 +26693,384 @@ behavior as described above. The rounding mode argument has no effect, since
the result of frem is never rounded, but the argument is included for
consistency with the other constrained floating-point intrinsics.
-Semantics:
-""""""""""
+##### Semantics:
The value produced is the floating-point remainder from the division of the two
value arguments and has the same type as the arguments. The remainder has the
same sign as the dividend.
-'``llvm.experimental.constrained.fma``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fma`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fma(<type> <op1>, <type> <op2>, <type> <op3>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fma(<type> <op1>, <type> <op2>, <type> <op3>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fma``' intrinsic returns the result of a
+The '`llvm.experimental.constrained.fma`' intrinsic returns the result of a
fused-multiply-add operation on its arguments.
-Arguments:
-""""""""""
+##### Arguments:
-The first three arguments to the '``llvm.experimental.constrained.fma``'
-intrinsic must be :ref:`floating-point <t_floating>` or :ref:`vector
-<t_vector>` of floating-point values. All arguments must have identical types.
+The first three arguments to the '`llvm.experimental.constrained.fma`'
+intrinsic must be {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of floating-point values. All arguments must have identical types.
The fourth and fifth arguments specify the rounding mode and exception behavior
as described above.
-Semantics:
-""""""""""
+##### Semantics:
The result produced is the product of the first two arguments added to the third
argument computed with infinite precision, and then rounded to the target
precision.
-'``llvm.experimental.constrained.fptoui``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.fptoui`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.fptoui(<type> <value>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.fptoui(<type> <value>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fptoui``' intrinsic converts a
-floating-point ``value`` to its unsigned integer equivalent of type ``ty2``.
+The '`llvm.experimental.constrained.fptoui`' intrinsic converts a
+floating-point `value` to its unsigned integer equivalent of type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.fptoui``'
-intrinsic must be :ref:`floating point <t_floating>` or :ref:`vector
-<t_vector>` of floating point values.
+The first argument to the '`llvm.experimental.constrained.fptoui`'
+intrinsic must be {ref}`floating point <t_floating>` or {ref}`vector <t_vector>` of floating point values.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The result produced is an unsigned integer converted from the floating
point argument. The value is truncated, so it is rounded towards zero.
-'``llvm.experimental.constrained.fptosi``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fptosi`' Intrinsic
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.fptosi(<type> <value>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.fptosi(<type> <value>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fptosi``' intrinsic converts
-:ref:`floating-point <t_floating>` ``value`` to type ``ty2``.
+The '`llvm.experimental.constrained.fptosi`' intrinsic converts
+{ref}`floating-point <t_floating>` `value` to type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.fptosi``'
-intrinsic must be :ref:`floating point <t_floating>` or :ref:`vector
-<t_vector>` of floating point values.
+The first argument to the '`llvm.experimental.constrained.fptosi`'
+intrinsic must be {ref}`floating point <t_floating>` or {ref}`vector <t_vector>` of floating point values.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The result produced is a signed integer converted from the floating
point argument. The value is truncated, so it is rounded towards zero.
-'``llvm.experimental.constrained.uitofp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.uitofp`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.uitofp(<type> <value>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.uitofp(<type> <value>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.uitofp``' intrinsic converts an
-unsigned integer ``value`` to a floating-point of type ``ty2``.
+The '`llvm.experimental.constrained.uitofp`' intrinsic converts an
+unsigned integer `value` to a floating-point of type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.uitofp``'
-intrinsic must be an :ref:`integer <t_integer>` or :ref:`vector
-<t_vector>` of integer values.
+The first argument to the '`llvm.experimental.constrained.uitofp`'
+intrinsic must be an {ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
An inexact floating-point exception will be raised if rounding is required.
Any result produced is a floating point value converted from the input
integer argument.
-'``llvm.experimental.constrained.sitofp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.sitofp`' Intrinsic
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.sitofp(<type> <value>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.sitofp(<type> <value>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.sitofp``' intrinsic converts a
-signed integer ``value`` to a floating-point of type ``ty2``.
+The '`llvm.experimental.constrained.sitofp`' intrinsic converts a
+signed integer `value` to a floating-point of type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.sitofp``'
-intrinsic must be an :ref:`integer <t_integer>` or :ref:`vector
-<t_vector>` of integer values.
+The first argument to the '`llvm.experimental.constrained.sitofp`'
+intrinsic must be an {ref}`integer <t_integer>` or {ref}`vector <t_vector>` of integer values.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
An inexact floating-point exception will be raised if rounding is required.
Any result produced is a floating point value converted from the input
integer argument.
-'``llvm.experimental.constrained.fptrunc``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.fptrunc`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.fptrunc(<type> <value>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.fptrunc(<type> <value>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fptrunc``' intrinsic truncates ``value``
-to type ``ty2``.
+The '`llvm.experimental.constrained.fptrunc`' intrinsic truncates `value`
+to type `ty2`.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.fptrunc``'
-intrinsic must be :ref:`floating point <t_floating>` or :ref:`vector
-<t_vector>` of floating point values. This argument must be larger in size
+The first argument to the '`llvm.experimental.constrained.fptrunc`'
+intrinsic must be {ref}`floating point <t_floating>` or {ref}`vector <t_vector>` of floating point values. This argument must be larger in size
than the result.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The result produced is a floating point value truncated to be smaller in size
than the argument.
-'``llvm.experimental.constrained.fpext``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fpext`' Intrinsic
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.fpext(<type> <value>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.fpext(<type> <value>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fpext``' intrinsic extends a
-floating-point ``value`` to a larger floating-point value.
+The '`llvm.experimental.constrained.fpext`' intrinsic extends a
+floating-point `value` to a larger floating-point value.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.experimental.constrained.fpext``'
-intrinsic must be :ref:`floating point <t_floating>` or :ref:`vector
-<t_vector>` of floating point values. This argument must be smaller in size
+The first argument to the '`llvm.experimental.constrained.fpext`'
+intrinsic must be {ref}`floating point <t_floating>` or {ref}`vector <t_vector>` of floating point values. This argument must be smaller in size
than the result.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
The result produced is a floating point value extended to be larger in size
than the argument. All restrictions that apply to the fpext instruction also
apply to this intrinsic.
-'``llvm.experimental.constrained.fcmp``' and '``llvm.experimental.constrained.fcmps``' Intrinsics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.fcmp`' and '`llvm.experimental.constrained.fcmps`' Intrinsics
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <ty2>
- @llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
- metadata <condition code>,
- metadata <exception behavior>)
- declare <ty2>
- @llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
- metadata <condition code>,
- metadata <exception behavior>)
+```
+declare <ty2>
+ at llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
+ metadata <condition code>,
+ metadata <exception behavior>)
+declare <ty2>
+ at llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
+ metadata <condition code>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fcmp``' and
-'``llvm.experimental.constrained.fcmps``' intrinsics return a boolean
+The '`llvm.experimental.constrained.fcmp`' and
+'`llvm.experimental.constrained.fcmps`' intrinsics return a boolean
value or vector of boolean values based on comparison of its arguments.
If the arguments are floating-point scalars, then the result type is a
-boolean (:ref:`i1 <t_integer>`).
+boolean ({ref}`i1 <t_integer>`).
If the arguments are floating-point vectors, then the result type is a
vector of boolean with the same number of elements as the arguments being
compared.
-The '``llvm.experimental.constrained.fcmp``' intrinsic performs a quiet
-comparison operation while the '``llvm.experimental.constrained.fcmps``'
+The '`llvm.experimental.constrained.fcmp`' intrinsic performs a quiet
+comparison operation while the '`llvm.experimental.constrained.fcmps`'
intrinsic performs a signaling comparison operation.
-Arguments:
-""""""""""
+##### Arguments:
-The first two arguments to the '``llvm.experimental.constrained.fcmp``'
-and '``llvm.experimental.constrained.fcmps``' intrinsics must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first two arguments to the '`llvm.experimental.constrained.fcmp`'
+and '`llvm.experimental.constrained.fcmps`' intrinsics must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values. Both arguments must have identical types.
The third argument is the condition code indicating the kind of comparison
to perform. It must be a metadata string with one of the following values:
-.. _fcmp_md_cc:
-
-- "``oeq``": ordered and equal
-- "``ogt``": ordered and greater than
-- "``oge``": ordered and greater than or equal
-- "``olt``": ordered and less than
-- "``ole``": ordered and less than or equal
-- "``one``": ordered and not equal
-- "``ord``": ordered (no nans)
-- "``ueq``": unordered or equal
-- "``ugt``": unordered or greater than
-- "``uge``": unordered or greater than or equal
-- "``ult``": unordered or less than
-- "``ule``": unordered or less than or equal
-- "``une``": unordered or not equal
-- "``uno``": unordered (either nans)
+(fcmp_md_cc)=
+
+- "`oeq`": ordered and equal
+- "`ogt`": ordered and greater than
+- "`oge`": ordered and greater than or equal
+- "`olt`": ordered and less than
+- "`ole`": ordered and less than or equal
+- "`one`": ordered and not equal
+- "`ord`": ordered (no nans)
+- "`ueq`": unordered or equal
+- "`ugt`": unordered or greater than
+- "`uge`": unordered or greater than or equal
+- "`ult`": unordered or less than
+- "`ule`": unordered or less than or equal
+- "`une`": unordered or not equal
+- "`uno`": unordered (either nans)
*Ordered* means that neither argument is a NAN while *unordered* means
that either argument may be a NAN.
The fourth argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-``op1`` and ``op2`` are compared according to the condition code given
+`op1` and `op2` are compared according to the condition code given
as the third argument. If the arguments are vectors, then the
vectors are compared element by element. Each comparison performed
-always yields an :ref:`i1 <t_integer>` result, as follows:
-
-.. _fcmp_md_cc_sem:
-
-- "``oeq``": yields ``true`` if both arguments are not a NAN and ``op1``
- is equal to ``op2``.
-- "``ogt``": yields ``true`` if both arguments are not a NAN and ``op1``
- is greater than ``op2``.
-- "``oge``": yields ``true`` if both arguments are not a NAN and ``op1``
- is greater than or equal to ``op2``.
-- "``olt``": yields ``true`` if both arguments are not a NAN and ``op1``
- is less than ``op2``.
-- "``ole``": yields ``true`` if both arguments are not a NAN and ``op1``
- is less than or equal to ``op2``.
-- "``one``": yields ``true`` if both arguments are not a NAN and ``op1``
- is not equal to ``op2``.
-- "``ord``": yields ``true`` if both arguments are not a NAN.
-- "``ueq``": yields ``true`` if either argument is a NAN or ``op1`` is
- equal to ``op2``.
-- "``ugt``": yields ``true`` if either argument is a NAN or ``op1`` is
- greater than ``op2``.
-- "``uge``": yields ``true`` if either argument is a NAN or ``op1`` is
- greater than or equal to ``op2``.
-- "``ult``": yields ``true`` if either argument is a NAN or ``op1`` is
- less than ``op2``.
-- "``ule``": yields ``true`` if either argument is a NAN or ``op1`` is
- less than or equal to ``op2``.
-- "``une``": yields ``true`` if either argument is a NAN or ``op1`` is
- not equal to ``op2``.
-- "``uno``": yields ``true`` if either argument is a NAN.
+always yields an {ref}`i1 <t_integer>` result, as follows:
+
+(fcmp_md_cc_sem)=
+
+- "`oeq`": yields `true` if both arguments are not a NAN and `op1`
+ is equal to `op2`.
+- "`ogt`": yields `true` if both arguments are not a NAN and `op1`
+ is greater than `op2`.
+- "`oge`": yields `true` if both arguments are not a NAN and `op1`
+ is greater than or equal to `op2`.
+- "`olt`": yields `true` if both arguments are not a NAN and `op1`
+ is less than `op2`.
+- "`ole`": yields `true` if both arguments are not a NAN and `op1`
+ is less than or equal to `op2`.
+- "`one`": yields `true` if both arguments are not a NAN and `op1`
+ is not equal to `op2`.
+- "`ord`": yields `true` if both arguments are not a NAN.
+- "`ueq`": yields `true` if either argument is a NAN or `op1` is
+ equal to `op2`.
+- "`ugt`": yields `true` if either argument is a NAN or `op1` is
+ greater than `op2`.
+- "`uge`": yields `true` if either argument is a NAN or `op1` is
+ greater than or equal to `op2`.
+- "`ult`": yields `true` if either argument is a NAN or `op1` is
+ less than `op2`.
+- "`ule`": yields `true` if either argument is a NAN or `op1` is
+ less than or equal to `op2`.
+- "`une`": yields `true` if either argument is a NAN or `op1` is
+ not equal to `op2`.
+- "`uno`": yields `true` if either argument is a NAN.
The quiet comparison operation performed by
-'``llvm.experimental.constrained.fcmp``' will only raise an exception
+'`llvm.experimental.constrained.fcmp`' will only raise an exception
if either argument is a SNAN. The signaling comparison operation
-performed by '``llvm.experimental.constrained.fcmps``' will raise an
+performed by '`llvm.experimental.constrained.fcmps`' will raise an
exception if either argument is a NAN (QNAN or SNAN). Such an exception
does not preclude a result being produced (e.g., exception might only
set a flag), therefore the distinction between ordered and unordered
comparisons is also relevant for the
-'``llvm.experimental.constrained.fcmps``' intrinsic.
+'`llvm.experimental.constrained.fcmps`' intrinsic.
-'``llvm.experimental.constrained.fmuladd``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.fmuladd`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.fmuladd(<type> <op1>, <type> <op2>,
- <type> <op3>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.fmuladd(<type> <op1>, <type> <op2>,
+ <type> <op3>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.fmuladd``' intrinsic represents
+The '`llvm.experimental.constrained.fmuladd`' intrinsic represents
multiply-add expressions that can be fused if the code generator determines
that (a) the target instruction set has support for a fused operation,
and (b) that the fused operation is more efficient than the equivalent,
separate pair of mul and add instructions.
-Arguments:
-""""""""""
+##### Arguments:
-The first three arguments to the '``llvm.experimental.constrained.fmuladd``'
+The first three arguments to the '`llvm.experimental.constrained.fmuladd`'
intrinsic must be floating-point or vector of floating-point values.
All three arguments must have identical types.
The fourth and fifth arguments specify the rounding mode and exception behavior
as described above.
-Semantics:
-""""""""""
+##### Semantics:
The expression:
-::
-
- %0 = call float @llvm.experimental.constrained.fmuladd.f32(%a, %b, %c,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+%0 = call float @llvm.experimental.constrained.fmuladd.f32(%a, %b, %c,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
is equivalent to the expression:
-::
-
- %0 = call float @llvm.experimental.constrained.fmul.f32(%a, %b,
- metadata <rounding mode>,
- metadata <exception behavior>)
- %1 = call float @llvm.experimental.constrained.fadd.f32(%0, %c,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+%0 = call float @llvm.experimental.constrained.fmul.f32(%a, %b,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+%1 = call float @llvm.experimental.constrained.fadd.f32(%0, %c,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
except that it is unspecified whether rounding will be performed between the
multiplication and addition steps. Fusion is not guaranteed, even if the target
platform supports it.
If a fused multiply-add is required, the corresponding
-:ref:`llvm.experimental.constrained.fma <int_fma>` intrinsic function should be
+{ref}`llvm.experimental.constrained.fma <int_fma>` intrinsic function should be
used instead.
-This never sets errno, just as '``llvm.experimental.constrained.fma.*``'.
+This never sets errno, just as '`llvm.experimental.constrained.fma.*`'.
-Constrained libm-equivalent Intrinsics
---------------------------------------
+### Constrained libm-equivalent Intrinsics
In addition to the basic floating-point operations for which constrained
intrinsics are described above, there are constrained versions of various
@@ -29406,28 +27083,24 @@ and exception behavior arguments only control the behavior of the optimizer.
They do not change the runtime floating-point environment.
-'``llvm.experimental.constrained.sqrt``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.sqrt`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.sqrt(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.sqrt(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.sqrt``' intrinsic returns the square root
-of the specified value, returning the same value as the libm '``sqrt``'
-functions would, but without setting ``errno``.
+The '`llvm.experimental.constrained.sqrt`' intrinsic returns the square root
+of the specified value, returning the same value as the libm '`sqrt`'
+functions would, but without setting `errno`.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29435,35 +27108,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the nonnegative square root of the specified value.
If the value is less than negative zero, a floating-point exception occurs
and the return value is architecture specific.
-'``llvm.experimental.constrained.pow``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.pow`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.pow(<type> <op1>, <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.pow(<type> <op1>, <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.pow``' intrinsic returns the first argument
+The '`llvm.experimental.constrained.pow`' intrinsic returns the first argument
raised to the (positive or negative) power specified by the second argument.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers of the
same type. The second argument specifies the power to which the first argument
@@ -29472,38 +27140,33 @@ should be raised.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the first value raised to the second power,
-returning the same values as the libm ``pow`` functions would, and
+returning the same values as the libm `pow` functions would, and
handles error conditions in the same way.
-'``llvm.experimental.constrained.powi``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.powi`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.powi(<type> <op1>, i32 <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.powi(<type> <op1>, i32 <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.powi``' intrinsic returns the first argument
+The '`llvm.experimental.constrained.powi`' intrinsic returns the first argument
raised to the (positive or negative) power specified by the second argument. The
order of evaluation of multiplications is not defined. When a vector of
floating-point type is used, the second argument remains a scalar integer value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type. The second argument is a 32-bit signed integer specifying the power to
@@ -29512,37 +27175,31 @@ which the first argument should be raised.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the first value raised to the second power with an
unspecified sequence of rounding operations.
-'``llvm.experimental.constrained.ldexp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.ldexp`' Intrinsic
-::
+##### Syntax:
- declare <type0>
- @llvm.experimental.constrained.ldexp(<type0> <op1>, <type1> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type0>
+ at llvm.experimental.constrained.ldexp(<type0> <op1>, <type1> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.ldexp``' performs the ldexp function.
+The '`llvm.experimental.constrained.ldexp`' performs the ldexp function.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument and the return value are :ref:`floating-point
-<t_floating>` or :ref:`vector <t_vector>` of floating-point values of
+The first argument and the return value are {ref}`floating-point <t_floating>` or {ref}`vector <t_vector>` of floating-point values of
the same type. The second argument is an integer with the same number
of elements.
@@ -29550,8 +27207,7 @@ of elements.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function multiplies the first argument by 2 raised to the second
argument's power. If the first argument is NaN or infinite, the same
@@ -29560,27 +27216,23 @@ is returned. If the result overflows, the result is an infinity with
the same sign.
-'``llvm.experimental.constrained.sin``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.sin`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.sin(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.sin(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.sin``' intrinsic returns the sine of the
+The '`llvm.experimental.constrained.sin`' intrinsic returns the sine of the
first argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29588,35 +27240,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the sine of the specified argument, returning the
-same values as the libm ``sin`` functions would, and handles error
+same values as the libm `sin` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.cos``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.cos`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.cos(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.cos(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.cos``' intrinsic returns the cosine of the
+The '`llvm.experimental.constrained.cos`' intrinsic returns the cosine of the
first argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29624,35 +27271,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the cosine of the specified argument, returning the
-same values as the libm ``cos`` functions would, and handles error
+same values as the libm `cos` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.tan``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.tan`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.tan(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.tan(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.tan``' intrinsic returns the tangent of the
+The '`llvm.experimental.constrained.tan`' intrinsic returns the tangent of the
first argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29660,34 +27302,29 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the tangent of the specified argument, returning the
-same values as the libm ``tan`` functions would, and handles error
+same values as the libm `tan` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.asin``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.asin`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.asin(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.asin(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.asin``' intrinsic returns the arcsine of the
+The '`llvm.experimental.constrained.asin`' intrinsic returns the arcsine of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29695,35 +27332,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the arcsine of the specified operand, returning the
-same values as the libm ``asin`` functions would, and handles error
+same values as the libm `asin` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.acos``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.acos`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.acos(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.acos(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.acos``' intrinsic returns the arccosine of the
+The '`llvm.experimental.constrained.acos`' intrinsic returns the arccosine of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29731,35 +27363,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the arccosine of the specified operand, returning the
-same values as the libm ``acos`` functions would, and handles error
+same values as the libm `acos` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.atan``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.atan`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.atan(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.atan(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.atan``' intrinsic returns the arctangent of the
+The '`llvm.experimental.constrained.atan`' intrinsic returns the arctangent of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29767,35 +27394,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the arctangent of the specified operand, returning the
-same values as the libm ``atan`` functions would, and handles error
+same values as the libm `atan` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.atan2``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.atan2`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.atan2(<type> <op1>,
- <type> <op2>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.atan2(<type> <op1>,
+ <type> <op2>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.atan2``' intrinsic returns the arctangent
-of ``<op1>`` divided by ``<op2>`` accounting for the quadrant.
+The '`llvm.experimental.constrained.atan2`' intrinsic returns the arctangent
+of `<op1>` divided by `<op2>` accounting for the quadrant.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers of the
same type.
@@ -29803,34 +27425,29 @@ same type.
The third and fourth arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the quadrant-specific arctangent using the specified
-operands, returning the same values as the libm ``atan2`` functions would, and
+operands, returning the same values as the libm `atan2` functions would, and
handles error conditions in the same way.
-'``llvm.experimental.constrained.sinh``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.sinh`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.sinh(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.sinh(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.sinh``' intrinsic returns the hyperbolic sine of the
+The '`llvm.experimental.constrained.sinh`' intrinsic returns the hyperbolic sine of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29838,35 +27455,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the hyperbolic sine of the specified operand, returning the
-same values as the libm ``sinh`` functions would, and handles error
+same values as the libm `sinh` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.cosh``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.cosh`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.cosh(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.cosh(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.cosh``' intrinsic returns the hyperbolic cosine of the
+The '`llvm.experimental.constrained.cosh`' intrinsic returns the hyperbolic cosine of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29874,35 +27486,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the hyperbolic cosine of the specified operand, returning the
-same values as the libm ``cosh`` functions would, and handles error
+same values as the libm `cosh` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.tanh``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.tanh`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.tanh(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.tanh(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.tanh``' intrinsic returns the hyperbolic tangent of the
+The '`llvm.experimental.constrained.tanh`' intrinsic returns the hyperbolic tangent of the
first operand.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return type are floating-point numbers of the same
type.
@@ -29910,34 +27517,29 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function returns the hyperbolic tangent of the specified operand, returning the
-same values as the libm ``tanh`` functions would, and handles error
+same values as the libm `tanh` functions would, and handles error
conditions in the same way.
-'``llvm.experimental.constrained.exp``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.exp`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.exp(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.exp(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.exp``' intrinsic computes the base-e
+The '`llvm.experimental.constrained.exp`' intrinsic computes the base-e
exponential of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -29945,35 +27547,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``exp`` functions
+This function returns the same values as the libm `exp` functions
would, and handles error conditions in the same way.
-'``llvm.experimental.constrained.exp2``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.exp2`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.exp2(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.exp2(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.exp2``' intrinsic computes the base-2
+The '`llvm.experimental.constrained.exp2`' intrinsic computes the base-2
exponential of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -29981,34 +27578,29 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``exp2`` functions
+This function returns the same values as the libm `exp2` functions
would, and handles error conditions in the same way.
-'``llvm.experimental.constrained.log``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.log`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.log(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.log(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.log``' intrinsic computes the base-e
+The '`llvm.experimental.constrained.log`' intrinsic computes the base-e
logarithm of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -30017,34 +27609,29 @@ The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``log`` functions
+This function returns the same values as the libm `log` functions
would, and handles error conditions in the same way.
-'``llvm.experimental.constrained.log10``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.log10`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.log10(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.log10(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.log10``' intrinsic computes the base-10
+The '`llvm.experimental.constrained.log10`' intrinsic computes the base-10
logarithm of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -30052,34 +27639,29 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``log10`` functions
+This function returns the same values as the libm `log10` functions
would, and handles error conditions in the same way.
-'``llvm.experimental.constrained.log2``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.log2`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.log2(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.log2(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.log2``' intrinsic computes the base-2
+The '`llvm.experimental.constrained.log2`' intrinsic computes the base-2
logarithm of the specified value.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -30087,35 +27669,30 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``log2`` functions
+This function returns the same values as the libm `log2` functions
would, and handles error conditions in the same way.
-'``llvm.experimental.constrained.rint``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.rint`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.rint(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.rint(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.rint``' intrinsic returns the first
+The '`llvm.experimental.constrained.rint`' intrinsic returns the first
argument rounded to the nearest integer. It may raise an inexact floating-point
exception if the argument is not an integer.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -30123,53 +27700,47 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``rint`` functions
+This function returns the same values as the libm `rint` functions
would, and handles error conditions in the same way. The rounding mode is
described, not determined, by the rounding mode argument. The actual rounding
mode is determined by the runtime floating-point environment. The rounding
mode argument is only intended as information to the compiler.
-'``llvm.experimental.constrained.lrint``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.lrint`' Intrinsic
-::
+##### Syntax:
- declare <inttype>
- @llvm.experimental.constrained.lrint(<fptype> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <inttype>
+ at llvm.experimental.constrained.lrint(<fptype> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.lrint``' intrinsic returns the first
+The '`llvm.experimental.constrained.lrint`' intrinsic returns the first
argument rounded to the nearest integer. An inexact floating-point exception
will be raised if the argument is not an integer. If the rounded value is too
large to fit into the result type, an invalid exception is raised, and the
return value is a non-deterministic value (equivalent to `freeze poison`).
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point number. The return value is an
integer type. Not all types are supported on all targets. The supported
-types are the same as the ``llvm.lrint`` intrinsic and the ``lrint``
+types are the same as the `llvm.lrint` intrinsic and the `lrint`
libm functions.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``lrint`` functions
+This function returns the same values as the libm `lrint` functions
would, and handles error conditions in the same way.
The rounding mode is described, not determined, by the rounding mode
@@ -30178,46 +27749,41 @@ environment. The rounding mode argument is only intended as information
to the compiler.
If the runtime floating-point environment is using the default rounding mode
-then the results will be the same as the ``llvm.lrint`` intrinsic.
+then the results will be the same as the `llvm.lrint` intrinsic.
-'``llvm.experimental.constrained.llrint``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.llrint`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <inttype>
- @llvm.experimental.constrained.llrint(<fptype> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <inttype>
+ at llvm.experimental.constrained.llrint(<fptype> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.llrint``' intrinsic returns the first
+The '`llvm.experimental.constrained.llrint`' intrinsic returns the first
argument rounded to the nearest integer. An inexact floating-point exception
will be raised if the argument is not an integer. If the rounded value is too
large to fit into the result type, an invalid exception is raised, and the
return value is a non-deterministic value (equivalent to `freeze poison`).
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point number. The return value is an
integer type. Not all types are supported on all targets. The supported
-types are the same as the ``llvm.llrint`` intrinsic and the ``llrint``
+types are the same as the `llvm.llrint` intrinsic and the `llrint`
libm functions.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``llrint`` functions
+This function returns the same values as the libm `llrint` functions
would, and handles error conditions in the same way.
The rounding mode is described, not determined, by the rounding mode
@@ -30226,32 +27792,28 @@ environment. The rounding mode argument is only intended as information
to the compiler.
If the runtime floating-point environment is using the default rounding mode
-then the results will be the same as the ``llvm.llrint`` intrinsic.
+then the results will be the same as the `llvm.llrint` intrinsic.
-'``llvm.experimental.constrained.nearbyint``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.nearbyint`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.nearbyint(<type> <op1>,
- metadata <rounding mode>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.nearbyint(<type> <op1>,
+ metadata <rounding mode>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.nearbyint``' intrinsic returns the first
+The '`llvm.experimental.constrained.nearbyint`' intrinsic returns the first
argument rounded to the nearest integer. It will not raise an inexact
floating-point exception if the argument is not an integer.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
@@ -30259,423 +27821,362 @@ type.
The second and third arguments specify the rounding mode and exception
behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``nearbyint`` functions
+This function returns the same values as the libm `nearbyint` functions
would, and handles error conditions in the same way. The rounding mode is
described, not determined, by the rounding mode argument. The actual rounding
mode is determined by the runtime floating-point environment. The rounding
mode argument is only intended as information to the compiler.
-'``llvm.experimental.constrained.maxnum``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.maxnum`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.maxnum(<type> <op1>, <type> <op2>
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.maxnum(<type> <op1>, <type> <op2>
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.maxnum``' intrinsic returns the maximum
+The '`llvm.experimental.constrained.maxnum`' intrinsic returns the maximum
of the two arguments.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers
of the same type.
The third argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function follows the IEEE 754-2008 semantics for maxNum.
-'``llvm.experimental.constrained.minnum``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.minnum`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.minnum(<type> <op1>, <type> <op2>
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.minnum(<type> <op1>, <type> <op2>
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.minnum``' intrinsic returns the minimum
+The '`llvm.experimental.constrained.minnum`' intrinsic returns the minimum
of the two arguments.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers
of the same type.
The third argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function follows the IEEE 754-2008 semantics for minNum.
-'``llvm.experimental.constrained.maximum``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.maximum`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.maximum(<type> <op1>, <type> <op2>
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.maximum(<type> <op1>, <type> <op2>
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.maximum``' intrinsic returns the maximum
+The '`llvm.experimental.constrained.maximum`' intrinsic returns the maximum
of the two arguments, propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers
of the same type.
The third argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function follows semantics specified in the draft of IEEE 754-2019.
-'``llvm.experimental.constrained.minimum``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.minimum`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.minimum(<type> <op1>, <type> <op2>
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.minimum(<type> <op1>, <type> <op2>
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.minimum``' intrinsic returns the minimum
+The '`llvm.experimental.constrained.minimum`' intrinsic returns the minimum
of the two arguments, propagating NaNs and treating -0.0 as less than +0.0.
-Arguments:
-""""""""""
+##### Arguments:
The first two arguments and the return value are floating-point numbers
of the same type.
The third argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
This function follows semantics specified in the draft of IEEE 754-2019.
-'``llvm.experimental.constrained.ceil``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.ceil`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.ceil(<type> <op1>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.ceil(<type> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.ceil``' intrinsic returns the ceiling of the
+The '`llvm.experimental.constrained.ceil`' intrinsic returns the ceiling of the
first argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``ceil`` functions
+This function returns the same values as the libm `ceil` functions
would and handles error conditions in the same way.
-'``llvm.experimental.constrained.floor``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.floor`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.floor(<type> <op1>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.floor(<type> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.floor``' intrinsic returns the floor of the
+The '`llvm.experimental.constrained.floor`' intrinsic returns the floor of the
first argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``floor`` functions
+This function returns the same values as the libm `floor` functions
would and handles error conditions in the same way.
-'``llvm.experimental.constrained.round``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.round`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.round(<type> <op1>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.round(<type> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.round``' intrinsic returns the first
+The '`llvm.experimental.constrained.round`' intrinsic returns the first
argument rounded to the nearest integer.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``round`` functions
+This function returns the same values as the libm `round` functions
would and handles error conditions in the same way.
-'``llvm.experimental.constrained.roundeven``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.experimental.constrained.roundeven`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.roundeven(<type> <op1>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.roundeven(<type> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.roundeven``' intrinsic returns the first
+The '`llvm.experimental.constrained.roundeven`' intrinsic returns the first
argument rounded to the nearest integer in floating-point format, rounding
halfway cases to even (that is, to the nearest value that is an even integer),
regardless of the current rounding direction.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function implements IEEE 754 operation ``roundToIntegralTiesToEven``. It
-also behaves in the same way as C standard function ``roundeven`` and can signal
+This function implements IEEE 754 operation `roundToIntegralTiesToEven`. It
+also behaves in the same way as C standard function `roundeven` and can signal
the invalid operation exception for a SNAN argument.
-'``llvm.experimental.constrained.lround``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.lround`' Intrinsic
-::
+##### Syntax:
- declare <inttype>
- @llvm.experimental.constrained.lround(<fptype> <op1>,
- metadata <exception behavior>)
+```
+declare <inttype>
+ at llvm.experimental.constrained.lround(<fptype> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.lround``' intrinsic returns the first
+The '`llvm.experimental.constrained.lround`' intrinsic returns the first
argument rounded to the nearest integer with ties away from zero. It will
raise an inexact floating-point exception if the argument is not an integer.
If the rounded value is too large to fit into the result type, an invalid
exception is raised, and the return value is a non-deterministic value
(equivalent to `freeze poison`).
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point number. The return value is an
integer type. Not all types are supported on all targets. The supported
-types are the same as the ``llvm.lround`` intrinsic and the ``lround``
+types are the same as the `llvm.lround` intrinsic and the `lround`
libm functions.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``lround`` functions
+This function returns the same values as the libm `lround` functions
would and handles error conditions in the same way.
-'``llvm.experimental.constrained.llround``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.llround`' Intrinsic
-::
+##### Syntax:
- declare <inttype>
- @llvm.experimental.constrained.llround(<fptype> <op1>,
- metadata <exception behavior>)
+```
+declare <inttype>
+ at llvm.experimental.constrained.llround(<fptype> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.llround``' intrinsic returns the first
+The '`llvm.experimental.constrained.llround`' intrinsic returns the first
argument rounded to the nearest integer with ties away from zero. It will
raise an inexact floating-point exception if the argument is not an integer.
If the rounded value is too large to fit into the result type, an invalid
exception is raised, and the return value is a non-deterministic value
(equivalent to `freeze poison`).
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a floating-point number. The return value is an
integer type. Not all types are supported on all targets. The supported
-types are the same as the ``llvm.llround`` intrinsic and the ``llround``
+types are the same as the `llvm.llround` intrinsic and the `llround`
libm functions.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``llround`` functions
+This function returns the same values as the libm `llround` functions
would and handles error conditions in the same way.
-'``llvm.experimental.constrained.trunc``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.constrained.trunc`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.experimental.constrained.trunc(<type> <op1>,
- metadata <exception behavior>)
+```
+declare <type>
+ at llvm.experimental.constrained.trunc(<type> <op1>,
+ metadata <exception behavior>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.experimental.constrained.trunc``' intrinsic returns the first
+The '`llvm.experimental.constrained.trunc`' intrinsic returns the first
argument rounded to the nearest integer not larger in magnitude than the
argument.
-Arguments:
-""""""""""
+##### Arguments:
The first argument and the return value are floating-point numbers of the same
type.
The second argument specifies the exception behavior as described above.
-Semantics:
-""""""""""
+##### Semantics:
-This function returns the same values as the libm ``trunc`` functions
+This function returns the same values as the libm `trunc` functions
would and handles error conditions in the same way.
-.. _int_experimental_noalias_scope_decl:
-
-'``llvm.experimental.noalias.scope.decl``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_experimental_noalias_scope_decl)=
-Syntax:
-"""""""
+#### '`llvm.experimental.noalias.scope.decl`' Intrinsic
+##### Syntax:
-::
- declare void @llvm.experimental.noalias.scope.decl(metadata !id.scope.list)
+```
+declare void @llvm.experimental.noalias.scope.decl(metadata !id.scope.list)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.experimental.noalias.scope.decl`` intrinsic identifies where a
+The `llvm.experimental.noalias.scope.decl` intrinsic identifies where a
noalias scope is declared. When the intrinsic is duplicated, a decision must
also be made about the scope: depending on the reason of the duplication,
the scope might need to be duplicated as well.
-Arguments:
-""""""""""
+##### Arguments:
-The ``!id.scope.list`` argument is metadata that is a list of ``noalias``
-metadata references. The format is identical to that required for ``noalias``
+The `!id.scope.list` argument is metadata that is a list of `noalias`
+metadata references. The format is identical to that required for `noalias`
metadata. This list must have exactly one element.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.experimental.noalias.scope.decl`` intrinsic identifies where a
+The `llvm.experimental.noalias.scope.decl` intrinsic identifies where a
noalias scope is declared. When the intrinsic is duplicated, a decision must
also be made about the scope: depending on the reason of the duplication,
the scope might need to be duplicated as well.
@@ -30685,34 +28186,34 @@ unrolled, the associated noalias scope must also be duplicated. Otherwise, the
noalias property it signifies would spill across loop iterations, whereas it
was only valid within a single iteration.
-.. code-block:: llvm
-
- ; This example shows two possible positions for noalias.decl and how they impact the semantics:
- ; If it is outside the loop (Version 1), then %a and %b are noalias across *all* iterations.
- ; If it is inside the loop (Version 2), then %a and %b are noalias only within *one* iteration.
- declare void @decl_in_loop(ptr %a.base, ptr %b.base) {
- entry:
- ; call void @llvm.experimental.noalias.scope.decl(metadata !2) ; Version 1: noalias decl outside loop
- br label %loop
-
- loop:
- %a = phi ptr [ %a.base, %entry ], [ %a.inc, %loop ]
- %b = phi ptr [ %b.base, %entry ], [ %b.inc, %loop ]
- ; call void @llvm.experimental.noalias.scope.decl(metadata !2) ; Version 2: noalias decl inside loop
- %val = load i8, ptr %a, !alias.scope !2
- store i8 %val, ptr %b, !noalias !2
- %a.inc = getelementptr inbounds i8, ptr %a, i64 1
- %b.inc = getelementptr inbounds i8, ptr %b, i64 1
- %cond = call i1 @cond()
- br i1 %cond, label %loop, label %exit
-
- exit:
- ret void
- }
-
- !0 = !{!0} ; domain
- !1 = !{!1, !0} ; scope
- !2 = !{!1} ; scope list
+```llvm
+; This example shows two possible positions for noalias.decl and how they impact the semantics:
+; If it is outside the loop (Version 1), then %a and %b are noalias across *all* iterations.
+; If it is inside the loop (Version 2), then %a and %b are noalias only within *one* iteration.
+declare void @decl_in_loop(ptr %a.base, ptr %b.base) {
+entry:
+ ; call void @llvm.experimental.noalias.scope.decl(metadata !2) ; Version 1: noalias decl outside loop
+ br label %loop
+
+loop:
+ %a = phi ptr [ %a.base, %entry ], [ %a.inc, %loop ]
+ %b = phi ptr [ %b.base, %entry ], [ %b.inc, %loop ]
+ ; call void @llvm.experimental.noalias.scope.decl(metadata !2) ; Version 2: noalias decl inside loop
+ %val = load i8, ptr %a, !alias.scope !2
+ store i8 %val, ptr %b, !noalias !2
+ %a.inc = getelementptr inbounds i8, ptr %a, i64 1
+ %b.inc = getelementptr inbounds i8, ptr %b, i64 1
+ %cond = call i1 @cond()
+ br i1 %cond, label %loop, label %exit
+
+exit:
+ ret void
+}
+
+!0 = !{!0} ; domain
+!1 = !{!1, !0} ; scope
+!2 = !{!1} ; scope list
+```
Multiple calls to `@llvm.experimental.noalias.scope.decl` for the same scope
are possible, but one should never dominate another. Violations are pointed out
@@ -30720,404 +28221,352 @@ by the verifier as they indicate a problem in either a transformation pass or
the input.
-Floating Point Environment Manipulation intrinsics
---------------------------------------------------
+### Floating Point Environment Manipulation intrinsics
These functions read or write floating point environment, such as rounding
mode or state of floating point exceptions. Altering the floating point
-environment requires special care. See :ref:`Floating Point Environment <floatenv>`.
+environment requires special care. See {ref}`Floating Point Environment <floatenv>`.
-.. _int_get_rounding:
+(int_get_rounding)=
-'``llvm.get.rounding``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.get.rounding`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.get.rounding()
+```
+declare i32 @llvm.get.rounding()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.get.rounding``' intrinsic reads the current rounding mode.
+The '`llvm.get.rounding`' intrinsic reads the current rounding mode.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.get.rounding``' intrinsic returns the current rounding mode.
-Encoding of the returned values is same as the result of ``FLT_ROUNDS``,
+The '`llvm.get.rounding`' intrinsic returns the current rounding mode.
+Encoding of the returned values is same as the result of `FLT_ROUNDS`,
specified by C standard:
-::
-
- 0 - toward zero
- 1 - to nearest, ties to even
- 2 - toward positive infinity
- 3 - toward negative infinity
- 4 - to nearest, ties away from zero
+```
+0 - toward zero
+1 - to nearest, ties to even
+2 - toward positive infinity
+3 - toward negative infinity
+4 - to nearest, ties away from zero
+```
Other values may be used to represent additional rounding modes, supported by a
target. These values are target-specific.
-.. _int_set_rounding:
-
-'``llvm.set.rounding``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_set_rounding)=
-Syntax:
-"""""""
+#### '`llvm.set.rounding`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.set.rounding(i32 <val>)
+```
+declare void @llvm.set.rounding(i32 <val>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.set.rounding``' intrinsic sets current rounding mode.
+The '`llvm.set.rounding`' intrinsic sets current rounding mode.
-Arguments:
-""""""""""
+##### Arguments:
The argument is the required rounding mode. Encoding of rounding mode is
-the same as used by '``llvm.get.rounding``'.
+the same as used by '`llvm.get.rounding`'.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.set.rounding``' intrinsic sets the current rounding mode. It is
+The '`llvm.set.rounding`' intrinsic sets the current rounding mode. It is
similar to C library function 'fesetround', however this intrinsic does not
return any value and uses platform-independent representation of IEEE rounding
modes.
-.. _int_get_fpenv:
-
-'``llvm.get.fpenv``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_get_fpenv)=
-Syntax:
-"""""""
+#### '`llvm.get.fpenv`' Intrinsic
-::
+##### Syntax:
- declare <integer_type> @llvm.get.fpenv()
+```
+declare <integer_type> @llvm.get.fpenv()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.get.fpenv``' intrinsic returns bits of the current floating-point
+The '`llvm.get.fpenv`' intrinsic returns bits of the current floating-point
environment. The return value type is platform-specific.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.get.fpenv``' intrinsic reads the current floating-point environment
+The '`llvm.get.fpenv`' intrinsic reads the current floating-point environment
and returns it as an integer value.
-.. _int_set_fpenv:
-
-'``llvm.set.fpenv``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_set_fpenv)=
-Syntax:
-"""""""
+#### '`llvm.set.fpenv`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.set.fpenv(<integer_type> <val>)
+```
+declare void @llvm.set.fpenv(<integer_type> <val>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.set.fpenv``' intrinsic sets the current floating-point environment.
+The '`llvm.set.fpenv`' intrinsic sets the current floating-point environment.
-Arguments:
-""""""""""
+##### Arguments:
The argument is an integer representing the new floating-point environment. The
integer type is platform-specific.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.set.fpenv``' intrinsic sets the current floating-point environment
+The '`llvm.set.fpenv`' intrinsic sets the current floating-point environment
to the state specified by the argument. The state may be previously obtained by a
-call to '``llvm.get.fpenv``' or synthesized in a platform-dependent way.
-
+call to '`llvm.get.fpenv`' or synthesized in a platform-dependent way.
-'``llvm.reset.fpenv``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Syntax:
-"""""""
+#### '`llvm.reset.fpenv`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.reset.fpenv()
+```
+declare void @llvm.reset.fpenv()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.reset.fpenv``' intrinsic sets the default floating-point environment.
+The '`llvm.reset.fpenv`' intrinsic sets the default floating-point environment.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.reset.fpenv``' intrinsic sets the current floating-point environment
+The '`llvm.reset.fpenv`' intrinsic sets the current floating-point environment
to default state. It is similar to the call 'fesetenv(FE_DFL_ENV)', except it
does not return any value.
-.. _int_get_fpmode:
+(int_get_fpmode)=
-'``llvm.get.fpmode``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.get.fpmode`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-The '``llvm.get.fpmode``' intrinsic returns bits of the current floating-point
+The '`llvm.get.fpmode`' intrinsic returns bits of the current floating-point
control modes. The return value type is platform-specific.
-::
+```
+declare <integer_type> @llvm.get.fpmode()
+```
- declare <integer_type> @llvm.get.fpmode()
+##### Overview:
-Overview:
-"""""""""
-
-The '``llvm.get.fpmode``' intrinsic reads the current dynamic floating-point
+The '`llvm.get.fpmode`' intrinsic reads the current dynamic floating-point
control modes and returns it as an integer value.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.get.fpmode``' intrinsic reads the current dynamic floating-point
+The '`llvm.get.fpmode`' intrinsic reads the current dynamic floating-point
control modes, such as rounding direction, precision, treatment of denormals and
so on. It is similar to the C library function 'fegetmode', however this
function does not store the set of control modes into memory but returns it as
an integer value. Interpretation of the bits in this value is target-dependent.
-'``llvm.set.fpmode``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.set.fpmode`' Intrinsic
-The '``llvm.set.fpmode``' intrinsic sets the current floating-point control modes.
+##### Syntax:
-::
+The '`llvm.set.fpmode`' intrinsic sets the current floating-point control modes.
- declare void @llvm.set.fpmode(<integer_type> <val>)
+```
+declare void @llvm.set.fpmode(<integer_type> <val>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.set.fpmode``' intrinsic sets the current dynamic floating-point
+The '`llvm.set.fpmode`' intrinsic sets the current dynamic floating-point
control modes.
-Arguments:
-""""""""""
+##### Arguments:
The argument is a set of floating-point control modes, represented as an integer
value in a target-dependent way.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.set.fpmode``' intrinsic sets the current dynamic floating-point
+The '`llvm.set.fpmode`' intrinsic sets the current dynamic floating-point
control modes to the state specified by the argument, which must be obtained by
-a call to '``llvm.get.fpmode``' or constructed in a target-specific way. It is
+a call to '`llvm.get.fpmode`' or constructed in a target-specific way. It is
similar to the C library function 'fesetmode', however this function does not
read the set of control modes from memory but gets it as integer value.
-'``llvm.reset.fpmode``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.reset.fpmode`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.reset.fpmode()
+```
+declare void @llvm.reset.fpmode()
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.reset.fpmode``' intrinsic sets the default dynamic floating-point
+The '`llvm.reset.fpmode`' intrinsic sets the default dynamic floating-point
control modes.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.reset.fpmode``' intrinsic sets the current dynamic floating-point
+The '`llvm.reset.fpmode`' intrinsic sets the current dynamic floating-point
environment to default state. It is similar to the C library function call
'fesetmode(FE_DFL_MODE)', however this function does not return any value.
-Floating-Point Test Intrinsics
-------------------------------
+### Floating-Point Test Intrinsics
These functions get properties of floating-point values.
-.. _llvm.is.fpclass:
-
-'``llvm.is.fpclass``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(llvm.is.fpclass)=
-Syntax:
-"""""""
+#### '`llvm.is.fpclass`' Intrinsic
-::
+##### Syntax:
- declare i1 @llvm.is.fpclass(<fptype> <op>, i32 <test>)
- declare <N x i1> @llvm.is.fpclass(<vector-fptype> <op>, i32 <test>)
+```
+declare i1 @llvm.is.fpclass(<fptype> <op>, i32 <test>)
+declare <N x i1> @llvm.is.fpclass(<vector-fptype> <op>, i32 <test>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.is.fpclass``' intrinsic returns a boolean value or vector of boolean
+The '`llvm.is.fpclass`' intrinsic returns a boolean value or vector of boolean
values depending on whether the first argument satisfies the test specified by
the second argument.
If the first argument is a floating-point scalar, then the result type is a
-boolean (:ref:`i1 <t_integer>`).
+boolean ({ref}`i1 <t_integer>`).
If the first argument is a floating-point vector, then the result type is a
vector of boolean with the same number of elements as the first argument.
-Arguments:
-""""""""""
+##### Arguments:
-The first argument to the '``llvm.is.fpclass``' intrinsic must be
-:ref:`floating-point <t_floating>` or :ref:`vector <t_vector>`
+The first argument to the '`llvm.is.fpclass`' intrinsic must be
+{ref}`floating-point <t_floating>` or {ref}`vector <t_vector>`
of floating-point values.
The second argument specifies, which tests to perform. It must be a compile-time
integer constant, each bit in which specifies floating-point class:
-+-------+----------------------+
-| Bit # | floating-point class |
-+=======+======================+
-| 0 | Signaling NaN |
-+-------+----------------------+
-| 1 | Quiet NaN |
-+-------+----------------------+
-| 2 | Negative infinity |
-+-------+----------------------+
-| 3 | Negative normal |
-+-------+----------------------+
-| 4 | Negative subnormal |
-+-------+----------------------+
-| 5 | Negative zero |
-+-------+----------------------+
-| 6 | Positive zero |
-+-------+----------------------+
-| 7 | Positive subnormal |
-+-------+----------------------+
-| 8 | Positive normal |
-+-------+----------------------+
-| 9 | Positive infinity |
-+-------+----------------------+
-
-Semantics:
-""""""""""
-
-The function checks if ``op`` belongs to any of the floating-point classes
-specified by ``test``. If ``op`` is a vector, then the check is made element by
-element. Each check yields an :ref:`i1 <t_integer>` result, which is ``true``,
-if the element value satisfies the specified test. The argument ``test`` is a
+```{list-table}
+:header-rows: 1
+
+* - Bit #
+ - floating-point class
+* - 0
+ - Signaling NaN
+* - 1
+ - Quiet NaN
+* - 2
+ - Negative infinity
+* - 3
+ - Negative normal
+* - 4
+ - Negative subnormal
+* - 5
+ - Negative zero
+* - 6
+ - Positive zero
+* - 7
+ - Positive subnormal
+* - 8
+ - Positive normal
+* - 9
+ - Positive infinity
+```
+
+##### Semantics:
+
+The function checks if `op` belongs to any of the floating-point classes
+specified by `test`. If `op` is a vector, then the check is made element by
+element. Each check yields an {ref}`i1 <t_integer>` result, which is `true`,
+if the element value satisfies the specified test. The argument `test` is a
bit mask where each bit specifies floating-point class to test. For example, the
value 0x108 makes test for normal value, - bits 3 and 8 in it are set, which
-means that the function returns ``true`` if ``op`` is a positive or negative
+means that the function returns `true` if `op` is a positive or negative
normal value. The function never raises floating-point exceptions. The
function does not canonicalize its input value and does not depend
on the floating-point environment. If the floating-point environment
has a zeroing treatment of subnormal input values (such as indicated
-by the :ref:`denormal_fpenv <denormal_fpenv>` attribute), a subnormal
+by the {ref}`denormal_fpenv <denormal_fpenv>` attribute), a subnormal
value will be observed (will not be implicitly treated as zero).
-General Intrinsics
-------------------
+### General Intrinsics
This class of intrinsics is designed to be generic and has no specific
purpose.
-'``llvm.var.annotation``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.var.annotation`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.var.annotation(ptr <val>, ptr <str>, ptr <str>, i32 <int>)
+```
+declare void @llvm.var.annotation(ptr <val>, ptr <str>, ptr <str>, i32 <int>)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.var.annotation``' intrinsic.
+The '`llvm.var.annotation`' intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to a value, the second is a pointer to a
global string, the third is a pointer to a global string which is the
source file name, and the last argument is the line number.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic allows annotation of local variables with arbitrary
strings. This can be useful for special purpose optimizations that want
to look for these annotations. These have no other defined use; they are
ignored by code generation and optimization.
-'``llvm.ptr.annotation.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.ptr.annotation.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use '``llvm.ptr.annotation``' on a
+This is an overloaded intrinsic. You can use '`llvm.ptr.annotation`' on a
pointer to an integer of any width. *NOTE* you must specify an address space for
the pointer. The identifier for the default address space is the integer
-'``0``'.
+'`0`'.
-::
+```
+declare ptr @llvm.ptr.annotation.p0(ptr <val>, ptr <str>, ptr <str>, i32 <int>)
+declare ptr @llvm.ptr.annotation.p1(ptr addrspace(1) <val>, ptr <str>, ptr <str>, i32 <int>)
+```
- declare ptr @llvm.ptr.annotation.p0(ptr <val>, ptr <str>, ptr <str>, i32 <int>)
- declare ptr @llvm.ptr.annotation.p1(ptr addrspace(1) <val>, ptr <str>, ptr <str>, i32 <int>)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.ptr.annotation`' intrinsic.
-The '``llvm.ptr.annotation``' intrinsic.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to an integer value of arbitrary bitwidth
(result of some expression), the second is a pointer to a global string, the
third is a pointer to a global string which is the source file name, and the
last argument is the line number. It returns the value of the first argument.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic allows annotation of a pointer to an integer with arbitrary
strings. This can be useful for special purpose optimizations that want to look
@@ -31126,38 +28575,33 @@ annotations on a best-effort basis but are allowed to replace the intrinsic with
its first argument without breaking semantics and the intrinsic is completely
dropped during instruction selection.
-'``llvm.annotation.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.annotation.*`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use '``llvm.annotation``' on
+This is an overloaded intrinsic. You can use '`llvm.annotation`' on
any integer bit width.
-::
+```
+declare i8 @llvm.annotation.i8(i8 <val>, ptr <str>, ptr <str>, i32 <int>)
+declare i16 @llvm.annotation.i16(i16 <val>, ptr <str>, ptr <str>, i32 <int>)
+declare i32 @llvm.annotation.i32(i32 <val>, ptr <str>, ptr <str>, i32 <int>)
+declare i64 @llvm.annotation.i64(i64 <val>, ptr <str>, ptr <str>, i32 <int>)
+declare i256 @llvm.annotation.i256(i256 <val>, ptr <str>, ptr <str>, i32 <int>)
+```
- declare i8 @llvm.annotation.i8(i8 <val>, ptr <str>, ptr <str>, i32 <int>)
- declare i16 @llvm.annotation.i16(i16 <val>, ptr <str>, ptr <str>, i32 <int>)
- declare i32 @llvm.annotation.i32(i32 <val>, ptr <str>, ptr <str>, i32 <int>)
- declare i64 @llvm.annotation.i64(i64 <val>, ptr <str>, ptr <str>, i32 <int>)
- declare i256 @llvm.annotation.i256(i256 <val>, ptr <str>, ptr <str>, i32 <int>)
+##### Overview:
-Overview:
-"""""""""
+The '`llvm.annotation`' intrinsic.
-The '``llvm.annotation``' intrinsic.
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is an integer value (result of some expression), the
second is a pointer to a global string, the third is a pointer to a
global string which is the source file name, and the last argument is
the line number. It returns the value of the first argument.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic allows annotations to be put on arbitrary expressions with
arbitrary strings. This can be useful for special purpose optimizations that
@@ -31166,332 +28610,284 @@ transformations preserve annotations on a best-effort basis but are allowed to
replace the intrinsic with its first argument without breaking semantics and the
intrinsic is completely dropped during instruction selection.
-'``llvm.codeview.annotation``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.codeview.annotation`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This annotation emits a label at its program point and an associated
-``S_ANNOTATION`` codeview record with some additional string metadata. This is
-used to implement MSVC's ``__annotation`` intrinsic. It is marked
-``noduplicate``, so calls to this intrinsic prevent inlining and should be
+`S_ANNOTATION` codeview record with some additional string metadata. This is
+used to implement MSVC's `__annotation` intrinsic. It is marked
+`noduplicate`, so calls to this intrinsic prevent inlining and should be
considered expensive.
-::
+```
+declare void @llvm.codeview.annotation(metadata)
+```
- declare void @llvm.codeview.annotation(metadata)
-
-Arguments:
-""""""""""
+##### Arguments:
The argument should be an MDTuple containing any number of MDStrings.
-.. _llvm.trap:
-
-'``llvm.trap``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^
+(llvm.trap)=
-Syntax:
-"""""""
+#### '`llvm.trap`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.trap() cold noreturn nounwind
+```
+declare void @llvm.trap() cold noreturn nounwind
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.trap``' intrinsic.
+The '`llvm.trap`' intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is lowered to the target-dependent trap instruction. If
the target does not have a trap instruction, this intrinsic will be
-lowered to a call of the ``abort()`` function.
-
-.. _llvm.debugtrap:
+lowered to a call of the `abort()` function.
-'``llvm.debugtrap``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(llvm.debugtrap)=
-Syntax:
-"""""""
+#### '`llvm.debugtrap`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.debugtrap() nounwind
+```
+declare void @llvm.debugtrap() nounwind
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.debugtrap``' intrinsic.
+The '`llvm.debugtrap`' intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is lowered to code which is intended to cause an
execution trap with the intention of requesting the attention of a
debugger.
-.. _llvm.ubsantrap:
-
-'``llvm.ubsantrap``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(llvm.ubsantrap)=
-Syntax:
-"""""""
+#### '`llvm.ubsantrap`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.ubsantrap(i8 immarg) cold noreturn nounwind
+```
+declare void @llvm.ubsantrap(i8 immarg) cold noreturn nounwind
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.ubsantrap``' intrinsic.
+The '`llvm.ubsantrap`' intrinsic.
-Arguments:
-""""""""""
+##### Arguments:
An integer describing the kind of failure detected.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is lowered to code which is intended to cause an execution trap,
embedding the argument into encoding of that trap somehow to discriminate
crashes if possible.
-Equivalent to ``@llvm.trap`` for targets that do not support this behavior.
-
-'``llvm.stackprotector``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Equivalent to `@llvm.trap` for targets that do not support this behavior.
-Syntax:
-"""""""
+#### '`llvm.stackprotector`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.stackprotector(ptr <guard>, ptr <slot>)
+```
+declare void @llvm.stackprotector(ptr <guard>, ptr <slot>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.stackprotector`` intrinsic takes the ``guard`` and stores it
-onto the stack at ``slot``. The stack slot is adjusted to ensure that it
+The `llvm.stackprotector` intrinsic takes the `guard` and stores it
+onto the stack at `slot`. The stack slot is adjusted to ensure that it
is placed on the stack before local variables.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.stackprotector`` intrinsic requires two pointer arguments.
+The `llvm.stackprotector` intrinsic requires two pointer arguments.
The first argument is the value loaded from the stack guard
-``@__stack_chk_guard``. The second variable is an ``alloca`` that has
+`@__stack_chk_guard`. The second variable is an `alloca` that has
enough space to hold the value of the guard.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic causes the prologue/epilogue inserter to force the position of
-the ``AllocaInst`` stack slot to be before local variables on the stack. This is
+the `AllocaInst` stack slot to be before local variables on the stack. This is
to ensure that if a local variable on the stack is overwritten, it will destroy
the value of the guard. When the function exits, the guard on the stack is
-checked against the original guard by ``llvm.stackprotectorcheck``. If they are
-different, then ``llvm.stackprotectorcheck`` causes the program to abort by
-calling the ``__stack_chk_fail()`` function.
-
-'``llvm.stackguard``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+checked against the original guard by `llvm.stackprotectorcheck`. If they are
+different, then `llvm.stackprotectorcheck` causes the program to abort by
+calling the `__stack_chk_fail()` function.
-Syntax:
-"""""""
+#### '`llvm.stackguard`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.stackguard()
+```
+declare ptr @llvm.stackguard()
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.stackguard`` intrinsic returns the system stack guard value.
+The `llvm.stackguard` intrinsic returns the system stack guard value.
It should not be generated by frontends, since it is only for internal usage.
The reason why we create this intrinsic is that we still support IR form Stack
Protector in FastISel.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
On some platforms, the value returned by this intrinsic remains unchanged
between loads in the same thread. On other platforms, it returns the same
-global variable value, if any, e.g., ``@__stack_chk_guard``.
+global variable value, if any, e.g., `@__stack_chk_guard`.
Currently some platforms have IR-level customized stack guard loading (e.g.
-X86 Linux) that is not handled by ``llvm.stackguard()``, while they should be
+X86 Linux) that is not handled by `llvm.stackguard()`, while they should be
in the future.
-'``llvm.objectsize``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.objectsize`' Intrinsic
-::
+##### Syntax:
- declare i32 @llvm.objectsize.i32(ptr <object>, i1 <min>, i1 <nullunknown>, i1 <dynamic>)
- declare i64 @llvm.objectsize.i64(ptr <object>, i1 <min>, i1 <nullunknown>, i1 <dynamic>)
+```
+declare i32 @llvm.objectsize.i32(ptr <object>, i1 <min>, i1 <nullunknown>, i1 <dynamic>)
+declare i64 @llvm.objectsize.i64(ptr <object>, i1 <min>, i1 <nullunknown>, i1 <dynamic>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.objectsize`` intrinsic is designed to provide information to the
+The `llvm.objectsize` intrinsic is designed to provide information to the
optimizer to determine whether a) an operation (like memcpy) will overflow a
buffer that corresponds to an object, or b) that a runtime check for overflow
isn't necessary. An object in this context means an allocation of a specific
class, structure, array, or other object.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a
-pointer to or into the ``object``.
+The `llvm.objectsize` intrinsic takes four arguments. The first argument is a
+pointer to or into the `object`.
-The second argument determines whether ``llvm.objectsize`` returns the minimum
+The second argument determines whether `llvm.objectsize` returns the minimum
(if true) or maximum (if false) object size. The minimum size may be any size
smaller than or equal to the actual object size (including 0 if unknown). The
maximum size may be any size greater than or equal to the actual object size
(including -1 if unknown).
-The third argument controls how ``llvm.objectsize`` acts when ``null``
-in address space 0 is used as its pointer argument. If it's ``false``,
-``llvm.objectsize`` reports 0 bytes available when given ``null``. Otherwise, if
-the ``null`` is in a non-zero address space or if ``true`` is given for the
-third argument of ``llvm.objectsize``, we assume its size is unknown. The fourth
-argument to ``llvm.objectsize`` determines if the value should be evaluated at
+The third argument controls how `llvm.objectsize` acts when `null`
+in address space 0 is used as its pointer argument. If it's `false`,
+`llvm.objectsize` reports 0 bytes available when given `null`. Otherwise, if
+the `null` is in a non-zero address space or if `true` is given for the
+third argument of `llvm.objectsize`, we assume its size is unknown. The fourth
+argument to `llvm.objectsize` determines if the value should be evaluated at
runtime.
The second, third, and fourth arguments only accept constants.
-Semantics:
-""""""""""
+##### Semantics:
-The ``llvm.objectsize`` intrinsic is lowered to a value representing the size of
-the object concerned. If the size cannot be determined, ``llvm.objectsize``
-returns ``i32/i64 -1 or 0`` (depending on the ``min`` argument).
+The `llvm.objectsize` intrinsic is lowered to a value representing the size of
+the object concerned. If the size cannot be determined, `llvm.objectsize`
+returns `i32/i64 -1 or 0` (depending on the `min` argument).
-'``llvm.expect``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.expect`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.expect`` on any
+This is an overloaded intrinsic. You can use `llvm.expect` on any
integer bit width.
-::
+```
+declare i1 @llvm.expect.i1(i1 <val>, i1 <expected_val>)
+declare i32 @llvm.expect.i32(i32 <val>, i32 <expected_val>)
+declare i64 @llvm.expect.i64(i64 <val>, i64 <expected_val>)
+```
- declare i1 @llvm.expect.i1(i1 <val>, i1 <expected_val>)
- declare i32 @llvm.expect.i32(i32 <val>, i32 <expected_val>)
- declare i64 @llvm.expect.i64(i64 <val>, i64 <expected_val>)
+##### Overview:
-Overview:
-"""""""""
+The `llvm.expect` intrinsic provides information about expected (the
+most probable) value of `val`, which can be used by optimizers.
-The ``llvm.expect`` intrinsic provides information about expected (the
-most probable) value of ``val``, which can be used by optimizers.
+##### Arguments:
-Arguments:
-""""""""""
-
-The ``llvm.expect`` intrinsic takes two arguments. The first argument is
+The `llvm.expect` intrinsic takes two arguments. The first argument is
a value. The second argument is an expected value.
-Semantics:
-""""""""""
-
-This intrinsic is lowered to the ``val``.
+##### Semantics:
-'``llvm.expect.with.probability``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+This intrinsic is lowered to the `val`.
-Syntax:
-"""""""
+#### '`llvm.expect.with.probability`' Intrinsic
-This intrinsic is similar to ``llvm.expect``. This is an overloaded intrinsic.
-You can use ``llvm.expect.with.probability`` on any integer bit width.
+##### Syntax:
-::
+This intrinsic is similar to `llvm.expect`. This is an overloaded intrinsic.
+You can use `llvm.expect.with.probability` on any integer bit width.
- declare i1 @llvm.expect.with.probability.i1(i1 <val>, i1 <expected_val>, double <prob>)
- declare i32 @llvm.expect.with.probability.i32(i32 <val>, i32 <expected_val>, double <prob>)
- declare i64 @llvm.expect.with.probability.i64(i64 <val>, i64 <expected_val>, double <prob>)
+```
+declare i1 @llvm.expect.with.probability.i1(i1 <val>, i1 <expected_val>, double <prob>)
+declare i32 @llvm.expect.with.probability.i32(i32 <val>, i32 <expected_val>, double <prob>)
+declare i64 @llvm.expect.with.probability.i64(i64 <val>, i64 <expected_val>, double <prob>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.expect.with.probability`` intrinsic provides information about
-expected value of ``val`` with probability(or confidence) ``prob``, which can
+The `llvm.expect.with.probability` intrinsic provides information about
+expected value of `val` with probability(or confidence) `prob`, which can
be used by optimizers.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.expect.with.probability`` intrinsic takes three arguments. The first
+The `llvm.expect.with.probability` intrinsic takes three arguments. The first
argument is a value. The second argument is an expected value. The third
argument is a probability.
-Semantics:
-""""""""""
-
-This intrinsic is lowered to the ``val``.
+##### Semantics:
-.. _int_assume:
+This intrinsic is lowered to the `val`.
-'``llvm.assume``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_assume)=
-Syntax:
-"""""""
+#### '`llvm.assume`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.assume(i1 %cond)
+```
+declare void @llvm.assume(i1 %cond)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.assume`` allows the optimizer to assume that the provided
+The `llvm.assume` allows the optimizer to assume that the provided
condition is true. This information can then be used in simplifying other parts
of the code.
More complex assumptions can be encoded as
-:ref:`assume operand bundles <assume_opbundles>`.
+{ref}`assume operand bundles <assume_opbundles>`.
-Arguments:
-""""""""""
+##### Arguments:
The argument of the call is the condition which the optimizer may assume is
always true.
-Semantics:
-""""""""""
+##### Semantics:
The intrinsic allows the optimizer to assume that the provided condition is
always true whenever the control flow reaches the intrinsic call. No code is
@@ -31500,94 +28896,79 @@ provided condition are not used for code generation. If the condition is
violated during execution, the behavior is undefined.
Note that the optimizer might limit the transformations performed on values
-used by the ``llvm.assume`` intrinsic in order to preserve the instructions
+used by the `llvm.assume` intrinsic in order to preserve the instructions
only used to form the intrinsic's input argument. This might prove undesirable
-if the extra information provided by the ``llvm.assume`` intrinsic does not cause
+if the extra information provided by the `llvm.assume` intrinsic does not cause
sufficient overall improvement in code quality. For this reason,
-``llvm.assume`` should not be used to document basic mathematical invariants
+`llvm.assume` should not be used to document basic mathematical invariants
that the optimizer can otherwise deduce or facts that are of little use to the
optimizer.
-.. _int_ssa_copy:
-
-'``llvm.ssa.copy``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_ssa_copy)=
-Syntax:
-"""""""
+#### '`llvm.ssa.copy`' Intrinsic
-::
+##### Syntax:
- declare type @llvm.ssa.copy(type returned %operand) memory(none)
+```
+declare type @llvm.ssa.copy(type returned %operand) memory(none)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is an operand which is used as the returned value.
-Overview:
-""""""""""
+##### Overview:
-The ``llvm.ssa.copy`` intrinsic can be used to attach information to
+The `llvm.ssa.copy` intrinsic can be used to attach information to
operations by copying them and giving them new names. For example,
the PredicateInfo utility uses it to build Extended SSA form, and
attach various forms of information to operands that dominate specific
uses. It is not meant for general use, only for building temporary
renaming forms that require value splits at certain points.
-.. _type.test:
-
-'``llvm.type.test``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+(type.test)=
-::
+#### '`llvm.type.test`' Intrinsic
- declare i1 @llvm.type.test(ptr %ptr, metadata %type) nounwind memory(none)
+##### Syntax:
+```
+declare i1 @llvm.type.test(ptr %ptr, metadata %type) nounwind memory(none)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer to be tested. The second argument is a
-metadata object representing a :doc:`type identifier <TypeMetadata>`.
+metadata object representing a {doc}`type identifier <TypeMetadata>`.
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.type.test`` intrinsic tests whether the given pointer is associated
+The `llvm.type.test` intrinsic tests whether the given pointer is associated
with the given type identifier.
-.. _type.checked.load:
+(type.checked.load)=
-'``llvm.type.checked.load``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.type.checked.load`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare {ptr, i1} @llvm.type.checked.load(ptr %ptr, i32 %offset, metadata %type) nounwind memory(argmem: read)
+```
+declare {ptr, i1} @llvm.type.checked.load(ptr %ptr, i32 %offset, metadata %type) nounwind memory(argmem: read)
+```
-
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer from which to load a function pointer. The
second argument is the byte offset from which to load the function pointer. The
-third argument is a metadata object representing a :doc:`type identifier
-<TypeMetadata>`.
+third argument is a metadata object representing a {doc}`type identifier <TypeMetadata>`.
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.type.checked.load`` intrinsic safely loads a function pointer from a
+The `llvm.type.checked.load` intrinsic safely loads a function pointer from a
virtual table pointer using type metadata. This intrinsic is used to implement
control flow integrity in conjunction with virtual call optimization. The
-virtual call optimization pass will optimize away ``llvm.type.checked.load``
+virtual call optimization pass will optimize away `llvm.type.checked.load`
intrinsics associated with devirtualized calls, thereby removing the type
check in cases where it is not needed to enforce the control flow integrity
constraint.
@@ -31615,59 +28996,51 @@ element is true, the following rules apply to the first element:
If the function's return value's second element is false, the value of the
first element is undefined.
-.. _type.checked.load.relative:
-
-'``llvm.type.checked.load.relative``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(type.checked.load.relative)=
-Syntax:
-"""""""
+#### '`llvm.type.checked.load.relative`' Intrinsic
-::
+##### Syntax:
- declare {ptr, i1} @llvm.type.checked.load.relative(ptr %ptr, i32 %offset, metadata %type) nounwind memory(argmem: read)
+```
+declare {ptr, i1} @llvm.type.checked.load.relative(ptr %ptr, i32 %offset, metadata %type) nounwind memory(argmem: read)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.type.checked.load.relative`` intrinsic loads a relative pointer to a
+The `llvm.type.checked.load.relative` intrinsic loads a relative pointer to a
function from a virtual table pointer using metadata. Otherwise, its semantic is
-identical to the ``llvm.type.checked.load`` intrinsic.
+identical to the `llvm.type.checked.load` intrinsic.
A relative pointer is a pointer to an offset. This is the offset between the destination
pointer and the original pointer. The address of the destination pointer is obtained
by loading this offset and adding it to the original pointer. This calculation is the
-same as that of the ``llvm.load.relative`` intrinsic.
-
-'``llvm.arithmetic.fence``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+same as that of the `llvm.load.relative` intrinsic.
-Syntax:
-"""""""
+#### '`llvm.arithmetic.fence`' Intrinsic
-::
+##### Syntax:
- declare <type>
- @llvm.arithmetic.fence(<type> <op>)
+```
+declare <type>
+ at llvm.arithmetic.fence(<type> <op>)
+```
-Overview:
-"""""""""
+##### Overview:
-The purpose of the ``llvm.arithmetic.fence`` intrinsic
+The purpose of the `llvm.arithmetic.fence` intrinsic
is to prevent the optimizer from performing fast-math optimizations,
particularly reassociation,
between the argument and the expression that contains the argument.
It can be used to preserve the parentheses in the source language.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.arithmetic.fence`` intrinsic takes only one argument.
+The `llvm.arithmetic.fence` intrinsic takes only one argument.
The argument and the return value are floating-point numbers,
or vector floating-point numbers, of the same type.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic returns the value of its operand. The optimizer can optimize
the argument, but the optimizer cannot hoist any component of the operand
@@ -31675,50 +29048,41 @@ to the containing context, and the optimizer cannot move the calculation of
any expression in the containing context into the operand.
-'``llvm.donothing``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.donothing`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.donothing() nounwind memory(none)
+```
+declare void @llvm.donothing() nounwind memory(none)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.donothing`` intrinsic doesn't perform any operation. It's one of only
-three intrinsics (besides ``llvm.experimental.patchpoint`` and
-``llvm.experimental.gc.statepoint``) that can be called with an invoke
+The `llvm.donothing` intrinsic doesn't perform any operation. It's one of only
+three intrinsics (besides `llvm.experimental.patchpoint` and
+`llvm.experimental.gc.statepoint`) that can be called with an invoke
instruction.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic does nothing, and it's removed by optimizers and ignored
by codegen.
-'``llvm.experimental.deoptimize``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.deoptimize`' Intrinsic
-::
+##### Syntax:
- declare type @llvm.experimental.deoptimize(...) [ "deopt"(...) ]
+```
+declare type @llvm.experimental.deoptimize(...) [ "deopt"(...) ]
+```
-Overview:
-"""""""""
+##### Overview:
-This intrinsic, together with :ref:`deoptimization operand bundles
-<deopt_opbundles>`, allow frontends to express transfer of control and
+This intrinsic, together with {ref}`deoptimization operand bundles <deopt_opbundles>`, allow frontends to express transfer of control and
frame-local state from the currently executing (typically more specialized,
hence faster) version of a function into another (typically more generic, hence
slower) version.
@@ -31729,129 +29093,117 @@ functionality. In unmanaged languages like C and C++, this intrinsic can be
used to represent the slow paths of specialized functions.
-Arguments:
-""""""""""
+##### Arguments:
The intrinsic takes an arbitrary number of arguments, whose meaning is
-decided by the :ref:`lowering strategy<deoptimize_lowering>`.
+decided by the {ref}`lowering strategy<deoptimize_lowering>`.
-Semantics:
-""""""""""
+##### Semantics:
-The ``@llvm.experimental.deoptimize`` intrinsic executes an attached
-deoptimization continuation (denoted using a :ref:`deoptimization
-operand bundle <deopt_opbundles>`) and returns the value returned by
+The `@llvm.experimental.deoptimize` intrinsic executes an attached
+deoptimization continuation (denoted using a {ref}`deoptimization operand bundle <deopt_opbundles>`) and returns the value returned by
the deoptimization continuation. Defining the semantic properties of
the continuation itself is out of scope of the language reference --
as far as LLVM is concerned, the deoptimization continuation can
invoke arbitrary side effects, including reading from and writing to
the entire heap.
-Deoptimization continuations expressed using ``"deopt"`` operand bundles always
+Deoptimization continuations expressed using `"deopt"` operand bundles always
continue execution to the end of the physical frame containing them, so all
-calls to ``@llvm.experimental.deoptimize`` must be in "tail position":
+calls to `@llvm.experimental.deoptimize` must be in "tail position":
- - ``@llvm.experimental.deoptimize`` cannot be invoked.
- - The call must immediately precede a :ref:`ret <i_ret>` instruction.
- - The ``ret`` instruction must return the value produced by the
- ``@llvm.experimental.deoptimize`` call if there is one, or void.
+ - `@llvm.experimental.deoptimize` cannot be invoked.
+ - The call must immediately precede a {ref}`ret <i_ret>` instruction.
+ - The `ret` instruction must return the value produced by the
+ `@llvm.experimental.deoptimize` call if there is one, or void.
Note that the above restrictions imply that the return type for a call to
-``@llvm.experimental.deoptimize`` will match the return type of its immediate
+`@llvm.experimental.deoptimize` will match the return type of its immediate
caller.
-The inliner composes the ``"deopt"`` continuations of the caller into the
-``"deopt"`` continuations present in the inlinee, and also updates calls to this
+The inliner composes the `"deopt"` continuations of the caller into the
+`"deopt"` continuations present in the inlinee, and also updates calls to this
intrinsic to return directly from the frame of the function it inlined into.
-All declarations of ``@llvm.experimental.deoptimize`` must share the
+All declarations of `@llvm.experimental.deoptimize` must share the
same calling convention.
-.. _deoptimize_lowering:
+(deoptimize_lowering)=
-Lowering:
-"""""""""
+##### Lowering:
-Calls to ``@llvm.experimental.deoptimize`` are lowered to calls to the
-symbol ``__llvm_deoptimize`` (it is the frontend's responsibility to
+Calls to `@llvm.experimental.deoptimize` are lowered to calls to the
+symbol `__llvm_deoptimize` (it is the frontend's responsibility to
ensure that this symbol is defined). The call arguments to
-``@llvm.experimental.deoptimize`` are lowered as if they were formal
+`@llvm.experimental.deoptimize` are lowered as if they were formal
arguments of the specified types, and not as varargs.
-'``llvm.experimental.guard``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.guard`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.experimental.guard(i1, ...) [ "deopt"(...) ]
+```
+declare void @llvm.experimental.guard(i1, ...) [ "deopt"(...) ]
+```
-Overview:
-"""""""""
+##### Overview:
-This intrinsic, together with :ref:`deoptimization operand bundles
-<deopt_opbundles>`, allows frontends to express guards or checks on
+This intrinsic, together with {ref}`deoptimization operand bundles <deopt_opbundles>`, allows frontends to express guards or checks on
optimistic assumptions made during compilation. The semantics of
-``@llvm.experimental.guard`` is defined in terms of
-``@llvm.experimental.deoptimize`` -- its body is defined to be
+`@llvm.experimental.guard` is defined in terms of
+`@llvm.experimental.deoptimize` -- its body is defined to be
equivalent to:
-.. code-block:: text
-
- define void @llvm.experimental.guard(i1 %pred, <args...>) {
- %realPred = and i1 %pred, undef
- br i1 %realPred, label %continue, label %leave [, !make.implicit !{}]
-
- leave:
- call void @llvm.experimental.deoptimize(<args...>) [ "deopt"() ]
- ret void
+```text
+define void @llvm.experimental.guard(i1 %pred, <args...>) {
+ %realPred = and i1 %pred, undef
+ br i1 %realPred, label %continue, label %leave [, !make.implicit !{}]
- continue:
- ret void
- }
+leave:
+ call void @llvm.experimental.deoptimize(<args...>) [ "deopt"() ]
+ ret void
+continue:
+ ret void
+}
+```
-with the optional ``[, !make.implicit !{}]`` present if and only if it
-is present on the call site. For more details on ``!make.implicit``,
-see :doc:`FaultMaps`.
+with the optional `[, !make.implicit !{}]` present if and only if it
+is present on the call site. For more details on `!make.implicit`,
+see {doc}`FaultMaps`.
-In words, ``@llvm.experimental.guard`` executes the attached
-``"deopt"`` continuation if (but **not** only if) its first argument
-is ``false``. Since the optimizer is allowed to replace the ``undef``
+In words, `@llvm.experimental.guard` executes the attached
+`"deopt"` continuation if (but **not** only if) its first argument
+is `false`. Since the optimizer is allowed to replace the `undef`
with an arbitrary value, it can optimize guard to fail "spuriously",
i.e., without the original condition being false (hence the "not only
if"); and this allows for "check widening" type optimizations.
-``@llvm.experimental.guard`` cannot be invoked.
+`@llvm.experimental.guard` cannot be invoked.
-After ``@llvm.experimental.guard`` was first added, a more general
-formulation was found in ``@llvm.experimental.widenable.condition``.
-Support for ``@llvm.experimental.guard`` is slowly being rephrased in
+After `@llvm.experimental.guard` was first added, a more general
+formulation was found in `@llvm.experimental.widenable.condition`.
+Support for `@llvm.experimental.guard` is slowly being rephrased in
terms of this alternate.
-'``llvm.experimental.widenable.condition``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.experimental.widenable.condition`' Intrinsic
-::
+##### Syntax:
- declare i1 @llvm.experimental.widenable.condition()
+```
+declare i1 @llvm.experimental.widenable.condition()
+```
-Overview:
-"""""""""
+##### Overview:
This intrinsic represents a "widenable condition" which is
boolean expressions with the following property: whether this
expression is `true` or `false`, the program is correct and
well-defined.
-Together with :ref:`deoptimization operand bundles <deopt_opbundles>`,
-``@llvm.experimental.widenable.condition`` allows frontends to
+Together with {ref}`deoptimization operand bundles <deopt_opbundles>`,
+`@llvm.experimental.widenable.condition` allows frontends to
express guards or checks on optimistic assumptions made during
compilation and represent them as branch instructions on special
conditions.
@@ -31862,15 +29214,13 @@ value. It is also intended to be lowered late, and remain available
for specific optimizations and transforms that can benefit from its
special properties.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
-The intrinsic ``@llvm.experimental.widenable.condition()``
+The intrinsic `@llvm.experimental.widenable.condition()`
returns either `true` or `false`. For each evaluation of a call
to this intrinsic, the program must be valid and correct both if
it returns `true` and if it returns `false`. This allows
@@ -31881,290 +29231,264 @@ When used in a branch condition, it allows us to choose between
two alternative correct solutions for the same problem, like
in example below:
-.. code-block:: text
+```text
+ %cond = call i1 @llvm.experimental.widenable.condition()
+ br i1 %cond, label %fast_path, label %slow_path
- %cond = call i1 @llvm.experimental.widenable.condition()
- br i1 %cond, label %fast_path, label %slow_path
+fast_path:
+ ; Apply memory-consuming but fast solution for a task.
- fast_path:
- ; Apply memory-consuming but fast solution for a task.
-
- slow_path:
- ; Cheap in memory but slow solution.
+slow_path:
+ ; Cheap in memory but slow solution.
+```
Whether the result of intrinsic's call is `true` or `false`,
it should be correct to pick either solution. We can switch
between them by replacing the result of
-``@llvm.experimental.widenable.condition`` with different
+`@llvm.experimental.widenable.condition` with different
`i1` expressions.
This is how it can be used to represent guards as widenable branches:
-.. code-block:: text
-
- block:
- ; Unguarded instructions
- call void @llvm.experimental.guard(i1 %cond, <args...>) ["deopt"(<deopt_args...>)]
- ; Guarded instructions
+```text
+block:
+ ; Unguarded instructions
+ call void @llvm.experimental.guard(i1 %cond, <args...>) ["deopt"(<deopt_args...>)]
+ ; Guarded instructions
+```
Can be expressed in an alternative equivalent form of explicit branch using
-``@llvm.experimental.widenable.condition``:
+`@llvm.experimental.widenable.condition`:
-.. code-block:: text
+```text
+block:
+ ; Unguarded instructions
+ %widenable_condition = call i1 @llvm.experimental.widenable.condition()
+ %guard_condition = and i1 %cond, %widenable_condition
+ br i1 %guard_condition, label %guarded, label %deopt
- block:
- ; Unguarded instructions
- %widenable_condition = call i1 @llvm.experimental.widenable.condition()
- %guard_condition = and i1 %cond, %widenable_condition
- br i1 %guard_condition, label %guarded, label %deopt
+guarded:
+ ; Guarded instructions
- guarded:
- ; Guarded instructions
-
- deopt:
- call type @llvm.experimental.deoptimize(<args...>) [ "deopt"(<deopt_args...>) ]
+deopt:
+ call type @llvm.experimental.deoptimize(<args...>) [ "deopt"(<deopt_args...>) ]
+```
So the block `guarded` is only reachable when `%cond` is `true`,
and it should be valid to go to the block `deopt` whenever `%cond`
is `true` or `false`.
-``@llvm.experimental.widenable.condition`` will never throw, thus
+`@llvm.experimental.widenable.condition` will never throw, thus
it cannot be invoked.
-Guard widening:
-"""""""""""""""
+##### Guard widening:
-When ``@llvm.experimental.widenable.condition()`` is used in
+When `@llvm.experimental.widenable.condition()` is used in
condition of a guard represented as explicit branch, it is
legal to widen the guard's condition with any additional
conditions.
Guard widening looks like replacement of
-.. code-block:: text
-
- %widenable_cond = call i1 @llvm.experimental.widenable.condition()
- %guard_cond = and i1 %cond, %widenable_cond
- br i1 %guard_cond, label %guarded, label %deopt
+```text
+%widenable_cond = call i1 @llvm.experimental.widenable.condition()
+%guard_cond = and i1 %cond, %widenable_cond
+br i1 %guard_cond, label %guarded, label %deopt
+```
with
-.. code-block:: text
-
- %widenable_cond = call i1 @llvm.experimental.widenable.condition()
- %new_cond = and i1 %any_other_cond, %widenable_cond
- %new_guard_cond = and i1 %cond, %new_cond
- br i1 %new_guard_cond, label %guarded, label %deopt
+```text
+%widenable_cond = call i1 @llvm.experimental.widenable.condition()
+%new_cond = and i1 %any_other_cond, %widenable_cond
+%new_guard_cond = and i1 %cond, %new_cond
+br i1 %new_guard_cond, label %guarded, label %deopt
+```
for this branch. Here `%any_other_cond` is an arbitrarily chosen
well-defined `i1` value. By making guard widening, we may
impose stricter conditions on `guarded` block and bail to the
deopt when the new condition is not met.
-Lowering:
-"""""""""
+##### Lowering:
Default lowering strategy is replacing the result of
-call of ``@llvm.experimental.widenable.condition`` with
+call of `@llvm.experimental.widenable.condition` with
constant `true`. However it is always correct to replace
it with any other `i1` value. Any pass can
freely do it if it can benefit from non-default lowering.
-'``llvm.allow.ubsan.check``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.allow.ubsan.check`' Intrinsic
-::
+##### Syntax:
- declare i1 @llvm.allow.ubsan.check(i8 immarg %kind)
+```
+declare i1 @llvm.allow.ubsan.check(i8 immarg %kind)
+```
-Overview:
-"""""""""
+##### Overview:
-This intrinsic returns ``true`` if and only if the compiler opted to enable the
+This intrinsic returns `true` if and only if the compiler opted to enable the
ubsan check in the current basic block.
Rules to allow ubsan checks are not part of the intrinsic declaration, and
controlled by compiler options.
-This intrinsic is the ubsan specific version of ``@llvm.allow.runtime.check()``.
+This intrinsic is the ubsan specific version of `@llvm.allow.runtime.check()`.
-Arguments:
-""""""""""
+##### Arguments:
An integer describing the kind of ubsan check guarded by the intrinsic.
-Semantics:
-""""""""""
+##### Semantics:
-The intrinsic ``@llvm.allow.ubsan.check()`` returns either ``true`` or
-``false``, depending on compiler options.
+The intrinsic `@llvm.allow.ubsan.check()` returns either `true` or
+`false`, depending on compiler options.
For each evaluation of a call to this intrinsic, the program must be valid and
-correct both if it returns ``true`` and if it returns ``false``.
+correct both if it returns `true` and if it returns `false`.
When used in a branch condition, it selects one of the two paths:
-* `true``: Executes the UBSan check and reports any failures.
+* `true`: Executes the UBSan check and reports any failures.
* `false`: Bypasses the check, assuming it always succeeds.
Example:
-.. code-block:: text
-
- %allow = call i1 @llvm.allow.ubsan.check(i8 5)
- %not.allow = xor i1 %allow, true
- %cond = or i1 %ubcheck, %not.allow
- br i1 %cond, label %cont, label %trap
+```text
+ %allow = call i1 @llvm.allow.ubsan.check(i8 5)
+ %not.allow = xor i1 %allow, true
+ %cond = or i1 %ubcheck, %not.allow
+ br i1 %cond, label %cont, label %trap
- cont:
- ; Proceed
+cont:
+ ; Proceed
- trap:
- call void @llvm.ubsantrap(i8 5)
- unreachable
+trap:
+ call void @llvm.ubsantrap(i8 5)
+ unreachable
+```
+#### '`llvm.allow.runtime.check`' Intrinsic
-'``llvm.allow.runtime.check``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+declare i1 @llvm.allow.runtime.check(metadata %kind)
+```
- declare i1 @llvm.allow.runtime.check(metadata %kind)
+##### Overview:
-Overview:
-"""""""""
-
-This intrinsic returns ``true`` if and only if the compiler opted to enable
+This intrinsic returns `true` if and only if the compiler opted to enable
runtime checks in the current basic block.
Rules to allow runtime checks are not part of the intrinsic declaration, and
controlled by compiler options.
-This intrinsic is non-ubsan specific version of ``@llvm.allow.ubsan.check()``.
+This intrinsic is non-ubsan specific version of `@llvm.allow.ubsan.check()`.
-Arguments:
-""""""""""
+##### Arguments:
A string identifying the kind of runtime check guarded by the intrinsic. The
string can be used to control rules to allow checks.
-Semantics:
-""""""""""
+##### Semantics:
-The intrinsic ``@llvm.allow.runtime.check()`` returns either ``true`` or
-``false``, depending on compiler options.
+The intrinsic `@llvm.allow.runtime.check()` returns either `true` or
+`false`, depending on compiler options.
For each evaluation of a call to this intrinsic, the program must be valid and
-correct both if it returns ``true`` and if it returns ``false``.
+correct both if it returns `true` and if it returns `false`.
When used in a branch condition, it allows us to choose between
two alternative correct solutions for the same problem.
-If the intrinsic is evaluated as ``true``, program should execute a guarded
-check. If the intrinsic is evaluated as ``false``, the program should avoid any
+If the intrinsic is evaluated as `true`, program should execute a guarded
+check. If the intrinsic is evaluated as `false`, the program should avoid any
unnecessary checks.
Example:
-.. code-block:: text
-
- %allow = call i1 @llvm.allow.runtime.check(metadata !"my_check")
- br i1 %allow, label %fast_path, label %slow_path
+```text
+ %allow = call i1 @llvm.allow.runtime.check(metadata !"my_check")
+ br i1 %allow, label %fast_path, label %slow_path
- fast_path:
- ; Omit diagnostics.
+fast_path:
+ ; Omit diagnostics.
- slow_path:
- ; Additional diagnostics.
+slow_path:
+ ; Additional diagnostics.
+```
+#### '`llvm.load.relative`' Intrinsic
-'``llvm.load.relative``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
-Syntax:
-"""""""
-
-::
+```
+declare ptr @llvm.load.relative.iN(ptr %ptr, iN %offset) nounwind memory(argmem: read)
+```
- declare ptr @llvm.load.relative.iN(ptr %ptr, iN %offset) nounwind memory(argmem: read)
+##### Overview:
-Overview:
-"""""""""
-
-This intrinsic loads a 32-bit value from the address ``%ptr + %offset``,
-adds ``%ptr`` to that value and returns it. The constant folder specifically
+This intrinsic loads a 32-bit value from the address `%ptr + %offset`,
+adds `%ptr` to that value and returns it. The constant folder specifically
recognizes the form of this intrinsic and the constant initializers it may
load from; if a loaded constant initializer is known to have the form
-``i32 trunc(x - %ptr)``, the intrinsic call is folded to ``x``.
+`i32 trunc(x - %ptr)`, the intrinsic call is folded to `x`.
LLVM provides that the calculation of such a constant initializer will
-not overflow at link time under the medium code model if ``x`` is an
-``unnamed_addr`` function. However, it does not provide this guarantee for
+not overflow at link time under the medium code model if `x` is an
+`unnamed_addr` function. However, it does not provide this guarantee for
a constant initializer folded into a function body. This intrinsic can be
used to avoid the possibility of overflows when loading from such a constant.
-.. _llvm_sideeffect:
-
-'``llvm.sideeffect``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(llvm_sideeffect)=
-Syntax:
-"""""""
+#### '`llvm.sideeffect`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.sideeffect() inaccessiblememonly nounwind willreturn
+```
+declare void @llvm.sideeffect() inaccessiblememonly nounwind willreturn
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.sideeffect`` intrinsic doesn't perform any operation. Optimizers
+The `llvm.sideeffect` intrinsic doesn't perform any operation. Optimizers
treat it as having side effects, so it can be inserted into a loop to
indicate that the loop shouldn't be assumed to terminate (which could
potentially lead to the loop being optimized away entirely), even if it's
an infinite loop with no other side effects.
-Arguments:
-""""""""""
+##### Arguments:
None.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic actually does nothing, but optimizers must assume that it
has externally observable side effects.
-'``llvm.is.constant.*``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.is.constant.*`' Intrinsic
-This is an overloaded intrinsic. You can use ``llvm.is.constant`` with any argument type.
+##### Syntax:
-::
+This is an overloaded intrinsic. You can use `llvm.is.constant` with any argument type.
- declare i1 @llvm.is.constant.i32(i32 %operand) nounwind memory(none)
- declare i1 @llvm.is.constant.f32(float %operand) nounwind memory(none)
- declare i1 @llvm.is.constant.TYPENAME(TYPE %operand) nounwind memory(none)
+```
+declare i1 @llvm.is.constant.i32(i32 %operand) nounwind memory(none)
+declare i1 @llvm.is.constant.f32(float %operand) nounwind memory(none)
+declare i1 @llvm.is.constant.TYPENAME(TYPE %operand) nounwind memory(none)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.is.constant``' intrinsic will return true if the argument
+The '`llvm.is.constant`' intrinsic will return true if the argument
is known to be a manifest compile-time constant. It is guaranteed to
fold to either true or false before generating machine code.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic generates no code. If its argument is known to be a
manifest compile-time constant value, then the intrinsic will be
@@ -32180,47 +29504,43 @@ The result also intentionally depends on the result of optimization
passes -- e.g., the result can change depending on whether a
function gets inlined or not. A function's parameters are
obviously not constant. However, a call like
-``llvm.is.constant.i32(i32 %param)`` *can* return true after the
+`llvm.is.constant.i32(i32 %param)` *can* return true after the
function is inlined, if the value passed to the function parameter was
a constant.
-.. _int_ptrmask:
-
-'``llvm.ptrmask``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+(int_ptrmask)=
-Syntax:
-"""""""
+#### '`llvm.ptrmask`' Intrinsic
-::
+##### Syntax:
- declare ptrty llvm.ptrmask(ptrty %ptr, intty %mask) speculatable memory(none)
+```
+declare ptrty llvm.ptrmask(ptrty %ptr, intty %mask) speculatable memory(none)
+```
-Arguments:
-""""""""""
+##### Arguments:
The first argument is a pointer or vector of pointers. The second argument is
an integer or vector of integers with the same bit width as the index type
size of the first argument.
-Overview:
-""""""""""
+##### Overview:
-The ``llvm.ptrmask`` intrinsic masks out bits of the pointer according to a mask.
+The `llvm.ptrmask` intrinsic masks out bits of the pointer according to a mask.
This allows stripping data from tagged pointers without converting them to an
integer (ptrtoint/inttoptr). As a consequence, we can preserve more information
to facilitate alias analysis and underlying-object detection.
-Semantics:
-""""""""""
-
-The result of ``ptrmask(%ptr, %mask)`` is equivalent to the following expansion,
-where ``iPtrIdx`` is the index type size of the pointer::
+##### Semantics:
- %intptr = ptrtoint ptr %ptr to iPtrIdx ; this may truncate
- %masked = and iPtrIdx %intptr, %mask
- %diff = sub iPtrIdx %masked, %intptr
- %result = getelementptr i8, ptr %ptr, iPtrIdx %diff
+The result of `ptrmask(%ptr, %mask)` is equivalent to the following expansion,
+where `iPtrIdx` is the index type size of the pointer:
+```
+%intptr = ptrtoint ptr %ptr to iPtrIdx ; this may truncate
+%masked = and iPtrIdx %intptr, %mask
+%diff = sub iPtrIdx %masked, %intptr
+%result = getelementptr i8, ptr %ptr, iPtrIdx %diff
+```
If the pointer index type size is smaller than the pointer type size, this
implies that pointer bits beyond the index size are not affected by this
@@ -32229,198 +29549,173 @@ intrinsic. For integral pointers, it behaves as if the mask were extended with
Both the returned pointer(s) and the first argument are based on the same
underlying object (for more information on the *based on* terminology see
-:ref:`the pointer aliasing rules <pointeraliasing>`).
+{ref}`the pointer aliasing rules <pointeraliasing>`).
The intrinsic only captures the pointer argument through the return value.
-.. _int_threadlocal_address:
+(int_threadlocal_address)=
-'``llvm.threadlocal.address``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.threadlocal.address`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.threadlocal.address(ptr) nounwind willreturn memory(none)
+```
+declare ptr @llvm.threadlocal.address(ptr) nounwind willreturn memory(none)
+```
-Arguments:
-""""""""""
+##### Arguments:
The `llvm.threadlocal.address` intrinsic requires a global value argument (a
-:ref:`global variable <globalvars>` or alias) that is thread local.
+{ref}`global variable <globalvars>` or alias) that is thread local.
-Semantics:
-""""""""""
+##### Semantics:
The address of a thread local global is not a constant, since it depends on
the calling thread. The `llvm.threadlocal.address` intrinsic returns the
address of the given thread local global in the calling thread.
-.. _int_vscale:
+(int_vscale)=
-'``llvm.vscale``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.vscale`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare i32 llvm.vscale.i32()
- declare i64 llvm.vscale.i64()
+```
+declare i32 llvm.vscale.i32()
+declare i64 llvm.vscale.i64()
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.vscale`` intrinsic returns the value for ``vscale`` in scalable
-vectors such as ``<vscale x 16 x i8>``.
+The `llvm.vscale` intrinsic returns the value for `vscale` in scalable
+vectors such as `<vscale x 16 x i8>`.
-Semantics:
-""""""""""
+##### Semantics:
-``vscale`` is a positive power-of-two integer that is constant throughout
+`vscale` is a positive power-of-two integer that is constant throughout
program execution, but is unknown at compile time.
If the result value does not fit in the result type, then the result is
-a :ref:`poison value <poisonvalues>`.
+a {ref}`poison value <poisonvalues>`.
-.. _llvm_fake_use:
+(llvm_fake_use)=
-'``llvm.fake.use``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.fake.use`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.fake.use(...)
+```
+declare void @llvm.fake.use(...)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.fake.use`` intrinsic is a no-op. It takes a single
+The `llvm.fake.use` intrinsic is a no-op. It takes a single
value as an operand and is treated as a use of that operand, to force the
optimizer to preserve that value prior to the fake use. This is used for
extending the lifetimes of variables, where this intrinsic placed at the end of
a variable's scope helps prevent that variable from being optimized out.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.fake.use`` intrinsic takes one argument, which may be any
+The `llvm.fake.use` intrinsic takes one argument, which may be any
function-local SSA value. Note that the signature is variadic so that the
intrinsic can take any type of argument, but passing more than one argument will
result in an error.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic does nothing, but optimizers must consider it a use of its single
operand and should try to preserve the intrinsic and its position in the
function.
-.. _llvm_reloc_none:
+(llvm_reloc_none)=
-'``llvm.reloc.none``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.reloc.none`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.reloc.none(metadata !<name_str>)
+```
+declare void @llvm.reloc.none(metadata !<name_str>)
+```
-Overview:
-"""""""""
+##### Overview:
-The ``llvm.reloc.none`` intrinsic emits a no-op relocation against a given
+The `llvm.reloc.none` intrinsic emits a no-op relocation against a given
operand symbol. This can bring the symbol definition into the link without
emitting any code or data to the binary for that purpose.
-Arguments:
-""""""""""
+##### Arguments:
-The ``llvm.reloc.none`` intrinsic takes the symbol as a metadata string
+The `llvm.reloc.none` intrinsic takes the symbol as a metadata string
argument.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic emits a no-op relocation for the symbol at the location of the
intrinsic call.
-Stack Map Intrinsics
---------------------
+### Stack Map Intrinsics
LLVM provides experimental intrinsics to support runtime patching
mechanisms commonly desired in dynamic language JITs. These intrinsics
-are described in :doc:`StackMaps`.
+are described in {doc}`StackMaps`.
-Element Wise Atomic Memory Intrinsics
--------------------------------------
+### Element Wise Atomic Memory Intrinsics
These intrinsics are similar to the standard library memory intrinsics except
that they perform memory transfer as a sequence of atomic memory accesses.
-.. _int_memcpy_element_unordered_atomic:
+(int_memcpy_element_unordered_atomic)=
-'``llvm.memcpy.element.unordered.atomic``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memcpy.element.unordered.atomic`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memcpy.element.unordered.atomic`` on
+This is an overloaded intrinsic. You can use `llvm.memcpy.element.unordered.atomic` on
any integer bit width and for different address spaces. Not all targets
support all bit widths however.
-::
-
- declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i32(ptr <dest>,
- ptr <src>,
- i32 <len>,
- i32 <element_size>)
- declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i64(ptr <dest>,
- ptr <src>,
- i64 <len>,
- i32 <element_size>)
-
-Overview:
-"""""""""
-
-The '``llvm.memcpy.element.unordered.atomic.*``' intrinsic is a specialization of the
-'``llvm.memcpy.*``' intrinsic. It differs in that the ``dest`` and ``src`` are treated
-as arrays with elements that are exactly ``element_size`` bytes, and the copy between
-buffers uses a sequence of :ref:`unordered atomic <ordering>` load/store operations
-that are a positive integer multiple of the ``element_size`` in size.
-
-Arguments:
-""""""""""
-
-The first three arguments are the same as they are in the :ref:`@llvm.memcpy <int_memcpy>`
-intrinsic, with the added constraint that ``len`` is required to be a positive integer
-multiple of the ``element_size``. If ``len`` is not a positive integer multiple of
-``element_size``, then the behavior of the intrinsic is undefined.
-
-``element_size`` must be a compile-time constant positive power of two no greater than
+```
+declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i32(ptr <dest>,
+ ptr <src>,
+ i32 <len>,
+ i32 <element_size>)
+declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i64(ptr <dest>,
+ ptr <src>,
+ i64 <len>,
+ i32 <element_size>)
+```
+
+##### Overview:
+
+The '`llvm.memcpy.element.unordered.atomic.*`' intrinsic is a specialization of the
+'`llvm.memcpy.*`' intrinsic. It differs in that the `dest` and `src` are treated
+as arrays with elements that are exactly `element_size` bytes, and the copy between
+buffers uses a sequence of {ref}`unordered atomic <ordering>` load/store operations
+that are a positive integer multiple of the `element_size` in size.
+
+##### Arguments:
+
+The first three arguments are the same as they are in the {ref}`@llvm.memcpy <int_memcpy>`
+intrinsic, with the added constraint that `len` is required to be a positive integer
+multiple of the `element_size`. If `len` is not a positive integer multiple of
+`element_size`, then the behavior of the intrinsic is undefined.
+
+`element_size` must be a compile-time constant positive power of two no greater than
target-specific atomic access size limit.
-For each of the input pointers ``align`` parameter attribute must be specified. It
-must be a power of two no less than the ``element_size``. Caller guarantees that
+For each of the input pointers `align` parameter attribute must be specified. It
+must be a power of two no less than the `element_size`. Caller guarantees that
both the source and destination pointers are aligned to that boundary.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memcpy.element.unordered.atomic.*``' intrinsic copies ``len`` bytes of
+The '`llvm.memcpy.element.unordered.atomic.*`' intrinsic copies `len` bytes of
memory from the source location to the destination location. These locations are not
allowed to overlap. The memory copy is performed as a sequence of load/store operations
-where each access is guaranteed to be a multiple of ``element_size`` bytes wide and
-aligned at an ``element_size`` boundary.
+where each access is guaranteed to be a multiple of `element_size` bytes wide and
+aligned at an `element_size` boundary.
The order of the copy is unspecified. The same value may be read from the source
buffer many times, but only one write is issued to the destination buffer per
@@ -32431,73 +29726,66 @@ This intrinsic does not provide any additional ordering guarantees over those
provided by a set of unordered loads from the source location and stores to the
destination.
-Lowering:
-"""""""""
+##### Lowering:
-In the most general case call to the '``llvm.memcpy.element.unordered.atomic.*``' is
-lowered to a call to the symbol ``__llvm_memcpy_element_unordered_atomic_*``. Where '*'
-is replaced with an actual element size. See :ref:`RewriteStatepointsForGC intrinsic
-lowering <RewriteStatepointsForGC_intrinsic_lowering>` for details on GC specific
+In the most general case call to the '`llvm.memcpy.element.unordered.atomic.*`' is
+lowered to a call to the symbol `__llvm_memcpy_element_unordered_atomic_*`. Where '*'
+is replaced with an actual element size. See {ref}`RewriteStatepointsForGC intrinsic lowering <RewriteStatepointsForGC_intrinsic_lowering>` for details on GC specific
lowering.
Optimizer is allowed to inline memory copy when it's profitable to do so.
-'``llvm.memmove.element.unordered.atomic``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memmove.element.unordered.atomic`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
This is an overloaded intrinsic. You can use
-``llvm.memmove.element.unordered.atomic`` on any integer bit width and for
+`llvm.memmove.element.unordered.atomic` on any integer bit width and for
different address spaces. Not all targets support all bit widths however.
-::
-
- declare void @llvm.memmove.element.unordered.atomic.p0.p0.i32(ptr <dest>,
- ptr <src>,
- i32 <len>,
- i32 <element_size>)
- declare void @llvm.memmove.element.unordered.atomic.p0.p0.i64(ptr <dest>,
- ptr <src>,
- i64 <len>,
- i32 <element_size>)
-
-Overview:
-"""""""""
-
-The '``llvm.memmove.element.unordered.atomic.*``' intrinsic is a specialization
-of the '``llvm.memmove.*``' intrinsic. It differs in that the ``dest`` and
-``src`` are treated as arrays with elements that are exactly ``element_size``
+```
+declare void @llvm.memmove.element.unordered.atomic.p0.p0.i32(ptr <dest>,
+ ptr <src>,
+ i32 <len>,
+ i32 <element_size>)
+declare void @llvm.memmove.element.unordered.atomic.p0.p0.i64(ptr <dest>,
+ ptr <src>,
+ i64 <len>,
+ i32 <element_size>)
+```
+
+##### Overview:
+
+The '`llvm.memmove.element.unordered.atomic.*`' intrinsic is a specialization
+of the '`llvm.memmove.*`' intrinsic. It differs in that the `dest` and
+`src` are treated as arrays with elements that are exactly `element_size`
bytes, and the copy between buffers uses a sequence of
-:ref:`unordered atomic <ordering>` load/store operations that are a positive
-integer multiple of the ``element_size`` in size.
+{ref}`unordered atomic <ordering>` load/store operations that are a positive
+integer multiple of the `element_size` in size.
-Arguments:
-""""""""""
+##### Arguments:
The first three arguments are the same as they are in the
-:ref:`@llvm.memmove <int_memmove>` intrinsic, with the added constraint that
-``len`` is required to be a positive integer multiple of the ``element_size``.
-If ``len`` is not a positive integer multiple of ``element_size``, then the
+{ref}`@llvm.memmove <int_memmove>` intrinsic, with the added constraint that
+`len` is required to be a positive integer multiple of the `element_size`.
+If `len` is not a positive integer multiple of `element_size`, then the
behavior of the intrinsic is undefined.
-``element_size`` must be a compile-time constant positive power of two no
+`element_size` must be a compile-time constant positive power of two no
greater than a target-specific atomic access size limit.
-For each of the input pointers the ``align`` parameter attribute must be
-specified. It must be a power of two no less than the ``element_size``. Caller
+For each of the input pointers the `align` parameter attribute must be
+specified. It must be a power of two no less than the `element_size`. Caller
guarantees that both the source and destination pointers are aligned to that
boundary.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memmove.element.unordered.atomic.*``' intrinsic copies ``len`` bytes
+The '`llvm.memmove.element.unordered.atomic.*`' intrinsic copies `len` bytes
of memory from the source location to the destination location. These locations
are allowed to overlap. The memory copy is performed as a sequence of load/store
-operations where each access is guaranteed to be a multiple of ``element_size``
-bytes wide and aligned at an ``element_size`` boundary.
+operations where each access is guaranteed to be a multiple of `element_size`
+bytes wide and aligned at an `element_size` boundary.
The order of the copy is unspecified. The same value may be read from the source
buffer many times, but only one write is issued to the destination buffer per
@@ -32509,72 +29797,65 @@ This intrinsic does not provide any additional ordering guarantees over those
provided by a set of unordered loads from the source location and stores to the
destination.
-Lowering:
-"""""""""
+##### Lowering:
In the most general case call to the
-'``llvm.memmove.element.unordered.atomic.*``' is lowered to a call to the symbol
-``__llvm_memmove_element_unordered_atomic_*``. Where '*' is replaced with an
-actual element size. See :ref:`RewriteStatepointsForGC intrinsic lowering
-<RewriteStatepointsForGC_intrinsic_lowering>` for details on GC specific
+'`llvm.memmove.element.unordered.atomic.*`' is lowered to a call to the symbol
+`__llvm_memmove_element_unordered_atomic_*`. Where '*' is replaced with an
+actual element size. See {ref}`RewriteStatepointsForGC intrinsic lowering <RewriteStatepointsForGC_intrinsic_lowering>` for details on GC specific
lowering.
The optimizer is allowed to inline the memory copy when it's profitable to do so.
-.. _int_memset_element_unordered_atomic:
+(int_memset_element_unordered_atomic)=
-'``llvm.memset.element.unordered.atomic``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.memset.element.unordered.atomic`' Intrinsic
-Syntax:
-"""""""
+##### Syntax:
-This is an overloaded intrinsic. You can use ``llvm.memset.element.unordered.atomic`` on
+This is an overloaded intrinsic. You can use `llvm.memset.element.unordered.atomic` on
any integer bit width and for different address spaces. Not all targets
support all bit widths however.
-::
-
- declare void @llvm.memset.element.unordered.atomic.p0.i32(ptr <dest>,
- i8 <value>,
- i32 <len>,
- i32 <element_size>)
- declare void @llvm.memset.element.unordered.atomic.p0.i64(ptr <dest>,
- i8 <value>,
- i64 <len>,
- i32 <element_size>)
-
-Overview:
-"""""""""
-
-The '``llvm.memset.element.unordered.atomic.*``' intrinsic is a specialization of the
-'``llvm.memset.*``' intrinsic. It differs in that the ``dest`` is treated as an array
-with elements that are exactly ``element_size`` bytes, and the assignment to that array
-uses uses a sequence of :ref:`unordered atomic <ordering>` store operations
-that are a positive integer multiple of the ``element_size`` in size.
-
-Arguments:
-""""""""""
-
-The first three arguments are the same as they are in the :ref:`@llvm.memset <int_memset>`
-intrinsic, with the added constraint that ``len`` is required to be a positive integer
-multiple of the ``element_size``. If ``len`` is not a positive integer multiple of
-``element_size``, then the behavior of the intrinsic is undefined.
-
-``element_size`` must be a compile-time constant positive power of two no greater than
+```
+declare void @llvm.memset.element.unordered.atomic.p0.i32(ptr <dest>,
+ i8 <value>,
+ i32 <len>,
+ i32 <element_size>)
+declare void @llvm.memset.element.unordered.atomic.p0.i64(ptr <dest>,
+ i8 <value>,
+ i64 <len>,
+ i32 <element_size>)
+```
+
+##### Overview:
+
+The '`llvm.memset.element.unordered.atomic.*`' intrinsic is a specialization of the
+'`llvm.memset.*`' intrinsic. It differs in that the `dest` is treated as an array
+with elements that are exactly `element_size` bytes, and the assignment to that array
+uses uses a sequence of {ref}`unordered atomic <ordering>` store operations
+that are a positive integer multiple of the `element_size` in size.
+
+##### Arguments:
+
+The first three arguments are the same as they are in the {ref}`@llvm.memset <int_memset>`
+intrinsic, with the added constraint that `len` is required to be a positive integer
+multiple of the `element_size`. If `len` is not a positive integer multiple of
+`element_size`, then the behavior of the intrinsic is undefined.
+
+`element_size` must be a compile-time constant positive power of two no greater than
target-specific atomic access size limit.
-The ``dest`` input pointer must have the ``align`` parameter attribute specified. It
-must be a power of two no less than the ``element_size``. Caller guarantees that
+The `dest` input pointer must have the `align` parameter attribute specified. It
+must be a power of two no less than the `element_size`. Caller guarantees that
the destination pointer is aligned to that boundary.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.memset.element.unordered.atomic.*``' intrinsic sets the ``len`` bytes of
-memory starting at the destination location to the given ``value``. The memory is
+The '`llvm.memset.element.unordered.atomic.*`' intrinsic sets the `len` bytes of
+memory starting at the destination location to the given `value`. The memory is
set with a sequence of store operations where each access is guaranteed to be a
-multiple of ``element_size`` bytes wide and aligned at an ``element_size`` boundary.
+multiple of `element_size` bytes wide and aligned at an `element_size` boundary.
The order of the assignment is unspecified. Only one write is issued to the
destination buffer per element. It is well defined to have concurrent reads and
@@ -32584,277 +29865,219 @@ when specified.
This intrinsic does not provide any additional ordering guarantees over those
provided by a set of unordered stores to the destination.
-Lowering:
-"""""""""
+##### Lowering:
-In the most general case call to the '``llvm.memset.element.unordered.atomic.*``' is
-lowered to a call to the symbol ``__llvm_memset_element_unordered_atomic_*``. Where '*'
+In the most general case call to the '`llvm.memset.element.unordered.atomic.*`' is
+lowered to a call to the symbol `__llvm_memset_element_unordered_atomic_*`. Where '*'
is replaced with an actual element size.
The optimizer is allowed to inline the memory assignment when it's profitable to do so.
-Objective-C ARC Runtime Intrinsics
-----------------------------------
+### Objective-C ARC Runtime Intrinsics
LLVM provides intrinsics that lower to Objective-C ARC runtime entry points.
LLVM is aware of the semantics of these functions, and optimizes based on that
-knowledge. You can read more about the details of Objective-C ARC `here
-<https://clang.llvm.org/docs/AutomaticReferenceCounting.html>`_.
-
-'``llvm.objc.autorelease``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-::
-
- declare ptr @llvm.objc.autorelease(ptr)
-
-Lowering:
-"""""""""
-
-Lowers to a call to `objc_autorelease <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autorelease>`_.
-
-'``llvm.objc.autoreleasePoolPop``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-::
-
- declare void @llvm.objc.autoreleasePoolPop(ptr)
-
-Lowering:
-"""""""""
-
-Lowers to a call to `objc_autoreleasePoolPop <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-autoreleasepoolpop-void-pool>`_.
-
-'``llvm.objc.autoreleasePoolPush``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-::
-
- declare ptr @llvm.objc.autoreleasePoolPush()
+knowledge. You can read more about the details of Objective-C ARC [here](https://clang.llvm.org/docs/AutomaticReferenceCounting.html).
-Lowering:
-"""""""""
+#### '`llvm.objc.autorelease`' Intrinsic
-Lowers to a call to `objc_autoreleasePoolPush <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-autoreleasepoolpush-void>`_.
+##### Syntax:
+```
+declare ptr @llvm.objc.autorelease(ptr)
+```
-'``llvm.objc.autoreleaseReturnValue``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Lowering:
-Syntax:
-"""""""
-::
-
- declare ptr @llvm.objc.autoreleaseReturnValue(ptr)
-
-Lowering:
-"""""""""
-
-Lowers to a call to `objc_autoreleaseReturnValue <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue>`_.
+Lowers to a call to [objc_autorelease](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autorelease).
-'``llvm.objc.copyWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.objc.autoreleasePoolPop`' Intrinsic
-Syntax:
-"""""""
-::
-
- declare void @llvm.objc.copyWeak(ptr, ptr)
+##### Syntax:
+```
+declare void @llvm.objc.autoreleasePoolPop(ptr)
+```
-Lowering:
-"""""""""
+##### Lowering:
-Lowers to a call to `objc_copyWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-copyweak-id-dest-id-src>`_.
+Lowers to a call to [objc_autoreleasePoolPop](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-autoreleasepoolpop-void-pool).
-'``llvm.objc.destroyWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-::
+#### '`llvm.objc.autoreleasePoolPush`' Intrinsic
- declare void @llvm.objc.destroyWeak(ptr)
+##### Syntax:
+```
+declare ptr @llvm.objc.autoreleasePoolPush()
+```
-Lowering:
-"""""""""
+##### Lowering:
-Lowers to a call to `objc_destroyWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-destroyweak-id-object>`_.
+Lowers to a call to [objc_autoreleasePoolPush](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-autoreleasepoolpush-void).
-'``llvm.objc.initWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.objc.autoreleaseReturnValue`' Intrinsic
-Syntax:
-"""""""
-::
+##### Syntax:
+```
+declare ptr @llvm.objc.autoreleaseReturnValue(ptr)
+```
- declare ptr @llvm.objc.initWeak(ptr, ptr)
+##### Lowering:
-Lowering:
-"""""""""
+Lowers to a call to [objc_autoreleaseReturnValue](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue).
-Lowers to a call to `objc_initWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-initweak>`_.
+#### '`llvm.objc.copyWeak`' Intrinsic
-'``llvm.objc.loadWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
+```
+declare void @llvm.objc.copyWeak(ptr, ptr)
+```
-Syntax:
-"""""""
-::
+##### Lowering:
- declare ptr @llvm.objc.loadWeak(ptr)
+Lowers to a call to [objc_copyWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-copyweak-id-dest-id-src).
-Lowering:
-"""""""""
+#### '`llvm.objc.destroyWeak`' Intrinsic
-Lowers to a call to `objc_loadWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-loadweak>`_.
+##### Syntax:
+```
+declare void @llvm.objc.destroyWeak(ptr)
+```
-'``llvm.objc.loadWeakRetained``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Lowering:
-Syntax:
-"""""""
-::
+Lowers to a call to [objc_destroyWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-destroyweak-id-object).
- declare ptr @llvm.objc.loadWeakRetained(ptr)
+#### '`llvm.objc.initWeak`' Intrinsic
-Lowering:
-"""""""""
+##### Syntax:
+```
+declare ptr @llvm.objc.initWeak(ptr, ptr)
+```
-Lowers to a call to `objc_loadWeakRetained <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-loadweakretained>`_.
+##### Lowering:
-'``llvm.objc.moveWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Lowers to a call to [objc_initWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-initweak).
-Syntax:
-"""""""
-::
+#### '`llvm.objc.loadWeak`' Intrinsic
- declare void @llvm.objc.moveWeak(ptr, ptr)
+##### Syntax:
+```
+declare ptr @llvm.objc.loadWeak(ptr)
+```
-Lowering:
-"""""""""
+##### Lowering:
-Lowers to a call to `objc_moveWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-moveweak-id-dest-id-src>`_.
+Lowers to a call to [objc_loadWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-loadweak).
-'``llvm.objc.release``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.objc.loadWeakRetained`' Intrinsic
-Syntax:
-"""""""
-::
+##### Syntax:
+```
+declare ptr @llvm.objc.loadWeakRetained(ptr)
+```
- declare void @llvm.objc.release(ptr)
+##### Lowering:
-Lowering:
-"""""""""
+Lowers to a call to [objc_loadWeakRetained](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-loadweakretained).
-Lowers to a call to `objc_release <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-release-id-value>`_.
+#### '`llvm.objc.moveWeak`' Intrinsic
-'``llvm.objc.retain``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
+```
+declare void @llvm.objc.moveWeak(ptr, ptr)
+```
-Syntax:
-"""""""
-::
+##### Lowering:
- declare ptr @llvm.objc.retain(ptr)
+Lowers to a call to [objc_moveWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-moveweak-id-dest-id-src).
-Lowering:
-"""""""""
+#### '`llvm.objc.release`' Intrinsic
-Lowers to a call to `objc_retain <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain>`_.
+##### Syntax:
+```
+declare void @llvm.objc.release(ptr)
+```
-'``llvm.objc.retainAutorelease``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Lowering:
-Syntax:
-"""""""
-::
+Lowers to a call to [objc_release](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-release-id-value).
- declare ptr @llvm.objc.retainAutorelease(ptr)
+#### '`llvm.objc.retain`' Intrinsic
-Lowering:
-"""""""""
+##### Syntax:
+```
+declare ptr @llvm.objc.retain(ptr)
+```
-Lowers to a call to `objc_retainAutorelease <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautorelease>`_.
+##### Lowering:
-'``llvm.objc.retainAutoreleaseReturnValue``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Lowers to a call to [objc_retain](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain).
-Syntax:
-"""""""
-::
+#### '`llvm.objc.retainAutorelease`' Intrinsic
- declare ptr @llvm.objc.retainAutoreleaseReturnValue(ptr)
+##### Syntax:
+```
+declare ptr @llvm.objc.retainAutorelease(ptr)
+```
-Lowering:
-"""""""""
+##### Lowering:
-Lowers to a call to `objc_retainAutoreleaseReturnValue <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautoreleasereturnvalue>`_.
+Lowers to a call to [objc_retainAutorelease](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautorelease).
-'``llvm.objc.retainAutoreleasedReturnValue``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.objc.retainAutoreleaseReturnValue`' Intrinsic
-Syntax:
-"""""""
-::
+##### Syntax:
+```
+declare ptr @llvm.objc.retainAutoreleaseReturnValue(ptr)
+```
- declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
+##### Lowering:
-Lowering:
-"""""""""
+Lowers to a call to [objc_retainAutoreleaseReturnValue](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautoreleasereturnvalue).
-Lowers to a call to `objc_retainAutoreleasedReturnValue <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautoreleasedreturnvalue>`_.
+#### '`llvm.objc.retainAutoreleasedReturnValue`' Intrinsic
-'``llvm.objc.retainBlock``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Syntax:
+```
+declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr)
+```
-Syntax:
-"""""""
-::
+##### Lowering:
- declare ptr @llvm.objc.retainBlock(ptr)
+Lowers to a call to [objc_retainAutoreleasedReturnValue](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainautoreleasedreturnvalue).
-Lowering:
-"""""""""
+#### '`llvm.objc.retainBlock`' Intrinsic
-Lowers to a call to `objc_retainBlock <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainblock>`_.
+##### Syntax:
+```
+declare ptr @llvm.objc.retainBlock(ptr)
+```
-'``llvm.objc.storeStrong``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+##### Lowering:
-Syntax:
-"""""""
-::
+Lowers to a call to [objc_retainBlock](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retainblock).
- declare void @llvm.objc.storeStrong(ptr, ptr)
+#### '`llvm.objc.storeStrong`' Intrinsic
-Lowering:
-"""""""""
+##### Syntax:
+```
+declare void @llvm.objc.storeStrong(ptr, ptr)
+```
-Lowers to a call to `objc_storeStrong <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-storestrong-id-object-id-value>`_.
+##### Lowering:
-'``llvm.objc.storeWeak``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Lowers to a call to [objc_storeStrong](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#void-objc-storestrong-id-object-id-value).
-Syntax:
-"""""""
-::
+#### '`llvm.objc.storeWeak`' Intrinsic
- declare ptr @llvm.objc.storeWeak(ptr, ptr)
+##### Syntax:
+```
+declare ptr @llvm.objc.storeWeak(ptr, ptr)
+```
-Lowering:
-"""""""""
+##### Lowering:
-Lowers to a call to `objc_storeWeak <https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-storeweak>`_.
+Lowers to a call to [objc_storeWeak](https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-storeweak).
-Preserving Debug Information Intrinsics
----------------------------------------
+### Preserving Debug Information Intrinsics
These intrinsics are used to carry certain debuginfo together with
IR-level operations. For example, it may be desirable to
@@ -32863,144 +30086,122 @@ indices. Such information got lost in IR GetElementPtr instruction
since the IR types are different from debugInfo types and unions
are converted to structs in IR.
-'``llvm.preserve.array.access.index``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.preserve.array.access.index`' Intrinsic
-Syntax:
-"""""""
-::
-
- declare <ret_type>
- @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(<type> base,
- i32 dim,
- i32 index)
+##### Syntax:
+```
+declare <ret_type>
+ at llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(<type> base,
+ i32 dim,
+ i32 index)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.preserve.array.access.index``' intrinsic returns the getelementptr address
-based on array base ``base``, array dimension ``dim`` and the last access index ``index``
-into the array. The return type ``ret_type`` is a pointer type to the array element.
-The array ``dim`` and ``index`` are preserved which is more robust than
+The '`llvm.preserve.array.access.index`' intrinsic returns the getelementptr address
+based on array base `base`, array dimension `dim` and the last access index `index`
+into the array. The return type `ret_type` is a pointer type to the array element.
+The array `dim` and `index` are preserved which is more robust than
getelementptr instruction which may be subject to compiler transformation.
-The ``llvm.preserve.access.index`` type of metadata is attached to this call instruction
+The `llvm.preserve.access.index` type of metadata is attached to this call instruction
to provide array or pointer debuginfo type.
-The metadata is a ``DICompositeType`` or ``DIDerivedType`` representing the
-debuginfo version of ``type``.
+The metadata is a `DICompositeType` or `DIDerivedType` representing the
+debuginfo version of `type`.
-Arguments:
-""""""""""
+##### Arguments:
-The ``base`` is the array base address. The ``dim`` is the array dimension.
-The ``base`` is a pointer if ``dim`` equals 0.
-The ``index`` is the last access index into the array or pointer.
+The `base` is the array base address. The `dim` is the array dimension.
+The `base` is a pointer if `dim` equals 0.
+The `index` is the last access index into the array or pointer.
-The ``base`` argument must be annotated with an :ref:`elementtype
-<attr_elementtype>` attribute at the call-site. This attribute specifies the
+The `base` argument must be annotated with an {ref}`elementtype <attr_elementtype>` attribute at the call-site. This attribute specifies the
getelementptr element type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.preserve.array.access.index``' intrinsic produces the same result
-as a getelementptr with base ``base`` and access operands ``{dim's 0's, index}``.
+The '`llvm.preserve.array.access.index`' intrinsic produces the same result
+as a getelementptr with base `base` and access operands `{dim's 0's, index}`.
-'``llvm.preserve.union.access.index``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
-::
+#### '`llvm.preserve.union.access.index`' Intrinsic
- declare <type>
- @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(<type> base,
- i32 di_index)
+##### Syntax:
+```
+declare <type>
+ at llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(<type> base,
+ i32 di_index)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.preserve.union.access.index``' intrinsic carries the debuginfo field index
-``di_index`` and returns the ``base`` address.
-The ``llvm.preserve.access.index`` type of metadata is attached to this call instruction
+The '`llvm.preserve.union.access.index`' intrinsic carries the debuginfo field index
+`di_index` and returns the `base` address.
+The `llvm.preserve.access.index` type of metadata is attached to this call instruction
to provide union debuginfo type.
-The metadata is a ``DICompositeType`` representing the debuginfo version of ``type``.
-The return type ``type`` is the same as the ``base`` type.
+The metadata is a `DICompositeType` representing the debuginfo version of `type`.
+The return type `type` is the same as the `base` type.
-Arguments:
-""""""""""
+##### Arguments:
-The ``base`` is the union base address. The ``di_index`` is the field index in debuginfo.
+The `base` is the union base address. The `di_index` is the field index in debuginfo.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.preserve.union.access.index``' intrinsic returns the ``base`` address.
+The '`llvm.preserve.union.access.index`' intrinsic returns the `base` address.
-'``llvm.preserve.struct.access.index``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.preserve.struct.access.index`' Intrinsic
-Syntax:
-"""""""
-::
-
- declare <ret_type>
- @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(<type> base,
- i32 gep_index,
- i32 di_index)
+##### Syntax:
+```
+declare <ret_type>
+ at llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(<type> base,
+ i32 gep_index,
+ i32 di_index)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.preserve.struct.access.index``' intrinsic returns the getelementptr address
-based on struct base ``base`` and IR struct member index ``gep_index``.
-The ``llvm.preserve.access.index`` type of metadata is attached to this call instruction
+The '`llvm.preserve.struct.access.index`' intrinsic returns the getelementptr address
+based on struct base `base` and IR struct member index `gep_index`.
+The `llvm.preserve.access.index` type of metadata is attached to this call instruction
to provide struct debuginfo type.
-The metadata is a ``DICompositeType`` representing the debuginfo version of ``type``.
-The return type ``ret_type`` is a pointer type to the structure member.
+The metadata is a `DICompositeType` representing the debuginfo version of `type`.
+The return type `ret_type` is a pointer type to the structure member.
-Arguments:
-""""""""""
+##### Arguments:
-The ``base`` is the structure base address. The ``gep_index`` is the struct member index
-based on IR structures. The ``di_index`` is the struct member index based on debuginfo.
+The `base` is the structure base address. The `gep_index` is the struct member index
+based on IR structures. The `di_index` is the struct member index based on debuginfo.
-The ``base`` argument must be annotated with an :ref:`elementtype
-<attr_elementtype>` attribute at the call-site. This attribute specifies the
+The `base` argument must be annotated with an {ref}`elementtype <attr_elementtype>` attribute at the call-site. This attribute specifies the
getelementptr element type.
-Semantics:
-""""""""""
+##### Semantics:
-The '``llvm.preserve.struct.access.index``' intrinsic produces the same result
-as a getelementptr with base ``base`` and access operands ``{0, gep_index}``.
+The '`llvm.preserve.struct.access.index`' intrinsic produces the same result
+as a getelementptr with base `base` and access operands `{0, gep_index}`.
-'``llvm.protected.field.ptr``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.protected.field.ptr`' Intrinsic
-::
+##### Syntax:
- declare ptr @llvm.protected.field.ptr(ptr ptr, i64 disc, i1 use_hw_encoding)
+```
+declare ptr @llvm.protected.field.ptr(ptr ptr, i64 disc, i1 use_hw_encoding)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.protected.field.ptr``' intrinsic returns a pointer to the
+The '`llvm.protected.field.ptr`' intrinsic returns a pointer to the
storage location of a pointer that has special properties as described
below.
-Arguments:
-""""""""""
+##### Arguments:
The first argument is the pointer specifying the location to store the
pointer. The second argument is the discriminator, which is used as an
input for the pointer encoding. The third argument specifies whether to
use a target-specific mechanism to encode the pointer.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic returns a pointer which may be used to store a
pointer at the specified address that is encoded using the specified
@@ -33026,32 +30227,27 @@ deactivation symbol represents a field identifier.
This intrinsic is used to implement structure protection.
-'``llvm.cond.loop``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#### '`llvm.cond.loop`' Intrinsic
-Syntax:
-"""""""
-
-::
+##### Syntax:
- declare void @llvm.cond.loop(i1 pred)
+```
+declare void @llvm.cond.loop(i1 pred)
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.cond.loop``' intrinsic spins in an infinite loop if the
-given predicate ``pred`` is true, otherwise it does nothing.
+The '`llvm.cond.loop`' intrinsic spins in an infinite loop if the
+given predicate `pred` is true, otherwise it does nothing.
-Arguments:
-""""""""""
+##### Arguments:
-``pred`` is the predicate.
+`pred` is the predicate.
-Semantics:
-""""""""""
+##### Semantics:
This intrinsic is semantically equivalent to a conditional branch
-conditioned on ``pred`` to a basic block consisting only of an
+conditioned on `pred` to a basic block consisting only of an
unconditional branch to itself.
Unlike such a branch, certain backends guarantee that this intrinsic
@@ -33060,7 +30256,7 @@ other introspection mechanism to straightforwardly detect whether
the program is currently spinning in the infinite loop and possibly
terminate the program if so. The intent is that this intrinsic may
be used as a more efficient alternative to a conditional branch to
-a call to ``llvm.trap`` in circumstances where the loop detection
+a call to `llvm.trap` in circumstances where the loop detection
is guaranteed to be present. This construct has been experimentally
determined to be executed more efficiently (when the branch is not taken)
than a conditional branch to a trap instruction on AMD and older Intel
@@ -33074,24 +30270,21 @@ itself. Specifically, the first byte of the instruction will be between
There are currently no guarantees about instructions used by other backends.
-'``llvm.looptrap``' Intrinsic
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Syntax:
-"""""""
+#### '`llvm.looptrap`' Intrinsic
-::
+##### Syntax:
- declare void @llvm.looptrap() cold noreturn nounwind
+```
+declare void @llvm.looptrap() cold noreturn nounwind
+```
-Overview:
-"""""""""
+##### Overview:
-The '``llvm.looptrap``' intrinsic is equivalent to
-``llvm.cond.loop(true)``, but is also considered to be ``noreturn``,
+The '`llvm.looptrap`' intrinsic is equivalent to
+`llvm.cond.loop(true)`, but is also considered to be `noreturn`,
which enables certain optimizations by allowing the optimizer to
assume that a branch leading to a call to this intrinsic was not
taken. A late optimization pass will convert this intrinsic to either
-``llvm.cond.loop(true)`` or ``llvm.cond.loop(pred)``, where ``pred``
+`llvm.cond.loop(true)` or `llvm.cond.loop(pred)`, where `pred`
is a predicate for a conditional branch leading to the intrinsic call,
if possible.
>From 0b46f557fb22545dcffc435b18dfd5a7c2b92fe6 Mon Sep 17 00:00:00 2001
From: Reid Kleckner <rkleckner at nvidia.com>
Date: Mon, 22 Jun 2026 17:00:16 -0700
Subject: [PATCH 2/2] Migrate 11 tables back from list-table to regular
markdown tables
---
llvm/docs/LangRef.md | 284 ++++++++++++-------------------------------
1 file changed, 81 insertions(+), 203 deletions(-)
diff --git a/llvm/docs/LangRef.md b/llvm/docs/LangRef.md
index 5ea1a8bf5f638..578ab381f7962 100644
--- a/llvm/docs/LangRef.md
+++ b/llvm/docs/LangRef.md
@@ -1731,61 +1731,26 @@ Currently, only the following parameter attributes are defined:
indicating zero treatment of input denormals, it does not imply the
value cannot be a denormal value which would compare equal to 0.
- ```{list-table} Recognized test mask names
- :header-rows: 1
-
- * - Name
- - floating-point class
- - Bitmask value
- * - nan
- - Any NaN
- - 3
- * - inf
- - +/- infinity
- - 516
- * - norm
- - +/- normal
- - 264
- * - sub
- - +/- subnormal
- - 144
- * - zero
- - +/- 0
- - 96
- * - all
- - All values
- - 1023
- * - snan
- - Signaling NaN
- - 1
- * - qnan
- - Quiet NaN
- - 2
- * - ninf
- - Negative infinity
- - 4
- * - nnorm
- - Negative normal
- - 8
- * - nsub
- - Negative subnormal
- - 16
- * - nzero
- - Negative zero
- - 32
- * - pzero
- - Positive zero
- - 64
- * - psub
- - Positive subnormal
- - 128
- * - pnorm
- - Positive normal
- - 256
- * - pinf
- - Positive infinity
- - 512
- ```
+ Recognized test mask names:
+
+ | Name | floating-point class | Bitmask value |
+ | --- | --- | --- |
+ | nan | Any NaN | 3 |
+ | inf | +/- infinity | 516 |
+ | norm | +/- normal | 264 |
+ | sub | +/- subnormal | 144 |
+ | zero | +/- 0 | 96 |
+ | all | All values | 1023 |
+ | snan | Signaling NaN | 1 |
+ | qnan | Quiet NaN | 2 |
+ | ninf | Negative infinity | 4 |
+ | nnorm | Negative normal | 8 |
+ | nsub | Negative subnormal | 16 |
+ | nzero | Negative zero | 32 |
+ | pzero | Positive zero | 64 |
+ | psub | Positive subnormal | 128 |
+ | pnorm | Positive normal | 256 |
+ | pinf | Positive infinity | 512 |
`alignstack(<n>)`
: This indicates the alignment that should be considered by the backend when
@@ -4580,16 +4545,11 @@ value.
###### Examples:
-```{list-table}
-:header-rows: 0
-
-* - `i1`
- - a single-bit integer.
-* - `i32`
- - a 32-bit integer.
-* - `i1942652`
- - a really big integer of over 1 million bits.
-```
+| Type | Description |
+| --- | --- |
+| `i1` | a single-bit integer. |
+| `i32` | a 32-bit integer. |
+| `i1942652` | a really big integer of over 1 million bits. |
(t_byte)=
@@ -4634,16 +4594,11 @@ The number of bits the byte occupies is specified by the `N` value.
###### Examples:
-```{list-table}
-:header-rows: 0
-
-* - `b1`
- - a single-bit byte value.
-* - `b32`
- - a 32-bit byte value.
-* - `b128`
- - a 128-bit byte value.
-```
+| Type | Description |
+| --- | --- |
+| `b1` | a single-bit byte value. |
+| `b32` | a 32-bit byte value. |
+| `b128` | a 128-bit byte value. |
(t_floating)=
@@ -4878,20 +4833,13 @@ IR, even if the exact size in bytes cannot be determined until run time.
**Examples:**
-```{list-table}
-:header-rows: 0
-
-* - `<4 x i32>`
- - Vector of 4 32-bit integer values.
-* - `<8 x float>`
- - Vector of 8 32-bit floating-point values.
-* - `<2 x i64>`
- - Vector of 2 64-bit integer values.
-* - `<4 x ptr>`
- - Vector of 4 pointers
-* - `<vscale x 4 x i32>`
- - Vector with a multiple of 4 32-bit integer values.
-```
+| Type | Description |
+| --- | --- |
+| `<4 x i32>` | Vector of 4 32-bit integer values. |
+| `<8 x float>` | Vector of 8 32-bit floating-point values. |
+| `<2 x i64>` | Vector of 2 64-bit integer values. |
+| `<4 x ptr>` | Vector of 4 pointers |
+| `<vscale x 4 x i32>` | Vector with a multiple of 4 32-bit integer values. |
(t_label)=
@@ -4969,29 +4917,19 @@ be any type with a size.
**Examples:**
-```{list-table}
-:header-rows: 0
-
-* - `[40 x i32]`
- - Array of 40 32-bit integer values.
-* - `[41 x i32]`
- - Array of 41 32-bit integer values.
-* - `[4 x i8]`
- - Array of 4 8-bit integer values.
-```
+| Type | Description |
+| --- | --- |
+| `[40 x i32]` | Array of 40 32-bit integer values. |
+| `[41 x i32]` | Array of 41 32-bit integer values. |
+| `[4 x i8]` | Array of 4 8-bit integer values. |
Here are some examples of multidimensional arrays:
-```{list-table}
-:header-rows: 0
-
-* - `[3 x [4 x i32]]`
- - 3x4 array of 32-bit integer values.
-* - `[12 x [10 x float]]`
- - 12x10 array of single precision floating-point values.
-* - `[2 x [3 x [4 x i16]]]`
- - 2x3x4 array of 16-bit integer values.
-```
+|Type|Description|
+|---|---|
+|`[3 x [4 x i32]]`|3x4 array of 32-bit integer values.|
+|`[12 x [10 x float]]`|12x10 array of single precision floating-point values.|
+|`[2 x [3 x [4 x i16]]]`|2x3x4 array of 16-bit integer values.|
There is no restriction on indexing beyond the end of the array implied
by a static type (though there are restrictions on indexing beyond the
@@ -11203,25 +11141,12 @@ arguments must have identical types.
The truth table used for the '`and`' instruction is:
-```{list-table}
-:header-rows: 0
-
-* - In0
- - In1
- - Out
-* - 0
- - 0
- - 0
-* - 0
- - 1
- - 0
-* - 1
- - 0
- - 0
-* - 1
- - 1
- - 1
-```
+| In0 | In1 | Out |
+| --- | --- | --- |
+| 0 | 0 | 0 |
+| 0 | 1 | 0 |
+| 1 | 0 | 0 |
+| 1 | 1 | 1 |
##### Example:
@@ -11257,25 +11182,12 @@ arguments must have identical types.
The truth table used for the '`or`' instruction is:
-```{list-table}
-:header-rows: 0
-
-* - In0
- - In1
- - Out
-* - 0
- - 0
- - 0
-* - 0
- - 1
- - 1
-* - 1
- - 0
- - 1
-* - 1
- - 1
- - 1
-```
+| In0 | In1 | Out |
+| --- | --- | --- |
+| 0 | 0 | 0 |
+| 0 | 1 | 1 |
+| 1 | 0 | 1 |
+| 1 | 1 | 1 |
`disjoint` means that for each bit, that bit is zero in at least one of the
inputs. This allows the Or to be treated as an Add since no carry can occur from
@@ -11317,25 +11229,12 @@ arguments must have identical types.
The truth table used for the '`xor`' instruction is:
-```{list-table}
-:header-rows: 0
-
-* - In0
- - In1
- - Out
-* - 0
- - 0
- - 0
-* - 0
- - 1
- - 1
-* - 1
- - 0
- - 1
-* - 1
- - 1
- - 0
-```
+| In0 | In1 | Out |
+| --- | --- | --- |
+| 0 | 0 | 0 |
+| 0 | 1 | 1 |
+| 1 | 0 | 1 |
+| 1 | 1 | 0 |
##### Example:
@@ -14299,17 +14198,10 @@ statepoint. This is currently only used to mark certain statepoints
as GC transitions. This operand is a 64-bit integer with the following
layout, where bit 0 is the least significant bit:
- ```{list-table}
- :header-rows: 1
-
- * - Bit #
- - Usage
- * - 0
- - Set if the statepoint is a GC transition, cleared
- otherwise.
- * - 1-63
- - Reserved for future use; must be cleared.
- ```
+ | Bit # | Usage |
+ | --- | --- |
+ | 0 | Set if the statepoint is a GC transition, cleared otherwise. |
+ | 1-63 | Reserved for future use; must be cleared. |
The 'call parameters' arguments are simply the arguments which need to
be passed to the call target. They will be lowered according to the
@@ -28467,32 +28359,18 @@ of floating-point values.
The second argument specifies, which tests to perform. It must be a compile-time
integer constant, each bit in which specifies floating-point class:
-```{list-table}
-:header-rows: 1
-
-* - Bit #
- - floating-point class
-* - 0
- - Signaling NaN
-* - 1
- - Quiet NaN
-* - 2
- - Negative infinity
-* - 3
- - Negative normal
-* - 4
- - Negative subnormal
-* - 5
- - Negative zero
-* - 6
- - Positive zero
-* - 7
- - Positive subnormal
-* - 8
- - Positive normal
-* - 9
- - Positive infinity
-```
+| Bit # | floating-point class |
+| --- | --- |
+| 0 | Signaling NaN |
+| 1 | Quiet NaN |
+| 2 | Negative infinity |
+| 3 | Negative normal |
+| 4 | Negative subnormal |
+| 5 | Negative zero |
+| 6 | Positive zero |
+| 7 | Positive subnormal |
+| 8 | Positive normal |
+| 9 | Positive infinity |
##### Semantics:
More information about the llvm-branch-commits
mailing list