authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-16 15:58:47+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-17 19:17:56+01:00
loge0f8d4e68e159f3b33ab7397f54379345ec683a9
tree3f076ec7b3885eea1992401ba96b3a43d133ff93
parent9c015e6c2b7b153f1a5897caf872a9428f232b47
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.builtin: Rename CallingConvention.wasm_watc to wasm_mvp.


7 files changed, 19 insertions(+), 20 deletions(-)

lib/std/Target.zig+2-3
...@@ -1794,7 +1794,7 @@ pub const Cpu = struct {...@@ -1794,7 +1794,7 @@ pub const Cpu = struct {
1794 .powerpc_aix_altivec,1794 .powerpc_aix_altivec,
1795 => &.{ .powerpc, .powerpcle },1795 => &.{ .powerpc, .powerpcle },
17961796
1797 .wasm_watc,1797 .wasm_mvp,
1798 => &.{ .wasm64, .wasm32 },1798 => &.{ .wasm64, .wasm32 },
17991799
1800 .arc_sysv,1800 .arc_sysv,
...@@ -3322,8 +3322,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {...@@ -3322,8 +3322,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
3322 .aix => .{ .powerpc_aix = .{} },3322 .aix => .{ .powerpc_aix = .{} },
3323 else => .{ .powerpc_sysv = .{} },3323 else => .{ .powerpc_sysv = .{} },
3324 },3324 },
3325 .wasm32 => .{ .wasm_watc = .{} },3325 .wasm32, .wasm64 => .{ .wasm_mvp = .{} },
3326 .wasm64 => .{ .wasm_watc = .{} },
3327 .arc => .{ .arc_sysv = .{} },3326 .arc => .{ .arc_sysv = .{} },
3328 .avr => .avr_gnu,3327 .avr => .avr_gnu,
3329 .bpfel, .bpfeb => .{ .bpf_std = .{} },3328 .bpfel, .bpfeb => .{ .bpf_std = .{} },
lib/std/builtin.zig+1-1
...@@ -325,7 +325,7 @@ pub const CallingConvention = union(enum(u8)) {...@@ -325,7 +325,7 @@ pub const CallingConvention = union(enum(u8)) {
325 powerpc_aix_altivec: CommonOptions,325 powerpc_aix_altivec: CommonOptions,
326326
327 /// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions.327 /// The standard `wasm32` and `wasm64` calling convention, as specified in the WebAssembly Tool Conventions.
328 wasm_watc: CommonOptions,328 wasm_mvp: CommonOptions,
329329
330 /// The standard `arc` calling convention.330 /// The standard `arc` calling convention.
331 arc_sysv: CommonOptions,331 arc_sysv: CommonOptions,
src/Sema.zig+1-1
...@@ -9425,7 +9425,7 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention...@@ -9425,7 +9425,7 @@ const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention
9425 .powerpc_sysv_altivec,9425 .powerpc_sysv_altivec,
9426 .powerpc_aix,9426 .powerpc_aix,
9427 .powerpc_aix_altivec,9427 .powerpc_aix_altivec,
9428 .wasm_watc,9428 .wasm_mvp,
9429 .arc_sysv,9429 .arc_sysv,
9430 .avr_gnu,9430 .avr_gnu,
9431 .bpf_std,9431 .bpf_std,
src/Zcu.zig+1-1
...@@ -4237,7 +4237,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu...@@ -4237,7 +4237,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
4237 };4237 };
4238 },4238 },
4239 .stage2_wasm => switch (cc) {4239 .stage2_wasm => switch (cc) {
4240 .wasm_watc => |opts| opts.incoming_stack_alignment == null,4240 .wasm_mvp => |opts| opts.incoming_stack_alignment == null,
4241 else => false,4241 else => false,
4242 },4242 },
4243 .stage2_arm => switch (cc) {4243 .stage2_arm => switch (cc) {
src/arch/wasm/CodeGen.zig+8-8
...@@ -1396,7 +1396,7 @@ fn resolveCallingConventionValues(...@@ -1396,7 +1396,7 @@ fn resolveCallingConventionValues(
1396 result.local_index += 1;1396 result.local_index += 1;
1397 }1397 }
1398 },1398 },
1399 .wasm_watc => {1399 .wasm_mvp => {
1400 for (fn_info.param_types.get(ip)) |ty| {1400 for (fn_info.param_types.get(ip)) |ty| {
1401 const ty_classes = abi.classifyType(Type.fromInterned(ty), zcu);1401 const ty_classes = abi.classifyType(Type.fromInterned(ty), zcu);
1402 for (ty_classes) |class| {1402 for (ty_classes) |class| {
...@@ -1421,7 +1421,7 @@ pub fn firstParamSRet(...@@ -1421,7 +1421,7 @@ pub fn firstParamSRet(
1421 switch (cc) {1421 switch (cc) {
1422 .@"inline" => unreachable,1422 .@"inline" => unreachable,
1423 .auto => return isByRef(return_type, zcu, target),1423 .auto => return isByRef(return_type, zcu, target),
1424 .wasm_watc => {1424 .wasm_mvp => {
1425 const ty_classes = abi.classifyType(return_type, zcu);1425 const ty_classes = abi.classifyType(return_type, zcu);
1426 if (ty_classes[0] == .indirect) return true;1426 if (ty_classes[0] == .indirect) return true;
1427 if (ty_classes[0] == .direct and ty_classes[1] == .direct) return true;1427 if (ty_classes[0] == .direct and ty_classes[1] == .direct) return true;
...@@ -1434,7 +1434,7 @@ pub fn firstParamSRet(...@@ -1434,7 +1434,7 @@ pub fn firstParamSRet(
1434/// Lowers a Zig type and its value based on a given calling convention to ensure1434/// Lowers a Zig type and its value based on a given calling convention to ensure
1435/// it matches the ABI.1435/// it matches the ABI.
1436fn lowerArg(cg: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WValue) !void {1436fn lowerArg(cg: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WValue) !void {
1437 if (cc != .wasm_watc) {1437 if (cc != .wasm_mvp) {
1438 return cg.lowerToStack(value);1438 return cg.lowerToStack(value);
1439 }1439 }
14401440
...@@ -2124,7 +2124,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2124,7 +2124,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2124 // to the stack instead2124 // to the stack instead
2125 if (cg.return_value != .none) {2125 if (cg.return_value != .none) {
2126 try cg.store(cg.return_value, operand, ret_ty, 0);2126 try cg.store(cg.return_value, operand, ret_ty, 0);
2127 } else if (fn_info.cc == .wasm_watc and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {2127 } else if (fn_info.cc == .wasm_mvp and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
2128 switch (ret_ty.zigTypeTag(zcu)) {2128 switch (ret_ty.zigTypeTag(zcu)) {
2129 // Aggregate types can be lowered as a singular value2129 // Aggregate types can be lowered as a singular value
2130 .@"struct", .@"union" => {2130 .@"struct", .@"union" => {
...@@ -2268,7 +2268,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie...@@ -2268,7 +2268,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie
2268 } else if (first_param_sret) {2268 } else if (first_param_sret) {
2269 break :result_value sret;2269 break :result_value sret;
2270 // TODO: Make this less fragile and optimize2270 // TODO: Make this less fragile and optimize
2271 } else if (zcu.typeToFunc(fn_ty).?.cc == .wasm_watc and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") {2271 } else if (zcu.typeToFunc(fn_ty).?.cc == .wasm_mvp and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") {
2272 const result_local = try cg.allocLocal(ret_ty);2272 const result_local = try cg.allocLocal(ret_ty);
2273 try cg.addLocal(.local_set, result_local.local.value);2273 try cg.addLocal(.local_set, result_local.local.value);
2274 const scalar_type = abi.scalarType(ret_ty, zcu);2274 const scalar_type = abi.scalarType(ret_ty, zcu);
...@@ -2546,7 +2546,7 @@ fn airArg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2546,7 +2546,7 @@ fn airArg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2546 const arg = cg.args[arg_index];2546 const arg = cg.args[arg_index];
2547 const cc = zcu.typeToFunc(zcu.navValue(cg.owner_nav).typeOf(zcu)).?.cc;2547 const cc = zcu.typeToFunc(zcu.navValue(cg.owner_nav).typeOf(zcu)).?.cc;
2548 const arg_ty = cg.typeOfIndex(inst);2548 const arg_ty = cg.typeOfIndex(inst);
2549 if (cc == .wasm_watc) {2549 if (cc == .wasm_mvp) {
2550 const arg_classes = abi.classifyType(arg_ty, zcu);2550 const arg_classes = abi.classifyType(arg_ty, zcu);
2551 for (arg_classes) |class| {2551 for (arg_classes) |class| {
2552 if (class != .none) {2552 if (class != .none) {
...@@ -7047,7 +7047,7 @@ fn callIntrinsic(...@@ -7047,7 +7047,7 @@ fn callIntrinsic(
70477047
7048 // Always pass over C-ABI7048 // Always pass over C-ABI
70497049
7050 const want_sret_param = firstParamSRet(.{ .wasm_watc = .{} }, return_type, zcu, cg.target);7050 const want_sret_param = firstParamSRet(.{ .wasm_mvp = .{} }, return_type, zcu, cg.target);
7051 // if we want return as first param, we allocate a pointer to stack,7051 // if we want return as first param, we allocate a pointer to stack,
7052 // and emit it as our first argument7052 // and emit it as our first argument
7053 const sret = if (want_sret_param) blk: {7053 const sret = if (want_sret_param) blk: {
...@@ -7060,7 +7060,7 @@ fn callIntrinsic(...@@ -7060,7 +7060,7 @@ fn callIntrinsic(
7060 for (args, 0..) |arg, arg_i| {7060 for (args, 0..) |arg, arg_i| {
7061 assert(!(want_sret_param and arg == .stack));7061 assert(!(want_sret_param and arg == .stack));
7062 assert(Type.fromInterned(param_types[arg_i]).hasRuntimeBitsIgnoreComptime(zcu));7062 assert(Type.fromInterned(param_types[arg_i]).hasRuntimeBitsIgnoreComptime(zcu));
7063 try cg.lowerArg(.{ .wasm_watc = .{} }, Type.fromInterned(param_types[arg_i]), arg);7063 try cg.lowerArg(.{ .wasm_mvp = .{} }, Type.fromInterned(param_types[arg_i]), arg);
7064 }7064 }
70657065
7066 try cg.addInst(.{ .tag = .call_intrinsic, .data = .{ .intrinsic = intrinsic } });7066 try cg.addInst(.{ .tag = .call_intrinsic, .data = .{ .intrinsic = intrinsic } });
src/codegen/llvm.zig+4-4
...@@ -11811,7 +11811,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ...@@ -11811,7 +11811,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
11811 .powerpc_sysv_altivec,11811 .powerpc_sysv_altivec,
11812 .powerpc_aix,11812 .powerpc_aix,
11813 .powerpc_aix_altivec,11813 .powerpc_aix_altivec,
11814 .wasm_watc,11814 .wasm_mvp,
11815 .arc_sysv,11815 .arc_sysv,
11816 .avr_gnu,11816 .avr_gnu,
11817 .bpf_std,11817 .bpf_std,
...@@ -11988,7 +11988,7 @@ fn firstParamSRet(fn_info: InternPool.Key.FuncType, zcu: *Zcu, target: std.Targe...@@ -11988,7 +11988,7 @@ fn firstParamSRet(fn_info: InternPool.Key.FuncType, zcu: *Zcu, target: std.Targe
11988 .x86_64_win => x86_64_abi.classifyWindows(return_type, zcu) == .memory,11988 .x86_64_win => x86_64_abi.classifyWindows(return_type, zcu) == .memory,
11989 .x86_sysv, .x86_win => isByRef(return_type, zcu),11989 .x86_sysv, .x86_win => isByRef(return_type, zcu),
11990 .x86_stdcall => !isScalar(zcu, return_type),11990 .x86_stdcall => !isScalar(zcu, return_type),
11991 .wasm_watc => wasm_c_abi.classifyType(return_type, zcu)[0] == .indirect,11991 .wasm_mvp => wasm_c_abi.classifyType(return_type, zcu)[0] == .indirect,
11992 .aarch64_aapcs,11992 .aarch64_aapcs,
11993 .aarch64_aapcs_darwin,11993 .aarch64_aapcs_darwin,
11994 .aarch64_aapcs_win,11994 .aarch64_aapcs_win,
...@@ -12073,7 +12073,7 @@ fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Error!Bu...@@ -12073,7 +12073,7 @@ fn lowerFnRetTy(o: *Object, fn_info: InternPool.Key.FuncType) Allocator.Error!Bu
12073 return o.builder.structType(.normal, types[0..types_len]);12073 return o.builder.structType(.normal, types[0..types_len]);
12074 },12074 },
12075 },12075 },
12076 .wasm_watc => {12076 .wasm_mvp => {
12077 if (isScalar(zcu, return_type)) {12077 if (isScalar(zcu, return_type)) {
12078 return o.lowerType(return_type);12078 return o.lowerType(return_type);
12079 }12079 }
...@@ -12338,7 +12338,7 @@ const ParamTypeIterator = struct {...@@ -12338,7 +12338,7 @@ const ParamTypeIterator = struct {
12338 },12338 },
12339 }12339 }
12340 },12340 },
12341 .wasm_watc => {12341 .wasm_mvp => {
12342 it.zig_index += 1;12342 it.zig_index += 1;
12343 it.llvm_index += 1;12343 it.llvm_index += 1;
12344 if (isScalar(zcu, ty)) {12344 if (isScalar(zcu, ty)) {
src/link/Wasm.zig+2-2
...@@ -4600,7 +4600,7 @@ fn convertZcuFnType(...@@ -4600,7 +4600,7 @@ fn convertZcuFnType(
4600 if (CodeGen.firstParamSRet(cc, return_type, zcu, target)) {4600 if (CodeGen.firstParamSRet(cc, return_type, zcu, target)) {
4601 try params_buffer.append(gpa, .i32); // memory address is always a 32-bit handle4601 try params_buffer.append(gpa, .i32); // memory address is always a 32-bit handle
4602 } else if (return_type.hasRuntimeBitsIgnoreComptime(zcu)) {4602 } else if (return_type.hasRuntimeBitsIgnoreComptime(zcu)) {
4603 if (cc == .wasm_watc) {4603 if (cc == .wasm_mvp) {
4604 const res_classes = abi.classifyType(return_type, zcu);4604 const res_classes = abi.classifyType(return_type, zcu);
4605 assert(res_classes[0] == .direct and res_classes[1] == .none);4605 assert(res_classes[0] == .direct and res_classes[1] == .none);
4606 const scalar_type = abi.scalarType(return_type, zcu);4606 const scalar_type = abi.scalarType(return_type, zcu);
...@@ -4618,7 +4618,7 @@ fn convertZcuFnType(...@@ -4618,7 +4618,7 @@ fn convertZcuFnType(
4618 if (!param_type.hasRuntimeBitsIgnoreComptime(zcu)) continue;4618 if (!param_type.hasRuntimeBitsIgnoreComptime(zcu)) continue;
46194619
4620 switch (cc) {4620 switch (cc) {
4621 .wasm_watc => {4621 .wasm_mvp => {
4622 const param_classes = abi.classifyType(param_type, zcu);4622 const param_classes = abi.classifyType(param_type, zcu);
4623 if (param_classes[1] == .none) {4623 if (param_classes[1] == .none) {
4624 if (param_classes[0] == .direct) {4624 if (param_classes[0] == .direct) {