================
@@ -3540,6 +3540,41 @@ def CIR_MemCpyOp : CIR_MemOp<"libc.memcpy"> {
 
 // TODO: MemMoveOp
 
+//===----------------------------------------------------------------------===//
+// MemSetOp
+//===----------------------------------------------------------------------===//
+
+def CIR_MemSetOp : CIR_Op<"libc.memset"> {
+  let summary = "Equivalent to libc's `memset`";
+  let description = [{
+    Given the CIR pointer, `dst`, `cir.libc.memset` will set the first `len`
+    bytes of the memory pointed by `dst` to the specified `val`.
+
+    Examples:
+
+    ```mlir
+      // Set 2 bytes from a record to 0:
+      %2 = cir.const #cir.int<2> : !u32i
+      %3 = cir.const #cir.int<0> : !u32i
+      %zero = cir.cast integral %3 : !s32i -> !u8i
+      cir.libc.memset %2 bytes from %record set to %zero : !cir.ptr<!void>,
----------------
andykaylor wrote:

I wasn't sure about the order of changes (whether we are moving towards or away 
from this sort of format), but I verified that this matches what we have for 
the memcpy operation, though now looking again I find myself questioning the 
use of "from" here. The memcpy operation looks like:

`cir.libc.memcpy %2 bytes from %arr to %record`

which is quite clear. It seems that if we are attempting this in memset, it 
should be:

`cir.libc.memset %2 bytes at %record set to %zero`

Or perhaps

`cir.libc.memset %2 bytes at %record to %zero`

https://github.com/llvm/llvm-project/pull/178806
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to