| author | |
| committer | |
| log | bc797a97b1f7476b620567ff32b7a396ebdb4c9c |
| tree | 368d8fbb1d1dd5fb0b84b8499392ec4f69ea2693 |
| parent | 36405b9b43237960733a86d0b1eeac1bc047311c |
| signature |
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.19 files changed, 109 insertions(+), 160 deletions(-)
lib/std/Target.zig+2-2| ... | ... | @@ -1612,7 +1612,7 @@ pub const Cpu = struct { |
| 1612 | 1612 | |
| 1613 | 1613 | /// Returns the array of `Arch` to which a specific `std.builtin.CallingConvention` applies. |
| 1614 | 1614 | /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`. |
| 1615 | pub fn fromCallconv(cc: std.builtin.NewCallingConvention) []const Arch { | |
| 1615 | pub fn fromCallconv(cc: std.builtin.CallingConvention) []const Arch { | |
| 1616 | 1616 | return switch (cc) { |
| 1617 | 1617 | .auto, |
| 1618 | 1618 | .@"async", |
| ... | ... | @@ -3032,7 +3032,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { |
| 3032 | 3032 | ); |
| 3033 | 3033 | } |
| 3034 | 3034 | |
| 3035 | pub fn defaultCCallingConvention(target: Target) ?std.builtin.NewCallingConvention { | |
| 3035 | pub fn defaultCCallingConvention(target: Target) ?std.builtin.CallingConvention { | |
| 3036 | 3036 | return switch (target.cpu.arch) { |
| 3037 | 3037 | .x86_64 => switch (target.os.tag) { |
| 3038 | 3038 | .windows, .uefi => .{ .x86_64_win = .{} }, |
lib/std/builtin.zig+31-76| ... | ... | @@ -160,72 +160,20 @@ pub const OptimizeMode = enum { |
| 160 | 160 | /// Deprecated; use OptimizeMode. |
| 161 | 161 | pub const Mode = OptimizeMode; |
| 162 | 162 | |
| 163 | /// This data structure is used by the Zig language code generation and | |
| 164 | /// therefore must be kept in sync with the compiler implementation. | |
| 165 | pub const CallingConvention = enum(u8) { | |
| 166 | /// This is the default Zig calling convention used when not using `export` on `fn` | |
| 167 | /// and no other calling convention is specified. | |
| 168 | Unspecified, | |
| 169 | /// Matches the C ABI for the target. | |
| 170 | /// This is the default calling convention when using `export` on `fn` | |
| 171 | /// and no other calling convention is specified. | |
| 172 | C, | |
| 173 | /// This makes a function not have any function prologue or epilogue, | |
| 174 | /// making the function itself uncallable in regular Zig code. | |
| 175 | /// This can be useful when integrating with assembly. | |
| 176 | Naked, | |
| 177 | /// Functions with this calling convention are called asynchronously, | |
| 178 | /// as if called as `async function()`. | |
| 179 | Async, | |
| 180 | /// Functions with this calling convention are inlined at all call sites. | |
| 181 | Inline, | |
| 182 | /// x86-only. | |
| 183 | Interrupt, | |
| 184 | Signal, | |
| 185 | /// x86-only. | |
| 186 | Stdcall, | |
| 187 | /// x86-only. | |
| 188 | Fastcall, | |
| 189 | /// x86-only. | |
| 190 | Vectorcall, | |
| 191 | /// x86-only. | |
| 192 | Thiscall, | |
| 193 | /// ARM Procedure Call Standard (obsolete) | |
| 194 | /// ARM-only. | |
| 195 | APCS, | |
| 196 | /// ARM Architecture Procedure Call Standard (current standard) | |
| 197 | /// ARM-only. | |
| 198 | AAPCS, | |
| 199 | /// ARM Architecture Procedure Call Standard Vector Floating-Point | |
| 200 | /// ARM-only. | |
| 201 | AAPCSVFP, | |
| 202 | /// x86-64-only. | |
| 203 | SysV, | |
| 204 | /// x86-64-only. | |
| 205 | Win64, | |
| 206 | /// AMD GPU, NVPTX, or SPIR-V kernel | |
| 207 | Kernel, | |
| 208 | // Vulkan-only | |
| 209 | Fragment, | |
| 210 | Vertex, | |
| 211 | }; | |
| 212 | ||
| 213 | 163 | /// The calling convention of a function defines how arguments and return values are passed, as well |
| 214 | 164 | /// as any other requirements which callers and callees must respect, such as register preservation |
| 215 | 165 | /// and stack alignment. |
| 216 | 166 | /// |
| 217 | 167 | /// This data structure is used by the Zig language code generation and |
| 218 | 168 | /// therefore must be kept in sync with the compiler implementation. |
| 219 | /// | |
| 220 | /// TODO: this will be renamed `CallingConvention` after an initial zig1.wasm update. | |
| 221 | pub const NewCallingConvention = union(enum(u8)) { | |
| 222 | pub const Tag = @typeInfo(NewCallingConvention).@"union".tag_type.?; | |
| 169 | pub const CallingConvention = union(enum(u8)) { | |
| 170 | pub const Tag = @typeInfo(CallingConvention).@"union".tag_type.?; | |
| 223 | 171 | |
| 224 | 172 | /// This is an alias for the default C calling convention for this target. |
| 225 | 173 | /// Functions marked as `extern` or `export` are given this calling convention by default. |
| 226 | 174 | pub const c = builtin.target.defaultCCallingConvention().?; |
| 227 | 175 | |
| 228 | pub const winapi: NewCallingConvention = switch (builtin.target.arch) { | |
| 176 | pub const winapi: CallingConvention = switch (builtin.target.arch) { | |
| 229 | 177 | .x86_64 => .{ .x86_64_win = .{} }, |
| 230 | 178 | .x86 => .{ .x86_stdcall = .{} }, |
| 231 | 179 | .aarch64, .aarch64_be => .{ .aarch64_aapcs_win = .{} }, |
| ... | ... | @@ -233,7 +181,7 @@ pub const NewCallingConvention = union(enum(u8)) { |
| 233 | 181 | else => unreachable, |
| 234 | 182 | }; |
| 235 | 183 | |
| 236 | pub const kernel: NewCallingConvention = switch (builtin.target.cpu.arch) { | |
| 184 | pub const kernel: CallingConvention = switch (builtin.target.cpu.arch) { | |
| 237 | 185 | .amdgcn => .amdgcn_kernel, |
| 238 | 186 | .nvptx, .nvptx64 => .nvptx_kernel, |
| 239 | 187 | .spirv, .spirv32, .spirv64 => .spirv_kernel, |
| ... | ... | @@ -241,53 +189,53 @@ pub const NewCallingConvention = union(enum(u8)) { |
| 241 | 189 | }; |
| 242 | 190 | |
| 243 | 191 | /// Deprecated; use `.auto`. |
| 244 | pub const Unspecified: NewCallingConvention = .auto; | |
| 192 | pub const Unspecified: CallingConvention = .auto; | |
| 245 | 193 | /// Deprecated; use `.c`. |
| 246 | pub const C: NewCallingConvention = .c; | |
| 194 | pub const C: CallingConvention = .c; | |
| 247 | 195 | /// Deprecated; use `.naked`. |
| 248 | pub const Naked: NewCallingConvention = .naked; | |
| 196 | pub const Naked: CallingConvention = .naked; | |
| 249 | 197 | /// Deprecated; use `.@"async"`. |
| 250 | pub const Async: NewCallingConvention = .@"async"; | |
| 198 | pub const Async: CallingConvention = .@"async"; | |
| 251 | 199 | /// Deprecated; use `.@"inline"`. |
| 252 | pub const Inline: NewCallingConvention = .@"inline"; | |
| 200 | pub const Inline: CallingConvention = .@"inline"; | |
| 253 | 201 | /// Deprecated; use `.x86_64_interrupt`, `.x86_interrupt`, or `.avr_interrupt`. |
| 254 | pub const Interrupt: NewCallingConvention = switch (builtin.target.cpu.arch) { | |
| 202 | pub const Interrupt: CallingConvention = switch (builtin.target.cpu.arch) { | |
| 255 | 203 | .x86_64 => .{ .x86_64_interrupt = .{} }, |
| 256 | 204 | .x86 => .{ .x86_interrupt = .{} }, |
| 257 | 205 | .avr => .avr_interrupt, |
| 258 | 206 | else => unreachable, |
| 259 | 207 | }; |
| 260 | 208 | /// Deprecated; use `.avr_signal`. |
| 261 | pub const Signal: NewCallingConvention = .avr_signal; | |
| 209 | pub const Signal: CallingConvention = .avr_signal; | |
| 262 | 210 | /// Deprecated; use `.x86_stdcall`. |
| 263 | pub const Stdcall: NewCallingConvention = .{ .x86_stdcall = .{} }; | |
| 211 | pub const Stdcall: CallingConvention = .{ .x86_stdcall = .{} }; | |
| 264 | 212 | /// Deprecated; use `.x86_fastcall`. |
| 265 | pub const Fastcall: NewCallingConvention = .{ .x86_fastcall = .{} }; | |
| 213 | pub const Fastcall: CallingConvention = .{ .x86_fastcall = .{} }; | |
| 266 | 214 | /// Deprecated; use `.x86_64_vectorcall`, `.x86_vectorcall`, or `aarch64_vfabi`. |
| 267 | pub const Vectorcall: NewCallingConvention = switch (builtin.target.cpu.arch) { | |
| 215 | pub const Vectorcall: CallingConvention = switch (builtin.target.cpu.arch) { | |
| 268 | 216 | .x86_64 => .{ .x86_64_vectorcall = .{} }, |
| 269 | 217 | .x86 => .{ .x86_vectorcall = .{} }, |
| 270 | 218 | .aarch64, .aarch64_be => .{ .aarch64_vfabi = .{} }, |
| 271 | 219 | else => unreachable, |
| 272 | 220 | }; |
| 273 | 221 | /// Deprecated; use `.x86_thiscall`. |
| 274 | pub const Thiscall: NewCallingConvention = .{ .x86_thiscall = .{} }; | |
| 222 | pub const Thiscall: CallingConvention = .{ .x86_thiscall = .{} }; | |
| 275 | 223 | /// Deprecated; use `.arm_apcs`. |
| 276 | pub const APCS: NewCallingConvention = .{ .arm_apcs = .{} }; | |
| 224 | pub const APCS: CallingConvention = .{ .arm_apcs = .{} }; | |
| 277 | 225 | /// Deprecated; use `.arm_aapcs`. |
| 278 | pub const AAPCS: NewCallingConvention = .{ .arm_aapcs = .{} }; | |
| 226 | pub const AAPCS: CallingConvention = .{ .arm_aapcs = .{} }; | |
| 279 | 227 | /// Deprecated; use `.arm_aapcs_vfp`. |
| 280 | pub const AAPCSVFP: NewCallingConvention = .{ .arm_aapcs_vfp = .{} }; | |
| 228 | pub const AAPCSVFP: CallingConvention = .{ .arm_aapcs_vfp = .{} }; | |
| 281 | 229 | /// Deprecated; use `.x86_64_sysv`. |
| 282 | pub const SysV: NewCallingConvention = .{ .x86_64_sysv = .{} }; | |
| 230 | pub const SysV: CallingConvention = .{ .x86_64_sysv = .{} }; | |
| 283 | 231 | /// Deprecated; use `.x86_64_win`. |
| 284 | pub const Win64: NewCallingConvention = .{ .x86_64_win = .{} }; | |
| 232 | pub const Win64: CallingConvention = .{ .x86_64_win = .{} }; | |
| 285 | 233 | /// Deprecated; use `.kernel`. |
| 286 | pub const Kernel: NewCallingConvention = .kernel; | |
| 234 | pub const Kernel: CallingConvention = .kernel; | |
| 287 | 235 | /// Deprecated; use `.spirv_fragment`. |
| 288 | pub const Fragment: NewCallingConvention = .spirv_fragment; | |
| 236 | pub const Fragment: CallingConvention = .spirv_fragment; | |
| 289 | 237 | /// Deprecated; use `.spirv_vertex`. |
| 290 | pub const Vertex: NewCallingConvention = .spirv_vertex; | |
| 238 | pub const Vertex: CallingConvention = .spirv_vertex; | |
| 291 | 239 | |
| 292 | 240 | /// The default Zig calling convention when neither `export` nor `inline` is specified. |
| 293 | 241 | /// This calling convention makes no guarantees about stack alignment, registers, etc. |
| ... | ... | @@ -535,9 +483,16 @@ pub const NewCallingConvention = union(enum(u8)) { |
| 535 | 483 | /// Asserts that `cc` is not `.auto`, `.@"async"`, `.naked`, or `.@"inline"`. |
| 536 | 484 | pub const archs = std.Target.Cpu.Arch.fromCallconv; |
| 537 | 485 | |
| 538 | pub fn eql(a: NewCallingConvention, b: NewCallingConvention) bool { | |
| 486 | pub fn eql(a: CallingConvention, b: CallingConvention) bool { | |
| 539 | 487 | return std.meta.eql(a, b); |
| 540 | 488 | } |
| 489 | ||
| 490 | pub fn withStackAlign(cc: CallingConvention, incoming_stack_alignment: u64) CallingConvention { | |
| 491 | const tag: CallingConvention.Tag = cc; | |
| 492 | var result = cc; | |
| 493 | @field(result, tag).incoming_stack_alignment = incoming_stack_alignment; | |
| 494 | return result; | |
| 495 | } | |
| 541 | 496 | }; |
| 542 | 497 | |
| 543 | 498 | /// This data structure is used by the Zig language code generation and |
lib/std/crypto/25519/field.zig+3-3| ... | ... | @@ -6,9 +6,9 @@ const NonCanonicalError = crypto.errors.NonCanonicalError; |
| 6 | 6 | const NotSquareError = crypto.errors.NotSquareError; |
| 7 | 7 | |
| 8 | 8 | // Inline conditionally, when it can result in large code generation. |
| 9 | const bloaty_inline = switch (builtin.mode) { | |
| 10 | .ReleaseSafe, .ReleaseFast => .Inline, | |
| 11 | .Debug, .ReleaseSmall => .Unspecified, | |
| 9 | const bloaty_inline: std.builtin.CallingConvention = switch (builtin.mode) { | |
| 10 | .ReleaseSafe, .ReleaseFast => .@"inline", | |
| 11 | .Debug, .ReleaseSmall => .auto, | |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | 14 | pub const Fe = struct { |
lib/std/os/windows.zig+1-4| ... | ... | @@ -2824,10 +2824,7 @@ pub const STD_OUTPUT_HANDLE = maxInt(DWORD) - 11 + 1; |
| 2824 | 2824 | /// The standard error device. Initially, this is the active console screen buffer, CONOUT$. |
| 2825 | 2825 | pub const STD_ERROR_HANDLE = maxInt(DWORD) - 12 + 1; |
| 2826 | 2826 | |
| 2827 | pub const WINAPI: std.builtin.CallingConvention = if (native_arch == .x86) | |
| 2828 | .Stdcall | |
| 2829 | else | |
| 2830 | .C; | |
| 2827 | pub const WINAPI: std.builtin.CallingConvention = .winapi; | |
| 2831 | 2828 | |
| 2832 | 2829 | pub const BOOL = c_int; |
| 2833 | 2830 | pub const BOOLEAN = BYTE; |
lib/std/start.zig+4-7| ... | ... | @@ -55,7 +55,7 @@ comptime { |
| 55 | 55 | if (builtin.link_libc and @hasDecl(root, "main")) { |
| 56 | 56 | if (native_arch.isWasm()) { |
| 57 | 57 | @export(&mainWithoutEnv, .{ .name = "main" }); |
| 58 | } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) { | |
| 58 | } else if (!@typeInfo(@TypeOf(root.main)).@"fn".calling_convention.eql(.c)) { | |
| 59 | 59 | @export(&main, .{ .name = "main" }); |
| 60 | 60 | } |
| 61 | 61 | } else if (native_os == .windows) { |
| ... | ... | @@ -102,12 +102,11 @@ fn main2() callconv(.C) c_int { |
| 102 | 102 | return 0; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | fn _start2() callconv(.C) noreturn { | |
| 105 | fn _start2() callconv(.withStackAlign(.c, 1)) noreturn { | |
| 106 | 106 | callMain2(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | fn callMain2() noreturn { |
| 110 | @setAlignStack(16); | |
| 111 | 110 | root.main(); |
| 112 | 111 | exit2(0); |
| 113 | 112 | } |
| ... | ... | @@ -428,8 +427,7 @@ fn _start() callconv(.Naked) noreturn { |
| 428 | 427 | ); |
| 429 | 428 | } |
| 430 | 429 | |
| 431 | fn WinStartup() callconv(std.os.windows.WINAPI) noreturn { | |
| 432 | @setAlignStack(16); | |
| 430 | fn WinStartup() callconv(.withStackAlign(.winapi, 1)) noreturn { | |
| 433 | 431 | if (!builtin.single_threaded and !builtin.link_libc) { |
| 434 | 432 | _ = @import("os/windows/tls.zig"); |
| 435 | 433 | } |
| ... | ... | @@ -439,8 +437,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn { |
| 439 | 437 | std.os.windows.ntdll.RtlExitUserProcess(callMain()); |
| 440 | 438 | } |
| 441 | 439 | |
| 442 | fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { | |
| 443 | @setAlignStack(16); | |
| 440 | fn wWinMainCRTStartup() callconv(.withStackAlign(.winapi, 1)) noreturn { | |
| 444 | 441 | if (!builtin.single_threaded and !builtin.link_libc) { |
| 445 | 442 | _ = @import("os/windows/tls.zig"); |
| 446 | 443 | } |
src/InternPool.zig+20-20| ... | ... | @@ -1988,7 +1988,7 @@ pub const Key = union(enum) { |
| 1988 | 1988 | /// Tells whether a parameter is noalias. See `paramIsNoalias` helper |
| 1989 | 1989 | /// method for accessing this. |
| 1990 | 1990 | noalias_bits: u32, |
| 1991 | cc: std.builtin.NewCallingConvention, | |
| 1991 | cc: std.builtin.CallingConvention, | |
| 1992 | 1992 | is_var_args: bool, |
| 1993 | 1993 | is_generic: bool, |
| 1994 | 1994 | is_noinline: bool, |
| ... | ... | @@ -8526,7 +8526,7 @@ pub const GetFuncTypeKey = struct { |
| 8526 | 8526 | comptime_bits: u32 = 0, |
| 8527 | 8527 | noalias_bits: u32 = 0, |
| 8528 | 8528 | /// `null` means generic. |
| 8529 | cc: ?std.builtin.NewCallingConvention = .auto, | |
| 8529 | cc: ?std.builtin.CallingConvention = .auto, | |
| 8530 | 8530 | is_var_args: bool = false, |
| 8531 | 8531 | is_generic: bool = false, |
| 8532 | 8532 | is_noinline: bool = false, |
| ... | ... | @@ -8668,7 +8668,7 @@ pub const GetFuncDeclKey = struct { |
| 8668 | 8668 | rbrace_line: u32, |
| 8669 | 8669 | lbrace_column: u32, |
| 8670 | 8670 | rbrace_column: u32, |
| 8671 | cc: ?std.builtin.NewCallingConvention, | |
| 8671 | cc: ?std.builtin.CallingConvention, | |
| 8672 | 8672 | is_noinline: bool, |
| 8673 | 8673 | }; |
| 8674 | 8674 | |
| ... | ... | @@ -8733,7 +8733,7 @@ pub const GetFuncDeclIesKey = struct { |
| 8733 | 8733 | comptime_bits: u32, |
| 8734 | 8734 | bare_return_type: Index, |
| 8735 | 8735 | /// null means generic. |
| 8736 | cc: ?std.builtin.NewCallingConvention, | |
| 8736 | cc: ?std.builtin.CallingConvention, | |
| 8737 | 8737 | /// null means generic. |
| 8738 | 8738 | alignment: ?Alignment, |
| 8739 | 8739 | section_is_generic: bool, |
| ... | ... | @@ -8948,7 +8948,7 @@ pub const GetFuncInstanceKey = struct { |
| 8948 | 8948 | comptime_args: []const Index, |
| 8949 | 8949 | noalias_bits: u32, |
| 8950 | 8950 | bare_return_type: Index, |
| 8951 | cc: std.builtin.NewCallingConvention, | |
| 8951 | cc: std.builtin.CallingConvention, | |
| 8952 | 8952 | alignment: Alignment, |
| 8953 | 8953 | section: OptionalNullTerminatedString, |
| 8954 | 8954 | is_noinline: bool, |
| ... | ... | @@ -12226,13 +12226,13 @@ pub fn getErrorValueIfExists(ip: *const InternPool, name: NullTerminatedString) |
| 12226 | 12226 | } |
| 12227 | 12227 | |
| 12228 | 12228 | const PackedCallingConvention = packed struct(u18) { |
| 12229 | tag: std.builtin.NewCallingConvention.Tag, | |
| 12229 | tag: std.builtin.CallingConvention.Tag, | |
| 12230 | 12230 | /// May be ignored depending on `tag`. |
| 12231 | 12231 | incoming_stack_alignment: Alignment, |
| 12232 | 12232 | /// Interpretation depends on `tag`. |
| 12233 | 12233 | extra: u4, |
| 12234 | 12234 | |
| 12235 | fn pack(cc: std.builtin.NewCallingConvention) PackedCallingConvention { | |
| 12235 | fn pack(cc: std.builtin.CallingConvention) PackedCallingConvention { | |
| 12236 | 12236 | return switch (cc) { |
| 12237 | 12237 | inline else => |pl, tag| switch (@TypeOf(pl)) { |
| 12238 | 12238 | void => .{ |
| ... | ... | @@ -12240,27 +12240,27 @@ const PackedCallingConvention = packed struct(u18) { |
| 12240 | 12240 | .incoming_stack_alignment = .none, // unused |
| 12241 | 12241 | .extra = 0, // unused |
| 12242 | 12242 | }, |
| 12243 | std.builtin.NewCallingConvention.CommonOptions => .{ | |
| 12243 | std.builtin.CallingConvention.CommonOptions => .{ | |
| 12244 | 12244 | .tag = tag, |
| 12245 | 12245 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12246 | 12246 | .extra = 0, // unused |
| 12247 | 12247 | }, |
| 12248 | std.builtin.NewCallingConvention.X86RegparmOptions => .{ | |
| 12248 | std.builtin.CallingConvention.X86RegparmOptions => .{ | |
| 12249 | 12249 | .tag = tag, |
| 12250 | 12250 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12251 | 12251 | .extra = pl.register_params, |
| 12252 | 12252 | }, |
| 12253 | std.builtin.NewCallingConvention.ArmInterruptOptions => .{ | |
| 12253 | std.builtin.CallingConvention.ArmInterruptOptions => .{ | |
| 12254 | 12254 | .tag = tag, |
| 12255 | 12255 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12256 | 12256 | .extra = @intFromEnum(pl.type), |
| 12257 | 12257 | }, |
| 12258 | std.builtin.NewCallingConvention.MipsInterruptOptions => .{ | |
| 12258 | std.builtin.CallingConvention.MipsInterruptOptions => .{ | |
| 12259 | 12259 | .tag = tag, |
| 12260 | 12260 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12261 | 12261 | .extra = @intFromEnum(pl.mode), |
| 12262 | 12262 | }, |
| 12263 | std.builtin.NewCallingConvention.RiscvInterruptOptions => .{ | |
| 12263 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ | |
| 12264 | 12264 | .tag = tag, |
| 12265 | 12265 | .incoming_stack_alignment = .fromByteUnits(pl.incoming_stack_alignment orelse 0), |
| 12266 | 12266 | .extra = @intFromEnum(pl.level), |
| ... | ... | @@ -12270,30 +12270,30 @@ const PackedCallingConvention = packed struct(u18) { |
| 12270 | 12270 | }; |
| 12271 | 12271 | } |
| 12272 | 12272 | |
| 12273 | fn unpack(cc: PackedCallingConvention) std.builtin.NewCallingConvention { | |
| 12273 | fn unpack(cc: PackedCallingConvention) std.builtin.CallingConvention { | |
| 12274 | 12274 | @setEvalBranchQuota(400_000); |
| 12275 | 12275 | return switch (cc.tag) { |
| 12276 | 12276 | inline else => |tag| @unionInit( |
| 12277 | std.builtin.NewCallingConvention, | |
| 12277 | std.builtin.CallingConvention, | |
| 12278 | 12278 | @tagName(tag), |
| 12279 | switch (std.meta.FieldType(std.builtin.NewCallingConvention, tag)) { | |
| 12279 | switch (std.meta.FieldType(std.builtin.CallingConvention, tag)) { | |
| 12280 | 12280 | void => {}, |
| 12281 | std.builtin.NewCallingConvention.CommonOptions => .{ | |
| 12281 | std.builtin.CallingConvention.CommonOptions => .{ | |
| 12282 | 12282 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12283 | 12283 | }, |
| 12284 | std.builtin.NewCallingConvention.X86RegparmOptions => .{ | |
| 12284 | std.builtin.CallingConvention.X86RegparmOptions => .{ | |
| 12285 | 12285 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12286 | 12286 | .register_params = @intCast(cc.extra), |
| 12287 | 12287 | }, |
| 12288 | std.builtin.NewCallingConvention.ArmInterruptOptions => .{ | |
| 12288 | std.builtin.CallingConvention.ArmInterruptOptions => .{ | |
| 12289 | 12289 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12290 | 12290 | .type = @enumFromInt(cc.extra), |
| 12291 | 12291 | }, |
| 12292 | std.builtin.NewCallingConvention.MipsInterruptOptions => .{ | |
| 12292 | std.builtin.CallingConvention.MipsInterruptOptions => .{ | |
| 12293 | 12293 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12294 | 12294 | .mode = @enumFromInt(cc.extra), |
| 12295 | 12295 | }, |
| 12296 | std.builtin.NewCallingConvention.RiscvInterruptOptions => .{ | |
| 12296 | std.builtin.CallingConvention.RiscvInterruptOptions => .{ | |
| 12297 | 12297 | .incoming_stack_alignment = cc.incoming_stack_alignment.toByteUnits(), |
| 12298 | 12298 | .level = @enumFromInt(cc.extra), |
| 12299 | 12299 | }, |
src/Sema.zig+21-21| ... | ... | @@ -2703,9 +2703,9 @@ fn analyzeValueAsCallconv( |
| 2703 | 2703 | block: *Block, |
| 2704 | 2704 | src: LazySrcLoc, |
| 2705 | 2705 | unresolved_val: Value, |
| 2706 | ) !std.builtin.NewCallingConvention { | |
| 2706 | ) !std.builtin.CallingConvention { | |
| 2707 | 2707 | const resolved_val = try sema.resolveLazyValue(unresolved_val); |
| 2708 | return resolved_val.interpret(std.builtin.NewCallingConvention, sema.pt) catch |err| switch (err) { | |
| 2708 | return resolved_val.interpret(std.builtin.CallingConvention, sema.pt) catch |err| switch (err) { | |
| 2709 | 2709 | error.OutOfMemory => |e| return e, |
| 2710 | 2710 | error.UndefinedValue => return sema.failWithUseOfUndef(block, src), |
| 2711 | 2711 | error.TypeMismatch => @panic("std.builtin is corrupt"), |
| ... | ... | @@ -9520,7 +9520,7 @@ fn zirFunc( |
| 9520 | 9520 | // If this instruction has a body, then it's a function declaration, and we decide |
| 9521 | 9521 | // the callconv based on whether it is exported. Otherwise, the callconv defaults |
| 9522 | 9522 | // to `.auto`. |
| 9523 | const cc: std.builtin.NewCallingConvention = if (has_body) cc: { | |
| 9523 | const cc: std.builtin.CallingConvention = if (has_body) cc: { | |
| 9524 | 9524 | const func_decl_cau = if (sema.generic_owner != .none) cau: { |
| 9525 | 9525 | const generic_owner_fn = zcu.funcInfo(sema.generic_owner); |
| 9526 | 9526 | // The generic owner definitely has a `Cau` for the corresponding function declaration. |
| ... | ... | @@ -9686,7 +9686,7 @@ fn handleExternLibName( |
| 9686 | 9686 | /// These are calling conventions that are confirmed to work with variadic functions. |
| 9687 | 9687 | /// Any calling conventions not included here are either not yet verified to work with variadic |
| 9688 | 9688 | /// functions or there are no more other calling conventions that support variadic functions. |
| 9689 | const calling_conventions_supporting_var_args = [_]std.builtin.NewCallingConvention.Tag{ | |
| 9689 | const calling_conventions_supporting_var_args = [_]std.builtin.CallingConvention.Tag{ | |
| 9690 | 9690 | .x86_64_sysv, |
| 9691 | 9691 | .x86_64_win, |
| 9692 | 9692 | .x86_sysv, |
| ... | ... | @@ -9738,12 +9738,12 @@ const calling_conventions_supporting_var_args = [_]std.builtin.NewCallingConvent |
| 9738 | 9738 | .xtensa_call0, |
| 9739 | 9739 | .xtensa_windowed, |
| 9740 | 9740 | }; |
| 9741 | fn callConvSupportsVarArgs(cc: std.builtin.NewCallingConvention.Tag) bool { | |
| 9741 | fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool { | |
| 9742 | 9742 | return for (calling_conventions_supporting_var_args) |supported_cc| { |
| 9743 | 9743 | if (cc == supported_cc) return true; |
| 9744 | 9744 | } else false; |
| 9745 | 9745 | } |
| 9746 | fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.NewCallingConvention.Tag) CompileError!void { | |
| 9746 | fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void { | |
| 9747 | 9747 | const CallingConventionsSupportingVarArgsList = struct { |
| 9748 | 9748 | pub fn format(_: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
| 9749 | 9749 | _ = fmt; |
| ... | ... | @@ -9784,7 +9784,7 @@ fn funcCommon( |
| 9784 | 9784 | address_space: ?std.builtin.AddressSpace, |
| 9785 | 9785 | section: Section, |
| 9786 | 9786 | /// null means generic poison |
| 9787 | cc: ?std.builtin.NewCallingConvention, | |
| 9787 | cc: ?std.builtin.CallingConvention, | |
| 9788 | 9788 | /// this might be Type.generic_poison |
| 9789 | 9789 | bare_return_type: Type, |
| 9790 | 9790 | var_args: bool, |
| ... | ... | @@ -10141,7 +10141,7 @@ fn finishFunc( |
| 10141 | 10141 | ret_poison: bool, |
| 10142 | 10142 | bare_return_type: Type, |
| 10143 | 10143 | ret_ty_src: LazySrcLoc, |
| 10144 | cc_resolved: std.builtin.NewCallingConvention, | |
| 10144 | cc_resolved: std.builtin.CallingConvention, | |
| 10145 | 10145 | is_source_decl: bool, |
| 10146 | 10146 | ret_ty_requires_comptime: bool, |
| 10147 | 10147 | func_inst: Zir.Inst.Index, |
| ... | ... | @@ -26744,7 +26744,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26744 | 26744 | break :blk .{ .explicit = section_name }; |
| 26745 | 26745 | } else .default; |
| 26746 | 26746 | |
| 26747 | const cc: ?std.builtin.NewCallingConvention = if (extra.data.bits.has_cc_body) blk: { | |
| 26747 | const cc: ?std.builtin.CallingConvention = if (extra.data.bits.has_cc_body) blk: { | |
| 26748 | 26748 | const body_len = sema.code.extra[extra_index]; |
| 26749 | 26749 | extra_index += 1; |
| 26750 | 26750 | const body = sema.code.bodySlice(extra_index, body_len); |
| ... | ... | @@ -27253,14 +27253,14 @@ fn zirBuiltinValue(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 27253 | 27253 | ) orelse @panic("std.builtin is corrupt"); |
| 27254 | 27254 | }, |
| 27255 | 27255 | .calling_convention_inline => { |
| 27256 | comptime assert(@typeInfo(std.builtin.NewCallingConvention.Tag).@"enum".tag_type == u8); | |
| 27256 | comptime assert(@typeInfo(std.builtin.CallingConvention.Tag).@"enum".tag_type == u8); | |
| 27257 | 27257 | const callconv_ty = try sema.getBuiltinType("CallingConvention"); |
| 27258 | 27258 | const callconv_tag_ty = callconv_ty.unionTagType(zcu) orelse @panic("std.builtin is corrupt"); |
| 27259 | 27259 | const inline_tag_val = try pt.enumValue( |
| 27260 | 27260 | callconv_tag_ty, |
| 27261 | 27261 | (try pt.intValue( |
| 27262 | 27262 | Type.u8, |
| 27263 | @intFromEnum(std.builtin.NewCallingConvention.@"inline"), | |
| 27263 | @intFromEnum(std.builtin.CallingConvention.@"inline"), | |
| 27264 | 27264 | )).toIntern(), |
| 27265 | 27265 | ); |
| 27266 | 27266 | return sema.coerce(block, callconv_ty, Air.internedToRef(inline_tag_val.toIntern()), src); |
| ... | ... | @@ -30621,8 +30621,8 @@ const InMemoryCoercionResult = union(enum) { |
| 30621 | 30621 | }; |
| 30622 | 30622 | |
| 30623 | 30623 | const CC = struct { |
| 30624 | actual: std.builtin.NewCallingConvention, | |
| 30625 | wanted: std.builtin.NewCallingConvention, | |
| 30624 | actual: std.builtin.CallingConvention, | |
| 30625 | wanted: std.builtin.CallingConvention, | |
| 30626 | 30626 | }; |
| 30627 | 30627 | |
| 30628 | 30628 | const BitRange = struct { |
| ... | ... | @@ -31348,10 +31348,10 @@ fn coerceInMemoryAllowedFns( |
| 31348 | 31348 | |
| 31349 | 31349 | fn callconvCoerceAllowed( |
| 31350 | 31350 | target: std.Target, |
| 31351 | src_cc: std.builtin.NewCallingConvention, | |
| 31352 | dest_cc: std.builtin.NewCallingConvention, | |
| 31351 | src_cc: std.builtin.CallingConvention, | |
| 31352 | dest_cc: std.builtin.CallingConvention, | |
| 31353 | 31353 | ) bool { |
| 31354 | const Tag = std.builtin.NewCallingConvention.Tag; | |
| 31354 | const Tag = std.builtin.CallingConvention.Tag; | |
| 31355 | 31355 | if (@as(Tag, src_cc) != @as(Tag, dest_cc)) return false; |
| 31356 | 31356 | |
| 31357 | 31357 | switch (src_cc) { |
| ... | ... | @@ -31364,17 +31364,17 @@ fn callconvCoerceAllowed( |
| 31364 | 31364 | if (dest_stack_align < src_stack_align) return false; |
| 31365 | 31365 | } |
| 31366 | 31366 | switch (@TypeOf(src_data)) { |
| 31367 | void, std.builtin.NewCallingConvention.CommonOptions => {}, | |
| 31368 | std.builtin.NewCallingConvention.X86RegparmOptions => { | |
| 31367 | void, std.builtin.CallingConvention.CommonOptions => {}, | |
| 31368 | std.builtin.CallingConvention.X86RegparmOptions => { | |
| 31369 | 31369 | if (src_data.register_params != dest_data.register_params) return false; |
| 31370 | 31370 | }, |
| 31371 | std.builtin.NewCallingConvention.ArmInterruptOptions => { | |
| 31371 | std.builtin.CallingConvention.ArmInterruptOptions => { | |
| 31372 | 31372 | if (src_data.type != dest_data.type) return false; |
| 31373 | 31373 | }, |
| 31374 | std.builtin.NewCallingConvention.MipsInterruptOptions => { | |
| 31374 | std.builtin.CallingConvention.MipsInterruptOptions => { | |
| 31375 | 31375 | if (src_data.mode != dest_data.mode) return false; |
| 31376 | 31376 | }, |
| 31377 | std.builtin.NewCallingConvention.RiscvInterruptOptions => { | |
| 31377 | std.builtin.CallingConvention.RiscvInterruptOptions => { | |
| 31378 | 31378 | if (src_data.level != dest_data.level) return false; |
| 31379 | 31379 | }, |
| 31380 | 31380 | else => comptime unreachable, |
src/Type.zig+1-1| ... | ... | @@ -2493,7 +2493,7 @@ pub fn fnReturnType(ty: Type, zcu: *const Zcu) Type { |
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | 2495 | /// Asserts the type is a function. |
| 2496 | pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.NewCallingConvention { | |
| 2496 | pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.CallingConvention { | |
| 2497 | 2497 | return zcu.intern_pool.indexToKey(ty.toIntern()).func_type.cc; |
| 2498 | 2498 | } |
| 2499 | 2499 |
src/Zcu.zig+1-1| ... | ... | @@ -3540,7 +3540,7 @@ pub fn maybeUnresolveIes(zcu: *Zcu, func_index: InternPool.Index) !void { |
| 3540 | 3540 | } |
| 3541 | 3541 | } |
| 3542 | 3542 | |
| 3543 | pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.NewCallingConvention) union(enum) { | |
| 3543 | pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enum) { | |
| 3544 | 3544 | ok, |
| 3545 | 3545 | bad_arch: []const std.Target.Cpu.Arch, // value is allowed archs for cc |
| 3546 | 3546 | bad_backend: std.builtin.CompilerBackend, // value is current backend |
src/arch/riscv64/Lower.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ link_mode: std.builtin.LinkMode, |
| 6 | 6 | pic: bool, |
| 7 | 7 | allocator: Allocator, |
| 8 | 8 | mir: Mir, |
| 9 | cc: std.builtin.NewCallingConvention, | |
| 9 | cc: std.builtin.CallingConvention, | |
| 10 | 10 | err_msg: ?*ErrorMsg = null, |
| 11 | 11 | src_loc: Zcu.LazySrcLoc, |
| 12 | 12 | result_insts_len: u8 = undefined, |
src/arch/wasm/CodeGen.zig+3-3| ... | ... | @@ -1145,7 +1145,7 @@ fn ensureAllocLocal(func: *CodeGen, ty: Type) InnerError!WValue { |
| 1145 | 1145 | /// Memory is owned by the caller. |
| 1146 | 1146 | fn genFunctype( |
| 1147 | 1147 | gpa: Allocator, |
| 1148 | cc: std.builtin.NewCallingConvention, | |
| 1148 | cc: std.builtin.CallingConvention, | |
| 1149 | 1149 | params: []const InternPool.Index, |
| 1150 | 1150 | return_type: Type, |
| 1151 | 1151 | pt: Zcu.PerThread, |
| ... | ... | @@ -1408,7 +1408,7 @@ fn resolveCallingConventionValues(func: *CodeGen, fn_ty: Type) InnerError!CallWV |
| 1408 | 1408 | return result; |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | fn firstParamSRet(cc: std.builtin.NewCallingConvention, return_type: Type, pt: Zcu.PerThread, target: std.Target) bool { | |
| 1411 | fn firstParamSRet(cc: std.builtin.CallingConvention, return_type: Type, pt: Zcu.PerThread, target: std.Target) bool { | |
| 1412 | 1412 | switch (cc) { |
| 1413 | 1413 | .@"inline" => unreachable, |
| 1414 | 1414 | .auto => return isByRef(return_type, pt, target), |
| ... | ... | @@ -1424,7 +1424,7 @@ fn firstParamSRet(cc: std.builtin.NewCallingConvention, return_type: Type, pt: Z |
| 1424 | 1424 | |
| 1425 | 1425 | /// Lowers a Zig type and its value based on a given calling convention to ensure |
| 1426 | 1426 | /// it matches the ABI. |
| 1427 | fn lowerArg(func: *CodeGen, cc: std.builtin.NewCallingConvention, ty: Type, value: WValue) !void { | |
| 1427 | fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WValue) !void { | |
| 1428 | 1428 | if (cc != .wasm_watc) { |
| 1429 | 1429 | return func.lowerToStack(value); |
| 1430 | 1430 | } |
src/arch/x86_64/CodeGen.zig+2-2| ... | ... | @@ -2694,7 +2694,7 @@ fn setFrameLoc( |
| 2694 | 2694 | offset.* += self.frame_allocs.items(.abi_size)[frame_i]; |
| 2695 | 2695 | } |
| 2696 | 2696 | |
| 2697 | fn computeFrameLayout(self: *Self, cc: std.builtin.NewCallingConvention) !FrameLayout { | |
| 2697 | fn computeFrameLayout(self: *Self, cc: std.builtin.CallingConvention) !FrameLayout { | |
| 2698 | 2698 | const frame_allocs_len = self.frame_allocs.len; |
| 2699 | 2699 | try self.frame_locs.resize(self.gpa, frame_allocs_len); |
| 2700 | 2700 | 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 { |
| 3006 | 3006 | } |
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | pub fn spillCallerPreservedRegs(self: *Self, cc: std.builtin.NewCallingConvention) !void { | |
| 3009 | pub fn spillCallerPreservedRegs(self: *Self, cc: std.builtin.CallingConvention) !void { | |
| 3010 | 3010 | switch (cc) { |
| 3011 | 3011 | .x86_64_sysv => try self.spillRegisters(abi.getCallerPreservedRegs(.{ .x86_64_sysv = .{} })), |
| 3012 | 3012 | .x86_64_win => try self.spillRegisters(abi.getCallerPreservedRegs(.{ .x86_64_win = .{} })), |
src/arch/x86_64/Lower.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ link_mode: std.builtin.LinkMode, |
| 6 | 6 | pic: bool, |
| 7 | 7 | allocator: std.mem.Allocator, |
| 8 | 8 | mir: Mir, |
| 9 | cc: std.builtin.NewCallingConvention, | |
| 9 | cc: std.builtin.CallingConvention, | |
| 10 | 10 | err_msg: ?*Zcu.ErrorMsg = null, |
| 11 | 11 | src_loc: Zcu.LazySrcLoc, |
| 12 | 12 | result_insts_len: u8 = undefined, |
src/arch/x86_64/abi.zig+8-8| ... | ... | @@ -436,9 +436,9 @@ pub const Win64 = struct { |
| 436 | 436 | }; |
| 437 | 437 | |
| 438 | 438 | pub fn resolveCallingConvention( |
| 439 | cc: std.builtin.NewCallingConvention, | |
| 439 | cc: std.builtin.CallingConvention, | |
| 440 | 440 | target: std.Target, |
| 441 | ) std.builtin.NewCallingConvention { | |
| 441 | ) std.builtin.CallingConvention { | |
| 442 | 442 | return switch (cc) { |
| 443 | 443 | .auto => switch (target.os.tag) { |
| 444 | 444 | else => .{ .x86_64_sysv = .{} }, |
| ... | ... | @@ -448,7 +448,7 @@ pub fn resolveCallingConvention( |
| 448 | 448 | }; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | pub fn getCalleePreservedRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 451 | pub fn getCalleePreservedRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 452 | 452 | return switch (cc) { |
| 453 | 453 | .x86_64_sysv => &SysV.callee_preserved_regs, |
| 454 | 454 | .x86_64_win => &Win64.callee_preserved_regs, |
| ... | ... | @@ -456,7 +456,7 @@ pub fn getCalleePreservedRegs(cc: std.builtin.NewCallingConvention) []const Regi |
| 456 | 456 | }; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | pub fn getCallerPreservedRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 459 | pub fn getCallerPreservedRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 460 | 460 | return switch (cc) { |
| 461 | 461 | .x86_64_sysv => &SysV.caller_preserved_regs, |
| 462 | 462 | .x86_64_win => &Win64.caller_preserved_regs, |
| ... | ... | @@ -464,7 +464,7 @@ pub fn getCallerPreservedRegs(cc: std.builtin.NewCallingConvention) []const Regi |
| 464 | 464 | }; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | pub fn getCAbiIntParamRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 467 | pub fn getCAbiIntParamRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 468 | 468 | return switch (cc) { |
| 469 | 469 | .x86_64_sysv => &SysV.c_abi_int_param_regs, |
| 470 | 470 | .x86_64_win => &Win64.c_abi_int_param_regs, |
| ... | ... | @@ -472,7 +472,7 @@ pub fn getCAbiIntParamRegs(cc: std.builtin.NewCallingConvention) []const Registe |
| 472 | 472 | }; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | pub fn getCAbiSseParamRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 475 | pub fn getCAbiSseParamRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 476 | 476 | return switch (cc) { |
| 477 | 477 | .x86_64_sysv => &SysV.c_abi_sse_param_regs, |
| 478 | 478 | .x86_64_win => &Win64.c_abi_sse_param_regs, |
| ... | ... | @@ -480,7 +480,7 @@ pub fn getCAbiSseParamRegs(cc: std.builtin.NewCallingConvention) []const Registe |
| 480 | 480 | }; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | pub fn getCAbiIntReturnRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 483 | pub fn getCAbiIntReturnRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 484 | 484 | return switch (cc) { |
| 485 | 485 | .x86_64_sysv => &SysV.c_abi_int_return_regs, |
| 486 | 486 | .x86_64_win => &Win64.c_abi_int_return_regs, |
| ... | ... | @@ -488,7 +488,7 @@ pub fn getCAbiIntReturnRegs(cc: std.builtin.NewCallingConvention) []const Regist |
| 488 | 488 | }; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | pub fn getCAbiSseReturnRegs(cc: std.builtin.NewCallingConvention) []const Register { | |
| 491 | pub fn getCAbiSseReturnRegs(cc: std.builtin.CallingConvention) []const Register { | |
| 492 | 492 | return switch (cc) { |
| 493 | 493 | .x86_64_sysv => &SysV.c_abi_sse_return_regs, |
| 494 | 494 | .x86_64_win => &Win64.c_abi_sse_return_regs, |
src/codegen/c.zig+1-1| ... | ... | @@ -7604,7 +7604,7 @@ fn writeMemoryOrder(w: anytype, order: std.builtin.AtomicOrder) !void { |
| 7604 | 7604 | return w.writeAll(toMemoryOrder(order)); |
| 7605 | 7605 | } |
| 7606 | 7606 | |
| 7607 | fn toCallingConvention(cc: std.builtin.NewCallingConvention, zcu: *Zcu) ?[]const u8 { | |
| 7607 | fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8 { | |
| 7608 | 7608 | return switch (cc) { |
| 7609 | 7609 | .auto, .naked => null, |
| 7610 | 7610 | .x86_stdcall => "stdcall", |
src/codegen/llvm.zig+5-5| ... | ... | @@ -11595,13 +11595,13 @@ const CallingConventionInfo = struct { |
| 11595 | 11595 | inreg_param_count: u2 = 0, |
| 11596 | 11596 | }; |
| 11597 | 11597 | |
| 11598 | pub fn toLlvmCallConv(cc: std.builtin.NewCallingConvention, target: std.Target) ?CallingConventionInfo { | |
| 11598 | pub fn toLlvmCallConv(cc: std.builtin.CallingConvention, target: std.Target) ?CallingConventionInfo { | |
| 11599 | 11599 | const llvm_cc = toLlvmCallConvTag(cc, target) orelse return null; |
| 11600 | 11600 | const incoming_stack_alignment: ?u64, const register_params: u2 = switch (cc) { |
| 11601 | 11601 | inline else => |pl| switch (@TypeOf(pl)) { |
| 11602 | 11602 | void => .{ null, 0 }, |
| 11603 | std.builtin.NewCallingConvention.CommonOptions => .{ pl.incoming_stack_alignment, 0 }, | |
| 11604 | std.builtin.NewCallingConvention.X86RegparmOptions => .{ pl.incoming_stack_alignment, pl.register_params }, | |
| 11603 | std.builtin.CallingConvention.CommonOptions => .{ pl.incoming_stack_alignment, 0 }, | |
| 11604 | std.builtin.CallingConvention.X86RegparmOptions => .{ pl.incoming_stack_alignment, pl.register_params }, | |
| 11605 | 11605 | else => unreachable, |
| 11606 | 11606 | }, |
| 11607 | 11607 | }; |
| ... | ... | @@ -11615,7 +11615,7 @@ pub fn toLlvmCallConv(cc: std.builtin.NewCallingConvention, target: std.Target) |
| 11615 | 11615 | .inreg_param_count = register_params, |
| 11616 | 11616 | }; |
| 11617 | 11617 | } |
| 11618 | fn toLlvmCallConvTag(cc_tag: std.builtin.NewCallingConvention.Tag, target: std.Target) ?Builder.CallConv { | |
| 11618 | fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: std.Target) ?Builder.CallConv { | |
| 11619 | 11619 | if (target.defaultCCallingConvention()) |default_c| { |
| 11620 | 11620 | if (cc_tag == default_c) { |
| 11621 | 11621 | return .ccc; |
| ... | ... | @@ -12371,7 +12371,7 @@ fn iterateParamTypes(object: *Object, fn_info: InternPool.Key.FuncType) ParamTyp |
| 12371 | 12371 | } |
| 12372 | 12372 | |
| 12373 | 12373 | fn ccAbiPromoteInt( |
| 12374 | cc: std.builtin.NewCallingConvention, | |
| 12374 | cc: std.builtin.CallingConvention, | |
| 12375 | 12375 | zcu: *Zcu, |
| 12376 | 12376 | ty: Type, |
| 12377 | 12377 | ) ?std.builtin.Signedness { |
src/link/Coff.zig+2-2| ... | ... | @@ -1485,12 +1485,12 @@ pub fn updateExports( |
| 1485 | 1485 | const exported_ty = exported_nav.typeOf(ip); |
| 1486 | 1486 | if (!ip.isFunctionType(exported_ty)) continue; |
| 1487 | 1487 | const c_cc = target.defaultCCallingConvention().?; |
| 1488 | const winapi_cc: std.builtin.NewCallingConvention = switch (target.cpu.arch) { | |
| 1488 | const winapi_cc: std.builtin.CallingConvention = switch (target.cpu.arch) { | |
| 1489 | 1489 | .x86 => .{ .x86_stdcall = .{} }, |
| 1490 | 1490 | else => c_cc, |
| 1491 | 1491 | }; |
| 1492 | 1492 | const exported_cc = Type.fromInterned(exported_ty).fnCallingConvention(zcu); |
| 1493 | const CcTag = std.builtin.NewCallingConvention.Tag; | |
| 1493 | const CcTag = std.builtin.CallingConvention.Tag; | |
| 1494 | 1494 | if (@as(CcTag, exported_cc) == @as(CcTag, c_cc) and exp.opts.name.eqlSlice("main", ip) and comp.config.link_libc) { |
| 1495 | 1495 | zcu.stage1_flags.have_c_main = true; |
| 1496 | 1496 | } else if (@as(CcTag, exported_cc) == @as(CcTag, winapi_cc) and target.os.tag == .windows) { |
src/link/Dwarf.zig+1-1| ... | ... | @@ -3400,7 +3400,7 @@ fn updateType( |
| 3400 | 3400 | try wip_nav.strp(name); |
| 3401 | 3401 | const cc: DW.CC = cc: { |
| 3402 | 3402 | if (zcu.getTarget().defaultCCallingConvention()) |cc| { |
| 3403 | if (@as(std.builtin.NewCallingConvention.Tag, cc) == func_type.cc) { | |
| 3403 | if (@as(std.builtin.CallingConvention.Tag, cc) == func_type.cc) { | |
| 3404 | 3404 | break :cc .normal; |
| 3405 | 3405 | } |
| 3406 | 3406 | } |
src/target.zig+1-1| ... | ... | @@ -544,7 +544,7 @@ pub fn compilerRtIntAbbrev(bits: u16) []const u8 { |
| 544 | 544 | }; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | pub fn fnCallConvAllowsZigTypes(cc: std.builtin.NewCallingConvention) bool { | |
| 547 | pub fn fnCallConvAllowsZigTypes(cc: std.builtin.CallingConvention) bool { | |
| 548 | 548 | return switch (cc) { |
| 549 | 549 | .auto, .@"async", .@"inline" => true, |
| 550 | 550 | // For now we want to authorize PTX kernel to use zig objects, even if |