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 {...@@ -746,7 +746,9 @@ pub const Inst = struct {
746 /// Dest slice may have any alignment; source pointer may have any alignment.746 /// Dest slice may have any alignment; source pointer may have any alignment.
747 /// The two memory regions must not overlap.747 /// The two memory regions must not overlap.
748 /// Result type is always void.748 /// Result type is always void.
749 ///
749 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.750 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
751 ///
750 /// If the length is compile-time known (due to the destination or752 /// If the length is compile-time known (due to the destination or
751 /// source being a pointer-to-array), then it is guaranteed to be753 /// source being a pointer-to-array), then it is guaranteed to be
752 /// greater than zero.754 /// greater than zero.
...@@ -758,7 +760,9 @@ pub const Inst = struct {...@@ -758,7 +760,9 @@ pub const Inst = struct {
758 /// Dest slice may have any alignment; source pointer may have any alignment.760 /// Dest slice may have any alignment; source pointer may have any alignment.
759 /// The two memory regions may overlap.761 /// The two memory regions may overlap.
760 /// Result type is always void.762 /// Result type is always void.
763 ///
761 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.764 /// Uses the `bin_op` field. LHS is the dest slice. RHS is the source pointer.
765 ///
762 /// If the length is compile-time known (due to the destination or766 /// If the length is compile-time known (due to the destination or
763 /// source being a pointer-to-array), then it is guaranteed to be767 /// source being a pointer-to-array), then it is guaranteed to be
764 /// greater than zero.768 /// greater than zero.
src/arch/wasm/CodeGen.zig+1-2
...@@ -1959,7 +1959,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1959,7 +1959,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1959 .wasm_memory_size => cg.airWasmMemorySize(inst),1959 .wasm_memory_size => cg.airWasmMemorySize(inst),
1960 .wasm_memory_grow => cg.airWasmMemoryGrow(inst),1960 .wasm_memory_grow => cg.airWasmMemoryGrow(inst),
19611961
1962 .memcpy => cg.airMemcpy(inst),1962 .memcpy, .memmove => cg.airMemcpy(inst),
19631963
1964 .ret_addr => cg.airRetAddr(inst),1964 .ret_addr => cg.airRetAddr(inst),
1965 .tag_name => cg.airTagName(inst),1965 .tag_name => cg.airTagName(inst),
...@@ -1983,7 +1983,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1983,7 +1983,6 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1983 .c_va_copy,1983 .c_va_copy,
1984 .c_va_end,1984 .c_va_end,
1985 .c_va_start,1985 .c_va_start,
1986 .memmove,
1987 => |tag| return cg.fail("TODO: Implement wasm inst: {s}", .{@tagName(tag)}),1986 => |tag| return cg.fail("TODO: Implement wasm inst: {s}", .{@tagName(tag)}),
19881987
1989 .atomic_load => cg.airAtomicLoad(inst),1988 .atomic_load => cg.airAtomicLoad(inst),