[llvm-branch-commits] [llvm] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 6 01:18:09 PDT 2025


================
@@ -12521,6 +12521,59 @@ Example:
       %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
 
+.. _i_ptrtoaddr:
+
+'``ptrtoaddr .. to``' Instruction
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+      <result> = ptrtoaddr <ty> <value> to <ty2>             ; yields ty2
+
+Overview:
+"""""""""
+
+The '``ptrtoaddr``' instruction converts the pointer or a vector of
+pointers ``value`` to the underlying integer address (or vector of integers) 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``.
----------------
nikic wrote:

I think the sentence fits better into the arguments sections which currently says "which must be an :ref:`integer <t_integer>` or a vector of integers type." without specifying which integer type specifically it has to be.

https://github.com/llvm/llvm-project/pull/139357


More information about the llvm-branch-commits mailing list