diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 200cc537ac..d229719568 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 d016a4f136..e874c67eea 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 630101fd07..a3ffe1bc3a 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 509c0325bc..62997d2d93 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 9dfc165e55..3262a22dc8 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 c7f3d6a9e3..517d2e9d9d 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 13486c8660..54c881a487 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 c33aa9d31a..a93204e033 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 7bf43cef54..1964cdf111 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 5a35bb70c3..aa98754a99 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 019e8e03f2..21fe7155a6 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; }