diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 200cc537acb51620cfe1278903baff8a7a9c38a6..d229719568e8d7f8828c5ae94bd03ff9854a4b98 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -1612,7 +1612,7 @@ pub const Cpu = struct { /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies. /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`. - pub fn fromCallconv(cc: std.builtin.CallingConvention.Tag) []const Arch { + pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch { return switch (cc) { .auto, .@"async", @@ -3032,7 +3032,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { ); } -pub fn defaultCCallingConvention(target: Target) ?std.builtin.CallingConvention { +pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention { return switch (target.cpu.arch) { .x86_64 => switch (target.os.tag) { .windows, .uefi => .{ .x86_64_win = .{} }, diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index d016a4f136bc39561611ff719550055135179bc2..e874c67eeafe9987ef7e69929c02e19cad17c13a 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -171,7 +171,7 @@ pub const CallingConvention = union(enum(u8)) { /// This is an alias for the default C calling convention for this target. /// Functions marked as `extern` or `export` are given this calling convention by default. - pub const c = builtin.target.defaultCCallingConvention().?; + pub const c = builtin.target.cCallingConvention().?; pub const winapi: CallingConvention = switch (builtin.target.cpu.arch) { .x86_64 => .{ .x86_64_win = .{} }, @@ -482,7 +482,7 @@ pub const CallingConvention = union(enum(u8)) { /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies. /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`. pub fn archs(cc: CallingConvention) []const std.Target.Cpu.Arch { - return std.Target.Cpu.Arch.fromCallconv(cc); + return std.Target.Cpu.Arch.fromCallingConvention(cc); } pub fn eql(a: CallingConvention, b: CallingConvention) bool { diff --git a/src/Sema.zig b/src/Sema.zig index 630101fd0711d32583f4fa79bb6eebdd262ae01f..a3ffe1bc3a2296ecb1ad6b33f02e93536c31467b 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -9499,11 +9499,11 @@ fn zirFunc( break :exported zir_decl.flags.is_export; }; if (fn_is_exported) { - break :cc target.defaultCCallingConvention() orelse { + break :cc target.cCallingConvention() orelse { // This target has no default C calling convention. We sometimes trigger a similar // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency, // let's eval that now and just get the transitive error. (It's guaranteed to error - // because it does the exact `defaultCCallingConvention` call we just did.) + // because it does the exact `cCallingConvention` call we just did.) const cc_type = try sema.getBuiltinType("CallingConvention"); _ = try sema.namespaceLookupVal( block, @@ -9717,7 +9717,7 @@ fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: _ = options; var first = true; for (calling_conventions_supporting_var_args) |cc_inner| { - for (std.Target.Cpu.Arch.fromCallconv(cc_inner)) |supported_arch| { + for (std.Target.Cpu.Arch.fromCallingConvention(cc_inner)) |supported_arch| { if (supported_arch == ctx.arch) break; } else continue; // callconv not supported by this arch if (!first) { diff --git a/src/Type.zig b/src/Type.zig index 509c0325bc470fe25aa4d0e6c480de06e68eb545..62997d2d93675719e3f1fa31946af0fef3844c74 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -391,7 +391,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error } try writer.writeAll(") "); if (fn_info.cc != .auto) print_cc: { - if (zcu.getTarget().defaultCCallingConvention()) |ccc| { + if (zcu.getTarget().cCallingConvention()) |ccc| { if (fn_info.cc.eql(ccc)) { try writer.writeAll("callconv(.c) "); break :print_cc; diff --git a/src/Zcu.zig b/src/Zcu.zig index 9dfc165e55aa6c1267cc87e7437ea4e1276f7a49..3262a22dc84244b3e1228861f6cabe0c7f8b098b 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -3562,7 +3562,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu .stage2_llvm => @import("codegen/llvm.zig").toLlvmCallConv(cc, target) != null, .stage2_c => ok: { - if (target.defaultCCallingConvention()) |default_c| { + if (target.cCallingConvention()) |default_c| { if (cc.eql(default_c)) { break :ok true; } diff --git a/src/arch/riscv64/CodeGen.zig b/src/arch/riscv64/CodeGen.zig index c7f3d6a9e3d8ba48d5b78a3a4e6ca640fc223f7f..517d2e9d9d52199e66e0c3b45da4992ef8ef0fd9 100644 --- a/src/arch/riscv64/CodeGen.zig +++ b/src/arch/riscv64/CodeGen.zig @@ -4895,7 +4895,7 @@ fn genCall( .lib => |lib| try pt.funcType(.{ .param_types = lib.param_types, .return_type = lib.return_type, - .cc = func.target.defaultCCallingConvention().?, + .cc = func.target.cCallingConvention().?, }), }; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 13486c8660d204f262287ce208602c80b2949d8a..54c881a4876069ec95eca76a9cee86c5b3518dbb 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -12384,7 +12384,7 @@ fn genCall(self: *Self, info: union(enum) { .lib => |lib| try pt.funcType(.{ .param_types = lib.param_types, .return_type = lib.return_type, - .cc = self.target.defaultCCallingConvention().?, + .cc = self.target.cCallingConvention().?, }), }; const fn_info = zcu.typeToFunc(fn_ty).?; diff --git a/src/codegen/c.zig b/src/codegen/c.zig index c33aa9d31a39acf5ea167a6e550d25d0896e8e7c..a93204e033c53ad052177e3c2c1f67dfd7f14082 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -7612,7 +7612,7 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8 .x86_vectorcall, .x86_64_vectorcall => "vectorcall", else => { // `Zcu.callconvSupported` means this must be the C callconv. - assert(cc.eql(zcu.getTarget().defaultCCallingConvention().?)); + assert(cc.eql(zcu.getTarget().cCallingConvention().?)); return null; }, }; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 7bf43cef54e9c6a584ccdf6e1c29710c5ef8174e..1964cdf1117ba22d9076cb5344956c7f871b0bbd 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -11616,7 +11616,7 @@ pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) ?Ca }; } fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Target) ?Builder.CallConv { - if (target.defaultCCallingConvention()) |default_c| { + if (target.cCallingConvention()) |default_c| { if (cc_tag == default_c) { return .ccc; } @@ -11668,7 +11668,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ .nvptx_kernel => .ptx_kernel, // All the calling conventions which LLVM does not have a general representation for. - // Note that these are often still supported through the `defaultCCallingConvention` path above via `ccc`. + // Note that these are often still supported through the `cCallingConvention` path above via `ccc`. .x86_sysv, .x86_win, .x86_thiscall_mingw, diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 5a35bb70c34fa4270d495a9fc4045845b466772a..aa98754a99504d865c4feb9ac6b009015562d871 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -1484,7 +1484,7 @@ pub fn updateExports( const exported_nav = ip.getNav(exported_nav_index); const exported_ty = exported_nav.typeOf(ip); if (!ip.isFunctionType(exported_ty)) continue; - const c_cc = target.defaultCCallingConvention().?; + const c_cc = target.cCallingConvention().?; const winapi_cc: std.builtin.CallingConvention = switch (target.cpu.arch) { .x86 => .{ .x86_stdcall = .{} }, else => c_cc, diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 019e8e03f2da008d9410b9f1a48278d8c4374306..21fe7155a6c8c630ad4223327c77a8c1fa1148cc 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -3399,7 +3399,7 @@ fn updateType( try wip_nav.abbrevCode(if (is_nullary) .nullary_func_type else .func_type); try wip_nav.strp(name); const cc: DW.CC = cc: { - if (zcu.getTarget().defaultCCallingConvention()) |cc| { + if (zcu.getTarget().cCallingConvention()) |cc| { if (@as(std.builtin.CallingConvention.Tag, cc) == func_type.cc) { break :cc .normal; }