Commit bc797a97b1

mlugg <mlugg@mlugg.co.uk>
2024-10-08 22:16:35
std: update for new `CallingConvention`
The old `CallingConvention` type is replaced with the new `NewCallingConvention`. References to `NewCallingConvention` in the compiler are updated accordingly. In addition, a few parts of the standard library are updated to use the new type correctly.
1 parent 36405b9
lib/std/crypto/25519/field.zig
@@ -6,9 +6,9 @@ const NonCanonicalError = crypto.errors.NonCanonicalError;
 const NotSquareError = crypto.errors.NotSquareError;
 
 // Inline conditionally, when it can result in large code generation.
-const bloaty_inline = switch (builtin.mode) {
-    .ReleaseSafe, .ReleaseFast => .Inline,
-    .Debug, .ReleaseSmall => .Unspecified,
+const bloaty_inline: std.builtin.CallingConvention = switch (builtin.mode) {
+    .ReleaseSafe, .ReleaseFast => .@"inline",
+    .Debug, .ReleaseSmall => .auto,
 };
 
 pub const Fe = struct {
lib/std/os/windows.zig
@@ -2824,10 +2824,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1;
 /// The standard error device. Initially, this is the active console screen buffer, CONOUT$.
 pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1;
 
-pub const WINAPI: std.builtin.CallingConvention = if (native_arch == .x86)
-    .Stdcall
-else
-    .C;
+pub const WINAPI: std.builtin.CallingConvention = .winapi;
 
 pub const BOOL = c_int;
 pub const BOOLEAN = BYTE;
lib/std/builtin.zig
@@ -160,72 +160,20 @@ pub const OptimizeMode = enum {
 /// Deprecated; use OptimizeMode.
 pub const Mode = OptimizeMode;
 
-/// This data structure is used by the Zig language code generation and
-/// therefore must be kept in sync with the compiler implementation.
-pub const CallingConvention = enum(u8) {
-    /// This is the default Zig calling convention used when not using `export` on `fn`
-    /// and no other calling convention is specified.
-    Unspecified,
-    /// Matches the C ABI for the target.
-    /// This is the default calling convention when using `export` on `fn`
-    /// and no other calling convention is specified.
-    C,
-    /// This makes a function not have any function prologue or epilogue,
-    /// making the function itself uncallable in regular Zig code.
-    /// This can be useful when integrating with assembly.
-    Naked,
-    /// Functions with this calling convention are called asynchronously,
-    /// as if called as `async function()`.
-    Async,
-    /// Functions with this calling convention are inlined at all call sites.
-    Inline,
-    /// x86-only.
-    Interrupt,
-    Signal,
-    /// x86-only.
-    Stdcall,
-    /// x86-only.
-    Fastcall,
-    /// x86-only.
-    Vectorcall,
-    /// x86-only.
-    Thiscall,
-    /// ARM Procedure Call Standard (obsolete)
-    /// ARM-only.
-    APCS,
-    /// ARM Architecture Procedure Call Standard (current standard)
-    /// ARM-only.
-    AAPCS,
-    /// ARM Architecture Procedure Call Standard Vector Floating-Point
-    /// ARM-only.
-    AAPCSVFP,
-    /// x86-64-only.
-    SysV,
-    /// x86-64-only.
-    Win64,
-    /// AMD GPU, NVPTX, or SPIR-V kernel
-    Kernel,
-    // Vulkan-only
-    Fragment,
-    Vertex,
-};
-
 /// The calling convention of a function defines how arguments and return values are passed, as well
 /// as any other requirements which callers and callees must respect, such as register preservation
 /// and stack alignment.
 ///
 /// This data structure is used by the Zig language code generation and
 /// therefore must be kept in sync with the compiler implementation.
-///
-/// TODO: this will be renamed `CallingConvention` after an initial zig1.wasm update.
-pub const NewCallingConvention = union(enum(u8)) {
-    pub const Tag = @typeInfo(NewCallingConvention).@"union".tag_type.?;
+pub const CallingConvention = union(enum(u8)) {
+    pub const Tag = @typeInfo(CallingConvention).@"union".tag_type.?;
 
     /// 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 winapi: NewCallingConvention = switch (builtin.target.arch) {
+    pub const winapi: CallingConvention = switch (builtin.target.arch) {
         .x86_64 => .{ .x86_64_win = .{} },
         .x86 => .{ .x86_stdcall = .{} },
         .aarch64, .aarch64_be => .{ .aarch64_aapcs_win = .{} },
@@ -233,7 +181,7 @@ pub const NewCallingConvention = union(enum(u8)) {
         else => unreachable,
     };
 
-    pub const kernel: NewCallingConvention = switch (builtin.target.cpu.arch) {
+    pub const kernel: CallingConvention = switch (builtin.target.cpu.arch) {
         .amdgcn => .amdgcn_kernel,
         .nvptx, .nvptx64 => .nvptx_kernel,
         .spirv, .spirv32, .spirv64 => .spirv_kernel,
@@ -241,53 +189,53 @@ pub const NewCallingConvention = union(enum(u8)) {
     };
 
     /// Deprecated; use `.auto`.
-    pub const Unspecified: NewCallingConvention = .auto;
+    pub const Unspecified: CallingConvention = .auto;
     /// Deprecated; use `.c`.
-    pub const C: NewCallingConvention = .c;
+    pub const C: CallingConvention = .c;
     /// Deprecated; use `.naked`.
-    pub const Naked: NewCallingConvention = .naked;
+    pub const Naked: CallingConvention = .naked;
     /// Deprecated; use `.@"async"`.
-    pub const Async: NewCallingConvention = .@"async";
+    pub const Async: CallingConvention = .@"async";
     /// Deprecated; use `.@"inline"`.
-    pub const Inline: NewCallingConvention = .@"inline";
+    pub const Inline: CallingConvention = .@"inline";
     /// Deprecated; use `.x86_64_interrupt`, `.x86_interrupt`, or `.avr_interrupt`.
-    pub const Interrupt: NewCallingConvention = switch (builtin.target.cpu.arch) {
+    pub const Interrupt: CallingConvention = switch (builtin.target.cpu.arch) {
         .x86_64 => .{ .x86_64_interrupt = .{} },
         .x86 => .{ .x86_interrupt = .{} },
         .avr => .avr_interrupt,
         else => unreachable,
     };
     /// Deprecated; use `.avr_signal`.
-    pub const Signal: NewCallingConvention = .avr_signal;
+    pub const Signal: CallingConvention = .avr_signal;
     /// Deprecated; use `.x86_stdcall`.
-    pub const Stdcall: NewCallingConvention = .{ .x86_stdcall = .{} };
+    pub const Stdcall: CallingConvention = .{ .x86_stdcall = .{} };
     /// Deprecated; use `.x86_fastcall`.
-    pub const Fastcall: NewCallingConvention = .{ .x86_fastcall = .{} };
+    pub const Fastcall: CallingConvention = .{ .x86_fastcall = .{} };
     /// Deprecated; use `.x86_64_vectorcall`, `.x86_vectorcall`, or `aarch64_vfabi`.
-    pub const Vectorcall: NewCallingConvention = switch (builtin.target.cpu.arch) {
+    pub const Vectorcall: CallingConvention = switch (builtin.target.cpu.arch) {
         .x86_64 => .{ .x86_64_vectorcall = .{} },
         .x86 => .{ .x86_vectorcall = .{} },
         .aarch64, .aarch64_be => .{ .aarch64_vfabi = .{} },
         else => unreachable,
     };
     /// Deprecated; use `.x86_thiscall`.
-    pub const Thiscall: NewCallingConvention = .{ .x86_thiscall = .{} };
+    pub const Thiscall: CallingConvention = .{ .x86_thiscall = .{} };
     /// Deprecated; use `.arm_apcs`.
-    pub const APCS: NewCallingConvention = .{ .arm_apcs = .{} };
+    pub const APCS: CallingConvention = .{ .arm_apcs = .{} };
     /// Deprecated; use `.arm_aapcs`.
-    pub const AAPCS: NewCallingConvention = .{ .arm_aapcs = .{} };
+    pub const AAPCS: CallingConvention = .{ .arm_aapcs = .{} };
     /// Deprecated; use `.arm_aapcs_vfp`.
-    pub const AAPCSVFP: NewCallingConvention = .{ .arm_aapcs_vfp = .{} };
+    pub const AAPCSVFP: CallingConvention = .{ .arm_aapcs_vfp = .{} };
     /// Deprecated; use `.x86_64_sysv`.
-    pub const SysV: NewCallingConvention = .{ .x86_64_sysv = .{} };
+    pub const SysV: CallingConvention = .{ .x86_64_sysv = .{} };
     /// Deprecated; use `.x86_64_win`.
-    pub const Win64: NewCallingConvention = .{ .x86_64_win = .{} };
+    pub const Win64: CallingConvention = .{ .x86_64_win = .{} };
     /// Deprecated; use `.kernel`.
-    pub const Kernel: NewCallingConvention = .kernel;
+    pub const Kernel: CallingConvention = .kernel;
     /// Deprecated; use `.spirv_fragment`.
-    pub const Fragment: NewCallingConvention = .spirv_fragment;
+    pub const Fragment: CallingConvention = .spirv_fragment;
     /// Deprecated; use `.spirv_vertex`.
-    pub const Vertex: NewCallingConvention = .spirv_vertex;
+    pub const Vertex: CallingConvention = .spirv_vertex;
 
     /// The default Zig calling convention when neither `export` nor `inline` is specified.
     /// This calling convention makes no guarantees about stack alignment, registers, etc.
@@ -535,9 +483,16 @@ pub const NewCallingConvention = union(enum(u8)) {
     /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`.
     pub const archs = std.Target.Cpu.Arch.fromCallconv;
 
-    pub fn eql(a: NewCallingConvention, b: NewCallingConvention) bool {
+    pub fn eql(a: CallingConvention, b: CallingConvention) bool {
         return std.meta.eql(a, b);
     }
+
+    pub fn withStackAlign(cc: CallingConvention, incoming_stack_alignment: u64) CallingConvention {
+        const tag: CallingConvention.Tag = cc;
+        var result = cc;
+        @field(result, tag).incoming_stack_alignment = incoming_stack_alignment;
+        return result;
+    }
 };
 
 /// This data structure is used by the Zig language code generation and
lib/std/start.zig
@@ -55,7 +55,7 @@ comptime {
             if (builtin.link_libc and @hasDecl(root, "main")) {
                 if (native_arch.isWasm()) {
                     @export(&mainWithoutEnv, .{ .name = "main" });
-                } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
+                } else if (!@typeInfo(@TypeOf(root.main)).@"fn".calling_convention.eql(.c)) {
                     @export(&main, .{ .name = "main" });
                 }
             } else if (native_os == .windows) {
@@ -102,12 +102,11 @@ fn main2() callconv(.C) c_int {
     return 0;
 }
 
-fn _start2() callconv(.C) noreturn {
+fn _start2() callconv(.withStackAlign(.c, 1)) noreturn {
     callMain2();
 }
 
 fn callMain2() noreturn {
-    @setAlignStack(16);
     root.main();
     exit2(0);
 }
@@ -428,8 +427,7 @@ fn _start() callconv(.Naked) noreturn {
     );
 }
 
-fn WinStartup() callconv(std.os.windows.WINAPI) noreturn {
-    @setAlignStack(16);
+fn WinStartup() callconv(.withStackAlign(.winapi, 1)) noreturn {
     if (!builtin.single_threaded and !builtin.link_libc) {
         _ = @import("os/windows/tls.zig");
     }
@@ -439,8 +437,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn {
     std.os.windows.ntdll.RtlExitUserProcess(callMain());
 }
 
-fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn {
-    @setAlignStack(16);
+fn wWinMainCRTStartup() callconv(.withStackAlign(.winapi, 1)) noreturn {
     if (!builtin.single_threaded and !builtin.link_libc) {
         _ = @import("os/windows/tls.zig");
     }
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.NewCallingConvention) []const Arch {
+        pub fn fromCallconv(cc: std.builtin.CallingConvention) []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.NewCallingConvention {
+pub fn defaultCCallingConvention(target: Target) ?std.builtin.CallingConvention {
     return switch (target.cpu.arch) {
         .x86_64 => switch (target.os.tag) {
             .windows, .uefi => .{ .x86_64_win = .{} },
src/arch/riscv64/Lower.zig
@@ -6,7 +6,7 @@ link_mode: std.builtin.LinkMode,
 pic: bool,
 allocator: Allocator,
 mir: Mir,
-cc: std.builtin.NewCallingConvention,
+cc: std.builtin.CallingConvention,
 err_msg: ?*ErrorMsg = null,
 src_loc: Zcu.LazySrcLoc,
 result_insts_len: u8 = undefined,
src/arch/wasm/CodeGen.zig
@@ -1145,7 +1145,7 @@ fn ensureAllocLocal(func: *CodeGen, ty: Type) InnerError!WValue {
 /// Memory is owned by the caller.
 fn genFunctype(
     gpa: Allocator,
-    cc: std.builtin.NewCallingConvention,
+    cc: std.builtin.CallingConvention,
     params: []const InternPool.Index,
     return_type: Type,
     pt: Zcu.PerThread,
@@ -1408,7 +1408,7 @@ fn resolveCallingConventionValues(func: *CodeGen, fn_ty: Type) InnerError!CallWV
     return result;
 }
 
-fn firstParamSRet(cc: std.builtin.NewCallingConvention, return_type: Type, pt: Zcu.PerThread, target: std.Target) bool {
+fn firstParamSRet(cc: std.builtin.CallingConvention, return_type: Type, pt: Zcu.PerThread, target: std.Target) bool {
     switch (cc) {
         .@"inline" => unreachable,
         .auto => return isByRef(return_type, pt, target),
@@ -1424,7 +1424,7 @@ fn firstParamSRet(cc: std.builtin.NewCallingConvention, return_type: Type, pt: Z
 
 /// Lowers a Zig type and its value based on a given calling convention to ensure
 /// it matches the ABI.
-fn lowerArg(func: *CodeGen, cc: std.builtin.NewCallingConvention, ty: Type, value: WValue) !void {
+fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WValue) !void {
     if (cc != .wasm_watc) {
         return func.lowerToStack(value);
     }
src/arch/x86_64/abi.zig
@@ -436,9 +436,9 @@ pub const Win64 = struct {
 };
 
 pub fn resolveCallingConvention(
-    cc: std.builtin.NewCallingConvention,
+    cc: std.builtin.CallingConvention,
     target: std.Target,
-) std.builtin.NewCallingConvention {
+) std.builtin.CallingConvention {
     return switch (cc) {
         .auto => switch (target.os.tag) {
             else => .{ .x86_64_sysv = .{} },
@@ -448,7 +448,7 @@ pub fn resolveCallingConvention(
     };
 }
 
-pub fn getCalleePreservedRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCalleePreservedRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.callee_preserved_regs,
         .x86_64_win => &Win64.callee_preserved_regs,
@@ -456,7 +456,7 @@ pub fn getCalleePreservedRegs(cc: std.builtin.NewCallingConvention) []const Regi
     };
 }
 
-pub fn getCallerPreservedRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCallerPreservedRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.caller_preserved_regs,
         .x86_64_win => &Win64.caller_preserved_regs,
@@ -464,7 +464,7 @@ pub fn getCallerPreservedRegs(cc: std.builtin.NewCallingConvention) []const Regi
     };
 }
 
-pub fn getCAbiIntParamRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCAbiIntParamRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.c_abi_int_param_regs,
         .x86_64_win => &Win64.c_abi_int_param_regs,
@@ -472,7 +472,7 @@ pub fn getCAbiIntParamRegs(cc: std.builtin.NewCallingConvention) []const Registe
     };
 }
 
-pub fn getCAbiSseParamRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCAbiSseParamRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.c_abi_sse_param_regs,
         .x86_64_win => &Win64.c_abi_sse_param_regs,
@@ -480,7 +480,7 @@ pub fn getCAbiSseParamRegs(cc: std.builtin.NewCallingConvention) []const Registe
     };
 }
 
-pub fn getCAbiIntReturnRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCAbiIntReturnRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.c_abi_int_return_regs,
         .x86_64_win => &Win64.c_abi_int_return_regs,
@@ -488,7 +488,7 @@ pub fn getCAbiIntReturnRegs(cc: std.builtin.NewCallingConvention) []const Regist
     };
 }
 
-pub fn getCAbiSseReturnRegs(cc: std.builtin.NewCallingConvention) []const Register {
+pub fn getCAbiSseReturnRegs(cc: std.builtin.CallingConvention) []const Register {
     return switch (cc) {
         .x86_64_sysv => &SysV.c_abi_sse_return_regs,
         .x86_64_win => &Win64.c_abi_sse_return_regs,
src/arch/x86_64/CodeGen.zig
@@ -2694,7 +2694,7 @@ fn setFrameLoc(
     offset.* += self.frame_allocs.items(.abi_size)[frame_i];
 }
 
-fn computeFrameLayout(self: *Self, cc: std.builtin.NewCallingConvention) !FrameLayout {
+fn computeFrameLayout(self: *Self, cc: std.builtin.CallingConvention) !FrameLayout {
     const frame_allocs_len = self.frame_allocs.len;
     try self.frame_locs.resize(self.gpa, frame_allocs_len);
     const stack_frame_order = try self.gpa.alloc(FrameIndex, frame_allocs_len - FrameIndex.named_count);
@@ -3006,7 +3006,7 @@ pub fn spillEflagsIfOccupied(self: *Self) !void {
     }
 }
 
-pub fn spillCallerPreservedRegs(self: *Self, cc: std.builtin.NewCallingConvention) !void {
+pub fn spillCallerPreservedRegs(self: *Self, cc: std.builtin.CallingConvention) !void {
     switch (cc) {
         .x86_64_sysv => try self.spillRegisters(abi.getCallerPreservedRegs(.{ .x86_64_sysv = .{} })),
         .x86_64_win => try self.spillRegisters(abi.getCallerPreservedRegs(.{ .x86_64_win = .{} })),
src/arch/x86_64/Lower.zig
@@ -6,7 +6,7 @@ link_mode: std.builtin.LinkMode,
 pic: bool,
 allocator: std.mem.Allocator,
 mir: Mir,
-cc: std.builtin.NewCallingConvention,
+cc: std.builtin.CallingConvention,
 err_msg: ?*Zcu.ErrorMsg = null,
 src_loc: Zcu.LazySrcLoc,
 result_insts_len: u8 = undefined,
src/codegen/c.zig
@@ -7604,7 +7604,7 @@ fn writeMemoryOrder(w: anytype, order: std.builtin.AtomicOrder) !void {
     return w.writeAll(toMemoryOrder(order));
 }
 
-fn toCallingConvention(cc: std.builtin.NewCallingConvention, zcu: *Zcu) ?[]const u8 {
+fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8 {
     return switch (cc) {
         .auto, .naked => null,
         .x86_stdcall => "stdcall",
src/codegen/llvm.zig
@@ -11595,13 +11595,13 @@ const CallingConventionInfo = struct {
     inreg_param_count: u2 = 0,
 };
 
-pub fn toLlvmCallConv(cc: std.builtin.NewCallingConvention, target: std.Target) ?CallingConventionInfo {
+pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) ?CallingConventionInfo {
     const llvm_cc = toLlvmCallConvTag(cc, target) orelse return null;
     const incoming_stack_alignment: ?u64, const register_params: u2 = switch (cc) {
         inline else => |pl| switch (@TypeOf(pl)) {
             void => .{ null, 0 },
-            std.builtin.NewCallingConvention.CommonOptions => .{ pl.incoming_stack_alignment, 0 },
-            std.builtin.NewCallingConvention.X86RegparmOptions => .{ pl.incoming_stack_alignment, pl.register_params },
+            std.builtin.CallingConvention.CommonOptions => .{ pl.incoming_stack_alignment, 0 },
+            std.builtin.CallingConvention.X86RegparmOptions => .{ pl.incoming_stack_alignment, pl.register_params },
             else => unreachable,
         },
     };
@@ -11615,7 +11615,7 @@ pub fn toLlvmCallConv(cc: std.builtin.NewCallingConvention, target: std.Target)
         .inreg_param_count = register_params,
     };
 }
-fn toLlvmCallConvTag(cc_tag: std.builtin.NewCallingConvention.Tag, target: std.Target) ?Builder.CallConv {
+fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Target) ?Builder.CallConv {
     if (target.defaultCCallingConvention()) |default_c| {
         if (cc_tag == default_c) {
             return .ccc;
@@ -12371,7 +12371,7 @@ fn iterateParamTypes(object: *Object, fn_info: InternPool.Key.FuncType) ParamTyp
 }
 
 fn ccAbiPromoteInt(
-    cc: std.builtin.NewCallingConvention,
+    cc: std.builtin.CallingConvention,
     zcu: *Zcu,
     ty: Type,
 ) ?std.builtin.Signedness {
src/link/Coff.zig
@@ -1485,12 +1485,12 @@ pub fn updateExports(
             const exported_ty = exported_nav.typeOf(ip);
             if (!ip.isFunctionType(exported_ty)) continue;
             const c_cc = target.defaultCCallingConvention().?;
-            const winapi_cc: std.builtin.NewCallingConvention = switch (target.cpu.arch) {
+            const winapi_cc: std.builtin.CallingConvention = switch (target.cpu.arch) {
                 .x86 => .{ .x86_stdcall = .{} },
                 else => c_cc,
             };
             const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(zcu);
-            const CcTag = std.builtin.NewCallingConvention.Tag;
+            const CcTag = std.builtin.CallingConvention.Tag;
             if (@as(CcTag, exported_cc) == @as(CcTag, c_cc) and exp.opts.name.eqlSlice("main", ip) and comp.config.link_libc) {
                 zcu.stage1_flags.have_c_main = true;
             } else if (@as(CcTag, exported_cc) == @as(CcTag, winapi_cc) and target.os.tag == .windows) {
src/link/Dwarf.zig
@@ -3400,7 +3400,7 @@ fn updateType(
             try wip_nav.strp(name);
             const cc: DW.CC = cc: {
                 if (zcu.getTarget().defaultCCallingConvention()) |cc| {
-                    if (@as(std.builtin.NewCallingConvention.Tag, cc) == func_type.cc) {
+                    if (@as(std.builtin.CallingConvention.Tag, cc) == func_type.cc) {
                         break :cc .normal;
                     }
                 }
src/InternPool.zig
@@ -1988,7 +1988,7 @@ pub const Key = union(enum) {
         /// Tells whether a parameter is noalias. See `paramIsNoalias` helper
         /// method for accessing this.
         noalias_bits: u32,
-        cc: std.builtin.NewCallingConvention,
+        cc: std.builtin.CallingConvention,
         is_var_args: bool,
         is_generic: bool,
         is_noinline: bool,
@@ -8526,7 +8526,7 @@ pub const GetFuncTypeKey = struct {
     comptime_bits: u32 = 0,
     noalias_bits: u32 = 0,
     /// `null` means generic.
-    cc: ?std.builtin.NewCallingConvention = .auto,
+    cc: ?std.builtin.CallingConvention = .auto,
     is_var_args: bool = false,
     is_generic: bool = false,
     is_noinline: bool = false,
@@ -8668,7 +8668,7 @@ pub const GetFuncDeclKey = struct {
     rbrace_line: u32,
     lbrace_column: u32,
     rbrace_column: u32,
-    cc: ?std.builtin.NewCallingConvention,
+    cc: ?std.builtin.CallingConvention,
     is_noinline: bool,
 };
 
@@ -8733,7 +8733,7 @@ pub const GetFuncDeclIesKey = struct {
     comptime_bits: u32,
     bare_return_type: Index,
     /// null means generic.
-    cc: ?std.builtin.NewCallingConvention,
+    cc: ?std.builtin.CallingConvention,
     /// null means generic.
     alignment: ?Alignment,
     section_is_generic: bool,
@@ -8948,7 +8948,7 @@ pub const GetFuncInstanceKey = struct {
     comptime_args: []const Index,
     noalias_bits: u32,
     bare_return_type: Index,
-    cc: std.builtin.NewCallingConvention,
+    cc: std.builtin.CallingConvention,
     alignment: Alignment,
     section: OptionalNullTerminatedString,
     is_noinline: bool,
@@ -12226,13 +12226,13 @@ pub fn getErrorValueIfExists(ip: *const InternPool, name: NullTerminatedString)
 }
 
 const PackedCallingConvention = packed struct(u18) {
-    tag: std.builtin.NewCallingConvention.Tag,
+    tag: std.builtin.CallingConvention.Tag,
     /// May be ignored depending on `tag`.
     incoming_stack_alignment: Alignment,
     /// Interpretation depends on `tag`.
     extra: u4,
 
-    fn pack(cc: std.builtin.NewCallingConvention) PackedCallingConvention {
+    fn pack(cc: std.builtin.CallingConvention) PackedCallingConvention {
         return switch (cc) {
             inline else => |pl, tag| switch (@TypeOf(pl)) {
                 void => .{
@@ -12240,27 +12240,27 @@ const PackedCallingConvention = packed struct(u18) {
                     .incoming_stack_alignment = .none, // unused
                     .extra = 0, // unused
                 },
-                std.builtin.NewCallingConvention.CommonOptions => .{
+                std.builtin.CallingConvention.CommonOptions => .{
                     .tag = tag,
                     .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
                     .extra = 0, // unused
                 },
-                std.builtin.NewCallingConvention.X86RegparmOptions => .{
+                std.builtin.CallingConvention.X86RegparmOptions => .{
                     .tag = tag,
                     .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
                     .extra = pl.register_params,
                 },
-                std.builtin.NewCallingConvention.ArmInterruptOptions => .{
+                std.builtin.CallingConvention.ArmInterruptOptions => .{
                     .tag = tag,
                     .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
                     .extra = @intFromEnum(pl.type),
                 },
-                std.builtin.NewCallingConvention.MipsInterruptOptions => .{
+                std.builtin.CallingConvention.MipsInterruptOptions => .{
                     .tag = tag,
                     .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
                     .extra = @intFromEnum(pl.mode),
                 },
-                std.builtin.NewCallingConvention.RiscvInterruptOptions => .{
+                std.builtin.CallingConvention.RiscvInterruptOptions => .{
                     .tag = tag,
                     .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0),
                     .extra = @intFromEnum(pl.level),
@@ -12270,30 +12270,30 @@ const PackedCallingConvention = packed struct(u18) {
         };
     }
 
-    fn unpack(cc: PackedCallingConvention) std.builtin.NewCallingConvention {
+    fn unpack(cc: PackedCallingConvention) std.builtin.CallingConvention {
         @setEvalBranchQuota(400_000);
         return switch (cc.tag) {
             inline else => |tag| @unionInit(
-                std.builtin.NewCallingConvention,
+                std.builtin.CallingConvention,
                 @tagName(tag),
-                switch (std.meta.FieldType(std.builtin.NewCallingConvention, tag)) {
+                switch (std.meta.FieldType(std.builtin.CallingConvention, tag)) {
                     void => {},
-                    std.builtin.NewCallingConvention.CommonOptions => .{
+                    std.builtin.CallingConvention.CommonOptions => .{
                         .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
                     },
-                    std.builtin.NewCallingConvention.X86RegparmOptions => .{
+                    std.builtin.CallingConvention.X86RegparmOptions => .{
                         .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
                         .register_params = @intCast(cc.extra),
                     },
-                    std.builtin.NewCallingConvention.ArmInterruptOptions => .{
+                    std.builtin.CallingConvention.ArmInterruptOptions => .{
                         .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
                         .type = @enumFromInt(cc.extra),
                     },
-                    std.builtin.NewCallingConvention.MipsInterruptOptions => .{
+                    std.builtin.CallingConvention.MipsInterruptOptions => .{
                         .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
                         .mode = @enumFromInt(cc.extra),
                     },
-                    std.builtin.NewCallingConvention.RiscvInterruptOptions => .{
+                    std.builtin.CallingConvention.RiscvInterruptOptions => .{
                         .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(),
                         .level = @enumFromInt(cc.extra),
                     },
src/Sema.zig
@@ -2703,9 +2703,9 @@ fn analyzeValueAsCallconv(
     block: *Block,
     src: LazySrcLoc,
     unresolved_val: Value,
-) !std.builtin.NewCallingConvention {
+) !std.builtin.CallingConvention {
     const resolved_val = try sema.resolveLazyValue(unresolved_val);
-    return resolved_val.interpret(std.builtin.NewCallingConvention, sema.pt) catch |err| switch (err) {
+    return resolved_val.interpret(std.builtin.CallingConvention, sema.pt) catch |err| switch (err) {
         error.OutOfMemory => |e| return e,
         error.UndefinedValue => return sema.failWithUseOfUndef(block, src),
         error.TypeMismatch => @panic("std.builtin is corrupt"),
@@ -9520,7 +9520,7 @@ fn zirFunc(
     // If this instruction has a body, then it's a function declaration, and we decide
     // the callconv based on whether it is exported. Otherwise, the callconv defaults
     // to `.auto`.
-    const cc: std.builtin.NewCallingConvention = if (has_body) cc: {
+    const cc: std.builtin.CallingConvention = if (has_body) cc: {
         const func_decl_cau = if (sema.generic_owner != .none) cau: {
             const generic_owner_fn = zcu.funcInfo(sema.generic_owner);
             // The generic owner definitely has a `Cau` for the corresponding function declaration.
@@ -9686,7 +9686,7 @@ fn handleExternLibName(
 /// These are calling conventions that are confirmed to work with variadic functions.
 /// Any calling conventions not included here are either not yet verified to work with variadic
 /// functions or there are no more other calling conventions that support variadic functions.
-const calling_conventions_supporting_var_args = [_]std.builtin.NewCallingConvention.Tag{
+const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention.Tag{
     .x86_64_sysv,
     .x86_64_win,
     .x86_sysv,
@@ -9738,12 +9738,12 @@ const calling_conventions_supporting_var_args = [_]std.builtin.NewCallingConvent
     .xtensa_call0,
     .xtensa_windowed,
 };
-fn callConvSupportsVarArgs(cc: std.builtin.NewCallingConvention.Tag) bool {
+fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool {
     return for (calling_conventions_supporting_var_args) |supported_cc| {
         if (cc == supported_cc) return true;
     } else false;
 }
-fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.NewCallingConvention.Tag) CompileError!void {
+fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void {
     const CallingConventionsSupportingVarArgsList = struct {
         pub fn format(_: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
             _ = fmt;
@@ -9784,7 +9784,7 @@ fn funcCommon(
     address_space: ?std.builtin.AddressSpace,
     section: Section,
     /// null means generic poison
-    cc: ?std.builtin.NewCallingConvention,
+    cc: ?std.builtin.CallingConvention,
     /// this might be Type.generic_poison
     bare_return_type: Type,
     var_args: bool,
@@ -10141,7 +10141,7 @@ fn finishFunc(
     ret_poison: bool,
     bare_return_type: Type,
     ret_ty_src: LazySrcLoc,
-    cc_resolved: std.builtin.NewCallingConvention,
+    cc_resolved: std.builtin.CallingConvention,
     is_source_decl: bool,
     ret_ty_requires_comptime: bool,
     func_inst: Zir.Inst.Index,
@@ -26744,7 +26744,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
         break :blk .{ .explicit = section_name };
     } else .default;
 
-    const cc: ?std.builtin.NewCallingConvention = if (extra.data.bits.has_cc_body) blk: {
+    const cc: ?std.builtin.CallingConvention = if (extra.data.bits.has_cc_body) blk: {
         const body_len = sema.code.extra[extra_index];
         extra_index += 1;
         const body = sema.code.bodySlice(extra_index, body_len);
@@ -27253,14 +27253,14 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
             ) orelse @panic("std.builtin is corrupt");
         },
         .calling_convention_inline => {
-            comptime assert(@typeInfo(std.builtin.NewCallingConvention.Tag).@"enum".tag_type == u8);
+            comptime assert(@typeInfo(std.builtin.CallingConvention.Tag).@"enum".tag_type == u8);
             const callconv_ty = try sema.getBuiltinType("CallingConvention");
             const callconv_tag_ty = callconv_ty.unionTagType(zcu) orelse @panic("std.builtin is corrupt");
             const inline_tag_val = try pt.enumValue(
                 callconv_tag_ty,
                 (try pt.intValue(
                     Type.u8,
-                    @intFromEnum(std.builtin.NewCallingConvention.@"inline"),
+                    @intFromEnum(std.builtin.CallingConvention.@"inline"),
                 )).toIntern(),
             );
             return sema.coerce(block, callconv_ty, Air.internedToRef(inline_tag_val.toIntern()), src);
@@ -30621,8 +30621,8 @@ const InMemoryCoercionResult = union(enum) {
     };
 
     const CC = struct {
-        actual: std.builtin.NewCallingConvention,
-        wanted: std.builtin.NewCallingConvention,
+        actual: std.builtin.CallingConvention,
+        wanted: std.builtin.CallingConvention,
     };
 
     const BitRange = struct {
@@ -31348,10 +31348,10 @@ fn coerceInMemoryAllowedFns(
 
 fn callconvCoerceAllowed(
     target: std.Target,
-    src_cc: std.builtin.NewCallingConvention,
-    dest_cc: std.builtin.NewCallingConvention,
+    src_cc: std.builtin.CallingConvention,
+    dest_cc: std.builtin.CallingConvention,
 ) bool {
-    const Tag = std.builtin.NewCallingConvention.Tag;
+    const Tag = std.builtin.CallingConvention.Tag;
     if (@as(Tag, src_cc) != @as(Tag, dest_cc)) return false;
 
     switch (src_cc) {
@@ -31364,17 +31364,17 @@ fn callconvCoerceAllowed(
                 if (dest_stack_align < src_stack_align) return false;
             }
             switch (@TypeOf(src_data)) {
-                void, std.builtin.NewCallingConvention.CommonOptions => {},
-                std.builtin.NewCallingConvention.X86RegparmOptions => {
+                void, std.builtin.CallingConvention.CommonOptions => {},
+                std.builtin.CallingConvention.X86RegparmOptions => {
                     if (src_data.register_params != dest_data.register_params) return false;
                 },
-                std.builtin.NewCallingConvention.ArmInterruptOptions => {
+                std.builtin.CallingConvention.ArmInterruptOptions => {
                     if (src_data.type != dest_data.type) return false;
                 },
-                std.builtin.NewCallingConvention.MipsInterruptOptions => {
+                std.builtin.CallingConvention.MipsInterruptOptions => {
                     if (src_data.mode != dest_data.mode) return false;
                 },
-                std.builtin.NewCallingConvention.RiscvInterruptOptions => {
+                std.builtin.CallingConvention.RiscvInterruptOptions => {
                     if (src_data.level != dest_data.level) return false;
                 },
                 else => comptime unreachable,
src/target.zig
@@ -544,7 +544,7 @@ pub fn compilerRtIntAbbrev(bits: u16) []const u8 {
     };
 }
 
-pub fn fnCallConvAllowsZigTypes(cc: std.builtin.NewCallingConvention) bool {
+pub fn fnCallConvAllowsZigTypes(cc: std.builtin.CallingConvention) bool {
     return switch (cc) {
         .auto, .@"async", .@"inline" => true,
         // For now we want to authorize PTX kernel to use zig objects, even if
src/Type.zig
@@ -2493,7 +2493,7 @@ pub fn fnReturnType(ty: Type, zcu: *const Zcu) Type {
 }
 
 /// Asserts the type is a function.
-pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.NewCallingConvention {
+pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.CallingConvention {
     return zcu.intern_pool.indexToKey(ty.toIntern()).func_type.cc;
 }
 
src/Zcu.zig
@@ -3540,7 +3540,7 @@ pub fn maybeUnresolveIes(zcu: *Zcu, func_index: InternPool.Index) !void {
     }
 }
 
-pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.NewCallingConvention) union(enum) {
+pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enum) {
     ok,
     bad_arch: []const std.Target.Cpu.Arch, // value is allowed archs for cc
     bad_backend: std.builtin.CompilerBackend, // value is current backend