authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-27 06:10:56+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-27 06:10:56+01:00
logd3c6f7179c7a6086ab9cdbaed231da9a1f0b4dee
treea75bc8abc129a679fce0673165e04fa7283f2823
parentd9147b91a601ad2442aaa43f4dba2d01b25d803d
parent4c0f021c2e4270c7392df7250a5d8f2431dcc54f
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21214 from mlugg/branch-hint-and-export

Implement `@branchHint` and new `@export` usage

266 files changed, 2443 insertions(+), 1808 deletions(-)

doc/langref.html.in+12-24
...@@ -4340,6 +4340,13 @@ comptime {...@@ -4340,6 +4340,13 @@ comptime {
4340 {#see_also|@sizeOf|@typeInfo#}4340 {#see_also|@sizeOf|@typeInfo#}
4341 {#header_close#}4341 {#header_close#}
43424342
4343 {#header_open|@branchHint#}
4344 <pre>{#syntax#}@branchHint(hint: BranchHint) void{#endsyntax#}</pre>
4345 <p>Hints to the optimizer how likely a given branch of control flow is to be reached.</p>
4346 <p>{#syntax#}BranchHint{#endsyntax#} can be found with {#syntax#}@import("std").builtin.BranchHint{#endsyntax#}.</p>
4347 <p>This function is only valid as the first statement in a control flow branch, or the first statement in a function.</p>
4348 {#header_close#}
4349
4343 {#header_open|@breakpoint#}4350 {#header_open|@breakpoint#}
4344 <pre>{#syntax#}@breakpoint() void{#endsyntax#}</pre>4351 <pre>{#syntax#}@breakpoint() void{#endsyntax#}</pre>
4345 <p>4352 <p>
...@@ -4767,23 +4774,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -4767,23 +4774,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4767 {#header_close#}4774 {#header_close#}
47684775
4769 {#header_open|@export#}4776 {#header_open|@export#}
4770 <pre>{#syntax#}@export(declaration, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>4777 <pre>{#syntax#}@export(comptime ptr: *const anyopaque, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
4771 <p>4778 <p>Creates a symbol in the output object file which refers to the target of <code>ptr</code>.</p>
4772 Creates a symbol in the output object file.4779 <p><code>ptr</code> must point to a global variable or a comptime-known constant.</p>
4773 </p>
4774 <p>
4775 <code>declaration</code> must be one of two things:
4776 </p>
4777 <ul>
4778 <li>An identifier ({#syntax#}x{#endsyntax#}) identifying a {#link|function|Functions#} or a
4779 {#link|variable|Container Level Variables#}.</li>
4780 <li>Field access ({#syntax#}x.y{#endsyntax#}) looking up a {#link|function|Functions#} or a
4781 {#link|variable|Container Level Variables#}.</li>
4782 </ul>
4783 <p>4780 <p>
4784 This builtin can be called from a {#link|comptime#} block to conditionally export symbols.4781 This builtin can be called from a {#link|comptime#} block to conditionally export symbols.
4785 When <code>declaration</code> is a function with the C calling convention and4782 When <code>ptr</code> points to a function with the C calling convention and
4786 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to4783 {#syntax#}options.linkage{#endsyntax#} is {#syntax#}.Strong{#endsyntax#}, this is equivalent to
4787 the {#syntax#}export{#endsyntax#} keyword used on a function:4784 the {#syntax#}export{#endsyntax#} keyword used on a function:
4788 </p>4785 </p>
4789 {#code|export_builtin.zig#}4786 {#code|export_builtin.zig#}
...@@ -5252,15 +5249,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5252,15 +5249,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5252 </p>5249 </p>
5253 {#header_close#}5250 {#header_close#}
52545251
5255 {#header_open|@setCold#}
5256 <pre>{#syntax#}@setCold(comptime is_cold: bool) void{#endsyntax#}</pre>
5257 <p>
5258 Tells the optimizer that the current function is (or is not) rarely called.
5259
5260 This function is only valid within function scope.
5261 </p>
5262 {#header_close#}
5263
5264 {#header_open|@setEvalBranchQuota#}5252 {#header_open|@setEvalBranchQuota#}
5265 <pre>{#syntax#}@setEvalBranchQuota(comptime new_quota: u32) void{#endsyntax#}</pre>5253 <pre>{#syntax#}@setEvalBranchQuota(comptime new_quota: u32) void{#endsyntax#}</pre>
5266 <p>5254 <p>
doc/langref/export_builtin.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1comptime {1comptime {
2 @export(internalName, .{ .name = "foo", .linkage = .strong });2 @export(&internalName, .{ .name = "foo", .linkage = .strong });
3}3}
44
5fn internalName() callconv(.C) void {}5fn internalName() callconv(.C) void {}
doc/langref/test_functions.zig+2-2
...@@ -27,9 +27,9 @@ const WINAPI: std.builtin.CallingConvention = if (native_arch == .x86) .Stdcall...@@ -27,9 +27,9 @@ const WINAPI: std.builtin.CallingConvention = if (native_arch == .x86) .Stdcall
27extern "kernel32" fn ExitProcess(exit_code: u32) callconv(WINAPI) noreturn;27extern "kernel32" fn ExitProcess(exit_code: u32) callconv(WINAPI) noreturn;
28extern "c" fn atan2(a: f64, b: f64) f64;28extern "c" fn atan2(a: f64, b: f64) f64;
2929
30// The @setCold builtin tells the optimizer that a function is rarely called.30// The @branchHint builtin can be used to tell the optimizer that a function is rarely called ("cold").
31fn abort() noreturn {31fn abort() noreturn {
32 @setCold(true);32 @branchHint(.cold);
33 while (true) {}33 while (true) {}
34}34}
3535
lib/c.zig+11-11
...@@ -26,27 +26,27 @@ const is_freestanding = switch (native_os) {...@@ -26,27 +26,27 @@ const is_freestanding = switch (native_os) {
2626
27comptime {27comptime {
28 if (is_freestanding and is_wasm and builtin.link_libc) {28 if (is_freestanding and is_wasm and builtin.link_libc) {
29 @export(wasm_start, .{ .name = "_start", .linkage = .strong });29 @export(&wasm_start, .{ .name = "_start", .linkage = .strong });
30 }30 }
3131
32 if (builtin.link_libc) {32 if (builtin.link_libc) {
33 @export(strcmp, .{ .name = "strcmp", .linkage = .strong });33 @export(&strcmp, .{ .name = "strcmp", .linkage = .strong });
34 @export(strncmp, .{ .name = "strncmp", .linkage = .strong });34 @export(&strncmp, .{ .name = "strncmp", .linkage = .strong });
35 @export(strerror, .{ .name = "strerror", .linkage = .strong });35 @export(&strerror, .{ .name = "strerror", .linkage = .strong });
36 @export(strlen, .{ .name = "strlen", .linkage = .strong });36 @export(&strlen, .{ .name = "strlen", .linkage = .strong });
37 @export(strcpy, .{ .name = "strcpy", .linkage = .strong });37 @export(&strcpy, .{ .name = "strcpy", .linkage = .strong });
38 @export(strncpy, .{ .name = "strncpy", .linkage = .strong });38 @export(&strncpy, .{ .name = "strncpy", .linkage = .strong });
39 @export(strcat, .{ .name = "strcat", .linkage = .strong });39 @export(&strcat, .{ .name = "strcat", .linkage = .strong });
40 @export(strncat, .{ .name = "strncat", .linkage = .strong });40 @export(&strncat, .{ .name = "strncat", .linkage = .strong });
41 } else if (is_msvc) {41 } else if (is_msvc) {
42 @export(_fltused, .{ .name = "_fltused", .linkage = .strong });42 @export(&_fltused, .{ .name = "_fltused", .linkage = .strong });
43 }43 }
44}44}
4545
46// Avoid dragging in the runtime safety mechanisms into this .o file,46// Avoid dragging in the runtime safety mechanisms into this .o file,
47// unless we're trying to test this file.47// unless we're trying to test this file.
48pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {48pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
49 @setCold(true);49 @branchHint(.cold);
50 _ = error_return_trace;50 _ = error_return_trace;
51 if (builtin.is_test) {51 if (builtin.is_test) {
52 std.debug.panic("{s}", .{msg});52 std.debug.panic("{s}", .{msg});
lib/compiler/aro/aro/Driver/Filesystem.zig+4-4
...@@ -4,7 +4,7 @@ const builtin = @import("builtin");...@@ -4,7 +4,7 @@ const builtin = @import("builtin");
4const is_windows = builtin.os.tag == .windows;4const is_windows = builtin.os.tag == .windows;
55
6fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) ?[]const u8 {6fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) ?[]const u8 {
7 @setCold(true);7 @branchHint(.cold);
8 for (entries) |entry| {8 for (entries) |entry| {
9 if (mem.eql(u8, entry.path, path)) {9 if (mem.eql(u8, entry.path, path)) {
10 const len = @min(entry.contents.len, buf.len);10 const len = @min(entry.contents.len, buf.len);
...@@ -16,7 +16,7 @@ fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8)...@@ -16,7 +16,7 @@ fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8)
16}16}
1717
18fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {18fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
19 @setCold(true);19 @branchHint(.cold);
20 if (mem.indexOfScalar(u8, name, '/') != null) {20 if (mem.indexOfScalar(u8, name, '/') != null) {
21 @memcpy(buf[0..name.len], name);21 @memcpy(buf[0..name.len], name);
22 return buf[0..name.len];22 return buf[0..name.len];
...@@ -35,7 +35,7 @@ fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, pa...@@ -35,7 +35,7 @@ fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, pa
35}35}
3636
37fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {37fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
38 @setCold(true);38 @branchHint(.cold);
39 for (entries) |entry| {39 for (entries) |entry| {
40 if (mem.eql(u8, entry.path, path)) {40 if (mem.eql(u8, entry.path, path)) {
41 return entry.executable;41 return entry.executable;
...@@ -45,7 +45,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {...@@ -45,7 +45,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
45}45}
4646
47fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {47fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {
48 @setCold(true);48 @branchHint(.cold);
49 var buf: [std.fs.max_path_bytes]u8 = undefined;49 var buf: [std.fs.max_path_bytes]u8 = undefined;
50 var fib = std.heap.FixedBufferAllocator.init(&buf);50 var fib = std.heap.FixedBufferAllocator.init(&buf);
51 const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;51 const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;
lib/compiler/aro/aro/Parser.zig+5-5
...@@ -385,12 +385,12 @@ fn errExpectedToken(p: *Parser, expected: Token.Id, actual: Token.Id) Error {...@@ -385,12 +385,12 @@ fn errExpectedToken(p: *Parser, expected: Token.Id, actual: Token.Id) Error {
385}385}
386386
387pub fn errStr(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, str: []const u8) Compilation.Error!void {387pub fn errStr(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, str: []const u8) Compilation.Error!void {
388 @setCold(true);388 @branchHint(.cold);
389 return p.errExtra(tag, tok_i, .{ .str = str });389 return p.errExtra(tag, tok_i, .{ .str = str });
390}390}
391391
392pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diagnostics.Message.Extra) Compilation.Error!void {392pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diagnostics.Message.Extra) Compilation.Error!void {
393 @setCold(true);393 @branchHint(.cold);
394 const tok = p.pp.tokens.get(tok_i);394 const tok = p.pp.tokens.get(tok_i);
395 var loc = tok.loc;395 var loc = tok.loc;
396 if (tok_i != 0 and tok.id == .eof) {396 if (tok_i != 0 and tok.id == .eof) {
...@@ -407,12 +407,12 @@ pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diag...@@ -407,12 +407,12 @@ pub fn errExtra(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex, extra: Diag
407}407}
408408
409pub fn errTok(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex) Compilation.Error!void {409pub fn errTok(p: *Parser, tag: Diagnostics.Tag, tok_i: TokenIndex) Compilation.Error!void {
410 @setCold(true);410 @branchHint(.cold);
411 return p.errExtra(tag, tok_i, .{ .none = {} });411 return p.errExtra(tag, tok_i, .{ .none = {} });
412}412}
413413
414pub fn err(p: *Parser, tag: Diagnostics.Tag) Compilation.Error!void {414pub fn err(p: *Parser, tag: Diagnostics.Tag) Compilation.Error!void {
415 @setCold(true);415 @branchHint(.cold);
416 return p.errExtra(tag, p.tok_i, .{ .none = {} });416 return p.errExtra(tag, p.tok_i, .{ .none = {} });
417}417}
418418
...@@ -638,7 +638,7 @@ fn pragma(p: *Parser) Compilation.Error!bool {...@@ -638,7 +638,7 @@ fn pragma(p: *Parser) Compilation.Error!bool {
638638
639/// Issue errors for top-level definitions whose type was never completed.639/// Issue errors for top-level definitions whose type was never completed.
640fn diagnoseIncompleteDefinitions(p: *Parser) !void {640fn diagnoseIncompleteDefinitions(p: *Parser) !void {
641 @setCold(true);641 @branchHint(.cold);
642642
643 const node_slices = p.nodes.slice();643 const node_slices = p.nodes.slice();
644 const tags = node_slices.items(.tag);644 const tags = node_slices.items(.tag);
lib/compiler/resinator/main.zig+4-4
...@@ -421,7 +421,7 @@ fn cliDiagnosticsToErrorBundle(...@@ -421,7 +421,7 @@ fn cliDiagnosticsToErrorBundle(
421 gpa: std.mem.Allocator,421 gpa: std.mem.Allocator,
422 diagnostics: *cli.Diagnostics,422 diagnostics: *cli.Diagnostics,
423) !ErrorBundle {423) !ErrorBundle {
424 @setCold(true);424 @branchHint(.cold);
425425
426 var bundle: ErrorBundle.Wip = undefined;426 var bundle: ErrorBundle.Wip = undefined;
427 try bundle.init(gpa);427 try bundle.init(gpa);
...@@ -468,7 +468,7 @@ fn diagnosticsToErrorBundle(...@@ -468,7 +468,7 @@ fn diagnosticsToErrorBundle(
468 diagnostics: *Diagnostics,468 diagnostics: *Diagnostics,
469 mappings: SourceMappings,469 mappings: SourceMappings,
470) !ErrorBundle {470) !ErrorBundle {
471 @setCold(true);471 @branchHint(.cold);
472472
473 var bundle: ErrorBundle.Wip = undefined;473 var bundle: ErrorBundle.Wip = undefined;
474 try bundle.init(gpa);474 try bundle.init(gpa);
...@@ -559,7 +559,7 @@ fn flushErrorMessageIntoBundle(wip: *ErrorBundle.Wip, msg: ErrorBundle.ErrorMess...@@ -559,7 +559,7 @@ fn flushErrorMessageIntoBundle(wip: *ErrorBundle.Wip, msg: ErrorBundle.ErrorMess
559}559}
560560
561fn errorStringToErrorBundle(allocator: std.mem.Allocator, comptime format: []const u8, args: anytype) !ErrorBundle {561fn errorStringToErrorBundle(allocator: std.mem.Allocator, comptime format: []const u8, args: anytype) !ErrorBundle {
562 @setCold(true);562 @branchHint(.cold);
563 var bundle: ErrorBundle.Wip = undefined;563 var bundle: ErrorBundle.Wip = undefined;
564 try bundle.init(allocator);564 try bundle.init(allocator);
565 errdefer bundle.deinit();565 errdefer bundle.deinit();
...@@ -574,7 +574,7 @@ fn aroDiagnosticsToErrorBundle(...@@ -574,7 +574,7 @@ fn aroDiagnosticsToErrorBundle(
574 fail_msg: []const u8,574 fail_msg: []const u8,
575 comp: *aro.Compilation,575 comp: *aro.Compilation,
576) !ErrorBundle {576) !ErrorBundle {
577 @setCold(true);577 @branchHint(.cold);
578578
579 var bundle: ErrorBundle.Wip = undefined;579 var bundle: ErrorBundle.Wip = undefined;
580 try bundle.init(gpa);580 try bundle.init(gpa);
lib/compiler_rt/aarch64_outline_atomics.zig+100-100
...@@ -2124,104 +2124,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.Naked) void {...@@ -2124,104 +2124,104 @@ fn __aarch64_cas16_acq_rel() align(16) callconv(.Naked) void {
2124}2124}
21252125
2126comptime {2126comptime {
2127 @export(__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage });2127 @export(&__aarch64_cas1_relax, .{ .name = "__aarch64_cas1_relax", .linkage = linkage });
2128 @export(__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage });2128 @export(&__aarch64_swp1_relax, .{ .name = "__aarch64_swp1_relax", .linkage = linkage });
2129 @export(__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage });2129 @export(&__aarch64_ldadd1_relax, .{ .name = "__aarch64_ldadd1_relax", .linkage = linkage });
2130 @export(__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage });2130 @export(&__aarch64_ldclr1_relax, .{ .name = "__aarch64_ldclr1_relax", .linkage = linkage });
2131 @export(__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage });2131 @export(&__aarch64_ldeor1_relax, .{ .name = "__aarch64_ldeor1_relax", .linkage = linkage });
2132 @export(__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage });2132 @export(&__aarch64_ldset1_relax, .{ .name = "__aarch64_ldset1_relax", .linkage = linkage });
2133 @export(__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage });2133 @export(&__aarch64_cas1_acq, .{ .name = "__aarch64_cas1_acq", .linkage = linkage });
2134 @export(__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage });2134 @export(&__aarch64_swp1_acq, .{ .name = "__aarch64_swp1_acq", .linkage = linkage });
2135 @export(__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage });2135 @export(&__aarch64_ldadd1_acq, .{ .name = "__aarch64_ldadd1_acq", .linkage = linkage });
2136 @export(__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage });2136 @export(&__aarch64_ldclr1_acq, .{ .name = "__aarch64_ldclr1_acq", .linkage = linkage });
2137 @export(__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage });2137 @export(&__aarch64_ldeor1_acq, .{ .name = "__aarch64_ldeor1_acq", .linkage = linkage });
2138 @export(__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage });2138 @export(&__aarch64_ldset1_acq, .{ .name = "__aarch64_ldset1_acq", .linkage = linkage });
2139 @export(__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage });2139 @export(&__aarch64_cas1_rel, .{ .name = "__aarch64_cas1_rel", .linkage = linkage });
2140 @export(__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage });2140 @export(&__aarch64_swp1_rel, .{ .name = "__aarch64_swp1_rel", .linkage = linkage });
2141 @export(__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage });2141 @export(&__aarch64_ldadd1_rel, .{ .name = "__aarch64_ldadd1_rel", .linkage = linkage });
2142 @export(__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage });2142 @export(&__aarch64_ldclr1_rel, .{ .name = "__aarch64_ldclr1_rel", .linkage = linkage });
2143 @export(__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage });2143 @export(&__aarch64_ldeor1_rel, .{ .name = "__aarch64_ldeor1_rel", .linkage = linkage });
2144 @export(__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage });2144 @export(&__aarch64_ldset1_rel, .{ .name = "__aarch64_ldset1_rel", .linkage = linkage });
2145 @export(__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage });2145 @export(&__aarch64_cas1_acq_rel, .{ .name = "__aarch64_cas1_acq_rel", .linkage = linkage });
2146 @export(__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage });2146 @export(&__aarch64_swp1_acq_rel, .{ .name = "__aarch64_swp1_acq_rel", .linkage = linkage });
2147 @export(__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage });2147 @export(&__aarch64_ldadd1_acq_rel, .{ .name = "__aarch64_ldadd1_acq_rel", .linkage = linkage });
2148 @export(__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage });2148 @export(&__aarch64_ldclr1_acq_rel, .{ .name = "__aarch64_ldclr1_acq_rel", .linkage = linkage });
2149 @export(__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage });2149 @export(&__aarch64_ldeor1_acq_rel, .{ .name = "__aarch64_ldeor1_acq_rel", .linkage = linkage });
2150 @export(__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage });2150 @export(&__aarch64_ldset1_acq_rel, .{ .name = "__aarch64_ldset1_acq_rel", .linkage = linkage });
2151 @export(__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage });2151 @export(&__aarch64_cas2_relax, .{ .name = "__aarch64_cas2_relax", .linkage = linkage });
2152 @export(__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage });2152 @export(&__aarch64_swp2_relax, .{ .name = "__aarch64_swp2_relax", .linkage = linkage });
2153 @export(__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage });2153 @export(&__aarch64_ldadd2_relax, .{ .name = "__aarch64_ldadd2_relax", .linkage = linkage });
2154 @export(__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage });2154 @export(&__aarch64_ldclr2_relax, .{ .name = "__aarch64_ldclr2_relax", .linkage = linkage });
2155 @export(__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage });2155 @export(&__aarch64_ldeor2_relax, .{ .name = "__aarch64_ldeor2_relax", .linkage = linkage });
2156 @export(__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage });2156 @export(&__aarch64_ldset2_relax, .{ .name = "__aarch64_ldset2_relax", .linkage = linkage });
2157 @export(__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage });2157 @export(&__aarch64_cas2_acq, .{ .name = "__aarch64_cas2_acq", .linkage = linkage });
2158 @export(__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage });2158 @export(&__aarch64_swp2_acq, .{ .name = "__aarch64_swp2_acq", .linkage = linkage });
2159 @export(__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage });2159 @export(&__aarch64_ldadd2_acq, .{ .name = "__aarch64_ldadd2_acq", .linkage = linkage });
2160 @export(__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage });2160 @export(&__aarch64_ldclr2_acq, .{ .name = "__aarch64_ldclr2_acq", .linkage = linkage });
2161 @export(__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage });2161 @export(&__aarch64_ldeor2_acq, .{ .name = "__aarch64_ldeor2_acq", .linkage = linkage });
2162 @export(__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage });2162 @export(&__aarch64_ldset2_acq, .{ .name = "__aarch64_ldset2_acq", .linkage = linkage });
2163 @export(__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage });2163 @export(&__aarch64_cas2_rel, .{ .name = "__aarch64_cas2_rel", .linkage = linkage });
2164 @export(__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage });2164 @export(&__aarch64_swp2_rel, .{ .name = "__aarch64_swp2_rel", .linkage = linkage });
2165 @export(__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage });2165 @export(&__aarch64_ldadd2_rel, .{ .name = "__aarch64_ldadd2_rel", .linkage = linkage });
2166 @export(__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage });2166 @export(&__aarch64_ldclr2_rel, .{ .name = "__aarch64_ldclr2_rel", .linkage = linkage });
2167 @export(__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage });2167 @export(&__aarch64_ldeor2_rel, .{ .name = "__aarch64_ldeor2_rel", .linkage = linkage });
2168 @export(__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage });2168 @export(&__aarch64_ldset2_rel, .{ .name = "__aarch64_ldset2_rel", .linkage = linkage });
2169 @export(__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage });2169 @export(&__aarch64_cas2_acq_rel, .{ .name = "__aarch64_cas2_acq_rel", .linkage = linkage });
2170 @export(__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage });2170 @export(&__aarch64_swp2_acq_rel, .{ .name = "__aarch64_swp2_acq_rel", .linkage = linkage });
2171 @export(__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage });2171 @export(&__aarch64_ldadd2_acq_rel, .{ .name = "__aarch64_ldadd2_acq_rel", .linkage = linkage });
2172 @export(__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage });2172 @export(&__aarch64_ldclr2_acq_rel, .{ .name = "__aarch64_ldclr2_acq_rel", .linkage = linkage });
2173 @export(__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage });2173 @export(&__aarch64_ldeor2_acq_rel, .{ .name = "__aarch64_ldeor2_acq_rel", .linkage = linkage });
2174 @export(__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage });2174 @export(&__aarch64_ldset2_acq_rel, .{ .name = "__aarch64_ldset2_acq_rel", .linkage = linkage });
2175 @export(__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage });2175 @export(&__aarch64_cas4_relax, .{ .name = "__aarch64_cas4_relax", .linkage = linkage });
2176 @export(__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage });2176 @export(&__aarch64_swp4_relax, .{ .name = "__aarch64_swp4_relax", .linkage = linkage });
2177 @export(__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage });2177 @export(&__aarch64_ldadd4_relax, .{ .name = "__aarch64_ldadd4_relax", .linkage = linkage });
2178 @export(__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage });2178 @export(&__aarch64_ldclr4_relax, .{ .name = "__aarch64_ldclr4_relax", .linkage = linkage });
2179 @export(__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage });2179 @export(&__aarch64_ldeor4_relax, .{ .name = "__aarch64_ldeor4_relax", .linkage = linkage });
2180 @export(__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage });2180 @export(&__aarch64_ldset4_relax, .{ .name = "__aarch64_ldset4_relax", .linkage = linkage });
2181 @export(__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage });2181 @export(&__aarch64_cas4_acq, .{ .name = "__aarch64_cas4_acq", .linkage = linkage });
2182 @export(__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage });2182 @export(&__aarch64_swp4_acq, .{ .name = "__aarch64_swp4_acq", .linkage = linkage });
2183 @export(__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage });2183 @export(&__aarch64_ldadd4_acq, .{ .name = "__aarch64_ldadd4_acq", .linkage = linkage });
2184 @export(__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage });2184 @export(&__aarch64_ldclr4_acq, .{ .name = "__aarch64_ldclr4_acq", .linkage = linkage });
2185 @export(__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage });2185 @export(&__aarch64_ldeor4_acq, .{ .name = "__aarch64_ldeor4_acq", .linkage = linkage });
2186 @export(__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage });2186 @export(&__aarch64_ldset4_acq, .{ .name = "__aarch64_ldset4_acq", .linkage = linkage });
2187 @export(__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage });2187 @export(&__aarch64_cas4_rel, .{ .name = "__aarch64_cas4_rel", .linkage = linkage });
2188 @export(__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage });2188 @export(&__aarch64_swp4_rel, .{ .name = "__aarch64_swp4_rel", .linkage = linkage });
2189 @export(__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage });2189 @export(&__aarch64_ldadd4_rel, .{ .name = "__aarch64_ldadd4_rel", .linkage = linkage });
2190 @export(__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage });2190 @export(&__aarch64_ldclr4_rel, .{ .name = "__aarch64_ldclr4_rel", .linkage = linkage });
2191 @export(__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage });2191 @export(&__aarch64_ldeor4_rel, .{ .name = "__aarch64_ldeor4_rel", .linkage = linkage });
2192 @export(__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage });2192 @export(&__aarch64_ldset4_rel, .{ .name = "__aarch64_ldset4_rel", .linkage = linkage });
2193 @export(__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage });2193 @export(&__aarch64_cas4_acq_rel, .{ .name = "__aarch64_cas4_acq_rel", .linkage = linkage });
2194 @export(__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage });2194 @export(&__aarch64_swp4_acq_rel, .{ .name = "__aarch64_swp4_acq_rel", .linkage = linkage });
2195 @export(__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage });2195 @export(&__aarch64_ldadd4_acq_rel, .{ .name = "__aarch64_ldadd4_acq_rel", .linkage = linkage });
2196 @export(__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage });2196 @export(&__aarch64_ldclr4_acq_rel, .{ .name = "__aarch64_ldclr4_acq_rel", .linkage = linkage });
2197 @export(__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage });2197 @export(&__aarch64_ldeor4_acq_rel, .{ .name = "__aarch64_ldeor4_acq_rel", .linkage = linkage });
2198 @export(__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage });2198 @export(&__aarch64_ldset4_acq_rel, .{ .name = "__aarch64_ldset4_acq_rel", .linkage = linkage });
2199 @export(__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage });2199 @export(&__aarch64_cas8_relax, .{ .name = "__aarch64_cas8_relax", .linkage = linkage });
2200 @export(__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage });2200 @export(&__aarch64_swp8_relax, .{ .name = "__aarch64_swp8_relax", .linkage = linkage });
2201 @export(__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage });2201 @export(&__aarch64_ldadd8_relax, .{ .name = "__aarch64_ldadd8_relax", .linkage = linkage });
2202 @export(__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage });2202 @export(&__aarch64_ldclr8_relax, .{ .name = "__aarch64_ldclr8_relax", .linkage = linkage });
2203 @export(__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage });2203 @export(&__aarch64_ldeor8_relax, .{ .name = "__aarch64_ldeor8_relax", .linkage = linkage });
2204 @export(__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage });2204 @export(&__aarch64_ldset8_relax, .{ .name = "__aarch64_ldset8_relax", .linkage = linkage });
2205 @export(__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage });2205 @export(&__aarch64_cas8_acq, .{ .name = "__aarch64_cas8_acq", .linkage = linkage });
2206 @export(__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage });2206 @export(&__aarch64_swp8_acq, .{ .name = "__aarch64_swp8_acq", .linkage = linkage });
2207 @export(__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage });2207 @export(&__aarch64_ldadd8_acq, .{ .name = "__aarch64_ldadd8_acq", .linkage = linkage });
2208 @export(__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage });2208 @export(&__aarch64_ldclr8_acq, .{ .name = "__aarch64_ldclr8_acq", .linkage = linkage });
2209 @export(__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage });2209 @export(&__aarch64_ldeor8_acq, .{ .name = "__aarch64_ldeor8_acq", .linkage = linkage });
2210 @export(__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage });2210 @export(&__aarch64_ldset8_acq, .{ .name = "__aarch64_ldset8_acq", .linkage = linkage });
2211 @export(__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage });2211 @export(&__aarch64_cas8_rel, .{ .name = "__aarch64_cas8_rel", .linkage = linkage });
2212 @export(__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage });2212 @export(&__aarch64_swp8_rel, .{ .name = "__aarch64_swp8_rel", .linkage = linkage });
2213 @export(__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage });2213 @export(&__aarch64_ldadd8_rel, .{ .name = "__aarch64_ldadd8_rel", .linkage = linkage });
2214 @export(__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage });2214 @export(&__aarch64_ldclr8_rel, .{ .name = "__aarch64_ldclr8_rel", .linkage = linkage });
2215 @export(__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage });2215 @export(&__aarch64_ldeor8_rel, .{ .name = "__aarch64_ldeor8_rel", .linkage = linkage });
2216 @export(__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage });2216 @export(&__aarch64_ldset8_rel, .{ .name = "__aarch64_ldset8_rel", .linkage = linkage });
2217 @export(__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage });2217 @export(&__aarch64_cas8_acq_rel, .{ .name = "__aarch64_cas8_acq_rel", .linkage = linkage });
2218 @export(__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage });2218 @export(&__aarch64_swp8_acq_rel, .{ .name = "__aarch64_swp8_acq_rel", .linkage = linkage });
2219 @export(__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage });2219 @export(&__aarch64_ldadd8_acq_rel, .{ .name = "__aarch64_ldadd8_acq_rel", .linkage = linkage });
2220 @export(__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage });2220 @export(&__aarch64_ldclr8_acq_rel, .{ .name = "__aarch64_ldclr8_acq_rel", .linkage = linkage });
2221 @export(__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage });2221 @export(&__aarch64_ldeor8_acq_rel, .{ .name = "__aarch64_ldeor8_acq_rel", .linkage = linkage });
2222 @export(__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage });2222 @export(&__aarch64_ldset8_acq_rel, .{ .name = "__aarch64_ldset8_acq_rel", .linkage = linkage });
2223 @export(__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage });2223 @export(&__aarch64_cas16_relax, .{ .name = "__aarch64_cas16_relax", .linkage = linkage });
2224 @export(__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage });2224 @export(&__aarch64_cas16_acq, .{ .name = "__aarch64_cas16_acq", .linkage = linkage });
2225 @export(__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage });2225 @export(&__aarch64_cas16_rel, .{ .name = "__aarch64_cas16_rel", .linkage = linkage });
2226 @export(__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage });2226 @export(&__aarch64_cas16_acq_rel, .{ .name = "__aarch64_cas16_acq_rel", .linkage = linkage });
2227}2227}
lib/compiler_rt/absvdi2.zig+1-1
...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __absvdi2(a: i64) callconv(.C) i64 {10pub fn __absvdi2(a: i64) callconv(.C) i64 {
lib/compiler_rt/absvsi2.zig+1-1
...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __absvsi2(a: i32) callconv(.C) i32 {10pub fn __absvsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/absvti2.zig+1-1
...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;...@@ -4,7 +4,7 @@ const absv = @import("./absv.zig").absv;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__absvti2, .{ .name = "__absvti2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __absvti2(a: i128) callconv(.C) i128 {10pub fn __absvti2(a: i128) callconv(.C) i128 {
lib/compiler_rt/adddf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__adddf3, .{ .name = "__adddf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/addhf3.zig+1-1
...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __addhf3(a: f16, b: f16) callconv(.C) f16 {10fn __addhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/addo.zig+3-3
...@@ -5,9 +5,9 @@ const common = @import("./common.zig");...@@ -5,9 +5,9 @@ const common = @import("./common.zig");
5pub const panic = @import("common.zig").panic;5pub const panic = @import("common.zig").panic;
66
7comptime {7comptime {
8 @export(__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__addosi4, .{ .name = "__addosi4", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__addodi4, .{ .name = "__addodi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__addoti4, .{ .name = "__addoti4", .linkage = common.linkage, .visibility = common.visibility });
11}11}
1212
13// addo - add overflow13// addo - add overflow
lib/compiler_rt/addsf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__addsf3, .{ .name = "__addsf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/addtf3.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__addtf3, .{ .name = "__addkf3", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__addtf3, .{ .name = "__addtf3", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {15pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/addxf3.zig+1-1
...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__addxf3, .{ .name = "__addxf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 {10pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/arm.zig+22-22
...@@ -10,39 +10,39 @@ pub const panic = common.panic;...@@ -10,39 +10,39 @@ pub const panic = common.panic;
10comptime {10comptime {
11 if (!builtin.is_test) {11 if (!builtin.is_test) {
12 if (arch.isArmOrThumb()) {12 if (arch.isArmOrThumb()) {
13 @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage, .visibility = common.visibility });
1616
17 @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage, .visibility = common.visibility });
1919
20 @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });20 @export(&__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage, .visibility = common.visibility });
2222
23 @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });23 @export(&__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });24 @export(&__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage, .visibility = common.visibility });
2626
27 @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility });27 @export(&__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage, .visibility = common.visibility });
28 @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility });28 @export(&__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility });29 @export(&__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage, .visibility = common.visibility });
3030
31 @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility });31 @export(&__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility });32 @export(&__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility });33 @export(&__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage, .visibility = common.visibility });
3434
35 @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility });35 @export(&__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage, .visibility = common.visibility });
36 @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });36 @export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });
37 @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });37 @export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });
3838
39 if (builtin.os.tag == .linux) {39 if (builtin.os.tag == .linux) {
40 @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });40 @export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
41 }41 }
4242
43 // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig43 // floating-point helper functions (single+double-precision reverse subtraction, y – x), see subdf3.zig
44 @export(__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility });44 @export(&__aeabi_frsub, .{ .name = "__aeabi_frsub", .linkage = common.linkage, .visibility = common.visibility });
45 @export(__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });45 @export(&__aeabi_drsub, .{ .name = "__aeabi_drsub", .linkage = common.linkage, .visibility = common.visibility });
46 }46 }
47 }47 }
48}48}
lib/compiler_rt/atomics.zig+76-76
...@@ -538,81 +538,81 @@ fn __atomic_fetch_umin_16(ptr: *u128, val: u128, model: i32) callconv(.C) u128 {...@@ -538,81 +538,81 @@ fn __atomic_fetch_umin_16(ptr: *u128, val: u128, model: i32) callconv(.C) u128 {
538538
539comptime {539comptime {
540 if (supports_atomic_ops and builtin.object_format != .c) {540 if (supports_atomic_ops and builtin.object_format != .c) {
541 @export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility });541 @export(&__atomic_load, .{ .name = "__atomic_load", .linkage = linkage, .visibility = visibility });
542 @export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility });542 @export(&__atomic_store, .{ .name = "__atomic_store", .linkage = linkage, .visibility = visibility });
543 @export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility });543 @export(&__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage, .visibility = visibility });
544 @export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility });544 @export(&__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage, .visibility = visibility });
545545
546 @export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility });546 @export(&__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage, .visibility = visibility });
547 @export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility });547 @export(&__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage, .visibility = visibility });
548 @export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility });548 @export(&__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage, .visibility = visibility });
549 @export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility });549 @export(&__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage, .visibility = visibility });
550 @export(__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility });550 @export(&__atomic_fetch_add_16, .{ .name = "__atomic_fetch_add_16", .linkage = linkage, .visibility = visibility });
551551
552 @export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility });552 @export(&__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage, .visibility = visibility });
553 @export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility });553 @export(&__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage, .visibility = visibility });
554 @export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility });554 @export(&__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage, .visibility = visibility });
555 @export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility });555 @export(&__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage, .visibility = visibility });
556 @export(__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility });556 @export(&__atomic_fetch_sub_16, .{ .name = "__atomic_fetch_sub_16", .linkage = linkage, .visibility = visibility });
557557
558 @export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility });558 @export(&__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage, .visibility = visibility });
559 @export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility });559 @export(&__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage, .visibility = visibility });
560 @export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility });560 @export(&__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage, .visibility = visibility });
561 @export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility });561 @export(&__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage, .visibility = visibility });
562 @export(__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility });562 @export(&__atomic_fetch_and_16, .{ .name = "__atomic_fetch_and_16", .linkage = linkage, .visibility = visibility });
563563
564 @export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility });564 @export(&__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage, .visibility = visibility });
565 @export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility });565 @export(&__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage, .visibility = visibility });
566 @export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility });566 @export(&__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage, .visibility = visibility });
567 @export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility });567 @export(&__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage, .visibility = visibility });
568 @export(__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility });568 @export(&__atomic_fetch_or_16, .{ .name = "__atomic_fetch_or_16", .linkage = linkage, .visibility = visibility });
569569
570 @export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility });570 @export(&__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage, .visibility = visibility });
571 @export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility });571 @export(&__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage, .visibility = visibility });
572 @export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility });572 @export(&__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage, .visibility = visibility });
573 @export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility });573 @export(&__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage, .visibility = visibility });
574 @export(__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility });574 @export(&__atomic_fetch_xor_16, .{ .name = "__atomic_fetch_xor_16", .linkage = linkage, .visibility = visibility });
575575
576 @export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility });576 @export(&__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage, .visibility = visibility });
577 @export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility });577 @export(&__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage, .visibility = visibility });
578 @export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility });578 @export(&__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage, .visibility = visibility });
579 @export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility });579 @export(&__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage, .visibility = visibility });
580 @export(__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility });580 @export(&__atomic_fetch_nand_16, .{ .name = "__atomic_fetch_nand_16", .linkage = linkage, .visibility = visibility });
581581
582 @export(__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility });582 @export(&__atomic_fetch_umax_1, .{ .name = "__atomic_fetch_umax_1", .linkage = linkage, .visibility = visibility });
583 @export(__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility });583 @export(&__atomic_fetch_umax_2, .{ .name = "__atomic_fetch_umax_2", .linkage = linkage, .visibility = visibility });
584 @export(__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility });584 @export(&__atomic_fetch_umax_4, .{ .name = "__atomic_fetch_umax_4", .linkage = linkage, .visibility = visibility });
585 @export(__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility });585 @export(&__atomic_fetch_umax_8, .{ .name = "__atomic_fetch_umax_8", .linkage = linkage, .visibility = visibility });
586 @export(__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility });586 @export(&__atomic_fetch_umax_16, .{ .name = "__atomic_fetch_umax_16", .linkage = linkage, .visibility = visibility });
587587
588 @export(__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility });588 @export(&__atomic_fetch_umin_1, .{ .name = "__atomic_fetch_umin_1", .linkage = linkage, .visibility = visibility });
589 @export(__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility });589 @export(&__atomic_fetch_umin_2, .{ .name = "__atomic_fetch_umin_2", .linkage = linkage, .visibility = visibility });
590 @export(__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility });590 @export(&__atomic_fetch_umin_4, .{ .name = "__atomic_fetch_umin_4", .linkage = linkage, .visibility = visibility });
591 @export(__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility });591 @export(&__atomic_fetch_umin_8, .{ .name = "__atomic_fetch_umin_8", .linkage = linkage, .visibility = visibility });
592 @export(__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility });592 @export(&__atomic_fetch_umin_16, .{ .name = "__atomic_fetch_umin_16", .linkage = linkage, .visibility = visibility });
593593
594 @export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility });594 @export(&__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage, .visibility = visibility });
595 @export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility });595 @export(&__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage, .visibility = visibility });
596 @export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility });596 @export(&__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage, .visibility = visibility });
597 @export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility });597 @export(&__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage, .visibility = visibility });
598 @export(__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility });598 @export(&__atomic_load_16, .{ .name = "__atomic_load_16", .linkage = linkage, .visibility = visibility });
599599
600 @export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility });600 @export(&__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage, .visibility = visibility });
601 @export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility });601 @export(&__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage, .visibility = visibility });
602 @export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility });602 @export(&__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage, .visibility = visibility });
603 @export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility });603 @export(&__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage, .visibility = visibility });
604 @export(__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility });604 @export(&__atomic_store_16, .{ .name = "__atomic_store_16", .linkage = linkage, .visibility = visibility });
605605
606 @export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility });606 @export(&__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage, .visibility = visibility });
607 @export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility });607 @export(&__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage, .visibility = visibility });
608 @export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility });608 @export(&__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage, .visibility = visibility });
609 @export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility });609 @export(&__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage, .visibility = visibility });
610 @export(__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility });610 @export(&__atomic_exchange_16, .{ .name = "__atomic_exchange_16", .linkage = linkage, .visibility = visibility });
611611
612 @export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility });612 @export(&__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage, .visibility = visibility });
613 @export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility });613 @export(&__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage, .visibility = visibility });
614 @export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility });614 @export(&__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage, .visibility = visibility });
615 @export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility });615 @export(&__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage, .visibility = visibility });
616 @export(__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility });616 @export(&__atomic_compare_exchange_16, .{ .name = "__atomic_compare_exchange_16", .linkage = linkage, .visibility = visibility });
617 }617 }
618}618}
lib/compiler_rt/aulldiv.zig+2-2
...@@ -9,8 +9,8 @@ pub const panic = common.panic;...@@ -9,8 +9,8 @@ pub const panic = common.panic;
9comptime {9comptime {
10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {
11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });12 @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });
13 @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });13 @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/aullrem.zig+2-2
...@@ -9,8 +9,8 @@ pub const panic = common.panic;...@@ -9,8 +9,8 @@ pub const panic = common.panic;
9comptime {9comptime {
10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {
11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });12 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
13 @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });13 @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/bcmp.zig+1-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const common = @import("./common.zig");2const common = @import("./common.zig");
33
4comptime {4comptime {
5 @export(bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility });5 @export(&bcmp, .{ .name = "bcmp", .linkage = common.linkage, .visibility = common.visibility });
6}6}
77
8pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int {8pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int {
lib/compiler_rt/bitreverse.zig+3-3
...@@ -5,9 +5,9 @@ const common = @import("common.zig");...@@ -5,9 +5,9 @@ const common = @import("common.zig");
5pub const panic = common.panic;5pub const panic = common.panic;
66
7comptime {7comptime {
8 @export(__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__bitreversesi2, .{ .name = "__bitreversesi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__bitreversedi2, .{ .name = "__bitreversedi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__bitreverseti2, .{ .name = "__bitreverseti2", .linkage = common.linkage, .visibility = common.visibility });
11}11}
1212
13inline fn bitreverseXi2(comptime T: type, a: T) T {13inline fn bitreverseXi2(comptime T: type, a: T) T {
lib/compiler_rt/bswap.zig+3-3
...@@ -5,9 +5,9 @@ const common = @import("common.zig");...@@ -5,9 +5,9 @@ const common = @import("common.zig");
5pub const panic = common.panic;5pub const panic = common.panic;
66
7comptime {7comptime {
8 @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage, .visibility = common.visibility });
11}11}
1212
13// bswap - byteswap13// bswap - byteswap
lib/compiler_rt/ceil.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__ceilh, .{ .name = "__ceilh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility });19 @export(&ceilf, .{ .name = "ceilf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility });20 @export(&ceil, .{ .name = "ceil", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__ceilx, .{ .name = "__ceilx", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&ceilq, .{ .name = "ceilf128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility });25 @export(&ceilq, .{ .name = "ceilq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility });26 @export(&ceill, .{ .name = "ceill", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __ceilh(x: f16) callconv(.C) f16 {29pub fn __ceilh(x: f16) callconv(.C) f16 {
lib/compiler_rt/clear_cache.zig+1-1
...@@ -175,7 +175,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {...@@ -175,7 +175,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
175const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak;175const linkage = if (builtin.is_test) std.builtin.GlobalLinkage.internal else std.builtin.GlobalLinkage.weak;
176176
177fn exportIt() void {177fn exportIt() void {
178 @export(clear_cache, .{ .name = "__clear_cache", .linkage = linkage });178 @export(&clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
179}179}
180180
181// Darwin-only181// Darwin-only
lib/compiler_rt/cmp.zig+6-6
...@@ -6,12 +6,12 @@ const common = @import("common.zig");...@@ -6,12 +6,12 @@ const common = @import("common.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage, .visibility = common.visibility });
15}15}
1616
17// cmp - signed compare17// cmp - signed compare
lib/compiler_rt/cmpdf2.zig+8-8
...@@ -7,15 +7,15 @@ pub const panic = common.panic;...@@ -7,15 +7,15 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_aeabi) {9 if (common.want_aeabi) {
10 @export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage, .visibility = common.visibility });
13 } else {13 } else {
14 @export(__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__nedf2, .{ .name = "__nedf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__ledf2, .{ .name = "__ledf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage, .visibility = common.visibility });
19 }19 }
20}20}
2121
lib/compiler_rt/cmphf2.zig+5-5
...@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");...@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__nehf2, .{ .name = "__nehf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__lehf2, .{ .name = "__lehf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__lthf2, .{ .name = "__lthf2", .linkage = common.linkage, .visibility = common.visibility });
14}14}
1515
16/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;16/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/cmpsf2.zig+8-8
...@@ -7,15 +7,15 @@ pub const panic = common.panic;...@@ -7,15 +7,15 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_aeabi) {9 if (common.want_aeabi) {
10 @export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage, .visibility = common.visibility });
13 } else {13 } else {
14 @export(__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__nesf2, .{ .name = "__nesf2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__lesf2, .{ .name = "__lesf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage, .visibility = common.visibility });
19 }19 }
20}20}
2121
lib/compiler_rt/cmptf2.zig+16-16
...@@ -7,24 +7,24 @@ pub const panic = common.panic;...@@ -7,24 +7,24 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_ppc_abi) {9 if (common.want_ppc_abi) {
10 @export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__netf2, .{ .name = "__nekf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__letf2, .{ .name = "__lekf2", .linkage = common.linkage, .visibility = common.visibility });
14 } else if (common.want_sparc_abi) {14 } else if (common.want_sparc_abi) {
15 @export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility });15 @export(&_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage, .visibility = common.visibility });
16 @export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility });16 @export(&_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility });17 @export(&_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage, .visibility = common.visibility });
18 @export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility });18 @export(&_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage, .visibility = common.visibility });
19 @export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility });19 @export(&_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage, .visibility = common.visibility });
20 @export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility });20 @export(&_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage, .visibility = common.visibility });
21 @export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility });21 @export(&_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage, .visibility = common.visibility });
22 }22 }
23 @export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility });23 @export(&__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility });24 @export(&__netf2, .{ .name = "__netf2", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__letf2, .{ .name = "__letf2", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility });26 @export(&__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility });27 @export(&__lttf2, .{ .name = "__lttf2", .linkage = common.linkage, .visibility = common.visibility });
28}28}
2929
30/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;30/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/cmpxf2.zig+5-5
...@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");...@@ -6,11 +6,11 @@ const comparef = @import("./comparef.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__nexf2, .{ .name = "__nexf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__lexf2, .{ .name = "__lexf2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage, .visibility = common.visibility });
14}14}
1515
16/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;16/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
lib/compiler_rt/common.zig+1-1
...@@ -72,7 +72,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();...@@ -72,7 +72,7 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
72pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {72pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
73 _ = error_return_trace;73 _ = error_return_trace;
74 if (builtin.is_test) {74 if (builtin.is_test) {
75 @setCold(true);75 @branchHint(.cold);
76 std.debug.panic("{s}", .{msg});76 std.debug.panic("{s}", .{msg});
77 } else {77 } else {
78 unreachable;78 unreachable;
lib/compiler_rt/cos.zig+7-7
...@@ -11,15 +11,15 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2;...@@ -11,15 +11,15 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
11const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;11const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
1212
13comptime {13comptime {
14 @export(__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__cosh, .{ .name = "__cosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility });15 @export(&cosf, .{ .name = "cosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility });16 @export(&cos, .{ .name = "cos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__cosx, .{ .name = "__cosx", .linkage = common.linkage, .visibility = common.visibility });
18 if (common.want_ppc_abi) {18 if (common.want_ppc_abi) {
19 @export(cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility });19 @export(&cosq, .{ .name = "cosf128", .linkage = common.linkage, .visibility = common.visibility });
20 }20 }
21 @export(cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility });21 @export(&cosq, .{ .name = "cosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility });22 @export(&cosl, .{ .name = "cosl", .linkage = common.linkage, .visibility = common.visibility });
23}23}
2424
25pub fn __cosh(a: f16) callconv(.C) f16 {25pub fn __cosh(a: f16) callconv(.C) f16 {
lib/compiler_rt/count0bits.zig+9-9
...@@ -6,15 +6,15 @@ const common = @import("common.zig");...@@ -6,15 +6,15 @@ const common = @import("common.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__clzti2, .{ .name = "__clzti2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage, .visibility = common.visibility });
18}18}
1919
20// clz - count leading zeroes20// clz - count leading zeroes
lib/compiler_rt/divdc3.zig+1-1
...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
5comptime {5comptime {
6 if (@import("builtin").zig_backend != .stage2_c) {6 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__divdc3, .{ .name = "__divdc3", .linkage = common.linkage, .visibility = common.visibility });
8 }8 }
9}9}
1010
lib/compiler_rt/divdf3.zig+2-2
...@@ -15,9 +15,9 @@ pub const panic = common.panic;...@@ -15,9 +15,9 @@ pub const panic = common.panic;
1515
16comptime {16comptime {
17 if (common.want_aeabi) {17 if (common.want_aeabi) {
18 @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage, .visibility = common.visibility });
19 } else {19 } else {
20 @export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility });20 @export(&__divdf3, .{ .name = "__divdf3", .linkage = common.linkage, .visibility = common.visibility });
21 }21 }
22}22}
2323
lib/compiler_rt/divhc3.zig+1-1
...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
5comptime {5comptime {
6 if (@import("builtin").zig_backend != .stage2_c) {6 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__divhc3, .{ .name = "__divhc3", .linkage = common.linkage, .visibility = common.visibility });
8 }8 }
9}9}
1010
lib/compiler_rt/divhf3.zig+1-1
...@@ -2,7 +2,7 @@ const common = @import("common.zig");...@@ -2,7 +2,7 @@ const common = @import("common.zig");
2const divsf3 = @import("./divsf3.zig");2const divsf3 = @import("./divsf3.zig");
33
4comptime {4comptime {
5 @export(__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility });5 @export(&__divhf3, .{ .name = "__divhf3", .linkage = common.linkage, .visibility = common.visibility });
6}6}
77
8pub fn __divhf3(a: f16, b: f16) callconv(.C) f16 {8pub fn __divhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/divsc3.zig+1-1
...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
5comptime {5comptime {
6 if (@import("builtin").zig_backend != .stage2_c) {6 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__divsc3, .{ .name = "__divsc3", .linkage = common.linkage, .visibility = common.visibility });
8 }8 }
9}9}
1010
lib/compiler_rt/divsf3.zig+2-2
...@@ -13,9 +13,9 @@ pub const panic = common.panic;...@@ -13,9 +13,9 @@ pub const panic = common.panic;
1313
14comptime {14comptime {
15 if (common.want_aeabi) {15 if (common.want_aeabi) {
16 @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage, .visibility = common.visibility });
17 } else {17 } else {
18 @export(__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__divsf3, .{ .name = "__divsf3", .linkage = common.linkage, .visibility = common.visibility });
19 }19 }
20}20}
2121
lib/compiler_rt/divtc3.zig+2-2
...@@ -5,8 +5,8 @@ const Complex = @import("./mulc3.zig").Complex;...@@ -5,8 +5,8 @@ const Complex = @import("./mulc3.zig").Complex;
5comptime {5comptime {
6 if (@import("builtin").zig_backend != .stage2_c) {6 if (@import("builtin").zig_backend != .stage2_c) {
7 if (common.want_ppc_abi)7 if (common.want_ppc_abi)
8 @export(__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility });
9 @export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility });
10 }10 }
11}11}
1212
lib/compiler_rt/divtf3.zig+3-3
...@@ -9,11 +9,11 @@ pub const panic = common.panic;...@@ -9,11 +9,11 @@ pub const panic = common.panic;
99
10comptime {10comptime {
11 if (common.want_ppc_abi) {11 if (common.want_ppc_abi) {
12 @export(__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__divtf3, .{ .name = "__divkf3", .linkage = common.linkage, .visibility = common.visibility });
13 } else if (common.want_sparc_abi) {13 } else if (common.want_sparc_abi) {
14 @export(_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility });14 @export(&_Qp_div, .{ .name = "_Qp_div", .linkage = common.linkage, .visibility = common.visibility });
15 }15 }
16 @export(__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__divtf3, .{ .name = "__divtf3", .linkage = common.linkage, .visibility = common.visibility });
17}17}
1818
19pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {19pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/divti3.zig+2-2
...@@ -8,9 +8,9 @@ pub const panic = common.panic;...@@ -8,9 +8,9 @@ pub const panic = common.panic;
88
9comptime {9comptime {
10 if (common.want_windows_v2u64_abi) {10 if (common.want_windows_v2u64_abi) {
11 @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
12 } else {12 } else {
13 @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/divxc3.zig+1-1
...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;...@@ -4,7 +4,7 @@ const Complex = @import("./mulc3.zig").Complex;
44
5comptime {5comptime {
6 if (@import("builtin").zig_backend != .stage2_c) {6 if (@import("builtin").zig_backend != .stage2_c) {
7 @export(__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__divxc3, .{ .name = "__divxc3", .linkage = common.linkage, .visibility = common.visibility });
8 }8 }
9}9}
1010
lib/compiler_rt/divxf3.zig+1-1
...@@ -9,7 +9,7 @@ const wideMultiply = common.wideMultiply;...@@ -9,7 +9,7 @@ const wideMultiply = common.wideMultiply;
9pub const panic = common.panic;9pub const panic = common.panic;
1010
11comptime {11comptime {
12 @export(__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__divxf3, .{ .name = "__divxf3", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {15pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/emutls.zig+1-1
...@@ -19,7 +19,7 @@ pub const panic = common.panic;...@@ -19,7 +19,7 @@ pub const panic = common.panic;
1919
20comptime {20comptime {
21 if (builtin.link_libc and (builtin.abi == .android or builtin.os.tag == .openbsd)) {21 if (builtin.link_libc and (builtin.abi == .android or builtin.os.tag == .openbsd)) {
22 @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });22 @export(&__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage, .visibility = common.visibility });
23 }23 }
24}24}
2525
lib/compiler_rt/exp.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__exph, .{ .name = "__exph", .linkage = common.linkage, .visibility = common.visibility });
19 @export(expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility });19 @export(&expf, .{ .name = "expf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility });20 @export(&exp, .{ .name = "exp", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__expx, .{ .name = "__expx", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&expq, .{ .name = "expf128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility });25 @export(&expq, .{ .name = "expq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility });26 @export(&expl, .{ .name = "expl", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __exph(a: f16) callconv(.C) f16 {29pub fn __exph(a: f16) callconv(.C) f16 {
lib/compiler_rt/exp2.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__exp2h, .{ .name = "__exp2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility });19 @export(&exp2f, .{ .name = "exp2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility });20 @export(&exp2, .{ .name = "exp2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__exp2x, .{ .name = "__exp2x", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&exp2q, .{ .name = "exp2f128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility });25 @export(&exp2q, .{ .name = "exp2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility });26 @export(&exp2l, .{ .name = "exp2l", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __exp2h(x: f16) callconv(.C) f16 {29pub fn __exp2h(x: f16) callconv(.C) f16 {
lib/compiler_rt/extenddftf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__extenddftf2, .{ .name = "__extenddfkf2", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__extenddftf2, .{ .name = "__extenddftf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __extenddftf2(a: f64) callconv(.C) f128 {15pub fn __extenddftf2(a: f64) callconv(.C) f128 {
lib/compiler_rt/extenddfxf2.zig+1-1
...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extenddfxf2, .{ .name = "__extenddfxf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __extenddfxf2(a: f64) callconv(.C) f80 {10pub fn __extenddfxf2(a: f64) callconv(.C) f80 {
lib/compiler_rt/extendhfdf2.zig+1-1
...@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;...@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extendhfdf2, .{ .name = "__extendhfdf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.C) f64 {10pub fn __extendhfdf2(a: common.F16T(f64)) callconv(.C) f64 {
lib/compiler_rt/extendhfsf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.gnu_f16_abi) {7 if (common.gnu_f16_abi) {
8 @export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_aeabi) {9 } else if (common.want_aeabi) {
10 @export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__extendhfsf2, .{ .name = "__extendhfsf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.C) f32 {15pub fn __extendhfsf2(a: common.F16T(f32)) callconv(.C) f32 {
lib/compiler_rt/extendhftf2.zig+1-1
...@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;...@@ -4,7 +4,7 @@ const extendf = @import("./extendf.zig").extendf;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extendhftf2, .{ .name = "__extendhftf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __extendhftf2(a: common.F16T(f128)) callconv(.C) f128 {10pub fn __extendhftf2(a: common.F16T(f128)) callconv(.C) f128 {
lib/compiler_rt/extendhfxf2.zig+1-1
...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extendhfxf2, .{ .name = "__extendhfxf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __extendhfxf2(a: common.F16T(f80)) callconv(.C) f80 {10fn __extendhfxf2(a: common.F16T(f80)) callconv(.C) f80 {
lib/compiler_rt/extendsfdf2.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_f2d, .{ .name = "__aeabi_f2d", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__extendsfdf2, .{ .name = "__extendsfdf2", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/extendsftf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__extendsftf2, .{ .name = "__extendsfkf2", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_stoq, .{ .name = "_Qp_stoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__extendsftf2, .{ .name = "__extendsftf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __extendsftf2(a: f32) callconv(.C) f128 {15pub fn __extendsftf2(a: f32) callconv(.C) f128 {
lib/compiler_rt/extendsfxf2.zig+1-1
...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;...@@ -4,7 +4,7 @@ const extend_f80 = @import("./extendf.zig").extend_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extendsfxf2, .{ .name = "__extendsfxf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __extendsfxf2(a: f32) callconv(.C) f80 {10fn __extendsfxf2(a: f32) callconv(.C) f80 {
lib/compiler_rt/extendxftf2.zig+1-1
...@@ -4,7 +4,7 @@ const common = @import("./common.zig");...@@ -4,7 +4,7 @@ const common = @import("./common.zig");
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__extendxftf2, .{ .name = "__extendxftf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __extendxftf2(a: f80) callconv(.C) f128 {10fn __extendxftf2(a: f80) callconv(.C) f128 {
lib/compiler_rt/fabs.zig+7-7
...@@ -6,15 +6,15 @@ const common = @import("common.zig");...@@ -6,15 +6,15 @@ const common = @import("common.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fabsh, .{ .name = "__fabsh", .linkage = common.linkage, .visibility = common.visibility });
10 @export(fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&fabsf, .{ .name = "fabsf", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility });11 @export(&fabs, .{ .name = "fabs", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fabsx, .{ .name = "__fabsx", .linkage = common.linkage, .visibility = common.visibility });
13 if (common.want_ppc_abi) {13 if (common.want_ppc_abi) {
14 @export(fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility });14 @export(&fabsq, .{ .name = "fabsf128", .linkage = common.linkage, .visibility = common.visibility });
15 }15 }
16 @export(fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility });16 @export(&fabsq, .{ .name = "fabsq", .linkage = common.linkage, .visibility = common.visibility });
17 @export(fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility });17 @export(&fabsl, .{ .name = "fabsl", .linkage = common.linkage, .visibility = common.visibility });
18}18}
1919
20pub fn __fabsh(a: f16) callconv(.C) f16 {20pub fn __fabsh(a: f16) callconv(.C) f16 {
lib/compiler_rt/fixdfdi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2lz, .{ .name = "__aeabi_d2lz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixdfdi, .{ .name = "__fixdfdi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixdfsi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2iz, .{ .name = "__aeabi_d2iz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixdfsi, .{ .name = "__fixdfsi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixdfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixdfti_windows_x86_64, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixdfti, .{ .name = "__fixdfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixhfdi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixhfdi, .{ .name = "__fixhfdi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixhfdi(a: f16) callconv(.C) i64 {10fn __fixhfdi(a: f16) callconv(.C) i64 {
lib/compiler_rt/fixhfsi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixhfsi, .{ .name = "__fixhfsi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixhfsi(a: f16) callconv(.C) i32 {10fn __fixhfsi(a: f16) callconv(.C) i32 {
lib/compiler_rt/fixhfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixhfti_windows_x86_64, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixhfti, .{ .name = "__fixhfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixsfdi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_f2lz, .{ .name = "__aeabi_f2lz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixsfdi, .{ .name = "__fixsfdi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixsfsi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_f2iz, .{ .name = "__aeabi_f2iz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixsfsi, .{ .name = "__fixsfsi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixsfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixsfti_windows_x86_64, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixsfti, .{ .name = "__fixsfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixtfdi.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__fixtfdi, .{ .name = "__fixkfdi", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtox, .{ .name = "_Qp_qtox", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixtfdi, .{ .name = "__fixtfdi", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __fixtfdi(a: f128) callconv(.C) i64 {15pub fn __fixtfdi(a: f128) callconv(.C) i64 {
lib/compiler_rt/fixtfsi.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__fixtfsi, .{ .name = "__fixkfsi", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtoi, .{ .name = "_Qp_qtoi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixtfsi, .{ .name = "__fixtfsi", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __fixtfsi(a: f128) callconv(.C) i32 {15pub fn __fixtfsi(a: f128) callconv(.C) i32 {
lib/compiler_rt/fixtfti.zig+3-3
...@@ -6,11 +6,11 @@ pub const panic = common.panic;...@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 if (common.want_ppc_abi)11 if (common.want_ppc_abi)
12 @export(__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/fixunsdfdi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2ulz, .{ .name = "__aeabi_d2ulz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixunsdfdi, .{ .name = "__fixunsdfdi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixunsdfsi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2uiz, .{ .name = "__aeabi_d2uiz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixunsdfsi, .{ .name = "__fixunsdfsi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixunsdfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixunsdfti_windows_x86_64, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixunsdfti, .{ .name = "__fixunsdfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixunshfdi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixunshfdi, .{ .name = "__fixunshfdi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixunshfdi(a: f16) callconv(.C) u64 {10fn __fixunshfdi(a: f16) callconv(.C) u64 {
lib/compiler_rt/fixunshfsi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixunshfsi, .{ .name = "__fixunshfsi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixunshfsi(a: f16) callconv(.C) u32 {10fn __fixunshfsi(a: f16) callconv(.C) u32 {
lib/compiler_rt/fixunshfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixunshfti_windows_x86_64, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixunshfti, .{ .name = "__fixunshfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixunssfdi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_f2ulz, .{ .name = "__aeabi_f2ulz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixunssfdi, .{ .name = "__fixunssfdi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixunssfsi.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_f2uiz, .{ .name = "__aeabi_f2uiz", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fixunssfsi, .{ .name = "__fixunssfsi", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/fixunssfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixunssfti_windows_x86_64, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixunssfti, .{ .name = "__fixunssfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixunstfdi.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__fixunstfdi, .{ .name = "__fixunskfdi", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtoux, .{ .name = "_Qp_qtoux", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixunstfdi, .{ .name = "__fixunstfdi", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __fixunstfdi(a: f128) callconv(.C) u64 {15pub fn __fixunstfdi(a: f128) callconv(.C) u64 {
lib/compiler_rt/fixunstfsi.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__fixunstfsi, .{ .name = "__fixunskfsi", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtoui, .{ .name = "_Qp_qtoui", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixunstfsi, .{ .name = "__fixunstfsi", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __fixunstfsi(a: f128) callconv(.C) u32 {15pub fn __fixunstfsi(a: f128) callconv(.C) u32 {
lib/compiler_rt/fixunstfti.zig+3-3
...@@ -6,11 +6,11 @@ pub const panic = common.panic;...@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 if (common.want_ppc_abi)11 if (common.want_ppc_abi)
12 @export(__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/fixunsxfdi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixunsxfdi, .{ .name = "__fixunsxfdi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixunsxfdi(a: f80) callconv(.C) u64 {10fn __fixunsxfdi(a: f80) callconv(.C) u64 {
lib/compiler_rt/fixunsxfsi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixunsxfsi, .{ .name = "__fixunsxfsi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixunsxfsi(a: f80) callconv(.C) u32 {10fn __fixunsxfsi(a: f80) callconv(.C) u32 {
lib/compiler_rt/fixunsxfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixunsxfti_windows_x86_64, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixunsxfti, .{ .name = "__fixunsxfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/fixxfdi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixxfdi, .{ .name = "__fixxfdi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixxfdi(a: f80) callconv(.C) i64 {10fn __fixxfdi(a: f80) callconv(.C) i64 {
lib/compiler_rt/fixxfsi.zig+1-1
...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;...@@ -4,7 +4,7 @@ const intFromFloat = @import("./int_from_float.zig").intFromFloat;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__fixxfsi, .{ .name = "__fixxfsi", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __fixxfsi(a: f80) callconv(.C) i32 {10fn __fixxfsi(a: f80) callconv(.C) i32 {
lib/compiler_rt/fixxfti.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__fixxfti_windows_x86_64, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__fixxfti, .{ .name = "__fixxfti", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floatdidf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_l2d, .{ .name = "__aeabi_l2d", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatdidf, .{ .name = "__floatdidf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatdihf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatdihf, .{ .name = "__floatdihf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatdihf(a: i64) callconv(.C) f16 {10fn __floatdihf(a: i64) callconv(.C) f16 {
lib/compiler_rt/floatdisf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_l2f, .{ .name = "__aeabi_l2f", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatdisf, .{ .name = "__floatdisf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatditf.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__floatditf, .{ .name = "__floatdikf", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_xtoq, .{ .name = "_Qp_xtoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floatditf, .{ .name = "__floatditf", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __floatditf(a: i64) callconv(.C) f128 {15pub fn __floatditf(a: i64) callconv(.C) f128 {
lib/compiler_rt/floatdixf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatdixf, .{ .name = "__floatdixf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatdixf(a: i64) callconv(.C) f80 {10fn __floatdixf(a: i64) callconv(.C) f80 {
lib/compiler_rt/floatsidf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_i2d, .{ .name = "__aeabi_i2d", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatsidf, .{ .name = "__floatsidf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatsihf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatsihf, .{ .name = "__floatsihf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatsihf(a: i32) callconv(.C) f16 {10fn __floatsihf(a: i32) callconv(.C) f16 {
lib/compiler_rt/floatsisf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_i2f, .{ .name = "__aeabi_i2f", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatsisf, .{ .name = "__floatsisf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatsitf.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__floatsitf, .{ .name = "__floatsikf", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_itoq, .{ .name = "_Qp_itoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floatsitf, .{ .name = "__floatsitf", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __floatsitf(a: i32) callconv(.C) f128 {15pub fn __floatsitf(a: i32) callconv(.C) f128 {
lib/compiler_rt/floatsixf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatsixf, .{ .name = "__floatsixf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatsixf(a: i32) callconv(.C) f80 {10fn __floatsixf(a: i32) callconv(.C) f80 {
lib/compiler_rt/floattidf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floattidf_windows_x86_64, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floattidf, .{ .name = "__floattidf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floattihf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floattihf_windows_x86_64, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floattihf, .{ .name = "__floattihf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floattisf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floattisf_windows_x86_64, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floattisf, .{ .name = "__floattisf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floattitf.zig+3-3
...@@ -6,11 +6,11 @@ pub const panic = common.panic;...@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 if (common.want_ppc_abi)11 if (common.want_ppc_abi)
12 @export(__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/floattixf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floattixf_windows_x86_64, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floattixf, .{ .name = "__floattixf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floatundidf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_ul2d, .{ .name = "__aeabi_ul2d", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatundidf, .{ .name = "__floatundidf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatundihf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatundihf, .{ .name = "__floatundihf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatundihf(a: u64) callconv(.C) f16 {10fn __floatundihf(a: u64) callconv(.C) f16 {
lib/compiler_rt/floatundisf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_ul2f, .{ .name = "__aeabi_ul2f", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatundisf, .{ .name = "__floatundisf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatunditf.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__floatunditf, .{ .name = "__floatundikf", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_uxtoq, .{ .name = "_Qp_uxtoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floatunditf, .{ .name = "__floatunditf", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __floatunditf(a: u64) callconv(.C) f128 {15pub fn __floatunditf(a: u64) callconv(.C) f128 {
lib/compiler_rt/floatundixf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatundixf, .{ .name = "__floatundixf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatundixf(a: u64) callconv(.C) f80 {10fn __floatundixf(a: u64) callconv(.C) f80 {
lib/compiler_rt/floatunsidf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_ui2d, .{ .name = "__aeabi_ui2d", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatunsidf, .{ .name = "__floatunsidf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatunsihf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatunsihf, .{ .name = "__floatunsihf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __floatunsihf(a: u32) callconv(.C) f16 {10pub fn __floatunsihf(a: u32) callconv(.C) f16 {
lib/compiler_rt/floatunsisf.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_ui2f, .{ .name = "__aeabi_ui2f", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__floatunsisf, .{ .name = "__floatunsisf", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/floatunsitf.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__floatunsitf, .{ .name = "__floatunsikf", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_uitoq, .{ .name = "_Qp_uitoq", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floatunsitf, .{ .name = "__floatunsitf", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __floatunsitf(a: u32) callconv(.C) f128 {15pub fn __floatunsitf(a: u32) callconv(.C) f128 {
lib/compiler_rt/floatunsixf.zig+1-1
...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;...@@ -4,7 +4,7 @@ const floatFromInt = @import("./float_from_int.zig").floatFromInt;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__floatunsixf, .{ .name = "__floatunsixf", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __floatunsixf(a: u32) callconv(.C) f80 {10fn __floatunsixf(a: u32) callconv(.C) f80 {
lib/compiler_rt/floatuntidf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floatuntidf_windows_x86_64, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floatuntidf, .{ .name = "__floatuntidf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floatuntihf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floatuntihf_windows_x86_64, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floatuntihf, .{ .name = "__floatuntihf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floatuntisf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floatuntisf_windows_x86_64, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floatuntisf, .{ .name = "__floatuntisf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floatuntitf.zig+3-3
...@@ -6,11 +6,11 @@ pub const panic = common.panic;...@@ -6,11 +6,11 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floatuntitf_windows_x86_64, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 if (common.want_ppc_abi)11 if (common.want_ppc_abi)
12 @export(__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__floatuntitf, .{ .name = "__floatuntikf", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__floatuntitf, .{ .name = "__floatuntitf", .linkage = common.linkage, .visibility = common.visibility });
14 }14 }
15}15}
1616
lib/compiler_rt/floatuntixf.zig+2-2
...@@ -6,9 +6,9 @@ pub const panic = common.panic;...@@ -6,9 +6,9 @@ pub const panic = common.panic;
66
7comptime {7comptime {
8 if (common.want_windows_v2u64_abi) {8 if (common.want_windows_v2u64_abi) {
9 @export(__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__floatuntixf_windows_x86_64, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
10 } else {10 } else {
11 @export(__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__floatuntixf, .{ .name = "__floatuntixf", .linkage = common.linkage, .visibility = common.visibility });
12 }12 }
13}13}
1414
lib/compiler_rt/floor.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__floorh, .{ .name = "__floorh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility });19 @export(&floorf, .{ .name = "floorf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility });20 @export(&floor, .{ .name = "floor", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__floorx, .{ .name = "__floorx", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&floorq, .{ .name = "floorf128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility });25 @export(&floorq, .{ .name = "floorq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility });26 @export(&floorl, .{ .name = "floorl", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __floorh(x: f16) callconv(.C) f16 {29pub fn __floorh(x: f16) callconv(.C) f16 {
lib/compiler_rt/fma.zig+7-7
...@@ -13,15 +13,15 @@ const common = @import("common.zig");...@@ -13,15 +13,15 @@ const common = @import("common.zig");
13pub const panic = common.panic;13pub const panic = common.panic;
1414
15comptime {15comptime {
16 @export(__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__fmah, .{ .name = "__fmah", .linkage = common.linkage, .visibility = common.visibility });
17 @export(fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility });17 @export(&fmaf, .{ .name = "fmaf", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility });18 @export(&fma, .{ .name = "fma", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility });19 @export(&__fmax, .{ .name = "__fmax", .linkage = common.linkage, .visibility = common.visibility });
20 if (common.want_ppc_abi) {20 if (common.want_ppc_abi) {
21 @export(fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility });21 @export(&fmaq, .{ .name = "fmaf128", .linkage = common.linkage, .visibility = common.visibility });
22 }22 }
23 @export(fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility });23 @export(&fmaq, .{ .name = "fmaq", .linkage = common.linkage, .visibility = common.visibility });
24 @export(fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility });24 @export(&fmal, .{ .name = "fmal", .linkage = common.linkage, .visibility = common.visibility });
25}25}
2626
27pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 {27pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 {
lib/compiler_rt/fmax.zig+7-7
...@@ -7,15 +7,15 @@ const common = @import("common.zig");...@@ -7,15 +7,15 @@ const common = @import("common.zig");
7pub const panic = common.panic;7pub const panic = common.panic;
88
9comptime {9comptime {
10 @export(__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&fmaxf, .{ .name = "fmaxf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility });12 @export(&fmax, .{ .name = "fmax", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage, .visibility = common.visibility });
14 if (common.want_ppc_abi) {14 if (common.want_ppc_abi) {
15 @export(fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility });15 @export(&fmaxq, .{ .name = "fmaxf128", .linkage = common.linkage, .visibility = common.visibility });
16 }16 }
17 @export(fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility });17 @export(&fmaxq, .{ .name = "fmaxq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility });18 @export(&fmaxl, .{ .name = "fmaxl", .linkage = common.linkage, .visibility = common.visibility });
19}19}
2020
21pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 {21pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/fmin.zig+7-7
...@@ -7,15 +7,15 @@ const common = @import("common.zig");...@@ -7,15 +7,15 @@ const common = @import("common.zig");
7pub const panic = common.panic;7pub const panic = common.panic;
88
9comptime {9comptime {
10 @export(__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__fminh, .{ .name = "__fminh", .linkage = common.linkage, .visibility = common.visibility });
11 @export(fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&fminf, .{ .name = "fminf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility });12 @export(&fmin, .{ .name = "fmin", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__fminx, .{ .name = "__fminx", .linkage = common.linkage, .visibility = common.visibility });
14 if (common.want_ppc_abi) {14 if (common.want_ppc_abi) {
15 @export(fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility });15 @export(&fminq, .{ .name = "fminf128", .linkage = common.linkage, .visibility = common.visibility });
16 }16 }
17 @export(fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility });17 @export(&fminq, .{ .name = "fminq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility });18 @export(&fminl, .{ .name = "fminl", .linkage = common.linkage, .visibility = common.visibility });
19}19}
2020
21pub fn __fminh(x: f16, y: f16) callconv(.C) f16 {21pub fn __fminh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/fmod.zig+7-7
...@@ -9,15 +9,15 @@ const normalize = common.normalize;...@@ -9,15 +9,15 @@ const normalize = common.normalize;
9pub const panic = common.panic;9pub const panic = common.panic;
1010
11comptime {11comptime {
12 @export(__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__fmodh, .{ .name = "__fmodh", .linkage = common.linkage, .visibility = common.visibility });
13 @export(fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility });13 @export(&fmodf, .{ .name = "fmodf", .linkage = common.linkage, .visibility = common.visibility });
14 @export(fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility });14 @export(&fmod, .{ .name = "fmod", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__fmodx, .{ .name = "__fmodx", .linkage = common.linkage, .visibility = common.visibility });
16 if (common.want_ppc_abi) {16 if (common.want_ppc_abi) {
17 @export(fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility });17 @export(&fmodq, .{ .name = "fmodf128", .linkage = common.linkage, .visibility = common.visibility });
18 }18 }
19 @export(fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility });19 @export(&fmodq, .{ .name = "fmodq", .linkage = common.linkage, .visibility = common.visibility });
20 @export(fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility });20 @export(&fmodl, .{ .name = "fmodl", .linkage = common.linkage, .visibility = common.visibility });
21}21}
2222
23pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 {23pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 {
lib/compiler_rt/gedf2.zig+4-4
...@@ -7,11 +7,11 @@ pub const panic = common.panic;...@@ -7,11 +7,11 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_aeabi) {9 if (common.want_aeabi) {
10 @export(__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_dcmpge, .{ .name = "__aeabi_dcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__aeabi_dcmpgt, .{ .name = "__aeabi_dcmpgt", .linkage = common.linkage, .visibility = common.visibility });
12 } else {12 } else {
13 @export(__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__gedf2, .{ .name = "__gedf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__gtdf2, .{ .name = "__gtdf2", .linkage = common.linkage, .visibility = common.visibility });
15 }15 }
16}16}
1717
lib/compiler_rt/gehf2.zig+2-2
...@@ -6,8 +6,8 @@ const comparef = @import("./comparef.zig");...@@ -6,8 +6,8 @@ const comparef = @import("./comparef.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__gehf2, .{ .name = "__gehf2", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__gthf2, .{ .name = "__gthf2", .linkage = common.linkage, .visibility = common.visibility });
11}11}
1212
13/// "These functions return a value greater than or equal to zero if neither13/// "These functions return a value greater than or equal to zero if neither
lib/compiler_rt/gesf2.zig+4-4
...@@ -7,11 +7,11 @@ pub const panic = common.panic;...@@ -7,11 +7,11 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_aeabi) {9 if (common.want_aeabi) {
10 @export(__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_fcmpge, .{ .name = "__aeabi_fcmpge", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__aeabi_fcmpgt, .{ .name = "__aeabi_fcmpgt", .linkage = common.linkage, .visibility = common.visibility });
12 } else {12 } else {
13 @export(__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__gesf2, .{ .name = "__gesf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__gtsf2, .{ .name = "__gtsf2", .linkage = common.linkage, .visibility = common.visibility });
15 }15 }
16}16}
1717
lib/compiler_rt/getf2.zig+4-4
...@@ -7,14 +7,14 @@ pub const panic = common.panic;...@@ -7,14 +7,14 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_ppc_abi) {9 if (common.want_ppc_abi) {
10 @export(__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__getf2, .{ .name = "__gekf2", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__gttf2, .{ .name = "__gtkf2", .linkage = common.linkage, .visibility = common.visibility });
12 } else if (common.want_sparc_abi) {12 } else if (common.want_sparc_abi) {
13 // These exports are handled in cmptf2.zig because gt and ge on sparc13 // These exports are handled in cmptf2.zig because gt and ge on sparc
14 // are based on calling _Qp_cmp.14 // are based on calling _Qp_cmp.
15 }15 }
16 @export(__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__getf2, .{ .name = "__getf2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__gttf2, .{ .name = "__gttf2", .linkage = common.linkage, .visibility = common.visibility });
18}18}
1919
20/// "These functions return a value greater than or equal to zero if neither20/// "These functions return a value greater than or equal to zero if neither
lib/compiler_rt/gexf2.zig+2-2
...@@ -4,8 +4,8 @@ const comparef = @import("./comparef.zig");...@@ -4,8 +4,8 @@ const comparef = @import("./comparef.zig");
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__gexf2, .{ .name = "__gexf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__gtxf2, .{ .name = "__gtxf2", .linkage = common.linkage, .visibility = common.visibility });
9}9}
1010
11fn __gexf2(a: f80, b: f80) callconv(.C) i32 {11fn __gexf2(a: f80, b: f80) callconv(.C) i32 {
lib/compiler_rt/int.zig+15-15
...@@ -15,24 +15,24 @@ const arm = @import("arm.zig");...@@ -15,24 +15,24 @@ const arm = @import("arm.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__divmodti4, .{ .name = "__divmodti4", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility });19 @export(&__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility });20 @export(&__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage, .visibility = common.visibility });
21 if (common.want_aeabi) {21 if (common.want_aeabi) {
22 @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility });22 @export(&__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage, .visibility = common.visibility });
23 @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility });23 @export(&__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage, .visibility = common.visibility });
24 } else {24 } else {
25 @export(__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__divsi3, .{ .name = "__divsi3", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility });26 @export(&__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage, .visibility = common.visibility });
27 }27 }
28 @export(__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility });28 @export(&__divdi3, .{ .name = "__divdi3", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility });29 @export(&__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage, .visibility = common.visibility });
30 @export(__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility });30 @export(&__modsi3, .{ .name = "__modsi3", .linkage = common.linkage, .visibility = common.visibility });
31 @export(__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility });31 @export(&__moddi3, .{ .name = "__moddi3", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility });32 @export(&__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility });33 @export(&__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage, .visibility = common.visibility });
34 @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility });34 @export(&__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage, .visibility = common.visibility });
35 @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility });35 @export(&__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage, .visibility = common.visibility });
36}36}
3737
38pub fn __divmodti4(a: i128, b: i128, rem: *i128) callconv(.C) i128 {38pub fn __divmodti4(a: i128, b: i128, rem: *i128) callconv(.C) i128 {
lib/compiler_rt/log.zig+7-7
...@@ -14,15 +14,15 @@ const common = @import("common.zig");...@@ -14,15 +14,15 @@ const common = @import("common.zig");
14pub const panic = common.panic;14pub const panic = common.panic;
1515
16comptime {16comptime {
17 @export(__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__logh, .{ .name = "__logh", .linkage = common.linkage, .visibility = common.visibility });
18 @export(logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility });18 @export(&logf, .{ .name = "logf", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility });19 @export(&log, .{ .name = "log", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility });20 @export(&__logx, .{ .name = "__logx", .linkage = common.linkage, .visibility = common.visibility });
21 if (common.want_ppc_abi) {21 if (common.want_ppc_abi) {
22 @export(logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility });22 @export(&logq, .{ .name = "logf128", .linkage = common.linkage, .visibility = common.visibility });
23 }23 }
24 @export(logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility });24 @export(&logq, .{ .name = "logq", .linkage = common.linkage, .visibility = common.visibility });
25 @export(logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility });25 @export(&logl, .{ .name = "logl", .linkage = common.linkage, .visibility = common.visibility });
26}26}
2727
28pub fn __logh(a: f16) callconv(.C) f16 {28pub fn __logh(a: f16) callconv(.C) f16 {
lib/compiler_rt/log10.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__log10h, .{ .name = "__log10h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility });19 @export(&log10f, .{ .name = "log10f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility });20 @export(&log10, .{ .name = "log10", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__log10x, .{ .name = "__log10x", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&log10q, .{ .name = "log10f128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility });25 @export(&log10q, .{ .name = "log10q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility });26 @export(&log10l, .{ .name = "log10l", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __log10h(a: f16) callconv(.C) f16 {29pub fn __log10h(a: f16) callconv(.C) f16 {
lib/compiler_rt/log2.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__log2h, .{ .name = "__log2h", .linkage = common.linkage, .visibility = common.visibility });
19 @export(log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility });19 @export(&log2f, .{ .name = "log2f", .linkage = common.linkage, .visibility = common.visibility });
20 @export(log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility });20 @export(&log2, .{ .name = "log2", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__log2x, .{ .name = "__log2x", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&log2q, .{ .name = "log2f128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility });25 @export(&log2q, .{ .name = "log2q", .linkage = common.linkage, .visibility = common.visibility });
26 @export(log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility });26 @export(&log2l, .{ .name = "log2l", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __log2h(a: f16) callconv(.C) f16 {29pub fn __log2h(a: f16) callconv(.C) f16 {
lib/compiler_rt/memcmp.zig+1-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const common = @import("./common.zig");2const common = @import("./common.zig");
33
4comptime {4comptime {
5 @export(memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility });5 @export(&memcmp, .{ .name = "memcmp", .linkage = common.linkage, .visibility = common.visibility });
6}6}
77
8pub fn memcmp(vl: [*]const u8, vr: [*]const u8, n: usize) callconv(.C) c_int {8pub fn memcmp(vl: [*]const u8, vr: [*]const u8, n: usize) callconv(.C) c_int {
lib/compiler_rt/memcpy.zig+1-1
...@@ -4,7 +4,7 @@ const builtin = @import("builtin");...@@ -4,7 +4,7 @@ const builtin = @import("builtin");
44
5comptime {5comptime {
6 if (builtin.object_format != .c) {6 if (builtin.object_format != .c) {
7 @export(memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility });7 @export(&memcpy, .{ .name = "memcpy", .linkage = common.linkage, .visibility = common.visibility });
8 }8 }
9}9}
1010
lib/compiler_rt/memmove.zig+1-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const common = @import("./common.zig");2const common = @import("./common.zig");
33
4comptime {4comptime {
5 @export(memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility });5 @export(&memmove, .{ .name = "memmove", .linkage = common.linkage, .visibility = common.visibility });
6}6}
77
8pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {8pub fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 {
lib/compiler_rt/memset.zig+2-2
...@@ -4,8 +4,8 @@ const builtin = @import("builtin");...@@ -4,8 +4,8 @@ const builtin = @import("builtin");
44
5comptime {5comptime {
6 if (builtin.object_format != .c) {6 if (builtin.object_format != .c) {
7 @export(memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility });7 @export(&memset, .{ .name = "memset", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__memset, .{ .name = "__memset", .linkage = common.linkage, .visibility = common.visibility });
9 }9 }
10}10}
1111
lib/compiler_rt/modti3.zig+2-2
...@@ -11,9 +11,9 @@ pub const panic = common.panic;...@@ -11,9 +11,9 @@ pub const panic = common.panic;
1111
12comptime {12comptime {
13 if (common.want_windows_v2u64_abi) {13 if (common.want_windows_v2u64_abi) {
14 @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
15 } else {15 } else {
16 @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__modti3, .{ .name = "__modti3", .linkage = common.linkage, .visibility = common.visibility });
17 }17 }
18}18}
1919
lib/compiler_rt/mulXi3.zig+5-5
...@@ -7,16 +7,16 @@ const native_endian = builtin.cpu.arch.endian();...@@ -7,16 +7,16 @@ const native_endian = builtin.cpu.arch.endian();
7pub const panic = common.panic;7pub const panic = common.panic;
88
9comptime {9comptime {
10 @export(__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage, .visibility = common.visibility });
11 if (common.want_aeabi) {11 if (common.want_aeabi) {
12 @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage, .visibility = common.visibility });
13 } else {13 } else {
14 @export(__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__muldi3, .{ .name = "__muldi3", .linkage = common.linkage, .visibility = common.visibility });
15 }15 }
16 if (common.want_windows_v2u64_abi) {16 if (common.want_windows_v2u64_abi) {
17 @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
18 } else {18 } else {
19 @export(__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });19 @export(&__multi3, .{ .name = "__multi3", .linkage = common.linkage, .visibility = common.visibility });
20 }20 }
21}21}
2222
lib/compiler_rt/muldc3.zig+1-1
...@@ -5,7 +5,7 @@ pub const panic = common.panic;...@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (@import("builtin").zig_backend != .stage2_c) {7 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__muldc3, .{ .name = "__muldc3", .linkage = common.linkage, .visibility = common.visibility });
9 }9 }
10}10}
1111
lib/compiler_rt/muldf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_dmul, .{ .name = "__aeabi_dmul", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__muldf3, .{ .name = "__muldf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/mulhc3.zig+1-1
...@@ -5,7 +5,7 @@ pub const panic = common.panic;...@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (@import("builtin").zig_backend != .stage2_c) {7 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__mulhc3, .{ .name = "__mulhc3", .linkage = common.linkage, .visibility = common.visibility });
9 }9 }
10}10}
1111
lib/compiler_rt/mulhf3.zig+1-1
...@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;...@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__mulhf3, .{ .name = "__mulhf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __mulhf3(a: f16, b: f16) callconv(.C) f16 {10pub fn __mulhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/mulo.zig+3-3
...@@ -6,9 +6,9 @@ const common = @import("common.zig");...@@ -6,9 +6,9 @@ const common = @import("common.zig");
6pub const panic = common.panic;6pub const panic = common.panic;
77
8comptime {8comptime {
9 @export(__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__muloti4, .{ .name = "__muloti4", .linkage = common.linkage, .visibility = common.visibility });
12}12}
1313
14// mulo - multiplication overflow14// mulo - multiplication overflow
lib/compiler_rt/mulsc3.zig+1-1
...@@ -5,7 +5,7 @@ pub const panic = common.panic;...@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (@import("builtin").zig_backend != .stage2_c) {7 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__mulsc3, .{ .name = "__mulsc3", .linkage = common.linkage, .visibility = common.visibility });
9 }9 }
10}10}
1111
lib/compiler_rt/mulsf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_fmul, .{ .name = "__aeabi_fmul", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__mulsf3, .{ .name = "__mulsf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/multc3.zig+2-2
...@@ -6,8 +6,8 @@ pub const panic = common.panic;...@@ -6,8 +6,8 @@ pub const panic = common.panic;
6comptime {6comptime {
7 if (@import("builtin").zig_backend != .stage2_c) {7 if (@import("builtin").zig_backend != .stage2_c) {
8 if (common.want_ppc_abi)8 if (common.want_ppc_abi)
9 @export(__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility });
10 @export(__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/multf3.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__multf3, .{ .name = "__mulkf3", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_mul, .{ .name = "_Qp_mul", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__multf3, .{ .name = "__multf3", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {15pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/mulxc3.zig+1-1
...@@ -5,7 +5,7 @@ pub const panic = common.panic;...@@ -5,7 +5,7 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (@import("builtin").zig_backend != .stage2_c) {7 if (@import("builtin").zig_backend != .stage2_c) {
8 @export(__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__mulxc3, .{ .name = "__mulxc3", .linkage = common.linkage, .visibility = common.visibility });
9 }9 }
10}10}
1111
lib/compiler_rt/mulxf3.zig+1-1
...@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;...@@ -4,7 +4,7 @@ const mulf3 = @import("./mulf3.zig").mulf3;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__mulxf3, .{ .name = "__mulxf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __mulxf3(a: f80, b: f80) callconv(.C) f80 {10pub fn __mulxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/negXi2.zig+3-3
...@@ -13,9 +13,9 @@ const common = @import("common.zig");...@@ -13,9 +13,9 @@ const common = @import("common.zig");
13pub const panic = common.panic;13pub const panic = common.panic;
1414
15comptime {15comptime {
16 @export(__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__negsi2, .{ .name = "__negsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__negdi2, .{ .name = "__negdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__negti2, .{ .name = "__negti2", .linkage = common.linkage, .visibility = common.visibility });
19}19}
2020
21pub fn __negsi2(a: i32) callconv(.C) i32 {21pub fn __negsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/negdf2.zig+2-2
...@@ -4,9 +4,9 @@ pub const panic = common.panic;...@@ -4,9 +4,9 @@ pub const panic = common.panic;
44
5comptime {5comptime {
6 if (common.want_aeabi) {6 if (common.want_aeabi) {
7 @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage, .visibility = common.visibility });
8 } else {8 } else {
9 @export(__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__negdf2, .{ .name = "__negdf2", .linkage = common.linkage, .visibility = common.visibility });
10 }10 }
11}11}
1212
lib/compiler_rt/neghf2.zig+1-1
...@@ -3,7 +3,7 @@ const common = @import("./common.zig");...@@ -3,7 +3,7 @@ const common = @import("./common.zig");
3pub const panic = common.panic;3pub const panic = common.panic;
44
5comptime {5comptime {
6 @export(__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility });6 @export(&__neghf2, .{ .name = "__neghf2", .linkage = common.linkage, .visibility = common.visibility });
7}7}
88
9fn __neghf2(a: f16) callconv(.C) f16 {9fn __neghf2(a: f16) callconv(.C) f16 {
lib/compiler_rt/negsf2.zig+2-2
...@@ -4,9 +4,9 @@ pub const panic = common.panic;...@@ -4,9 +4,9 @@ pub const panic = common.panic;
44
5comptime {5comptime {
6 if (common.want_aeabi) {6 if (common.want_aeabi) {
7 @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage, .visibility = common.visibility });
8 } else {8 } else {
9 @export(__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility });9 @export(&__negsf2, .{ .name = "__negsf2", .linkage = common.linkage, .visibility = common.visibility });
10 }10 }
11}11}
1212
lib/compiler_rt/negtf2.zig+2-2
...@@ -4,8 +4,8 @@ pub const panic = common.panic;...@@ -4,8 +4,8 @@ pub const panic = common.panic;
44
5comptime {5comptime {
6 if (common.want_ppc_abi)6 if (common.want_ppc_abi)
7 @export(__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility });
8 @export(__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility });
9}9}
1010
11fn __negtf2(a: f128) callconv(.C) f128 {11fn __negtf2(a: f128) callconv(.C) f128 {
lib/compiler_rt/negv.zig+3-3
...@@ -8,9 +8,9 @@ const common = @import("common.zig");...@@ -8,9 +8,9 @@ const common = @import("common.zig");
8pub const panic = common.panic;8pub const panic = common.panic;
99
10comptime {10comptime {
11 @export(__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__negvti2, .{ .name = "__negvti2", .linkage = common.linkage, .visibility = common.visibility });
14}14}
1515
16pub fn __negvsi2(a: i32) callconv(.C) i32 {16pub fn __negvsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/negxf2.zig+1-1
...@@ -3,7 +3,7 @@ const common = @import("./common.zig");...@@ -3,7 +3,7 @@ const common = @import("./common.zig");
3pub const panic = common.panic;3pub const panic = common.panic;
44
5comptime {5comptime {
6 @export(__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility });6 @export(&__negxf2, .{ .name = "__negxf2", .linkage = common.linkage, .visibility = common.visibility });
7}7}
88
9fn __negxf2(a: f80) callconv(.C) f80 {9fn __negxf2(a: f80) callconv(.C) f80 {
lib/compiler_rt/os_version_check.zig+1-1
...@@ -9,7 +9,7 @@ const have_availability_version_check = builtin.os.tag.isDarwin() and...@@ -9,7 +9,7 @@ const have_availability_version_check = builtin.os.tag.isDarwin() and
99
10comptime {10comptime {
11 if (have_availability_version_check) {11 if (have_availability_version_check) {
12 @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });12 @export(&__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage });
13 }13 }
14}14}
1515
lib/compiler_rt/parity.zig+3-3
...@@ -8,9 +8,9 @@ const common = @import("common.zig");...@@ -8,9 +8,9 @@ const common = @import("common.zig");
8pub const panic = common.panic;8pub const panic = common.panic;
99
10comptime {10comptime {
11 @export(__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__parityti2, .{ .name = "__parityti2", .linkage = common.linkage, .visibility = common.visibility });
14}14}
1515
16pub fn __paritysi2(a: i32) callconv(.C) i32 {16pub fn __paritysi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/popcount.zig+3-3
...@@ -13,9 +13,9 @@ const common = @import("common.zig");...@@ -13,9 +13,9 @@ const common = @import("common.zig");
13pub const panic = common.panic;13pub const panic = common.panic;
1414
15comptime {15comptime {
16 @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage, .visibility = common.visibility });
19}19}
2020
21pub fn __popcountsi2(a: i32) callconv(.C) i32 {21pub fn __popcountsi2(a: i32) callconv(.C) i32 {
lib/compiler_rt/powiXf2.zig+6-6
...@@ -10,13 +10,13 @@ const std = @import("std");...@@ -10,13 +10,13 @@ const std = @import("std");
10pub const panic = common.panic;10pub const panic = common.panic;
1111
12comptime {12comptime {
13 @export(__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility });
16 if (common.want_ppc_abi)16 if (common.want_ppc_abi)
17 @export(__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility });
18 @export(__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility });
19 @export(__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility });19 @export(&__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility });
20}20}
2121
22inline fn powiXf2(comptime FT: type, a: FT, b: i32) FT {22inline fn powiXf2(comptime FT: type, a: FT, b: i32) FT {
lib/compiler_rt/round.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__roundh, .{ .name = "__roundh", .linkage = common.linkage, .visibility = common.visibility });
19 @export(roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility });19 @export(&roundf, .{ .name = "roundf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility });20 @export(&round, .{ .name = "round", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__roundx, .{ .name = "__roundx", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&roundq, .{ .name = "roundf128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility });25 @export(&roundq, .{ .name = "roundq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility });26 @export(&roundl, .{ .name = "roundl", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __roundh(x: f16) callconv(.C) f16 {29pub fn __roundh(x: f16) callconv(.C) f16 {
lib/compiler_rt/shift.zig+12-12
...@@ -7,22 +7,22 @@ pub const panic = common.panic;...@@ -7,22 +7,22 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 // symbol compatibility with libgcc9 // symbol compatibility with libgcc
10 @export(__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__ashlsi3, .{ .name = "__ashlsi3", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__ashrsi3, .{ .name = "__ashrsi3", .linkage = common.linkage, .visibility = common.visibility });
12 @export(__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__lshrsi3, .{ .name = "__lshrsi3", .linkage = common.linkage, .visibility = common.visibility });
1313
14 @export(__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage, .visibility = common.visibility });
16 @export(__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility });16 @export(&__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage, .visibility = common.visibility });
1717
18 if (common.want_aeabi) {18 if (common.want_aeabi) {
19 @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility });19 @export(&__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage, .visibility = common.visibility });
20 @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility });20 @export(&__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage, .visibility = common.visibility });
22 } else {22 } else {
23 @export(__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility });23 @export(&__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage, .visibility = common.visibility });
24 @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility });24 @export(&__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage, .visibility = common.visibility });
26 }26 }
27}27}
2828
lib/compiler_rt/sin.zig+7-7
...@@ -19,15 +19,15 @@ const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;...@@ -19,15 +19,15 @@ const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
19pub const panic = common.panic;19pub const panic = common.panic;
2020
21comptime {21comptime {
22 @export(__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility });22 @export(&__sinh, .{ .name = "__sinh", .linkage = common.linkage, .visibility = common.visibility });
23 @export(sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility });23 @export(&sinf, .{ .name = "sinf", .linkage = common.linkage, .visibility = common.visibility });
24 @export(sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility });24 @export(&sin, .{ .name = "sin", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__sinx, .{ .name = "__sinx", .linkage = common.linkage, .visibility = common.visibility });
26 if (common.want_ppc_abi) {26 if (common.want_ppc_abi) {
27 @export(sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility });27 @export(&sinq, .{ .name = "sinf128", .linkage = common.linkage, .visibility = common.visibility });
28 }28 }
29 @export(sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility });29 @export(&sinq, .{ .name = "sinq", .linkage = common.linkage, .visibility = common.visibility });
30 @export(sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility });30 @export(&sinl, .{ .name = "sinl", .linkage = common.linkage, .visibility = common.visibility });
31}31}
3232
33pub fn __sinh(x: f16) callconv(.C) f16 {33pub fn __sinh(x: f16) callconv(.C) f16 {
lib/compiler_rt/sincos.zig+7-7
...@@ -11,15 +11,15 @@ const common = @import("common.zig");...@@ -11,15 +11,15 @@ const common = @import("common.zig");
11pub const panic = common.panic;11pub const panic = common.panic;
1212
13comptime {13comptime {
14 @export(__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__sincosh, .{ .name = "__sincosh", .linkage = common.linkage, .visibility = common.visibility });
15 @export(sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility });15 @export(&sincosf, .{ .name = "sincosf", .linkage = common.linkage, .visibility = common.visibility });
16 @export(sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility });16 @export(&sincos, .{ .name = "sincos", .linkage = common.linkage, .visibility = common.visibility });
17 @export(__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility });17 @export(&__sincosx, .{ .name = "__sincosx", .linkage = common.linkage, .visibility = common.visibility });
18 if (common.want_ppc_abi) {18 if (common.want_ppc_abi) {
19 @export(sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility });19 @export(&sincosq, .{ .name = "sincosf128", .linkage = common.linkage, .visibility = common.visibility });
20 }20 }
21 @export(sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility });21 @export(&sincosq, .{ .name = "sincosq", .linkage = common.linkage, .visibility = common.visibility });
22 @export(sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility });22 @export(&sincosl, .{ .name = "sincosl", .linkage = common.linkage, .visibility = common.visibility });
23}23}
2424
25pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void {25pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void {
lib/compiler_rt/sqrt.zig+7-7
...@@ -7,15 +7,15 @@ const common = @import("common.zig");...@@ -7,15 +7,15 @@ const common = @import("common.zig");
7pub const panic = common.panic;7pub const panic = common.panic;
88
9comptime {9comptime {
10 @export(__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__sqrth, .{ .name = "__sqrth", .linkage = common.linkage, .visibility = common.visibility });
11 @export(sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility });11 @export(&sqrtf, .{ .name = "sqrtf", .linkage = common.linkage, .visibility = common.visibility });
12 @export(sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility });12 @export(&sqrt, .{ .name = "sqrt", .linkage = common.linkage, .visibility = common.visibility });
13 @export(__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage, .visibility = common.visibility });
14 if (common.want_ppc_abi) {14 if (common.want_ppc_abi) {
15 @export(sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility });15 @export(&sqrtq, .{ .name = "sqrtf128", .linkage = common.linkage, .visibility = common.visibility });
16 }16 }
17 @export(sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility });17 @export(&sqrtq, .{ .name = "sqrtq", .linkage = common.linkage, .visibility = common.visibility });
18 @export(sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility });18 @export(&sqrtl, .{ .name = "sqrtl", .linkage = common.linkage, .visibility = common.visibility });
19}19}
2020
21pub fn __sqrth(x: f16) callconv(.C) f16 {21pub fn __sqrth(x: f16) callconv(.C) f16 {
lib/compiler_rt/ssp.zig+10-10
...@@ -21,16 +21,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call...@@ -21,16 +21,16 @@ extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) call
21extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;21extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8;
2222
23comptime {23comptime {
24 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility });24 @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = common.linkage, .visibility = common.visibility });
25 @export(__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility });25 @export(&__chk_fail, .{ .name = "__chk_fail", .linkage = common.linkage, .visibility = common.visibility });
26 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility });26 @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility });27 @export(&__strcpy_chk, .{ .name = "__strcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
28 @export(__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility });28 @export(&__strncpy_chk, .{ .name = "__strncpy_chk", .linkage = common.linkage, .visibility = common.visibility });
29 @export(__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility });29 @export(&__strcat_chk, .{ .name = "__strcat_chk", .linkage = common.linkage, .visibility = common.visibility });
30 @export(__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility });30 @export(&__strncat_chk, .{ .name = "__strncat_chk", .linkage = common.linkage, .visibility = common.visibility });
31 @export(__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility });31 @export(&__memcpy_chk, .{ .name = "__memcpy_chk", .linkage = common.linkage, .visibility = common.visibility });
32 @export(__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility });32 @export(&__memmove_chk, .{ .name = "__memmove_chk", .linkage = common.linkage, .visibility = common.visibility });
33 @export(__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility });33 @export(&__memset_chk, .{ .name = "__memset_chk", .linkage = common.linkage, .visibility = common.visibility });
34}34}
3535
36fn __stack_chk_fail() callconv(.C) noreturn {36fn __stack_chk_fail() callconv(.C) noreturn {
lib/compiler_rt/stack_probe.zig+6-6
...@@ -16,16 +16,16 @@ comptime {...@@ -16,16 +16,16 @@ comptime {
16 if (builtin.os.tag == .windows) {16 if (builtin.os.tag == .windows) {
17 // Default stack-probe functions emitted by LLVM17 // Default stack-probe functions emitted by LLVM
18 if (is_mingw) {18 if (is_mingw) {
19 @export(_chkstk, .{ .name = "_alloca", .linkage = linkage });19 @export(&_chkstk, .{ .name = "_alloca", .linkage = linkage });
20 @export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage });20 @export(&___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = linkage });
2121
22 if (arch.isAARCH64()) {22 if (arch.isAARCH64()) {
23 @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage });23 @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage });
24 }24 }
25 } else if (!builtin.link_libc) {25 } else if (!builtin.link_libc) {
26 // This symbols are otherwise exported by MSVCRT.lib26 // This symbols are otherwise exported by MSVCRT.lib
27 @export(_chkstk, .{ .name = "_chkstk", .linkage = linkage });27 @export(&_chkstk, .{ .name = "_chkstk", .linkage = linkage });
28 @export(__chkstk, .{ .name = "__chkstk", .linkage = linkage });28 @export(&__chkstk, .{ .name = "__chkstk", .linkage = linkage });
29 }29 }
30 }30 }
3131
...@@ -33,7 +33,7 @@ comptime {...@@ -33,7 +33,7 @@ comptime {
33 .x86,33 .x86,
34 .x86_64,34 .x86_64,
35 => {35 => {
36 @export(zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage });36 @export(&zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage });
37 },37 },
38 else => {},38 else => {},
39 }39 }
lib/compiler_rt/subdf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_dsub, .{ .name = "__aeabi_dsub", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__subdf3, .{ .name = "__subdf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/subhf3.zig+1-1
...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;...@@ -4,7 +4,7 @@ const addf3 = @import("./addf3.zig").addf3;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__subhf3, .{ .name = "__subhf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __subhf3(a: f16, b: f16) callconv(.C) f16 {10fn __subhf3(a: f16, b: f16) callconv(.C) f16 {
lib/compiler_rt/subo.zig+3-3
...@@ -10,9 +10,9 @@ const common = @import("common.zig");...@@ -10,9 +10,9 @@ const common = @import("common.zig");
10pub const panic = common.panic;10pub const panic = common.panic;
1111
12comptime {12comptime {
13 @export(__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__subosi4, .{ .name = "__subosi4", .linkage = common.linkage, .visibility = common.visibility });
14 @export(__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility });14 @export(&__subodi4, .{ .name = "__subodi4", .linkage = common.linkage, .visibility = common.visibility });
15 @export(__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility });15 @export(&__suboti4, .{ .name = "__suboti4", .linkage = common.linkage, .visibility = common.visibility });
16}16}
1717
18pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 {18pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 {
lib/compiler_rt/subsf3.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_fsub, .{ .name = "__aeabi_fsub", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__subsf3, .{ .name = "__subsf3", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/subtf3.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__subtf3, .{ .name = "__subkf3", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_sub, .{ .name = "_Qp_sub", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__subtf3, .{ .name = "__subtf3", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {15pub fn __subtf3(a: f128, b: f128) callconv(.C) f128 {
lib/compiler_rt/subxf3.zig+1-1
...@@ -4,7 +4,7 @@ const common = @import("./common.zig");...@@ -4,7 +4,7 @@ const common = @import("./common.zig");
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__subxf3, .{ .name = "__subxf3", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __subxf3(a: f80, b: f80) callconv(.C) f80 {10fn __subxf3(a: f80, b: f80) callconv(.C) f80 {
lib/compiler_rt/tan.zig+7-7
...@@ -21,15 +21,15 @@ const common = @import("common.zig");...@@ -21,15 +21,15 @@ const common = @import("common.zig");
21pub const panic = common.panic;21pub const panic = common.panic;
2222
23comptime {23comptime {
24 @export(__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility });24 @export(&__tanh, .{ .name = "__tanh", .linkage = common.linkage, .visibility = common.visibility });
25 @export(tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility });25 @export(&tanf, .{ .name = "tanf", .linkage = common.linkage, .visibility = common.visibility });
26 @export(tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility });26 @export(&tan, .{ .name = "tan", .linkage = common.linkage, .visibility = common.visibility });
27 @export(__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility });27 @export(&__tanx, .{ .name = "__tanx", .linkage = common.linkage, .visibility = common.visibility });
28 if (common.want_ppc_abi) {28 if (common.want_ppc_abi) {
29 @export(tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility });29 @export(&tanq, .{ .name = "tanf128", .linkage = common.linkage, .visibility = common.visibility });
30 }30 }
31 @export(tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility });31 @export(&tanq, .{ .name = "tanq", .linkage = common.linkage, .visibility = common.visibility });
32 @export(tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility });32 @export(&tanl, .{ .name = "tanl", .linkage = common.linkage, .visibility = common.visibility });
33}33}
3434
35pub fn __tanh(x: f16) callconv(.C) f16 {35pub fn __tanh(x: f16) callconv(.C) f16 {
lib/compiler_rt/trunc.zig+7-7
...@@ -15,15 +15,15 @@ const common = @import("common.zig");...@@ -15,15 +15,15 @@ const common = @import("common.zig");
15pub const panic = common.panic;15pub const panic = common.panic;
1616
17comptime {17comptime {
18 @export(__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility });18 @export(&__trunch, .{ .name = "__trunch", .linkage = common.linkage, .visibility = common.visibility });
19 @export(truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility });19 @export(&truncf, .{ .name = "truncf", .linkage = common.linkage, .visibility = common.visibility });
20 @export(trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility });20 @export(&trunc, .{ .name = "trunc", .linkage = common.linkage, .visibility = common.visibility });
21 @export(__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility });21 @export(&__truncx, .{ .name = "__truncx", .linkage = common.linkage, .visibility = common.visibility });
22 if (common.want_ppc_abi) {22 if (common.want_ppc_abi) {
23 @export(truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility });23 @export(&truncq, .{ .name = "truncf128", .linkage = common.linkage, .visibility = common.visibility });
24 }24 }
25 @export(truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility });25 @export(&truncq, .{ .name = "truncq", .linkage = common.linkage, .visibility = common.visibility });
26 @export(truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility });26 @export(&truncl, .{ .name = "truncl", .linkage = common.linkage, .visibility = common.visibility });
27}27}
2828
29pub fn __trunch(x: f16) callconv(.C) f16 {29pub fn __trunch(x: f16) callconv(.C) f16 {
lib/compiler_rt/truncdfhf2.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/truncdfsf2.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_d2f, .{ .name = "__aeabi_d2f", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__truncdfsf2, .{ .name = "__truncdfsf2", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/truncsfhf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.gnu_f16_abi) {7 if (common.gnu_f16_abi) {
8 @export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_aeabi) {9 } else if (common.want_aeabi) {
10 @export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__truncsfhf2, .{ .name = "__truncsfhf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T(f32) {15pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T(f32) {
lib/compiler_rt/trunctfdf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__trunctfdf2, .{ .name = "__trunckfdf2", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtod, .{ .name = "_Qp_qtod", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__trunctfdf2, .{ .name = "__trunctfdf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __trunctfdf2(a: f128) callconv(.C) f64 {15pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
lib/compiler_rt/trunctfhf2.zig+1-1
...@@ -4,7 +4,7 @@ const truncf = @import("./truncf.zig").truncf;...@@ -4,7 +4,7 @@ const truncf = @import("./truncf.zig").truncf;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__trunctfhf2, .{ .name = "__trunctfhf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __trunctfhf2(a: f128) callconv(.C) common.F16T(f128) {10pub fn __trunctfhf2(a: f128) callconv(.C) common.F16T(f128) {
lib/compiler_rt/trunctfsf2.zig+3-3
...@@ -5,11 +5,11 @@ pub const panic = common.panic;...@@ -5,11 +5,11 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__trunctfsf2, .{ .name = "__trunckfsf2", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 @export(_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility });10 @export(&_Qp_qtos, .{ .name = "_Qp_qtos", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12 @export(__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__trunctfsf2, .{ .name = "__trunctfsf2", .linkage = common.linkage, .visibility = common.visibility });
13}13}
1414
15pub fn __trunctfsf2(a: f128) callconv(.C) f32 {15pub fn __trunctfsf2(a: f128) callconv(.C) f32 {
lib/compiler_rt/trunctfxf2.zig+1-1
...@@ -5,7 +5,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;...@@ -5,7 +5,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
5pub const panic = common.panic;5pub const panic = common.panic;
66
7comptime {7comptime {
8 @export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = common.linkage, .visibility = common.visibility });
9}9}
1010
11pub fn __trunctfxf2(a: f128) callconv(.C) f80 {11pub fn __trunctfxf2(a: f128) callconv(.C) f80 {
lib/compiler_rt/truncxfdf2.zig+1-1
...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__truncxfdf2, .{ .name = "__truncxfdf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __truncxfdf2(a: f80) callconv(.C) f64 {10fn __truncxfdf2(a: f80) callconv(.C) f64 {
lib/compiler_rt/truncxfhf2.zig+1-1
...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__truncxfhf2, .{ .name = "__truncxfhf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __truncxfhf2(a: f80) callconv(.C) common.F16T(f80) {10fn __truncxfhf2(a: f80) callconv(.C) common.F16T(f80) {
lib/compiler_rt/truncxfsf2.zig+1-1
...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;...@@ -4,7 +4,7 @@ const trunc_f80 = @import("./truncf.zig").trunc_f80;
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__truncxfsf2, .{ .name = "__truncxfsf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10fn __truncxfsf2(a: f80) callconv(.C) f32 {10fn __truncxfsf2(a: f80) callconv(.C) f32 {
lib/compiler_rt/udivmodei4.zig+2-2
...@@ -7,8 +7,8 @@ const shl = std.math.shl;...@@ -7,8 +7,8 @@ const shl = std.math.shl;
7const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u655357const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535
88
9comptime {9comptime {
10 @export(__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__udivei4, .{ .name = "__udivei4", .linkage = common.linkage, .visibility = common.visibility });
11 @export(__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility });11 @export(&__umodei4, .{ .name = "__umodei4", .linkage = common.linkage, .visibility = common.visibility });
12}12}
1313
14const endian = builtin.cpu.arch.endian();14const endian = builtin.cpu.arch.endian();
lib/compiler_rt/udivmodti4.zig+2-2
...@@ -7,9 +7,9 @@ pub const panic = common.panic;...@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_windows_v2u64_abi) {9 if (common.want_windows_v2u64_abi) {
10 @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
11 } else {11 } else {
12 @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage, .visibility = common.visibility });
13 }13 }
14}14}
1515
lib/compiler_rt/udivti3.zig+2-2
...@@ -7,9 +7,9 @@ pub const panic = common.panic;...@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_windows_v2u64_abi) {9 if (common.want_windows_v2u64_abi) {
10 @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
11 } else {11 } else {
12 @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__udivti3, .{ .name = "__udivti3", .linkage = common.linkage, .visibility = common.visibility });
13 }13 }
14}14}
1515
lib/compiler_rt/umodti3.zig+2-2
...@@ -7,9 +7,9 @@ pub const panic = common.panic;...@@ -7,9 +7,9 @@ pub const panic = common.panic;
77
8comptime {8comptime {
9 if (common.want_windows_v2u64_abi) {9 if (common.want_windows_v2u64_abi) {
10 @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
11 } else {11 } else {
12 @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });12 @export(&__umodti3, .{ .name = "__umodti3", .linkage = common.linkage, .visibility = common.visibility });
13 }13 }
14}14}
1515
lib/compiler_rt/unorddf2.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_dcmpun, .{ .name = "__aeabi_dcmpun", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__unorddf2, .{ .name = "__unorddf2", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/unordhf2.zig+1-1
...@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");...@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__unordhf2, .{ .name = "__unordhf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __unordhf2(a: f16, b: f16) callconv(.C) i32 {10pub fn __unordhf2(a: f16, b: f16) callconv(.C) i32 {
lib/compiler_rt/unordsf2.zig+2-2
...@@ -5,9 +5,9 @@ pub const panic = common.panic;...@@ -5,9 +5,9 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_aeabi) {7 if (common.want_aeabi) {
8 @export(__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__aeabi_fcmpun, .{ .name = "__aeabi_fcmpun", .linkage = common.linkage, .visibility = common.visibility });
9 } else {9 } else {
10 @export(__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility });10 @export(&__unordsf2, .{ .name = "__unordsf2", .linkage = common.linkage, .visibility = common.visibility });
11 }11 }
12}12}
1313
lib/compiler_rt/unordtf2.zig+2-2
...@@ -5,12 +5,12 @@ pub const panic = common.panic;...@@ -5,12 +5,12 @@ pub const panic = common.panic;
55
6comptime {6comptime {
7 if (common.want_ppc_abi) {7 if (common.want_ppc_abi) {
8 @export(__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility });8 @export(&__unordtf2, .{ .name = "__unordkf2", .linkage = common.linkage, .visibility = common.visibility });
9 } else if (common.want_sparc_abi) {9 } else if (common.want_sparc_abi) {
10 // These exports are handled in cmptf2.zig because unordered comparisons10 // These exports are handled in cmptf2.zig because unordered comparisons
11 // are based on calling _Qp_cmp.11 // are based on calling _Qp_cmp.
12 }12 }
13 @export(__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility });13 @export(&__unordtf2, .{ .name = "__unordtf2", .linkage = common.linkage, .visibility = common.visibility });
14}14}
1515
16fn __unordtf2(a: f128, b: f128) callconv(.C) i32 {16fn __unordtf2(a: f128, b: f128) callconv(.C) i32 {
lib/compiler_rt/unordxf2.zig+1-1
...@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");...@@ -4,7 +4,7 @@ const comparef = @import("./comparef.zig");
4pub const panic = common.panic;4pub const panic = common.panic;
55
6comptime {6comptime {
7 @export(__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility });7 @export(&__unordxf2, .{ .name = "__unordxf2", .linkage = common.linkage, .visibility = common.visibility });
8}8}
99
10pub fn __unordxf2(a: f80, b: f80) callconv(.C) i32 {10pub fn __unordxf2(a: f80, b: f80) callconv(.C) i32 {
lib/std/Thread/Futex.zig+4-4
...@@ -27,7 +27,7 @@ const atomic = std.atomic;...@@ -27,7 +27,7 @@ const atomic = std.atomic;
27/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically27/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically
28/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.28/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.
29pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {29pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {
30 @setCold(true);30 @branchHint(.cold);
3131
32 Impl.wait(ptr, expect, null) catch |err| switch (err) {32 Impl.wait(ptr, expect, null) catch |err| switch (err) {
33 error.Timeout => unreachable, // null timeout meant to wait forever33 error.Timeout => unreachable, // null timeout meant to wait forever
...@@ -43,7 +43,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {...@@ -43,7 +43,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void {
43/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically43/// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically
44/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.44/// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`.
45pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void {45pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void {
46 @setCold(true);46 @branchHint(.cold);
4747
48 // Avoid calling into the OS for no-op timeouts.48 // Avoid calling into the OS for no-op timeouts.
49 if (timeout_ns == 0) {49 if (timeout_ns == 0) {
...@@ -56,7 +56,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er...@@ -56,7 +56,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er
5656
57/// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`.57/// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`.
58pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {58pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void {
59 @setCold(true);59 @branchHint(.cold);
6060
61 // Avoid calling into the OS if there's nothing to wake up.61 // Avoid calling into the OS if there's nothing to wake up.
62 if (max_waiters == 0) {62 if (max_waiters == 0) {
...@@ -1048,7 +1048,7 @@ pub const Deadline = struct {...@@ -1048,7 +1048,7 @@ pub const Deadline = struct {
1048 /// - A spurious wake occurs.1048 /// - A spurious wake occurs.
1049 /// - The deadline expires; In which case `error.Timeout` is returned.1049 /// - The deadline expires; In which case `error.Timeout` is returned.
1050 pub fn wait(self: *Deadline, ptr: *const atomic.Value(u32), expect: u32) error{Timeout}!void {1050 pub fn wait(self: *Deadline, ptr: *const atomic.Value(u32), expect: u32) error{Timeout}!void {
1051 @setCold(true);1051 @branchHint(.cold);
10521052
1053 // Check if we actually have a timeout to wait until.1053 // Check if we actually have a timeout to wait until.
1054 // If not just wait "forever".1054 // If not just wait "forever".
lib/std/Thread/Mutex.zig+1-1
...@@ -169,7 +169,7 @@ const FutexImpl = struct {...@@ -169,7 +169,7 @@ const FutexImpl = struct {
169 }169 }
170170
171 fn lockSlow(self: *@This()) void {171 fn lockSlow(self: *@This()) void {
172 @setCold(true);172 @branchHint(.cold);
173173
174 // Avoid doing an atomic swap below if we already know the state is contended.174 // Avoid doing an atomic swap below if we already know the state is contended.
175 // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily.175 // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily.
lib/std/Thread/ResetEvent.zig+1-1
...@@ -107,7 +107,7 @@ const FutexImpl = struct {...@@ -107,7 +107,7 @@ const FutexImpl = struct {
107 }107 }
108108
109 fn waitUntilSet(self: *Impl, timeout: ?u64) error{Timeout}!void {109 fn waitUntilSet(self: *Impl, timeout: ?u64) error{Timeout}!void {
110 @setCold(true);110 @branchHint(.cold);
111111
112 // Try to set the state from `unset` to `waiting` to indicate112 // Try to set the state from `unset` to `waiting` to indicate
113 // to the set() thread that others are blocked on the ResetEvent.113 // to the set() thread that others are blocked on the ResetEvent.
lib/std/builtin.zig+26-7
...@@ -675,6 +675,25 @@ pub const ExternOptions = struct {...@@ -675,6 +675,25 @@ pub const ExternOptions = struct {
675 is_thread_local: bool = false,675 is_thread_local: bool = false,
676};676};
677677
678/// This data structure is used by the Zig language code generation and
679/// therefore must be kept in sync with the compiler implementation.
680pub const BranchHint = enum(u3) {
681 /// Equivalent to no hint given.
682 none,
683 /// This branch of control flow is more likely to be reached than its peers.
684 /// The optimizer should optimize for reaching it.
685 likely,
686 /// This branch of control flow is less likely to be reached than its peers.
687 /// The optimizer should optimize for not reaching it.
688 unlikely,
689 /// This branch of control flow is unlikely to *ever* be reached.
690 /// The optimizer may place it in a different page of memory to optimize other branches.
691 cold,
692 /// It is difficult to predict whether this branch of control flow will be reached.
693 /// The optimizer should avoid branching behavior with expensive mispredictions.
694 unpredictable,
695};
696
678/// This enum is set by the compiler and communicates which compiler backend is697/// This enum is set by the compiler and communicates which compiler backend is
679/// used to produce machine code.698/// used to produce machine code.
680/// Think carefully before deciding to observe this value. Nearly all code should699/// Think carefully before deciding to observe this value. Nearly all code should
...@@ -760,7 +779,7 @@ else...@@ -760,7 +779,7 @@ else
760/// This function is used by the Zig language code generation and779/// This function is used by the Zig language code generation and
761/// therefore must be kept in sync with the compiler implementation.780/// therefore must be kept in sync with the compiler implementation.
762pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn {781pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace, ret_addr: ?usize) noreturn {
763 @setCold(true);782 @branchHint(.cold);
764783
765 // For backends that cannot handle the language features depended on by the784 // For backends that cannot handle the language features depended on by the
766 // default panic handler, we have a simpler panic handler:785 // default panic handler, we have a simpler panic handler:
...@@ -877,27 +896,27 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void...@@ -877,27 +896,27 @@ pub fn checkNonScalarSentinel(expected: anytype, actual: @TypeOf(expected)) void
877}896}
878897
879pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {898pub fn panicSentinelMismatch(expected: anytype, actual: @TypeOf(expected)) noreturn {
880 @setCold(true);899 @branchHint(.cold);
881 std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });900 std.debug.panicExtra(null, @returnAddress(), "sentinel mismatch: expected {any}, found {any}", .{ expected, actual });
882}901}
883902
884pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {903pub fn panicUnwrapError(st: ?*StackTrace, err: anyerror) noreturn {
885 @setCold(true);904 @branchHint(.cold);
886 std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});905 std.debug.panicExtra(st, @returnAddress(), "attempt to unwrap error: {s}", .{@errorName(err)});
887}906}
888907
889pub fn panicOutOfBounds(index: usize, len: usize) noreturn {908pub fn panicOutOfBounds(index: usize, len: usize) noreturn {
890 @setCold(true);909 @branchHint(.cold);
891 std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });910 std.debug.panicExtra(null, @returnAddress(), "index out of bounds: index {d}, len {d}", .{ index, len });
892}911}
893912
894pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {913pub fn panicStartGreaterThanEnd(start: usize, end: usize) noreturn {
895 @setCold(true);914 @branchHint(.cold);
896 std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end });915 std.debug.panicExtra(null, @returnAddress(), "start index {d} is larger than end index {d}", .{ start, end });
897}916}
898917
899pub fn panicInactiveUnionField(active: anytype, wanted: @TypeOf(active)) noreturn {918pub fn panicInactiveUnionField(active: anytype, wanted: @TypeOf(active)) noreturn {
900 @setCold(true);919 @branchHint(.cold);
901 std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{ @tagName(wanted), @tagName(active) });920 std.debug.panicExtra(null, @returnAddress(), "access of union field '{s}' while field '{s}' is active", .{ @tagName(wanted), @tagName(active) });
902}921}
903922
...@@ -930,7 +949,7 @@ pub const panic_messages = struct {...@@ -930,7 +949,7 @@ pub const panic_messages = struct {
930};949};
931950
932pub noinline fn returnError(st: *StackTrace) void {951pub noinline fn returnError(st: *StackTrace) void {
933 @setCold(true);952 @branchHint(.cold);
934 @setRuntimeSafety(false);953 @setRuntimeSafety(false);
935 addErrRetTraceAddr(st, @returnAddress());954 addErrRetTraceAddr(st, @returnAddress());
936}955}
lib/std/c.zig+1-1
...@@ -40,7 +40,7 @@ pub extern var _mh_execute_header: mach_hdr;...@@ -40,7 +40,7 @@ pub extern var _mh_execute_header: mach_hdr;
40var dummy_execute_header: mach_hdr = undefined;40var dummy_execute_header: mach_hdr = undefined;
41comptime {41comptime {
42 if (native_os.isDarwin()) {42 if (native_os.isDarwin()) {
43 @export(dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });43 @export(&dummy_execute_header, .{ .name = "_mh_execute_header", .linkage = .weak });
44 }44 }
45}45}
4646
lib/std/debug.zig+3-3
...@@ -409,7 +409,7 @@ pub fn assertReadable(slice: []const volatile u8) void {...@@ -409,7 +409,7 @@ pub fn assertReadable(slice: []const volatile u8) void {
409}409}
410410
411pub fn panic(comptime format: []const u8, args: anytype) noreturn {411pub fn panic(comptime format: []const u8, args: anytype) noreturn {
412 @setCold(true);412 @branchHint(.cold);
413413
414 panicExtra(@errorReturnTrace(), @returnAddress(), format, args);414 panicExtra(@errorReturnTrace(), @returnAddress(), format, args);
415}415}
...@@ -422,7 +422,7 @@ pub fn panicExtra(...@@ -422,7 +422,7 @@ pub fn panicExtra(
422 comptime format: []const u8,422 comptime format: []const u8,
423 args: anytype,423 args: anytype,
424) noreturn {424) noreturn {
425 @setCold(true);425 @branchHint(.cold);
426426
427 const size = 0x1000;427 const size = 0x1000;
428 const trunc_msg = "(msg truncated)";428 const trunc_msg = "(msg truncated)";
...@@ -450,7 +450,7 @@ threadlocal var panic_stage: usize = 0;...@@ -450,7 +450,7 @@ threadlocal var panic_stage: usize = 0;
450// `panicImpl` could be useful in implementing a custom panic handler which450// `panicImpl` could be useful in implementing a custom panic handler which
451// calls the default handler (on supported platforms)451// calls the default handler (on supported platforms)
452pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn {452pub fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn {
453 @setCold(true);453 @branchHint(.cold);
454454
455 if (enable_segfault_handler) {455 if (enable_segfault_handler) {
456 // If a segfault happens while panicking, we want it to actually segfault, not trigger456 // If a segfault happens while panicking, we want it to actually segfault, not trigger
lib/std/fmt/parse_float/convert_slow.zig+1-1
...@@ -36,7 +36,7 @@ pub fn getShift(n: usize) usize {...@@ -36,7 +36,7 @@ pub fn getShift(n: usize) usize {
36/// Note that this function needs a lot of stack space and is marked36/// Note that this function needs a lot of stack space and is marked
37/// cold to hint against inlining into the caller.37/// cold to hint against inlining into the caller.
38pub fn convertSlow(comptime T: type, s: []const u8) BiasedFp(T) {38pub fn convertSlow(comptime T: type, s: []const u8) BiasedFp(T) {
39 @setCold(true);39 @branchHint(.cold);
4040
41 const MantissaT = mantissaType(T);41 const MantissaT = mantissaType(T);
42 const min_exponent = -(1 << (math.floatExponentBits(T) - 1)) + 1;42 const min_exponent = -(1 << (math.floatExponentBits(T) - 1)) + 1;
lib/std/hash/xxhash.zig+6-6
...@@ -593,7 +593,7 @@ pub const XxHash3 = struct {...@@ -593,7 +593,7 @@ pub const XxHash3 = struct {
593 }593 }
594594
595 fn hash3(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {595 fn hash3(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
596 @setCold(true);596 @branchHint(.cold);
597 std.debug.assert(input.len > 0 and input.len < 4);597 std.debug.assert(input.len > 0 and input.len < 4);
598598
599 const flip: [2]u32 = @bitCast(secret[0..8].*);599 const flip: [2]u32 = @bitCast(secret[0..8].*);
...@@ -609,7 +609,7 @@ pub const XxHash3 = struct {...@@ -609,7 +609,7 @@ pub const XxHash3 = struct {
609 }609 }
610610
611 fn hash8(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {611 fn hash8(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
612 @setCold(true);612 @branchHint(.cold);
613 std.debug.assert(input.len >= 4 and input.len <= 8);613 std.debug.assert(input.len >= 4 and input.len <= 8);
614614
615 const flip: [2]u64 = @bitCast(secret[8..24].*);615 const flip: [2]u64 = @bitCast(secret[8..24].*);
...@@ -625,7 +625,7 @@ pub const XxHash3 = struct {...@@ -625,7 +625,7 @@ pub const XxHash3 = struct {
625 }625 }
626626
627 fn hash16(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {627 fn hash16(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
628 @setCold(true);628 @branchHint(.cold);
629 std.debug.assert(input.len > 8 and input.len <= 16);629 std.debug.assert(input.len > 8 and input.len <= 16);
630630
631 const flip: [4]u64 = @bitCast(secret[24..56].*);631 const flip: [4]u64 = @bitCast(secret[24..56].*);
...@@ -641,7 +641,7 @@ pub const XxHash3 = struct {...@@ -641,7 +641,7 @@ pub const XxHash3 = struct {
641 }641 }
642642
643 fn hash128(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {643 fn hash128(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
644 @setCold(true);644 @branchHint(.cold);
645 std.debug.assert(input.len > 16 and input.len <= 128);645 std.debug.assert(input.len > 16 and input.len <= 128);
646646
647 var acc = XxHash64.prime_1 *% @as(u64, input.len);647 var acc = XxHash64.prime_1 *% @as(u64, input.len);
...@@ -657,7 +657,7 @@ pub const XxHash3 = struct {...@@ -657,7 +657,7 @@ pub const XxHash3 = struct {
657 }657 }
658658
659 fn hash240(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {659 fn hash240(seed: u64, input: anytype, noalias secret: *const [192]u8) u64 {
660 @setCold(true);660 @branchHint(.cold);
661 std.debug.assert(input.len > 128 and input.len <= 240);661 std.debug.assert(input.len > 128 and input.len <= 240);
662662
663 var acc = XxHash64.prime_1 *% @as(u64, input.len);663 var acc = XxHash64.prime_1 *% @as(u64, input.len);
...@@ -676,7 +676,7 @@ pub const XxHash3 = struct {...@@ -676,7 +676,7 @@ pub const XxHash3 = struct {
676 }676 }
677677
678 noinline fn hashLong(seed: u64, input: []const u8) u64 {678 noinline fn hashLong(seed: u64, input: []const u8) u64 {
679 @setCold(true);679 @branchHint(.cold);
680 std.debug.assert(input.len >= 240);680 std.debug.assert(input.len >= 240);
681681
682 const block_count = ((input.len - 1) / @sizeOf(Block)) * @sizeOf(Block);682 const block_count = ((input.len - 1) / @sizeOf(Block)) * @sizeOf(Block);
lib/std/hash_map.zig+1-1
...@@ -1657,7 +1657,7 @@ pub fn HashMapUnmanaged(...@@ -1657,7 +1657,7 @@ pub fn HashMapUnmanaged(
1657 }1657 }
16581658
1659 fn grow(self: *Self, allocator: Allocator, new_capacity: Size, ctx: Context) Allocator.Error!void {1659 fn grow(self: *Self, allocator: Allocator, new_capacity: Size, ctx: Context) Allocator.Error!void {
1660 @setCold(true);1660 @branchHint(.cold);
1661 const new_cap = @max(new_capacity, minimal_capacity);1661 const new_cap = @max(new_capacity, minimal_capacity);
1662 assert(new_cap > self.capacity());1662 assert(new_cap > self.capacity());
1663 assert(std.math.isPowerOfTwo(new_cap));1663 assert(std.math.isPowerOfTwo(new_cap));
lib/std/heap/WasmPageAllocator.zig+1-1
...@@ -61,7 +61,7 @@ const FreeBlock = struct {...@@ -61,7 +61,7 @@ const FreeBlock = struct {
61 const not_found = maxInt(usize);61 const not_found = maxInt(usize);
6262
63 fn useRecycled(self: FreeBlock, num_pages: usize, log2_align: u8) usize {63 fn useRecycled(self: FreeBlock, num_pages: usize, log2_align: u8) usize {
64 @setCold(true);64 @branchHint(.cold);
65 for (self.data, 0..) |segment, i| {65 for (self.data, 0..) |segment, i| {
66 const spills_into_next = @as(i128, @bitCast(segment)) < 0;66 const spills_into_next = @as(i128, @bitCast(segment)) < 0;
67 const has_enough_bits = @popCount(segment) >= num_pages;67 const has_enough_bits = @popCount(segment) >= num_pages;
lib/std/log.zig+1-1
...@@ -171,7 +171,7 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {...@@ -171,7 +171,7 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
171 comptime format: []const u8,171 comptime format: []const u8,
172 args: anytype,172 args: anytype,
173 ) void {173 ) void {
174 @setCold(true);174 @branchHint(.cold);
175 log(.err, scope, format, args);175 log(.err, scope, format, args);
176 }176 }
177177
lib/std/once.zig+1-1
...@@ -25,7 +25,7 @@ pub fn Once(comptime f: fn () void) type {...@@ -25,7 +25,7 @@ pub fn Once(comptime f: fn () void) type {
25 }25 }
2626
27 fn callSlow(self: *@This()) void {27 fn callSlow(self: *@This()) void {
28 @setCold(true);28 @branchHint(.cold);
2929
30 self.mutex.lock();30 self.mutex.lock();
31 defer self.mutex.unlock();31 defer self.mutex.unlock();
lib/std/os/emscripten.zig+2-2
...@@ -21,8 +21,8 @@ comptime {...@@ -21,8 +21,8 @@ comptime {
21 if (builtin.os.tag == .emscripten) {21 if (builtin.os.tag == .emscripten) {
22 if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) {22 if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) {
23 // Emscripten does not provide these symbols, so we must export our own23 // Emscripten does not provide these symbols, so we must export our own
24 @export(__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong });24 @export(&__stack_chk_guard, .{ .name = "__stack_chk_guard", .linkage = .strong });
25 @export(__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong });25 @export(&__stack_chk_fail, .{ .name = "__stack_chk_fail", .linkage = .strong });
26 }26 }
27 }27 }
28}28}
lib/std/os/linux.zig+1-1
...@@ -434,7 +434,7 @@ comptime {...@@ -434,7 +434,7 @@ comptime {
434 // Export this only when building executable, otherwise it is overriding434 // Export this only when building executable, otherwise it is overriding
435 // the libc implementation435 // the libc implementation
436 if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {436 if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {
437 @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });437 @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
438 }438 }
439}439}
440440
lib/std/posix.zig+1-1
...@@ -654,7 +654,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void {...@@ -654,7 +654,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void {
654/// it raises SIGABRT followed by SIGKILL and finally lo654/// it raises SIGABRT followed by SIGKILL and finally lo
655/// Invokes the current signal handler for SIGABRT, if any.655/// Invokes the current signal handler for SIGABRT, if any.
656pub fn abort() noreturn {656pub fn abort() noreturn {
657 @setCold(true);657 @branchHint(.cold);
658 // MSVCRT abort() sometimes opens a popup window which is undesirable, so658 // MSVCRT abort() sometimes opens a popup window which is undesirable, so
659 // even when linking libc on Windows we use our own abort implementation.659 // even when linking libc on Windows we use our own abort implementation.
660 // See https://github.com/ziglang/zig/issues/2071 for more details.660 // See https://github.com/ziglang/zig/issues/2071 for more details.
lib/std/sort/pdq.zig+2-2
...@@ -203,7 +203,7 @@ fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize {...@@ -203,7 +203,7 @@ fn partitionEqual(a: usize, b: usize, pivot: usize, context: anytype) usize {
203///203///
204/// returns `true` if the slice is sorted at the end. This function is `O(n)` worst-case.204/// returns `true` if the slice is sorted at the end. This function is `O(n)` worst-case.
205fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {205fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {
206 @setCold(true);206 @branchHint(.cold);
207207
208 // maximum number of adjacent out-of-order pairs that will get shifted208 // maximum number of adjacent out-of-order pairs that will get shifted
209 const max_steps = 5;209 const max_steps = 5;
...@@ -247,7 +247,7 @@ fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {...@@ -247,7 +247,7 @@ fn partialInsertionSort(a: usize, b: usize, context: anytype) bool {
247}247}
248248
249fn breakPatterns(a: usize, b: usize, context: anytype) void {249fn breakPatterns(a: usize, b: usize, context: anytype) void {
250 @setCold(true);250 @branchHint(.cold);
251251
252 const len = b - a;252 const len = b - a;
253 if (len < 8) return;253 if (len < 8) return;
lib/std/start.zig+13-13
...@@ -31,38 +31,38 @@ comptime {...@@ -31,38 +31,38 @@ comptime {
31 if (builtin.output_mode == .Exe) {31 if (builtin.output_mode == .Exe) {
32 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {32 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
33 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {33 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
34 @export(main2, .{ .name = "main" });34 @export(&main2, .{ .name = "main" });
35 }35 }
36 } else if (builtin.os.tag == .windows) {36 } else if (builtin.os.tag == .windows) {
37 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {37 if (!@hasDecl(root, "wWinMainCRTStartup") and !@hasDecl(root, "mainCRTStartup")) {
38 @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });38 @export(&wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
39 }39 }
40 } else if (builtin.os.tag == .opencl) {40 } else if (builtin.os.tag == .opencl) {
41 if (@hasDecl(root, "main"))41 if (@hasDecl(root, "main"))
42 @export(spirvMain2, .{ .name = "main" });42 @export(&spirvMain2, .{ .name = "main" });
43 } else {43 } else {
44 if (!@hasDecl(root, "_start")) {44 if (!@hasDecl(root, "_start")) {
45 @export(_start2, .{ .name = "_start" });45 @export(&_start2, .{ .name = "_start" });
46 }46 }
47 }47 }
48 }48 }
49 } else {49 } else {
50 if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {50 if (builtin.output_mode == .Lib and builtin.link_mode == .dynamic) {
51 if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {51 if (native_os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
52 @export(_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });52 @export(&_DllMainCRTStartup, .{ .name = "_DllMainCRTStartup" });
53 }53 }
54 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {54 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
55 if (builtin.link_libc and @hasDecl(root, "main")) {55 if (builtin.link_libc and @hasDecl(root, "main")) {
56 if (native_arch.isWasm()) {56 if (native_arch.isWasm()) {
57 @export(mainWithoutEnv, .{ .name = "main" });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 != .C) {
59 @export(main, .{ .name = "main" });59 @export(&main, .{ .name = "main" });
60 }60 }
61 } else if (native_os == .windows) {61 } else if (native_os == .windows) {
62 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and62 if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and
63 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))63 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))
64 {64 {
65 @export(WinStartup, .{ .name = "wWinMainCRTStartup" });65 @export(&WinStartup, .{ .name = "wWinMainCRTStartup" });
66 } else if (@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and66 } else if (@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and
67 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))67 !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))
68 {68 {
...@@ -70,10 +70,10 @@ comptime {...@@ -70,10 +70,10 @@ comptime {
70 } else if (@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup") and70 } else if (@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup") and
71 !@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup"))71 !@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup"))
72 {72 {
73 @export(wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" });73 @export(&wWinMainCRTStartup, .{ .name = "wWinMainCRTStartup" });
74 }74 }
75 } else if (native_os == .uefi) {75 } else if (native_os == .uefi) {
76 if (!@hasDecl(root, "EfiMain")) @export(EfiMain, .{ .name = "EfiMain" });76 if (!@hasDecl(root, "EfiMain")) @export(&EfiMain, .{ .name = "EfiMain" });
77 } else if (native_os == .wasi) {77 } else if (native_os == .wasi) {
78 const wasm_start_sym = switch (builtin.wasi_exec_model) {78 const wasm_start_sym = switch (builtin.wasi_exec_model) {
79 .reactor => "_initialize",79 .reactor => "_initialize",
...@@ -82,14 +82,14 @@ comptime {...@@ -82,14 +82,14 @@ comptime {
82 if (!@hasDecl(root, wasm_start_sym) and @hasDecl(root, "main")) {82 if (!@hasDecl(root, wasm_start_sym) and @hasDecl(root, "main")) {
83 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which83 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which
84 // case it's not required to provide an entrypoint such as main.84 // case it's not required to provide an entrypoint such as main.
85 @export(wasi_start, .{ .name = wasm_start_sym });85 @export(&wasi_start, .{ .name = wasm_start_sym });
86 }86 }
87 } else if (native_arch.isWasm() and native_os == .freestanding) {87 } else if (native_arch.isWasm() and native_os == .freestanding) {
88 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which88 // Only call main when defined. For WebAssembly it's allowed to pass `-fno-entry` in which
89 // case it's not required to provide an entrypoint such as main.89 // case it's not required to provide an entrypoint such as main.
90 if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(wasm_freestanding_start, .{ .name = start_sym_name });90 if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(&wasm_freestanding_start, .{ .name = start_sym_name });
91 } else if (native_os != .other and native_os != .freestanding) {91 } else if (native_os != .other and native_os != .freestanding) {
92 if (!@hasDecl(root, start_sym_name)) @export(_start, .{ .name = start_sym_name });92 if (!@hasDecl(root, start_sym_name)) @export(&_start, .{ .name = start_sym_name });
93 }93 }
94 }94 }
95 }95 }
lib/std/zig/AstGen.zig+97-136
...@@ -811,18 +811,18 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE...@@ -811,18 +811,18 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
811 .builtin_call_two, .builtin_call_two_comma => {811 .builtin_call_two, .builtin_call_two_comma => {
812 if (node_datas[node].lhs == 0) {812 if (node_datas[node].lhs == 0) {
813 const params = [_]Ast.Node.Index{};813 const params = [_]Ast.Node.Index{};
814 return builtinCall(gz, scope, ri, node, &params);814 return builtinCall(gz, scope, ri, node, &params, false);
815 } else if (node_datas[node].rhs == 0) {815 } else if (node_datas[node].rhs == 0) {
816 const params = [_]Ast.Node.Index{node_datas[node].lhs};816 const params = [_]Ast.Node.Index{node_datas[node].lhs};
817 return builtinCall(gz, scope, ri, node, &params);817 return builtinCall(gz, scope, ri, node, &params, false);
818 } else {818 } else {
819 const params = [_]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };819 const params = [_]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
820 return builtinCall(gz, scope, ri, node, &params);820 return builtinCall(gz, scope, ri, node, &params, false);
821 }821 }
822 },822 },
823 .builtin_call, .builtin_call_comma => {823 .builtin_call, .builtin_call_comma => {
824 const params = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];824 const params = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
825 return builtinCall(gz, scope, ri, node, params);825 return builtinCall(gz, scope, ri, node, params, false);
826 },826 },
827827
828 .call_one,828 .call_one,
...@@ -1017,16 +1017,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE...@@ -1017,16 +1017,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
1017 .block_two, .block_two_semicolon => {1017 .block_two, .block_two_semicolon => {
1018 const statements = [2]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };1018 const statements = [2]Ast.Node.Index{ node_datas[node].lhs, node_datas[node].rhs };
1019 if (node_datas[node].lhs == 0) {1019 if (node_datas[node].lhs == 0) {
1020 return blockExpr(gz, scope, ri, node, statements[0..0]);1020 return blockExpr(gz, scope, ri, node, statements[0..0], .normal);
1021 } else if (node_datas[node].rhs == 0) {1021 } else if (node_datas[node].rhs == 0) {
1022 return blockExpr(gz, scope, ri, node, statements[0..1]);1022 return blockExpr(gz, scope, ri, node, statements[0..1], .normal);
1023 } else {1023 } else {
1024 return blockExpr(gz, scope, ri, node, statements[0..2]);1024 return blockExpr(gz, scope, ri, node, statements[0..2], .normal);
1025 }1025 }
1026 },1026 },
1027 .block, .block_semicolon => {1027 .block, .block_semicolon => {
1028 const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];1028 const statements = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
1029 return blockExpr(gz, scope, ri, node, statements);1029 return blockExpr(gz, scope, ri, node, statements, .normal);
1030 },1030 },
1031 .enum_literal => return simpleStrTok(gz, ri, main_tokens[node], node, .enum_literal),1031 .enum_literal => return simpleStrTok(gz, ri, main_tokens[node], node, .enum_literal),
1032 .error_value => return simpleStrTok(gz, ri, node_datas[node].rhs, node, .error_value),1032 .error_value => return simpleStrTok(gz, ri, node_datas[node].rhs, node, .error_value),
...@@ -1241,7 +1241,7 @@ fn suspendExpr(...@@ -1241,7 +1241,7 @@ fn suspendExpr(
1241 suspend_scope.suspend_node = node;1241 suspend_scope.suspend_node = node;
1242 defer suspend_scope.unstack();1242 defer suspend_scope.unstack();
12431243
1244 const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node);1244 const body_result = try fullBodyExpr(&suspend_scope, &suspend_scope.base, .{ .rl = .none }, body_node, .normal);
1245 if (!gz.refIsNoReturn(body_result)) {1245 if (!gz.refIsNoReturn(body_result)) {
1246 _ = try suspend_scope.addBreak(.break_inline, suspend_inst, .void_value);1246 _ = try suspend_scope.addBreak(.break_inline, suspend_inst, .void_value);
1247 }1247 }
...@@ -1362,7 +1362,7 @@ fn fnProtoExpr(...@@ -1362,7 +1362,7 @@ fn fnProtoExpr(
1362 assert(param_type_node != 0);1362 assert(param_type_node != 0);
1363 var param_gz = block_scope.makeSubBlock(scope);1363 var param_gz = block_scope.makeSubBlock(scope);
1364 defer param_gz.unstack();1364 defer param_gz.unstack();
1365 const param_type = try fullBodyExpr(&param_gz, scope, coerced_type_ri, param_type_node);1365 const param_type = try fullBodyExpr(&param_gz, scope, coerced_type_ri, param_type_node, .normal);
1366 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);1366 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);
1367 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);1367 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
1368 const main_tokens = tree.nodes.items(.main_token);1368 const main_tokens = tree.nodes.items(.main_token);
...@@ -2040,13 +2040,13 @@ fn comptimeExpr(...@@ -2040,13 +2040,13 @@ fn comptimeExpr(
2040 else2040 else
2041 stmts[0..2];2041 stmts[0..2];
20422042
2043 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true);2043 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmt_slice, true, .normal);
2044 return rvalue(gz, ri, block_ref, node);2044 return rvalue(gz, ri, block_ref, node);
2045 },2045 },
2046 .block, .block_semicolon => {2046 .block, .block_semicolon => {
2047 const stmts = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];2047 const stmts = tree.extra_data[node_datas[node].lhs..node_datas[node].rhs];
2048 // Replace result location and copy back later - see above.2048 // Replace result location and copy back later - see above.
2049 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true);2049 const block_ref = try labeledBlockExpr(gz, scope, ty_only_ri, node, stmts, true, .normal);
2050 return rvalue(gz, ri, block_ref, node);2050 return rvalue(gz, ri, block_ref, node);
2051 },2051 },
2052 else => unreachable,2052 else => unreachable,
...@@ -2071,7 +2071,7 @@ fn comptimeExpr(...@@ -2071,7 +2071,7 @@ fn comptimeExpr(
2071 else2071 else
2072 .none,2072 .none,
2073 };2073 };
2074 const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node);2074 const block_result = try fullBodyExpr(&block_scope, scope, ty_only_ri, node, .normal);
2075 if (!gz.refIsNoReturn(block_result)) {2075 if (!gz.refIsNoReturn(block_result)) {
2076 _ = try block_scope.addBreak(.@"break", block_inst, block_result);2076 _ = try block_scope.addBreak(.@"break", block_inst, block_result);
2077 }2077 }
...@@ -2311,6 +2311,7 @@ fn fullBodyExpr(...@@ -2311,6 +2311,7 @@ fn fullBodyExpr(
2311 scope: *Scope,2311 scope: *Scope,
2312 ri: ResultInfo,2312 ri: ResultInfo,
2313 node: Ast.Node.Index,2313 node: Ast.Node.Index,
2314 block_kind: BlockKind,
2314) InnerError!Zir.Inst.Ref {2315) InnerError!Zir.Inst.Ref {
2315 const tree = gz.astgen.tree;2316 const tree = gz.astgen.tree;
2316 const node_tags = tree.nodes.items(.tag);2317 const node_tags = tree.nodes.items(.tag);
...@@ -2340,21 +2341,24 @@ fn fullBodyExpr(...@@ -2340,21 +2341,24 @@ fn fullBodyExpr(
2340 // Labeled blocks are tricky - forwarding result location information properly is non-trivial,2341 // Labeled blocks are tricky - forwarding result location information properly is non-trivial,
2341 // plus if this block is exited with a `break_inline` we aren't allowed multiple breaks. This2342 // plus if this block is exited with a `break_inline` we aren't allowed multiple breaks. This
2342 // case is rare, so just treat it as a normal expression and create a nested block.2343 // case is rare, so just treat it as a normal expression and create a nested block.
2343 return expr(gz, scope, ri, node);2344 return blockExpr(gz, scope, ri, node, statements, block_kind);
2344 }2345 }
23452346
2346 var sub_gz = gz.makeSubBlock(scope);2347 var sub_gz = gz.makeSubBlock(scope);
2347 try blockExprStmts(&sub_gz, &sub_gz.base, statements);2348 try blockExprStmts(&sub_gz, &sub_gz.base, statements, block_kind);
23482349
2349 return rvalue(gz, ri, .void_value, node);2350 return rvalue(gz, ri, .void_value, node);
2350}2351}
23512352
2353const BlockKind = enum { normal, allow_branch_hint };
2354
2352fn blockExpr(2355fn blockExpr(
2353 gz: *GenZir,2356 gz: *GenZir,
2354 scope: *Scope,2357 scope: *Scope,
2355 ri: ResultInfo,2358 ri: ResultInfo,
2356 block_node: Ast.Node.Index,2359 block_node: Ast.Node.Index,
2357 statements: []const Ast.Node.Index,2360 statements: []const Ast.Node.Index,
2361 kind: BlockKind,
2358) InnerError!Zir.Inst.Ref {2362) InnerError!Zir.Inst.Ref {
2359 const astgen = gz.astgen;2363 const astgen = gz.astgen;
2360 const tree = astgen.tree;2364 const tree = astgen.tree;
...@@ -2365,7 +2369,7 @@ fn blockExpr(...@@ -2365,7 +2369,7 @@ fn blockExpr(
2365 if (token_tags[lbrace - 1] == .colon and2369 if (token_tags[lbrace - 1] == .colon and
2366 token_tags[lbrace - 2] == .identifier)2370 token_tags[lbrace - 2] == .identifier)
2367 {2371 {
2368 return labeledBlockExpr(gz, scope, ri, block_node, statements, false);2372 return labeledBlockExpr(gz, scope, ri, block_node, statements, false, kind);
2369 }2373 }
23702374
2371 if (!gz.is_comptime) {2375 if (!gz.is_comptime) {
...@@ -2380,7 +2384,7 @@ fn blockExpr(...@@ -2380,7 +2384,7 @@ fn blockExpr(
2380 var block_scope = gz.makeSubBlock(scope);2384 var block_scope = gz.makeSubBlock(scope);
2381 defer block_scope.unstack();2385 defer block_scope.unstack();
23822386
2383 try blockExprStmts(&block_scope, &block_scope.base, statements);2387 try blockExprStmts(&block_scope, &block_scope.base, statements, kind);
23842388
2385 if (!block_scope.endsWithNoReturn()) {2389 if (!block_scope.endsWithNoReturn()) {
2386 // As our last action before the break, "pop" the error trace if needed2390 // As our last action before the break, "pop" the error trace if needed
...@@ -2391,7 +2395,7 @@ fn blockExpr(...@@ -2391,7 +2395,7 @@ fn blockExpr(
2391 try block_scope.setBlockBody(block_inst);2395 try block_scope.setBlockBody(block_inst);
2392 } else {2396 } else {
2393 var sub_gz = gz.makeSubBlock(scope);2397 var sub_gz = gz.makeSubBlock(scope);
2394 try blockExprStmts(&sub_gz, &sub_gz.base, statements);2398 try blockExprStmts(&sub_gz, &sub_gz.base, statements, kind);
2395 }2399 }
23962400
2397 return rvalue(gz, ri, .void_value, block_node);2401 return rvalue(gz, ri, .void_value, block_node);
...@@ -2436,6 +2440,7 @@ fn labeledBlockExpr(...@@ -2436,6 +2440,7 @@ fn labeledBlockExpr(
2436 block_node: Ast.Node.Index,2440 block_node: Ast.Node.Index,
2437 statements: []const Ast.Node.Index,2441 statements: []const Ast.Node.Index,
2438 force_comptime: bool,2442 force_comptime: bool,
2443 block_kind: BlockKind,
2439) InnerError!Zir.Inst.Ref {2444) InnerError!Zir.Inst.Ref {
2440 const astgen = gz.astgen;2445 const astgen = gz.astgen;
2441 const tree = astgen.tree;2446 const tree = astgen.tree;
...@@ -2476,7 +2481,7 @@ fn labeledBlockExpr(...@@ -2476,7 +2481,7 @@ fn labeledBlockExpr(
2476 if (force_comptime) block_scope.is_comptime = true;2481 if (force_comptime) block_scope.is_comptime = true;
2477 defer block_scope.unstack();2482 defer block_scope.unstack();
24782483
2479 try blockExprStmts(&block_scope, &block_scope.base, statements);2484 try blockExprStmts(&block_scope, &block_scope.base, statements, block_kind);
2480 if (!block_scope.endsWithNoReturn()) {2485 if (!block_scope.endsWithNoReturn()) {
2481 // As our last action before the return, "pop" the error trace if needed2486 // As our last action before the return, "pop" the error trace if needed
2482 _ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node);2487 _ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node);
...@@ -2495,7 +2500,7 @@ fn labeledBlockExpr(...@@ -2495,7 +2500,7 @@ fn labeledBlockExpr(
2495 }2500 }
2496}2501}
24972502
2498fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index) !void {2503fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Node.Index, block_kind: BlockKind) !void {
2499 const astgen = gz.astgen;2504 const astgen = gz.astgen;
2500 const tree = astgen.tree;2505 const tree = astgen.tree;
2501 const node_tags = tree.nodes.items(.tag);2506 const node_tags = tree.nodes.items(.tag);
...@@ -2509,7 +2514,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod...@@ -2509,7 +2514,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
25092514
2510 var noreturn_src_node: Ast.Node.Index = 0;2515 var noreturn_src_node: Ast.Node.Index = 0;
2511 var scope = parent_scope;2516 var scope = parent_scope;
2512 for (statements) |statement| {2517 for (statements, 0..) |statement, stmt_idx| {
2513 if (noreturn_src_node != 0) {2518 if (noreturn_src_node != 0) {
2514 try astgen.appendErrorNodeNotes(2519 try astgen.appendErrorNodeNotes(
2515 statement,2520 statement,
...@@ -2524,6 +2529,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod...@@ -2524,6 +2529,10 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
2524 },2529 },
2525 );2530 );
2526 }2531 }
2532 const allow_branch_hint = switch (block_kind) {
2533 .normal => false,
2534 .allow_branch_hint => stmt_idx == 0,
2535 };
2527 var inner_node = statement;2536 var inner_node = statement;
2528 while (true) {2537 while (true) {
2529 switch (node_tags[inner_node]) {2538 switch (node_tags[inner_node]) {
...@@ -2567,6 +2576,30 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod...@@ -2567,6 +2576,30 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod
2567 .for_simple,2576 .for_simple,
2568 .@"for", => _ = try forExpr(gz, scope, .{ .rl = .none }, inner_node, tree.fullFor(inner_node).?, true),2577 .@"for", => _ = try forExpr(gz, scope, .{ .rl = .none }, inner_node, tree.fullFor(inner_node).?, true),
25692578
2579 // These cases are here to allow branch hints.
2580 .builtin_call_two, .builtin_call_two_comma => {
2581 try emitDbgNode(gz, inner_node);
2582 const ri: ResultInfo = .{ .rl = .none };
2583 const result = if (node_data[inner_node].lhs == 0) r: {
2584 break :r try builtinCall(gz, scope, ri, inner_node, &.{}, allow_branch_hint);
2585 } else if (node_data[inner_node].rhs == 0) r: {
2586 break :r try builtinCall(gz, scope, ri, inner_node, &.{node_data[inner_node].lhs}, allow_branch_hint);
2587 } else r: {
2588 break :r try builtinCall(gz, scope, ri, inner_node, &.{
2589 node_data[inner_node].lhs,
2590 node_data[inner_node].rhs,
2591 }, allow_branch_hint);
2592 };
2593 noreturn_src_node = try addEnsureResult(gz, result, inner_node);
2594 },
2595 .builtin_call, .builtin_call_comma => {
2596 try emitDbgNode(gz, inner_node);
2597 const ri: ResultInfo = .{ .rl = .none };
2598 const params = tree.extra_data[node_data[inner_node].lhs..node_data[inner_node].rhs];
2599 const result = try builtinCall(gz, scope, ri, inner_node, params, allow_branch_hint);
2600 noreturn_src_node = try addEnsureResult(gz, result, inner_node);
2601 },
2602
2570 else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node),2603 else => noreturn_src_node = try unusedResultExpr(gz, scope, inner_node),
2571 // zig fmt: on2604 // zig fmt: on
2572 }2605 }
...@@ -2827,7 +2860,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As...@@ -2827,7 +2860,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
2827 .fence,2860 .fence,
2828 .set_float_mode,2861 .set_float_mode,
2829 .set_align_stack,2862 .set_align_stack,
2830 .set_cold,2863 .branch_hint,
2831 => break :b true,2864 => break :b true,
2832 else => break :b false,2865 else => break :b false,
2833 },2866 },
...@@ -2861,7 +2894,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As...@@ -2861,7 +2894,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
2861 .ensure_result_non_error,2894 .ensure_result_non_error,
2862 .ensure_err_union_payload_void,2895 .ensure_err_union_payload_void,
2863 .@"export",2896 .@"export",
2864 .export_value,
2865 .set_eval_branch_quota,2897 .set_eval_branch_quota,
2866 .atomic_store,2898 .atomic_store,
2867 .store_node,2899 .store_node,
...@@ -4155,7 +4187,7 @@ fn fnDecl(...@@ -4155,7 +4187,7 @@ fn fnDecl(
4155 assert(param_type_node != 0);4187 assert(param_type_node != 0);
4156 var param_gz = decl_gz.makeSubBlock(scope);4188 var param_gz = decl_gz.makeSubBlock(scope);
4157 defer param_gz.unstack();4189 defer param_gz.unstack();
4158 const param_type = try fullBodyExpr(&param_gz, params_scope, coerced_type_ri, param_type_node);4190 const param_type = try fullBodyExpr(&param_gz, params_scope, coerced_type_ri, param_type_node, .normal);
4159 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);4191 const param_inst_expected: Zir.Inst.Index = @enumFromInt(astgen.instructions.len + 1);
4160 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);4192 _ = try param_gz.addBreakWithSrcNode(.break_inline, param_inst_expected, param_type, param_type_node);
41614193
...@@ -4277,7 +4309,7 @@ fn fnDecl(...@@ -4277,7 +4309,7 @@ fn fnDecl(
4277 var ret_gz = decl_gz.makeSubBlock(params_scope);4309 var ret_gz = decl_gz.makeSubBlock(params_scope);
4278 defer ret_gz.unstack();4310 defer ret_gz.unstack();
4279 const ret_ref: Zir.Inst.Ref = inst: {4311 const ret_ref: Zir.Inst.Ref = inst: {
4280 const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type);4312 const inst = try fullBodyExpr(&ret_gz, params_scope, coerced_type_ri, fn_proto.ast.return_type, .normal);
4281 if (ret_gz.instructionsSlice().len == 0) {4313 if (ret_gz.instructionsSlice().len == 0) {
4282 // In this case we will send a len=0 body which can be encoded more efficiently.4314 // In this case we will send a len=0 body which can be encoded more efficiently.
4283 break :inst inst;4315 break :inst inst;
...@@ -4352,7 +4384,7 @@ fn fnDecl(...@@ -4352,7 +4384,7 @@ fn fnDecl(
4352 const lbrace_line = astgen.source_line - decl_gz.decl_line;4384 const lbrace_line = astgen.source_line - decl_gz.decl_line;
4353 const lbrace_column = astgen.source_column;4385 const lbrace_column = astgen.source_column;
43544386
4355 _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node);4387 _ = try fullBodyExpr(&fn_gz, params_scope, .{ .rl = .none }, body_node, .allow_branch_hint);
4356 try checkUsed(gz, &fn_gz.base, params_scope);4388 try checkUsed(gz, &fn_gz.base, params_scope);
43574389
4358 if (!fn_gz.endsWithNoReturn()) {4390 if (!fn_gz.endsWithNoReturn()) {
...@@ -4553,20 +4585,20 @@ fn globalVarDecl(...@@ -4553,20 +4585,20 @@ fn globalVarDecl(
45534585
4554 var align_gz = block_scope.makeSubBlock(scope);4586 var align_gz = block_scope.makeSubBlock(scope);
4555 if (var_decl.ast.align_node != 0) {4587 if (var_decl.ast.align_node != 0) {
4556 const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node);4588 const align_inst = try fullBodyExpr(&align_gz, &align_gz.base, coerced_align_ri, var_decl.ast.align_node, .normal);
4557 _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, align_inst, node);4589 _ = try align_gz.addBreakWithSrcNode(.break_inline, decl_inst, align_inst, node);
4558 }4590 }
45594591
4560 var linksection_gz = align_gz.makeSubBlock(scope);4592 var linksection_gz = align_gz.makeSubBlock(scope);
4561 if (var_decl.ast.section_node != 0) {4593 if (var_decl.ast.section_node != 0) {
4562 const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node);4594 const linksection_inst = try fullBodyExpr(&linksection_gz, &linksection_gz.base, coerced_linksection_ri, var_decl.ast.section_node, .normal);
4563 _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node);4595 _ = try linksection_gz.addBreakWithSrcNode(.break_inline, decl_inst, linksection_inst, node);
4564 }4596 }
45654597
4566 var addrspace_gz = linksection_gz.makeSubBlock(scope);4598 var addrspace_gz = linksection_gz.makeSubBlock(scope);
4567 if (var_decl.ast.addrspace_node != 0) {4599 if (var_decl.ast.addrspace_node != 0) {
4568 const addrspace_ty = try addrspace_gz.addBuiltinValue(var_decl.ast.addrspace_node, .address_space);4600 const addrspace_ty = try addrspace_gz.addBuiltinValue(var_decl.ast.addrspace_node, .address_space);
4569 const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node);4601 const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node, .normal);
4570 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);4602 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);
4571 }4603 }
45724604
...@@ -4623,7 +4655,7 @@ fn comptimeDecl(...@@ -4623,7 +4655,7 @@ fn comptimeDecl(
4623 };4655 };
4624 defer decl_block.unstack();4656 defer decl_block.unstack();
46254657
4626 const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node);4658 const block_result = try fullBodyExpr(&decl_block, &decl_block.base, .{ .rl = .none }, body_node, .normal);
4627 if (decl_block.isEmpty() or !decl_block.refIsNoReturn(block_result)) {4659 if (decl_block.isEmpty() or !decl_block.refIsNoReturn(block_result)) {
4628 _ = try decl_block.addBreak(.break_inline, decl_inst, .void_value);4660 _ = try decl_block.addBreak(.break_inline, decl_inst, .void_value);
4629 }4661 }
...@@ -4844,7 +4876,7 @@ fn testDecl(...@@ -4844,7 +4876,7 @@ fn testDecl(
4844 const lbrace_line = astgen.source_line - decl_block.decl_line;4876 const lbrace_line = astgen.source_line - decl_block.decl_line;
4845 const lbrace_column = astgen.source_column;4877 const lbrace_column = astgen.source_column;
48464878
4847 const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node);4879 const block_result = try fullBodyExpr(&fn_block, &fn_block.base, .{ .rl = .none }, body_node, .normal);
4848 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {4880 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
48494881
4850 // As our last action before the return, "pop" the error trace if needed4882 // As our last action before the return, "pop" the error trace if needed
...@@ -6113,7 +6145,7 @@ fn orelseCatchExpr(...@@ -6113,7 +6145,7 @@ fn orelseCatchExpr(
6113 break :blk &err_val_scope.base;6145 break :blk &err_val_scope.base;
6114 };6146 };
61156147
6116 const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs);6148 const else_result = try fullBodyExpr(&else_scope, else_sub_scope, block_scope.break_result_info, rhs, .allow_branch_hint);
6117 if (!else_scope.endsWithNoReturn()) {6149 if (!else_scope.endsWithNoReturn()) {
6118 // As our last action before the break, "pop" the error trace if needed6150 // As our last action before the break, "pop" the error trace if needed
6119 if (do_err_trace)6151 if (do_err_trace)
...@@ -6281,7 +6313,7 @@ fn boolBinOp(...@@ -6281,7 +6313,7 @@ fn boolBinOp(
62816313
6282 var rhs_scope = gz.makeSubBlock(scope);6314 var rhs_scope = gz.makeSubBlock(scope);
6283 defer rhs_scope.unstack();6315 defer rhs_scope.unstack();
6284 const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs);6316 const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, node_datas[node].rhs, .allow_branch_hint);
6285 if (!gz.refIsNoReturn(rhs)) {6317 if (!gz.refIsNoReturn(rhs)) {
6286 _ = try rhs_scope.addBreakWithSrcNode(.break_inline, bool_br, rhs, node_datas[node].rhs);6318 _ = try rhs_scope.addBreakWithSrcNode(.break_inline, bool_br, rhs, node_datas[node].rhs);
6287 }6319 }
...@@ -6425,7 +6457,7 @@ fn ifExpr(...@@ -6425,7 +6457,7 @@ fn ifExpr(
6425 }6457 }
6426 };6458 };
64276459
6428 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node);6460 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, block_scope.break_result_info, then_node, .allow_branch_hint);
6429 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);6461 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
6430 if (!then_scope.endsWithNoReturn()) {6462 if (!then_scope.endsWithNoReturn()) {
6431 _ = try then_scope.addBreakWithSrcNode(.@"break", block, then_result, then_node);6463 _ = try then_scope.addBreakWithSrcNode(.@"break", block, then_result, then_node);
...@@ -6467,7 +6499,7 @@ fn ifExpr(...@@ -6467,7 +6499,7 @@ fn ifExpr(
6467 break :s &else_scope.base;6499 break :s &else_scope.base;
6468 }6500 }
6469 };6501 };
6470 const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node);6502 const else_result = try fullBodyExpr(&else_scope, sub_scope, block_scope.break_result_info, else_node, .allow_branch_hint);
6471 if (!else_scope.endsWithNoReturn()) {6503 if (!else_scope.endsWithNoReturn()) {
6472 // As our last action before the break, "pop" the error trace if needed6504 // As our last action before the break, "pop" the error trace if needed
6473 if (do_err_trace)6505 if (do_err_trace)
...@@ -6576,7 +6608,7 @@ fn whileExpr(...@@ -6576,7 +6608,7 @@ fn whileExpr(
6576 } = c: {6608 } = c: {
6577 if (while_full.error_token) |_| {6609 if (while_full.error_token) |_| {
6578 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };6610 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };
6579 const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr);6611 const err_union = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal);
6580 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_err_ptr else .is_non_err;6612 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_err_ptr else .is_non_err;
6581 break :c .{6613 break :c .{
6582 .inst = err_union,6614 .inst = err_union,
...@@ -6584,14 +6616,14 @@ fn whileExpr(...@@ -6584,14 +6616,14 @@ fn whileExpr(
6584 };6616 };
6585 } else if (while_full.payload_token) |_| {6617 } else if (while_full.payload_token) |_| {
6586 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };6618 const cond_ri: ResultInfo = .{ .rl = if (payload_is_ref) .ref else .none };
6587 const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr);6619 const optional = try fullBodyExpr(&cond_scope, &cond_scope.base, cond_ri, while_full.ast.cond_expr, .normal);
6588 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;6620 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
6589 break :c .{6621 break :c .{
6590 .inst = optional,6622 .inst = optional,
6591 .bool_bit = try cond_scope.addUnNode(tag, optional, while_full.ast.cond_expr),6623 .bool_bit = try cond_scope.addUnNode(tag, optional, while_full.ast.cond_expr),
6592 };6624 };
6593 } else {6625 } else {
6594 const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr);6626 const cond = try fullBodyExpr(&cond_scope, &cond_scope.base, coerced_bool_ri, while_full.ast.cond_expr, .normal);
6595 break :c .{6627 break :c .{
6596 .inst = cond,6628 .inst = cond,
6597 .bool_bit = cond,6629 .bool_bit = cond,
...@@ -6716,7 +6748,7 @@ fn whileExpr(...@@ -6716,7 +6748,7 @@ fn whileExpr(
6716 continue_scope.instructions_top = continue_scope.instructions.items.len;6748 continue_scope.instructions_top = continue_scope.instructions.items.len;
6717 {6749 {
6718 try emitDbgNode(&continue_scope, then_node);6750 try emitDbgNode(&continue_scope, then_node);
6719 const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node);6751 const unused_result = try fullBodyExpr(&continue_scope, &continue_scope.base, .{ .rl = .none }, then_node, .allow_branch_hint);
6720 _ = try addEnsureResult(&continue_scope, unused_result, then_node);6752 _ = try addEnsureResult(&continue_scope, unused_result, then_node);
6721 }6753 }
6722 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);6754 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
...@@ -6762,7 +6794,7 @@ fn whileExpr(...@@ -6762,7 +6794,7 @@ fn whileExpr(
6762 // control flow apply to outer loops; not this one.6794 // control flow apply to outer loops; not this one.
6763 loop_scope.continue_block = .none;6795 loop_scope.continue_block = .none;
6764 loop_scope.break_block = .none;6796 loop_scope.break_block = .none;
6765 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node);6797 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint);
6766 if (is_statement) {6798 if (is_statement) {
6767 _ = try addEnsureResult(&else_scope, else_result, else_node);6799 _ = try addEnsureResult(&else_scope, else_result, else_node);
6768 }6800 }
...@@ -7030,7 +7062,7 @@ fn forExpr(...@@ -7030,7 +7062,7 @@ fn forExpr(
7030 break :blk capture_sub_scope;7062 break :blk capture_sub_scope;
7031 };7063 };
70327064
7033 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node);7065 const then_result = try fullBodyExpr(&then_scope, then_sub_scope, .{ .rl = .none }, then_node, .allow_branch_hint);
7034 _ = try addEnsureResult(&then_scope, then_result, then_node);7066 _ = try addEnsureResult(&then_scope, then_result, then_node);
70357067
7036 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);7068 try checkUsed(parent_gz, &then_scope.base, then_sub_scope);
...@@ -7049,7 +7081,7 @@ fn forExpr(...@@ -7049,7 +7081,7 @@ fn forExpr(
7049 // control flow apply to outer loops; not this one.7081 // control flow apply to outer loops; not this one.
7050 loop_scope.continue_block = .none;7082 loop_scope.continue_block = .none;
7051 loop_scope.break_block = .none;7083 loop_scope.break_block = .none;
7052 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node);7084 const else_result = try fullBodyExpr(&else_scope, sub_scope, loop_scope.break_result_info, else_node, .allow_branch_hint);
7053 if (is_statement) {7085 if (is_statement) {
7054 _ = try addEnsureResult(&else_scope, else_result, else_node);7086 _ = try addEnsureResult(&else_scope, else_result, else_node);
7055 }7087 }
...@@ -7526,7 +7558,7 @@ fn switchExprErrUnion(...@@ -7526,7 +7558,7 @@ fn switchExprErrUnion(
7526 }7558 }
75277559
7528 const target_expr_node = case.ast.target_expr;7560 const target_expr_node = case.ast.target_expr;
7529 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node);7561 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint);
7530 // check capture_scope, not err_scope to avoid false positive unused error capture7562 // check capture_scope, not err_scope to avoid false positive unused error capture
7531 try checkUsed(parent_gz, &case_scope.base, err_scope.parent);7563 try checkUsed(parent_gz, &case_scope.base, err_scope.parent);
7532 const uses_err = err_scope.used != 0 or err_scope.discarded != 0;7564 const uses_err = err_scope.used != 0 or err_scope.discarded != 0;
...@@ -7987,7 +8019,7 @@ fn switchExpr(...@@ -7987,7 +8019,7 @@ fn switchExpr(
7987 try case_scope.addDbgVar(.dbg_var_val, dbg_var_tag_name, dbg_var_tag_inst);8019 try case_scope.addDbgVar(.dbg_var_val, dbg_var_tag_name, dbg_var_tag_inst);
7988 }8020 }
7989 const target_expr_node = case.ast.target_expr;8021 const target_expr_node = case.ast.target_expr;
7990 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node);8022 const case_result = try fullBodyExpr(&case_scope, sub_scope, block_scope.break_result_info, target_expr_node, .allow_branch_hint);
7991 try checkUsed(parent_gz, &case_scope.base, sub_scope);8023 try checkUsed(parent_gz, &case_scope.base, sub_scope);
7992 if (!parent_gz.refIsNoReturn(case_result)) {8024 if (!parent_gz.refIsNoReturn(case_result)) {
7993 _ = try case_scope.addBreakWithSrcNode(.@"break", switch_block, case_result, target_expr_node);8025 _ = try case_scope.addBreakWithSrcNode(.@"break", switch_block, case_result, target_expr_node);
...@@ -9155,6 +9187,7 @@ fn builtinCall(...@@ -9155,6 +9187,7 @@ fn builtinCall(
9155 ri: ResultInfo,9187 ri: ResultInfo,
9156 node: Ast.Node.Index,9188 node: Ast.Node.Index,
9157 params: []const Ast.Node.Index,9189 params: []const Ast.Node.Index,
9190 allow_branch_hint: bool,
9158) InnerError!Zir.Inst.Ref {9191) InnerError!Zir.Inst.Ref {
9159 const astgen = gz.astgen;9192 const astgen = gz.astgen;
9160 const tree = astgen.tree;9193 const tree = astgen.tree;
...@@ -9188,6 +9221,18 @@ fn builtinCall(...@@ -9188,6 +9221,18 @@ fn builtinCall(
9188 return astgen.failNode(node, "'{s}' outside function scope", .{builtin_name});9221 return astgen.failNode(node, "'{s}' outside function scope", .{builtin_name});
91899222
9190 switch (info.tag) {9223 switch (info.tag) {
9224 .branch_hint => {
9225 if (!allow_branch_hint) {
9226 return astgen.failNode(node, "'@branchHint' must appear as the first statement in a function or conditional branch", .{});
9227 }
9228 const hint_ty = try gz.addBuiltinValue(node, .branch_hint);
9229 const hint_val = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = hint_ty } }, params[0]);
9230 _ = try gz.addExtendedPayload(.branch_hint, Zir.Inst.UnNode{
9231 .node = gz.nodeIndexToRelative(node),
9232 .operand = hint_val,
9233 });
9234 return rvalue(gz, ri, .void_value, node);
9235 },
9191 .import => {9236 .import => {
9192 const node_tags = tree.nodes.items(.tag);9237 const node_tags = tree.nodes.items(.tag);
9193 const operand_node = params[0];9238 const operand_node = params[0];
...@@ -9249,87 +9294,11 @@ fn builtinCall(...@@ -9249,87 +9294,11 @@ fn builtinCall(
9249 // zig fmt: on9294 // zig fmt: on
92509295
9251 .@"export" => {9296 .@"export" => {
9297 const exported = try expr(gz, scope, .{ .rl = .none }, params[0]);
9252 const export_options_ty = try gz.addBuiltinValue(node, .export_options);9298 const export_options_ty = try gz.addBuiltinValue(node, .export_options);
9253 const node_tags = tree.nodes.items(.tag);
9254 const node_datas = tree.nodes.items(.data);
9255 // This function causes a Decl to be exported. The first parameter is not an expression,
9256 // but an identifier of the Decl to be exported.
9257 var namespace: Zir.Inst.Ref = .none;
9258 var decl_name: Zir.NullTerminatedString = .empty;
9259 switch (node_tags[params[0]]) {
9260 .identifier => {
9261 const ident_token = main_tokens[params[0]];
9262 if (isPrimitive(tree.tokenSlice(ident_token))) {
9263 return astgen.failTok(ident_token, "unable to export primitive value", .{});
9264 }
9265 decl_name = try astgen.identAsString(ident_token);
9266
9267 var s = scope;
9268 var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already
9269 while (true) switch (s.tag) {
9270 .local_val => {
9271 const local_val = s.cast(Scope.LocalVal).?;
9272 if (local_val.name == decl_name) {
9273 local_val.used = ident_token;
9274 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9275 .operand = local_val.inst,
9276 .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]),
9277 });
9278 return rvalue(gz, ri, .void_value, node);
9279 }
9280 s = local_val.parent;
9281 },
9282 .local_ptr => {
9283 const local_ptr = s.cast(Scope.LocalPtr).?;
9284 if (local_ptr.name == decl_name) {
9285 if (!local_ptr.maybe_comptime)
9286 return astgen.failNode(params[0], "unable to export runtime-known value", .{});
9287 local_ptr.used = ident_token;
9288 const loaded = try gz.addUnNode(.load, local_ptr.ptr, node);
9289 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9290 .operand = loaded,
9291 .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]),
9292 });
9293 return rvalue(gz, ri, .void_value, node);
9294 }
9295 s = local_ptr.parent;
9296 },
9297 .gen_zir => s = s.cast(GenZir).?.parent,
9298 .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent,
9299 .namespace => {
9300 const ns = s.cast(Scope.Namespace).?;
9301 if (ns.decls.get(decl_name)) |i| {
9302 if (found_already) |f| {
9303 return astgen.failNodeNotes(node, "ambiguous reference", .{}, &.{
9304 try astgen.errNoteNode(f, "declared here", .{}),
9305 try astgen.errNoteNode(i, "also declared here", .{}),
9306 });
9307 }
9308 // We found a match but must continue looking for ambiguous references to decls.
9309 found_already = i;
9310 }
9311 s = ns.parent;
9312 },
9313 .top => break,
9314 };
9315 if (found_already == null) {
9316 const ident_name = try astgen.identifierTokenString(ident_token);
9317 return astgen.failNode(params[0], "use of undeclared identifier '{s}'", .{ident_name});
9318 }
9319 },
9320 .field_access => {
9321 const namespace_node = node_datas[params[0]].lhs;
9322 namespace = try typeExpr(gz, scope, namespace_node);
9323 const dot_token = main_tokens[params[0]];
9324 const field_ident = dot_token + 1;
9325 decl_name = try astgen.identAsString(field_ident);
9326 },
9327 else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}),
9328 }
9329 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]);9299 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]);
9330 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{9300 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
9331 .namespace = namespace,9301 .exported = exported,
9332 .decl_name = decl_name,
9333 .options = options,9302 .options = options,
9334 });9303 });
9335 return rvalue(gz, ri, .void_value, node);9304 return rvalue(gz, ri, .void_value, node);
...@@ -9371,14 +9340,6 @@ fn builtinCall(...@@ -9371,14 +9340,6 @@ fn builtinCall(
9371 });9340 });
9372 return rvalue(gz, ri, .void_value, node);9341 return rvalue(gz, ri, .void_value, node);
9373 },9342 },
9374 .set_cold => {
9375 const order = try expr(gz, scope, ri, params[0]);
9376 _ = try gz.addExtendedPayload(.set_cold, Zir.Inst.UnNode{
9377 .node = gz.nodeIndexToRelative(node),
9378 .operand = order,
9379 });
9380 return rvalue(gz, ri, .void_value, node);
9381 },
93829343
9383 .src => {9344 .src => {
9384 // Incorporate the source location into the source hash, so that9345 // Incorporate the source location into the source hash, so that
...@@ -10040,7 +10001,7 @@ fn cImport(...@@ -10040,7 +10001,7 @@ fn cImport(
10040 defer block_scope.unstack();10001 defer block_scope.unstack();
1004110002
10042 const block_inst = try gz.makeBlockInst(.c_import, node);10003 const block_inst = try gz.makeBlockInst(.c_import, node);
10043 const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node);10004 const block_result = try fullBodyExpr(&block_scope, &block_scope.base, .{ .rl = .none }, body_node, .normal);
10044 _ = try gz.addUnNode(.ensure_result_used, block_result, node);10005 _ = try gz.addUnNode(.ensure_result_used, block_result, node);
10045 if (!gz.refIsNoReturn(block_result)) {10006 if (!gz.refIsNoReturn(block_result)) {
10046 _ = try block_scope.addBreak(.break_inline, block_inst, .void_value);10007 _ = try block_scope.addBreak(.break_inline, block_inst, .void_value);
...@@ -10123,7 +10084,7 @@ fn callExpr(...@@ -10123,7 +10084,7 @@ fn callExpr(
10123 defer arg_block.unstack();10084 defer arg_block.unstack();
1012410085
10125 // `call_inst` is reused to provide the param type.10086 // `call_inst` is reused to provide the param type.
10126 const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node);10087 const arg_ref = try fullBodyExpr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node, .normal);
10127 _ = try arg_block.addBreakWithSrcNode(.break_inline, call_index, arg_ref, param_node);10088 _ = try arg_block.addBreakWithSrcNode(.break_inline, call_index, arg_ref, param_node);
1012810089
10129 const body = arg_block.instructionsSlice();10090 const body = arg_block.instructionsSlice();
...@@ -11474,7 +11435,7 @@ fn appendErrorNodeNotes(...@@ -11474,7 +11435,7 @@ fn appendErrorNodeNotes(
11474 args: anytype,11435 args: anytype,
11475 notes: []const u32,11436 notes: []const u32,
11476) Allocator.Error!void {11437) Allocator.Error!void {
11477 @setCold(true);11438 @branchHint(.cold);
11478 const string_bytes = &astgen.string_bytes;11439 const string_bytes = &astgen.string_bytes;
11479 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);11440 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
11480 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);11441 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
...@@ -11565,7 +11526,7 @@ fn appendErrorTokNotesOff(...@@ -11565,7 +11526,7 @@ fn appendErrorTokNotesOff(
11565 args: anytype,11526 args: anytype,
11566 notes: []const u32,11527 notes: []const u32,
11567) !void {11528) !void {
11568 @setCold(true);11529 @branchHint(.cold);
11569 const gpa = astgen.gpa;11530 const gpa = astgen.gpa;
11570 const string_bytes = &astgen.string_bytes;11531 const string_bytes = &astgen.string_bytes;
11571 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);11532 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
...@@ -11602,7 +11563,7 @@ fn errNoteTokOff(...@@ -11602,7 +11563,7 @@ fn errNoteTokOff(
11602 comptime format: []const u8,11563 comptime format: []const u8,
11603 args: anytype,11564 args: anytype,
11604) Allocator.Error!u32 {11565) Allocator.Error!u32 {
11605 @setCold(true);11566 @branchHint(.cold);
11606 const string_bytes = &astgen.string_bytes;11567 const string_bytes = &astgen.string_bytes;
11607 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);11568 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
11608 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);11569 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
...@@ -11621,7 +11582,7 @@ fn errNoteNode(...@@ -11621,7 +11582,7 @@ fn errNoteNode(
11621 comptime format: []const u8,11582 comptime format: []const u8,
11622 args: anytype,11583 args: anytype,
11623) Allocator.Error!u32 {11584) Allocator.Error!u32 {
11624 @setCold(true);11585 @branchHint(.cold);
11625 const string_bytes = &astgen.string_bytes;11586 const string_bytes = &astgen.string_bytes;
11626 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);11587 const msg: Zir.NullTerminatedString = @enumFromInt(string_bytes.items.len);
11627 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);11588 try string_bytes.writer(astgen.gpa).print(format ++ "\x00", args);
lib/std/zig/AstRlAnnotate.zig+4-1
...@@ -829,6 +829,10 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast....@@ -829,6 +829,10 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
829 }829 }
830 switch (info.tag) {830 switch (info.tag) {
831 .import => return false,831 .import => return false,
832 .branch_hint => {
833 _ = try astrl.expr(args[0], block, ResultInfo.type_only);
834 return false;
835 },
832 .compile_log, .TypeOf => {836 .compile_log, .TypeOf => {
833 for (args) |arg_node| {837 for (args) |arg_node| {
834 _ = try astrl.expr(arg_node, block, ResultInfo.none);838 _ = try astrl.expr(arg_node, block, ResultInfo.none);
...@@ -907,7 +911,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast....@@ -907,7 +911,6 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.
907 .fence,911 .fence,
908 .set_float_mode,912 .set_float_mode,
909 .set_align_stack,913 .set_align_stack,
910 .set_cold,
911 .type_info,914 .type_info,
912 .work_item_id,915 .work_item_id,
913 .work_group_size,916 .work_group_size,
lib/std/zig/BuiltinFn.zig+9-9
...@@ -14,6 +14,7 @@ pub const Tag = enum {...@@ -14,6 +14,7 @@ pub const Tag = enum {
14 bit_offset_of,14 bit_offset_of,
15 int_from_bool,15 int_from_bool,
16 bit_size_of,16 bit_size_of,
17 branch_hint,
17 breakpoint,18 breakpoint,
18 disable_instrumentation,19 disable_instrumentation,
19 mul_add,20 mul_add,
...@@ -82,7 +83,6 @@ pub const Tag = enum {...@@ -82,7 +83,6 @@ pub const Tag = enum {
82 return_address,83 return_address,
83 select,84 select,
84 set_align_stack,85 set_align_stack,
85 set_cold,
86 set_eval_branch_quota,86 set_eval_branch_quota,
87 set_float_mode,87 set_float_mode,
88 set_runtime_safety,88 set_runtime_safety,
...@@ -256,6 +256,14 @@ pub const list = list: {...@@ -256,6 +256,14 @@ pub const list = list: {
256 .param_count = 1,256 .param_count = 1,
257 },257 },
258 },258 },
259 .{
260 "@branchHint",
261 .{
262 .tag = .branch_hint,
263 .param_count = 1,
264 .illegal_outside_function = true,
265 },
266 },
259 .{267 .{
260 "@breakpoint",268 "@breakpoint",
261 .{269 .{
...@@ -744,14 +752,6 @@ pub const list = list: {...@@ -744,14 +752,6 @@ pub const list = list: {
744 .illegal_outside_function = true,752 .illegal_outside_function = true,
745 },753 },
746 },754 },
747 .{
748 "@setCold",
749 .{
750 .tag = .set_cold,
751 .param_count = 1,
752 .illegal_outside_function = true,
753 },
754 },
755 .{755 .{
756 "@setEvalBranchQuota",756 "@setEvalBranchQuota",
757 .{757 .{
lib/std/zig/Parse.zig+6-6
...@@ -81,7 +81,7 @@ fn addExtra(p: *Parse, extra: anytype) Allocator.Error!Node.Index {...@@ -81,7 +81,7 @@ fn addExtra(p: *Parse, extra: anytype) Allocator.Error!Node.Index {
81}81}
8282
83fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {83fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {
84 @setCold(true);84 @branchHint(.cold);
85 try p.warnMsg(.{85 try p.warnMsg(.{
86 .tag = .expected_token,86 .tag = .expected_token,
87 .token = p.tok_i,87 .token = p.tok_i,
...@@ -90,12 +90,12 @@ fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {...@@ -90,12 +90,12 @@ fn warnExpected(p: *Parse, expected_token: Token.Tag) error{OutOfMemory}!void {
90}90}
9191
92fn warn(p: *Parse, error_tag: AstError.Tag) error{OutOfMemory}!void {92fn warn(p: *Parse, error_tag: AstError.Tag) error{OutOfMemory}!void {
93 @setCold(true);93 @branchHint(.cold);
94 try p.warnMsg(.{ .tag = error_tag, .token = p.tok_i });94 try p.warnMsg(.{ .tag = error_tag, .token = p.tok_i });
95}95}
9696
97fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {97fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {
98 @setCold(true);98 @branchHint(.cold);
99 switch (msg.tag) {99 switch (msg.tag) {
100 .expected_semi_after_decl,100 .expected_semi_after_decl,
101 .expected_semi_after_stmt,101 .expected_semi_after_stmt,
...@@ -141,12 +141,12 @@ fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {...@@ -141,12 +141,12 @@ fn warnMsg(p: *Parse, msg: Ast.Error) error{OutOfMemory}!void {
141}141}
142142
143fn fail(p: *Parse, tag: Ast.Error.Tag) error{ ParseError, OutOfMemory } {143fn fail(p: *Parse, tag: Ast.Error.Tag) error{ ParseError, OutOfMemory } {
144 @setCold(true);144 @branchHint(.cold);
145 return p.failMsg(.{ .tag = tag, .token = p.tok_i });145 return p.failMsg(.{ .tag = tag, .token = p.tok_i });
146}146}
147147
148fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMemory } {148fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMemory } {
149 @setCold(true);149 @branchHint(.cold);
150 return p.failMsg(.{150 return p.failMsg(.{
151 .tag = .expected_token,151 .tag = .expected_token,
152 .token = p.tok_i,152 .token = p.tok_i,
...@@ -155,7 +155,7 @@ fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMe...@@ -155,7 +155,7 @@ fn failExpected(p: *Parse, expected_token: Token.Tag) error{ ParseError, OutOfMe
155}155}
156156
157fn failMsg(p: *Parse, msg: Ast.Error) error{ ParseError, OutOfMemory } {157fn failMsg(p: *Parse, msg: Ast.Error) error{ ParseError, OutOfMemory } {
158 @setCold(true);158 @branchHint(.cold);
159 try p.warnMsg(msg);159 try p.warnMsg(msg);
160 return error.ParseError;160 return error.ParseError;
161}161}
lib/std/zig/Zir.zig+9-26
...@@ -431,14 +431,9 @@ pub const Inst = struct {...@@ -431,14 +431,9 @@ pub const Inst = struct {
431 error_union_type,431 error_union_type,
432 /// `error.Foo` syntax. Uses the `str_tok` field of the Data union.432 /// `error.Foo` syntax. Uses the `str_tok` field of the Data union.
433 error_value,433 error_value,
434 /// Implements the `@export` builtin function, based on either an identifier to a Decl,434 /// Implements the `@export` builtin function.
435 /// or field access of a Decl. The thing being exported is the Decl.
436 /// Uses the `pl_node` union field. Payload is `Export`.435 /// Uses the `pl_node` union field. Payload is `Export`.
437 @"export",436 @"export",
438 /// Implements the `@export` builtin function, based on a comptime-known value.
439 /// The thing being exported is the comptime-known value which is the operand.
440 /// Uses the `pl_node` union field. Payload is `ExportValue`.
441 export_value,
442 /// Given a pointer to a struct or object that contains virtual fields, returns a pointer437 /// Given a pointer to a struct or object that contains virtual fields, returns a pointer
443 /// to the named field. The field name is stored in string_bytes. Used by a.b syntax.438 /// to the named field. The field name is stored in string_bytes. Used by a.b syntax.
444 /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field.439 /// Uses `pl_node` field. The AST node is the a.b syntax. Payload is Field.
...@@ -1093,7 +1088,6 @@ pub const Inst = struct {...@@ -1093,7 +1088,6 @@ pub const Inst = struct {
1093 .ensure_result_non_error,1088 .ensure_result_non_error,
1094 .ensure_err_union_payload_void,1089 .ensure_err_union_payload_void,
1095 .@"export",1090 .@"export",
1096 .export_value,
1097 .field_ptr,1091 .field_ptr,
1098 .field_val,1092 .field_val,
1099 .field_ptr_named,1093 .field_ptr_named,
...@@ -1314,7 +1308,6 @@ pub const Inst = struct {...@@ -1314,7 +1308,6 @@ pub const Inst = struct {
1314 .validate_deref,1308 .validate_deref,
1315 .validate_destructure,1309 .validate_destructure,
1316 .@"export",1310 .@"export",
1317 .export_value,
1318 .set_runtime_safety,1311 .set_runtime_safety,
1319 .memcpy,1312 .memcpy,
1320 .memset,1313 .memset,
...@@ -1553,7 +1546,7 @@ pub const Inst = struct {...@@ -1553,7 +1546,7 @@ pub const Inst = struct {
1553 => false,1546 => false,
15541547
1555 .extended => switch (data.extended.opcode) {1548 .extended => switch (data.extended.opcode) {
1556 .fence, .set_cold, .breakpoint, .disable_instrumentation => true,1549 .fence, .branch_hint, .breakpoint, .disable_instrumentation => true,
1557 else => false,1550 else => false,
1558 },1551 },
1559 };1552 };
...@@ -1637,7 +1630,6 @@ pub const Inst = struct {...@@ -1637,7 +1630,6 @@ pub const Inst = struct {
1637 .error_union_type = .pl_node,1630 .error_union_type = .pl_node,
1638 .error_value = .str_tok,1631 .error_value = .str_tok,
1639 .@"export" = .pl_node,1632 .@"export" = .pl_node,
1640 .export_value = .pl_node,
1641 .field_ptr = .pl_node,1633 .field_ptr = .pl_node,
1642 .field_val = .pl_node,1634 .field_val = .pl_node,
1643 .field_ptr_named = .pl_node,1635 .field_ptr_named = .pl_node,
...@@ -1962,9 +1954,6 @@ pub const Inst = struct {...@@ -1962,9 +1954,6 @@ pub const Inst = struct {
1962 /// Implement builtin `@setAlignStack`.1954 /// Implement builtin `@setAlignStack`.
1963 /// `operand` is payload index to `UnNode`.1955 /// `operand` is payload index to `UnNode`.
1964 set_align_stack,1956 set_align_stack,
1965 /// Implements `@setCold`.
1966 /// `operand` is payload index to `UnNode`.
1967 set_cold,
1968 /// Implements the `@errorCast` builtin.1957 /// Implements the `@errorCast` builtin.
1969 /// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.1958 /// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
1970 error_cast,1959 error_cast,
...@@ -2059,6 +2048,10 @@ pub const Inst = struct {...@@ -2059,6 +2048,10 @@ pub const Inst = struct {
2059 /// `operand` is `src_node: i32`.2048 /// `operand` is `src_node: i32`.
2060 /// `small` is an `Inst.BuiltinValue`.2049 /// `small` is an `Inst.BuiltinValue`.
2061 builtin_value,2050 builtin_value,
2051 /// Provide a `@branchHint` for the current block.
2052 /// `operand` is payload index to `UnNode`.
2053 /// `small` is unused.
2054 branch_hint,
20622055
2063 pub const InstData = struct {2056 pub const InstData = struct {
2064 opcode: Extended,2057 opcode: Extended,
...@@ -3150,6 +3143,7 @@ pub const Inst = struct {...@@ -3150,6 +3143,7 @@ pub const Inst = struct {
3150 export_options,3143 export_options,
3151 extern_options,3144 extern_options,
3152 type_info,3145 type_info,
3146 branch_hint,
3153 // Values3147 // Values
3154 calling_convention_c,3148 calling_convention_c,
3155 calling_convention_inline,3149 calling_convention_inline,
...@@ -3425,17 +3419,7 @@ pub const Inst = struct {...@@ -3425,17 +3419,7 @@ pub const Inst = struct {
3425 };3419 };
34263420
3427 pub const Export = struct {3421 pub const Export = struct {
3428 /// If present, this is referring to a Decl via field access, e.g. `a.b`.3422 exported: Ref,
3429 /// If omitted, this is referring to a Decl via identifier, e.g. `a`.
3430 namespace: Ref,
3431 /// Null-terminated string index.
3432 decl_name: NullTerminatedString,
3433 options: Ref,
3434 };
3435
3436 pub const ExportValue = struct {
3437 /// The comptime value to export.
3438 operand: Ref,
3439 options: Ref,3423 options: Ref,
3440 };3424 };
34413425
...@@ -3793,7 +3777,6 @@ fn findDeclsInner(...@@ -3793,7 +3777,6 @@ fn findDeclsInner(
3793 .error_union_type,3777 .error_union_type,
3794 .error_value,3778 .error_value,
3795 .@"export",3779 .@"export",
3796 .export_value,
3797 .field_ptr,3780 .field_ptr,
3798 .field_val,3781 .field_val,
3799 .field_ptr_named,3782 .field_ptr_named,
...@@ -3981,7 +3964,6 @@ fn findDeclsInner(...@@ -3981,7 +3964,6 @@ fn findDeclsInner(
3981 .fence,3964 .fence,
3982 .set_float_mode,3965 .set_float_mode,
3983 .set_align_stack,3966 .set_align_stack,
3984 .set_cold,
3985 .error_cast,3967 .error_cast,
3986 .await_nosuspend,3968 .await_nosuspend,
3987 .breakpoint,3969 .breakpoint,
...@@ -4005,6 +3987,7 @@ fn findDeclsInner(...@@ -4005,6 +3987,7 @@ fn findDeclsInner(
4005 .closure_get,3987 .closure_get,
4006 .field_parent_ptr,3988 .field_parent_ptr,
4007 .builtin_value,3989 .builtin_value,
3990 .branch_hint,
4008 => return,3991 => return,
40093992
4010 // `@TypeOf` has a body.3993 // `@TypeOf` has a body.
src/Air.zig+109-6
...@@ -433,13 +433,18 @@ pub const Inst = struct {...@@ -433,13 +433,18 @@ pub const Inst = struct {
433 /// In the case of non-error, control flow proceeds to the next instruction433 /// In the case of non-error, control flow proceeds to the next instruction
434 /// after the `try`, with the result of this instruction being the unwrapped434 /// after the `try`, with the result of this instruction being the unwrapped
435 /// payload value, as if `unwrap_errunion_payload` was executed on the operand.435 /// payload value, as if `unwrap_errunion_payload` was executed on the operand.
436 /// The error branch is considered to have a branch hint of `.unlikely`.
436 /// Uses the `pl_op` field. Payload is `Try`.437 /// Uses the `pl_op` field. Payload is `Try`.
437 @"try",438 @"try",
439 /// Same as `try` except the error branch hint is `.cold`.
440 try_cold,
438 /// Same as `try` except the operand is a pointer to an error union, and the441 /// Same as `try` except the operand is a pointer to an error union, and the
439 /// result is a pointer to the payload. Result is as if `unwrap_errunion_payload_ptr`442 /// result is a pointer to the payload. Result is as if `unwrap_errunion_payload_ptr`
440 /// was executed on the operand.443 /// was executed on the operand.
441 /// Uses the `ty_pl` field. Payload is `TryPtr`.444 /// Uses the `ty_pl` field. Payload is `TryPtr`.
442 try_ptr,445 try_ptr,
446 /// Same as `try_ptr` except the error branch hint is `.cold`.
447 try_ptr_cold,
443 /// Notes the beginning of a source code statement and marks the line and column.448 /// Notes the beginning of a source code statement and marks the line and column.
444 /// Result type is always void.449 /// Result type is always void.
445 /// Uses the `dbg_stmt` field.450 /// Uses the `dbg_stmt` field.
...@@ -1116,11 +1121,20 @@ pub const Call = struct {...@@ -1116,11 +1121,20 @@ pub const Call = struct {
1116pub const CondBr = struct {1121pub const CondBr = struct {
1117 then_body_len: u32,1122 then_body_len: u32,
1118 else_body_len: u32,1123 else_body_len: u32,
1124 branch_hints: BranchHints,
1125 pub const BranchHints = packed struct(u32) {
1126 true: std.builtin.BranchHint,
1127 false: std.builtin.BranchHint,
1128 _: u26 = 0,
1129 };
1119};1130};
11201131
1121/// Trailing:1132/// Trailing:
1122/// * 0. `Case` for each `cases_len`1133/// * 0. `BranchHint` for each `cases_len + 1`. bit-packed into `u32`
1123/// * 1. the else body, according to `else_body_len`.1134/// elems such that each `u32` contains up to 10x `BranchHint`.
1135/// LSBs are first case. Final hint is `else`.
1136/// * 1. `Case` for each `cases_len`
1137/// * 2. the else body, according to `else_body_len`.
1124pub const SwitchBr = struct {1138pub const SwitchBr = struct {
1125 cases_len: u32,1139 cases_len: u32,
1126 else_body_len: u32,1140 else_body_len: u32,
...@@ -1380,6 +1394,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)...@@ -1380,6 +1394,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
1380 .ptr_add,1394 .ptr_add,
1381 .ptr_sub,1395 .ptr_sub,
1382 .try_ptr,1396 .try_ptr,
1397 .try_ptr_cold,
1383 => return datas[@intFromEnum(inst)].ty_pl.ty.toType(),1398 => return datas[@intFromEnum(inst)].ty_pl.ty.toType(),
13841399
1385 .not,1400 .not,
...@@ -1500,7 +1515,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)...@@ -1500,7 +1515,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
1500 return air.typeOf(extra.lhs, ip);1515 return air.typeOf(extra.lhs, ip);
1501 },1516 },
15021517
1503 .@"try" => {1518 .@"try", .try_cold => {
1504 const err_union_ty = air.typeOf(datas[@intFromEnum(inst)].pl_op.operand, ip);1519 const err_union_ty = air.typeOf(datas[@intFromEnum(inst)].pl_op.operand, ip);
1505 return Type.fromInterned(ip.indexToKey(err_union_ty.ip_index).error_union_type.payload_type);1520 return Type.fromInterned(ip.indexToKey(err_union_ty.ip_index).error_union_type.payload_type);
1506 },1521 },
...@@ -1524,9 +1539,8 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end...@@ -1524,9 +1539,8 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
1524 inline for (fields) |field| {1539 inline for (fields) |field| {
1525 @field(result, field.name) = switch (field.type) {1540 @field(result, field.name) = switch (field.type) {
1526 u32 => air.extra[i],1541 u32 => air.extra[i],
1527 Inst.Ref => @as(Inst.Ref, @enumFromInt(air.extra[i])),1542 InternPool.Index, Inst.Ref => @enumFromInt(air.extra[i]),
1528 i32 => @as(i32, @bitCast(air.extra[i])),1543 i32, CondBr.BranchHints => @bitCast(air.extra[i]),
1529 InternPool.Index => @as(InternPool.Index, @enumFromInt(air.extra[i])),
1530 else => @compileError("bad field type: " ++ @typeName(field.type)),1544 else => @compileError("bad field type: " ++ @typeName(field.type)),
1531 };1545 };
1532 i += 1;1546 i += 1;
...@@ -1593,7 +1607,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1593,7 +1607,9 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1593 .cond_br,1607 .cond_br,
1594 .switch_br,1608 .switch_br,
1595 .@"try",1609 .@"try",
1610 .try_cold,
1596 .try_ptr,1611 .try_ptr,
1612 .try_ptr_cold,
1597 .dbg_stmt,1613 .dbg_stmt,
1598 .dbg_inline_block,1614 .dbg_inline_block,
1599 .dbg_var_ptr,1615 .dbg_var_ptr,
...@@ -1796,4 +1812,91 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1796,4 +1812,91 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1796 };1812 };
1797}1813}
17981814
1815pub const UnwrappedSwitch = struct {
1816 air: *const Air,
1817 operand: Inst.Ref,
1818 cases_len: u32,
1819 else_body_len: u32,
1820 branch_hints_start: u32,
1821 cases_start: u32,
1822
1823 /// Asserts that `case_idx < us.cases_len`.
1824 pub fn getHint(us: UnwrappedSwitch, case_idx: u32) std.builtin.BranchHint {
1825 assert(case_idx < us.cases_len);
1826 return us.getHintInner(case_idx);
1827 }
1828 pub fn getElseHint(us: UnwrappedSwitch) std.builtin.BranchHint {
1829 return us.getHintInner(us.cases_len);
1830 }
1831 fn getHintInner(us: UnwrappedSwitch, idx: u32) std.builtin.BranchHint {
1832 const bag = us.air.extra[us.branch_hints_start..][idx / 10];
1833 const bits: u3 = @truncate(bag >> @intCast(3 * (idx % 10)));
1834 return @enumFromInt(bits);
1835 }
1836
1837 pub fn iterateCases(us: UnwrappedSwitch) CaseIterator {
1838 return .{
1839 .air = us.air,
1840 .cases_len = us.cases_len,
1841 .else_body_len = us.else_body_len,
1842 .next_case = 0,
1843 .extra_index = us.cases_start,
1844 };
1845 }
1846 pub const CaseIterator = struct {
1847 air: *const Air,
1848 cases_len: u32,
1849 else_body_len: u32,
1850 next_case: u32,
1851 extra_index: u32,
1852
1853 pub fn next(it: *CaseIterator) ?Case {
1854 if (it.next_case == it.cases_len) return null;
1855 const idx = it.next_case;
1856 it.next_case += 1;
1857
1858 const extra = it.air.extraData(SwitchBr.Case, it.extra_index);
1859 var extra_index = extra.end;
1860 const items: []const Inst.Ref = @ptrCast(it.air.extra[extra_index..][0..extra.data.items_len]);
1861 extra_index += items.len;
1862 const body: []const Inst.Index = @ptrCast(it.air.extra[extra_index..][0..extra.data.body_len]);
1863 extra_index += body.len;
1864 it.extra_index = @intCast(extra_index);
1865
1866 return .{
1867 .idx = idx,
1868 .items = items,
1869 .body = body,
1870 };
1871 }
1872 /// Only valid to call once all cases have been iterated, i.e. `next` returns `null`.
1873 /// Returns the body of the "default" (`else`) case.
1874 pub fn elseBody(it: *CaseIterator) []const Inst.Index {
1875 assert(it.next_case == it.cases_len);
1876 return @ptrCast(it.air.extra[it.extra_index..][0..it.else_body_len]);
1877 }
1878 pub const Case = struct {
1879 idx: u32,
1880 items: []const Inst.Ref,
1881 body: []const Inst.Index,
1882 };
1883 };
1884};
1885
1886pub fn unwrapSwitch(air: *const Air, switch_inst: Inst.Index) UnwrappedSwitch {
1887 const inst = air.instructions.get(@intFromEnum(switch_inst));
1888 assert(inst.tag == .switch_br);
1889 const pl_op = inst.data.pl_op;
1890 const extra = air.extraData(SwitchBr, pl_op.payload);
1891 const hint_bag_count = std.math.divCeil(usize, extra.data.cases_len + 1, 10) catch unreachable;
1892 return .{
1893 .air = air,
1894 .operand = pl_op.operand,
1895 .cases_len = extra.data.cases_len,
1896 .else_body_len = extra.data.else_body_len,
1897 .branch_hints_start = @intCast(extra.end),
1898 .cases_start = @intCast(extra.end + hint_bag_count),
1899 };
1900}
1901
1799pub const typesFullyResolved = @import("Air/types_resolved.zig").typesFullyResolved;1902pub const typesFullyResolved = @import("Air/types_resolved.zig").typesFullyResolved;
src/Air/types_resolved.zig+9-22
...@@ -344,7 +344,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {...@@ -344,7 +344,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
344 if (!checkRef(data.pl_op.operand, zcu)) return false;344 if (!checkRef(data.pl_op.operand, zcu)) return false;
345 },345 },
346346
347 .@"try" => {347 .@"try", .try_cold => {
348 const extra = air.extraData(Air.Try, data.pl_op.payload);348 const extra = air.extraData(Air.Try, data.pl_op.payload);
349 if (!checkRef(data.pl_op.operand, zcu)) return false;349 if (!checkRef(data.pl_op.operand, zcu)) return false;
350 if (!checkBody(350 if (!checkBody(
...@@ -354,7 +354,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {...@@ -354,7 +354,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
354 )) return false;354 )) return false;
355 },355 },
356356
357 .try_ptr => {357 .try_ptr, .try_ptr_cold => {
358 const extra = air.extraData(Air.TryPtr, data.ty_pl.payload);358 const extra = air.extraData(Air.TryPtr, data.ty_pl.payload);
359 if (!checkType(data.ty_pl.ty.toType(), zcu)) return false;359 if (!checkType(data.ty_pl.ty.toType(), zcu)) return false;
360 if (!checkRef(extra.data.ptr, zcu)) return false;360 if (!checkRef(extra.data.ptr, zcu)) return false;
...@@ -381,27 +381,14 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {...@@ -381,27 +381,14 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
381 },381 },
382382
383 .switch_br => {383 .switch_br => {
384 const extra = air.extraData(Air.SwitchBr, data.pl_op.payload);384 const switch_br = air.unwrapSwitch(inst);
385 if (!checkRef(data.pl_op.operand, zcu)) return false;385 if (!checkRef(switch_br.operand, zcu)) return false;
386 var extra_index = extra.end;386 var it = switch_br.iterateCases();
387 for (0..extra.data.cases_len) |_| {387 while (it.next()) |case| {
388 const case = air.extraData(Air.SwitchBr.Case, extra_index);388 for (case.items) |item| if (!checkRef(item, zcu)) return false;
389 extra_index = case.end;389 if (!checkBody(air, case.body, zcu)) return false;
390 const items: []const Air.Inst.Ref = @ptrCast(air.extra[extra_index..][0..case.data.items_len]);
391 extra_index += case.data.items_len;
392 for (items) |item| if (!checkRef(item, zcu)) return false;
393 if (!checkBody(
394 air,
395 @ptrCast(air.extra[extra_index..][0..case.data.body_len]),
396 zcu,
397 )) return false;
398 extra_index += case.data.body_len;
399 }390 }
400 if (!checkBody(391 if (!checkBody(air, it.elseBody(), zcu)) return false;
401 air,
402 @ptrCast(air.extra[extra_index..][0..extra.data.else_body_len]),
403 zcu,
404 )) return false;
405 },392 },
406393
407 .assembly => {394 .assembly => {
src/Compilation.zig+4-4
...@@ -5785,7 +5785,7 @@ fn failCObj(...@@ -5785,7 +5785,7 @@ fn failCObj(
5785 comptime format: []const u8,5785 comptime format: []const u8,
5786 args: anytype,5786 args: anytype,
5787) SemaError {5787) SemaError {
5788 @setCold(true);5788 @branchHint(.cold);
5789 const diag_bundle = blk: {5789 const diag_bundle = blk: {
5790 const diag_bundle = try comp.gpa.create(CObject.Diag.Bundle);5790 const diag_bundle = try comp.gpa.create(CObject.Diag.Bundle);
5791 diag_bundle.* = .{};5791 diag_bundle.* = .{};
...@@ -5809,7 +5809,7 @@ fn failCObjWithOwnedDiagBundle(...@@ -5809,7 +5809,7 @@ fn failCObjWithOwnedDiagBundle(
5809 c_object: *CObject,5809 c_object: *CObject,
5810 diag_bundle: *CObject.Diag.Bundle,5810 diag_bundle: *CObject.Diag.Bundle,
5811) SemaError {5811) SemaError {
5812 @setCold(true);5812 @branchHint(.cold);
5813 assert(diag_bundle.diags.len > 0);5813 assert(diag_bundle.diags.len > 0);
5814 {5814 {
5815 comp.mutex.lock();5815 comp.mutex.lock();
...@@ -5825,7 +5825,7 @@ fn failCObjWithOwnedDiagBundle(...@@ -5825,7 +5825,7 @@ fn failCObjWithOwnedDiagBundle(
5825}5825}
58265826
5827fn failWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, comptime format: []const u8, args: anytype) SemaError {5827fn failWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, comptime format: []const u8, args: anytype) SemaError {
5828 @setCold(true);5828 @branchHint(.cold);
5829 var bundle: ErrorBundle.Wip = undefined;5829 var bundle: ErrorBundle.Wip = undefined;
5830 try bundle.init(comp.gpa);5830 try bundle.init(comp.gpa);
5831 errdefer bundle.deinit();5831 errdefer bundle.deinit();
...@@ -5852,7 +5852,7 @@ fn failWin32ResourceWithOwnedBundle(...@@ -5852,7 +5852,7 @@ fn failWin32ResourceWithOwnedBundle(
5852 win32_resource: *Win32Resource,5852 win32_resource: *Win32Resource,
5853 err_bundle: ErrorBundle,5853 err_bundle: ErrorBundle,
5854) SemaError {5854) SemaError {
5855 @setCold(true);5855 @branchHint(.cold);
5856 {5856 {
5857 comp.mutex.lock();5857 comp.mutex.lock();
5858 defer comp.mutex.unlock();5858 defer comp.mutex.unlock();
src/InternPool.zig+17-18
...@@ -2121,6 +2121,17 @@ pub const Key = union(enum) {...@@ -2121,6 +2121,17 @@ pub const Key = union(enum) {
2121 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);2121 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
2122 }2122 }
21232123
2124 pub fn setBranchHint(func: Func, ip: *InternPool, hint: std.builtin.BranchHint) void {
2125 const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex;
2126 extra_mutex.lock();
2127 defer extra_mutex.unlock();
2128
2129 const analysis_ptr = func.analysisPtr(ip);
2130 var analysis = analysis_ptr.*;
2131 analysis.branch_hint = hint;
2132 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
2133 }
2134
2124 /// Returns a pointer that becomes invalid after any additions to the `InternPool`.2135 /// Returns a pointer that becomes invalid after any additions to the `InternPool`.
2125 fn zirBodyInstPtr(func: Func, ip: *InternPool) *TrackedInst.Index {2136 fn zirBodyInstPtr(func: Func, ip: *InternPool) *TrackedInst.Index {
2126 const extra = ip.getLocalShared(func.tid).extra.acquire();2137 const extra = ip.getLocalShared(func.tid).extra.acquire();
...@@ -5575,7 +5586,7 @@ pub const Tag = enum(u8) {...@@ -5575,7 +5586,7 @@ pub const Tag = enum(u8) {
5575/// to be part of the type of the function.5586/// to be part of the type of the function.
5576pub const FuncAnalysis = packed struct(u32) {5587pub const FuncAnalysis = packed struct(u32) {
5577 state: State,5588 state: State,
5578 is_cold: bool,5589 branch_hint: std.builtin.BranchHint,
5579 is_noinline: bool,5590 is_noinline: bool,
5580 calls_or_awaits_errorable_fn: bool,5591 calls_or_awaits_errorable_fn: bool,
5581 stack_alignment: Alignment,5592 stack_alignment: Alignment,
...@@ -5583,7 +5594,7 @@ pub const FuncAnalysis = packed struct(u32) {...@@ -5583,7 +5594,7 @@ pub const FuncAnalysis = packed struct(u32) {
5583 inferred_error_set: bool,5594 inferred_error_set: bool,
5584 disable_instrumentation: bool,5595 disable_instrumentation: bool,
55855596
5586 _: u19 = 0,5597 _: u17 = 0,
55875598
5588 pub const State = enum(u2) {5599 pub const State = enum(u2) {
5589 /// The runtime function has never been referenced.5600 /// The runtime function has never been referenced.
...@@ -8636,7 +8647,7 @@ pub fn getFuncDecl(...@@ -8636,7 +8647,7 @@ pub fn getFuncDecl(
8636 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{8647 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{
8637 .analysis = .{8648 .analysis = .{
8638 .state = .unreferenced,8649 .state = .unreferenced,
8639 .is_cold = false,8650 .branch_hint = .none,
8640 .is_noinline = key.is_noinline,8651 .is_noinline = key.is_noinline,
8641 .calls_or_awaits_errorable_fn = false,8652 .calls_or_awaits_errorable_fn = false,
8642 .stack_alignment = .none,8653 .stack_alignment = .none,
...@@ -8740,7 +8751,7 @@ pub fn getFuncDeclIes(...@@ -8740,7 +8751,7 @@ pub fn getFuncDeclIes(
8740 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{8751 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{
8741 .analysis = .{8752 .analysis = .{
8742 .state = .unreferenced,8753 .state = .unreferenced,
8743 .is_cold = false,8754 .branch_hint = .none,
8744 .is_noinline = key.is_noinline,8755 .is_noinline = key.is_noinline,
8745 .calls_or_awaits_errorable_fn = false,8756 .calls_or_awaits_errorable_fn = false,
8746 .stack_alignment = .none,8757 .stack_alignment = .none,
...@@ -8932,7 +8943,7 @@ pub fn getFuncInstance(...@@ -8932,7 +8943,7 @@ pub fn getFuncInstance(
8932 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{8943 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{
8933 .analysis = .{8944 .analysis = .{
8934 .state = .unreferenced,8945 .state = .unreferenced,
8935 .is_cold = false,8946 .branch_hint = .none,
8936 .is_noinline = arg.is_noinline,8947 .is_noinline = arg.is_noinline,
8937 .calls_or_awaits_errorable_fn = false,8948 .calls_or_awaits_errorable_fn = false,
8938 .stack_alignment = .none,8949 .stack_alignment = .none,
...@@ -9032,7 +9043,7 @@ pub fn getFuncInstanceIes(...@@ -9032,7 +9043,7 @@ pub fn getFuncInstanceIes(
9032 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{9043 const func_extra_index = addExtraAssumeCapacity(extra, Tag.FuncInstance{
9033 .analysis = .{9044 .analysis = .{
9034 .state = .unreferenced,9045 .state = .unreferenced,
9035 .is_cold = false,9046 .branch_hint = .none,
9036 .is_noinline = arg.is_noinline,9047 .is_noinline = arg.is_noinline,
9037 .calls_or_awaits_errorable_fn = false,9048 .calls_or_awaits_errorable_fn = false,
9038 .stack_alignment = .none,9049 .stack_alignment = .none,
...@@ -11853,18 +11864,6 @@ pub fn funcSetDisableInstrumentation(ip: *InternPool, func: Index) void {...@@ -11853,18 +11864,6 @@ pub fn funcSetDisableInstrumentation(ip: *InternPool, func: Index) void {
11853 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);11864 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
11854}11865}
1185511866
11856pub fn funcSetCold(ip: *InternPool, func: Index, is_cold: bool) void {
11857 const unwrapped_func = func.unwrap(ip);
11858 const extra_mutex = &ip.getLocal(unwrapped_func.tid).mutate.extra.mutex;
11859 extra_mutex.lock();
11860 defer extra_mutex.unlock();
11861
11862 const analysis_ptr = ip.funcAnalysisPtr(func);
11863 var analysis = analysis_ptr.*;
11864 analysis.is_cold = is_cold;
11865 @atomicStore(FuncAnalysis, analysis_ptr, analysis, .release);
11866}
11867
11868pub fn funcZirBodyInst(ip: *const InternPool, func: Index) TrackedInst.Index {11867pub fn funcZirBodyInst(ip: *const InternPool, func: Index) TrackedInst.Index {
11869 const unwrapped_func = func.unwrap(ip);11868 const unwrapped_func = func.unwrap(ip);
11870 const item = unwrapped_func.getItem(ip);11869 const item = unwrapped_func.getItem(ip);
src/Liveness.zig+15-21
...@@ -658,10 +658,10 @@ pub fn categorizeOperand(...@@ -658,10 +658,10 @@ pub fn categorizeOperand(
658658
659 return .complex;659 return .complex;
660 },660 },
661 .@"try" => {661 .@"try", .try_cold => {
662 return .complex;662 return .complex;
663 },663 },
664 .try_ptr => {664 .try_ptr, .try_ptr_cold => {
665 return .complex;665 return .complex;
666 },666 },
667 .loop => {667 .loop => {
...@@ -1254,8 +1254,8 @@ fn analyzeInst(...@@ -1254,8 +1254,8 @@ fn analyzeInst(
1254 },1254 },
1255 .loop => return analyzeInstLoop(a, pass, data, inst),1255 .loop => return analyzeInstLoop(a, pass, data, inst),
12561256
1257 .@"try" => return analyzeInstCondBr(a, pass, data, inst, .@"try"),1257 .@"try", .try_cold => return analyzeInstCondBr(a, pass, data, inst, .@"try"),
1258 .try_ptr => return analyzeInstCondBr(a, pass, data, inst, .try_ptr),1258 .try_ptr, .try_ptr_cold => return analyzeInstCondBr(a, pass, data, inst, .try_ptr),
1259 .cond_br => return analyzeInstCondBr(a, pass, data, inst, .cond_br),1259 .cond_br => return analyzeInstCondBr(a, pass, data, inst, .cond_br),
1260 .switch_br => return analyzeInstSwitchBr(a, pass, data, inst),1260 .switch_br => return analyzeInstSwitchBr(a, pass, data, inst),
12611261
...@@ -1674,21 +1674,18 @@ fn analyzeInstSwitchBr(...@@ -1674,21 +1674,18 @@ fn analyzeInstSwitchBr(
1674 const inst_datas = a.air.instructions.items(.data);1674 const inst_datas = a.air.instructions.items(.data);
1675 const pl_op = inst_datas[@intFromEnum(inst)].pl_op;1675 const pl_op = inst_datas[@intFromEnum(inst)].pl_op;
1676 const condition = pl_op.operand;1676 const condition = pl_op.operand;
1677 const switch_br = a.air.extraData(Air.SwitchBr, pl_op.payload);1677 const switch_br = a.air.unwrapSwitch(inst);
1678 const gpa = a.gpa;1678 const gpa = a.gpa;
1679 const ncases = switch_br.data.cases_len;1679 const ncases = switch_br.cases_len;
16801680
1681 switch (pass) {1681 switch (pass) {
1682 .loop_analysis => {1682 .loop_analysis => {
1683 var air_extra_index: usize = switch_br.end;1683 var it = switch_br.iterateCases();
1684 for (0..ncases) |_| {1684 while (it.next()) |case| {
1685 const case = a.air.extraData(Air.SwitchBr.Case, air_extra_index);1685 try analyzeBody(a, pass, data, case.body);
1686 const case_body: []const Air.Inst.Index = @ptrCast(a.air.extra[case.end + case.data.items_len ..][0..case.data.body_len]);
1687 air_extra_index = case.end + case.data.items_len + case_body.len;
1688 try analyzeBody(a, pass, data, case_body);
1689 }1686 }
1690 { // else1687 { // else
1691 const else_body: []const Air.Inst.Index = @ptrCast(a.air.extra[air_extra_index..][0..switch_br.data.else_body_len]);1688 const else_body = it.elseBody();
1692 try analyzeBody(a, pass, data, else_body);1689 try analyzeBody(a, pass, data, else_body);
1693 }1690 }
1694 },1691 },
...@@ -1706,16 +1703,13 @@ fn analyzeInstSwitchBr(...@@ -1706,16 +1703,13 @@ fn analyzeInstSwitchBr(
1706 @memset(case_live_sets, .{});1703 @memset(case_live_sets, .{});
1707 defer for (case_live_sets) |*live_set| live_set.deinit(gpa);1704 defer for (case_live_sets) |*live_set| live_set.deinit(gpa);
17081705
1709 var air_extra_index: usize = switch_br.end;1706 var case_it = switch_br.iterateCases();
1710 for (case_live_sets[0..ncases]) |*live_set| {1707 while (case_it.next()) |case| {
1711 const case = a.air.extraData(Air.SwitchBr.Case, air_extra_index);1708 try analyzeBody(a, pass, data, case.body);
1712 const case_body: []const Air.Inst.Index = @ptrCast(a.air.extra[case.end + case.data.items_len ..][0..case.data.body_len]);1709 case_live_sets[case.idx] = data.live_set.move();
1713 air_extra_index = case.end + case.data.items_len + case_body.len;
1714 try analyzeBody(a, pass, data, case_body);
1715 live_set.* = data.live_set.move();
1716 }1710 }
1717 { // else1711 { // else
1718 const else_body: []const Air.Inst.Index = @ptrCast(a.air.extra[air_extra_index..][0..switch_br.data.else_body_len]);1712 const else_body = case_it.elseBody();
1719 try analyzeBody(a, pass, data, else_body);1713 try analyzeBody(a, pass, data, else_body);
1720 case_live_sets[ncases] = data.live_set.move();1714 case_live_sets[ncases] = data.live_set.move();
1721 }1715 }
src/Liveness/Verify.zig+11-22
...@@ -374,7 +374,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -374,7 +374,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
374 },374 },
375375
376 // control flow376 // control flow
377 .@"try" => {377 .@"try", .try_cold => {
378 const pl_op = data[@intFromEnum(inst)].pl_op;378 const pl_op = data[@intFromEnum(inst)].pl_op;
379 const extra = self.air.extraData(Air.Try, pl_op.payload);379 const extra = self.air.extraData(Air.Try, pl_op.payload);
380 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);380 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
...@@ -396,7 +396,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -396,7 +396,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
396396
397 try self.verifyInst(inst);397 try self.verifyInst(inst);
398 },398 },
399 .try_ptr => {399 .try_ptr, .try_ptr_cold => {
400 const ty_pl = data[@intFromEnum(inst)].ty_pl;400 const ty_pl = data[@intFromEnum(inst)].ty_pl;
401 const extra = self.air.extraData(Air.TryPtr, ty_pl.payload);401 const extra = self.air.extraData(Air.TryPtr, ty_pl.payload);
402 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);402 const try_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
...@@ -509,44 +509,33 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -509,44 +509,33 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
509 try self.verifyInst(inst);509 try self.verifyInst(inst);
510 },510 },
511 .switch_br => {511 .switch_br => {
512 const pl_op = data[@intFromEnum(inst)].pl_op;512 const switch_br = self.air.unwrapSwitch(inst);
513 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
514 var extra_index = switch_br.end;
515 var case_i: u32 = 0;
516 const switch_br_liveness = try self.liveness.getSwitchBr(513 const switch_br_liveness = try self.liveness.getSwitchBr(
517 self.gpa,514 self.gpa,
518 inst,515 inst,
519 switch_br.data.cases_len + 1,516 switch_br.cases_len + 1,
520 );517 );
521 defer self.gpa.free(switch_br_liveness.deaths);518 defer self.gpa.free(switch_br_liveness.deaths);
522519
523 try self.verifyOperand(inst, pl_op.operand, self.liveness.operandDies(inst, 0));520 try self.verifyOperand(inst, switch_br.operand, self.liveness.operandDies(inst, 0));
524521
525 var live = self.live.move();522 var live = self.live.move();
526 defer live.deinit(self.gpa);523 defer live.deinit(self.gpa);
527524
528 while (case_i < switch_br.data.cases_len) : (case_i += 1) {525 var it = switch_br.iterateCases();
529 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);526 while (it.next()) |case| {
530 const items = @as(
531 []const Air.Inst.Ref,
532 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]),
533 );
534 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
535 extra_index = case.end + items.len + case_body.len;
536
537 self.live.deinit(self.gpa);527 self.live.deinit(self.gpa);
538 self.live = try live.clone(self.gpa);528 self.live = try live.clone(self.gpa);
539529
540 for (switch_br_liveness.deaths[case_i]) |death| try self.verifyDeath(inst, death);530 for (switch_br_liveness.deaths[case.idx]) |death| try self.verifyDeath(inst, death);
541 try self.verifyBody(case_body);531 try self.verifyBody(case.body);
542 }532 }
543533
544 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);534 const else_body = it.elseBody();
545 if (else_body.len > 0) {535 if (else_body.len > 0) {
546 self.live.deinit(self.gpa);536 self.live.deinit(self.gpa);
547 self.live = try live.clone(self.gpa);537 self.live = try live.clone(self.gpa);
548538 for (switch_br_liveness.deaths[switch_br.cases_len]) |death| try self.verifyDeath(inst, death);
549 for (switch_br_liveness.deaths[case_i]) |death| try self.verifyDeath(inst, death);
550 try self.verifyBody(else_body);539 try self.verifyBody(else_body);
551 }540 }
552541
src/Sema.zig+319-174
...@@ -118,6 +118,10 @@ dependencies: std.AutoArrayHashMapUnmanaged(InternPool.Dependee, void) = .{},...@@ -118,6 +118,10 @@ dependencies: std.AutoArrayHashMapUnmanaged(InternPool.Dependee, void) = .{},
118/// by `analyzeCall`.118/// by `analyzeCall`.
119allow_memoize: bool = true,119allow_memoize: bool = true,
120120
121/// The `BranchHint` for the current branch of runtime control flow.
122/// This state is on `Sema` so that `cold` hints can be propagated up through blocks with less special handling.
123branch_hint: ?std.builtin.BranchHint = null,
124
121const MaybeComptimeAlloc = struct {125const MaybeComptimeAlloc = struct {
122 /// The runtime index of the `alloc` instruction.126 /// The runtime index of the `alloc` instruction.
123 runtime_index: Value.RuntimeIndex,127 runtime_index: Value.RuntimeIndex,
...@@ -892,7 +896,12 @@ pub fn deinit(sema: *Sema) void {...@@ -892,7 +896,12 @@ pub fn deinit(sema: *Sema) void {
892/// Performs semantic analysis of a ZIR body which is behind a runtime condition. If comptime896/// Performs semantic analysis of a ZIR body which is behind a runtime condition. If comptime
893/// control flow happens here, Sema will convert it to runtime control flow by introducing post-hoc897/// control flow happens here, Sema will convert it to runtime control flow by introducing post-hoc
894/// blocks where necessary.898/// blocks where necessary.
895fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) !void {899/// Returns the branch hint for this branch.
900fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) !std.builtin.BranchHint {
901 const parent_hint = sema.branch_hint;
902 defer sema.branch_hint = parent_hint;
903 sema.branch_hint = null;
904
896 sema.analyzeBodyInner(block, body) catch |err| switch (err) {905 sema.analyzeBodyInner(block, body) catch |err| switch (err) {
897 error.ComptimeBreak => {906 error.ComptimeBreak => {
898 const zir_datas = sema.code.instructions.items(.data);907 const zir_datas = sema.code.instructions.items(.data);
...@@ -902,6 +911,8 @@ fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.In...@@ -902,6 +911,8 @@ fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.In
902 },911 },
903 else => |e| return e,912 else => |e| return e,
904 };913 };
914
915 return sema.branch_hint orelse .none;
905}916}
906917
907/// Semantically analyze a ZIR function body. It is guranteed by AstGen that such a body cannot918/// Semantically analyze a ZIR function body. It is guranteed by AstGen that such a body cannot
...@@ -1304,11 +1315,6 @@ fn analyzeBodyInner(...@@ -1304,11 +1315,6 @@ fn analyzeBodyInner(
1304 i += 1;1315 i += 1;
1305 continue;1316 continue;
1306 },1317 },
1307 .set_cold => {
1308 try sema.zirSetCold(block, extended);
1309 i += 1;
1310 continue;
1311 },
1312 .breakpoint => {1318 .breakpoint => {
1313 if (!block.is_comptime) {1319 if (!block.is_comptime) {
1314 _ = try block.addNoOp(.breakpoint);1320 _ = try block.addNoOp(.breakpoint);
...@@ -1326,6 +1332,11 @@ fn analyzeBodyInner(...@@ -1326,6 +1332,11 @@ fn analyzeBodyInner(
1326 i += 1;1332 i += 1;
1327 continue;1333 continue;
1328 },1334 },
1335 .branch_hint => {
1336 try sema.zirBranchHint(block, extended);
1337 i += 1;
1338 continue;
1339 },
1329 .value_placeholder => unreachable, // never appears in a body1340 .value_placeholder => unreachable, // never appears in a body
1330 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),1341 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),
1331 .builtin_value => try sema.zirBuiltinValue(extended),1342 .builtin_value => try sema.zirBuiltinValue(extended),
...@@ -1442,11 +1453,6 @@ fn analyzeBodyInner(...@@ -1442,11 +1453,6 @@ fn analyzeBodyInner(
1442 i += 1;1453 i += 1;
1443 continue;1454 continue;
1444 },1455 },
1445 .export_value => {
1446 try sema.zirExportValue(block, inst);
1447 i += 1;
1448 continue;
1449 },
1450 .set_runtime_safety => {1456 .set_runtime_safety => {
1451 try sema.zirSetRuntimeSafety(block, inst);1457 try sema.zirSetRuntimeSafety(block, inst);
1452 i += 1;1458 i += 1;
...@@ -2465,7 +2471,7 @@ fn addFieldErrNote(...@@ -2465,7 +2471,7 @@ fn addFieldErrNote(
2465 comptime format: []const u8,2471 comptime format: []const u8,
2466 args: anytype,2472 args: anytype,
2467) !void {2473) !void {
2468 @setCold(true);2474 @branchHint(.cold);
2469 const type_src = container_ty.srcLocOrNull(sema.pt.zcu) orelse return;2475 const type_src = container_ty.srcLocOrNull(sema.pt.zcu) orelse return;
2470 const field_src: LazySrcLoc = .{2476 const field_src: LazySrcLoc = .{
2471 .base_node_inst = type_src.base_node_inst,2477 .base_node_inst = type_src.base_node_inst,
...@@ -2501,7 +2507,7 @@ pub fn fail(...@@ -2501,7 +2507,7 @@ pub fn fail(
2501}2507}
25022508
2503pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg) error{ AnalysisFail, OutOfMemory } {2509pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg) error{ AnalysisFail, OutOfMemory } {
2504 @setCold(true);2510 @branchHint(.cold);
2505 const gpa = sema.gpa;2511 const gpa = sema.gpa;
2506 const zcu = sema.pt.zcu;2512 const zcu = sema.pt.zcu;
25072513
...@@ -5732,6 +5738,13 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -5732,6 +5738,13 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
5732 if (block.is_comptime) {5738 if (block.is_comptime) {
5733 return sema.fail(block, src, "encountered @panic at comptime", .{});5739 return sema.fail(block, src, "encountered @panic at comptime", .{});
5734 }5740 }
5741
5742 // We only apply the first hint in a branch.
5743 // This allows user-provided hints to override implicit cold hints.
5744 if (sema.branch_hint == null) {
5745 sema.branch_hint = .cold;
5746 }
5747
5735 try sema.panicWithMsg(block, src, coerced_msg, .@"@panic");5748 try sema.panicWithMsg(block, src, coerced_msg, .@"@panic");
5736}5749}
57375750
...@@ -6279,73 +6292,72 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -6279,73 +6292,72 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
6279 const ip = &zcu.intern_pool;6292 const ip = &zcu.intern_pool;
6280 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;6293 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6281 const extra = sema.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;6294 const extra = sema.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;
6282 const src = block.nodeOffset(inst_data.src_node);
6283 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
6284 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
6285 const decl_name = try ip.getOrPutString(
6286 zcu.gpa,
6287 pt.tid,
6288 sema.code.nullTerminatedString(extra.decl_name),
6289 .no_embedded_nulls,
6290 );
6291 const nav_index = if (extra.namespace != .none) index_blk: {
6292 const container_ty = try sema.resolveType(block, operand_src, extra.namespace);
6293 const container_namespace = container_ty.getNamespaceIndex(zcu);
6294
6295 const lookup = try sema.lookupInNamespace(block, operand_src, container_namespace, decl_name, false) orelse
6296 return sema.failWithBadMemberAccess(block, container_ty, operand_src, decl_name);
62976295
6298 break :index_blk lookup.nav;
6299 } else try sema.lookupIdentifier(block, operand_src, decl_name);
6300 const options = try sema.resolveExportOptions(block, options_src, extra.options);
6301
6302 try sema.ensureNavResolved(src, nav_index);
6303
6304 // Make sure to export the owner Nav if applicable.
6305 const exported_nav = switch (ip.indexToKey(ip.getNav(nav_index).status.resolved.val)) {
6306 .variable => |v| v.owner_nav,
6307 .@"extern" => |e| e.owner_nav,
6308 .func => |f| f.owner_nav,
6309 else => nav_index,
6310 };
6311 try sema.analyzeExport(block, src, options, exported_nav);
6312}
6313
6314fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
6315 const tracy = trace(@src());
6316 defer tracy.end();
6317
6318 const pt = sema.pt;
6319 const zcu = pt.zcu;
6320 const ip = &zcu.intern_pool;
6321 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6322 const extra = sema.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;
6323 const src = block.nodeOffset(inst_data.src_node);6296 const src = block.nodeOffset(inst_data.src_node);
6324 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);6297 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
6325 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);6298 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
6326 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, .{6299
6300 const ptr = try sema.resolveInst(extra.exported);
6301 const ptr_val = try sema.resolveConstDefinedValue(block, ptr_src, ptr, .{
6327 .needed_comptime_reason = "export target must be comptime-known",6302 .needed_comptime_reason = "export target must be comptime-known",
6328 });6303 });
6304 const ptr_ty = ptr_val.typeOf(zcu);
6305
6329 const options = try sema.resolveExportOptions(block, options_src, extra.options);6306 const options = try sema.resolveExportOptions(block, options_src, extra.options);
6330 if (options.linkage == .internal)
6331 return;
63326307
6333 // If the value has an owner Nav, export that instead.6308 {
6334 const maybe_owner_nav = switch (ip.indexToKey(operand.toIntern())) {6309 if (ptr_ty.zigTypeTag(zcu) != .Pointer) {
6335 .variable => |v| v.owner_nav,6310 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
6336 .@"extern" => |e| e.owner_nav,6311 }
6337 .func => |f| f.owner_nav,6312 const ptr_ty_info = ptr_ty.ptrInfo(zcu);
6338 else => null,6313 if (ptr_ty_info.flags.size == .Slice) {
6339 };6314 return sema.fail(block, ptr_src, "export target cannot be slice", .{});
6340 if (maybe_owner_nav) |owner_nav| {6315 }
6341 return sema.analyzeExport(block, src, options, owner_nav);6316 if (ptr_ty_info.packed_offset.host_size != 0) {
6342 } else {6317 return sema.fail(block, ptr_src, "export target cannot be bit-pointer", .{});
6343 try sema.exports.append(zcu.gpa, .{6318 }
6344 .opts = options,6319 }
6345 .src = src,6320
6346 .exported = .{ .uav = operand.toIntern() },6321 const ptr_info = ip.indexToKey(ptr_val.toIntern()).ptr;
6347 .status = .in_progress,6322 switch (ptr_info.base_addr) {
6348 });6323 .comptime_alloc, .int, .comptime_field => return sema.fail(block, ptr_src, "export target must be a global variable or a comptime-known constant", .{}),
6324 .eu_payload, .opt_payload, .field, .arr_elem => return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{}),
6325 .uav => |uav| {
6326 if (ptr_info.byte_offset != 0) {
6327 return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{});
6328 }
6329 if (options.linkage == .internal) return;
6330 const export_ty = Value.fromInterned(uav.val).typeOf(zcu);
6331 if (!try sema.validateExternType(export_ty, .other)) {
6332 return sema.failWithOwnedErrorMsg(block, msg: {
6333 const msg = try sema.errMsg(src, "unable to export type '{}'", .{export_ty.fmt(pt)});
6334 errdefer msg.destroy(sema.gpa);
6335 try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other);
6336 try sema.addDeclaredHereNote(msg, export_ty);
6337 break :msg msg;
6338 });
6339 }
6340 try sema.exports.append(zcu.gpa, .{
6341 .opts = options,
6342 .src = src,
6343 .exported = .{ .uav = uav.val },
6344 .status = .in_progress,
6345 });
6346 },
6347 .nav => |nav| {
6348 if (ptr_info.byte_offset != 0) {
6349 return sema.fail(block, ptr_src, "TODO: export pointer in middle of value", .{});
6350 }
6351 try sema.ensureNavResolved(src, nav);
6352 // Make sure to export the owner Nav if applicable.
6353 const exported_nav = switch (ip.indexToKey(ip.getNav(nav).status.resolved.val)) {
6354 .variable => |v| v.owner_nav,
6355 .@"extern" => |e| e.owner_nav,
6356 .func => |f| f.owner_nav,
6357 else => nav,
6358 };
6359 try sema.analyzeExport(block, src, options, exported_nav);
6360 },
6349 }6361 }
6350}6362}
63516363
...@@ -6424,25 +6436,6 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -6424,25 +6436,6 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
6424 sema.allow_memoize = false;6436 sema.allow_memoize = false;
6425}6437}
64266438
6427fn zirSetCold(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
6428 const pt = sema.pt;
6429 const zcu = pt.zcu;
6430 const ip = &zcu.intern_pool;
6431 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6432 const operand_src = block.builtinCallArgSrc(extra.node, 0);
6433 const is_cold = try sema.resolveConstBool(block, operand_src, extra.operand, .{
6434 .needed_comptime_reason = "operand to @setCold must be comptime-known",
6435 });
6436 // TODO: should `@setCold` apply to the parent in an inline call?
6437 // See also #20642 and friends.
6438 const func = switch (sema.owner.unwrap()) {
6439 .func => |func| func,
6440 .cau => return, // does nothing outside a function
6441 };
6442 ip.funcSetCold(func, is_cold);
6443 sema.allow_memoize = false;
6444}
6445
6446fn zirDisableInstrumentation(sema: *Sema) CompileError!void {6439fn zirDisableInstrumentation(sema: *Sema) CompileError!void {
6447 const pt = sema.pt;6440 const pt = sema.pt;
6448 const zcu = pt.zcu;6441 const zcu = pt.zcu;
...@@ -6897,13 +6890,20 @@ fn popErrorReturnTrace(...@@ -6897,13 +6890,20 @@ fn popErrorReturnTrace(
6897 @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block6890 @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block
68986891
6899 const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);6892 const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);
6900 try sema.air_instructions.append(gpa, .{ .tag = .cond_br, .data = .{ .pl_op = .{6893 try sema.air_instructions.append(gpa, .{
6901 .operand = is_non_error_inst,6894 .tag = .cond_br,
6902 .payload = sema.addExtraAssumeCapacity(Air.CondBr{6895 .data = .{
6903 .then_body_len = @intCast(then_block.instructions.items.len),6896 .pl_op = .{
6904 .else_body_len = @intCast(else_block.instructions.items.len),6897 .operand = is_non_error_inst,
6905 }),6898 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
6906 } } });6899 .then_body_len = @intCast(then_block.instructions.items.len),
6900 .else_body_len = @intCast(else_block.instructions.items.len),
6901 // weight against error branch
6902 .branch_hints = .{ .true = .likely, .false = .unlikely },
6903 }),
6904 },
6905 },
6906 });
6907 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));6907 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
6908 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));6908 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
69096909
...@@ -10960,6 +10960,11 @@ const SwitchProngAnalysis = struct {...@@ -10960,6 +10960,11 @@ const SwitchProngAnalysis = struct {
10960 sema.code.instructions.items(.data)[@intFromEnum(spa.switch_block_inst)].pl_node.src_node,10960 sema.code.instructions.items(.data)[@intFromEnum(spa.switch_block_inst)].pl_node.src_node,
10961 );10961 );
1096210962
10963 // We can propagate `.cold` hints from this branch since it's comptime-known
10964 // to be taken from the parent branch.
10965 const parent_hint = sema.branch_hint;
10966 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
10967
10963 if (has_tag_capture) {10968 if (has_tag_capture) {
10964 const tag_ref = try spa.analyzeTagCapture(child_block, capture_src, inline_case_capture);10969 const tag_ref = try spa.analyzeTagCapture(child_block, capture_src, inline_case_capture);
10965 sema.inst_map.putAssumeCapacity(spa.tag_capture_inst, tag_ref);10970 sema.inst_map.putAssumeCapacity(spa.tag_capture_inst, tag_ref);
...@@ -10996,6 +11001,7 @@ const SwitchProngAnalysis = struct {...@@ -10996,6 +11001,7 @@ const SwitchProngAnalysis = struct {
1099611001
10997 /// Analyze a switch prong which may have peers at runtime.11002 /// Analyze a switch prong which may have peers at runtime.
10998 /// Uses `analyzeBodyRuntimeBreak`. Sets up captures as needed.11003 /// Uses `analyzeBodyRuntimeBreak`. Sets up captures as needed.
11004 /// Returns the `BranchHint` for the prong.
10999 fn analyzeProngRuntime(11005 fn analyzeProngRuntime(
11000 spa: SwitchProngAnalysis,11006 spa: SwitchProngAnalysis,
11001 case_block: *Block,11007 case_block: *Block,
...@@ -11013,7 +11019,7 @@ const SwitchProngAnalysis = struct {...@@ -11013,7 +11019,7 @@ const SwitchProngAnalysis = struct {
11013 /// Whether this prong has an inline tag capture. If `true`, then11019 /// Whether this prong has an inline tag capture. If `true`, then
11014 /// `inline_case_capture` cannot be `.none`.11020 /// `inline_case_capture` cannot be `.none`.
11015 has_tag_capture: bool,11021 has_tag_capture: bool,
11016 ) CompileError!void {11022 ) CompileError!std.builtin.BranchHint {
11017 const sema = spa.sema;11023 const sema = spa.sema;
1101811024
11019 if (has_tag_capture) {11025 if (has_tag_capture) {
...@@ -11039,7 +11045,7 @@ const SwitchProngAnalysis = struct {...@@ -11039,7 +11045,7 @@ const SwitchProngAnalysis = struct {
1103911045
11040 if (sema.typeOf(capture_ref).isNoReturn(sema.pt.zcu)) {11046 if (sema.typeOf(capture_ref).isNoReturn(sema.pt.zcu)) {
11041 // No need to analyze any further, the prong is unreachable11047 // No need to analyze any further, the prong is unreachable
11042 return;11048 return .none;
11043 }11049 }
1104411050
11045 sema.inst_map.putAssumeCapacity(spa.switch_block_inst, capture_ref);11051 sema.inst_map.putAssumeCapacity(spa.switch_block_inst, capture_ref);
...@@ -11308,10 +11314,17 @@ const SwitchProngAnalysis = struct {...@@ -11308,10 +11314,17 @@ const SwitchProngAnalysis = struct {
1130811314
11309 const prong_count = field_indices.len - in_mem_coercible.count();11315 const prong_count = field_indices.len - in_mem_coercible.count();
1131011316
11311 const estimated_extra = prong_count * 6; // 2 for Case, 1 item, probably 3 insts11317 const estimated_extra = prong_count * 6 + (prong_count / 10); // 2 for Case, 1 item, probably 3 insts; plus hints
11312 var cases_extra = try std.ArrayList(u32).initCapacity(sema.gpa, estimated_extra);11318 var cases_extra = try std.ArrayList(u32).initCapacity(sema.gpa, estimated_extra);
11313 defer cases_extra.deinit();11319 defer cases_extra.deinit();
1131411320
11321 {
11322 // All branch hints are `.none`, so just add zero elems.
11323 comptime assert(@intFromEnum(std.builtin.BranchHint.none) == 0);
11324 const need_elems = std.math.divCeil(usize, prong_count + 1, 10) catch unreachable;
11325 try cases_extra.appendNTimes(0, need_elems);
11326 }
11327
11315 {11328 {
11316 // Non-bitcast cases11329 // Non-bitcast cases
11317 var it = in_mem_coercible.iterator(.{ .kind = .unset });11330 var it = in_mem_coercible.iterator(.{ .kind = .unset });
...@@ -11734,7 +11747,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -11734,7 +11747,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
11734 sub_block.need_debug_scope = null; // this body is emitted regardless11747 sub_block.need_debug_scope = null; // this body is emitted regardless
11735 defer sub_block.instructions.deinit(gpa);11748 defer sub_block.instructions.deinit(gpa);
1173611749
11737 try sema.analyzeBodyRuntimeBreak(&sub_block, non_error_case.body);11750 const non_error_hint = try sema.analyzeBodyRuntimeBreak(&sub_block, non_error_case.body);
11738 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);11751 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);
11739 defer gpa.free(true_instructions);11752 defer gpa.free(true_instructions);
1174011753
...@@ -11788,6 +11801,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -11788,6 +11801,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
11788 .payload = sema.addExtraAssumeCapacity(Air.CondBr{11801 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
11789 .then_body_len = @intCast(true_instructions.len),11802 .then_body_len = @intCast(true_instructions.len),
11790 .else_body_len = @intCast(sub_block.instructions.items.len),11803 .else_body_len = @intCast(sub_block.instructions.items.len),
11804 .branch_hints = .{ .true = non_error_hint, .false = .none },
11791 }),11805 }),
11792 } },11806 } },
11793 });11807 });
...@@ -12492,6 +12506,9 @@ fn analyzeSwitchRuntimeBlock(...@@ -12492,6 +12506,9 @@ fn analyzeSwitchRuntimeBlock(
12492 var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra);12506 var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra);
12493 defer cases_extra.deinit(gpa);12507 defer cases_extra.deinit(gpa);
1249412508
12509 var branch_hints = try std.ArrayListUnmanaged(std.builtin.BranchHint).initCapacity(gpa, scalar_cases_len);
12510 defer branch_hints.deinit(gpa);
12511
12495 var case_block = child_block.makeSubBlock();12512 var case_block = child_block.makeSubBlock();
12496 case_block.runtime_loop = null;12513 case_block.runtime_loop = null;
12497 case_block.runtime_cond = operand_src;12514 case_block.runtime_cond = operand_src;
...@@ -12522,10 +12539,13 @@ fn analyzeSwitchRuntimeBlock(...@@ -12522,10 +12539,13 @@ fn analyzeSwitchRuntimeBlock(
12522 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;12539 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;
12523 } else true;12540 } else true;
1252412541
12525 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {12542 const prong_hint: std.builtin.BranchHint = if (err_set and
12526 // nothing to do here12543 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12527 } else if (analyze_body) {12544 h: {
12528 try spa.analyzeProngRuntime(12545 // nothing to do here. weight against error branch
12546 break :h .unlikely;
12547 } else if (analyze_body) h: {
12548 break :h try spa.analyzeProngRuntime(
12529 &case_block,12549 &case_block,
12530 .normal,12550 .normal,
12531 body,12551 body,
...@@ -12538,10 +12558,12 @@ fn analyzeSwitchRuntimeBlock(...@@ -12538,10 +12558,12 @@ fn analyzeSwitchRuntimeBlock(
12538 if (info.is_inline) item else .none,12558 if (info.is_inline) item else .none,
12539 info.has_tag_capture,12559 info.has_tag_capture,
12540 );12560 );
12541 } else {12561 } else h: {
12542 _ = try case_block.addNoOp(.unreach);12562 _ = try case_block.addNoOp(.unreach);
12543 }12563 break :h .none;
12564 };
1254412565
12566 try branch_hints.append(gpa, prong_hint);
12545 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12567 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12546 cases_extra.appendAssumeCapacity(1); // items_len12568 cases_extra.appendAssumeCapacity(1); // items_len
12547 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));12569 cases_extra.appendAssumeCapacity(@intCast(case_block.instructions.items.len));
...@@ -12551,6 +12573,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12551,6 +12573,7 @@ fn analyzeSwitchRuntimeBlock(
1255112573
12552 var is_first = true;12574 var is_first = true;
12553 var prev_cond_br: Air.Inst.Index = undefined;12575 var prev_cond_br: Air.Inst.Index = undefined;
12576 var prev_hint: std.builtin.BranchHint = undefined;
12554 var first_else_body: []const Air.Inst.Index = &.{};12577 var first_else_body: []const Air.Inst.Index = &.{};
12555 defer gpa.free(first_else_body);12578 defer gpa.free(first_else_body);
12556 var prev_then_body: []const Air.Inst.Index = &.{};12579 var prev_then_body: []const Air.Inst.Index = &.{};
...@@ -12612,7 +12635,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12612,7 +12635,7 @@ fn analyzeSwitchRuntimeBlock(
12612 } }));12635 } }));
12613 emit_bb = true;12636 emit_bb = true;
1261412637
12615 try spa.analyzeProngRuntime(12638 const prong_hint = try spa.analyzeProngRuntime(
12616 &case_block,12639 &case_block,
12617 .normal,12640 .normal,
12618 body,12641 body,
...@@ -12625,6 +12648,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12625,6 +12648,7 @@ fn analyzeSwitchRuntimeBlock(
12625 item_ref,12648 item_ref,
12626 info.has_tag_capture,12649 info.has_tag_capture,
12627 );12650 );
12651 try branch_hints.append(gpa, prong_hint);
1262812652
12629 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12653 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12630 cases_extra.appendAssumeCapacity(1); // items_len12654 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -12655,8 +12679,8 @@ fn analyzeSwitchRuntimeBlock(...@@ -12655,8 +12679,8 @@ fn analyzeSwitchRuntimeBlock(
12655 } }));12679 } }));
12656 emit_bb = true;12680 emit_bb = true;
1265712681
12658 if (analyze_body) {12682 const prong_hint: std.builtin.BranchHint = if (analyze_body) h: {
12659 try spa.analyzeProngRuntime(12683 break :h try spa.analyzeProngRuntime(
12660 &case_block,12684 &case_block,
12661 .normal,12685 .normal,
12662 body,12686 body,
...@@ -12669,9 +12693,11 @@ fn analyzeSwitchRuntimeBlock(...@@ -12669,9 +12693,11 @@ fn analyzeSwitchRuntimeBlock(
12669 item,12693 item,
12670 info.has_tag_capture,12694 info.has_tag_capture,
12671 );12695 );
12672 } else {12696 } else h: {
12673 _ = try case_block.addNoOp(.unreach);12697 _ = try case_block.addNoOp(.unreach);
12674 }12698 break :h .none;
12699 };
12700 try branch_hints.append(gpa, prong_hint);
1267512701
12676 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12702 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12677 cases_extra.appendAssumeCapacity(1); // items_len12703 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -12703,10 +12729,13 @@ fn analyzeSwitchRuntimeBlock(...@@ -12703,10 +12729,13 @@ fn analyzeSwitchRuntimeBlock(
1270312729
12704 const body = sema.code.bodySlice(extra_index, info.body_len);12730 const body = sema.code.bodySlice(extra_index, info.body_len);
12705 extra_index += info.body_len;12731 extra_index += info.body_len;
12706 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {12732 const prong_hint: std.builtin.BranchHint = if (err_set and
12707 // nothing to do here12733 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12708 } else if (analyze_body) {12734 h: {
12709 try spa.analyzeProngRuntime(12735 // nothing to do here. weight against error branch
12736 break :h .unlikely;
12737 } else if (analyze_body) h: {
12738 break :h try spa.analyzeProngRuntime(
12710 &case_block,12739 &case_block,
12711 .normal,12740 .normal,
12712 body,12741 body,
...@@ -12719,10 +12748,12 @@ fn analyzeSwitchRuntimeBlock(...@@ -12719,10 +12748,12 @@ fn analyzeSwitchRuntimeBlock(
12719 .none,12748 .none,
12720 false,12749 false,
12721 );12750 );
12722 } else {12751 } else h: {
12723 _ = try case_block.addNoOp(.unreach);12752 _ = try case_block.addNoOp(.unreach);
12724 }12753 break :h .none;
12754 };
1272512755
12756 try branch_hints.append(gpa, prong_hint);
12726 try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len +12757 try cases_extra.ensureUnusedCapacity(gpa, 2 + items.len +
12727 case_block.instructions.items.len);12758 case_block.instructions.items.len);
1272812759
...@@ -12790,23 +12821,24 @@ fn analyzeSwitchRuntimeBlock(...@@ -12790,23 +12821,24 @@ fn analyzeSwitchRuntimeBlock(
1279012821
12791 const body = sema.code.bodySlice(extra_index, info.body_len);12822 const body = sema.code.bodySlice(extra_index, info.body_len);
12792 extra_index += info.body_len;12823 extra_index += info.body_len;
12793 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap)) {12824 const prong_hint: std.builtin.BranchHint = if (err_set and
12794 // nothing to do here12825 try sema.maybeErrorUnwrap(&case_block, body, operand, operand_src, allow_err_code_unwrap))
12795 } else {12826 h: {
12796 try spa.analyzeProngRuntime(12827 // nothing to do here. weight against error branch
12797 &case_block,12828 break :h .unlikely;
12798 .normal,12829 } else try spa.analyzeProngRuntime(
12799 body,12830 &case_block,
12800 info.capture,12831 .normal,
12801 child_block.src(.{ .switch_capture = .{12832 body,
12802 .switch_node_offset = switch_node_offset,12833 info.capture,
12803 .case_idx = .{ .kind = .multi, .index = @intCast(multi_i) },12834 child_block.src(.{ .switch_capture = .{
12804 } }),12835 .switch_node_offset = switch_node_offset,
12805 items,12836 .case_idx = .{ .kind = .multi, .index = @intCast(multi_i) },
12806 .none,12837 } }),
12807 false,12838 items,
12808 );12839 .none,
12809 }12840 false,
12841 );
1281012842
12811 if (is_first) {12843 if (is_first) {
12812 is_first = false;12844 is_first = false;
...@@ -12818,10 +12850,10 @@ fn analyzeSwitchRuntimeBlock(...@@ -12818,10 +12850,10 @@ fn analyzeSwitchRuntimeBlock(
12818 @typeInfo(Air.CondBr).Struct.fields.len + prev_then_body.len + cond_body.len,12850 @typeInfo(Air.CondBr).Struct.fields.len + prev_then_body.len + cond_body.len,
12819 );12851 );
1282012852
12821 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload =12853 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
12822 sema.addExtraAssumeCapacity(Air.CondBr{
12823 .then_body_len = @intCast(prev_then_body.len),12854 .then_body_len = @intCast(prev_then_body.len),
12824 .else_body_len = @intCast(cond_body.len),12855 .else_body_len = @intCast(cond_body.len),
12856 .branch_hints = .{ .true = prev_hint, .false = .none },
12825 });12857 });
12826 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));12858 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));
12827 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cond_body));12859 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cond_body));
...@@ -12829,6 +12861,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12829,6 +12861,7 @@ fn analyzeSwitchRuntimeBlock(
12829 gpa.free(prev_then_body);12861 gpa.free(prev_then_body);
12830 prev_then_body = try case_block.instructions.toOwnedSlice(gpa);12862 prev_then_body = try case_block.instructions.toOwnedSlice(gpa);
12831 prev_cond_br = new_cond_br;12863 prev_cond_br = new_cond_br;
12864 prev_hint = prong_hint;
12832 }12865 }
12833 }12866 }
1283412867
...@@ -12860,8 +12893,8 @@ fn analyzeSwitchRuntimeBlock(...@@ -12860,8 +12893,8 @@ fn analyzeSwitchRuntimeBlock(
12860 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);12893 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
12861 emit_bb = true;12894 emit_bb = true;
1286212895
12863 if (analyze_body) {12896 const prong_hint: std.builtin.BranchHint = if (analyze_body) h: {
12864 try spa.analyzeProngRuntime(12897 break :h try spa.analyzeProngRuntime(
12865 &case_block,12898 &case_block,
12866 .special,12899 .special,
12867 special.body,12900 special.body,
...@@ -12874,9 +12907,11 @@ fn analyzeSwitchRuntimeBlock(...@@ -12874,9 +12907,11 @@ fn analyzeSwitchRuntimeBlock(
12874 item_ref,12907 item_ref,
12875 special.has_tag_capture,12908 special.has_tag_capture,
12876 );12909 );
12877 } else {12910 } else h: {
12878 _ = try case_block.addNoOp(.unreach);12911 _ = try case_block.addNoOp(.unreach);
12879 }12912 break :h .none;
12913 };
12914 try branch_hints.append(gpa, prong_hint);
1288012915
12881 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12916 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12882 cases_extra.appendAssumeCapacity(1); // items_len12917 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -12909,7 +12944,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12909,7 +12944,7 @@ fn analyzeSwitchRuntimeBlock(
12909 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);12944 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
12910 emit_bb = true;12945 emit_bb = true;
1291112946
12912 try spa.analyzeProngRuntime(12947 const prong_hint = try spa.analyzeProngRuntime(
12913 &case_block,12948 &case_block,
12914 .special,12949 .special,
12915 special.body,12950 special.body,
...@@ -12922,6 +12957,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12922,6 +12957,7 @@ fn analyzeSwitchRuntimeBlock(
12922 item_ref,12957 item_ref,
12923 special.has_tag_capture,12958 special.has_tag_capture,
12924 );12959 );
12960 try branch_hints.append(gpa, prong_hint);
1292512961
12926 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12962 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12927 cases_extra.appendAssumeCapacity(1); // items_len12963 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -12943,7 +12979,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12943,7 +12979,7 @@ fn analyzeSwitchRuntimeBlock(
12943 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);12979 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
12944 emit_bb = true;12980 emit_bb = true;
1294512981
12946 try spa.analyzeProngRuntime(12982 const prong_hint = try spa.analyzeProngRuntime(
12947 &case_block,12983 &case_block,
12948 .special,12984 .special,
12949 special.body,12985 special.body,
...@@ -12956,6 +12992,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12956,6 +12992,7 @@ fn analyzeSwitchRuntimeBlock(
12956 item_ref,12992 item_ref,
12957 special.has_tag_capture,12993 special.has_tag_capture,
12958 );12994 );
12995 try branch_hints.append(gpa, prong_hint);
1295912996
12960 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);12997 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12961 cases_extra.appendAssumeCapacity(1); // items_len12998 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -12974,7 +13011,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12974,7 +13011,7 @@ fn analyzeSwitchRuntimeBlock(
12974 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);13011 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
12975 emit_bb = true;13012 emit_bb = true;
1297613013
12977 try spa.analyzeProngRuntime(13014 const prong_hint = try spa.analyzeProngRuntime(
12978 &case_block,13015 &case_block,
12979 .special,13016 .special,
12980 special.body,13017 special.body,
...@@ -12987,6 +13024,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12987,6 +13024,7 @@ fn analyzeSwitchRuntimeBlock(
12987 .bool_true,13024 .bool_true,
12988 special.has_tag_capture,13025 special.has_tag_capture,
12989 );13026 );
13027 try branch_hints.append(gpa, prong_hint);
1299013028
12991 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);13029 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
12992 cases_extra.appendAssumeCapacity(1); // items_len13030 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -13003,7 +13041,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13003,7 +13041,7 @@ fn analyzeSwitchRuntimeBlock(
13003 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);13041 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
13004 emit_bb = true;13042 emit_bb = true;
1300513043
13006 try spa.analyzeProngRuntime(13044 const prong_hint = try spa.analyzeProngRuntime(
13007 &case_block,13045 &case_block,
13008 .special,13046 .special,
13009 special.body,13047 special.body,
...@@ -13016,6 +13054,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13016,6 +13054,7 @@ fn analyzeSwitchRuntimeBlock(
13016 .bool_false,13054 .bool_false,
13017 special.has_tag_capture,13055 special.has_tag_capture,
13018 );13056 );
13057 try branch_hints.append(gpa, prong_hint);
1301913058
13020 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);13059 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
13021 cases_extra.appendAssumeCapacity(1); // items_len13060 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -13051,12 +13090,13 @@ fn analyzeSwitchRuntimeBlock(...@@ -13051,12 +13090,13 @@ fn analyzeSwitchRuntimeBlock(
13051 } else false13090 } else false
13052 else13091 else
13053 true;13092 true;
13054 if (special.body.len != 0 and err_set and13093 const else_hint: std.builtin.BranchHint = if (special.body.len != 0 and err_set and
13055 try sema.maybeErrorUnwrap(&case_block, special.body, operand, operand_src, allow_err_code_unwrap))13094 try sema.maybeErrorUnwrap(&case_block, special.body, operand, operand_src, allow_err_code_unwrap))
13056 {13095 h: {
13057 // nothing to do here13096 // nothing to do here. weight against error branch
13058 } else if (special.body.len != 0 and analyze_body and !special.is_inline) {13097 break :h .unlikely;
13059 try spa.analyzeProngRuntime(13098 } else if (special.body.len != 0 and analyze_body and !special.is_inline) h: {
13099 break :h try spa.analyzeProngRuntime(
13060 &case_block,13100 &case_block,
13061 .special,13101 .special,
13062 special.body,13102 special.body,
...@@ -13069,7 +13109,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13069,7 +13109,7 @@ fn analyzeSwitchRuntimeBlock(
13069 .none,13109 .none,
13070 false,13110 false,
13071 );13111 );
13072 } else {13112 } else h: {
13073 // We still need a terminator in this block, but we have proven13113 // We still need a terminator in this block, but we have proven
13074 // that it is unreachable.13114 // that it is unreachable.
13075 if (case_block.wantSafety()) {13115 if (case_block.wantSafety()) {
...@@ -13078,33 +13118,57 @@ fn analyzeSwitchRuntimeBlock(...@@ -13078,33 +13118,57 @@ fn analyzeSwitchRuntimeBlock(
13078 } else {13118 } else {
13079 _ = try case_block.addNoOp(.unreach);13119 _ = try case_block.addNoOp(.unreach);
13080 }13120 }
13081 }13121 // Safety check / unreachable branches are cold.
13122 break :h .cold;
13123 };
1308213124
13083 if (is_first) {13125 if (is_first) {
13126 try branch_hints.append(gpa, else_hint);
13084 final_else_body = case_block.instructions.items;13127 final_else_body = case_block.instructions.items;
13085 } else {13128 } else {
13129 try branch_hints.append(gpa, .none); // we have the range conditionals first
13086 try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len +13130 try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len +
13087 @typeInfo(Air.CondBr).Struct.fields.len + case_block.instructions.items.len);13131 @typeInfo(Air.CondBr).Struct.fields.len + case_block.instructions.items.len);
1308813132
13089 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload =13133 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
13090 sema.addExtraAssumeCapacity(Air.CondBr{
13091 .then_body_len = @intCast(prev_then_body.len),13134 .then_body_len = @intCast(prev_then_body.len),
13092 .else_body_len = @intCast(case_block.instructions.items.len),13135 .else_body_len = @intCast(case_block.instructions.items.len),
13136 .branch_hints = .{ .true = prev_hint, .false = else_hint },
13093 });13137 });
13094 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));13138 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(prev_then_body));
13095 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));13139 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));
13096 final_else_body = first_else_body;13140 final_else_body = first_else_body;
13097 }13141 }
13142 } else {
13143 try branch_hints.append(gpa, .none);
13098 }13144 }
1309913145
13146 assert(branch_hints.items.len == cases_len + 1);
13147
13100 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).Struct.fields.len +13148 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).Struct.fields.len +
13101 cases_extra.items.len + final_else_body.len);13149 cases_extra.items.len + final_else_body.len +
13150 (std.math.divCeil(usize, branch_hints.items.len, 10) catch unreachable)); // branch hints
1310213151
13103 const payload_index = sema.addExtraAssumeCapacity(Air.SwitchBr{13152 const payload_index = sema.addExtraAssumeCapacity(Air.SwitchBr{
13104 .cases_len = @intCast(cases_len),13153 .cases_len = @intCast(cases_len),
13105 .else_body_len = @intCast(final_else_body.len),13154 .else_body_len = @intCast(final_else_body.len),
13106 });13155 });
1310713156
13157 {
13158 // Add branch hints.
13159 var cur_bag: u32 = 0;
13160 for (branch_hints.items, 0..) |hint, idx| {
13161 const idx_in_bag = idx % 10;
13162 cur_bag |= @as(u32, @intFromEnum(hint)) << @intCast(idx_in_bag * 3);
13163 if (idx_in_bag == 9) {
13164 sema.air_extra.appendAssumeCapacity(cur_bag);
13165 cur_bag = 0;
13166 }
13167 }
13168 if (branch_hints.items.len % 10 != 0) {
13169 sema.air_extra.appendAssumeCapacity(cur_bag);
13170 }
13171 }
13108 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items));13172 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(cases_extra.items));
13109 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(final_else_body));13173 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(final_else_body));
1311013174
...@@ -19165,6 +19229,10 @@ fn zirBoolBr(...@@ -19165,6 +19229,10 @@ fn zirBoolBr(
19165 const lhs_result: Air.Inst.Ref = if (is_bool_or) .bool_true else .bool_false;19229 const lhs_result: Air.Inst.Ref = if (is_bool_or) .bool_true else .bool_false;
19166 _ = try lhs_block.addBr(block_inst, lhs_result);19230 _ = try lhs_block.addBr(block_inst, lhs_result);
1916719231
19232 const parent_hint = sema.branch_hint;
19233 defer sema.branch_hint = parent_hint;
19234 sema.branch_hint = null;
19235
19168 const rhs_result = try sema.resolveInlineBody(rhs_block, body, inst);19236 const rhs_result = try sema.resolveInlineBody(rhs_block, body, inst);
19169 const rhs_noret = sema.typeOf(rhs_result).isNoReturn(zcu);19237 const rhs_noret = sema.typeOf(rhs_result).isNoReturn(zcu);
19170 const coerced_rhs_result = if (!rhs_noret) rhs: {19238 const coerced_rhs_result = if (!rhs_noret) rhs: {
...@@ -19173,7 +19241,17 @@ fn zirBoolBr(...@@ -19173,7 +19241,17 @@ fn zirBoolBr(
19173 break :rhs coerced_result;19241 break :rhs coerced_result;
19174 } else rhs_result;19242 } else rhs_result;
1917519243
19176 const result = sema.finishCondBr(parent_block, &child_block, &then_block, &else_block, lhs, block_inst);19244 const rhs_hint = sema.branch_hint orelse .none;
19245
19246 const result = try sema.finishCondBr(
19247 parent_block,
19248 &child_block,
19249 &then_block,
19250 &else_block,
19251 lhs,
19252 block_inst,
19253 if (is_bool_or) .{ .true = .none, .false = rhs_hint } else .{ .true = rhs_hint, .false = .none },
19254 );
19177 if (!rhs_noret) {19255 if (!rhs_noret) {
19178 if (try sema.resolveDefinedValue(rhs_block, rhs_src, coerced_rhs_result)) |rhs_val| {19256 if (try sema.resolveDefinedValue(rhs_block, rhs_src, coerced_rhs_result)) |rhs_val| {
19179 if (is_bool_or and rhs_val.toBool()) {19257 if (is_bool_or and rhs_val.toBool()) {
...@@ -19195,6 +19273,7 @@ fn finishCondBr(...@@ -19195,6 +19273,7 @@ fn finishCondBr(
19195 else_block: *Block,19273 else_block: *Block,
19196 cond: Air.Inst.Ref,19274 cond: Air.Inst.Ref,
19197 block_inst: Air.Inst.Index,19275 block_inst: Air.Inst.Index,
19276 branch_hints: Air.CondBr.BranchHints,
19198) !Air.Inst.Ref {19277) !Air.Inst.Ref {
19199 const gpa = sema.gpa;19278 const gpa = sema.gpa;
1920019279
...@@ -19205,6 +19284,7 @@ fn finishCondBr(...@@ -19205,6 +19284,7 @@ fn finishCondBr(
19205 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{19284 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
19206 .then_body_len = @intCast(then_block.instructions.items.len),19285 .then_body_len = @intCast(then_block.instructions.items.len),
19207 .else_body_len = @intCast(else_block.instructions.items.len),19286 .else_body_len = @intCast(else_block.instructions.items.len),
19287 .branch_hints = branch_hints,
19208 });19288 });
19209 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));19289 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
19210 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));19290 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
...@@ -19339,6 +19419,11 @@ fn zirCondbr(...@@ -19339,6 +19419,11 @@ fn zirCondbr(
19339 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {19419 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {
19340 const body = if (cond_val.toBool()) then_body else else_body;19420 const body = if (cond_val.toBool()) then_body else else_body;
1934119421
19422 // We can propagate `.cold` hints from this branch since it's comptime-known
19423 // to be taken from the parent branch.
19424 const parent_hint = sema.branch_hint;
19425 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19426
19342 try sema.maybeErrorUnwrapCondbr(parent_block, body, extra.data.condition, cond_src);19427 try sema.maybeErrorUnwrapCondbr(parent_block, body, extra.data.condition, cond_src);
19343 // We use `analyzeBodyInner` since we want to propagate any comptime control flow to the caller.19428 // We use `analyzeBodyInner` since we want to propagate any comptime control flow to the caller.
19344 return sema.analyzeBodyInner(parent_block, body);19429 return sema.analyzeBodyInner(parent_block, body);
...@@ -19355,7 +19440,7 @@ fn zirCondbr(...@@ -19355,7 +19440,7 @@ fn zirCondbr(
19355 sub_block.need_debug_scope = null; // this body is emitted regardless19440 sub_block.need_debug_scope = null; // this body is emitted regardless
19356 defer sub_block.instructions.deinit(gpa);19441 defer sub_block.instructions.deinit(gpa);
1935719442
19358 try sema.analyzeBodyRuntimeBreak(&sub_block, then_body);19443 const true_hint = try sema.analyzeBodyRuntimeBreak(&sub_block, then_body);
19359 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);19444 const true_instructions = try sub_block.instructions.toOwnedSlice(gpa);
19360 defer gpa.free(true_instructions);19445 defer gpa.free(true_instructions);
1936119446
...@@ -19371,11 +19456,13 @@ fn zirCondbr(...@@ -19371,11 +19456,13 @@ fn zirCondbr(
19371 break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand);19456 break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand);
19372 };19457 };
1937319458
19374 if (err_cond != null and try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?, cond_src, false)) {19459 const false_hint: std.builtin.BranchHint = if (err_cond != null and
19375 // nothing to do19460 try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?, cond_src, false))
19376 } else {19461 h: {
19377 try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);19462 // nothing to do here. weight against error branch
19378 }19463 break :h .unlikely;
19464 } else try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);
19465
19379 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +19466 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +
19380 true_instructions.len + sub_block.instructions.items.len);19467 true_instructions.len + sub_block.instructions.items.len);
19381 _ = try parent_block.addInst(.{19468 _ = try parent_block.addInst(.{
...@@ -19385,6 +19472,7 @@ fn zirCondbr(...@@ -19385,6 +19472,7 @@ fn zirCondbr(
19385 .payload = sema.addExtraAssumeCapacity(Air.CondBr{19472 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
19386 .then_body_len = @intCast(true_instructions.len),19473 .then_body_len = @intCast(true_instructions.len),
19387 .else_body_len = @intCast(sub_block.instructions.items.len),19474 .else_body_len = @intCast(sub_block.instructions.items.len),
19475 .branch_hints = .{ .true = true_hint, .false = false_hint },
19388 }),19476 }),
19389 } },19477 } },
19390 });19478 });
...@@ -19409,6 +19497,11 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -19409,6 +19497,11 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
19409 }19497 }
19410 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);19498 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);
19411 if (is_non_err != .none) {19499 if (is_non_err != .none) {
19500 // We can propagate `.cold` hints from this branch since it's comptime-known
19501 // to be taken from the parent branch.
19502 const parent_hint = sema.branch_hint;
19503 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19504
19412 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;19505 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;
19413 if (is_non_err_val.toBool()) {19506 if (is_non_err_val.toBool()) {
19414 return sema.analyzeErrUnionPayload(parent_block, src, err_union_ty, err_union, operand_src, false);19507 return sema.analyzeErrUnionPayload(parent_block, src, err_union_ty, err_union, operand_src, false);
...@@ -19422,13 +19515,19 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -19422,13 +19515,19 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
19422 var sub_block = parent_block.makeSubBlock();19515 var sub_block = parent_block.makeSubBlock();
19423 defer sub_block.instructions.deinit(sema.gpa);19516 defer sub_block.instructions.deinit(sema.gpa);
1942419517
19518 const parent_hint = sema.branch_hint;
19519 defer sema.branch_hint = parent_hint;
19520
19425 // This body is guaranteed to end with noreturn and has no breaks.19521 // This body is guaranteed to end with noreturn and has no breaks.
19426 try sema.analyzeBodyInner(&sub_block, body);19522 try sema.analyzeBodyInner(&sub_block, body);
1942719523
19524 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.
19525 const is_cold = sema.branch_hint == .cold;
19526
19428 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).Struct.fields.len +19527 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).Struct.fields.len +
19429 sub_block.instructions.items.len);19528 sub_block.instructions.items.len);
19430 const try_inst = try parent_block.addInst(.{19529 const try_inst = try parent_block.addInst(.{
19431 .tag = .@"try",19530 .tag = if (is_cold) .try_cold else .@"try",
19432 .data = .{ .pl_op = .{19531 .data = .{ .pl_op = .{
19433 .operand = err_union,19532 .operand = err_union,
19434 .payload = sema.addExtraAssumeCapacity(Air.Try{19533 .payload = sema.addExtraAssumeCapacity(Air.Try{
...@@ -19458,6 +19557,11 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -19458,6 +19557,11 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
19458 }19557 }
19459 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);19558 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(parent_block, operand_src, err_union);
19460 if (is_non_err != .none) {19559 if (is_non_err != .none) {
19560 // We can propagate `.cold` hints from this branch since it's comptime-known
19561 // to be taken from the parent branch.
19562 const parent_hint = sema.branch_hint;
19563 defer sema.branch_hint = parent_hint orelse if (sema.branch_hint == .cold) .cold else null;
19564
19461 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;19565 const is_non_err_val = (try sema.resolveDefinedValue(parent_block, operand_src, is_non_err)).?;
19462 if (is_non_err_val.toBool()) {19566 if (is_non_err_val.toBool()) {
19463 return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false);19567 return sema.analyzeErrUnionPayloadPtr(parent_block, src, operand, false, false);
...@@ -19471,9 +19575,15 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -19471,9 +19575,15 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
19471 var sub_block = parent_block.makeSubBlock();19575 var sub_block = parent_block.makeSubBlock();
19472 defer sub_block.instructions.deinit(sema.gpa);19576 defer sub_block.instructions.deinit(sema.gpa);
1947319577
19578 const parent_hint = sema.branch_hint;
19579 defer sema.branch_hint = parent_hint;
19580
19474 // This body is guaranteed to end with noreturn and has no breaks.19581 // This body is guaranteed to end with noreturn and has no breaks.
19475 try sema.analyzeBodyInner(&sub_block, body);19582 try sema.analyzeBodyInner(&sub_block, body);
1947619583
19584 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.
19585 const is_cold = sema.branch_hint == .cold;
19586
19477 const operand_ty = sema.typeOf(operand);19587 const operand_ty = sema.typeOf(operand);
19478 const ptr_info = operand_ty.ptrInfo(zcu);19588 const ptr_info = operand_ty.ptrInfo(zcu);
19479 const res_ty = try pt.ptrTypeSema(.{19589 const res_ty = try pt.ptrTypeSema(.{
...@@ -19489,7 +19599,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -19489,7 +19599,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
19489 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).Struct.fields.len +19599 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).Struct.fields.len +
19490 sub_block.instructions.items.len);19600 sub_block.instructions.items.len);
19491 const try_inst = try parent_block.addInst(.{19601 const try_inst = try parent_block.addInst(.{
19492 .tag = .try_ptr,19602 .tag = if (is_cold) .try_ptr_cold else .try_ptr,
19493 .data = .{ .ty_pl = .{19603 .data = .{ .ty_pl = .{
19494 .ty = res_ty_ref,19604 .ty = res_ty_ref,
19495 .payload = sema.addExtraAssumeCapacity(Air.TryPtr{19605 .payload = sema.addExtraAssumeCapacity(Air.TryPtr{
...@@ -19741,6 +19851,8 @@ fn retWithErrTracing(...@@ -19741,6 +19851,8 @@ fn retWithErrTracing(
19741 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{19851 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
19742 .then_body_len = @intCast(then_block.instructions.items.len),19852 .then_body_len = @intCast(then_block.instructions.items.len),
19743 .else_body_len = @intCast(else_block.instructions.items.len),19853 .else_body_len = @intCast(else_block.instructions.items.len),
19854 // weight against error branch
19855 .branch_hints = .{ .true = .likely, .false = .unlikely },
19744 });19856 });
19745 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));19857 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(then_block.instructions.items));
19746 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));19858 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(else_block.instructions.items));
...@@ -26753,6 +26865,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr...@@ -26753,6 +26865,7 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr
26753 .export_options => "ExportOptions",26865 .export_options => "ExportOptions",
26754 .extern_options => "ExternOptions",26866 .extern_options => "ExternOptions",
26755 .type_info => "Type",26867 .type_info => "Type",
26868 .branch_hint => "BranchHint",
2675626869
26757 // Values are handled here.26870 // Values are handled here.
26758 .calling_convention_c => {26871 .calling_convention_c => {
...@@ -26778,6 +26891,27 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr...@@ -26778,6 +26891,27 @@ fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileErr
26778 return Air.internedToRef(ty.toIntern());26891 return Air.internedToRef(ty.toIntern());
26779}26892}
2678026893
26894fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
26895 const pt = sema.pt;
26896 const zcu = pt.zcu;
26897
26898 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
26899 const uncoerced_hint = try sema.resolveInst(extra.operand);
26900 const operand_src = block.builtinCallArgSrc(extra.node, 0);
26901
26902 const hint_ty = try pt.getBuiltinType("BranchHint");
26903 const coerced_hint = try sema.coerce(block, hint_ty, uncoerced_hint, operand_src);
26904 const hint_val = try sema.resolveConstDefinedValue(block, operand_src, coerced_hint, .{
26905 .needed_comptime_reason = "operand to '@branchHint' must be comptime-known",
26906 });
26907
26908 // We only apply the first hint in a branch.
26909 // This allows user-provided hints to override implicit cold hints.
26910 if (sema.branch_hint == null) {
26911 sema.branch_hint = zcu.toEnum(std.builtin.BranchHint, hint_val);
26912 }
26913}
26914
26781fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void {26915fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void {
26782 if (block.is_comptime) {26916 if (block.is_comptime) {
26783 const msg = msg: {26917 const msg = msg: {
...@@ -27333,13 +27467,17 @@ fn addSafetyCheckExtra(...@@ -27333,13 +27467,17 @@ fn addSafetyCheckExtra(
2733327467
27334 sema.air_instructions.appendAssumeCapacity(.{27468 sema.air_instructions.appendAssumeCapacity(.{
27335 .tag = .cond_br,27469 .tag = .cond_br,
27336 .data = .{ .pl_op = .{27470 .data = .{
27337 .operand = ok,27471 .pl_op = .{
27338 .payload = sema.addExtraAssumeCapacity(Air.CondBr{27472 .operand = ok,
27339 .then_body_len = 1,27473 .payload = sema.addExtraAssumeCapacity(Air.CondBr{
27340 .else_body_len = @intCast(fail_block.instructions.items.len),27474 .then_body_len = 1,
27341 }),27475 .else_body_len = @intCast(fail_block.instructions.items.len),
27342 } },27476 // safety check failure branch is cold
27477 .branch_hints = .{ .true = .likely, .false = .cold },
27478 }),
27479 },
27480 },
27343 });27481 });
27344 sema.air_extra.appendAssumeCapacity(@intFromEnum(br_inst));27482 sema.air_extra.appendAssumeCapacity(@intFromEnum(br_inst));
27345 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(fail_block.instructions.items));27483 sema.air_extra.appendSliceAssumeCapacity(@ptrCast(fail_block.instructions.items));
...@@ -27536,6 +27674,7 @@ fn safetyCheckFormatted(...@@ -27536,6 +27674,7 @@ fn safetyCheckFormatted(
27536 try sema.addSafetyCheckExtra(parent_block, ok, &fail_block);27674 try sema.addSafetyCheckExtra(parent_block, ok, &fail_block);
27537}27675}
2753827676
27677/// This does not set `sema.branch_hint`.
27539fn safetyPanic(sema: *Sema, block: *Block, src: LazySrcLoc, panic_id: Zcu.PanicId) CompileError!void {27678fn safetyPanic(sema: *Sema, block: *Block, src: LazySrcLoc, panic_id: Zcu.PanicId) CompileError!void {
27540 const msg_nav_index = try sema.preparePanicId(block, src, panic_id);27679 const msg_nav_index = try sema.preparePanicId(block, src, panic_id);
27541 const msg_inst = try sema.analyzeNavVal(block, src, msg_nav_index);27680 const msg_inst = try sema.analyzeNavVal(block, src, msg_nav_index);
...@@ -37185,7 +37324,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {...@@ -37185,7 +37324,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
37185 inline for (fields) |field| {37324 inline for (fields) |field| {
37186 sema.air_extra.appendAssumeCapacity(switch (field.type) {37325 sema.air_extra.appendAssumeCapacity(switch (field.type) {
37187 u32 => @field(extra, field.name),37326 u32 => @field(extra, field.name),
37188 i32 => @bitCast(@field(extra, field.name)),37327 i32, Air.CondBr.BranchHints => @bitCast(@field(extra, field.name)),
37189 Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(extra, field.name)),37328 Air.Inst.Ref, InternPool.Index => @intFromEnum(@field(extra, field.name)),
37190 else => @compileError("bad field type: " ++ @typeName(field.type)),37329 else => @compileError("bad field type: " ++ @typeName(field.type)),
37191 });37330 });
...@@ -38253,6 +38392,12 @@ fn maybeDerefSliceAsArray(...@@ -38253,6 +38392,12 @@ fn maybeDerefSliceAsArray(
3825338392
38254fn analyzeUnreachable(sema: *Sema, block: *Block, src: LazySrcLoc, safety_check: bool) !void {38393fn analyzeUnreachable(sema: *Sema, block: *Block, src: LazySrcLoc, safety_check: bool) !void {
38255 if (safety_check and block.wantSafety()) {38394 if (safety_check and block.wantSafety()) {
38395 // We only apply the first hint in a branch.
38396 // This allows user-provided hints to override implicit cold hints.
38397 if (sema.branch_hint == null) {
38398 sema.branch_hint = .cold;
38399 }
38400
38256 try sema.safetyPanic(block, src, .unreach);38401 try sema.safetyPanic(block, src, .unreach);
38257 } else {38402 } else {
38258 _ = try block.addNoOp(.unreach);38403 _ = try block.addNoOp(.unreach);
src/Zcu/PerThread.zig+2
...@@ -2188,6 +2188,8 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!...@@ -2188,6 +2188,8 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!
2188 });2188 });
2189 }2189 }
21902190
2191 func.setBranchHint(ip, sema.branch_hint orelse .none);
2192
2191 // If we don't get an error return trace from a caller, create our own.2193 // If we don't get an error return trace from a caller, create our own.
2192 if (func.analysisUnordered(ip).calls_or_awaits_errorable_fn and2194 if (func.analysisUnordered(ip).calls_or_awaits_errorable_fn and
2193 zcu.comp.config.any_error_tracing and2195 zcu.comp.config.any_error_tracing and
src/arch/aarch64/CodeGen.zig+18-24
...@@ -795,7 +795,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -795,7 +795,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
795 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),795 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
796796
797 .@"try" => try self.airTry(inst),797 .@"try" => try self.airTry(inst),
798 .try_cold => try self.airTry(inst),
798 .try_ptr => try self.airTryPtr(inst),799 .try_ptr => try self.airTryPtr(inst),
800 .try_ptr_cold => try self.airTryPtr(inst),
799801
800 .dbg_stmt => try self.airDbgStmt(inst),802 .dbg_stmt => try self.airDbgStmt(inst),
801 .dbg_inline_block => try self.airDbgInlineBlock(inst),803 .dbg_inline_block => try self.airDbgInlineBlock(inst),
...@@ -5092,25 +5094,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !...@@ -5092,25 +5094,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
5092}5094}
50935095
5094fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {5096fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5095 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;5097 const switch_br = self.air.unwrapSwitch(inst);
5096 const condition_ty = self.typeOf(pl_op.operand);5098 const condition_ty = self.typeOf(switch_br.operand);
5097 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
5098 const liveness = try self.liveness.getSwitchBr(5099 const liveness = try self.liveness.getSwitchBr(
5099 self.gpa,5100 self.gpa,
5100 inst,5101 inst,
5101 switch_br.data.cases_len + 1,5102 switch_br.cases_len + 1,
5102 );5103 );
5103 defer self.gpa.free(liveness.deaths);5104 defer self.gpa.free(liveness.deaths);
51045105
5105 var extra_index: usize = switch_br.end;5106 var it = switch_br.iterateCases();
5106 var case_i: u32 = 0;5107 while (it.next()) |case| {
5107 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
5108 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
5109 const items = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[case.end..][0..case.data.items_len]));
5110 assert(items.len > 0);
5111 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
5112 extra_index = case.end + items.len + case_body.len;
5113
5114 // For every item, we compare it to condition and branch into5108 // For every item, we compare it to condition and branch into
5115 // the prong if they are equal. After we compared to all5109 // the prong if they are equal. After we compared to all
5116 // items, we branch into the next prong (or if no other prongs5110 // items, we branch into the next prong (or if no other prongs
...@@ -5126,11 +5120,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5126,11 +5120,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5126 // prong: ...5120 // prong: ...
5127 // ...5121 // ...
5128 // out: ...5122 // out: ...
5129 const branch_into_prong_relocs = try self.gpa.alloc(u32, items.len);5123 const branch_into_prong_relocs = try self.gpa.alloc(u32, case.items.len);
5130 defer self.gpa.free(branch_into_prong_relocs);5124 defer self.gpa.free(branch_into_prong_relocs);
51315125
5132 for (items, 0..) |item, idx| {5126 for (case.items, 0..) |item, idx| {
5133 const cmp_result = try self.cmp(.{ .inst = pl_op.operand }, .{ .inst = item }, condition_ty, .neq);5127 const cmp_result = try self.cmp(.{ .inst = switch_br.operand }, .{ .inst = item }, condition_ty, .neq);
5134 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);5128 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);
5135 }5129 }
51365130
...@@ -5156,11 +5150,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5156,11 +5150,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5156 _ = self.branch_stack.pop();5150 _ = self.branch_stack.pop();
5157 }5151 }
51585152
5159 try self.ensureProcessDeathCapacity(liveness.deaths[case_i].len);5153 try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len);
5160 for (liveness.deaths[case_i]) |operand| {5154 for (liveness.deaths[case.idx]) |operand| {
5161 self.processDeath(operand);5155 self.processDeath(operand);
5162 }5156 }
5163 try self.genBody(case_body);5157 try self.genBody(case.body);
51645158
5165 // Revert to the previous register and stack allocation state.5159 // Revert to the previous register and stack allocation state.
5166 var saved_case_branch = self.branch_stack.pop();5160 var saved_case_branch = self.branch_stack.pop();
...@@ -5178,8 +5172,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5178,8 +5172,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5178 try self.performReloc(branch_away_from_prong_reloc);5172 try self.performReloc(branch_away_from_prong_reloc);
5179 }5173 }
51805174
5181 if (switch_br.data.else_body_len > 0) {5175 if (switch_br.else_body_len > 0) {
5182 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);5176 const else_body = it.elseBody();
51835177
5184 // Capture the state of register and stack allocation state so that we can revert to it.5178 // Capture the state of register and stack allocation state so that we can revert to it.
5185 const parent_next_stack_offset = self.next_stack_offset;5179 const parent_next_stack_offset = self.next_stack_offset;
...@@ -5218,7 +5212,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5218,7 +5212,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5218 // in airCondBr.5212 // in airCondBr.
5219 }5213 }
52205214
5221 return self.finishAir(inst, .unreach, .{ pl_op.operand, .none, .none });5215 return self.finishAir(inst, .unreach, .{ switch_br.operand, .none, .none });
5222}5216}
52235217
5224fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {5218fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {
...@@ -6363,14 +6357,14 @@ fn wantSafety(self: *Self) bool {...@@ -6363,14 +6357,14 @@ fn wantSafety(self: *Self) bool {
6363}6357}
63646358
6365fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {6359fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6366 @setCold(true);6360 @branchHint(.cold);
6367 assert(self.err_msg == null);6361 assert(self.err_msg == null);
6368 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);6362 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);
6369 return error.CodegenFail;6363 return error.CodegenFail;
6370}6364}
63716365
6372fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {6366fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6373 @setCold(true);6367 @branchHint(.cold);
6374 assert(self.err_msg == null);6368 assert(self.err_msg == null);
6375 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);6369 self.err_msg = try ErrorMsg.create(self.gpa, self.src_loc, format, args);
6376 return error.CodegenFail;6370 return error.CodegenFail;
src/arch/aarch64/Emit.zig+1-1
...@@ -430,7 +430,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {...@@ -430,7 +430,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {
430}430}
431431
432fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {432fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
433 @setCold(true);433 @branchHint(.cold);
434 assert(emit.err_msg == null);434 assert(emit.err_msg == null);
435 const comp = emit.bin_file.comp;435 const comp = emit.bin_file.comp;
436 const gpa = comp.gpa;436 const gpa = comp.gpa;
src/arch/arm/CodeGen.zig+18-24
...@@ -782,7 +782,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -782,7 +782,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
782 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),782 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
783783
784 .@"try" => try self.airTry(inst),784 .@"try" => try self.airTry(inst),
785 .try_cold => try self.airTry(inst),
785 .try_ptr => try self.airTryPtr(inst),786 .try_ptr => try self.airTryPtr(inst),
787 .try_ptr_cold => try self.airTryPtr(inst),
786788
787 .dbg_stmt => try self.airDbgStmt(inst),789 .dbg_stmt => try self.airDbgStmt(inst),
788 .dbg_inline_block => try self.airDbgInlineBlock(inst),790 .dbg_inline_block => try self.airDbgInlineBlock(inst),
...@@ -5040,25 +5042,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !...@@ -5040,25 +5042,17 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
5040}5042}
50415043
5042fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {5044fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5043 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;5045 const switch_br = self.air.unwrapSwitch(inst);
5044 const condition_ty = self.typeOf(pl_op.operand);5046 const condition_ty = self.typeOf(switch_br.operand);
5045 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
5046 const liveness = try self.liveness.getSwitchBr(5047 const liveness = try self.liveness.getSwitchBr(
5047 self.gpa,5048 self.gpa,
5048 inst,5049 inst,
5049 switch_br.data.cases_len + 1,5050 switch_br.cases_len + 1,
5050 );5051 );
5051 defer self.gpa.free(liveness.deaths);5052 defer self.gpa.free(liveness.deaths);
50525053
5053 var extra_index: usize = switch_br.end;5054 var it = switch_br.iterateCases();
5054 var case_i: u32 = 0;5055 while (it.next()) |case| {
5055 while (case_i < switch_br.data.cases_len) : (case_i += 1) {
5056 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);
5057 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
5058 assert(items.len > 0);
5059 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
5060 extra_index = case.end + items.len + case_body.len;
5061
5062 // For every item, we compare it to condition and branch into5056 // For every item, we compare it to condition and branch into
5063 // the prong if they are equal. After we compared to all5057 // the prong if they are equal. After we compared to all
5064 // items, we branch into the next prong (or if no other prongs5058 // items, we branch into the next prong (or if no other prongs
...@@ -5074,11 +5068,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5074,11 +5068,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5074 // prong: ...5068 // prong: ...
5075 // ...5069 // ...
5076 // out: ...5070 // out: ...
5077 const branch_into_prong_relocs = try self.gpa.alloc(u32, items.len);5071 const branch_into_prong_relocs = try self.gpa.alloc(u32, case.items.len);
5078 defer self.gpa.free(branch_into_prong_relocs);5072 defer self.gpa.free(branch_into_prong_relocs);
50795073
5080 for (items, 0..) |item, idx| {5074 for (case.items, 0..) |item, idx| {
5081 const cmp_result = try self.cmp(.{ .inst = pl_op.operand }, .{ .inst = item }, condition_ty, .neq);5075 const cmp_result = try self.cmp(.{ .inst = switch_br.operand }, .{ .inst = item }, condition_ty, .neq);
5082 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);5076 branch_into_prong_relocs[idx] = try self.condBr(cmp_result);
5083 }5077 }
50845078
...@@ -5104,11 +5098,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5104,11 +5098,11 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5104 _ = self.branch_stack.pop();5098 _ = self.branch_stack.pop();
5105 }5099 }
51065100
5107 try self.ensureProcessDeathCapacity(liveness.deaths[case_i].len);5101 try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len);
5108 for (liveness.deaths[case_i]) |operand| {5102 for (liveness.deaths[case.idx]) |operand| {
5109 self.processDeath(operand);5103 self.processDeath(operand);
5110 }5104 }
5111 try self.genBody(case_body);5105 try self.genBody(case.body);
51125106
5113 // Revert to the previous register and stack allocation state.5107 // Revert to the previous register and stack allocation state.
5114 var saved_case_branch = self.branch_stack.pop();5108 var saved_case_branch = self.branch_stack.pop();
...@@ -5126,8 +5120,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5126,8 +5120,8 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5126 try self.performReloc(branch_away_from_prong_reloc);5120 try self.performReloc(branch_away_from_prong_reloc);
5127 }5121 }
51285122
5129 if (switch_br.data.else_body_len > 0) {5123 if (switch_br.else_body_len > 0) {
5130 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);5124 const else_body = it.elseBody();
51315125
5132 // Capture the state of register and stack allocation state so that we can revert to it.5126 // Capture the state of register and stack allocation state so that we can revert to it.
5133 const parent_next_stack_offset = self.next_stack_offset;5127 const parent_next_stack_offset = self.next_stack_offset;
...@@ -5166,7 +5160,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5166,7 +5160,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5166 // in airCondBr.5160 // in airCondBr.
5167 }5161 }
51685162
5169 return self.finishAir(inst, .unreach, .{ pl_op.operand, .none, .none });5163 return self.finishAir(inst, .unreach, .{ switch_br.operand, .none, .none });
5170}5164}
51715165
5172fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {5166fn performReloc(self: *Self, inst: Mir.Inst.Index) !void {
...@@ -6319,7 +6313,7 @@ fn wantSafety(self: *Self) bool {...@@ -6319,7 +6313,7 @@ fn wantSafety(self: *Self) bool {
6319}6313}
63206314
6321fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {6315fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6322 @setCold(true);6316 @branchHint(.cold);
6323 assert(self.err_msg == null);6317 assert(self.err_msg == null);
6324 const gpa = self.gpa;6318 const gpa = self.gpa;
6325 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);6319 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
...@@ -6327,7 +6321,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {...@@ -6327,7 +6321,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6327}6321}
63286322
6329fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {6323fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
6330 @setCold(true);6324 @branchHint(.cold);
6331 assert(self.err_msg == null);6325 assert(self.err_msg == null);
6332 const gpa = self.gpa;6326 const gpa = self.gpa;
6333 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);6327 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/arm/Emit.zig+1-1
...@@ -348,7 +348,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {...@@ -348,7 +348,7 @@ fn writeInstruction(emit: *Emit, instruction: Instruction) !void {
348}348}
349349
350fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {350fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
351 @setCold(true);351 @branchHint(.cold);
352 assert(emit.err_msg == null);352 assert(emit.err_msg == null);
353 const comp = emit.bin_file.comp;353 const comp = emit.bin_file.comp;
354 const gpa = comp.gpa;354 const gpa = comp.gpa;
src/arch/riscv64/CodeGen.zig+18-25
...@@ -1640,7 +1640,9 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {...@@ -1640,7 +1640,9 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
1640 .addrspace_cast => return func.fail("TODO: addrspace_cast", .{}),1640 .addrspace_cast => return func.fail("TODO: addrspace_cast", .{}),
16411641
1642 .@"try" => try func.airTry(inst),1642 .@"try" => try func.airTry(inst),
1643 .try_cold => try func.airTry(inst),
1643 .try_ptr => return func.fail("TODO: try_ptr", .{}),1644 .try_ptr => return func.fail("TODO: try_ptr", .{}),
1645 .try_ptr_cold => return func.fail("TODO: try_ptr_cold", .{}),
16441646
1645 .dbg_var_ptr,1647 .dbg_var_ptr,
1646 .dbg_var_val,1648 .dbg_var_val,
...@@ -5659,38 +5661,30 @@ fn lowerBlock(func: *Func, inst: Air.Inst.Index, body: []const Air.Inst.Index) !...@@ -5659,38 +5661,30 @@ fn lowerBlock(func: *Func, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
5659}5661}
56605662
5661fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {5663fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
5662 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;5664 const switch_br = func.air.unwrapSwitch(inst);
5663 const condition_ty = func.typeOf(pl_op.operand);5665
5664 const switch_br = func.air.extraData(Air.SwitchBr, pl_op.payload);5666 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.cases_len + 1);
5665 var extra_index: usize = switch_br.end;
5666 var case_i: u32 = 0;
5667 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.data.cases_len + 1);
5668 defer func.gpa.free(liveness.deaths);5667 defer func.gpa.free(liveness.deaths);
56695668
5670 const condition = try func.resolveInst(pl_op.operand);5669 const condition = try func.resolveInst(switch_br.operand);
5670 const condition_ty = func.typeOf(switch_br.operand);
56715671
5672 // If the condition dies here in this switch instruction, process5672 // If the condition dies here in this switch instruction, process
5673 // that death now instead of later as this has an effect on5673 // that death now instead of later as this has an effect on
5674 // whether it needs to be spilled in the branches5674 // whether it needs to be spilled in the branches
5675 if (func.liveness.operandDies(inst, 0)) {5675 if (func.liveness.operandDies(inst, 0)) {
5676 if (pl_op.operand.toIndex()) |op_inst| try func.processDeath(op_inst);5676 if (switch_br.operand.toIndex()) |op_inst| try func.processDeath(op_inst);
5677 }5677 }
56785678
5679 func.scope_generation += 1;5679 func.scope_generation += 1;
5680 const state = try func.saveState();5680 const state = try func.saveState();
56815681
5682 while (case_i < switch_br.data.cases_len) : (case_i += 1) {5682 var it = switch_br.iterateCases();
5683 const case = func.air.extraData(Air.SwitchBr.Case, extra_index);5683 while (it.next()) |case| {
5684 const items: []const Air.Inst.Ref =5684 var relocs = try func.gpa.alloc(Mir.Inst.Index, case.items.len);
5685 @ptrCast(func.air.extra[case.end..][0..case.data.items_len]);
5686 const case_body: []const Air.Inst.Index =
5687 @ptrCast(func.air.extra[case.end + items.len ..][0..case.data.body_len]);
5688 extra_index = case.end + items.len + case_body.len;
5689
5690 var relocs = try func.gpa.alloc(Mir.Inst.Index, items.len);
5691 defer func.gpa.free(relocs);5685 defer func.gpa.free(relocs);
56925686
5693 for (items, relocs, 0..) |item, *reloc, i| {5687 for (case.items, relocs, 0..) |item, *reloc, i| {
5694 const item_mcv = try func.resolveInst(item);5688 const item_mcv = try func.resolveInst(item);
56955689
5696 const cond_lock = switch (condition) {5690 const cond_lock = switch (condition) {
...@@ -5724,10 +5718,10 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {...@@ -5724,10 +5718,10 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
5724 reloc.* = try func.condBr(condition_ty, .{ .register = cmp_reg });5718 reloc.* = try func.condBr(condition_ty, .{ .register = cmp_reg });
5725 }5719 }
57265720
5727 for (liveness.deaths[case_i]) |operand| try func.processDeath(operand);5721 for (liveness.deaths[case.idx]) |operand| try func.processDeath(operand);
57285722
5729 for (relocs[0 .. relocs.len - 1]) |reloc| func.performReloc(reloc);5723 for (relocs[0 .. relocs.len - 1]) |reloc| func.performReloc(reloc);
5730 try func.genBody(case_body);5724 try func.genBody(case.body);
5731 try func.restoreState(state, &.{}, .{5725 try func.restoreState(state, &.{}, .{
5732 .emit_instructions = false,5726 .emit_instructions = false,
5733 .update_tracking = true,5727 .update_tracking = true,
...@@ -5738,9 +5732,8 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {...@@ -5738,9 +5732,8 @@ fn airSwitchBr(func: *Func, inst: Air.Inst.Index) !void {
5738 func.performReloc(relocs[relocs.len - 1]);5732 func.performReloc(relocs[relocs.len - 1]);
5739 }5733 }
57405734
5741 if (switch_br.data.else_body_len > 0) {5735 if (switch_br.else_body_len > 0) {
5742 const else_body: []const Air.Inst.Index =5736 const else_body = it.elseBody();
5743 @ptrCast(func.air.extra[extra_index..][0..switch_br.data.else_body_len]);
57445737
5745 const else_deaths = liveness.deaths.len - 1;5738 const else_deaths = liveness.deaths.len - 1;
5746 for (liveness.deaths[else_deaths]) |operand| try func.processDeath(operand);5739 for (liveness.deaths[else_deaths]) |operand| try func.processDeath(operand);
...@@ -8230,14 +8223,14 @@ fn wantSafety(func: *Func) bool {...@@ -8230,14 +8223,14 @@ fn wantSafety(func: *Func) bool {
8230}8223}
82318224
8232fn fail(func: *Func, comptime format: []const u8, args: anytype) InnerError {8225fn fail(func: *Func, comptime format: []const u8, args: anytype) InnerError {
8233 @setCold(true);8226 @branchHint(.cold);
8234 assert(func.err_msg == null);8227 assert(func.err_msg == null);
8235 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);8228 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);
8236 return error.CodegenFail;8229 return error.CodegenFail;
8237}8230}
82388231
8239fn failSymbol(func: *Func, comptime format: []const u8, args: anytype) InnerError {8232fn failSymbol(func: *Func, comptime format: []const u8, args: anytype) InnerError {
8240 @setCold(true);8233 @branchHint(.cold);
8241 assert(func.err_msg == null);8234 assert(func.err_msg == null);
8242 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);8235 func.err_msg = try ErrorMsg.create(func.gpa, func.src_loc, format, args);
8243 return error.CodegenFail;8236 return error.CodegenFail;
src/arch/riscv64/Lower.zig+1-1
...@@ -583,7 +583,7 @@ fn pushPopRegList(lower: *Lower, comptime spilling: bool, reg_list: Mir.Register...@@ -583,7 +583,7 @@ fn pushPopRegList(lower: *Lower, comptime spilling: bool, reg_list: Mir.Register
583}583}
584584
585pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {585pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {
586 @setCold(true);586 @branchHint(.cold);
587 assert(lower.err_msg == null);587 assert(lower.err_msg == null);
588 lower.err_msg = try ErrorMsg.create(lower.allocator, lower.src_loc, format, args);588 lower.err_msg = try ErrorMsg.create(lower.allocator, lower.src_loc, format, args);
589 return error.LowerFail;589 return error.LowerFail;
src/arch/sparc64/CodeGen.zig+3-1
...@@ -637,7 +637,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -637,7 +637,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
637 .addrspace_cast => @panic("TODO try self.airAddrSpaceCast(int)"),637 .addrspace_cast => @panic("TODO try self.airAddrSpaceCast(int)"),
638638
639 .@"try" => try self.airTry(inst),639 .@"try" => try self.airTry(inst),
640 .try_cold => try self.airTry(inst),
640 .try_ptr => @panic("TODO try self.airTryPtr(inst)"),641 .try_ptr => @panic("TODO try self.airTryPtr(inst)"),
642 .try_ptr_cold => @panic("TODO try self.airTryPtrCold(inst)"),
641643
642 .dbg_stmt => try self.airDbgStmt(inst),644 .dbg_stmt => try self.airDbgStmt(inst),
643 .dbg_inline_block => try self.airDbgInlineBlock(inst),645 .dbg_inline_block => try self.airDbgInlineBlock(inst),
...@@ -3531,7 +3533,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type)...@@ -3531,7 +3533,7 @@ fn errUnionPayload(self: *Self, error_union_mcv: MCValue, error_union_ty: Type)
3531}3533}
35323534
3533fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {3535fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
3534 @setCold(true);3536 @branchHint(.cold);
3535 assert(self.err_msg == null);3537 assert(self.err_msg == null);
3536 const gpa = self.gpa;3538 const gpa = self.gpa;
3537 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);3539 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/sparc64/Emit.zig+1-1
...@@ -511,7 +511,7 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void {...@@ -511,7 +511,7 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void {
511}511}
512512
513fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {513fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
514 @setCold(true);514 @branchHint(.cold);
515 assert(emit.err_msg == null);515 assert(emit.err_msg == null);
516 const comp = emit.bin_file.comp;516 const comp = emit.bin_file.comp;
517 const gpa = comp.gpa;517 const gpa = comp.gpa;
src/arch/wasm/CodeGen.zig+16-20
...@@ -1913,7 +1913,9 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1913,7 +1913,9 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1913 .get_union_tag => func.airGetUnionTag(inst),1913 .get_union_tag => func.airGetUnionTag(inst),
19141914
1915 .@"try" => func.airTry(inst),1915 .@"try" => func.airTry(inst),
1916 .try_cold => func.airTry(inst),
1916 .try_ptr => func.airTryPtr(inst),1917 .try_ptr => func.airTryPtr(inst),
1918 .try_ptr_cold => func.airTryPtr(inst),
19171919
1918 .dbg_stmt => func.airDbgStmt(inst),1920 .dbg_stmt => func.airDbgStmt(inst),
1919 .dbg_inline_block => func.airDbgInlineBlock(inst),1921 .dbg_inline_block => func.airDbgInlineBlock(inst),
...@@ -4041,37 +4043,31 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4041,37 +4043,31 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4041 const zcu = pt.zcu;4043 const zcu = pt.zcu;
4042 // result type is always 'noreturn'4044 // result type is always 'noreturn'
4043 const blocktype = wasm.block_empty;4045 const blocktype = wasm.block_empty;
4044 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;4046 const switch_br = func.air.unwrapSwitch(inst);
4045 const target = try func.resolveInst(pl_op.operand);4047 const target = try func.resolveInst(switch_br.operand);
4046 const target_ty = func.typeOf(pl_op.operand);4048 const target_ty = func.typeOf(switch_br.operand);
4047 const switch_br = func.air.extraData(Air.SwitchBr, pl_op.payload);4049 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.cases_len + 1);
4048 const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.data.cases_len + 1);
4049 defer func.gpa.free(liveness.deaths);4050 defer func.gpa.free(liveness.deaths);
40504051
4051 var extra_index: usize = switch_br.end;
4052 var case_i: u32 = 0;
4053
4054 // a list that maps each value with its value and body based on the order inside the list.4052 // a list that maps each value with its value and body based on the order inside the list.
4055 const CaseValue = struct { integer: i32, value: Value };4053 const CaseValue = struct { integer: i32, value: Value };
4056 var case_list = try std.ArrayList(struct {4054 var case_list = try std.ArrayList(struct {
4057 values: []const CaseValue,4055 values: []const CaseValue,
4058 body: []const Air.Inst.Index,4056 body: []const Air.Inst.Index,
4059 }).initCapacity(func.gpa, switch_br.data.cases_len);4057 }).initCapacity(func.gpa, switch_br.cases_len);
4060 defer for (case_list.items) |case| {4058 defer for (case_list.items) |case| {
4061 func.gpa.free(case.values);4059 func.gpa.free(case.values);
4062 } else case_list.deinit();4060 } else case_list.deinit();
40634061
4064 var lowest_maybe: ?i32 = null;4062 var lowest_maybe: ?i32 = null;
4065 var highest_maybe: ?i32 = null;4063 var highest_maybe: ?i32 = null;
4066 while (case_i < switch_br.data.cases_len) : (case_i += 1) {4064
4067 const case = func.air.extraData(Air.SwitchBr.Case, extra_index);4065 var it = switch_br.iterateCases();
4068 const items: []const Air.Inst.Ref = @ptrCast(func.air.extra[case.end..][0..case.data.items_len]);4066 while (it.next()) |case| {
4069 const case_body: []const Air.Inst.Index = @ptrCast(func.air.extra[case.end + items.len ..][0..case.data.body_len]);4067 const values = try func.gpa.alloc(CaseValue, case.items.len);
4070 extra_index = case.end + items.len + case_body.len;
4071 const values = try func.gpa.alloc(CaseValue, items.len);
4072 errdefer func.gpa.free(values);4068 errdefer func.gpa.free(values);
40734069
4074 for (items, 0..) |ref, i| {4070 for (case.items, 0..) |ref, i| {
4075 const item_val = (try func.air.value(ref, pt)).?;4071 const item_val = (try func.air.value(ref, pt)).?;
4076 const int_val = func.valueAsI32(item_val);4072 const int_val = func.valueAsI32(item_val);
4077 if (lowest_maybe == null or int_val < lowest_maybe.?) {4073 if (lowest_maybe == null or int_val < lowest_maybe.?) {
...@@ -4083,7 +4079,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4083,7 +4079,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4083 values[i] = .{ .integer = int_val, .value = item_val };4079 values[i] = .{ .integer = int_val, .value = item_val };
4084 }4080 }
40854081
4086 case_list.appendAssumeCapacity(.{ .values = values, .body = case_body });4082 case_list.appendAssumeCapacity(.{ .values = values, .body = case.body });
4087 try func.startBlock(.block, blocktype);4083 try func.startBlock(.block, blocktype);
4088 }4084 }
40894085
...@@ -4097,7 +4093,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4097,7 +4093,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4097 // TODO: Benchmark this to find a proper value, LLVM seems to draw the line at '40~45'.4093 // TODO: Benchmark this to find a proper value, LLVM seems to draw the line at '40~45'.
4098 const is_sparse = highest - lowest > 50 or target_ty.bitSize(zcu) > 32;4094 const is_sparse = highest - lowest > 50 or target_ty.bitSize(zcu) > 32;
40994095
4100 const else_body: []const Air.Inst.Index = @ptrCast(func.air.extra[extra_index..][0..switch_br.data.else_body_len]);4096 const else_body = it.elseBody();
4101 const has_else_body = else_body.len != 0;4097 const has_else_body = else_body.len != 0;
4102 if (has_else_body) {4098 if (has_else_body) {
4103 try func.startBlock(.block, blocktype);4099 try func.startBlock(.block, blocktype);
...@@ -4140,11 +4136,11 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4140,11 +4136,11 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4140 // for errors that are not present in any branch. This is fine as this default4136 // for errors that are not present in any branch. This is fine as this default
4141 // case will never be hit for those cases but we do save runtime cost and size4137 // case will never be hit for those cases but we do save runtime cost and size
4142 // by using a jump table for this instead of if-else chains.4138 // by using a jump table for this instead of if-else chains.
4143 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) case_i else unreachable;4139 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) switch_br.cases_len else unreachable;
4144 };4140 };
4145 func.mir_extra.appendAssumeCapacity(idx);4141 func.mir_extra.appendAssumeCapacity(idx);
4146 } else if (has_else_body) {4142 } else if (has_else_body) {
4147 func.mir_extra.appendAssumeCapacity(case_i); // default branch4143 func.mir_extra.appendAssumeCapacity(switch_br.cases_len); // default branch
4148 }4144 }
4149 try func.endBlock();4145 try func.endBlock();
4150 }4146 }
src/arch/wasm/Emit.zig+1-1
...@@ -252,7 +252,7 @@ fn offset(self: Emit) u32 {...@@ -252,7 +252,7 @@ fn offset(self: Emit) u32 {
252}252}
253253
254fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {254fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
255 @setCold(true);255 @branchHint(.cold);
256 std.debug.assert(emit.error_msg == null);256 std.debug.assert(emit.error_msg == null);
257 const comp = emit.bin_file.base.comp;257 const comp = emit.bin_file.base.comp;
258 const zcu = comp.zcu.?;258 const zcu = comp.zcu.?;
src/arch/x86_64/CodeGen.zig+17-25
...@@ -2262,7 +2262,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -2262,7 +2262,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
2262 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),2262 .addrspace_cast => return self.fail("TODO implement addrspace_cast", .{}),
22632263
2264 .@"try" => try self.airTry(inst),2264 .@"try" => try self.airTry(inst),
2265 .try_cold => try self.airTry(inst), // TODO
2265 .try_ptr => try self.airTryPtr(inst),2266 .try_ptr => try self.airTryPtr(inst),
2267 .try_ptr_cold => try self.airTryPtr(inst), // TODO
22662268
2267 .dbg_stmt => try self.airDbgStmt(inst),2269 .dbg_stmt => try self.airDbgStmt(inst),
2268 .dbg_inline_block => try self.airDbgInlineBlock(inst),2270 .dbg_inline_block => try self.airDbgInlineBlock(inst),
...@@ -13631,38 +13633,29 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !...@@ -13631,38 +13633,29 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
13631}13633}
1363213634
13633fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {13635fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
13634 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;13636 const switch_br = self.air.unwrapSwitch(inst);
13635 const condition = try self.resolveInst(pl_op.operand);13637 const condition = try self.resolveInst(switch_br.operand);
13636 const condition_ty = self.typeOf(pl_op.operand);13638 const condition_ty = self.typeOf(switch_br.operand);
13637 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);13639 const liveness = try self.liveness.getSwitchBr(self.gpa, inst, switch_br.cases_len + 1);
13638 var extra_index: usize = switch_br.end;
13639 var case_i: u32 = 0;
13640 const liveness = try self.liveness.getSwitchBr(self.gpa, inst, switch_br.data.cases_len + 1);
13641 defer self.gpa.free(liveness.deaths);13640 defer self.gpa.free(liveness.deaths);
1364213641
13643 // If the condition dies here in this switch instruction, process13642 // If the condition dies here in this switch instruction, process
13644 // that death now instead of later as this has an effect on13643 // that death now instead of later as this has an effect on
13645 // whether it needs to be spilled in the branches13644 // whether it needs to be spilled in the branches
13646 if (self.liveness.operandDies(inst, 0)) {13645 if (self.liveness.operandDies(inst, 0)) {
13647 if (pl_op.operand.toIndex()) |op_inst| try self.processDeath(op_inst);13646 if (switch_br.operand.toIndex()) |op_inst| try self.processDeath(op_inst);
13648 }13647 }
1364913648
13650 self.scope_generation += 1;13649 self.scope_generation += 1;
13651 const state = try self.saveState();13650 const state = try self.saveState();
1365213651
13653 while (case_i < switch_br.data.cases_len) : (case_i += 1) {13652 var it = switch_br.iterateCases();
13654 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);13653 while (it.next()) |case| {
13655 const items: []const Air.Inst.Ref =13654 var relocs = try self.gpa.alloc(Mir.Inst.Index, case.items.len);
13656 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
13657 const case_body: []const Air.Inst.Index =
13658 @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
13659 extra_index = case.end + items.len + case_body.len;
13660
13661 var relocs = try self.gpa.alloc(Mir.Inst.Index, items.len);
13662 defer self.gpa.free(relocs);13655 defer self.gpa.free(relocs);
1366313656
13664 try self.spillEflagsIfOccupied();13657 try self.spillEflagsIfOccupied();
13665 for (items, relocs, 0..) |item, *reloc, i| {13658 for (case.items, relocs, 0..) |item, *reloc, i| {
13666 const item_mcv = try self.resolveInst(item);13659 const item_mcv = try self.resolveInst(item);
13667 const cc: Condition = switch (condition) {13660 const cc: Condition = switch (condition) {
13668 .eflags => |cc| switch (item_mcv.immediate) {13661 .eflags => |cc| switch (item_mcv.immediate) {
...@@ -13678,10 +13671,10 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -13678,10 +13671,10 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
13678 reloc.* = try self.asmJccReloc(if (i < relocs.len - 1) cc else cc.negate(), undefined);13671 reloc.* = try self.asmJccReloc(if (i < relocs.len - 1) cc else cc.negate(), undefined);
13679 }13672 }
1368013673
13681 for (liveness.deaths[case_i]) |operand| try self.processDeath(operand);13674 for (liveness.deaths[case.idx]) |operand| try self.processDeath(operand);
1368213675
13683 for (relocs[0 .. relocs.len - 1]) |reloc| self.performReloc(reloc);13676 for (relocs[0 .. relocs.len - 1]) |reloc| self.performReloc(reloc);
13684 try self.genBody(case_body);13677 try self.genBody(case.body);
13685 try self.restoreState(state, &.{}, .{13678 try self.restoreState(state, &.{}, .{
13686 .emit_instructions = false,13679 .emit_instructions = false,
13687 .update_tracking = true,13680 .update_tracking = true,
...@@ -13692,9 +13685,8 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -13692,9 +13685,8 @@ fn airSwitchBr(self: *Self, inst: Air.Inst.Index) !void {
13692 self.performReloc(relocs[relocs.len - 1]);13685 self.performReloc(relocs[relocs.len - 1]);
13693 }13686 }
1369413687
13695 if (switch_br.data.else_body_len > 0) {13688 if (switch_br.else_body_len > 0) {
13696 const else_body: []const Air.Inst.Index =13689 const else_body = it.elseBody();
13697 @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);
1369813690
13699 const else_deaths = liveness.deaths.len - 1;13691 const else_deaths = liveness.deaths.len - 1;
13700 for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);13692 for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);
...@@ -19211,7 +19203,7 @@ fn resolveCallingConventionValues(...@@ -19211,7 +19203,7 @@ fn resolveCallingConventionValues(
19211}19203}
1921219204
19213fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {19205fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
19214 @setCold(true);19206 @branchHint(.cold);
19215 assert(self.err_msg == null);19207 assert(self.err_msg == null);
19216 const gpa = self.gpa;19208 const gpa = self.gpa;
19217 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);19209 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
...@@ -19219,7 +19211,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {...@@ -19219,7 +19211,7 @@ fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError {
19219}19211}
1922019212
19221fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {19213fn failSymbol(self: *Self, comptime format: []const u8, args: anytype) InnerError {
19222 @setCold(true);19214 @branchHint(.cold);
19223 assert(self.err_msg == null);19215 assert(self.err_msg == null);
19224 const gpa = self.gpa;19216 const gpa = self.gpa;
19225 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);19217 self.err_msg = try ErrorMsg.create(gpa, self.src_loc, format, args);
src/arch/x86_64/Lower.zig+1-1
...@@ -293,7 +293,7 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {...@@ -293,7 +293,7 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {
293}293}
294294
295pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {295pub fn fail(lower: *Lower, comptime format: []const u8, args: anytype) Error {
296 @setCold(true);296 @branchHint(.cold);
297 assert(lower.err_msg == null);297 assert(lower.err_msg == null);
298 lower.err_msg = try Zcu.ErrorMsg.create(lower.allocator, lower.src_loc, format, args);298 lower.err_msg = try Zcu.ErrorMsg.create(lower.allocator, lower.src_loc, format, args);
299 return error.LowerFail;299 return error.LowerFail;
src/codegen/c.zig+20-25
...@@ -626,7 +626,7 @@ pub const DeclGen = struct {...@@ -626,7 +626,7 @@ pub const DeclGen = struct {
626 }626 }
627627
628 fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {628 fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } {
629 @setCold(true);629 @branchHint(.cold);
630 const zcu = dg.pt.zcu;630 const zcu = dg.pt.zcu;
631 const src_loc = zcu.navSrcLoc(dg.pass.nav);631 const src_loc = zcu.navSrcLoc(dg.pass.nav);
632 dg.error_msg = try Zcu.ErrorMsg.create(dg.gpa, src_loc, format, args);632 dg.error_msg = try Zcu.ErrorMsg.create(dg.gpa, src_loc, format, args);
...@@ -1786,7 +1786,7 @@ pub const DeclGen = struct {...@@ -1786,7 +1786,7 @@ pub const DeclGen = struct {
1786 else => unreachable,1786 else => unreachable,
1787 }1787 }
1788 }1788 }
1789 if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).is_cold)1789 if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).branch_hint == .cold)
1790 try w.writeAll("zig_cold ");1790 try w.writeAll("zig_cold ");
1791 if (fn_info.return_type == .noreturn_type) try w.writeAll("zig_noreturn ");1791 if (fn_info.return_type == .noreturn_type) try w.writeAll("zig_noreturn ");
17921792
...@@ -3290,8 +3290,10 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,...@@ -3290,8 +3290,10 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
3290 .prefetch => try airPrefetch(f, inst),3290 .prefetch => try airPrefetch(f, inst),
3291 .addrspace_cast => return f.fail("TODO: C backend: implement addrspace_cast", .{}),3291 .addrspace_cast => return f.fail("TODO: C backend: implement addrspace_cast", .{}),
32923292
3293 .@"try" => try airTry(f, inst),3293 .@"try" => try airTry(f, inst),
3294 .try_ptr => try airTryPtr(f, inst),3294 .try_cold => try airTry(f, inst),
3295 .try_ptr => try airTryPtr(f, inst),
3296 .try_ptr_cold => try airTryPtr(f, inst),
32953297
3296 .dbg_stmt => try airDbgStmt(f, inst),3298 .dbg_stmt => try airDbgStmt(f, inst),
3297 .dbg_inline_block => try airDbgInlineBlock(f, inst),3299 .dbg_inline_block => try airDbgInlineBlock(f, inst),
...@@ -4988,11 +4990,10 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -4988,11 +4990,10 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
4988fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {4990fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
4989 const pt = f.object.dg.pt;4991 const pt = f.object.dg.pt;
4990 const zcu = pt.zcu;4992 const zcu = pt.zcu;
4991 const pl_op = f.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;4993 const switch_br = f.air.unwrapSwitch(inst);
4992 const condition = try f.resolveInst(pl_op.operand);4994 const condition = try f.resolveInst(switch_br.operand);
4993 try reap(f, inst, &.{pl_op.operand});4995 try reap(f, inst, &.{switch_br.operand});
4994 const condition_ty = f.typeOf(pl_op.operand);4996 const condition_ty = f.typeOf(switch_br.operand);
4995 const switch_br = f.air.extraData(Air.SwitchBr, pl_op.payload);
4996 const writer = f.object.writer();4997 const writer = f.object.writer();
49974998
4998 try writer.writeAll("switch (");4999 try writer.writeAll("switch (");
...@@ -5013,22 +5014,16 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5013,22 +5014,16 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
5013 f.object.indent_writer.pushIndent();5014 f.object.indent_writer.pushIndent();
50145015
5015 const gpa = f.object.dg.gpa;5016 const gpa = f.object.dg.gpa;
5016 const liveness = try f.liveness.getSwitchBr(gpa, inst, switch_br.data.cases_len + 1);5017 const liveness = try f.liveness.getSwitchBr(gpa, inst, switch_br.cases_len + 1);
5017 defer gpa.free(liveness.deaths);5018 defer gpa.free(liveness.deaths);
50185019
5019 // On the final iteration we do not need to fix any state. This is because, like in the `else`5020 // On the final iteration we do not need to fix any state. This is because, like in the `else`
5020 // branch of a `cond_br`, our parent has to do it for this entire body anyway.5021 // branch of a `cond_br`, our parent has to do it for this entire body anyway.
5021 const last_case_i = switch_br.data.cases_len - @intFromBool(switch_br.data.else_body_len == 0);5022 const last_case_i = switch_br.cases_len - @intFromBool(switch_br.else_body_len == 0);
5022
5023 var extra_index: usize = switch_br.end;
5024 for (0..switch_br.data.cases_len) |case_i| {
5025 const case = f.air.extraData(Air.SwitchBr.Case, extra_index);
5026 const items = @as([]const Air.Inst.Ref, @ptrCast(f.air.extra[case.end..][0..case.data.items_len]));
5027 const case_body: []const Air.Inst.Index =
5028 @ptrCast(f.air.extra[case.end + items.len ..][0..case.data.body_len]);
5029 extra_index = case.end + case.data.items_len + case_body.len;
50305023
5031 for (items) |item| {5024 var it = switch_br.iterateCases();
5025 while (it.next()) |case| {
5026 for (case.items) |item| {
5032 try f.object.indent_writer.insertNewline();5027 try f.object.indent_writer.insertNewline();
5033 try writer.writeAll("case ");5028 try writer.writeAll("case ");
5034 const item_value = try f.air.value(item, pt);5029 const item_value = try f.air.value(item, pt);
...@@ -5046,19 +5041,19 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5046,19 +5041,19 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
5046 }5041 }
5047 try writer.writeByte(' ');5042 try writer.writeByte(' ');
50485043
5049 if (case_i != last_case_i) {5044 if (case.idx != last_case_i) {
5050 try genBodyResolveState(f, inst, liveness.deaths[case_i], case_body, false);5045 try genBodyResolveState(f, inst, liveness.deaths[case.idx], case.body, false);
5051 } else {5046 } else {
5052 for (liveness.deaths[case_i]) |death| {5047 for (liveness.deaths[case.idx]) |death| {
5053 try die(f, inst, death.toRef());5048 try die(f, inst, death.toRef());
5054 }5049 }
5055 try genBody(f, case_body);5050 try genBody(f, case.body);
5056 }5051 }
50575052
5058 // The case body must be noreturn so we don't need to insert a break.5053 // The case body must be noreturn so we don't need to insert a break.
5059 }5054 }
50605055
5061 const else_body: []const Air.Inst.Index = @ptrCast(f.air.extra[extra_index..][0..switch_br.data.else_body_len]);5056 const else_body = it.elseBody();
5062 try f.object.indent_writer.insertNewline();5057 try f.object.indent_writer.insertNewline();
5063 if (else_body.len > 0) {5058 if (else_body.len > 0) {
5064 // Note that this must be the last case (i.e. the `last_case_i` case was not hit above)5059 // Note that this must be the last case (i.e. the `last_case_i` case was not hit above)
src/codegen/llvm.zig+160-75
...@@ -898,9 +898,9 @@ pub const Object = struct {...@@ -898,9 +898,9 @@ pub const Object = struct {
898 const i32_2 = try builder.intConst(.i32, 2);898 const i32_2 = try builder.intConst(.i32, 2);
899 const i32_3 = try builder.intConst(.i32, 3);899 const i32_3 = try builder.intConst(.i32, 3);
900 const debug_info_version = try builder.debugModuleFlag(900 const debug_info_version = try builder.debugModuleFlag(
901 try builder.debugConstant(i32_2),901 try builder.metadataConstant(i32_2),
902 try builder.metadataString("Debug Info Version"),902 try builder.metadataString("Debug Info Version"),
903 try builder.debugConstant(i32_3),903 try builder.metadataConstant(i32_3),
904 );904 );
905905
906 switch (comp.config.debug_format) {906 switch (comp.config.debug_format) {
...@@ -908,9 +908,9 @@ pub const Object = struct {...@@ -908,9 +908,9 @@ pub const Object = struct {
908 .dwarf => |f| {908 .dwarf => |f| {
909 const i32_4 = try builder.intConst(.i32, 4);909 const i32_4 = try builder.intConst(.i32, 4);
910 const dwarf_version = try builder.debugModuleFlag(910 const dwarf_version = try builder.debugModuleFlag(
911 try builder.debugConstant(i32_2),911 try builder.metadataConstant(i32_2),
912 try builder.metadataString("Dwarf Version"),912 try builder.metadataString("Dwarf Version"),
913 try builder.debugConstant(i32_4),913 try builder.metadataConstant(i32_4),
914 );914 );
915 switch (f) {915 switch (f) {
916 .@"32" => {916 .@"32" => {
...@@ -921,9 +921,9 @@ pub const Object = struct {...@@ -921,9 +921,9 @@ pub const Object = struct {
921 },921 },
922 .@"64" => {922 .@"64" => {
923 const dwarf64 = try builder.debugModuleFlag(923 const dwarf64 = try builder.debugModuleFlag(
924 try builder.debugConstant(i32_2),924 try builder.metadataConstant(i32_2),
925 try builder.metadataString("DWARF64"),925 try builder.metadataString("DWARF64"),
926 try builder.debugConstant(.@"1"),926 try builder.metadataConstant(.@"1"),
927 );927 );
928 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{928 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{
929 debug_info_version,929 debug_info_version,
...@@ -935,9 +935,9 @@ pub const Object = struct {...@@ -935,9 +935,9 @@ pub const Object = struct {
935 },935 },
936 .code_view => {936 .code_view => {
937 const code_view = try builder.debugModuleFlag(937 const code_view = try builder.debugModuleFlag(
938 try builder.debugConstant(i32_2),938 try builder.metadataConstant(i32_2),
939 try builder.metadataString("CodeView"),939 try builder.metadataString("CodeView"),
940 try builder.debugConstant(.@"1"),940 try builder.metadataConstant(.@"1"),
941 );941 );
942 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{942 try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{
943 debug_info_version,943 debug_info_version,
...@@ -1122,12 +1122,12 @@ pub const Object = struct {...@@ -1122,12 +1122,12 @@ pub const Object = struct {
11221122
1123 self.builder.debugForwardReferenceSetType(1123 self.builder.debugForwardReferenceSetType(
1124 self.debug_enums_fwd_ref,1124 self.debug_enums_fwd_ref,
1125 try self.builder.debugTuple(self.debug_enums.items),1125 try self.builder.metadataTuple(self.debug_enums.items),
1126 );1126 );
11271127
1128 self.builder.debugForwardReferenceSetType(1128 self.builder.debugForwardReferenceSetType(
1129 self.debug_globals_fwd_ref,1129 self.debug_globals_fwd_ref,
1130 try self.builder.debugTuple(self.debug_globals.items),1130 try self.builder.metadataTuple(self.debug_globals.items),
1131 );1131 );
1132 }1132 }
1133 }1133 }
...@@ -1369,7 +1369,7 @@ pub const Object = struct {...@@ -1369,7 +1369,7 @@ pub const Object = struct {
1369 _ = try attributes.removeFnAttr(.alignstack);1369 _ = try attributes.removeFnAttr(.alignstack);
1370 }1370 }
13711371
1372 if (func_analysis.is_cold) {1372 if (func_analysis.branch_hint == .cold) {
1373 try attributes.addFnAttr(.cold, &o.builder);1373 try attributes.addFnAttr(.cold, &o.builder);
1374 } else {1374 } else {
1375 _ = try attributes.removeFnAttr(.cold);1375 _ = try attributes.removeFnAttr(.cold);
...@@ -1978,7 +1978,7 @@ pub const Object = struct {...@@ -1978,7 +1978,7 @@ pub const Object = struct {
1978 try o.lowerDebugType(int_ty),1978 try o.lowerDebugType(int_ty),
1979 ty.abiSize(zcu) * 8,1979 ty.abiSize(zcu) * 8,
1980 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,1980 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
1981 try o.builder.debugTuple(enumerators),1981 try o.builder.metadataTuple(enumerators),
1982 );1982 );
19831983
1984 try o.debug_type_map.put(gpa, ty, debug_enum_type);1984 try o.debug_type_map.put(gpa, ty, debug_enum_type);
...@@ -2087,7 +2087,7 @@ pub const Object = struct {...@@ -2087,7 +2087,7 @@ pub const Object = struct {
2087 .none, // Underlying type2087 .none, // Underlying type
2088 ty.abiSize(zcu) * 8,2088 ty.abiSize(zcu) * 8,
2089 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2089 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2090 try o.builder.debugTuple(&.{2090 try o.builder.metadataTuple(&.{
2091 debug_ptr_type,2091 debug_ptr_type,
2092 debug_len_type,2092 debug_len_type,
2093 }),2093 }),
...@@ -2167,10 +2167,10 @@ pub const Object = struct {...@@ -2167,10 +2167,10 @@ pub const Object = struct {
2167 try o.lowerDebugType(ty.childType(zcu)),2167 try o.lowerDebugType(ty.childType(zcu)),
2168 ty.abiSize(zcu) * 8,2168 ty.abiSize(zcu) * 8,
2169 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2169 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2170 try o.builder.debugTuple(&.{2170 try o.builder.metadataTuple(&.{
2171 try o.builder.debugSubrange(2171 try o.builder.debugSubrange(
2172 try o.builder.debugConstant(try o.builder.intConst(.i64, 0)),2172 try o.builder.metadataConstant(try o.builder.intConst(.i64, 0)),
2173 try o.builder.debugConstant(try o.builder.intConst(.i64, ty.arrayLen(zcu))),2173 try o.builder.metadataConstant(try o.builder.intConst(.i64, ty.arrayLen(zcu))),
2174 ),2174 ),
2175 }),2175 }),
2176 );2176 );
...@@ -2210,10 +2210,10 @@ pub const Object = struct {...@@ -2210,10 +2210,10 @@ pub const Object = struct {
2210 debug_elem_type,2210 debug_elem_type,
2211 ty.abiSize(zcu) * 8,2211 ty.abiSize(zcu) * 8,
2212 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2212 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2213 try o.builder.debugTuple(&.{2213 try o.builder.metadataTuple(&.{
2214 try o.builder.debugSubrange(2214 try o.builder.debugSubrange(
2215 try o.builder.debugConstant(try o.builder.intConst(.i64, 0)),2215 try o.builder.metadataConstant(try o.builder.intConst(.i64, 0)),
2216 try o.builder.debugConstant(try o.builder.intConst(.i64, ty.vectorLen(zcu))),2216 try o.builder.metadataConstant(try o.builder.intConst(.i64, ty.vectorLen(zcu))),
2217 ),2217 ),
2218 }),2218 }),
2219 );2219 );
...@@ -2288,7 +2288,7 @@ pub const Object = struct {...@@ -2288,7 +2288,7 @@ pub const Object = struct {
2288 .none, // Underlying type2288 .none, // Underlying type
2289 ty.abiSize(zcu) * 8,2289 ty.abiSize(zcu) * 8,
2290 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2290 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2291 try o.builder.debugTuple(&.{2291 try o.builder.metadataTuple(&.{
2292 debug_data_type,2292 debug_data_type,
2293 debug_some_type,2293 debug_some_type,
2294 }),2294 }),
...@@ -2367,7 +2367,7 @@ pub const Object = struct {...@@ -2367,7 +2367,7 @@ pub const Object = struct {
2367 .none, // Underlying type2367 .none, // Underlying type
2368 ty.abiSize(zcu) * 8,2368 ty.abiSize(zcu) * 8,
2369 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2369 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2370 try o.builder.debugTuple(&fields),2370 try o.builder.metadataTuple(&fields),
2371 );2371 );
23722372
2373 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_error_union_type);2373 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_error_union_type);
...@@ -2447,7 +2447,7 @@ pub const Object = struct {...@@ -2447,7 +2447,7 @@ pub const Object = struct {
2447 .none, // Underlying type2447 .none, // Underlying type
2448 ty.abiSize(zcu) * 8,2448 ty.abiSize(zcu) * 8,
2449 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2449 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2450 try o.builder.debugTuple(fields.items),2450 try o.builder.metadataTuple(fields.items),
2451 );2451 );
24522452
2453 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);2453 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);
...@@ -2520,7 +2520,7 @@ pub const Object = struct {...@@ -2520,7 +2520,7 @@ pub const Object = struct {
2520 .none, // Underlying type2520 .none, // Underlying type
2521 ty.abiSize(zcu) * 8,2521 ty.abiSize(zcu) * 8,
2522 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2522 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2523 try o.builder.debugTuple(fields.items),2523 try o.builder.metadataTuple(fields.items),
2524 );2524 );
25252525
2526 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);2526 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_struct_type);
...@@ -2561,7 +2561,7 @@ pub const Object = struct {...@@ -2561,7 +2561,7 @@ pub const Object = struct {
2561 .none, // Underlying type2561 .none, // Underlying type
2562 ty.abiSize(zcu) * 8,2562 ty.abiSize(zcu) * 8,
2563 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2563 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2564 try o.builder.debugTuple(2564 try o.builder.metadataTuple(
2565 &.{try o.lowerDebugType(Type.fromInterned(union_type.enum_tag_ty))},2565 &.{try o.lowerDebugType(Type.fromInterned(union_type.enum_tag_ty))},
2566 ),2566 ),
2567 );2567 );
...@@ -2623,7 +2623,7 @@ pub const Object = struct {...@@ -2623,7 +2623,7 @@ pub const Object = struct {
2623 .none, // Underlying type2623 .none, // Underlying type
2624 ty.abiSize(zcu) * 8,2624 ty.abiSize(zcu) * 8,
2625 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2625 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2626 try o.builder.debugTuple(fields.items),2626 try o.builder.metadataTuple(fields.items),
2627 );2627 );
26282628
2629 o.builder.debugForwardReferenceSetType(debug_union_fwd_ref, debug_union_type);2629 o.builder.debugForwardReferenceSetType(debug_union_fwd_ref, debug_union_type);
...@@ -2682,7 +2682,7 @@ pub const Object = struct {...@@ -2682,7 +2682,7 @@ pub const Object = struct {
2682 .none, // Underlying type2682 .none, // Underlying type
2683 ty.abiSize(zcu) * 8,2683 ty.abiSize(zcu) * 8,
2684 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,2684 (ty.abiAlignment(zcu).toByteUnits() orelse 0) * 8,
2685 try o.builder.debugTuple(&full_fields),2685 try o.builder.metadataTuple(&full_fields),
2686 );2686 );
26872687
2688 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_tagged_union_type);2688 o.builder.debugForwardReferenceSetType(debug_fwd_ref, debug_tagged_union_type);
...@@ -2735,7 +2735,7 @@ pub const Object = struct {...@@ -2735,7 +2735,7 @@ pub const Object = struct {
2735 }2735 }
27362736
2737 const debug_function_type = try o.builder.debugSubroutineType(2737 const debug_function_type = try o.builder.debugSubroutineType(
2738 try o.builder.debugTuple(debug_param_types.items),2738 try o.builder.metadataTuple(debug_param_types.items),
2739 );2739 );
27402740
2741 try o.debug_type_map.put(gpa, ty, debug_function_type);2741 try o.debug_type_map.put(gpa, ty, debug_function_type);
...@@ -4571,7 +4571,7 @@ pub const Object = struct {...@@ -4571,7 +4571,7 @@ pub const Object = struct {
4571 const bad_value_block = try wip.block(1, "BadValue");4571 const bad_value_block = try wip.block(1, "BadValue");
4572 const tag_int_value = wip.arg(0);4572 const tag_int_value = wip.arg(0);
4573 var wip_switch =4573 var wip_switch =
4574 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len));4574 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len), .none);
4575 defer wip_switch.finish(&wip);4575 defer wip_switch.finish(&wip);
45764576
4577 for (0..enum_type.names.len) |field_index| {4577 for (0..enum_type.names.len) |field_index| {
...@@ -4618,7 +4618,7 @@ pub const NavGen = struct {...@@ -4618,7 +4618,7 @@ pub const NavGen = struct {
4618 }4618 }
46194619
4620 fn todo(ng: *NavGen, comptime format: []const u8, args: anytype) Error {4620 fn todo(ng: *NavGen, comptime format: []const u8, args: anytype) Error {
4621 @setCold(true);4621 @branchHint(.cold);
4622 assert(ng.err_msg == null);4622 assert(ng.err_msg == null);
4623 const o = ng.object;4623 const o = ng.object;
4624 const gpa = o.gpa;4624 const gpa = o.gpa;
...@@ -4784,7 +4784,7 @@ pub const FuncGen = struct {...@@ -4784,7 +4784,7 @@ pub const FuncGen = struct {
4784 }4784 }
47854785
4786 fn todo(self: *FuncGen, comptime format: []const u8, args: anytype) Error {4786 fn todo(self: *FuncGen, comptime format: []const u8, args: anytype) Error {
4787 @setCold(true);4787 @branchHint(.cold);
4788 return self.ng.todo(format, args);4788 return self.ng.todo(format, args);
4789 }4789 }
47904790
...@@ -4958,8 +4958,10 @@ pub const FuncGen = struct {...@@ -4958,8 +4958,10 @@ pub const FuncGen = struct {
4958 .ret_addr => try self.airRetAddr(inst),4958 .ret_addr => try self.airRetAddr(inst),
4959 .frame_addr => try self.airFrameAddress(inst),4959 .frame_addr => try self.airFrameAddress(inst),
4960 .cond_br => try self.airCondBr(inst),4960 .cond_br => try self.airCondBr(inst),
4961 .@"try" => try self.airTry(body[i..]),4961 .@"try" => try self.airTry(body[i..], false),
4962 .try_ptr => try self.airTryPtr(inst),4962 .try_cold => try self.airTry(body[i..], true),
4963 .try_ptr => try self.airTryPtr(inst, false),
4964 .try_ptr_cold => try self.airTryPtr(inst, true),
4963 .intcast => try self.airIntCast(inst),4965 .intcast => try self.airIntCast(inst),
4964 .trunc => try self.airTrunc(inst),4966 .trunc => try self.airTrunc(inst),
4965 .fptrunc => try self.airFptrunc(inst),4967 .fptrunc => try self.airFptrunc(inst),
...@@ -5506,6 +5508,7 @@ pub const FuncGen = struct {...@@ -5506,6 +5508,7 @@ pub const FuncGen = struct {
5506 const panic_nav = ip.getNav(panic_func.owner_nav);5508 const panic_nav = ip.getNav(panic_func.owner_nav);
5507 const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?;5509 const fn_info = zcu.typeToFunc(Type.fromInterned(panic_nav.typeOf(ip))).?;
5508 const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav);5510 const panic_global = try o.resolveLlvmFunction(panic_func.owner_nav);
5511 _ = try fg.wip.callIntrinsicAssumeCold();
5509 _ = try fg.wip.call(5512 _ = try fg.wip.call(
5510 .normal,5513 .normal,
5511 toLlvmCallConv(fn_info.cc, target),5514 toLlvmCallConv(fn_info.cc, target),
...@@ -5794,7 +5797,7 @@ pub const FuncGen = struct {...@@ -5794,7 +5797,7 @@ pub const FuncGen = struct {
5794 const mixed_block = try self.wip.block(1, "Mixed");5797 const mixed_block = try self.wip.block(1, "Mixed");
5795 const both_pl_block = try self.wip.block(1, "BothNonNull");5798 const both_pl_block = try self.wip.block(1, "BothNonNull");
5796 const end_block = try self.wip.block(3, "End");5799 const end_block = try self.wip.block(3, "End");
5797 var wip_switch = try self.wip.@"switch"(lhs_rhs_ored, mixed_block, 2);5800 var wip_switch = try self.wip.@"switch"(lhs_rhs_ored, mixed_block, 2, .none);
5798 defer wip_switch.finish(&self.wip);5801 defer wip_switch.finish(&self.wip);
5799 try wip_switch.addCase(5802 try wip_switch.addCase(
5800 try o.builder.intConst(llvm_i2, 0b00),5803 try o.builder.intConst(llvm_i2, 0b00),
...@@ -5948,21 +5951,62 @@ pub const FuncGen = struct {...@@ -5948,21 +5951,62 @@ pub const FuncGen = struct {
5948 const then_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.then_body_len]);5951 const then_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.then_body_len]);
5949 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]);5952 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]);
59505953
5954 const Hint = enum {
5955 none,
5956 unpredictable,
5957 then_likely,
5958 else_likely,
5959 then_cold,
5960 else_cold,
5961 };
5962 const hint: Hint = switch (extra.data.branch_hints.true) {
5963 .none => switch (extra.data.branch_hints.false) {
5964 .none => .none,
5965 .likely => .else_likely,
5966 .unlikely => .then_likely,
5967 .cold => .else_cold,
5968 .unpredictable => .unpredictable,
5969 },
5970 .likely => switch (extra.data.branch_hints.false) {
5971 .none => .then_likely,
5972 .likely => .unpredictable,
5973 .unlikely => .then_likely,
5974 .cold => .else_cold,
5975 .unpredictable => .unpredictable,
5976 },
5977 .unlikely => switch (extra.data.branch_hints.false) {
5978 .none => .else_likely,
5979 .likely => .else_likely,
5980 .unlikely => .unpredictable,
5981 .cold => .else_cold,
5982 .unpredictable => .unpredictable,
5983 },
5984 .cold => .then_cold,
5985 .unpredictable => .unpredictable,
5986 };
5987
5951 const then_block = try self.wip.block(1, "Then");5988 const then_block = try self.wip.block(1, "Then");
5952 const else_block = try self.wip.block(1, "Else");5989 const else_block = try self.wip.block(1, "Else");
5953 _ = try self.wip.brCond(cond, then_block, else_block);5990 _ = try self.wip.brCond(cond, then_block, else_block, switch (hint) {
5991 .none, .then_cold, .else_cold => .none,
5992 .unpredictable => .unpredictable,
5993 .then_likely => .then_likely,
5994 .else_likely => .else_likely,
5995 });
59545996
5955 self.wip.cursor = .{ .block = then_block };5997 self.wip.cursor = .{ .block = then_block };
5998 if (hint == .then_cold) _ = try self.wip.callIntrinsicAssumeCold();
5956 try self.genBodyDebugScope(null, then_body);5999 try self.genBodyDebugScope(null, then_body);
59576000
5958 self.wip.cursor = .{ .block = else_block };6001 self.wip.cursor = .{ .block = else_block };
6002 if (hint == .else_cold) _ = try self.wip.callIntrinsicAssumeCold();
5959 try self.genBodyDebugScope(null, else_body);6003 try self.genBodyDebugScope(null, else_body);
59606004
5961 // No need to reset the insert cursor since this instruction is noreturn.6005 // No need to reset the insert cursor since this instruction is noreturn.
5962 return .none;6006 return .none;
5963 }6007 }
59646008
5965 fn airTry(self: *FuncGen, body_tail: []const Air.Inst.Index) !Builder.Value {6009 fn airTry(self: *FuncGen, body_tail: []const Air.Inst.Index, err_cold: bool) !Builder.Value {
5966 const o = self.ng.object;6010 const o = self.ng.object;
5967 const pt = o.pt;6011 const pt = o.pt;
5968 const zcu = pt.zcu;6012 const zcu = pt.zcu;
...@@ -5975,10 +6019,10 @@ pub const FuncGen = struct {...@@ -5975,10 +6019,10 @@ pub const FuncGen = struct {
5975 const payload_ty = self.typeOfIndex(inst);6019 const payload_ty = self.typeOfIndex(inst);
5976 const can_elide_load = if (isByRef(payload_ty, zcu)) self.canElideLoad(body_tail) else false;6020 const can_elide_load = if (isByRef(payload_ty, zcu)) self.canElideLoad(body_tail) else false;
5977 const is_unused = self.liveness.isUnused(inst);6021 const is_unused = self.liveness.isUnused(inst);
5978 return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, is_unused);6022 return lowerTry(self, err_union, body, err_union_ty, false, can_elide_load, is_unused, err_cold);
5979 }6023 }
59806024
5981 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {6025 fn airTryPtr(self: *FuncGen, inst: Air.Inst.Index, err_cold: bool) !Builder.Value {
5982 const o = self.ng.object;6026 const o = self.ng.object;
5983 const zcu = o.pt.zcu;6027 const zcu = o.pt.zcu;
5984 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6028 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
...@@ -5987,7 +6031,7 @@ pub const FuncGen = struct {...@@ -5987,7 +6031,7 @@ pub const FuncGen = struct {
5987 const body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);6031 const body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]);
5988 const err_union_ty = self.typeOf(extra.data.ptr).childType(zcu);6032 const err_union_ty = self.typeOf(extra.data.ptr).childType(zcu);
5989 const is_unused = self.liveness.isUnused(inst);6033 const is_unused = self.liveness.isUnused(inst);
5990 return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, is_unused);6034 return lowerTry(self, err_union_ptr, body, err_union_ty, true, true, is_unused, err_cold);
5991 }6035 }
59926036
5993 fn lowerTry(6037 fn lowerTry(
...@@ -5998,6 +6042,7 @@ pub const FuncGen = struct {...@@ -5998,6 +6042,7 @@ pub const FuncGen = struct {
5998 operand_is_ptr: bool,6042 operand_is_ptr: bool,
5999 can_elide_load: bool,6043 can_elide_load: bool,
6000 is_unused: bool,6044 is_unused: bool,
6045 err_cold: bool,
6001 ) !Builder.Value {6046 ) !Builder.Value {
6002 const o = fg.ng.object;6047 const o = fg.ng.object;
6003 const pt = o.pt;6048 const pt = o.pt;
...@@ -6036,9 +6081,10 @@ pub const FuncGen = struct {...@@ -6036,9 +6081,10 @@ pub const FuncGen = struct {
60366081
6037 const return_block = try fg.wip.block(1, "TryRet");6082 const return_block = try fg.wip.block(1, "TryRet");
6038 const continue_block = try fg.wip.block(1, "TryCont");6083 const continue_block = try fg.wip.block(1, "TryCont");
6039 _ = try fg.wip.brCond(is_err, return_block, continue_block);6084 _ = try fg.wip.brCond(is_err, return_block, continue_block, if (err_cold) .none else .else_likely);
60406085
6041 fg.wip.cursor = .{ .block = return_block };6086 fg.wip.cursor = .{ .block = return_block };
6087 if (err_cold) _ = try fg.wip.callIntrinsicAssumeCold();
6042 try fg.genBodyDebugScope(null, body);6088 try fg.genBodyDebugScope(null, body);
60436089
6044 fg.wip.cursor = .{ .block = continue_block };6090 fg.wip.cursor = .{ .block = continue_block };
...@@ -6065,9 +6111,11 @@ pub const FuncGen = struct {...@@ -6065,9 +6111,11 @@ pub const FuncGen = struct {
60656111
6066 fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {6112 fn airSwitchBr(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
6067 const o = self.ng.object;6113 const o = self.ng.object;
6068 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6114
6069 const cond = try self.resolveInst(pl_op.operand);6115 const switch_br = self.air.unwrapSwitch(inst);
6070 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);6116
6117 const cond = try self.resolveInst(switch_br.operand);
6118
6071 const else_block = try self.wip.block(1, "Default");6119 const else_block = try self.wip.block(1, "Default");
6072 const llvm_usize = try o.lowerType(Type.usize);6120 const llvm_usize = try o.lowerType(Type.usize);
6073 const cond_int = if (cond.typeOfWip(&self.wip).isPointer(&o.builder))6121 const cond_int = if (cond.typeOfWip(&self.wip).isPointer(&o.builder))
...@@ -6075,34 +6123,70 @@ pub const FuncGen = struct {...@@ -6075,34 +6123,70 @@ pub const FuncGen = struct {
6075 else6123 else
6076 cond;6124 cond;
60776125
6078 var extra_index: usize = switch_br.end;6126 const llvm_cases_len = llvm_cases_len: {
6079 var case_i: u32 = 0;6127 var len: u32 = 0;
6080 var llvm_cases_len: u32 = 0;6128 var it = switch_br.iterateCases();
6081 while (case_i < switch_br.data.cases_len) : (case_i += 1) {6129 while (it.next()) |case| len += @intCast(case.items.len);
6082 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);6130 break :llvm_cases_len len;
6083 const items: []const Air.Inst.Ref =6131 };
6084 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);6132
6085 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];6133 const weights: Builder.Function.Instruction.BrCond.Weights = weights: {
6086 extra_index = case.end + case.data.items_len + case_body.len;6134 // First pass. If any weights are `.unpredictable`, unpredictable.
6135 // If all are `.none` or `.cold`, none.
6136 var any_likely = false;
6137 for (0..switch_br.cases_len) |case_idx| {
6138 switch (switch_br.getHint(@intCast(case_idx))) {
6139 .none, .cold => {},
6140 .likely, .unlikely => any_likely = true,
6141 .unpredictable => break :weights .unpredictable,
6142 }
6143 }
6144 switch (switch_br.getElseHint()) {
6145 .none, .cold => {},
6146 .likely, .unlikely => any_likely = true,
6147 .unpredictable => break :weights .unpredictable,
6148 }
6149 if (!any_likely) break :weights .none;
60876150
6088 llvm_cases_len += @intCast(items.len);6151 var weights = try self.gpa.alloc(Builder.Metadata, llvm_cases_len + 1);
6089 }6152 defer self.gpa.free(weights);
60906153
6091 var wip_switch = try self.wip.@"switch"(cond_int, else_block, llvm_cases_len);6154 const else_weight: u32 = switch (switch_br.getElseHint()) {
6092 defer wip_switch.finish(&self.wip);6155 .unpredictable => unreachable,
6156 .none, .cold => 1000,
6157 .likely => 2000,
6158 .unlikely => 1,
6159 };
6160 weights[0] = try o.builder.metadataConstant(try o.builder.intConst(.i32, else_weight));
6161
6162 var weight_idx: usize = 1;
6163 var it = switch_br.iterateCases();
6164 while (it.next()) |case| {
6165 const weight_val: u32 = switch (switch_br.getHint(case.idx)) {
6166 .unpredictable => unreachable,
6167 .none, .cold => 1000,
6168 .likely => 2000,
6169 .unlikely => 1,
6170 };
6171 const weight_meta = try o.builder.metadataConstant(try o.builder.intConst(.i32, weight_val));
6172 @memset(weights[weight_idx..][0..case.items.len], weight_meta);
6173 weight_idx += case.items.len;
6174 }
6175
6176 assert(weight_idx == weights.len);
60936177
6094 extra_index = switch_br.end;6178 const branch_weights_str = try o.builder.metadataString("branch_weights");
6095 case_i = 0;6179 const tuple = try o.builder.strTuple(branch_weights_str, weights);
6096 while (case_i < switch_br.data.cases_len) : (case_i += 1) {6180 break :weights @enumFromInt(@intFromEnum(tuple));
6097 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);6181 };
6098 const items: []const Air.Inst.Ref =
6099 @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6100 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
6101 extra_index = case.end + case.data.items_len + case_body.len;
61026182
6103 const case_block = try self.wip.block(@intCast(items.len), "Case");6183 var wip_switch = try self.wip.@"switch"(cond_int, else_block, llvm_cases_len, weights);
6184 defer wip_switch.finish(&self.wip);
61046185
6105 for (items) |item| {6186 var it = switch_br.iterateCases();
6187 while (it.next()) |case| {
6188 const case_block = try self.wip.block(@intCast(case.items.len), "Case");
6189 for (case.items) |item| {
6106 const llvm_item = (try self.resolveInst(item)).toConst().?;6190 const llvm_item = (try self.resolveInst(item)).toConst().?;
6107 const llvm_int_item = if (llvm_item.typeOf(&o.builder).isPointer(&o.builder))6191 const llvm_int_item = if (llvm_item.typeOf(&o.builder).isPointer(&o.builder))
6108 try o.builder.castConst(.ptrtoint, llvm_item, llvm_usize)6192 try o.builder.castConst(.ptrtoint, llvm_item, llvm_usize)
...@@ -6110,13 +6194,14 @@ pub const FuncGen = struct {...@@ -6110,13 +6194,14 @@ pub const FuncGen = struct {
6110 llvm_item;6194 llvm_item;
6111 try wip_switch.addCase(llvm_int_item, case_block, &self.wip);6195 try wip_switch.addCase(llvm_int_item, case_block, &self.wip);
6112 }6196 }
6113
6114 self.wip.cursor = .{ .block = case_block };6197 self.wip.cursor = .{ .block = case_block };
6115 try self.genBodyDebugScope(null, case_body);6198 if (switch_br.getHint(case.idx) == .cold) _ = try self.wip.callIntrinsicAssumeCold();
6199 try self.genBodyDebugScope(null, case.body);
6116 }6200 }
61176201
6202 const else_body = it.elseBody();
6118 self.wip.cursor = .{ .block = else_block };6203 self.wip.cursor = .{ .block = else_block };
6119 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);6204 if (switch_br.getElseHint() == .cold) _ = try self.wip.callIntrinsicAssumeCold();
6120 if (else_body.len != 0) {6205 if (else_body.len != 0) {
6121 try self.genBodyDebugScope(null, else_body);6206 try self.genBodyDebugScope(null, else_body);
6122 } else {6207 } else {
...@@ -7748,7 +7833,7 @@ pub const FuncGen = struct {...@@ -7748,7 +7833,7 @@ pub const FuncGen = struct {
77487833
7749 const fail_block = try fg.wip.block(1, "OverflowFail");7834 const fail_block = try fg.wip.block(1, "OverflowFail");
7750 const ok_block = try fg.wip.block(1, "OverflowOk");7835 const ok_block = try fg.wip.block(1, "OverflowOk");
7751 _ = try fg.wip.brCond(overflow_bit, fail_block, ok_block);7836 _ = try fg.wip.brCond(overflow_bit, fail_block, ok_block, .none);
77527837
7753 fg.wip.cursor = .{ .block = fail_block };7838 fg.wip.cursor = .{ .block = fail_block };
7754 try fg.buildSimplePanic(.integer_overflow);7839 try fg.buildSimplePanic(.integer_overflow);
...@@ -9389,7 +9474,7 @@ pub const FuncGen = struct {...@@ -9389,7 +9474,7 @@ pub const FuncGen = struct {
9389 self.wip.cursor = .{ .block = loop_block };9474 self.wip.cursor = .{ .block = loop_block };
9390 const it_ptr = try self.wip.phi(.ptr, "");9475 const it_ptr = try self.wip.phi(.ptr, "");
9391 const end = try self.wip.icmp(.ne, it_ptr.toValue(), end_ptr, "");9476 const end = try self.wip.icmp(.ne, it_ptr.toValue(), end_ptr, "");
9392 _ = try self.wip.brCond(end, body_block, end_block);9477 _ = try self.wip.brCond(end, body_block, end_block, .none);
93939478
9394 self.wip.cursor = .{ .block = body_block };9479 self.wip.cursor = .{ .block = body_block };
9395 const elem_abi_align = elem_ty.abiAlignment(zcu);9480 const elem_abi_align = elem_ty.abiAlignment(zcu);
...@@ -9427,7 +9512,7 @@ pub const FuncGen = struct {...@@ -9427,7 +9512,7 @@ pub const FuncGen = struct {
9427 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);9512 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);
9428 const memset_block = try self.wip.block(1, "MemsetTrapSkip");9513 const memset_block = try self.wip.block(1, "MemsetTrapSkip");
9429 const end_block = try self.wip.block(2, "MemsetTrapEnd");9514 const end_block = try self.wip.block(2, "MemsetTrapEnd");
9430 _ = try self.wip.brCond(cond, memset_block, end_block);9515 _ = try self.wip.brCond(cond, memset_block, end_block, .none);
9431 self.wip.cursor = .{ .block = memset_block };9516 self.wip.cursor = .{ .block = memset_block };
9432 _ = try self.wip.callMemSet(dest_ptr, dest_ptr_align, fill_byte, len, access_kind);9517 _ = try self.wip.callMemSet(dest_ptr, dest_ptr_align, fill_byte, len, access_kind);
9433 _ = try self.wip.br(end_block);9518 _ = try self.wip.br(end_block);
...@@ -9462,7 +9547,7 @@ pub const FuncGen = struct {...@@ -9462,7 +9547,7 @@ pub const FuncGen = struct {
9462 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);9547 const cond = try self.cmp(.normal, .neq, Type.usize, len, usize_zero);
9463 const memcpy_block = try self.wip.block(1, "MemcpyTrapSkip");9548 const memcpy_block = try self.wip.block(1, "MemcpyTrapSkip");
9464 const end_block = try self.wip.block(2, "MemcpyTrapEnd");9549 const end_block = try self.wip.block(2, "MemcpyTrapEnd");
9465 _ = try self.wip.brCond(cond, memcpy_block, end_block);9550 _ = try self.wip.brCond(cond, memcpy_block, end_block, .none);
9466 self.wip.cursor = .{ .block = memcpy_block };9551 self.wip.cursor = .{ .block = memcpy_block };
9467 _ = try self.wip.callMemCpy(9552 _ = try self.wip.callMemCpy(
9468 dest_ptr,9553 dest_ptr,
...@@ -9632,7 +9717,7 @@ pub const FuncGen = struct {...@@ -9632,7 +9717,7 @@ pub const FuncGen = struct {
9632 const valid_block = try self.wip.block(@intCast(names.len), "Valid");9717 const valid_block = try self.wip.block(@intCast(names.len), "Valid");
9633 const invalid_block = try self.wip.block(1, "Invalid");9718 const invalid_block = try self.wip.block(1, "Invalid");
9634 const end_block = try self.wip.block(2, "End");9719 const end_block = try self.wip.block(2, "End");
9635 var wip_switch = try self.wip.@"switch"(operand, invalid_block, @intCast(names.len));9720 var wip_switch = try self.wip.@"switch"(operand, invalid_block, @intCast(names.len), .none);
9636 defer wip_switch.finish(&self.wip);9721 defer wip_switch.finish(&self.wip);
96379722
9638 for (0..names.len) |name_index| {9723 for (0..names.len) |name_index| {
...@@ -9708,7 +9793,7 @@ pub const FuncGen = struct {...@@ -9708,7 +9793,7 @@ pub const FuncGen = struct {
9708 const named_block = try wip.block(@intCast(enum_type.names.len), "Named");9793 const named_block = try wip.block(@intCast(enum_type.names.len), "Named");
9709 const unnamed_block = try wip.block(1, "Unnamed");9794 const unnamed_block = try wip.block(1, "Unnamed");
9710 const tag_int_value = wip.arg(0);9795 const tag_int_value = wip.arg(0);
9711 var wip_switch = try wip.@"switch"(tag_int_value, unnamed_block, @intCast(enum_type.names.len));9796 var wip_switch = try wip.@"switch"(tag_int_value, unnamed_block, @intCast(enum_type.names.len), .none);
9712 defer wip_switch.finish(&wip);9797 defer wip_switch.finish(&wip);
97139798
9714 for (0..enum_type.names.len) |field_index| {9799 for (0..enum_type.names.len) |field_index| {
...@@ -9858,7 +9943,7 @@ pub const FuncGen = struct {...@@ -9858,7 +9943,7 @@ pub const FuncGen = struct {
9858 const cond = try self.wip.icmp(.ult, i, llvm_vector_len, "");9943 const cond = try self.wip.icmp(.ult, i, llvm_vector_len, "");
9859 const loop_then = try self.wip.block(1, "ReduceLoopThen");9944 const loop_then = try self.wip.block(1, "ReduceLoopThen");
98609945
9861 _ = try self.wip.brCond(cond, loop_then, loop_exit);9946 _ = try self.wip.brCond(cond, loop_then, loop_exit, .none);
98629947
9863 {9948 {
9864 self.wip.cursor = .{ .block = loop_then };9949 self.wip.cursor = .{ .block = loop_then };
src/codegen/llvm/Builder.zig+316-101
...@@ -4817,12 +4817,22 @@ pub const Function = struct {...@@ -4817,12 +4817,22 @@ pub const Function = struct {
4817 cond: Value,4817 cond: Value,
4818 then: Block.Index,4818 then: Block.Index,
4819 @"else": Block.Index,4819 @"else": Block.Index,
4820 weights: Weights,
4821 pub const Weights = enum(u32) {
4822 // We can do this as metadata indices 0 and 1 are reserved.
4823 none = 0,
4824 unpredictable = 1,
4825 /// These values should be converted to `Metadata` to be used
4826 /// in a `prof` annotation providing branch weights.
4827 _,
4828 };
4820 };4829 };
48214830
4822 pub const Switch = struct {4831 pub const Switch = struct {
4823 val: Value,4832 val: Value,
4824 default: Block.Index,4833 default: Block.Index,
4825 cases_len: u32,4834 cases_len: u32,
4835 weights: BrCond.Weights,
4826 //case_vals: [cases_len]Constant,4836 //case_vals: [cases_len]Constant,
4827 //case_blocks: [cases_len]Block.Index,4837 //case_blocks: [cases_len]Block.Index,
4828 };4838 };
...@@ -4969,7 +4979,8 @@ pub const Function = struct {...@@ -4969,7 +4979,8 @@ pub const Function = struct {
4969 };4979 };
4970 pub const Info = packed struct(u32) {4980 pub const Info = packed struct(u32) {
4971 call_conv: CallConv,4981 call_conv: CallConv,
4972 _: u22 = undefined,4982 has_op_bundle_cold: bool,
4983 _: u21 = undefined,
4973 };4984 };
4974 };4985 };
49754986
...@@ -5036,6 +5047,7 @@ pub const Function = struct {...@@ -5036,6 +5047,7 @@ pub const Function = struct {
5036 FunctionAttributes,5047 FunctionAttributes,
5037 Type,5048 Type,
5038 Value,5049 Value,
5050 Instruction.BrCond.Weights,
5039 => @enumFromInt(value),5051 => @enumFromInt(value),
5040 MemoryAccessInfo,5052 MemoryAccessInfo,
5041 Instruction.Alloca.Info,5053 Instruction.Alloca.Info,
...@@ -5201,6 +5213,7 @@ pub const WipFunction = struct {...@@ -5201,6 +5213,7 @@ pub const WipFunction = struct {
5201 cond: Value,5213 cond: Value,
5202 then: Block.Index,5214 then: Block.Index,
5203 @"else": Block.Index,5215 @"else": Block.Index,
5216 weights: enum { none, unpredictable, then_likely, else_likely },
5204 ) Allocator.Error!Instruction.Index {5217 ) Allocator.Error!Instruction.Index {
5205 assert(cond.typeOfWip(self) == .i1);5218 assert(cond.typeOfWip(self) == .i1);
5206 try self.ensureUnusedExtraCapacity(1, Instruction.BrCond, 0);5219 try self.ensureUnusedExtraCapacity(1, Instruction.BrCond, 0);
...@@ -5210,6 +5223,22 @@ pub const WipFunction = struct {...@@ -5210,6 +5223,22 @@ pub const WipFunction = struct {
5210 .cond = cond,5223 .cond = cond,
5211 .then = then,5224 .then = then,
5212 .@"else" = @"else",5225 .@"else" = @"else",
5226 .weights = switch (weights) {
5227 .none => .none,
5228 .unpredictable => .unpredictable,
5229 .then_likely, .else_likely => w: {
5230 const branch_weights_str = try self.builder.metadataString("branch_weights");
5231 const unlikely_const = try self.builder.metadataConstant(try self.builder.intConst(.i32, 1));
5232 const likely_const = try self.builder.metadataConstant(try self.builder.intConst(.i32, 2000));
5233 const weight_vals: [2]Metadata = switch (weights) {
5234 .none, .unpredictable => unreachable,
5235 .then_likely => .{ likely_const, unlikely_const },
5236 .else_likely => .{ unlikely_const, likely_const },
5237 };
5238 const tuple = try self.builder.strTuple(branch_weights_str, &weight_vals);
5239 break :w @enumFromInt(@intFromEnum(tuple));
5240 },
5241 },
5213 }),5242 }),
5214 });5243 });
5215 then.ptr(self).branches += 1;5244 then.ptr(self).branches += 1;
...@@ -5248,6 +5277,7 @@ pub const WipFunction = struct {...@@ -5248,6 +5277,7 @@ pub const WipFunction = struct {
5248 val: Value,5277 val: Value,
5249 default: Block.Index,5278 default: Block.Index,
5250 cases_len: u32,5279 cases_len: u32,
5280 weights: Instruction.BrCond.Weights,
5251 ) Allocator.Error!WipSwitch {5281 ) Allocator.Error!WipSwitch {
5252 try self.ensureUnusedExtraCapacity(1, Instruction.Switch, cases_len * 2);5282 try self.ensureUnusedExtraCapacity(1, Instruction.Switch, cases_len * 2);
5253 const instruction = try self.addInst(null, .{5283 const instruction = try self.addInst(null, .{
...@@ -5256,6 +5286,7 @@ pub const WipFunction = struct {...@@ -5256,6 +5286,7 @@ pub const WipFunction = struct {
5256 .val = val,5286 .val = val,
5257 .default = default,5287 .default = default,
5258 .cases_len = cases_len,5288 .cases_len = cases_len,
5289 .weights = weights,
5259 }),5290 }),
5260 });5291 });
5261 _ = self.extra.addManyAsSliceAssumeCapacity(cases_len * 2);5292 _ = self.extra.addManyAsSliceAssumeCapacity(cases_len * 2);
...@@ -5895,6 +5926,20 @@ pub const WipFunction = struct {...@@ -5895,6 +5926,20 @@ pub const WipFunction = struct {
5895 callee: Value,5926 callee: Value,
5896 args: []const Value,5927 args: []const Value,
5897 name: []const u8,5928 name: []const u8,
5929 ) Allocator.Error!Value {
5930 return self.callInner(kind, call_conv, function_attributes, ty, callee, args, name, false);
5931 }
5932
5933 fn callInner(
5934 self: *WipFunction,
5935 kind: Instruction.Call.Kind,
5936 call_conv: CallConv,
5937 function_attributes: FunctionAttributes,
5938 ty: Type,
5939 callee: Value,
5940 args: []const Value,
5941 name: []const u8,
5942 has_op_bundle_cold: bool,
5898 ) Allocator.Error!Value {5943 ) Allocator.Error!Value {
5899 const ret_ty = ty.functionReturn(self.builder);5944 const ret_ty = ty.functionReturn(self.builder);
5900 assert(ty.isFunction(self.builder));5945 assert(ty.isFunction(self.builder));
...@@ -5918,7 +5963,10 @@ pub const WipFunction = struct {...@@ -5918,7 +5963,10 @@ pub const WipFunction = struct {
5918 .tail_fast => .@"tail call fast",5963 .tail_fast => .@"tail call fast",
5919 },5964 },
5920 .data = self.addExtraAssumeCapacity(Instruction.Call{5965 .data = self.addExtraAssumeCapacity(Instruction.Call{
5921 .info = .{ .call_conv = call_conv },5966 .info = .{
5967 .call_conv = call_conv,
5968 .has_op_bundle_cold = has_op_bundle_cold,
5969 },
5922 .attributes = function_attributes,5970 .attributes = function_attributes,
5923 .ty = ty,5971 .ty = ty,
5924 .callee = callee,5972 .callee = callee,
...@@ -5964,6 +6012,20 @@ pub const WipFunction = struct {...@@ -5964,6 +6012,20 @@ pub const WipFunction = struct {
5964 );6012 );
5965 }6013 }
59666014
6015 pub fn callIntrinsicAssumeCold(self: *WipFunction) Allocator.Error!Value {
6016 const intrinsic = try self.builder.getIntrinsic(.assume, &.{});
6017 return self.callInner(
6018 .normal,
6019 CallConv.default,
6020 .none,
6021 intrinsic.typeOf(self.builder),
6022 intrinsic.toValue(self.builder),
6023 &.{try self.builder.intValue(.i1, 1)},
6024 "",
6025 true,
6026 );
6027 }
6028
5967 pub fn callMemCpy(6029 pub fn callMemCpy(
5968 self: *WipFunction,6030 self: *WipFunction,
5969 dst: Value,6031 dst: Value,
...@@ -6040,7 +6102,7 @@ pub const WipFunction = struct {...@@ -6040,7 +6102,7 @@ pub const WipFunction = struct {
60406102
6041 break :blk metadata;6103 break :blk metadata;
6042 },6104 },
6043 .constant => |constant| try self.builder.debugConstant(constant),6105 .constant => |constant| try self.builder.metadataConstant(constant),
6044 .metadata => |metadata| metadata,6106 .metadata => |metadata| metadata,
6045 };6107 };
6046 }6108 }
...@@ -6099,6 +6161,7 @@ pub const WipFunction = struct {...@@ -6099,6 +6161,7 @@ pub const WipFunction = struct {
6099 FunctionAttributes,6161 FunctionAttributes,
6100 Type,6162 Type,
6101 Value,6163 Value,
6164 Instruction.BrCond.Weights,
6102 => @intFromEnum(value),6165 => @intFromEnum(value),
6103 MemoryAccessInfo,6166 MemoryAccessInfo,
6104 Instruction.Alloca.Info,6167 Instruction.Alloca.Info,
...@@ -6380,6 +6443,7 @@ pub const WipFunction = struct {...@@ -6380,6 +6443,7 @@ pub const WipFunction = struct {
6380 .cond = instructions.map(extra.cond),6443 .cond = instructions.map(extra.cond),
6381 .then = extra.then,6444 .then = extra.then,
6382 .@"else" = extra.@"else",6445 .@"else" = extra.@"else",
6446 .weights = extra.weights,
6383 });6447 });
6384 },6448 },
6385 .call,6449 .call,
...@@ -6522,6 +6586,7 @@ pub const WipFunction = struct {...@@ -6522,6 +6586,7 @@ pub const WipFunction = struct {
6522 .val = instructions.map(extra.data.val),6586 .val = instructions.map(extra.data.val),
6523 .default = extra.data.default,6587 .default = extra.data.default,
6524 .cases_len = extra.data.cases_len,6588 .cases_len = extra.data.cases_len,
6589 .weights = extra.data.weights,
6525 });6590 });
6526 wip_extra.appendSlice(case_vals);6591 wip_extra.appendSlice(case_vals);
6527 wip_extra.appendSlice(case_blocks);6592 wip_extra.appendSlice(case_blocks);
...@@ -6744,6 +6809,7 @@ pub const WipFunction = struct {...@@ -6744,6 +6809,7 @@ pub const WipFunction = struct {
6744 FunctionAttributes,6809 FunctionAttributes,
6745 Type,6810 Type,
6746 Value,6811 Value,
6812 Instruction.BrCond.Weights,
6747 => @intFromEnum(value),6813 => @intFromEnum(value),
6748 MemoryAccessInfo,6814 MemoryAccessInfo,
6749 Instruction.Alloca.Info,6815 Instruction.Alloca.Info,
...@@ -6792,6 +6858,7 @@ pub const WipFunction = struct {...@@ -6792,6 +6858,7 @@ pub const WipFunction = struct {
6792 FunctionAttributes,6858 FunctionAttributes,
6793 Type,6859 Type,
6794 Value,6860 Value,
6861 Instruction.BrCond.Weights,
6795 => @enumFromInt(value),6862 => @enumFromInt(value),
6796 MemoryAccessInfo,6863 MemoryAccessInfo,
6797 Instruction.Alloca.Info,6864 Instruction.Alloca.Info,
...@@ -7697,6 +7764,7 @@ pub const MetadataString = enum(u32) {...@@ -7697,6 +7764,7 @@ pub const MetadataString = enum(u32) {
76977764
7698pub const Metadata = enum(u32) {7765pub const Metadata = enum(u32) {
7699 none = 0,7766 none = 0,
7767 empty_tuple = 1,
7700 _,7768 _,
77017769
7702 const first_forward_reference = 1 << 29;7770 const first_forward_reference = 1 << 29;
...@@ -7734,6 +7802,7 @@ pub const Metadata = enum(u32) {...@@ -7734,6 +7802,7 @@ pub const Metadata = enum(u32) {
7734 enumerator_signed_negative,7802 enumerator_signed_negative,
7735 subrange,7803 subrange,
7736 tuple,7804 tuple,
7805 str_tuple,
7737 module_flag,7806 module_flag,
7738 expression,7807 expression,
7739 local_var,7808 local_var,
...@@ -7779,6 +7848,7 @@ pub const Metadata = enum(u32) {...@@ -7779,6 +7848,7 @@ pub const Metadata = enum(u32) {
7779 .enumerator_signed_negative,7848 .enumerator_signed_negative,
7780 .subrange,7849 .subrange,
7781 .tuple,7850 .tuple,
7851 .str_tuple,
7782 .module_flag,7852 .module_flag,
7783 .local_var,7853 .local_var,
7784 .parameter,7854 .parameter,
...@@ -8043,6 +8113,13 @@ pub const Metadata = enum(u32) {...@@ -8043,6 +8113,13 @@ pub const Metadata = enum(u32) {
8043 // elements: [elements_len]Metadata8113 // elements: [elements_len]Metadata
8044 };8114 };
80458115
8116 pub const StrTuple = struct {
8117 str: MetadataString,
8118 elements_len: u32,
8119
8120 // elements: [elements_len]Metadata
8121 };
8122
8046 pub const ModuleFlag = struct {8123 pub const ModuleFlag = struct {
8047 behavior: Metadata,8124 behavior: Metadata,
8048 name: MetadataString,8125 name: MetadataString,
...@@ -8355,7 +8432,7 @@ pub const Metadata = enum(u32) {...@@ -8355,7 +8432,7 @@ pub const Metadata = enum(u32) {
8355};8432};
83568433
8357pub fn init(options: Options) Allocator.Error!Builder {8434pub fn init(options: Options) Allocator.Error!Builder {
8358 var self = Builder{8435 var self: Builder = .{
8359 .gpa = options.allocator,8436 .gpa = options.allocator,
8360 .strip = options.strip,8437 .strip = options.strip,
83618438
...@@ -8454,7 +8531,9 @@ pub fn init(options: Options) Allocator.Error!Builder {...@@ -8454,7 +8531,9 @@ pub fn init(options: Options) Allocator.Error!Builder {
8454 assert(try self.intConst(.i32, 0) == .@"0");8531 assert(try self.intConst(.i32, 0) == .@"0");
8455 assert(try self.intConst(.i32, 1) == .@"1");8532 assert(try self.intConst(.i32, 1) == .@"1");
8456 assert(try self.noneConst(.token) == .none);8533 assert(try self.noneConst(.token) == .none);
8457 if (!self.strip) assert(try self.debugNone() == .none);8534
8535 assert(try self.metadataNone() == .none);
8536 assert(try self.metadataTuple(&.{}) == .empty_tuple);
84588537
8459 try self.metadata_string_indices.append(self.gpa, 0);8538 try self.metadata_string_indices.append(self.gpa, 0);
8460 assert(try self.metadataString("") == .none);8539 assert(try self.metadataString("") == .none);
...@@ -9683,6 +9762,13 @@ pub fn printUnbuffered(...@@ -9683,6 +9762,13 @@ pub fn printUnbuffered(
9683 extra.then.toInst(&function).fmt(function_index, self),9762 extra.then.toInst(&function).fmt(function_index, self),
9684 extra.@"else".toInst(&function).fmt(function_index, self),9763 extra.@"else".toInst(&function).fmt(function_index, self),
9685 });9764 });
9765 switch (extra.weights) {
9766 .none => {},
9767 .unpredictable => try writer.writeAll(", !unpredictable !{}"),
9768 _ => try writer.print("{}", .{
9769 try metadata_formatter.fmt(", !prof ", @as(Metadata, @enumFromInt(@intFromEnum(extra.weights)))),
9770 }),
9771 }
9686 },9772 },
9687 .call,9773 .call,
9688 .@"call fast",9774 .@"call fast",
...@@ -9727,6 +9813,9 @@ pub fn printUnbuffered(...@@ -9727,6 +9813,9 @@ pub fn printUnbuffered(
9727 });9813 });
9728 }9814 }
9729 try writer.writeByte(')');9815 try writer.writeByte(')');
9816 if (extra.data.info.has_op_bundle_cold) {
9817 try writer.writeAll(" [ \"cold\"() ]");
9818 }
9730 const call_function_attributes = extra.data.attributes.func(self);9819 const call_function_attributes = extra.data.attributes.func(self);
9731 if (call_function_attributes != .none) try writer.print(" #{d}", .{9820 if (call_function_attributes != .none) try writer.print(" #{d}", .{
9732 (try attribute_groups.getOrPutValue(9821 (try attribute_groups.getOrPutValue(
...@@ -9937,6 +10026,13 @@ pub fn printUnbuffered(...@@ -9937,6 +10026,13 @@ pub fn printUnbuffered(
9937 },10026 },
9938 );10027 );
9939 try writer.writeAll(" ]");10028 try writer.writeAll(" ]");
10029 switch (extra.data.weights) {
10030 .none => {},
10031 .unpredictable => try writer.writeAll(", !unpredictable !{}"),
10032 _ => try writer.print("{}", .{
10033 try metadata_formatter.fmt(", !prof ", @as(Metadata, @enumFromInt(@intFromEnum(extra.data.weights)))),
10034 }),
10035 }
9940 },10036 },
9941 .va_arg => |tag| {10037 .va_arg => |tag| {
9942 const extra = function.extraData(Function.Instruction.VaArg, instruction.data);10038 const extra = function.extraData(Function.Instruction.VaArg, instruction.data);
...@@ -10285,6 +10381,17 @@ pub fn printUnbuffered(...@@ -10285,6 +10381,17 @@ pub fn printUnbuffered(
10285 });10381 });
10286 try writer.writeAll("}\n");10382 try writer.writeAll("}\n");
10287 },10383 },
10384 .str_tuple => {
10385 var extra = self.metadataExtraDataTrail(Metadata.StrTuple, metadata_item.data);
10386 const elements = extra.trail.next(extra.data.elements_len, Metadata, self);
10387 try writer.print("!{{{[str]%}", .{
10388 .str = try metadata_formatter.fmt("", extra.data.str),
10389 });
10390 for (elements) |element| try writer.print("{[element]%}", .{
10391 .element = try metadata_formatter.fmt("", element),
10392 });
10393 try writer.writeAll("}\n");
10394 },
10288 .module_flag => {10395 .module_flag => {
10289 const extra = self.metadataExtraData(Metadata.ModuleFlag, metadata_item.data);10396 const extra = self.metadataExtraData(Metadata.ModuleFlag, metadata_item.data);
10290 try writer.print("!{{{[behavior]%}{[name]%}{[constant]%}}}\n", .{10397 try writer.print("!{{{[behavior]%}{[name]%}{[constant]%}}}\n", .{
...@@ -11797,9 +11904,9 @@ pub fn debugNamed(self: *Builder, name: MetadataString, operands: []const Metada...@@ -11797,9 +11904,9 @@ pub fn debugNamed(self: *Builder, name: MetadataString, operands: []const Metada
11797 self.debugNamedAssumeCapacity(name, operands);11904 self.debugNamedAssumeCapacity(name, operands);
11798}11905}
1179911906
11800fn debugNone(self: *Builder) Allocator.Error!Metadata {11907fn metadataNone(self: *Builder) Allocator.Error!Metadata {
11801 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);11908 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);
11802 return self.debugNoneAssumeCapacity();11909 return self.metadataNoneAssumeCapacity();
11803}11910}
1180411911
11805pub fn debugFile(11912pub fn debugFile(
...@@ -12088,12 +12195,21 @@ pub fn debugExpression(...@@ -12088,12 +12195,21 @@ pub fn debugExpression(
12088 return self.debugExpressionAssumeCapacity(elements);12195 return self.debugExpressionAssumeCapacity(elements);
12089}12196}
1209012197
12091pub fn debugTuple(12198pub fn metadataTuple(
12092 self: *Builder,12199 self: *Builder,
12093 elements: []const Metadata,12200 elements: []const Metadata,
12094) Allocator.Error!Metadata {12201) Allocator.Error!Metadata {
12095 try self.ensureUnusedMetadataCapacity(1, Metadata.Tuple, elements.len);12202 try self.ensureUnusedMetadataCapacity(1, Metadata.Tuple, elements.len);
12096 return self.debugTupleAssumeCapacity(elements);12203 return self.metadataTupleAssumeCapacity(elements);
12204}
12205
12206pub fn strTuple(
12207 self: *Builder,
12208 str: MetadataString,
12209 elements: []const Metadata,
12210) Allocator.Error!Metadata {
12211 try self.ensureUnusedMetadataCapacity(1, Metadata.StrTuple, elements.len);
12212 return self.strTupleAssumeCapacity(str, elements);
12097}12213}
1209812214
12099pub fn debugModuleFlag(12215pub fn debugModuleFlag(
...@@ -12164,9 +12280,9 @@ pub fn debugGlobalVarExpression(...@@ -12164,9 +12280,9 @@ pub fn debugGlobalVarExpression(
12164 return self.debugGlobalVarExpressionAssumeCapacity(variable, expression);12280 return self.debugGlobalVarExpressionAssumeCapacity(variable, expression);
12165}12281}
1216612282
12167pub fn debugConstant(self: *Builder, value: Constant) Allocator.Error!Metadata {12283pub fn metadataConstant(self: *Builder, value: Constant) Allocator.Error!Metadata {
12168 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);12284 try self.ensureUnusedMetadataCapacity(1, NoExtra, 0);
12169 return self.debugConstantAssumeCapacity(value);12285 return self.metadataConstantAssumeCapacity(value);
12170}12286}
1217112287
12172pub fn debugForwardReferenceSetType(self: *Builder, fwd_ref: Metadata, ty: Metadata) void {12288pub fn debugForwardReferenceSetType(self: *Builder, fwd_ref: Metadata, ty: Metadata) void {
...@@ -12261,8 +12377,7 @@ fn debugNamedAssumeCapacity(self: *Builder, name: MetadataString, operands: []co...@@ -12261,8 +12377,7 @@ fn debugNamedAssumeCapacity(self: *Builder, name: MetadataString, operands: []co
12261 };12377 };
12262}12378}
1226312379
12264pub fn debugNoneAssumeCapacity(self: *Builder) Metadata {12380pub fn metadataNoneAssumeCapacity(self: *Builder) Metadata {
12265 assert(!self.strip);
12266 return self.metadataSimpleAssumeCapacity(.none, .{});12381 return self.metadataSimpleAssumeCapacity(.none, .{});
12267}12382}
1226812383
...@@ -12738,11 +12853,10 @@ fn debugExpressionAssumeCapacity(...@@ -12738,11 +12853,10 @@ fn debugExpressionAssumeCapacity(
12738 return @enumFromInt(gop.index);12853 return @enumFromInt(gop.index);
12739}12854}
1274012855
12741fn debugTupleAssumeCapacity(12856fn metadataTupleAssumeCapacity(
12742 self: *Builder,12857 self: *Builder,
12743 elements: []const Metadata,12858 elements: []const Metadata,
12744) Metadata {12859) Metadata {
12745 assert(!self.strip);
12746 const Key = struct {12860 const Key = struct {
12747 elements: []const Metadata,12861 elements: []const Metadata,
12748 };12862 };
...@@ -12785,6 +12899,55 @@ fn debugTupleAssumeCapacity(...@@ -12785,6 +12899,55 @@ fn debugTupleAssumeCapacity(
12785 return @enumFromInt(gop.index);12899 return @enumFromInt(gop.index);
12786}12900}
1278712901
12902fn strTupleAssumeCapacity(
12903 self: *Builder,
12904 str: MetadataString,
12905 elements: []const Metadata,
12906) Metadata {
12907 const Key = struct {
12908 str: MetadataString,
12909 elements: []const Metadata,
12910 };
12911 const Adapter = struct {
12912 builder: *const Builder,
12913 pub fn hash(_: @This(), key: Key) u32 {
12914 var hasher = comptime std.hash.Wyhash.init(std.hash.uint32(@intFromEnum(Metadata.Tag.tuple)));
12915 hasher.update(std.mem.sliceAsBytes(key.elements));
12916 return @truncate(hasher.final());
12917 }
12918
12919 pub fn eql(ctx: @This(), lhs_key: Key, _: void, rhs_index: usize) bool {
12920 if (.str_tuple != ctx.builder.metadata_items.items(.tag)[rhs_index]) return false;
12921 const rhs_data = ctx.builder.metadata_items.items(.data)[rhs_index];
12922 var rhs_extra = ctx.builder.metadataExtraDataTrail(Metadata.StrTuple, rhs_data);
12923 return rhs_extra.data.str == lhs_key.str and std.mem.eql(
12924 Metadata,
12925 lhs_key.elements,
12926 rhs_extra.trail.next(rhs_extra.data.elements_len, Metadata, ctx.builder),
12927 );
12928 }
12929 };
12930
12931 const gop = self.metadata_map.getOrPutAssumeCapacityAdapted(
12932 Key{ .str = str, .elements = elements },
12933 Adapter{ .builder = self },
12934 );
12935
12936 if (!gop.found_existing) {
12937 gop.key_ptr.* = {};
12938 gop.value_ptr.* = {};
12939 self.metadata_items.appendAssumeCapacity(.{
12940 .tag = .str_tuple,
12941 .data = self.addMetadataExtraAssumeCapacity(Metadata.StrTuple{
12942 .str = str,
12943 .elements_len = @intCast(elements.len),
12944 }),
12945 });
12946 self.metadata_extra.appendSliceAssumeCapacity(@ptrCast(elements));
12947 }
12948 return @enumFromInt(gop.index);
12949}
12950
12788fn debugModuleFlagAssumeCapacity(12951fn debugModuleFlagAssumeCapacity(
12789 self: *Builder,12952 self: *Builder,
12790 behavior: Metadata,12953 behavior: Metadata,
...@@ -12875,8 +13038,7 @@ fn debugGlobalVarExpressionAssumeCapacity(...@@ -12875,8 +13038,7 @@ fn debugGlobalVarExpressionAssumeCapacity(
12875 });13038 });
12876}13039}
1287713040
12878fn debugConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata {13041fn metadataConstantAssumeCapacity(self: *Builder, constant: Constant) Metadata {
12879 assert(!self.strip);
12880 const Adapter = struct {13042 const Adapter = struct {
12881 builder: *const Builder,13043 builder: *const Builder,
12882 pub fn hash(_: @This(), key: Constant) u32 {13044 pub fn hash(_: @This(), key: Constant) u32 {
...@@ -13755,15 +13917,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13755,15 +13917,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13755 }13917 }
1375613918
13757 // METADATA_KIND_BLOCK13919 // METADATA_KIND_BLOCK
13758 if (!self.strip) {13920 {
13759 const MetadataKindBlock = ir.MetadataKindBlock;13921 const MetadataKindBlock = ir.MetadataKindBlock;
13760 var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);13922 var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
1376113923
13762 inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| {13924 inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| {
13763 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{13925 // don't include `dbg` in stripped functions
13764 .id = field.value,13926 if (!(self.strip and std.mem.eql(u8, field.name, "dbg"))) {
13765 .name = field.name,13927 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
13766 });13928 .id = field.value,
13929 .name = field.name,
13930 });
13931 }
13767 }13932 }
1376813933
13769 try metadata_kind_block.end();13934 try metadata_kind_block.end();
...@@ -13808,14 +13973,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13808,14 +13973,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13808 const metadata_adapter = MetadataAdapter.init(self, constant_adapter);13973 const metadata_adapter = MetadataAdapter.init(self, constant_adapter);
1380913974
13810 // METADATA_BLOCK13975 // METADATA_BLOCK
13811 if (!self.strip) {13976 {
13812 const MetadataBlock = ir.MetadataBlock;13977 const MetadataBlock = ir.MetadataBlock;
13813 var metadata_block = try module_block.enterSubBlock(MetadataBlock, true);13978 var metadata_block = try module_block.enterSubBlock(MetadataBlock, true);
1381413979
13815 const MetadataBlockWriter = @TypeOf(metadata_block);13980 const MetadataBlockWriter = @TypeOf(metadata_block);
1381613981
13817 // Emit all MetadataStrings13982 // Emit all MetadataStrings
13818 {13983 if (self.metadata_string_map.count() > 1) {
13819 const strings_offset, const strings_size = blk: {13984 const strings_offset, const strings_size = blk: {
13820 var strings_offset: u32 = 0;13985 var strings_offset: u32 = 0;
13821 var strings_size: u32 = 0;13986 var strings_size: u32 = 0;
...@@ -14046,7 +14211,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14046,7 +14211,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14046 else14211 else
14047 -%val << 1 | 1);14212 -%val << 1 | 1);
14048 }14213 }
14049 try metadata_block.writeUnabbrev(MetadataBlock.Enumerator.id, record.items);14214 try metadata_block.writeUnabbrev(@intFromEnum(MetadataBlock.Enumerator.id), record.items);
14050 continue;14215 continue;
14051 };14216 };
14052 try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{14217 try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{
...@@ -14085,6 +14250,22 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14085,6 +14250,22 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14085 .elements = elements,14250 .elements = elements,
14086 }, metadata_adapter);14251 }, metadata_adapter);
14087 },14252 },
14253 .str_tuple => {
14254 var extra = self.metadataExtraDataTrail(Metadata.StrTuple, data);
14255
14256 const elements = extra.trail.next(extra.data.elements_len, Metadata, self);
14257
14258 const all_elems = try self.gpa.alloc(Metadata, elements.len + 1);
14259 defer self.gpa.free(all_elems);
14260 all_elems[0] = @enumFromInt(metadata_adapter.getMetadataStringIndex(extra.data.str));
14261 for (elements, all_elems[1..]) |elem, *out_elem| {
14262 out_elem.* = @enumFromInt(metadata_adapter.getMetadataIndex(elem));
14263 }
14264
14265 try metadata_block.writeAbbrev(MetadataBlock.Node{
14266 .elements = all_elems,
14267 });
14268 },
14088 .module_flag => {14269 .module_flag => {
14089 const extra = self.metadataExtraData(Metadata.ModuleFlag, data);14270 const extra = self.metadataExtraData(Metadata.ModuleFlag, data);
14090 try metadata_block.writeAbbrev(MetadataBlock.Node{14271 try metadata_block.writeAbbrev(MetadataBlock.Node{
...@@ -14177,7 +14358,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14177,7 +14358,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1417714358
14178 try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{14359 try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{
14179 .value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())),14360 .value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())),
14180 .kind = ir.MetadataKind.dbg,14361 .kind = .dbg,
14181 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1),14362 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1),
14182 });14363 });
14183 }14364 }
...@@ -14186,6 +14367,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14186,6 +14367,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14186 try metadata_block.end();14367 try metadata_block.end();
14187 }14368 }
1418814369
14370 // OPERAND_BUNDLE_TAGS_BLOCK
14371 {
14372 const OperandBundleTags = ir.OperandBundleTags;
14373 var operand_bundle_tags_block = try module_block.enterSubBlock(OperandBundleTags, true);
14374
14375 try operand_bundle_tags_block.writeAbbrev(OperandBundleTags.OperandBundleTag{
14376 .tag = "cold",
14377 });
14378
14379 try operand_bundle_tags_block.end();
14380 }
14381
14189 // Block info14382 // Block info
14190 {14383 {
14191 const BlockInfo = ir.BlockInfo;14384 const BlockInfo = ir.BlockInfo;
...@@ -14220,20 +14413,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14220,20 +14413,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14220 constant_adapter: ConstantAdapter,14413 constant_adapter: ConstantAdapter,
14221 metadata_adapter: MetadataAdapter,14414 metadata_adapter: MetadataAdapter,
14222 func: *const Function,14415 func: *const Function,
14223 instruction_index: u32 = 0,14416 instruction_index: Function.Instruction.Index,
14224
14225 pub fn init(
14226 const_adapter: ConstantAdapter,
14227 meta_adapter: MetadataAdapter,
14228 func: *const Function,
14229 ) @This() {
14230 return .{
14231 .constant_adapter = const_adapter,
14232 .metadata_adapter = meta_adapter,
14233 .func = func,
14234 .instruction_index = 0,
14235 };
14236 }
1423714417
14238 pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) {14418 pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) {
14239 _ = field_name;14419 _ = field_name;
...@@ -14254,7 +14434,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14254,7 +14434,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14254 .instruction => |instruction| instruction.valueIndex(adapter.func) + adapter.firstInstr(),14434 .instruction => |instruction| instruction.valueIndex(adapter.func) + adapter.firstInstr(),
14255 .constant => |constant| adapter.constant_adapter.getConstantIndex(constant),14435 .constant => |constant| adapter.constant_adapter.getConstantIndex(constant),
14256 .metadata => |metadata| {14436 .metadata => |metadata| {
14257 assert(!adapter.func.strip);
14258 const real_metadata = metadata.unwrap(adapter.metadata_adapter.builder);14437 const real_metadata = metadata.unwrap(adapter.metadata_adapter.builder);
14259 if (@intFromEnum(real_metadata) < Metadata.first_local_metadata)14438 if (@intFromEnum(real_metadata) < Metadata.first_local_metadata)
14260 return adapter.metadata_adapter.getMetadataIndex(real_metadata) - 1;14439 return adapter.metadata_adapter.getMetadataIndex(real_metadata) - 1;
...@@ -14282,19 +14461,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14282,19 +14461,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14282 }14461 }
1428314462
14284 pub fn offset(adapter: @This()) u32 {14463 pub fn offset(adapter: @This()) u32 {
14285 return @as(14464 return adapter.instruction_index.valueIndex(adapter.func) + adapter.firstInstr();
14286 Function.Instruction.Index,
14287 @enumFromInt(adapter.instruction_index),
14288 ).valueIndex(adapter.func) + adapter.firstInstr();
14289 }14465 }
1429014466
14291 fn firstInstr(adapter: @This()) u32 {14467 fn firstInstr(adapter: @This()) u32 {
14292 return adapter.constant_adapter.numConstants();14468 return adapter.constant_adapter.numConstants();
14293 }14469 }
14294
14295 pub fn next(adapter: *@This()) void {
14296 adapter.instruction_index += 1;
14297 }
14298 };14470 };
1429914471
14300 for (self.functions.items, 0..) |func, func_index| {14472 for (self.functions.items, 0..) |func, func_index| {
...@@ -14307,7 +14479,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14307,7 +14479,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1430714479
14308 try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len });14480 try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len });
1430914481
14310 var adapter = FunctionAdapter.init(constant_adapter, metadata_adapter, &func);14482 var adapter: FunctionAdapter = .{
14483 .constant_adapter = constant_adapter,
14484 .metadata_adapter = metadata_adapter,
14485 .func = &func,
14486 .instruction_index = @enumFromInt(0),
14487 };
1431114488
14312 // Emit function level metadata block14489 // Emit function level metadata block
14313 if (!func.strip and func.debug_values.len > 0) {14490 if (!func.strip and func.debug_values.len > 0) {
...@@ -14330,21 +14507,27 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14330,21 +14507,27 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14330 var has_location = false;14507 var has_location = false;
1433114508
14332 var block_incoming_len: u32 = undefined;14509 var block_incoming_len: u32 = undefined;
14333 for (0..func.instructions.len) |instr_index| {14510 for (tags, datas, 0..) |tag, data, instr_index| {
14334 const tag = tags[instr_index];14511 adapter.instruction_index = @enumFromInt(instr_index);
14335
14336 record.clearRetainingCapacity();14512 record.clearRetainingCapacity();
1433714513
14338 switch (tag) {14514 switch (tag) {
14339 .block => block_incoming_len = datas[instr_index],14515 .arg => continue,
14340 .arg => {},14516 .block => {
14517 block_incoming_len = data;
14518 continue;
14519 },
14341 .@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}),14520 .@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}),
14342 .call,14521 .call,
14343 .@"musttail call",14522 .@"musttail call",
14344 .@"notail call",14523 .@"notail call",
14345 .@"tail call",14524 .@"tail call",
14346 => |kind| {14525 => |kind| {
14347 var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);14526 var extra = func.extraDataTrail(Function.Instruction.Call, data);
14527
14528 if (extra.data.info.has_op_bundle_cold) {
14529 try function_block.writeAbbrev(FunctionBlock.ColdOperandBundle{});
14530 }
1434814531
14349 const call_conv = extra.data.info.call_conv;14532 const call_conv = extra.data.info.call_conv;
14350 const args = extra.trail.next(extra.data.args_len, Value, &func);14533 const args = extra.trail.next(extra.data.args_len, Value, &func);
...@@ -14367,7 +14550,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14367,7 +14550,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14367 .@"notail call fast",14550 .@"notail call fast",
14368 .@"tail call fast",14551 .@"tail call fast",
14369 => |kind| {14552 => |kind| {
14370 var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);14553 var extra = func.extraDataTrail(Function.Instruction.Call, data);
14554
14555 if (extra.data.info.has_op_bundle_cold) {
14556 try function_block.writeAbbrev(FunctionBlock.ColdOperandBundle{});
14557 }
1437114558
14372 const call_conv = extra.data.info.call_conv;14559 const call_conv = extra.data.info.call_conv;
14373 const args = extra.trail.next(extra.data.args_len, Value, &func);14560 const args = extra.trail.next(extra.data.args_len, Value, &func);
...@@ -14405,7 +14592,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14405,7 +14592,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14405 .srem,14592 .srem,
14406 .ashr,14593 .ashr,
14407 => |kind| {14594 => |kind| {
14408 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14595 const extra = func.extraData(Function.Instruction.Binary, data);
14409 try function_block.writeAbbrev(FunctionBlock.Binary{14596 try function_block.writeAbbrev(FunctionBlock.Binary{
14410 .opcode = kind.toBinaryOpcode(),14597 .opcode = kind.toBinaryOpcode(),
14411 .lhs = adapter.getOffsetValueIndex(extra.lhs),14598 .lhs = adapter.getOffsetValueIndex(extra.lhs),
...@@ -14417,7 +14604,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14417,7 +14604,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14417 .@"lshr exact",14604 .@"lshr exact",
14418 .@"ashr exact",14605 .@"ashr exact",
14419 => |kind| {14606 => |kind| {
14420 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14607 const extra = func.extraData(Function.Instruction.Binary, data);
14421 try function_block.writeAbbrev(FunctionBlock.BinaryExact{14608 try function_block.writeAbbrev(FunctionBlock.BinaryExact{
14422 .opcode = kind.toBinaryOpcode(),14609 .opcode = kind.toBinaryOpcode(),
14423 .lhs = adapter.getOffsetValueIndex(extra.lhs),14610 .lhs = adapter.getOffsetValueIndex(extra.lhs),
...@@ -14437,7 +14624,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14437,7 +14624,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14437 .@"shl nuw",14624 .@"shl nuw",
14438 .@"shl nuw nsw",14625 .@"shl nuw nsw",
14439 => |kind| {14626 => |kind| {
14440 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14627 const extra = func.extraData(Function.Instruction.Binary, data);
14441 try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{14628 try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{
14442 .opcode = kind.toBinaryOpcode(),14629 .opcode = kind.toBinaryOpcode(),
14443 .lhs = adapter.getOffsetValueIndex(extra.lhs),14630 .lhs = adapter.getOffsetValueIndex(extra.lhs),
...@@ -14468,7 +14655,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14468,7 +14655,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14468 .@"frem fast",14655 .@"frem fast",
14469 .@"fsub fast",14656 .@"fsub fast",
14470 => |kind| {14657 => |kind| {
14471 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14658 const extra = func.extraData(Function.Instruction.Binary, data);
14472 try function_block.writeAbbrev(FunctionBlock.BinaryFast{14659 try function_block.writeAbbrev(FunctionBlock.BinaryFast{
14473 .opcode = kind.toBinaryOpcode(),14660 .opcode = kind.toBinaryOpcode(),
14474 .lhs = adapter.getOffsetValueIndex(extra.lhs),14661 .lhs = adapter.getOffsetValueIndex(extra.lhs),
...@@ -14479,7 +14666,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14479,7 +14666,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14479 .alloca,14666 .alloca,
14480 .@"alloca inalloca",14667 .@"alloca inalloca",
14481 => |kind| {14668 => |kind| {
14482 const extra = func.extraData(Function.Instruction.Alloca, datas[instr_index]);14669 const extra = func.extraData(Function.Instruction.Alloca, data);
14483 const alignment = extra.info.alignment.toLlvm();14670 const alignment = extra.info.alignment.toLlvm();
14484 try function_block.writeAbbrev(FunctionBlock.Alloca{14671 try function_block.writeAbbrev(FunctionBlock.Alloca{
14485 .inst_type = extra.type,14672 .inst_type = extra.type,
...@@ -14508,7 +14695,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14508,7 +14695,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14508 .sext,14695 .sext,
14509 .zext,14696 .zext,
14510 => |kind| {14697 => |kind| {
14511 const extra = func.extraData(Function.Instruction.Cast, datas[instr_index]);14698 const extra = func.extraData(Function.Instruction.Cast, data);
14512 try function_block.writeAbbrev(FunctionBlock.Cast{14699 try function_block.writeAbbrev(FunctionBlock.Cast{
14513 .val = adapter.getOffsetValueIndex(extra.val),14700 .val = adapter.getOffsetValueIndex(extra.val),
14514 .type_index = extra.type,14701 .type_index = extra.type,
...@@ -14542,7 +14729,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14542,7 +14729,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14542 .@"icmp ule",14729 .@"icmp ule",
14543 .@"icmp ult",14730 .@"icmp ult",
14544 => |kind| {14731 => |kind| {
14545 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14732 const extra = func.extraData(Function.Instruction.Binary, data);
14546 try function_block.writeAbbrev(FunctionBlock.Cmp{14733 try function_block.writeAbbrev(FunctionBlock.Cmp{
14547 .lhs = adapter.getOffsetValueIndex(extra.lhs),14734 .lhs = adapter.getOffsetValueIndex(extra.lhs),
14548 .rhs = adapter.getOffsetValueIndex(extra.rhs),14735 .rhs = adapter.getOffsetValueIndex(extra.rhs),
...@@ -14566,7 +14753,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14566,7 +14753,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14566 .@"fcmp fast une",14753 .@"fcmp fast une",
14567 .@"fcmp fast uno",14754 .@"fcmp fast uno",
14568 => |kind| {14755 => |kind| {
14569 const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);14756 const extra = func.extraData(Function.Instruction.Binary, data);
14570 try function_block.writeAbbrev(FunctionBlock.CmpFast{14757 try function_block.writeAbbrev(FunctionBlock.CmpFast{
14571 .lhs = adapter.getOffsetValueIndex(extra.lhs),14758 .lhs = adapter.getOffsetValueIndex(extra.lhs),
14572 .rhs = adapter.getOffsetValueIndex(extra.rhs),14759 .rhs = adapter.getOffsetValueIndex(extra.rhs),
...@@ -14575,14 +14762,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14575,14 +14762,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14575 });14762 });
14576 },14763 },
14577 .fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{14764 .fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{
14578 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),14765 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
14579 }),14766 }),
14580 .@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{14767 .@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{
14581 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),14768 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
14582 .fast_math = FastMath.fast,14769 .fast_math = FastMath.fast,
14583 }),14770 }),
14584 .extractvalue => {14771 .extractvalue => {
14585 var extra = func.extraDataTrail(Function.Instruction.ExtractValue, datas[instr_index]);14772 var extra = func.extraDataTrail(Function.Instruction.ExtractValue, data);
14586 const indices = extra.trail.next(extra.data.indices_len, u32, &func);14773 const indices = extra.trail.next(extra.data.indices_len, u32, &func);
14587 try function_block.writeAbbrev(FunctionBlock.ExtractValue{14774 try function_block.writeAbbrev(FunctionBlock.ExtractValue{
14588 .val = adapter.getOffsetValueIndex(extra.data.val),14775 .val = adapter.getOffsetValueIndex(extra.data.val),
...@@ -14590,7 +14777,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14590,7 +14777,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14590 });14777 });
14591 },14778 },
14592 .insertvalue => {14779 .insertvalue => {
14593 var extra = func.extraDataTrail(Function.Instruction.InsertValue, datas[instr_index]);14780 var extra = func.extraDataTrail(Function.Instruction.InsertValue, data);
14594 const indices = extra.trail.next(extra.data.indices_len, u32, &func);14781 const indices = extra.trail.next(extra.data.indices_len, u32, &func);
14595 try function_block.writeAbbrev(FunctionBlock.InsertValue{14782 try function_block.writeAbbrev(FunctionBlock.InsertValue{
14596 .val = adapter.getOffsetValueIndex(extra.data.val),14783 .val = adapter.getOffsetValueIndex(extra.data.val),
...@@ -14599,14 +14786,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14599,14 +14786,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14599 });14786 });
14600 },14787 },
14601 .extractelement => {14788 .extractelement => {
14602 const extra = func.extraData(Function.Instruction.ExtractElement, datas[instr_index]);14789 const extra = func.extraData(Function.Instruction.ExtractElement, data);
14603 try function_block.writeAbbrev(FunctionBlock.ExtractElement{14790 try function_block.writeAbbrev(FunctionBlock.ExtractElement{
14604 .val = adapter.getOffsetValueIndex(extra.val),14791 .val = adapter.getOffsetValueIndex(extra.val),
14605 .index = adapter.getOffsetValueIndex(extra.index),14792 .index = adapter.getOffsetValueIndex(extra.index),
14606 });14793 });
14607 },14794 },
14608 .insertelement => {14795 .insertelement => {
14609 const extra = func.extraData(Function.Instruction.InsertElement, datas[instr_index]);14796 const extra = func.extraData(Function.Instruction.InsertElement, data);
14610 try function_block.writeAbbrev(FunctionBlock.InsertElement{14797 try function_block.writeAbbrev(FunctionBlock.InsertElement{
14611 .val = adapter.getOffsetValueIndex(extra.val),14798 .val = adapter.getOffsetValueIndex(extra.val),
14612 .elem = adapter.getOffsetValueIndex(extra.elem),14799 .elem = adapter.getOffsetValueIndex(extra.elem),
...@@ -14614,7 +14801,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14614,7 +14801,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14614 });14801 });
14615 },14802 },
14616 .select => {14803 .select => {
14617 const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);14804 const extra = func.extraData(Function.Instruction.Select, data);
14618 try function_block.writeAbbrev(FunctionBlock.Select{14805 try function_block.writeAbbrev(FunctionBlock.Select{
14619 .lhs = adapter.getOffsetValueIndex(extra.lhs),14806 .lhs = adapter.getOffsetValueIndex(extra.lhs),
14620 .rhs = adapter.getOffsetValueIndex(extra.rhs),14807 .rhs = adapter.getOffsetValueIndex(extra.rhs),
...@@ -14622,7 +14809,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14622,7 +14809,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14622 });14809 });
14623 },14810 },
14624 .@"select fast" => {14811 .@"select fast" => {
14625 const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);14812 const extra = func.extraData(Function.Instruction.Select, data);
14626 try function_block.writeAbbrev(FunctionBlock.SelectFast{14813 try function_block.writeAbbrev(FunctionBlock.SelectFast{
14627 .lhs = adapter.getOffsetValueIndex(extra.lhs),14814 .lhs = adapter.getOffsetValueIndex(extra.lhs),
14628 .rhs = adapter.getOffsetValueIndex(extra.rhs),14815 .rhs = adapter.getOffsetValueIndex(extra.rhs),
...@@ -14631,7 +14818,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14631,7 +14818,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14631 });14818 });
14632 },14819 },
14633 .shufflevector => {14820 .shufflevector => {
14634 const extra = func.extraData(Function.Instruction.ShuffleVector, datas[instr_index]);14821 const extra = func.extraData(Function.Instruction.ShuffleVector, data);
14635 try function_block.writeAbbrev(FunctionBlock.ShuffleVector{14822 try function_block.writeAbbrev(FunctionBlock.ShuffleVector{
14636 .lhs = adapter.getOffsetValueIndex(extra.lhs),14823 .lhs = adapter.getOffsetValueIndex(extra.lhs),
14637 .rhs = adapter.getOffsetValueIndex(extra.rhs),14824 .rhs = adapter.getOffsetValueIndex(extra.rhs),
...@@ -14641,7 +14828,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14641,7 +14828,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14641 .getelementptr,14828 .getelementptr,
14642 .@"getelementptr inbounds",14829 .@"getelementptr inbounds",
14643 => |kind| {14830 => |kind| {
14644 var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, datas[instr_index]);14831 var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, data);
14645 const indices = extra.trail.next(extra.data.indices_len, Value, &func);14832 const indices = extra.trail.next(extra.data.indices_len, Value, &func);
14646 try function_block.writeAbbrevAdapted(14833 try function_block.writeAbbrevAdapted(
14647 FunctionBlock.GetElementPtr{14834 FunctionBlock.GetElementPtr{
...@@ -14654,7 +14841,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14654,7 +14841,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14654 );14841 );
14655 },14842 },
14656 .load => {14843 .load => {
14657 const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);14844 const extra = func.extraData(Function.Instruction.Load, data);
14658 try function_block.writeAbbrev(FunctionBlock.Load{14845 try function_block.writeAbbrev(FunctionBlock.Load{
14659 .ptr = adapter.getOffsetValueIndex(extra.ptr),14846 .ptr = adapter.getOffsetValueIndex(extra.ptr),
14660 .ty = extra.type,14847 .ty = extra.type,
...@@ -14663,7 +14850,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14663,7 +14850,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14663 });14850 });
14664 },14851 },
14665 .@"load atomic" => {14852 .@"load atomic" => {
14666 const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);14853 const extra = func.extraData(Function.Instruction.Load, data);
14667 try function_block.writeAbbrev(FunctionBlock.LoadAtomic{14854 try function_block.writeAbbrev(FunctionBlock.LoadAtomic{
14668 .ptr = adapter.getOffsetValueIndex(extra.ptr),14855 .ptr = adapter.getOffsetValueIndex(extra.ptr),
14669 .ty = extra.type,14856 .ty = extra.type,
...@@ -14674,7 +14861,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14674,7 +14861,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14674 });14861 });
14675 },14862 },
14676 .store => {14863 .store => {
14677 const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);14864 const extra = func.extraData(Function.Instruction.Store, data);
14678 try function_block.writeAbbrev(FunctionBlock.Store{14865 try function_block.writeAbbrev(FunctionBlock.Store{
14679 .ptr = adapter.getOffsetValueIndex(extra.ptr),14866 .ptr = adapter.getOffsetValueIndex(extra.ptr),
14680 .val = adapter.getOffsetValueIndex(extra.val),14867 .val = adapter.getOffsetValueIndex(extra.val),
...@@ -14683,7 +14870,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14683,7 +14870,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14683 });14870 });
14684 },14871 },
14685 .@"store atomic" => {14872 .@"store atomic" => {
14686 const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);14873 const extra = func.extraData(Function.Instruction.Store, data);
14687 try function_block.writeAbbrev(FunctionBlock.StoreAtomic{14874 try function_block.writeAbbrev(FunctionBlock.StoreAtomic{
14688 .ptr = adapter.getOffsetValueIndex(extra.ptr),14875 .ptr = adapter.getOffsetValueIndex(extra.ptr),
14689 .val = adapter.getOffsetValueIndex(extra.val),14876 .val = adapter.getOffsetValueIndex(extra.val),
...@@ -14695,11 +14882,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14695,11 +14882,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14695 },14882 },
14696 .br => {14883 .br => {
14697 try function_block.writeAbbrev(FunctionBlock.BrUnconditional{14884 try function_block.writeAbbrev(FunctionBlock.BrUnconditional{
14698 .block = datas[instr_index],14885 .block = data,
14699 });14886 });
14700 },14887 },
14701 .br_cond => {14888 .br_cond => {
14702 const extra = func.extraData(Function.Instruction.BrCond, datas[instr_index]);14889 const extra = func.extraData(Function.Instruction.BrCond, data);
14703 try function_block.writeAbbrev(FunctionBlock.BrConditional{14890 try function_block.writeAbbrev(FunctionBlock.BrConditional{
14704 .then_block = @intFromEnum(extra.then),14891 .then_block = @intFromEnum(extra.then),
14705 .else_block = @intFromEnum(extra.@"else"),14892 .else_block = @intFromEnum(extra.@"else"),
...@@ -14707,7 +14894,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14707,7 +14894,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14707 });14894 });
14708 },14895 },
14709 .@"switch" => {14896 .@"switch" => {
14710 var extra = func.extraDataTrail(Function.Instruction.Switch, datas[instr_index]);14897 var extra = func.extraDataTrail(Function.Instruction.Switch, data);
1471114898
14712 try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2);14899 try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2);
1471314900
...@@ -14730,7 +14917,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14730,7 +14917,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14730 try function_block.writeUnabbrev(12, record.items);14917 try function_block.writeUnabbrev(12, record.items);
14731 },14918 },
14732 .va_arg => {14919 .va_arg => {
14733 const extra = func.extraData(Function.Instruction.VaArg, datas[instr_index]);14920 const extra = func.extraData(Function.Instruction.VaArg, data);
14734 try function_block.writeAbbrev(FunctionBlock.VaArg{14921 try function_block.writeAbbrev(FunctionBlock.VaArg{
14735 .list_type = extra.list.typeOf(@enumFromInt(func_index), self),14922 .list_type = extra.list.typeOf(@enumFromInt(func_index), self),
14736 .list = adapter.getOffsetValueIndex(extra.list),14923 .list = adapter.getOffsetValueIndex(extra.list),
...@@ -14740,7 +14927,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14740,7 +14927,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14740 .phi,14927 .phi,
14741 .@"phi fast",14928 .@"phi fast",
14742 => |kind| {14929 => |kind| {
14743 var extra = func.extraDataTrail(Function.Instruction.Phi, datas[instr_index]);14930 var extra = func.extraDataTrail(Function.Instruction.Phi, data);
14744 const vals = extra.trail.next(block_incoming_len, Value, &func);14931 const vals = extra.trail.next(block_incoming_len, Value, &func);
14745 const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func);14932 const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func);
1474614933
...@@ -14764,11 +14951,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14764,11 +14951,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14764 try function_block.writeUnabbrev(16, record.items);14951 try function_block.writeUnabbrev(16, record.items);
14765 },14952 },
14766 .ret => try function_block.writeAbbrev(FunctionBlock.Ret{14953 .ret => try function_block.writeAbbrev(FunctionBlock.Ret{
14767 .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),14954 .val = adapter.getOffsetValueIndex(@enumFromInt(data)),
14768 }),14955 }),
14769 .@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}),14956 .@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}),
14770 .atomicrmw => {14957 .atomicrmw => {
14771 const extra = func.extraData(Function.Instruction.AtomicRmw, datas[instr_index]);14958 const extra = func.extraData(Function.Instruction.AtomicRmw, data);
14772 try function_block.writeAbbrev(FunctionBlock.AtomicRmw{14959 try function_block.writeAbbrev(FunctionBlock.AtomicRmw{
14773 .ptr = adapter.getOffsetValueIndex(extra.ptr),14960 .ptr = adapter.getOffsetValueIndex(extra.ptr),
14774 .val = adapter.getOffsetValueIndex(extra.val),14961 .val = adapter.getOffsetValueIndex(extra.val),
...@@ -14782,7 +14969,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14782,7 +14969,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14782 .cmpxchg,14969 .cmpxchg,
14783 .@"cmpxchg weak",14970 .@"cmpxchg weak",
14784 => |kind| {14971 => |kind| {
14785 const extra = func.extraData(Function.Instruction.CmpXchg, datas[instr_index]);14972 const extra = func.extraData(Function.Instruction.CmpXchg, data);
1478614973
14787 try function_block.writeAbbrev(FunctionBlock.CmpXchg{14974 try function_block.writeAbbrev(FunctionBlock.CmpXchg{
14788 .ptr = adapter.getOffsetValueIndex(extra.ptr),14975 .ptr = adapter.getOffsetValueIndex(extra.ptr),
...@@ -14797,7 +14984,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14797,7 +14984,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14797 });14984 });
14798 },14985 },
14799 .fence => {14986 .fence => {
14800 const info: MemoryAccessInfo = @bitCast(datas[instr_index]);14987 const info: MemoryAccessInfo = @bitCast(data);
14801 try function_block.writeAbbrev(FunctionBlock.Fence{14988 try function_block.writeAbbrev(FunctionBlock.Fence{
14802 .ordering = info.success_ordering,14989 .ordering = info.success_ordering,
14803 .sync_scope = info.sync_scope,14990 .sync_scope = info.sync_scope,
...@@ -14806,7 +14993,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14806,7 +14993,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14806 }14993 }
1480714994
14808 if (!func.strip) {14995 if (!func.strip) {
14809 if (func.debug_locations.get(@enumFromInt(instr_index))) |debug_location| {14996 if (func.debug_locations.get(adapter.instruction_index)) |debug_location| {
14810 switch (debug_location) {14997 switch (debug_location) {
14811 .no_location => has_location = false,14998 .no_location => has_location = false,
14812 .location => |location| {14999 .location => |location| {
...@@ -14823,8 +15010,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14823,8 +15010,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14823 try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{});15010 try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{});
14824 }15011 }
14825 }15012 }
14826
14827 adapter.next();
14828 }15013 }
1482915014
14830 // VALUE_SYMTAB15015 // VALUE_SYMTAB
...@@ -14850,18 +15035,48 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14850,18 +15035,48 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14850 }15035 }
1485115036
14852 // METADATA_ATTACHMENT_BLOCK15037 // METADATA_ATTACHMENT_BLOCK
14853 if (!func.strip) blk: {15038 {
14854 const dbg = func.global.ptrConst(self).dbg;
14855
14856 if (dbg == .none) break :blk;
14857
14858 const MetadataAttachmentBlock = ir.MetadataAttachmentBlock;15039 const MetadataAttachmentBlock = ir.MetadataAttachmentBlock;
14859 var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false);15040 var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false);
1486015041
14861 try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{15042 dbg: {
14862 .kind = ir.MetadataKind.dbg,15043 if (func.strip) break :dbg;
14863 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),15044 const dbg = func.global.ptrConst(self).dbg;
14864 });15045 if (dbg == .none) break :dbg;
15046 try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentGlobalSingle{
15047 .kind = .dbg,
15048 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),
15049 });
15050 }
15051
15052 var instr_index: u32 = 0;
15053 for (func.instructions.items(.tag), func.instructions.items(.data)) |instr_tag, data| switch (instr_tag) {
15054 .arg, .block => {}, // not an actual instruction
15055 else => {
15056 instr_index += 1;
15057 },
15058 .br_cond, .@"switch" => {
15059 const weights = switch (instr_tag) {
15060 .br_cond => func.extraData(Function.Instruction.BrCond, data).weights,
15061 .@"switch" => func.extraData(Function.Instruction.Switch, data).weights,
15062 else => unreachable,
15063 };
15064 switch (weights) {
15065 .none => {},
15066 .unpredictable => try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{
15067 .inst = instr_index,
15068 .kind = .unpredictable,
15069 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(.empty_tuple) - 1),
15070 }),
15071 _ => try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{
15072 .inst = instr_index,
15073 .kind = .prof,
15074 .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(@enumFromInt(@intFromEnum(weights))) - 1),
15075 }),
15076 }
15077 instr_index += 1;
15078 },
15079 };
1486515080
14866 try metadata_attach_block.end();15081 try metadata_attach_block.end();
14867 }15082 }
src/codegen/llvm/ir.zig+198-29
...@@ -20,8 +20,142 @@ const ColumnAbbrev = AbbrevOp{ .vbr = 8 };...@@ -20,8 +20,142 @@ const ColumnAbbrev = AbbrevOp{ .vbr = 8 };
2020
21const BlockAbbrev = AbbrevOp{ .vbr = 6 };21const BlockAbbrev = AbbrevOp{ .vbr = 6 };
2222
23pub const MetadataKind = enum(u1) {23/// Unused tags are commented out so that they are omitted in the generated
24/// bitcode, which scans over this enum using reflection.
25pub const FixedMetadataKind = enum(u8) {
24 dbg = 0,26 dbg = 0,
27 //tbaa = 1,
28 prof = 2,
29 //fpmath = 3,
30 //range = 4,
31 //@"tbaa.struct" = 5,
32 //@"invariant.load" = 6,
33 //@"alias.scope" = 7,
34 //@"noalias" = 8,
35 //nontemporal = 9,
36 //@"llvm.mem.parallel_loop_access" = 10,
37 //nonnull = 11,
38 //dereferenceable = 12,
39 //dereferenceable_or_null = 13,
40 //@"make.implicit" = 14,
41 unpredictable = 15,
42 //@"invariant.group" = 16,
43 //@"align" = 17,
44 //@"llvm.loop" = 18,
45 //type = 19,
46 //section_prefix = 20,
47 //absolute_symbol = 21,
48 //associated = 22,
49 //callees = 23,
50 //irr_loop = 24,
51 //@"llvm.access.group" = 25,
52 //callback = 26,
53 //@"llvm.preserve.access.index" = 27,
54 //vcall_visibility = 28,
55 //noundef = 29,
56 //annotation = 30,
57 //nosanitize = 31,
58 //func_sanitize = 32,
59 //exclude = 33,
60 //memprof = 34,
61 //callsite = 35,
62 //kcfi_type = 36,
63 //pcsections = 37,
64 //DIAssignID = 38,
65 //@"coro.outside.frame" = 39,
66};
67
68pub const MetadataCode = enum(u8) {
69 /// MDSTRING: [values]
70 STRING_OLD = 1,
71 /// VALUE: [type num, value num]
72 VALUE = 2,
73 /// NODE: [n x md num]
74 NODE = 3,
75 /// STRING: [values]
76 NAME = 4,
77 /// DISTINCT_NODE: [n x md num]
78 DISTINCT_NODE = 5,
79 /// [n x [id, name]]
80 KIND = 6,
81 /// [distinct, line, col, scope, inlined-at?]
82 LOCATION = 7,
83 /// OLD_NODE: [n x (type num, value num)]
84 OLD_NODE = 8,
85 /// OLD_FN_NODE: [n x (type num, value num)]
86 OLD_FN_NODE = 9,
87 /// NAMED_NODE: [n x mdnodes]
88 NAMED_NODE = 10,
89 /// [m x [value, [n x [id, mdnode]]]
90 ATTACHMENT = 11,
91 /// [distinct, tag, vers, header, n x md num]
92 GENERIC_DEBUG = 12,
93 /// [distinct, count, lo]
94 SUBRANGE = 13,
95 /// [isUnsigned|distinct, value, name]
96 ENUMERATOR = 14,
97 /// [distinct, tag, name, size, align, enc]
98 BASIC_TYPE = 15,
99 /// [distinct, filename, directory, checksumkind, checksum]
100 FILE = 16,
101 /// [distinct, ...]
102 DERIVED_TYPE = 17,
103 /// [distinct, ...]
104 COMPOSITE_TYPE = 18,
105 /// [distinct, flags, types, cc]
106 SUBROUTINE_TYPE = 19,
107 /// [distinct, ...]
108 COMPILE_UNIT = 20,
109 /// [distinct, ...]
110 SUBPROGRAM = 21,
111 /// [distinct, scope, file, line, column]
112 LEXICAL_BLOCK = 22,
113 ///[distinct, scope, file, discriminator]
114 LEXICAL_BLOCK_FILE = 23,
115 /// [distinct, scope, file, name, line, exportSymbols]
116 NAMESPACE = 24,
117 /// [distinct, scope, name, type, ...]
118 TEMPLATE_TYPE = 25,
119 /// [distinct, scope, name, type, value, ...]
120 TEMPLATE_VALUE = 26,
121 /// [distinct, ...]
122 GLOBAL_VAR = 27,
123 /// [distinct, ...]
124 LOCAL_VAR = 28,
125 /// [distinct, n x element]
126 EXPRESSION = 29,
127 /// [distinct, name, file, line, ...]
128 OBJC_PROPERTY = 30,
129 /// [distinct, tag, scope, entity, line, name]
130 IMPORTED_ENTITY = 31,
131 /// [distinct, scope, name, ...]
132 MODULE = 32,
133 /// [distinct, macinfo, line, name, value]
134 MACRO = 33,
135 /// [distinct, macinfo, line, file, ...]
136 MACRO_FILE = 34,
137 /// [count, offset] blob([lengths][chars])
138 STRINGS = 35,
139 /// [valueid, n x [id, mdnode]]
140 GLOBAL_DECL_ATTACHMENT = 36,
141 /// [distinct, var, expr]
142 GLOBAL_VAR_EXPR = 37,
143 /// [offset]
144 INDEX_OFFSET = 38,
145 /// [bitpos]
146 INDEX = 39,
147 /// [distinct, scope, name, file, line]
148 LABEL = 40,
149 /// [distinct, name, size, align,...]
150 STRING_TYPE = 41,
151 /// [distinct, scope, name, variable,...]
152 COMMON_BLOCK = 44,
153 /// [distinct, count, lo, up, stride]
154 GENERIC_SUBRANGE = 45,
155 /// [n x [type num, value num]]
156 ARG_LIST = 46,
157 /// [distinct, ...]
158 ASSIGN_ID = 47,
25};159};
26160
27pub const Identification = struct {161pub const Identification = struct {
...@@ -622,16 +756,29 @@ pub const MetadataAttachmentBlock = struct {...@@ -622,16 +756,29 @@ pub const MetadataAttachmentBlock = struct {
622 pub const id = 16;756 pub const id = 16;
623757
624 pub const abbrevs = [_]type{758 pub const abbrevs = [_]type{
625 AttachmentSingle,759 AttachmentGlobalSingle,
760 AttachmentInstructionSingle,
626 };761 };
627762
628 pub const AttachmentSingle = struct {763 pub const AttachmentGlobalSingle = struct {
629 pub const ops = [_]AbbrevOp{764 pub const ops = [_]AbbrevOp{
630 .{ .literal = 11 },765 .{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
631 .{ .fixed = 1 },766 .{ .fixed = 1 },
632 MetadataAbbrev,767 MetadataAbbrev,
633 };768 };
634 kind: MetadataKind,769 kind: FixedMetadataKind,
770 metadata: Builder.Metadata,
771 };
772
773 pub const AttachmentInstructionSingle = struct {
774 pub const ops = [_]AbbrevOp{
775 .{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
776 ValueAbbrev,
777 .{ .fixed = 5 },
778 MetadataAbbrev,
779 };
780 inst: u32,
781 kind: FixedMetadataKind,
635 metadata: Builder.Metadata,782 metadata: Builder.Metadata,
636 };783 };
637};784};
...@@ -666,7 +813,7 @@ pub const MetadataBlock = struct {...@@ -666,7 +813,7 @@ pub const MetadataBlock = struct {
666813
667 pub const Strings = struct {814 pub const Strings = struct {
668 pub const ops = [_]AbbrevOp{815 pub const ops = [_]AbbrevOp{
669 .{ .literal = 35 },816 .{ .literal = @intFromEnum(MetadataCode.STRINGS) },
670 .{ .vbr = 6 },817 .{ .vbr = 6 },
671 .{ .vbr = 6 },818 .{ .vbr = 6 },
672 .blob,819 .blob,
...@@ -678,7 +825,7 @@ pub const MetadataBlock = struct {...@@ -678,7 +825,7 @@ pub const MetadataBlock = struct {
678825
679 pub const File = struct {826 pub const File = struct {
680 pub const ops = [_]AbbrevOp{827 pub const ops = [_]AbbrevOp{
681 .{ .literal = 16 },828 .{ .literal = @intFromEnum(MetadataCode.FILE) },
682 .{ .literal = 0 }, // is distinct829 .{ .literal = 0 }, // is distinct
683 MetadataAbbrev, // filename830 MetadataAbbrev, // filename
684 MetadataAbbrev, // directory831 MetadataAbbrev, // directory
...@@ -692,7 +839,7 @@ pub const MetadataBlock = struct {...@@ -692,7 +839,7 @@ pub const MetadataBlock = struct {
692839
693 pub const CompileUnit = struct {840 pub const CompileUnit = struct {
694 pub const ops = [_]AbbrevOp{841 pub const ops = [_]AbbrevOp{
695 .{ .literal = 20 },842 .{ .literal = @intFromEnum(MetadataCode.COMPILE_UNIT) },
696 .{ .literal = 1 }, // is distinct843 .{ .literal = 1 }, // is distinct
697 .{ .literal = std.dwarf.LANG.C99 }, // source language844 .{ .literal = std.dwarf.LANG.C99 }, // source language
698 MetadataAbbrev, // file845 MetadataAbbrev, // file
...@@ -726,7 +873,7 @@ pub const MetadataBlock = struct {...@@ -726,7 +873,7 @@ pub const MetadataBlock = struct {
726873
727 pub const Subprogram = struct {874 pub const Subprogram = struct {
728 pub const ops = [_]AbbrevOp{875 pub const ops = [_]AbbrevOp{
729 .{ .literal = 21 },876 .{ .literal = @intFromEnum(MetadataCode.SUBPROGRAM) },
730 .{ .literal = 0b111 }, // is distinct | has sp flags | has flags877 .{ .literal = 0b111 }, // is distinct | has sp flags | has flags
731 MetadataAbbrev, // scope878 MetadataAbbrev, // scope
732 MetadataAbbrev, // name879 MetadataAbbrev, // name
...@@ -763,7 +910,7 @@ pub const MetadataBlock = struct {...@@ -763,7 +910,7 @@ pub const MetadataBlock = struct {
763910
764 pub const LexicalBlock = struct {911 pub const LexicalBlock = struct {
765 pub const ops = [_]AbbrevOp{912 pub const ops = [_]AbbrevOp{
766 .{ .literal = 22 },913 .{ .literal = @intFromEnum(MetadataCode.LEXICAL_BLOCK) },
767 .{ .literal = 0 }, // is distinct914 .{ .literal = 0 }, // is distinct
768 MetadataAbbrev, // scope915 MetadataAbbrev, // scope
769 MetadataAbbrev, // file916 MetadataAbbrev, // file
...@@ -779,7 +926,7 @@ pub const MetadataBlock = struct {...@@ -779,7 +926,7 @@ pub const MetadataBlock = struct {
779926
780 pub const Location = struct {927 pub const Location = struct {
781 pub const ops = [_]AbbrevOp{928 pub const ops = [_]AbbrevOp{
782 .{ .literal = 7 },929 .{ .literal = @intFromEnum(MetadataCode.LOCATION) },
783 .{ .literal = 0 }, // is distinct930 .{ .literal = 0 }, // is distinct
784 LineAbbrev, // line931 LineAbbrev, // line
785 ColumnAbbrev, // column932 ColumnAbbrev, // column
...@@ -796,7 +943,7 @@ pub const MetadataBlock = struct {...@@ -796,7 +943,7 @@ pub const MetadataBlock = struct {
796943
797 pub const BasicType = struct {944 pub const BasicType = struct {
798 pub const ops = [_]AbbrevOp{945 pub const ops = [_]AbbrevOp{
799 .{ .literal = 15 },946 .{ .literal = @intFromEnum(MetadataCode.BASIC_TYPE) },
800 .{ .literal = 0 }, // is distinct947 .{ .literal = 0 }, // is distinct
801 .{ .literal = std.dwarf.TAG.base_type }, // tag948 .{ .literal = std.dwarf.TAG.base_type }, // tag
802 MetadataAbbrev, // name949 MetadataAbbrev, // name
...@@ -813,7 +960,7 @@ pub const MetadataBlock = struct {...@@ -813,7 +960,7 @@ pub const MetadataBlock = struct {
813960
814 pub const CompositeType = struct {961 pub const CompositeType = struct {
815 pub const ops = [_]AbbrevOp{962 pub const ops = [_]AbbrevOp{
816 .{ .literal = 18 },963 .{ .literal = @intFromEnum(MetadataCode.COMPOSITE_TYPE) },
817 .{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref964 .{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref
818 .{ .fixed = 32 }, // tag965 .{ .fixed = 32 }, // tag
819 MetadataAbbrev, // name966 MetadataAbbrev, // name
...@@ -852,7 +999,7 @@ pub const MetadataBlock = struct {...@@ -852,7 +999,7 @@ pub const MetadataBlock = struct {
852999
853 pub const DerivedType = struct {1000 pub const DerivedType = struct {
854 pub const ops = [_]AbbrevOp{1001 pub const ops = [_]AbbrevOp{
855 .{ .literal = 17 },1002 .{ .literal = @intFromEnum(MetadataCode.DERIVED_TYPE) },
856 .{ .literal = 0 }, // is distinct1003 .{ .literal = 0 }, // is distinct
857 .{ .fixed = 32 }, // tag1004 .{ .fixed = 32 }, // tag
858 MetadataAbbrev, // name1005 MetadataAbbrev, // name
...@@ -880,7 +1027,7 @@ pub const MetadataBlock = struct {...@@ -880,7 +1027,7 @@ pub const MetadataBlock = struct {
8801027
881 pub const SubroutineType = struct {1028 pub const SubroutineType = struct {
882 pub const ops = [_]AbbrevOp{1029 pub const ops = [_]AbbrevOp{
883 .{ .literal = 19 },1030 .{ .literal = @intFromEnum(MetadataCode.SUBROUTINE_TYPE) },
884 .{ .literal = 0 | 0x2 }, // is distinct | has no old type refs1031 .{ .literal = 0 | 0x2 }, // is distinct | has no old type refs
885 .{ .literal = 0 }, // flags1032 .{ .literal = 0 }, // flags
886 MetadataAbbrev, // types1033 MetadataAbbrev, // types
...@@ -891,7 +1038,7 @@ pub const MetadataBlock = struct {...@@ -891,7 +1038,7 @@ pub const MetadataBlock = struct {
891 };1038 };
8921039
893 pub const Enumerator = struct {1040 pub const Enumerator = struct {
894 pub const id = 14;1041 pub const id: MetadataCode = .ENUMERATOR;
8951042
896 pub const Flags = packed struct(u3) {1043 pub const Flags = packed struct(u3) {
897 distinct: bool = false,1044 distinct: bool = false,
...@@ -900,7 +1047,7 @@ pub const MetadataBlock = struct {...@@ -900,7 +1047,7 @@ pub const MetadataBlock = struct {
900 };1047 };
9011048
902 pub const ops = [_]AbbrevOp{1049 pub const ops = [_]AbbrevOp{
903 .{ .literal = Enumerator.id },1050 .{ .literal = @intFromEnum(Enumerator.id) },
904 .{ .fixed = @bitSizeOf(Flags) }, // flags1051 .{ .fixed = @bitSizeOf(Flags) }, // flags
905 .{ .vbr = 6 }, // bit width1052 .{ .vbr = 6 }, // bit width
906 MetadataAbbrev, // name1053 MetadataAbbrev, // name
...@@ -915,7 +1062,7 @@ pub const MetadataBlock = struct {...@@ -915,7 +1062,7 @@ pub const MetadataBlock = struct {
9151062
916 pub const Subrange = struct {1063 pub const Subrange = struct {
917 pub const ops = [_]AbbrevOp{1064 pub const ops = [_]AbbrevOp{
918 .{ .literal = 13 },1065 .{ .literal = @intFromEnum(MetadataCode.SUBRANGE) },
919 .{ .literal = 0b10 }, // is distinct | version1066 .{ .literal = 0b10 }, // is distinct | version
920 MetadataAbbrev, // count1067 MetadataAbbrev, // count
921 MetadataAbbrev, // lower bound1068 MetadataAbbrev, // lower bound
...@@ -929,7 +1076,7 @@ pub const MetadataBlock = struct {...@@ -929,7 +1076,7 @@ pub const MetadataBlock = struct {
9291076
930 pub const Expression = struct {1077 pub const Expression = struct {
931 pub const ops = [_]AbbrevOp{1078 pub const ops = [_]AbbrevOp{
932 .{ .literal = 29 },1079 .{ .literal = @intFromEnum(MetadataCode.EXPRESSION) },
933 .{ .literal = 0 | (3 << 1) }, // is distinct | version1080 .{ .literal = 0 | (3 << 1) }, // is distinct | version
934 MetadataArrayAbbrev, // elements1081 MetadataArrayAbbrev, // elements
935 };1082 };
...@@ -939,7 +1086,7 @@ pub const MetadataBlock = struct {...@@ -939,7 +1086,7 @@ pub const MetadataBlock = struct {
9391086
940 pub const Node = struct {1087 pub const Node = struct {
941 pub const ops = [_]AbbrevOp{1088 pub const ops = [_]AbbrevOp{
942 .{ .literal = 3 },1089 .{ .literal = @intFromEnum(MetadataCode.NODE) },
943 MetadataArrayAbbrev, // elements1090 MetadataArrayAbbrev, // elements
944 };1091 };
9451092
...@@ -948,7 +1095,7 @@ pub const MetadataBlock = struct {...@@ -948,7 +1095,7 @@ pub const MetadataBlock = struct {
9481095
949 pub const LocalVar = struct {1096 pub const LocalVar = struct {
950 pub const ops = [_]AbbrevOp{1097 pub const ops = [_]AbbrevOp{
951 .{ .literal = 28 },1098 .{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
952 .{ .literal = 0b10 }, // is distinct | has alignment1099 .{ .literal = 0b10 }, // is distinct | has alignment
953 MetadataAbbrev, // scope1100 MetadataAbbrev, // scope
954 MetadataAbbrev, // name1101 MetadataAbbrev, // name
...@@ -970,7 +1117,7 @@ pub const MetadataBlock = struct {...@@ -970,7 +1117,7 @@ pub const MetadataBlock = struct {
9701117
971 pub const Parameter = struct {1118 pub const Parameter = struct {
972 pub const ops = [_]AbbrevOp{1119 pub const ops = [_]AbbrevOp{
973 .{ .literal = 28 },1120 .{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
974 .{ .literal = 0b10 }, // is distinct | has alignment1121 .{ .literal = 0b10 }, // is distinct | has alignment
975 MetadataAbbrev, // scope1122 MetadataAbbrev, // scope
976 MetadataAbbrev, // name1123 MetadataAbbrev, // name
...@@ -993,7 +1140,7 @@ pub const MetadataBlock = struct {...@@ -993,7 +1140,7 @@ pub const MetadataBlock = struct {
9931140
994 pub const GlobalVar = struct {1141 pub const GlobalVar = struct {
995 pub const ops = [_]AbbrevOp{1142 pub const ops = [_]AbbrevOp{
996 .{ .literal = 27 },1143 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR) },
997 .{ .literal = 0b101 }, // is distinct | version1144 .{ .literal = 0b101 }, // is distinct | version
998 MetadataAbbrev, // scope1145 MetadataAbbrev, // scope
999 MetadataAbbrev, // name1146 MetadataAbbrev, // name
...@@ -1020,7 +1167,7 @@ pub const MetadataBlock = struct {...@@ -1020,7 +1167,7 @@ pub const MetadataBlock = struct {
10201167
1021 pub const GlobalVarExpression = struct {1168 pub const GlobalVarExpression = struct {
1022 pub const ops = [_]AbbrevOp{1169 pub const ops = [_]AbbrevOp{
1023 .{ .literal = 37 },1170 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR_EXPR) },
1024 .{ .literal = 0 }, // is distinct1171 .{ .literal = 0 }, // is distinct
1025 MetadataAbbrev, // variable1172 MetadataAbbrev, // variable
1026 MetadataAbbrev, // expression1173 MetadataAbbrev, // expression
...@@ -1032,7 +1179,7 @@ pub const MetadataBlock = struct {...@@ -1032,7 +1179,7 @@ pub const MetadataBlock = struct {
10321179
1033 pub const Constant = struct {1180 pub const Constant = struct {
1034 pub const ops = [_]AbbrevOp{1181 pub const ops = [_]AbbrevOp{
1035 .{ .literal = 2 },1182 .{ .literal = @intFromEnum(MetadataCode.VALUE) },
1036 MetadataAbbrev, // type1183 MetadataAbbrev, // type
1037 MetadataAbbrev, // value1184 MetadataAbbrev, // value
1038 };1185 };
...@@ -1043,7 +1190,7 @@ pub const MetadataBlock = struct {...@@ -1043,7 +1190,7 @@ pub const MetadataBlock = struct {
10431190
1044 pub const Name = struct {1191 pub const Name = struct {
1045 pub const ops = [_]AbbrevOp{1192 pub const ops = [_]AbbrevOp{
1046 .{ .literal = 4 },1193 .{ .literal = @intFromEnum(MetadataCode.NAME) },
1047 .{ .array_fixed = 8 }, // name1194 .{ .array_fixed = 8 }, // name
1048 };1195 };
10491196
...@@ -1052,7 +1199,7 @@ pub const MetadataBlock = struct {...@@ -1052,7 +1199,7 @@ pub const MetadataBlock = struct {
10521199
1053 pub const NamedNode = struct {1200 pub const NamedNode = struct {
1054 pub const ops = [_]AbbrevOp{1201 pub const ops = [_]AbbrevOp{
1055 .{ .literal = 10 },1202 .{ .literal = @intFromEnum(MetadataCode.NAMED_NODE) },
1056 MetadataArrayAbbrev, // elements1203 MetadataArrayAbbrev, // elements
1057 };1204 };
10581205
...@@ -1061,18 +1208,32 @@ pub const MetadataBlock = struct {...@@ -1061,18 +1208,32 @@ pub const MetadataBlock = struct {
10611208
1062 pub const GlobalDeclAttachment = struct {1209 pub const GlobalDeclAttachment = struct {
1063 pub const ops = [_]AbbrevOp{1210 pub const ops = [_]AbbrevOp{
1064 .{ .literal = 36 },1211 .{ .literal = @intFromEnum(MetadataCode.GLOBAL_DECL_ATTACHMENT) },
1065 ValueAbbrev, // value id1212 ValueAbbrev, // value id
1066 .{ .fixed = 1 }, // kind1213 .{ .fixed = 1 }, // kind
1067 MetadataAbbrev, // elements1214 MetadataAbbrev, // elements
1068 };1215 };
10691216
1070 value: Builder.Constant,1217 value: Builder.Constant,
1071 kind: MetadataKind,1218 kind: FixedMetadataKind,
1072 metadata: Builder.Metadata,1219 metadata: Builder.Metadata,
1073 };1220 };
1074};1221};
10751222
1223pub const OperandBundleTags = struct {
1224 pub const id = 21;
1225
1226 pub const abbrevs = [_]type{OperandBundleTag};
1227
1228 pub const OperandBundleTag = struct {
1229 pub const ops = [_]AbbrevOp{
1230 .{ .literal = 1 },
1231 .array_char6,
1232 };
1233 tag: []const u8,
1234 };
1235};
1236
1076pub const FunctionMetadataBlock = struct {1237pub const FunctionMetadataBlock = struct {
1077 pub const id = 15;1238 pub const id = 15;
10781239
...@@ -1132,6 +1293,7 @@ pub const FunctionBlock = struct {...@@ -1132,6 +1293,7 @@ pub const FunctionBlock = struct {
1132 Fence,1293 Fence,
1133 DebugLoc,1294 DebugLoc,
1134 DebugLocAgain,1295 DebugLocAgain,
1296 ColdOperandBundle,
1135 };1297 };
11361298
1137 pub const DeclareBlocks = struct {1299 pub const DeclareBlocks = struct {
...@@ -1644,6 +1806,13 @@ pub const FunctionBlock = struct {...@@ -1644,6 +1806,13 @@ pub const FunctionBlock = struct {
1644 .{ .literal = 33 },1806 .{ .literal = 33 },
1645 };1807 };
1646 };1808 };
1809
1810 pub const ColdOperandBundle = struct {
1811 pub const ops = [_]AbbrevOp{
1812 .{ .literal = 55 },
1813 .{ .literal = 0 },
1814 };
1815 };
1647};1816};
16481817
1649pub const FunctionValueSymbolTable = struct {1818pub const FunctionValueSymbolTable = struct {
src/codegen/spirv.zig+18-32
...@@ -410,7 +410,7 @@ const NavGen = struct {...@@ -410,7 +410,7 @@ const NavGen = struct {
410 }410 }
411411
412 pub fn fail(self: *NavGen, comptime format: []const u8, args: anytype) Error {412 pub fn fail(self: *NavGen, comptime format: []const u8, args: anytype) Error {
413 @setCold(true);413 @branchHint(.cold);
414 const zcu = self.pt.zcu;414 const zcu = self.pt.zcu;
415 const src_loc = zcu.navSrcLoc(self.owner_nav);415 const src_loc = zcu.navSrcLoc(self.owner_nav);
416 assert(self.error_msg == null);416 assert(self.error_msg == null);
...@@ -6173,11 +6173,10 @@ const NavGen = struct {...@@ -6173,11 +6173,10 @@ const NavGen = struct {
6173 const pt = self.pt;6173 const pt = self.pt;
6174 const zcu = pt.zcu;6174 const zcu = pt.zcu;
6175 const target = self.getTarget();6175 const target = self.getTarget();
6176 const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6176 const switch_br = self.air.unwrapSwitch(inst);
6177 const cond_ty = self.typeOf(pl_op.operand);6177 const cond_ty = self.typeOf(switch_br.operand);
6178 const cond = try self.resolve(pl_op.operand);6178 const cond = try self.resolve(switch_br.operand);
6179 var cond_indirect = try self.convertToIndirect(cond_ty, cond);6179 var cond_indirect = try self.convertToIndirect(cond_ty, cond);
6180 const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload);
61816180
6182 const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) {6181 const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) {
6183 .Bool, .ErrorSet => 1,6182 .Bool, .ErrorSet => 1,
...@@ -6204,18 +6203,15 @@ const NavGen = struct {...@@ -6204,18 +6203,15 @@ const NavGen = struct {
6204 else => return self.todo("implement switch for type {s}", .{@tagName(cond_ty.zigTypeTag(zcu))}),6203 else => return self.todo("implement switch for type {s}", .{@tagName(cond_ty.zigTypeTag(zcu))}),
6205 };6204 };
62066205
6207 const num_cases = switch_br.data.cases_len;6206 const num_cases = switch_br.cases_len;
62086207
6209 // Compute the total number of arms that we need.6208 // Compute the total number of arms that we need.
6210 // Zig switches are grouped by condition, so we need to loop through all of them6209 // Zig switches are grouped by condition, so we need to loop through all of them
6211 const num_conditions = blk: {6210 const num_conditions = blk: {
6212 var extra_index: usize = switch_br.end;
6213 var num_conditions: u32 = 0;6211 var num_conditions: u32 = 0;
6214 for (0..num_cases) |_| {6212 var it = switch_br.iterateCases();
6215 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);6213 while (it.next()) |case| {
6216 const case_body = self.air.extra[case.end + case.data.items_len ..][0..case.data.body_len];6214 num_conditions += @intCast(case.items.len);
6217 extra_index = case.end + case.data.items_len + case_body.len;
6218 num_conditions += case.data.items_len;
6219 }6215 }
6220 break :blk num_conditions;6216 break :blk num_conditions;
6221 };6217 };
...@@ -6244,17 +6240,12 @@ const NavGen = struct {...@@ -6244,17 +6240,12 @@ const NavGen = struct {
62446240
6245 // Emit each of the cases6241 // Emit each of the cases
6246 {6242 {
6247 var extra_index: usize = switch_br.end;6243 var it = switch_br.iterateCases();
6248 for (0..num_cases) |case_i| {6244 while (it.next()) |case| {
6249 // SPIR-V needs a literal here, which' width depends on the case condition.6245 // SPIR-V needs a literal here, which' width depends on the case condition.
6250 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);6246 const label = case_labels.at(case.idx);
6251 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6252 const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
6253 extra_index = case.end + case.data.items_len + case_body.len;
6254
6255 const label = case_labels.at(case_i);
62566247
6257 for (items) |item| {6248 for (case.items) |item| {
6258 const value = (try self.air.value(item, pt)) orelse unreachable;6249 const value = (try self.air.value(item, pt)) orelse unreachable;
6259 const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) {6250 const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) {
6260 .Bool, .Int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu),6251 .Bool, .Int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu),
...@@ -6285,20 +6276,15 @@ const NavGen = struct {...@@ -6285,20 +6276,15 @@ const NavGen = struct {
6285 }6276 }
62866277
6287 // Now, finally, we can start emitting each of the cases.6278 // Now, finally, we can start emitting each of the cases.
6288 var extra_index: usize = switch_br.end;6279 var it = switch_br.iterateCases();
6289 for (0..num_cases) |case_i| {6280 while (it.next()) |case| {
6290 const case = self.air.extraData(Air.SwitchBr.Case, extra_index);6281 const label = case_labels.at(case.idx);
6291 const items: []const Air.Inst.Ref = @ptrCast(self.air.extra[case.end..][0..case.data.items_len]);
6292 const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
6293 extra_index = case.end + case.data.items_len + case_body.len;
6294
6295 const label = case_labels.at(case_i);
62966282
6297 try self.beginSpvBlock(label);6283 try self.beginSpvBlock(label);
62986284
6299 switch (self.control_flow) {6285 switch (self.control_flow) {
6300 .structured => {6286 .structured => {
6301 const next_block = try self.genStructuredBody(.selection, case_body);6287 const next_block = try self.genStructuredBody(.selection, case.body);
6302 incoming_structured_blocks.appendAssumeCapacity(.{6288 incoming_structured_blocks.appendAssumeCapacity(.{
6303 .src_label = self.current_block_label,6289 .src_label = self.current_block_label,
6304 .next_block = next_block,6290 .next_block = next_block,
...@@ -6306,12 +6292,12 @@ const NavGen = struct {...@@ -6306,12 +6292,12 @@ const NavGen = struct {
6306 try self.func.body.emitBranch(self.spv.gpa, merge_label.?);6292 try self.func.body.emitBranch(self.spv.gpa, merge_label.?);
6307 },6293 },
6308 .unstructured => {6294 .unstructured => {
6309 try self.genBody(case_body);6295 try self.genBody(case.body);
6310 },6296 },
6311 }6297 }
6312 }6298 }
63136299
6314 const else_body: []const Air.Inst.Index = @ptrCast(self.air.extra[extra_index..][0..switch_br.data.else_body_len]);6300 const else_body = it.elseBody();
6315 try self.beginSpvBlock(default);6301 try self.beginSpvBlock(default);
6316 if (else_body.len != 0) {6302 if (else_body.len != 0) {
6317 switch (self.control_flow) {6303 switch (self.control_flow) {
src/crash_report.zig+1-1
...@@ -153,8 +153,8 @@ fn writeFilePath(file: *Zcu.File, writer: anytype) !void {...@@ -153,8 +153,8 @@ fn writeFilePath(file: *Zcu.File, writer: anytype) !void {
153}153}
154154
155pub fn compilerPanic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, maybe_ret_addr: ?usize) noreturn {155pub fn compilerPanic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, maybe_ret_addr: ?usize) noreturn {
156 @branchHint(.cold);
156 PanicSwitch.preDispatch();157 PanicSwitch.preDispatch();
157 @setCold(true);
158 const ret_addr = maybe_ret_addr orelse @returnAddress();158 const ret_addr = maybe_ret_addr orelse @returnAddress();
159 const stack_ctx: StackContext = .{ .current = .{ .ret_addr = ret_addr } };159 const stack_ctx: StackContext = .{ .current = .{ .ret_addr = ret_addr } };
160 PanicSwitch.dispatch(error_return_trace, stack_ctx, msg);160 PanicSwitch.dispatch(error_return_trace, stack_ctx, msg);
src/print_air.zig+25-21
...@@ -297,8 +297,8 @@ const Writer = struct {...@@ -297,8 +297,8 @@ const Writer = struct {
297 .union_init => try w.writeUnionInit(s, inst),297 .union_init => try w.writeUnionInit(s, inst),
298 .br => try w.writeBr(s, inst),298 .br => try w.writeBr(s, inst),
299 .cond_br => try w.writeCondBr(s, inst),299 .cond_br => try w.writeCondBr(s, inst),
300 .@"try" => try w.writeTry(s, inst),300 .@"try", .try_cold => try w.writeTry(s, inst),
301 .try_ptr => try w.writeTryPtr(s, inst),301 .try_ptr, .try_ptr_cold => try w.writeTryPtr(s, inst),
302 .switch_br => try w.writeSwitchBr(s, inst),302 .switch_br => try w.writeSwitchBr(s, inst),
303 .cmpxchg_weak, .cmpxchg_strong => try w.writeCmpxchg(s, inst),303 .cmpxchg_weak, .cmpxchg_strong => try w.writeCmpxchg(s, inst),
304 .fence => try w.writeFence(s, inst),304 .fence => try w.writeFence(s, inst),
...@@ -825,41 +825,40 @@ const Writer = struct {...@@ -825,41 +825,40 @@ const Writer = struct {
825 }825 }
826826
827 fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {827 fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
828 const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;828 const switch_br = w.air.unwrapSwitch(inst);
829 const switch_br = w.air.extraData(Air.SwitchBr, pl_op.payload);829
830 const liveness = if (w.liveness) |liveness|830 const liveness = if (w.liveness) |liveness|
831 liveness.getSwitchBr(w.gpa, inst, switch_br.data.cases_len + 1) catch831 liveness.getSwitchBr(w.gpa, inst, switch_br.cases_len + 1) catch
832 @panic("out of memory")832 @panic("out of memory")
833 else blk: {833 else blk: {
834 const slice = w.gpa.alloc([]const Air.Inst.Index, switch_br.data.cases_len + 1) catch834 const slice = w.gpa.alloc([]const Air.Inst.Index, switch_br.cases_len + 1) catch
835 @panic("out of memory");835 @panic("out of memory");
836 @memset(slice, &.{});836 @memset(slice, &.{});
837 break :blk Liveness.SwitchBrTable{ .deaths = slice };837 break :blk Liveness.SwitchBrTable{ .deaths = slice };
838 };838 };
839 defer w.gpa.free(liveness.deaths);839 defer w.gpa.free(liveness.deaths);
840 var extra_index: usize = switch_br.end;
841 var case_i: u32 = 0;
842840
843 try w.writeOperand(s, inst, 0, pl_op.operand);841 try w.writeOperand(s, inst, 0, switch_br.operand);
844 if (w.skip_body) return s.writeAll(", ...");842 if (w.skip_body) return s.writeAll(", ...");
845 const old_indent = w.indent;843 const old_indent = w.indent;
846 w.indent += 2;844 w.indent += 2;
847845
848 while (case_i < switch_br.data.cases_len) : (case_i += 1) {846 var it = switch_br.iterateCases();
849 const case = w.air.extraData(Air.SwitchBr.Case, extra_index);847 while (it.next()) |case| {
850 const items = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra[case.end..][0..case.data.items_len]));
851 const case_body: []const Air.Inst.Index = @ptrCast(w.air.extra[case.end + items.len ..][0..case.data.body_len]);
852 extra_index = case.end + case.data.items_len + case_body.len;
853
854 try s.writeAll(", [");848 try s.writeAll(", [");
855 for (items, 0..) |item, item_i| {849 for (case.items, 0..) |item, item_i| {
856 if (item_i != 0) try s.writeAll(", ");850 if (item_i != 0) try s.writeAll(", ");
857 try w.writeInstRef(s, item, false);851 try w.writeInstRef(s, item, false);
858 }852 }
859 try s.writeAll("] => {\n");853 try s.writeAll("] ");
854 const hint = switch_br.getHint(case.idx);
855 if (hint != .none) {
856 try s.print(".{s} ", .{@tagName(hint)});
857 }
858 try s.writeAll("=> {\n");
860 w.indent += 2;859 w.indent += 2;
861860
862 const deaths = liveness.deaths[case_i];861 const deaths = liveness.deaths[case.idx];
863 if (deaths.len != 0) {862 if (deaths.len != 0) {
864 try s.writeByteNTimes(' ', w.indent);863 try s.writeByteNTimes(' ', w.indent);
865 for (deaths, 0..) |operand, i| {864 for (deaths, 0..) |operand, i| {
...@@ -869,15 +868,20 @@ const Writer = struct {...@@ -869,15 +868,20 @@ const Writer = struct {
869 try s.writeAll("\n");868 try s.writeAll("\n");
870 }869 }
871870
872 try w.writeBody(s, case_body);871 try w.writeBody(s, case.body);
873 w.indent -= 2;872 w.indent -= 2;
874 try s.writeByteNTimes(' ', w.indent);873 try s.writeByteNTimes(' ', w.indent);
875 try s.writeAll("}");874 try s.writeAll("}");
876 }875 }
877876
878 const else_body: []const Air.Inst.Index = @ptrCast(w.air.extra[extra_index..][0..switch_br.data.else_body_len]);877 const else_body = it.elseBody();
879 if (else_body.len != 0) {878 if (else_body.len != 0) {
880 try s.writeAll(", else => {\n");879 try s.writeAll(", else ");
880 const hint = switch_br.getElseHint();
881 if (hint != .none) {
882 try s.print(".{s} ", .{@tagName(hint)});
883 }
884 try s.writeAll("=> {\n");
881 w.indent += 2;885 w.indent += 2;
882886
883 const deaths = liveness.deaths[liveness.deaths.len - 1];887 const deaths = liveness.deaths[liveness.deaths.len - 1];
src/print_zir.zig+2-15
...@@ -429,7 +429,6 @@ const Writer = struct {...@@ -429,7 +429,6 @@ const Writer = struct {
429 .elem_val_imm => try self.writeElemValImm(stream, inst),429 .elem_val_imm => try self.writeElemValImm(stream, inst),
430430
431 .@"export" => try self.writePlNodeExport(stream, inst),431 .@"export" => try self.writePlNodeExport(stream, inst),
432 .export_value => try self.writePlNodeExportValue(stream, inst),
433432
434 .call => try self.writeCall(stream, inst, .direct),433 .call => try self.writeCall(stream, inst, .direct),
435 .field_call => try self.writeCall(stream, inst, .field),434 .field_call => try self.writeCall(stream, inst, .field),
...@@ -565,7 +564,6 @@ const Writer = struct {...@@ -565,7 +564,6 @@ const Writer = struct {
565 .fence,564 .fence,
566 .set_float_mode,565 .set_float_mode,
567 .set_align_stack,566 .set_align_stack,
568 .set_cold,
569 .wasm_memory_size,567 .wasm_memory_size,
570 .int_from_error,568 .int_from_error,
571 .error_from_int,569 .error_from_int,
...@@ -574,6 +572,7 @@ const Writer = struct {...@@ -574,6 +572,7 @@ const Writer = struct {
574 .work_item_id,572 .work_item_id,
575 .work_group_size,573 .work_group_size,
576 .work_group_id,574 .work_group_id,
575 .branch_hint,
577 => {576 => {
578 const inst_data = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;577 const inst_data = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;
579 try self.writeInstRef(stream, inst_data.operand);578 try self.writeInstRef(stream, inst_data.operand);
...@@ -1007,20 +1006,8 @@ const Writer = struct {...@@ -1007,20 +1006,8 @@ const Writer = struct {
1007 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1006 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
1008 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;1007 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1009 const extra = self.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;1008 const extra = self.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;
1010 const decl_name = self.code.nullTerminatedString(extra.decl_name);
10111009
1012 try self.writeInstRef(stream, extra.namespace);1010 try self.writeInstRef(stream, extra.exported);
1013 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});
1014 try self.writeInstRef(stream, extra.options);
1015 try stream.writeAll(") ");
1016 try self.writeSrcNode(stream, inst_data.src_node);
1017 }
1018
1019 fn writePlNodeExportValue(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
1020 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1021 const extra = self.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;
1022
1023 try self.writeInstRef(stream, extra.operand);
1024 try stream.writeAll(", ");1011 try stream.writeAll(", ");
1025 try self.writeInstRef(stream, extra.options);1012 try self.writeInstRef(stream, extra.options);
1026 try stream.writeAll(") ");1013 try stream.writeAll(") ");
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/behavior.zig+1
...@@ -12,6 +12,7 @@ test {...@@ -12,6 +12,7 @@ test {
12 _ = @import("behavior/bitcast.zig");12 _ = @import("behavior/bitcast.zig");
13 _ = @import("behavior/bitreverse.zig");13 _ = @import("behavior/bitreverse.zig");
14 _ = @import("behavior/bool.zig");14 _ = @import("behavior/bool.zig");
15 _ = @import("behavior/builtin_functions_returning_void_or_noreturn.zig");
15 _ = @import("behavior/byteswap.zig");16 _ = @import("behavior/byteswap.zig");
16 _ = @import("behavior/byval_arg_var.zig");17 _ = @import("behavior/byval_arg_var.zig");
17 _ = @import("behavior/call.zig");18 _ = @import("behavior/call.zig");
test/behavior/basic.zig+83-6
...@@ -107,13 +107,90 @@ test "non const ptr to aliased type" {...@@ -107,13 +107,90 @@ test "non const ptr to aliased type" {
107 try expect(?*int == ?*i32);107 try expect(?*int == ?*i32);
108}108}
109109
110test "cold function" {110test "function branch hints" {
111 thisIsAColdFn();111 const S = struct {
112 comptime thisIsAColdFn();112 fn none() void {
113 @branchHint(.none);
114 }
115 fn likely() void {
116 @branchHint(.likely);
117 }
118 fn unlikely() void {
119 @branchHint(.unlikely);
120 }
121 fn cold() void {
122 @branchHint(.cold);
123 }
124 fn unpredictable() void {
125 @branchHint(.unpredictable);
126 }
127 };
128 S.none();
129 S.likely();
130 S.unlikely();
131 S.cold();
132 S.unpredictable();
133 comptime S.none();
134 comptime S.likely();
135 comptime S.unlikely();
136 comptime S.cold();
137 comptime S.unpredictable();
138}
139
140test "if branch hints" {
141 var t: bool = undefined;
142 t = true;
143 if (t) {
144 @branchHint(.likely);
145 } else {
146 @branchHint(.cold);
147 }
113}148}
114149
115fn thisIsAColdFn() void {150test "switch branch hints" {
116 @setCold(true);151 var t: bool = undefined;
152 t = true;
153 switch (t) {
154 true => {
155 @branchHint(.likely);
156 },
157 false => {
158 @branchHint(.cold);
159 },
160 }
161}
162
163test "orelse branch hints" {
164 var x: ?u32 = undefined;
165 x = 123;
166 const val = x orelse val: {
167 @branchHint(.cold);
168 break :val 456;
169 };
170 try expect(val == 123);
171}
172
173test "catch branch hints" {
174 var x: error{Bad}!u32 = undefined;
175 x = 123;
176 const val = x catch val: {
177 @branchHint(.cold);
178 break :val 456;
179 };
180 try expect(val == 123);
181}
182
183test "and/or branch hints" {
184 var t: bool = undefined;
185 t = true;
186 try expect(t or b: {
187 @branchHint(.unlikely);
188 break :b false;
189 });
190 try expect(t and b: {
191 @branchHint(.likely);
192 break :b true;
193 });
117}194}
118195
119test "unicode escape in character literal" {196test "unicode escape in character literal" {
...@@ -734,7 +811,7 @@ test "extern variable with non-pointer opaque type" {...@@ -734,7 +811,7 @@ test "extern variable with non-pointer opaque type" {
734 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;811 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
735 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO812 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
736813
737 @export(var_to_export, .{ .name = "opaque_extern_var" });814 @export(&var_to_export, .{ .name = "opaque_extern_var" });
738 try expect(@as(*align(1) u32, @ptrCast(&opaque_extern_var)).* == 42);815 try expect(@as(*align(1) u32, @ptrCast(&opaque_extern_var)).* == 42);
739}816}
740extern var opaque_extern_var: opaque {};817extern var opaque_extern_var: opaque {};
test/behavior/builtin_functions_returning_void_or_noreturn.zig+1-2
...@@ -15,14 +15,13 @@ test {...@@ -15,14 +15,13 @@ test {
15 var val: u8 = undefined;15 var val: u8 = undefined;
16 try testing.expectEqual({}, @atomicStore(u8, &val, 0, .unordered));16 try testing.expectEqual({}, @atomicStore(u8, &val, 0, .unordered));
17 try testing.expectEqual(void, @TypeOf(@breakpoint()));17 try testing.expectEqual(void, @TypeOf(@breakpoint()));
18 try testing.expectEqual({}, @export(x, .{ .name = "x" }));18 try testing.expectEqual({}, @export(&x, .{ .name = "x" }));
19 try testing.expectEqual({}, @fence(.acquire));19 try testing.expectEqual({}, @fence(.acquire));
20 try testing.expectEqual({}, @memcpy(@as([*]u8, @ptrFromInt(1))[0..0], @as([*]u8, @ptrFromInt(1))[0..0]));20 try testing.expectEqual({}, @memcpy(@as([*]u8, @ptrFromInt(1))[0..0], @as([*]u8, @ptrFromInt(1))[0..0]));
21 try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined));21 try testing.expectEqual({}, @memset(@as([*]u8, @ptrFromInt(1))[0..0], undefined));
22 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));22 try testing.expectEqual(noreturn, @TypeOf(if (true) @panic("") else {}));
23 try testing.expectEqual({}, @prefetch(&val, .{}));23 try testing.expectEqual({}, @prefetch(&val, .{}));
24 try testing.expectEqual({}, @setAlignStack(16));24 try testing.expectEqual({}, @setAlignStack(16));
25 try testing.expectEqual({}, @setCold(true));
26 try testing.expectEqual({}, @setEvalBranchQuota(0));25 try testing.expectEqual({}, @setEvalBranchQuota(0));
27 try testing.expectEqual({}, @setFloatMode(.optimized));26 try testing.expectEqual({}, @setFloatMode(.optimized));
28 try testing.expectEqual({}, @setRuntimeSafety(true));27 try testing.expectEqual({}, @setRuntimeSafety(true));
test/behavior/export_builtin.zig+6-26
...@@ -2,7 +2,7 @@ const builtin = @import("builtin");...@@ -2,7 +2,7 @@ const builtin = @import("builtin");
2const std = @import("std");2const std = @import("std");
3const expect = std.testing.expect;3const expect = std.testing.expect;
44
5test "exporting enum type and value" {5test "exporting enum value" {
6 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;6 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
7 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;7 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
88
...@@ -10,7 +10,7 @@ test "exporting enum type and value" {...@@ -10,7 +10,7 @@ test "exporting enum type and value" {
10 const E = enum(c_int) { one, two };10 const E = enum(c_int) { one, two };
11 const e: E = .two;11 const e: E = .two;
12 comptime {12 comptime {
13 @export(e, .{ .name = "e" });13 @export(&e, .{ .name = "e" });
14 }14 }
15 };15 };
16 try expect(S.e == .two);16 try expect(S.e == .two);
...@@ -23,13 +23,13 @@ test "exporting with internal linkage" {...@@ -23,13 +23,13 @@ test "exporting with internal linkage" {
23 const S = struct {23 const S = struct {
24 fn foo() callconv(.C) void {}24 fn foo() callconv(.C) void {}
25 comptime {25 comptime {
26 @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });26 @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
27 }27 }
28 };28 };
29 S.foo();29 S.foo();
30}30}
3131
32test "exporting using field access" {32test "exporting using namespace access" {
33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
3535
...@@ -38,7 +38,7 @@ test "exporting using field access" {...@@ -38,7 +38,7 @@ test "exporting using field access" {
38 const x: u32 = 5;38 const x: u32 = 5;
39 };39 };
40 comptime {40 comptime {
41 @export(Inner.x, .{ .name = "foo", .linkage = .internal });41 @export(&Inner.x, .{ .name = "foo", .linkage = .internal });
42 }42 }
43 };43 };
4444
...@@ -57,29 +57,9 @@ test "exporting comptime-known value" {...@@ -57,29 +57,9 @@ test "exporting comptime-known value" {
57 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;57 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
5858
59 const x: u32 = 10;59 const x: u32 = 10;
60 @export(x, .{ .name = "exporting_comptime_known_value_foo" });60 @export(&x, .{ .name = "exporting_comptime_known_value_foo" });
61 const S = struct {61 const S = struct {
62 extern const exporting_comptime_known_value_foo: u32;62 extern const exporting_comptime_known_value_foo: u32;
63 };63 };
64 try expect(S.exporting_comptime_known_value_foo == 10);64 try expect(S.exporting_comptime_known_value_foo == 10);
65}65}
66
67test "exporting comptime var" {
68 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
69 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
70 if (builtin.zig_backend == .stage2_x86_64 and
71 (builtin.target.ofmt != .elf and
72 builtin.target.ofmt != .macho and
73 builtin.target.ofmt != .coff)) return error.SkipZigTest;
74 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
75 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
76 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
77
78 comptime var x: u32 = 5;
79 @export(x, .{ .name = "exporting_comptime_var_foo" });
80 x = 7; // modifying this now shouldn't change anything
81 const S = struct {
82 extern const exporting_comptime_var_foo: u32;
83 };
84 try expect(S.exporting_comptime_var_foo == 5);
85}
test/behavior/export_c_keywords.zig+12-12
...@@ -24,21 +24,21 @@ export fn some_non_c_keyword_function() Id {...@@ -24,21 +24,21 @@ export fn some_non_c_keyword_function() Id {
24}24}
2525
26comptime {26comptime {
27 @export(int, .{ .name = "long" });27 @export(&int, .{ .name = "long" });
28 @export(int, .{ .name = "an_alias_of_int" });28 @export(&int, .{ .name = "an_alias_of_int" });
2929
30 @export(some_non_c_keyword_variable, .{ .name = "void" });30 @export(&some_non_c_keyword_variable, .{ .name = "void" });
31 @export(some_non_c_keyword_variable, .{ .name = "an_alias_of_some_non_c_keyword_variable" });31 @export(&some_non_c_keyword_variable, .{ .name = "an_alias_of_some_non_c_keyword_variable" });
3232
33 @export(@"if", .{ .name = "else" });33 @export(&@"if", .{ .name = "else" });
34 @export(@"if", .{ .name = "an_alias_of_if" });34 @export(&@"if", .{ .name = "an_alias_of_if" });
3535
36 @export(some_non_c_keyword_constant, .{ .name = "switch" });36 @export(&some_non_c_keyword_constant, .{ .name = "switch" });
37 @export(some_non_c_keyword_constant, .{ .name = "an_alias_of_some_non_c_keyword_constant" });37 @export(&some_non_c_keyword_constant, .{ .name = "an_alias_of_some_non_c_keyword_constant" });
3838
39 @export(float, .{ .name = "double" });39 @export(&float, .{ .name = "double" });
40 @export(float, .{ .name = "an_alias_of_float" });40 @export(&float, .{ .name = "an_alias_of_float" });
4141
42 @export(some_non_c_keyword_function, .{ .name = "break" });42 @export(&some_non_c_keyword_function, .{ .name = "break" });
43 @export(some_non_c_keyword_function, .{ .name = "an_alias_of_some_non_c_keyword_function" });43 @export(&some_non_c_keyword_function, .{ .name = "an_alias_of_some_non_c_keyword_function" });
44}44}
test/behavior/generics.zig+1-1
...@@ -320,7 +320,7 @@ test "generic function instantiation non-duplicates" {...@@ -320,7 +320,7 @@ test "generic function instantiation non-duplicates" {
320320
321 const S = struct {321 const S = struct {
322 fn copy(comptime T: type, dest: []T, source: []const T) void {322 fn copy(comptime T: type, dest: []T, source: []const T) void {
323 @export(foo, .{ .name = "test_generic_instantiation_non_dupe" });323 @export(&foo, .{ .name = "test_generic_instantiation_non_dupe" });
324 for (source, 0..) |s, i| dest[i] = s;324 for (source, 0..) |s, i| dest[i] = s;
325 }325 }
326326
test/cases/compile_errors/@export_with_undeclared_identifier.zig deleted-9
...@@ -1,9 +0,0 @@
1export fn a() void {
2 @export(bogus, .{ .name = "bogus_alias" });
3}
4
5// error
6// backend=stage2
7// target=native
8//
9// :2:13: error: use of undeclared identifier 'bogus'
test/cases/compile_errors/export_with_empty_name_string.zig+2-2
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1pub export fn entry() void {}1pub export fn entry() void {}
2comptime {2comptime {
3 @export(entry, .{ .name = "" });3 @export(&entry, .{ .name = "" });
4}4}
55
6// error6// error
7// backend=llvm7// backend=llvm
8// target=native8// target=native
9//9//
10// :3:24: error: exported symbol name cannot be empty10// :3:25: error: exported symbol name cannot be empty
test/cases/compile_errors/exported_enum_without_explicit_integer_tag_type.zig+2-2
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1const E = enum { one, two };1const E = enum { one, two };
2comptime {2comptime {
3 @export(E, .{ .name = "E" });3 @export(&E, .{ .name = "E" });
4}4}
5const e: E = .two;5const e: E = .two;
6comptime {6comptime {
7 @export(e, .{ .name = "e" });7 @export(&e, .{ .name = "e" });
8}8}
99
10// error10// error
test/cases/compile_errors/exporting_primitive_values.zig deleted-29
...@@ -1,29 +0,0 @@
1pub export fn entry1() void {
2 @export(u100, .{ .name = "a" });
3}
4pub export fn entry3() void {
5 @export(undefined, .{ .name = "b" });
6}
7pub export fn entry4() void {
8 @export(null, .{ .name = "c" });
9}
10pub export fn entry5() void {
11 @export(false, .{ .name = "d" });
12}
13pub export fn entry6() void {
14 @export(u8, .{ .name = "e" });
15}
16pub export fn entry7() void {
17 @export(u65535, .{ .name = "f" });
18}
19
20// error
21// backend=llvm
22// target=native
23//
24// :2:13: error: unable to export primitive value
25// :5:13: error: unable to export primitive value
26// :8:13: error: unable to export primitive value
27// :11:13: error: unable to export primitive value
28// :14:13: error: unable to export primitive value
29// :17:13: error: unable to export primitive value
test/cases/compile_errors/function-only_builtins_outside_function.zig+2-2
...@@ -3,7 +3,7 @@ comptime {...@@ -3,7 +3,7 @@ comptime {
3}3}
44
5comptime {5comptime {
6 @setCold(true);6 @branchHint(.cold);
7}7}
88
9comptime {9comptime {
...@@ -55,7 +55,7 @@ comptime {...@@ -55,7 +55,7 @@ comptime {
55// target=native55// target=native
56//56//
57// :2:5: error: '@setAlignStack' outside function scope57// :2:5: error: '@setAlignStack' outside function scope
58// :6:5: error: '@setCold' outside function scope58// :6:5: error: '@branchHint' outside function scope
59// :10:5: error: '@src' outside function scope59// :10:5: error: '@src' outside function scope
60// :14:5: error: '@returnAddress' outside function scope60// :14:5: error: '@returnAddress' outside function scope
61// :18:5: error: '@frameAddress' outside function scope61// :18:5: error: '@frameAddress' outside function scope
test/cases/compile_errors/invalid_branch_hint.zig created+41
...@@ -0,0 +1,41 @@
1const globl = g: {
2 @branchHint(.none);
3 break :g {};
4};
5
6comptime {
7 @branchHint(.none);
8}
9
10test {
11 @branchHint(.none);
12}
13
14export fn foo() void {
15 {
16 @branchHint(.none);
17 }
18}
19
20export fn bar() void {
21 _ = (b: {
22 @branchHint(.none);
23 break :b true;
24 }) or true;
25}
26
27export fn qux() void {
28 (b: {
29 @branchHint(.none);
30 break :b @as(?void, {});
31 }) orelse unreachable;
32}
33
34// error
35//
36// :2:5: error: '@branchHint' outside function scope
37// :7:5: error: '@branchHint' outside function scope
38// :11:5: error: '@branchHint' must appear as the first statement in a function or conditional branch
39// :16:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
40// :22:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
41// :29:9: error: '@branchHint' must appear as the first statement in a function or conditional branch
test/cases/compile_errors/missing_member_in_namespace_export.zig deleted-10
...@@ -1,10 +0,0 @@
1const S = struct {};
2comptime {
3 @export(S.foo, .{ .name = "foo" });
4}
5
6// error
7// target=native
8//
9// :3:14: error: struct 'tmp.S' has no member named 'foo'
10// :1:11: note: struct declared here
test/cases/compile_errors/wrong_types_given_to_export.zig+2-2
...@@ -1,11 +1,11 @@...@@ -1,11 +1,11 @@
1fn entry() callconv(.C) void {}1fn entry() callconv(.C) void {}
2comptime {2comptime {
3 @export(entry, .{ .name = "entry", .linkage = @as(u32, 1234) });3 @export(&entry, .{ .name = "entry", .linkage = @as(u32, 1234) });
4}4}
55
6// error6// error
7// backend=stage27// backend=stage2
8// target=native8// target=native
9//9//
10// :3:41: error: expected type 'builtin.GlobalLinkage', found 'u32'10// :3:42: error: expected type 'builtin.GlobalLinkage', found 'u32'
11// :?:?: note: enum declared here11// :?:?: note: enum declared here
test/link/elf.zig+2-2
...@@ -937,8 +937,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {...@@ -937,8 +937,8 @@ fn testEmitStaticLib(b: *Build, opts: Options) *Step {
937 \\}937 \\}
938 \\export var strongBar: usize = 100;938 \\export var strongBar: usize = 100;
939 \\comptime {939 \\comptime {
940 \\ @export(weakFoo, .{ .name = "weakFoo", .linkage = .weak });940 \\ @export(&weakFoo, .{ .name = "weakFoo", .linkage = .weak });
941 \\ @export(strongBar, .{ .name = "strongBarAlias", .linkage = .strong });941 \\ @export(&strongBar, .{ .name = "strongBarAlias", .linkage = .strong });
942 \\}942 \\}
943 ,943 ,
944 });944 });
test/link/macho.zig+2-2
...@@ -196,7 +196,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {...@@ -196,7 +196,7 @@ fn testDuplicateDefinitions(b: *Build, opts: Options) *Step {
196 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes = 196 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
197 \\var x: usize = 1;197 \\var x: usize = 1;
198 \\export fn strong() void { x += 1; }198 \\export fn strong() void { x += 1; }
199 \\comptime { @export(weakImpl, .{ .name = "weak", .linkage = .weak }); }199 \\comptime { @export(&weakImpl, .{ .name = "weak", .linkage = .weak }); }
200 \\fn weakImpl() callconv(.C) void { x += 1; }200 \\fn weakImpl() callconv(.C) void { x += 1; }
201 \\extern fn weak() void;201 \\extern fn weak() void;
202 \\pub fn main() void {202 \\pub fn main() void {
...@@ -1676,7 +1676,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {...@@ -1676,7 +1676,7 @@ fn testReexportsZig(b: *Build, opts: Options) *Step {
1676 \\ return x;1676 \\ return x;
1677 \\}1677 \\}
1678 \\comptime {1678 \\comptime {
1679 \\ @export(foo, .{ .name = "bar", .linkage = .strong });1679 \\ @export(&foo, .{ .name = "bar", .linkage = .strong });
1680 \\}1680 \\}
1681 });1681 });
16821682
test/standalone/global_linkage/obj1.zig+2-2
...@@ -2,6 +2,6 @@ var internal_integer: usize = 1;...@@ -2,6 +2,6 @@ var internal_integer: usize = 1;
2var obj1_integer: usize = 421;2var obj1_integer: usize = 421;
33
4comptime {4comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });5 @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });6 @export(&obj1_integer, .{ .name = "obj1_integer", .linkage = .strong });
7}7}
test/standalone/global_linkage/obj2.zig+2-2
...@@ -2,6 +2,6 @@ var internal_integer: usize = 2;...@@ -2,6 +2,6 @@ var internal_integer: usize = 2;
2var obj2_integer: usize = 422;2var obj2_integer: usize = 422;
33
4comptime {4comptime {
5 @export(internal_integer, .{ .name = "internal_integer", .linkage = .internal });5 @export(&internal_integer, .{ .name = "internal_integer", .linkage = .internal });
6 @export(obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });6 @export(&obj2_integer, .{ .name = "obj2_integer", .linkage = .strong });
7}7}
tools/gen_outline_atomics.zig+1-1
...@@ -48,7 +48,7 @@ pub fn main() !void {...@@ -48,7 +48,7 @@ pub fn main() !void {
48 @tagName(op), n.toBytes(), @tagName(order),48 @tagName(op), n.toBytes(), @tagName(order),
49 });49 });
50 try writeFunction(arena, w, name, op, n, order);50 try writeFunction(arena, w, name, op, n, order);
51 try footer.writer().print(" @export({s}, .{{ .name = \"{s}\", .linkage = linkage }});\n", .{51 try footer.writer().print(" @export(&{s}, .{{ .name = \"{s}\", .linkage = linkage }});\n", .{
52 name, name,52 name, name,
53 });53 });
54 }54 }