authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 21:09:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:53-07:00
loga983f5b90f21c09ccc9e3fca1565b1b84b540307
treea07b7d7d91009793d0bb3cc7c3cf99e278af2530
parentc7b4b17ba2795cd01db192a99d926bd01e890e49

wasm backend: memcpy and memmove are the same

both lower to memory.fill operation, which are allowed to overlap

2 files changed, 5 insertions(+), 2 deletions(-)

src/Air.zig+4
......@@ -746,7 +746,9 @@ pub const Inst = struct {
746746 /// Dest slice may have any alignment; source pointer may have any alignment.
747747 /// The two memory regions must not overlap.
748748 /// Result type is always void.
749 ///
749750 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
751 ///
750752 /// If the length is compile-time known (due to the destination or
751753 /// source being a pointer-to-array), then it is guaranteed to be
752754 /// greater than zero.
......@@ -758,7 +760,9 @@ pub const Inst = struct {
758760 /// Dest slice may have any alignment; source pointer may have any alignment.
759761 /// The two memory regions may overlap.
760762 /// Result type is always void.
763 ///
761764 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
765 ///
762766 /// If the length is compile-time known (due to the destination or
763767 /// source being a pointer-to-array), then it is guaranteed to be
764768 /// greater than zero.
src/arch/wasm/CodeGen.zig+1-2
......@@ -1959,7 +1959,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19591959 .wasm_memory_size => cg.airWasmMemorySize(inst),
19601960 .wasm_memory_grow => cg.airWasmMemoryGrow(inst),
19611961
1962 .memcpy => cg.airMemcpy(inst),
1962 .memcpy, .memmove => cg.airMemcpy(inst),
19631963
19641964 .ret_addr => cg.airRetAddr(inst),
19651965 .tag_name => cg.airTagName(inst),
......@@ -1983,7 +1983,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19831983 .c_va_copy,
19841984 .c_va_end,
19851985 .c_va_start,
1986 .memmove,
19871986 => |tag| return cg.fail("TODO: Implement wasm inst: {s}", .{@tagName(tag)}),
19881987
19891988 .atomic_load => cg.airAtomicLoad(inst),