[clang] [CIR] Add cir.libc.memcpy Op (PR #176781)
Andrzej WarzyĆski via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 07:41:07 PST 2026
================
@@ -3439,6 +3439,53 @@ def CIR_CopyOp : CIR_Op<"copy",[
}];
}
+//===----------------------------------------------------------------------===//
+// MemCpyOp && MemMoveOp
+//===----------------------------------------------------------------------===//
+
+class CIR_MemOp<string mnemonic> : CIR_Op<mnemonic, [
+ AllTypesMatch<["dst", "src"]>
+]> {
+ dag commonArgs = (ins
+ Arg<CIR_VoidPtrType, "", [MemWrite]>:$dst,
+ Arg<CIR_VoidPtrType, "", [MemRead]>:$src
+ );
+}
+
+def CIR_MemCpyOp : CIR_MemOp<"libc.memcpy"> {
+ let summary = "Equivalent to libc's `memcpy`";
+ let description = [{
+ Given two CIR pointers, `src` and `dst`, `cir.libc.memcpy` will copy `len`
+ bytes from the memory pointed by `src` to the memory pointed by `dst`.
+
+ While `cir.copy` is meant to be used for implicit copies in the code where
+ the length of the copy is known, `cir.memcpy` copies only from and to void
+ pointers, requiring the copy length to be passed as an argument.
----------------
banach-space wrote:
Thanks for the clear, prescriptive comment - that's much appreciated!
https://github.com/llvm/llvm-project/pull/176781
More information about the cfe-commits
mailing list