From e0f8d4e68e159f3b33ab7397f54379345ec683a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 16 Feb 2025 15:58:47 +0100 Subject: [PATCH] std.builtin: Rename CallingConvention.wasm_watc to wasm_mvp. --- lib/std/Target.zig | 5 ++--- lib/std/builtin.zig | 2 +- src/Sema.zig | 2 +- src/Zcu.zig | 2 +- src/arch/wasm/CodeGen.zig | 16 ++++++++-------- src/codegen/llvm.zig | 8 ++++---- src/link/Wasm.zig | 4 ++-- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index c74f0afdaf..4ad688bffd 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -1794,7 +1794,7 @@ pub const Cpu = struct { .powerpc_aix_altivec, => &.{ .powerpc, .powerpcle }, - .wasm_watc, + .wasm_mvp, => &.{ .wasm64, .wasm32 }, .arc_sysv, @@ -3322,8 +3322,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention { .aix => .{ .powerpc_aix = .{} }, else => .{ .powerpc_sysv = .{} }, }, - .wasm32 => .{ .wasm_watc = .{} }, - .wasm64 => .{ .wasm_watc = .{} }, + .wasm32, .wasm64 => .{ .wasm_mvp = .{} }, .arc => .{ .arc_sysv = .{} }, .avr => .avr_gnu, .bpfel, .bpfeb => .{ .bpf_std = .{} }, diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 374601fc38..d8bb02dd01 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -325,7 +325,7 @@ pub const CallingConvention = union(enum(u8)) { powerpc_aix_altivec: CommonOptions, /// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions. - wasm_watc: CommonOptions, + wasm_mvp: CommonOptions, /// The standard `arc` calling convention. arc_sysv: CommonOptions, diff --git a/src/Sema.zig b/src/Sema.zig index 1559c12a09..f6793edb9e 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -9425,7 +9425,7 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention .powerpc_sysv_altivec, .powerpc_aix, .powerpc_aix_altivec, - .wasm_watc, + .wasm_mvp, .arc_sysv, .avr_gnu, .bpf_std, diff --git a/src/Zcu.zig b/src/Zcu.zig index a5d21a804b..bac2713240 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -4237,7 +4237,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu }; }, .stage2_wasm => switch (cc) { - .wasm_watc => |opts| opts.incoming_stack_alignment == null, + .wasm_mvp => |opts| opts.incoming_stack_alignment == null, else => false, }, .stage2_arm => switch (cc) { diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 4c94eda9e1..92b860926d 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -1396,7 +1396,7 @@ fn resolveCallingConventionValues( result.local_index += 1; } }, - .wasm_watc => { + .wasm_mvp => { for (fn_info.param_types.get(ip)) |ty| { const ty_classes = abi.classifyType(Type.fromInterned(ty), zcu); for (ty_classes) |class| { @@ -1421,7 +1421,7 @@ pub fn firstParamSRet( switch (cc) { .@"inline" => unreachable, .auto => return isByRef(return_type, zcu, target), - .wasm_watc => { + .wasm_mvp => { const ty_classes = abi.classifyType(return_type, zcu); if (ty_classes[0] == .indirect) return true; if (ty_classes[0] == .direct and ty_classes[1] == .direct) return true; @@ -1434,7 +1434,7 @@ pub fn firstParamSRet( /// Lowers a Zig type and its value based on a given calling convention to ensure /// it matches the ABI. fn lowerArg(cg: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WValue) !void { - if (cc != .wasm_watc) { + if (cc != .wasm_mvp) { return cg.lowerToStack(value); } @@ -2124,7 +2124,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { // to the stack instead if (cg.return_value != .none) { try cg.store(cg.return_value, operand, ret_ty, 0); - } else if (fn_info.cc == .wasm_watc and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { + } else if (fn_info.cc == .wasm_mvp and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { switch (ret_ty.zigTypeTag(zcu)) { // Aggregate types can be lowered as a singular value .@"struct", .@"union" => { @@ -2268,7 +2268,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie } else if (first_param_sret) { break :result_value sret; // TODO: Make this less fragile and optimize - } else if (zcu.typeToFunc(fn_ty).?.cc == .wasm_watc and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") { + } else if (zcu.typeToFunc(fn_ty).?.cc == .wasm_mvp and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") { const result_local = try cg.allocLocal(ret_ty); try cg.addLocal(.local_set, result_local.local.value); const scalar_type = abi.scalarType(ret_ty, zcu); @@ -2546,7 +2546,7 @@ fn airArg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const arg = cg.args[arg_index]; const cc = zcu.typeToFunc(zcu.navValue(cg.owner_nav).typeOf(zcu)).?.cc; const arg_ty = cg.typeOfIndex(inst); - if (cc == .wasm_watc) { + if (cc == .wasm_mvp) { const arg_classes = abi.classifyType(arg_ty, zcu); for (arg_classes) |class| { if (class != .none) { @@ -7047,7 +7047,7 @@ fn callIntrinsic( // Always pass over C-ABI - const want_sret_param = firstParamSRet(.{ .wasm_watc = .{} }, return_type, zcu, cg.target); + const want_sret_param = firstParamSRet(.{ .wasm_mvp = .{} }, return_type, zcu, cg.target); // if we want return as first param, we allocate a pointer to stack, // and emit it as our first argument const sret = if (want_sret_param) blk: { @@ -7060,7 +7060,7 @@ fn callIntrinsic( for (args, 0..) |arg, arg_i| { assert(!(want_sret_param and arg == .stack)); assert(Type.fromInterned(param_types[arg_i]).hasRuntimeBitsIgnoreComptime(zcu)); - try cg.lowerArg(.{ .wasm_watc = .{} }, Type.fromInterned(param_types[arg_i]), arg); + try cg.lowerArg(.{ .wasm_mvp = .{} }, Type.fromInterned(param_types[arg_i]), arg); } try cg.addInst(.{ .tag = .call_intrinsic, .data = .{ .intrinsic = intrinsic } }); diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 9248edc1dc..9fcfe3a4d8 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -11811,7 +11811,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ .powerpc_sysv_altivec, .powerpc_aix, .powerpc_aix_altivec, - .wasm_watc, + .wasm_mvp, .arc_sysv, .avr_gnu, .bpf_std, @@ -11988,7 +11988,7 @@ fn firstParamSRet(fn_info: InternPool.Key.FuncType, zcu: *Zcu, target: std.Targe .x86_64_win => x86_64_abi.classifyWindows(return_type, zcu) == .memory, .x86_sysv, .x86_win => isByRef(return_type, zcu), .x86_stdcall => !isScalar(zcu, return_type), - .wasm_watc => wasm_c_abi.classifyType(return_type, zcu)[0] == .indirect, + .wasm_mvp => wasm_c_abi.classifyType(return_type, zcu)[0] == .indirect, .aarch64_aapcs, .aarch64_aapcs_darwin, .aarch64_aapcs_win, @@ -12073,7 +12073,7 @@ fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Error!Bu return o.builder.structType(.normal, types[0..types_len]); }, }, - .wasm_watc => { + .wasm_mvp => { if (isScalar(zcu, return_type)) { return o.lowerType(return_type); } @@ -12338,7 +12338,7 @@ const ParamTypeIterator = struct { }, } }, - .wasm_watc => { + .wasm_mvp => { it.zig_index += 1; it.llvm_index += 1; if (isScalar(zcu, ty)) { diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 643c9ea952..80efa6b79a 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -4600,7 +4600,7 @@ fn convertZcuFnType( if (CodeGen.firstParamSRet(cc, return_type, zcu, target)) { try params_buffer.append(gpa, .i32); // memory address is always a 32-bit handle } else if (return_type.hasRuntimeBitsIgnoreComptime(zcu)) { - if (cc == .wasm_watc) { + if (cc == .wasm_mvp) { const res_classes = abi.classifyType(return_type, zcu); assert(res_classes[0] == .direct and res_classes[1] == .none); const scalar_type = abi.scalarType(return_type, zcu); @@ -4618,7 +4618,7 @@ fn convertZcuFnType( if (!param_type.hasRuntimeBitsIgnoreComptime(zcu)) continue; switch (cc) { - .wasm_watc => { + .wasm_mvp => { const param_classes = abi.classifyType(param_type, zcu); if (param_classes[1] == .none) { if (param_classes[0] == .direct) {