diff options
author | Alex Richardson <alexrichardson@google.com> | 2025-08-08 09:20:59 -0700 |
---|---|---|
committer | Alex Richardson <alexrichardson@google.com> | 2025-08-08 09:20:59 -0700 |
commit | 585d7d43b3543fb255edcaf4681d2ce180f4e314 (patch) | |
tree | 64d4cd15558536d36b351655f5f5ad83d6d4403d /llvm/docs/LangRef.rst | |
parent | a0dcd64920d736f158532ded1d3d6b324a4edfd8 (diff) | |
parent | f7c6c7ce361b8664eee962f10803e92661582176 (diff) | |
download | llvm-users/arichardson/spr/main.capturetracking-handle-ptrtoaddr.zip llvm-users/arichardson/spr/main.capturetracking-handle-ptrtoaddr.tar.gz llvm-users/arichardson/spr/main.capturetracking-handle-ptrtoaddr.tar.bz2 |
[𝘀𝗽𝗿] changes introduced through rebaseusers/arichardson/spr/main.capturetracking-handle-ptrtoaddr
Created using spr 1.3.6-beta.1
[skip ci]
Diffstat (limited to 'llvm/docs/LangRef.rst')
-rw-r--r-- | llvm/docs/LangRef.rst | 143 |
1 files changed, 120 insertions, 23 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 5279e69..2259799 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -26,7 +26,7 @@ readable assembly language representation. This allows LLVM to provide a powerful intermediate representation for efficient compiler transformations and analysis, while providing a natural means to debug and visualize the transformations. The three different forms of LLVM are -all equivalent. This document describes the human readable +all equivalent. This document describes the human-readable representation and notation. The LLVM representation aims to be light-weight and low-level while @@ -413,6 +413,8 @@ added in the future: - On AArch64 the callee preserves all general purpose registers, except X0-X8 and X16-X18. Not allowed with ``nest``. + - On RISC-V the callee preserve x5-x31 except x6, x7 and x28 registers. + The idea behind this convention is to support calls to runtime functions that have a hot path and a cold path. The hot path is usually a small piece of code that doesn't use many registers. The cold path might need to call out to @@ -5173,6 +5175,8 @@ The following is the syntax for constant expressions: 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! @@ -12537,19 +12541,19 @@ Overview: """"""""" The '``ptrtoaddr``' instruction converts the pointer or a vector of -pointers ``value`` to the underlying integer address (or vector of integers) 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. -``ty2`` must be the integer type (or vector of integers) matching the pointer -index width of the address space of ``ty``. +only operates on the index bits of the pointer and ignores all other bits, and +does not capture the provenance of the pointer. 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 an :ref:`integer <t_integer>` or -a vector of integers type. +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``. Semantics: """""""""" @@ -12569,9 +12573,8 @@ 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 i8 ; extracts low 32 bits and truncates - %Y = ptrtoaddr ptr addrspace(1) %P to i64 ; extracts low 32 bits and zero extends - %Z = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i64>; yields vector zero extension of low 32 bits for each pointer + %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: @@ -21340,7 +21343,7 @@ 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`` -after performing the required machine specific adjustments. The pointer +after performing the required machine-specific adjustments. The pointer returned can then be :ref:`bitcast and executed <int_trampoline>`. @@ -24294,6 +24297,92 @@ Examples: %also.r = call <8 x i8> @llvm.masked.load.v8i8.p0(ptr %ptr, i32 2, <8 x i1> %mask, <8 x i8> poison) +.. _int_vp_load_ff: + +'``llvm.vp.load_ff``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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) + +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 fault-first or fault-only-first. + +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 +argument. + +Semantics: +"""""""""" + +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 +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 +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 +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 +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 +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 +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 +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. + +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 +valid to look for the null terminator. If the terminator is not found, the +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>`. + +Examples: +""""""""" + +.. code-block:: text + + %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: '``llvm.vp.store``' Intrinsic @@ -26706,16 +26795,20 @@ object's lifetime. 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 an ``alloca`` instruction. +The first argument is a constant integer, which is ignored and will be removed +in the future. + +The second argument is either a pointer to an ``alloca`` instruction or +a ``poison`` value. Semantics: """""""""" -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. +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 +alive and has an uninitialized value. The stack object is marked as dead when either :ref:`llvm.lifetime.end <int_lifeend>` to the alloca is executed or the function returns. @@ -26746,15 +26839,19 @@ The '``llvm.lifetime.end``' intrinsic specifies the end of a 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 an ``alloca`` instruction. +The first argument is a constant integer, which is ignored and will be removed +in the future. + +The second argument is either a pointer to an ``alloca`` instruction or +a ``poison`` value. Semantics: """""""""" -The stack-allocated object that ``ptr`` points to becomes dead after the call -to this intrinsic. +If ``ptr`` is a ``poison`` value, the intrinsic has no effect. + +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 is no-op. @@ -29431,7 +29528,7 @@ None. Semantics: """""""""" -This intrinsic is lowered to the target dependent trap instruction. If +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. |