[llvm] [IR] Initial introduction of memset_pattern (PR #97583)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 05:10:03 PDT 2024


================
@@ -15230,6 +15230,64 @@ 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_memset_pattern:
+
+'``llvm.memset.pattern``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+This is an overloaded intrinsic. You can use ``llvm.memset_pattern`` on
+any integer bit width that is an integral number of bytes and for different
+address spaces. Not all targets support all bit widths however.
+
+::
+
+      declare void @llvm.memset.pattern.p0.i64.i128(ptr <dest>, i128 <val>,
+                                                    i64 <count>, i1 <isvolatile>)
+
+Overview:
+"""""""""
+
+The '``llvm.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:
+""""""""""
+
+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
+for the first argument.
+
+If the ``isvolatile`` parameter is ``true``, the
+``llvm.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:
+""""""""""
+
+The '``llvm.memset.pattern*``' intrinsic fills memory starting at the
+destination location with the given pattern ``<count>`` times. If the argument
+is known to be aligned to some boundary, this can be specified as an attribute
+on the argument. The pattern fills will respect the endianness of the target:
+i.e. on little endian targets, the least significant byte of the pattern is
+first in memory, while the most significant byte is first in memory for big
+endian targets.
----------------
nikic wrote:

Another thing that could be clarified here is that we increment by the alloc size of the type. (Only relevant for over-aligned types.)

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


More information about the llvm-commits mailing list