authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-15 02:27:18+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-19 19:15:23+01:00
log2d9a167cd2235ce221a9b3aec23a0e537c151380
tree31edcd6974b2700b2146c4247d8b77be908ee344
parentcbfe00b17df276fcf89faa1bb4380ed7f43156a0
signaturelock-open Commit is signed but in an unrecognized format.

std.Target: rename `defaultCCallingConvention` and `Cpu.Arch.fromCallconv`


11 files changed, 16 insertions(+), 16 deletions(-)

lib/std/Target.zig+2-2
......@@ -1612,7 +1612,7 @@ pub const Cpu = struct {
16121612
16131613 /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies.
16141614 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
1615 pub fn fromCallconv(cc: std.builtin.CallingConvention.Tag) []const Arch {
1615 pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch {
16161616 return switch (cc) {
16171617 .auto,
16181618 .@"async",
......@@ -3032,7 +3032,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
30323032 );
30333033}
30343034
3035pub fn defaultCCallingConvention(target: Target) ?std.builtin.CallingConvention {
3035pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
30363036 return switch (target.cpu.arch) {
30373037 .x86_64 => switch (target.os.tag) {
30383038 .windows, .uefi => .{ .x86_64_win = .{} },
lib/std/builtin.zig+2-2
......@@ -171,7 +171,7 @@ pub const CallingConvention = union(enum(u8)) {
171171
172172 /// This is an alias for the default C calling convention for this target.
173173 /// Functions marked as `extern` or `export` are given this calling convention by default.
174 pub const c = builtin.target.defaultCCallingConvention().?;
174 pub const c = builtin.target.cCallingConvention().?;
175175
176176 pub const winapi: CallingConvention = switch (builtin.target.cpu.arch) {
177177 .x86_64 => .{ .x86_64_win = .{} },
......@@ -482,7 +482,7 @@ pub const CallingConvention = union(enum(u8)) {
482482 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.
483483 /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
484484 pub fn archs(cc: CallingConvention) []const std.Target.Cpu.Arch {
485 return std.Target.Cpu.Arch.fromCallconv(cc);
485 return std.Target.Cpu.Arch.fromCallingConvention(cc);
486486 }
487487
488488 pub fn eql(a: CallingConvention, b: CallingConvention) bool {
src/Sema.zig+3-3
......@@ -9499,11 +9499,11 @@ fn zirFunc(
94999499 break :exported zir_decl.flags.is_export;
95009500 };
95019501 if (fn_is_exported) {
9502 break :cc target.defaultCCallingConvention() orelse {
9502 break :cc target.cCallingConvention() orelse {
95039503 // This target has no default C calling convention. We sometimes trigger a similar
95049504 // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency,
95059505 // let's eval that now and just get the transitive error. (It's guaranteed to error
9506 // because it does the exact `defaultCCallingConvention` call we just did.)
9506 // because it does the exact `cCallingConvention` call we just did.)
95079507 const cc_type = try sema.getBuiltinType("CallingConvention");
95089508 _ = try sema.namespaceLookupVal(
95099509 block,
......@@ -9717,7 +9717,7 @@ fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc:
97179717 _ = options;
97189718 var first = true;
97199719 for (calling_conventions_supporting_var_args) |cc_inner| {
9720 for (std.Target.Cpu.Arch.fromCallconv(cc_inner)) |supported_arch| {
9720 for (std.Target.Cpu.Arch.fromCallingConvention(cc_inner)) |supported_arch| {
97219721 if (supported_arch == ctx.arch) break;
97229722 } else continue; // callconv not supported by this arch
97239723 if (!first) {
src/Type.zig+1-1
......@@ -391,7 +391,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
391391 }
392392 try writer.writeAll(") ");
393393 if (fn_info.cc != .auto) print_cc: {
394 if (zcu.getTarget().defaultCCallingConvention()) |ccc| {
394 if (zcu.getTarget().cCallingConvention()) |ccc| {
395395 if (fn_info.cc.eql(ccc)) {
396396 try writer.writeAll("callconv(.c) ");
397397 break :print_cc;
src/Zcu.zig+1-1
......@@ -3562,7 +3562,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
35623562
35633563 .stage2_llvm => @import("codegen/llvm.zig").toLlvmCallConv(cc, target) != null,
35643564 .stage2_c => ok: {
3565 if (target.defaultCCallingConvention()) |default_c| {
3565 if (target.cCallingConvention()) |default_c| {
35663566 if (cc.eql(default_c)) {
35673567 break :ok true;
35683568 }
src/arch/riscv64/CodeGen.zig+1-1
......@@ -4895,7 +4895,7 @@ fn genCall(
48954895 .lib => |lib| try pt.funcType(.{
48964896 .param_types = lib.param_types,
48974897 .return_type = lib.return_type,
4898 .cc = func.target.defaultCCallingConvention().?,
4898 .cc = func.target.cCallingConvention().?,
48994899 }),
49004900 };
49014901
src/arch/x86_64/CodeGen.zig+1-1
......@@ -12384,7 +12384,7 @@ fn genCall(self: *Self, info: union(enum) {
1238412384 .lib => |lib| try pt.funcType(.{
1238512385 .param_types = lib.param_types,
1238612386 .return_type = lib.return_type,
12387 .cc = self.target.defaultCCallingConvention().?,
12387 .cc = self.target.cCallingConvention().?,
1238812388 }),
1238912389 };
1239012390 const fn_info = zcu.typeToFunc(fn_ty).?;
src/codegen/c.zig+1-1
......@@ -7612,7 +7612,7 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8
76127612 .x86_vectorcall, .x86_64_vectorcall => "vectorcall",
76137613 else => {
76147614 // `Zcu.callconvSupported` means this must be the C callconv.
7615 assert(cc.eql(zcu.getTarget().defaultCCallingConvention().?));
7615 assert(cc.eql(zcu.getTarget().cCallingConvention().?));
76167616 return null;
76177617 },
76187618 };
src/codegen/llvm.zig+2-2
......@@ -11616,7 +11616,7 @@ pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) ?Ca
1161611616 };
1161711617}
1161811618fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Target) ?Builder.CallConv {
11619 if (target.defaultCCallingConvention()) |default_c| {
11619 if (target.cCallingConvention()) |default_c| {
1162011620 if (cc_tag == default_c) {
1162111621 return .ccc;
1162211622 }
......@@ -11668,7 +11668,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Targ
1166811668 .nvptx_kernel => .ptx_kernel,
1166911669
1167011670 // All the calling conventions which LLVM does not have a general representation for.
11671 // Note that these are often still supported through the `defaultCCallingConvention` path above via `ccc`.
11671 // Note that these are often still supported through the `cCallingConvention` path above via `ccc`.
1167211672 .x86_sysv,
1167311673 .x86_win,
1167411674 .x86_thiscall_mingw,
src/link/Coff.zig+1-1
......@@ -1484,7 +1484,7 @@ pub fn updateExports(
14841484 const exported_nav = ip.getNav(exported_nav_index);
14851485 const exported_ty = exported_nav.typeOf(ip);
14861486 if (!ip.isFunctionType(exported_ty)) continue;
1487 const c_cc = target.defaultCCallingConvention().?;
1487 const c_cc = target.cCallingConvention().?;
14881488 const winapi_cc: std.builtin.CallingConvention = switch (target.cpu.arch) {
14891489 .x86 => .{ .x86_stdcall = .{} },
14901490 else => c_cc,
src/link/Dwarf.zig+1-1
......@@ -3399,7 +3399,7 @@ fn updateType(
33993399 try wip_nav.abbrevCode(if (is_nullary) .nullary_func_type else .func_type);
34003400 try wip_nav.strp(name);
34013401 const cc: DW.CC = cc: {
3402 if (zcu.getTarget().defaultCCallingConvention()) |cc| {
3402 if (zcu.getTarget().cCallingConvention()) |cc| {
34033403 if (@as(std.builtin.CallingConvention.Tag, cc) == func_type.cc) {
34043404 break :cc .normal;
34053405 }