authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-13 18:15:18-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-12-13 18:15:18-05:00
log6378644d4ea561a79edf44056609681e6d1438d1
tree84094f36ee3dd9e3befaf33a5a7da82fc5388da7
parent65270cdc3345e9840427179168a09ef6e4dd34b9
parent51ed5416ab2969a366c8c6bdc487f357bad267c3
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #13907 from Vexu/call-merge

Remove `stack` option from `@call`

38 files changed, 248 insertions(+), 320 deletions(-)

doc/langref.html.in+30-37
......@@ -4270,7 +4270,7 @@ test "using @typeInfo with runtime values" {
42704270}
42714271
42724272// Calls to `isFieldOptional` on `Struct1` get unrolled to an equivalent
4273// of this function:
4273// of this function:
42744274fn isFieldOptionalUnrolled(field_index: usize) !bool {
42754275 return switch (field_index) {
42764276 0 => false,
......@@ -7801,7 +7801,7 @@ comptime {
78017801 {#header_close#}
78027802
78037803 {#header_open|@call#}
7804 <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: anytype, args: anytype) anytype{#endsyntax#}</pre>
7804 <pre>{#syntax#}@call(modifier: std.builtin.CallModifier, function: anytype, args: anytype) anytype{#endsyntax#}</pre>
78057805 <p>
78067806 Calls a function, in the same way that invoking an expression with parentheses does:
78077807 </p>
......@@ -7809,7 +7809,7 @@ comptime {
78097809const expect = @import("std").testing.expect;
78107810
78117811test "noinline function call" {
7812 try expect(@call(.{}, add, .{3, 9}) == 12);
7812 try expect(@call(.auto, add, .{3, 9}) == 12);
78137813}
78147814
78157815fn add(a: i32, b: i32) i32 {
......@@ -7818,48 +7818,41 @@ fn add(a: i32, b: i32) i32 {
78187818 {#code_end#}
78197819 <p>
78207820 {#syntax#}@call{#endsyntax#} allows more flexibility than normal function call syntax does. The
7821 {#syntax#}CallOptions{#endsyntax#} struct is reproduced here:
7821 {#syntax#}CallModifier{#endsyntax#} enum is reproduced here:
78227822 </p>
7823 {#syntax_block|zig|builtin.CallOptions struct#}
7824pub const CallOptions = struct {
7825 modifier: Modifier = .auto,
7826
7827 /// Only valid when `Modifier` is `Modifier.async_kw`.
7828 stack: ?[]align(std.Target.stack_align) u8 = null,
7829
7830 pub const Modifier = enum {
7831 /// Equivalent to function call syntax.
7832 auto,
7823 {#syntax_block|zig|builtin.CallModifier struct#}
7824pub const CallModifier = enum {
7825 /// Equivalent to function call syntax.
7826 auto,
78337827
7834 /// Equivalent to async keyword used with function call syntax.
7835 async_kw,
7828 /// Equivalent to async keyword used with function call syntax.
7829 async_kw,
78367830
7837 /// Prevents tail call optimization. This guarantees that the return
7838 /// address will point to the callsite, as opposed to the callsite's
7839 /// callsite. If the call is otherwise required to be tail-called
7840 /// or inlined, a compile error is emitted instead.
7841 never_tail,
7831 /// Prevents tail call optimization. This guarantees that the return
7832 /// address will point to the callsite, as opposed to the callsite's
7833 /// callsite. If the call is otherwise required to be tail-called
7834 /// or inlined, a compile error is emitted instead.
7835 never_tail,
78427836
7843 /// Guarantees that the call will not be inlined. If the call is
7844 /// otherwise required to be inlined, a compile error is emitted instead.
7845 never_inline,
7837 /// Guarantees that the call will not be inlined. If the call is
7838 /// otherwise required to be inlined, a compile error is emitted instead.
7839 never_inline,
78467840
7847 /// Asserts that the function call will not suspend. This allows a
7848 /// non-async function to call an async function.
7849 no_async,
7841 /// Asserts that the function call will not suspend. This allows a
7842 /// non-async function to call an async function.
7843 no_async,
78507844
7851 /// Guarantees that the call will be generated with tail call optimization.
7852 /// If this is not possible, a compile error is emitted instead.
7853 always_tail,
7845 /// Guarantees that the call will be generated with tail call optimization.
7846 /// If this is not possible, a compile error is emitted instead.
7847 always_tail,
78547848
7855 /// Guarantees that the call will inlined at the callsite.
7856 /// If this is not possible, a compile error is emitted instead.
7857 always_inline,
7849 /// Guarantees that the call will inlined at the callsite.
7850 /// If this is not possible, a compile error is emitted instead.
7851 always_inline,
78587852
7859 /// Evaluates the call at compile-time. If the call cannot be completed at
7860 /// compile-time, a compile error is emitted instead.
7861 compile_time,
7862 };
7853 /// Evaluates the call at compile-time. If the call cannot be completed at
7854 /// compile-time, a compile error is emitted instead.
7855 compile_time,
78637856};
78647857 {#end_syntax_block#}
78657858 {#header_close#}
lib/compiler_rt/stack_probe.zig+7-7
......@@ -236,27 +236,27 @@ fn win_probe_stack_adjust_sp() void {
236236
237237pub fn _chkstk() callconv(.Naked) void {
238238 @setRuntimeSafety(false);
239 @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
239 @call(.always_inline, win_probe_stack_adjust_sp, .{});
240240}
241241pub fn __chkstk() callconv(.Naked) void {
242242 @setRuntimeSafety(false);
243243 if (comptime arch.isAARCH64()) {
244 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
244 @call(.always_inline, win_probe_stack_only, .{});
245245 } else switch (arch) {
246 .x86 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}),
247 .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}),
246 .x86 => @call(.always_inline, win_probe_stack_adjust_sp, .{}),
247 .x86_64 => @call(.always_inline, win_probe_stack_only, .{}),
248248 else => unreachable,
249249 }
250250}
251251pub fn ___chkstk() callconv(.Naked) void {
252252 @setRuntimeSafety(false);
253 @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{});
253 @call(.always_inline, win_probe_stack_adjust_sp, .{});
254254}
255255pub fn __chkstk_ms() callconv(.Naked) void {
256256 @setRuntimeSafety(false);
257 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
257 @call(.always_inline, win_probe_stack_only, .{});
258258}
259259pub fn ___chkstk_ms() callconv(.Naked) void {
260260 @setRuntimeSafety(false);
261 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
261 @call(.always_inline, win_probe_stack_only, .{});
262262}
lib/std/Thread.zig+4-4
......@@ -387,10 +387,10 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
387387
388388 switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {
389389 .NoReturn => {
390 @call(.{}, f, args);
390 @call(.auto, f, args);
391391 },
392392 .Void => {
393 @call(.{}, f, args);
393 @call(.auto, f, args);
394394 return default_value;
395395 },
396396 .Int => |info| {
......@@ -398,7 +398,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
398398 @compileError(bad_fn_ret);
399399 }
400400
401 const status = @call(.{}, f, args);
401 const status = @call(.auto, f, args);
402402 if (Impl != PosixThreadImpl) {
403403 return status;
404404 }
......@@ -411,7 +411,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
411411 @compileError(bad_fn_ret);
412412 }
413413
414 @call(.{}, f, args) catch |err| {
414 @call(.auto, f, args) catch |err| {
415415 std.debug.print("error: {s}\n", .{@errorName(err)});
416416 if (@errorReturnTrace()) |trace| {
417417 std.debug.dumpStackTrace(trace.*);
lib/std/builtin.zig+32-39
......@@ -591,45 +591,38 @@ fn testVersionParse() !void {
591591
592592/// This data structure is used by the Zig language code generation and
593593/// therefore must be kept in sync with the compiler implementation.
594pub const CallOptions = struct {
595 modifier: Modifier = .auto,
596
597 /// Only valid when `Modifier` is `Modifier.async_kw`.
598 stack: ?[]align(std.Target.stack_align) u8 = null,
599
600 pub const Modifier = enum {
601 /// Equivalent to function call syntax.
602 auto,
603
604 /// Equivalent to async keyword used with function call syntax.
605 async_kw,
606
607 /// Prevents tail call optimization. This guarantees that the return
608 /// address will point to the callsite, as opposed to the callsite's
609 /// callsite. If the call is otherwise required to be tail-called
610 /// or inlined, a compile error is emitted instead.
611 never_tail,
612
613 /// Guarantees that the call will not be inlined. If the call is
614 /// otherwise required to be inlined, a compile error is emitted instead.
615 never_inline,
616
617 /// Asserts that the function call will not suspend. This allows a
618 /// non-async function to call an async function.
619 no_async,
620
621 /// Guarantees that the call will be generated with tail call optimization.
622 /// If this is not possible, a compile error is emitted instead.
623 always_tail,
624
625 /// Guarantees that the call will inlined at the callsite.
626 /// If this is not possible, a compile error is emitted instead.
627 always_inline,
628
629 /// Evaluates the call at compile-time. If the call cannot be completed at
630 /// compile-time, a compile error is emitted instead.
631 compile_time,
632 };
594pub const CallModifier = enum {
595 /// Equivalent to function call syntax.
596 auto,
597
598 /// Equivalent to async keyword used with function call syntax.
599 async_kw,
600
601 /// Prevents tail call optimization. This guarantees that the return
602 /// address will point to the callsite, as opposed to the callsite's
603 /// callsite. If the call is otherwise required to be tail-called
604 /// or inlined, a compile error is emitted instead.
605 never_tail,
606
607 /// Guarantees that the call will not be inlined. If the call is
608 /// otherwise required to be inlined, a compile error is emitted instead.
609 never_inline,
610
611 /// Asserts that the function call will not suspend. This allows a
612 /// non-async function to call an async function.
613 no_async,
614
615 /// Guarantees that the call will be generated with tail call optimization.
616 /// If this is not possible, a compile error is emitted instead.
617 always_tail,
618
619 /// Guarantees that the call will inlined at the callsite.
620 /// If this is not possible, a compile error is emitted instead.
621 always_inline,
622
623 /// Evaluates the call at compile-time. If the call cannot be completed at
624 /// compile-time, a compile error is emitted instead.
625 compile_time,
633626};
634627
635628/// This data structure is used by the Zig language code generation and
lib/std/crypto/siphash.zig+6-13
......@@ -78,12 +78,10 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
7878 pub fn update(self: *Self, b: []const u8) void {
7979 std.debug.assert(b.len % 8 == 0);
8080
81 const inl = std.builtin.CallOptions{ .modifier = .always_inline };
82
8381 var off: usize = 0;
8482 while (off < b.len) : (off += 8) {
8583 const blob = b[off..][0..8].*;
86 @call(inl, round, .{ self, blob });
84 @call(.always_inline, round, .{ self, blob });
8785 }
8886
8987 self.msg_len +%= @truncate(u8, b.len);
......@@ -105,12 +103,9 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
105103 self.v2 ^= 0xff;
106104 }
107105
108 // TODO this is a workaround, should be able to supply the value without a separate variable
109 const inl = std.builtin.CallOptions{ .modifier = .always_inline };
110
111106 comptime var i: usize = 0;
112107 inline while (i < d_rounds) : (i += 1) {
113 @call(inl, sipRound, .{self});
108 @call(.always_inline, sipRound, .{self});
114109 }
115110
116111 const b1 = self.v0 ^ self.v1 ^ self.v2 ^ self.v3;
......@@ -122,7 +117,7 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
122117
123118 comptime var j: usize = 0;
124119 inline while (j < d_rounds) : (j += 1) {
125 @call(inl, sipRound, .{self});
120 @call(.always_inline, sipRound, .{self});
126121 }
127122
128123 const b2 = self.v0 ^ self.v1 ^ self.v2 ^ self.v3;
......@@ -133,11 +128,9 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
133128 const m = mem.readIntLittle(u64, b[0..8]);
134129 self.v3 ^= m;
135130
136 // TODO this is a workaround, should be able to supply the value without a separate variable
137 const inl = std.builtin.CallOptions{ .modifier = .always_inline };
138131 comptime var i: usize = 0;
139132 inline while (i < c_rounds) : (i += 1) {
140 @call(inl, sipRound, .{self});
133 @call(.always_inline, sipRound, .{self});
141134 }
142135
143136 self.v0 ^= m;
......@@ -163,8 +156,8 @@ fn SipHashStateless(comptime T: type, comptime c_rounds: usize, comptime d_round
163156 pub fn hash(msg: []const u8, key: *const [key_length]u8) T {
164157 const aligned_len = msg.len - (msg.len % 8);
165158 var c = Self.init(key);
166 @call(.{ .modifier = .always_inline }, c.update, .{msg[0..aligned_len]});
167 return @call(.{ .modifier = .always_inline }, c.final, .{msg[aligned_len..]});
159 @call(.always_inline, c.update, .{msg[0..aligned_len]});
160 return @call(.always_inline, c.final, .{msg[aligned_len..]});
168161 }
169162 };
170163}
lib/std/dynamic_library.zig+1-1
......@@ -381,7 +381,7 @@ pub const DlDynlib = struct {
381381 pub fn lookup(self: *DlDynlib, comptime T: type, name: [:0]const u8) ?T {
382382 // dlsym (and other dl-functions) secretly take shadow parameter - return address on stack
383383 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66826
384 if (@call(.{ .modifier = .never_tail }, system.dlsym, .{ self.handle, name.ptr })) |symbol| {
384 if (@call(.never_tail, system.dlsym, .{ self.handle, name.ptr })) |symbol| {
385385 return @ptrCast(T, symbol);
386386 } else {
387387 return null;
lib/std/hash/auto_hash.zig+4-4
......@@ -66,7 +66,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
6666 const Key = @TypeOf(key);
6767
6868 if (strat == .Shallow and comptime meta.trait.hasUniqueRepresentation(Key)) {
69 @call(.{ .modifier = .always_inline }, hasher.update, .{mem.asBytes(&key)});
69 @call(.always_inline, hasher.update, .{mem.asBytes(&key)});
7070 return;
7171 }
7272
......@@ -89,12 +89,12 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
8989 // TODO Check if the situation is better after #561 is resolved.
9090 .Int => {
9191 if (comptime meta.trait.hasUniqueRepresentation(Key)) {
92 @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)});
92 @call(.always_inline, hasher.update, .{std.mem.asBytes(&key)});
9393 } else {
9494 // Take only the part containing the key value, the remaining
9595 // bytes are undefined and must not be hashed!
9696 const byte_size = comptime std.math.divCeil(comptime_int, @bitSizeOf(Key), 8) catch unreachable;
97 @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)[0..byte_size]});
97 @call(.always_inline, hasher.update, .{std.mem.asBytes(&key)[0..byte_size]});
9898 }
9999 },
100100
......@@ -103,7 +103,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
103103 .ErrorSet => hash(hasher, @errorToInt(key), strat),
104104 .AnyFrame, .Fn => hash(hasher, @ptrToInt(key), strat),
105105
106 .Pointer => @call(.{ .modifier = .always_inline }, hashPointer, .{ hasher, key, strat }),
106 .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),
107107
108108 .Optional => if (key) |k| hash(hasher, k, strat),
109109
lib/std/hash/cityhash.zig+4-4
......@@ -185,7 +185,7 @@ pub const CityHash64 = struct {
185185 }
186186
187187 fn hashLen16(u: u64, v: u64) u64 {
188 return @call(.{ .modifier = .always_inline }, hash128To64, .{ u, v });
188 return @call(.always_inline, hash128To64, .{ u, v });
189189 }
190190
191191 fn hashLen16Mul(low: u64, high: u64, mul: u64) u64 {
......@@ -198,7 +198,7 @@ pub const CityHash64 = struct {
198198 }
199199
200200 fn hash128To64(low: u64, high: u64) u64 {
201 return @call(.{ .modifier = .always_inline }, hashLen16Mul, .{ low, high, 0x9ddfea08eb382d69 });
201 return @call(.always_inline, hashLen16Mul, .{ low, high, 0x9ddfea08eb382d69 });
202202 }
203203
204204 fn hashLen0To16(str: []const u8) u64 {
......@@ -279,7 +279,7 @@ pub const CityHash64 = struct {
279279 }
280280
281281 fn weakHashLen32WithSeeds(ptr: [*]const u8, a: u64, b: u64) WeakPair {
282 return @call(.{ .modifier = .always_inline }, weakHashLen32WithSeedsHelper, .{
282 return @call(.always_inline, weakHashLen32WithSeedsHelper, .{
283283 fetch64(ptr, 0),
284284 fetch64(ptr, 8),
285285 fetch64(ptr, 16),
......@@ -334,7 +334,7 @@ pub const CityHash64 = struct {
334334 }
335335
336336 pub fn hashWithSeed(str: []const u8, seed: u64) u64 {
337 return @call(.{ .modifier = .always_inline }, Self.hashWithSeeds, .{ str, k2, seed });
337 return @call(.always_inline, Self.hashWithSeeds, .{ str, k2, seed });
338338 }
339339
340340 pub fn hashWithSeeds(str: []const u8, seed0: u64, seed1: u64) u64 {
lib/std/hash/murmur.zig+9-9
......@@ -9,7 +9,7 @@ pub const Murmur2_32 = struct {
99 const Self = @This();
1010
1111 pub fn hash(str: []const u8) u32 {
12 return @call(.{ .modifier = .always_inline }, Self.hashWithSeed, .{ str, default_seed });
12 return @call(.always_inline, Self.hashWithSeed, .{ str, default_seed });
1313 }
1414
1515 pub fn hashWithSeed(str: []const u8, seed: u32) u32 {
......@@ -45,7 +45,7 @@ pub const Murmur2_32 = struct {
4545 }
4646
4747 pub fn hashUint32(v: u32) u32 {
48 return @call(.{ .modifier = .always_inline }, Self.hashUint32WithSeed, .{ v, default_seed });
48 return @call(.always_inline, Self.hashUint32WithSeed, .{ v, default_seed });
4949 }
5050
5151 pub fn hashUint32WithSeed(v: u32, seed: u32) u32 {
......@@ -65,7 +65,7 @@ pub const Murmur2_32 = struct {
6565 }
6666
6767 pub fn hashUint64(v: u64) u32 {
68 return @call(.{ .modifier = .always_inline }, Self.hashUint64WithSeed, .{ v, default_seed });
68 return @call(.always_inline, Self.hashUint64WithSeed, .{ v, default_seed });
6969 }
7070
7171 pub fn hashUint64WithSeed(v: u64, seed: u32) u32 {
......@@ -94,7 +94,7 @@ pub const Murmur2_64 = struct {
9494 const Self = @This();
9595
9696 pub fn hash(str: []const u8) u64 {
97 return @call(.{ .modifier = .always_inline }, Self.hashWithSeed, .{ str, default_seed });
97 return @call(.always_inline, Self.hashWithSeed, .{ str, default_seed });
9898 }
9999
100100 pub fn hashWithSeed(str: []const u8, seed: u64) u64 {
......@@ -128,7 +128,7 @@ pub const Murmur2_64 = struct {
128128 }
129129
130130 pub fn hashUint32(v: u32) u64 {
131 return @call(.{ .modifier = .always_inline }, Self.hashUint32WithSeed, .{ v, default_seed });
131 return @call(.always_inline, Self.hashUint32WithSeed, .{ v, default_seed });
132132 }
133133
134134 pub fn hashUint32WithSeed(v: u32, seed: u64) u64 {
......@@ -145,7 +145,7 @@ pub const Murmur2_64 = struct {
145145 }
146146
147147 pub fn hashUint64(v: u64) u64 {
148 return @call(.{ .modifier = .always_inline }, Self.hashUint64WithSeed, .{ v, default_seed });
148 return @call(.always_inline, Self.hashUint64WithSeed, .{ v, default_seed });
149149 }
150150
151151 pub fn hashUint64WithSeed(v: u64, seed: u64) u64 {
......@@ -173,7 +173,7 @@ pub const Murmur3_32 = struct {
173173 }
174174
175175 pub fn hash(str: []const u8) u32 {
176 return @call(.{ .modifier = .always_inline }, Self.hashWithSeed, .{ str, default_seed });
176 return @call(.always_inline, Self.hashWithSeed, .{ str, default_seed });
177177 }
178178
179179 pub fn hashWithSeed(str: []const u8, seed: u32) u32 {
......@@ -221,7 +221,7 @@ pub const Murmur3_32 = struct {
221221 }
222222
223223 pub fn hashUint32(v: u32) u32 {
224 return @call(.{ .modifier = .always_inline }, Self.hashUint32WithSeed, .{ v, default_seed });
224 return @call(.always_inline, Self.hashUint32WithSeed, .{ v, default_seed });
225225 }
226226
227227 pub fn hashUint32WithSeed(v: u32, seed: u32) u32 {
......@@ -247,7 +247,7 @@ pub const Murmur3_32 = struct {
247247 }
248248
249249 pub fn hashUint64(v: u64) u32 {
250 return @call(.{ .modifier = .always_inline }, Self.hashUint64WithSeed, .{ v, default_seed });
250 return @call(.always_inline, Self.hashUint64WithSeed, .{ v, default_seed });
251251 }
252252
253253 pub fn hashUint64WithSeed(v: u64, seed: u32) u32 {
lib/std/hash/wyhash.zig+3-3
......@@ -65,7 +65,7 @@ const WyhashStateless = struct {
6565
6666 var off: usize = 0;
6767 while (off < b.len) : (off += 32) {
68 @call(.{ .modifier = .always_inline }, self.round, .{b[off .. off + 32]});
68 @call(.always_inline, self.round, .{b[off .. off + 32]});
6969 }
7070
7171 self.msg_len += b.len;
......@@ -121,8 +121,8 @@ const WyhashStateless = struct {
121121 const aligned_len = input.len - (input.len % 32);
122122
123123 var c = WyhashStateless.init(seed);
124 @call(.{ .modifier = .always_inline }, c.update, .{input[0..aligned_len]});
125 return @call(.{ .modifier = .always_inline }, c.final, .{input[aligned_len..]});
124 @call(.always_inline, c.update, .{input[0..aligned_len]});
125 return @call(.always_inline, c.final, .{input[aligned_len..]});
126126 }
127127};
128128
lib/std/math/big/int.zig+2-2
......@@ -3587,7 +3587,7 @@ fn llshl(r: []Limb, a: []const Limb, shift: usize) void {
35873587 const dst_i = src_i + limb_shift;
35883588
35893589 const src_digit = a[src_i];
3590 r[dst_i] = carry | @call(.{ .modifier = .always_inline }, math.shr, .{
3590 r[dst_i] = carry | @call(.always_inline, math.shr, .{
35913591 Limb,
35923592 src_digit,
35933593 limb_bits - @intCast(Limb, interior_limb_shift),
......@@ -3615,7 +3615,7 @@ fn llshr(r: []Limb, a: []const Limb, shift: usize) void {
36153615
36163616 const src_digit = a[src_i];
36173617 r[dst_i] = carry | (src_digit >> interior_limb_shift);
3618 carry = @call(.{ .modifier = .always_inline }, math.shl, .{
3618 carry = @call(.always_inline, math.shl, .{
36193619 Limb,
36203620 src_digit,
36213621 limb_bits - @intCast(Limb, interior_limb_shift),
lib/std/os/linux.zig+1-1
......@@ -263,7 +263,7 @@ pub fn fork() usize {
263263/// the compiler is not aware of how vfork affects control flow and you may
264264/// see different results in optimized builds.
265265pub inline fn vfork() usize {
266 return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});
266 return @call(.always_inline, syscall0, .{.vfork});
267267}
268268
269269pub fn futimens(fd: i32, times: *const [2]timespec) usize {
lib/std/start.zig+9-9
......@@ -229,15 +229,15 @@ fn _DllMainCRTStartup(
229229fn wasm_freestanding_start() callconv(.C) void {
230230 // This is marked inline because for some reason LLVM in
231231 // release mode fails to inline it, and we want fewer call frames in stack traces.
232 _ = @call(.{ .modifier = .always_inline }, callMain, .{});
232 _ = @call(.always_inline, callMain, .{});
233233}
234234
235235fn wasi_start() callconv(.C) void {
236236 // The function call is marked inline because for some reason LLVM in
237237 // release mode fails to inline it, and we want fewer call frames in stack traces.
238238 switch (builtin.wasi_exec_model) {
239 .reactor => _ = @call(.{ .modifier = .always_inline }, callMain, .{}),
240 .command => std.os.wasi.proc_exit(@call(.{ .modifier = .always_inline }, callMain, .{})),
239 .reactor => _ = @call(.always_inline, callMain, .{}),
240 .command => std.os.wasi.proc_exit(@call(.always_inline, callMain, .{})),
241241 }
242242}
243243
......@@ -373,7 +373,7 @@ fn _start() callconv(.Naked) noreturn {
373373 }
374374 // If LLVM inlines stack variables into _start, they will overwrite
375375 // the command line argument data.
376 @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
376 @call(.never_inline, posixCallMainAndExit, .{});
377377}
378378
379379fn WinStartup() callconv(std.os.windows.WINAPI) noreturn {
......@@ -459,7 +459,7 @@ fn posixCallMainAndExit() callconv(.C) noreturn {
459459 expandStackSize(phdrs);
460460 }
461461
462 std.os.exit(@call(.{ .modifier = .always_inline }, callMainWithArgs, .{ argc, argv, envp }));
462 std.os.exit(@call(.always_inline, callMainWithArgs, .{ argc, argv, envp }));
463463}
464464
465465fn expandStackSize(phdrs: []elf.Phdr) void {
......@@ -510,12 +510,12 @@ fn main(c_argc: c_int, c_argv: [*c][*c]u8, c_envp: [*c][*c]u8) callconv(.C) c_in
510510 expandStackSize(phdrs);
511511 }
512512
513 return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), @ptrCast([*][*:0]u8, c_argv), envp });
513 return @call(.always_inline, callMainWithArgs, .{ @intCast(usize, c_argc), @ptrCast([*][*:0]u8, c_argv), envp });
514514}
515515
516516fn mainWithoutEnv(c_argc: c_int, c_argv: [*c][*c]u8) callconv(.C) c_int {
517517 std.os.argv = @ptrCast([*][*:0]u8, c_argv)[0..@intCast(usize, c_argc)];
518 return @call(.{ .modifier = .always_inline }, callMain, .{});
518 return @call(.always_inline, callMain, .{});
519519}
520520
521521// General error message for a malformed return type
......@@ -545,7 +545,7 @@ inline fn initEventLoopAndCallMain() u8 {
545545
546546 // This is marked inline because for some reason LLVM in release mode fails to inline it,
547547 // and we want fewer call frames in stack traces.
548 return @call(.{ .modifier = .always_inline }, callMain, .{});
548 return @call(.always_inline, callMain, .{});
549549}
550550
551551// This is marked inline because for some reason LLVM in release mode fails to inline it,
......@@ -574,7 +574,7 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT {
574574
575575 // This is marked inline because for some reason LLVM in release mode fails to inline it,
576576 // and we want fewer call frames in stack traces.
577 return @call(.{ .modifier = .always_inline }, call_wWinMain, .{});
577 return @call(.always_inline, call_wWinMain, .{});
578578}
579579
580580fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 {
lib/std/testing.zig+2-2
......@@ -828,7 +828,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
828828 var failing_allocator_inst = std.testing.FailingAllocator.init(backing_allocator, std.math.maxInt(usize));
829829 args.@"0" = failing_allocator_inst.allocator();
830830
831 try @call(.{}, test_fn, args);
831 try @call(.auto, test_fn, args);
832832 break :x failing_allocator_inst.index;
833833 };
834834
......@@ -837,7 +837,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
837837 var failing_allocator_inst = std.testing.FailingAllocator.init(backing_allocator, fail_index);
838838 args.@"0" = failing_allocator_inst.allocator();
839839
840 if (@call(.{}, test_fn, args)) |_| {
840 if (@call(.auto, test_fn, args)) |_| {
841841 if (failing_allocator_inst.has_induced_failure) {
842842 return error.SwallowedOutOfMemoryError;
843843 } else {
lib/std/unicode/throughput_test.zig+1-1
......@@ -25,7 +25,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
2525 var r: usize = undefined;
2626 while (i < N) : (i += 1) {
2727 r = try @call(
28 .{ .modifier = .never_inline },
28 .never_inline,
2929 std.unicode.utf8CountCodepoints,
3030 .{buf},
3131 );
src/AstGen.zig+3-3
......@@ -8297,11 +8297,11 @@ fn builtinCall(
82978297 return rvalue(gz, ri, result, node);
82988298 },
82998299 .call => {
8300 const options = try comptimeExpr(gz, scope, .{ .rl = .{ .ty = .call_options_type } }, params[0]);
8300 const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .modifier_type } }, params[0]);
83018301 const callee = try calleeExpr(gz, scope, params[1]);
83028302 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);
83038303 const result = try gz.addPlNode(.builtin_call, node, Zir.Inst.BuiltinCall{
8304 .options = options,
8304 .modifier = modifier,
83058305 .callee = callee,
83068306 .args = args,
83078307 .flags = .{
......@@ -8674,7 +8674,7 @@ fn callExpr(
86748674 const astgen = gz.astgen;
86758675
86768676 const callee = try calleeExpr(gz, scope, call.ast.fn_expr);
8677 const modifier: std.builtin.CallOptions.Modifier = blk: {
8677 const modifier: std.builtin.CallModifier = blk: {
86788678 if (gz.force_comptime) {
86798679 break :blk .compile_time;
86808680 }
src/Sema.zig+37-89
......@@ -5986,7 +5986,7 @@ fn zirCall(
59865986 const extra = sema.code.extraData(Zir.Inst.Call, inst_data.payload_index);
59875987 const args_len = extra.data.flags.args_len;
59885988
5989 const modifier = @intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier);
5989 const modifier = @intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier);
59905990 const ensure_result_used = extra.data.flags.ensure_result_used;
59915991 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;
59925992
......@@ -6222,7 +6222,7 @@ fn analyzeCall(
62226222 func: Air.Inst.Ref,
62236223 func_src: LazySrcLoc,
62246224 call_src: LazySrcLoc,
6225 modifier: std.builtin.CallOptions.Modifier,
6225 modifier: std.builtin.CallModifier,
62266226 ensure_result_used: bool,
62276227 uncasted_args: []const Air.Inst.Ref,
62286228 bound_arg_src: ?LazySrcLoc,
......@@ -20751,118 +20751,66 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2075120751 });
2075220752}
2075320753
20754fn resolveCallOptions(
20755 sema: *Sema,
20756 block: *Block,
20757 src: LazySrcLoc,
20758 zir_ref: Zir.Inst.Ref,
20759 is_comptime: bool,
20760 is_nosuspend: bool,
20761 func: Air.Inst.Ref,
20762 func_src: LazySrcLoc,
20763) CompileError!std.builtin.CallOptions.Modifier {
20764 const call_options_ty = try sema.getBuiltinType("CallOptions");
20765 const air_ref = try sema.resolveInst(zir_ref);
20766 const options = try sema.coerce(block, call_options_ty, air_ref, src);
20767
20768 const modifier_src = sema.maybeOptionsSrc(block, src, "modifier");
20769 const stack_src = sema.maybeOptionsSrc(block, src, "stack");
20770
20771 const modifier = try sema.fieldVal(block, src, options, "modifier", modifier_src);
20772 const modifier_val = try sema.resolveConstValue(block, modifier_src, modifier, "call modifier must be comptime-known");
20773 const wanted_modifier = modifier_val.toEnum(std.builtin.CallOptions.Modifier);
20754fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
20755 const tracy = trace(@src());
20756 defer tracy.end();
2077420757
20775 const stack = try sema.fieldVal(block, src, options, "stack", stack_src);
20776 const stack_val = try sema.resolveConstValue(block, stack_src, stack, "call stack value must be comptime-known");
20758 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
20759 const modifier_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
20760 const func_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
20761 const args_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
20762 const call_src = inst_data.src();
2077720763
20778 if (!stack_val.isNull()) {
20779 return sema.fail(block, stack_src, "TODO: implement @call with stack", .{});
20780 }
20764 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
20765 var func = try sema.resolveInst(extra.callee);
2078120766
20782 switch (wanted_modifier) {
20767 const modifier_ty = try sema.getBuiltinType("CallModifier");
20768 const air_ref = try sema.resolveInst(extra.modifier);
20769 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
20770 const modifier_val = try sema.resolveConstValue(block, modifier_src, modifier_ref, "call modifier must be comptime-known");
20771 var modifier = modifier_val.toEnum(std.builtin.CallModifier);
20772 switch (modifier) {
2078320773 // These can be upgraded to comptime or nosuspend calls.
2078420774 .auto, .never_tail, .no_async => {
20785 if (is_comptime) {
20786 if (wanted_modifier == .never_tail) {
20775 if (extra.flags.is_comptime) {
20776 if (modifier == .never_tail) {
2078720777 return sema.fail(block, modifier_src, "unable to perform 'never_tail' call at compile-time", .{});
2078820778 }
20789 return .compile_time;
20790 }
20791 if (is_nosuspend) {
20792 return .no_async;
20779 modifier = .compile_time;
20780 } else if (extra.flags.is_nosuspend) {
20781 modifier = .no_async;
2079320782 }
20794 return wanted_modifier;
2079520783 },
2079620784 // These can be upgraded to comptime. nosuspend bit can be safely ignored.
2079720785 .always_inline, .compile_time => {
2079820786 _ = (try sema.resolveDefinedValue(block, func_src, func)) orelse {
20799 return sema.fail(block, func_src, "modifier '{s}' requires a comptime-known function", .{@tagName(wanted_modifier)});
20787 return sema.fail(block, func_src, "modifier '{s}' requires a comptime-known function", .{@tagName(modifier)});
2080020788 };
2080120789
20802 if (is_comptime) {
20803 return .compile_time;
20790 if (extra.flags.is_comptime) {
20791 modifier = .compile_time;
2080420792 }
20805 return wanted_modifier;
2080620793 },
2080720794 .always_tail => {
20808 if (is_comptime) {
20809 return .compile_time;
20795 if (extra.flags.is_comptime) {
20796 modifier = .compile_time;
2081020797 }
20811 return wanted_modifier;
2081220798 },
2081320799 .async_kw => {
20814 if (is_nosuspend) {
20800 if (extra.flags.is_nosuspend) {
2081520801 return sema.fail(block, modifier_src, "modifier 'async_kw' cannot be used inside nosuspend block", .{});
2081620802 }
20817 if (is_comptime) {
20803 if (extra.flags.is_comptime) {
2081820804 return sema.fail(block, modifier_src, "modifier 'async_kw' cannot be used in combination with comptime function call", .{});
2081920805 }
20820 return wanted_modifier;
2082120806 },
2082220807 .never_inline => {
20823 if (is_comptime) {
20808 if (extra.flags.is_comptime) {
2082420809 return sema.fail(block, modifier_src, "unable to perform 'never_inline' call at compile-time", .{});
2082520810 }
20826 return wanted_modifier;
2082720811 },
2082820812 }
20829}
20830
20831fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
20832 const tracy = trace(@src());
20833 defer tracy.end();
2083420813
20835 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
20836 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
20837 const func_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
20838 const args_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
20839 const call_src = inst_data.src();
20840
20841 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
20842 var func = try sema.resolveInst(extra.callee);
20843 const modifier = sema.resolveCallOptions(
20844 block,
20845 .unneeded,
20846 extra.options,
20847 extra.flags.is_comptime,
20848 extra.flags.is_nosuspend,
20849 func,
20850 func_src,
20851 ) catch |err| switch (err) {
20852 error.NeededSourceLocation => {
20853 _ = try sema.resolveCallOptions(
20854 block,
20855 options_src,
20856 extra.options,
20857 extra.flags.is_comptime,
20858 extra.flags.is_nosuspend,
20859 func,
20860 func_src,
20861 );
20862 return error.AnalysisFail;
20863 },
20864 else => |e| return e,
20865 };
2086620814 const args = try sema.resolveInst(extra.args);
2086720815
2086820816 const args_ty = sema.typeOf(args);
......@@ -29558,7 +29506,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
2955829506 .address_space,
2955929507 .float_mode,
2956029508 .reduce_op,
29561 .call_options,
29509 .modifier,
2956229510 .prefetch_options,
2956329511 .export_options,
2956429512 .extern_options,
......@@ -29823,7 +29771,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
2982329771 .address_space => return sema.getBuiltinType("AddressSpace"),
2982429772 .float_mode => return sema.getBuiltinType("FloatMode"),
2982529773 .reduce_op => return sema.getBuiltinType("ReduceOp"),
29826 .call_options => return sema.getBuiltinType("CallOptions"),
29774 .modifier => return sema.getBuiltinType("CallModifier"),
2982729775 .prefetch_options => return sema.getBuiltinType("PrefetchOptions"),
2982829776
2982929777 else => return ty,
......@@ -30841,7 +30789,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3084130789 .address_space,
3084230790 .float_mode,
3084330791 .reduce_op,
30844 .call_options,
30792 .modifier,
3084530793 .prefetch_options,
3084630794 .export_options,
3084730795 .extern_options,
......@@ -31164,7 +31112,7 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
3116431112 .address_space => return .address_space_type,
3116531113 .float_mode => return .float_mode_type,
3116631114 .reduce_op => return .reduce_op_type,
31167 .call_options => return .call_options_type,
31115 .modifier => return .modifier_type,
3116831116 .prefetch_options => return .prefetch_options_type,
3116931117 .export_options => return .export_options_type,
3117031118 .extern_options => return .extern_options_type,
......@@ -31557,7 +31505,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
3155731505 .address_space,
3155831506 .float_mode,
3155931507 .reduce_op,
31560 .call_options,
31508 .modifier,
3156131509 .prefetch_options,
3156231510 .export_options,
3156331511 .extern_options,
......@@ -32387,7 +32335,7 @@ fn enumHasInt(
3238732335 .address_space,
3238832336 .float_mode,
3238932337 .reduce_op,
32390 .call_options,
32338 .modifier,
3239132339 .prefetch_options,
3239232340 .export_options,
3239332341 .extern_options,
src/ThreadPool.zig+2-2
......@@ -71,7 +71,7 @@ fn join(pool: *ThreadPool, spawned: usize) void {
7171
7272pub fn spawn(pool: *ThreadPool, comptime func: anytype, args: anytype) !void {
7373 if (builtin.single_threaded) {
74 @call(.{}, func, args);
74 @call(.auto, func, args);
7575 return;
7676 }
7777
......@@ -84,7 +84,7 @@ pub fn spawn(pool: *ThreadPool, comptime func: anytype, args: anytype) !void {
8484 fn runFn(runnable: *Runnable) void {
8585 const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);
8686 const closure = @fieldParentPtr(@This(), "run_node", run_node);
87 @call(.{}, func, closure.arguments);
87 @call(.auto, func, closure.arguments);
8888
8989 // The thread pool's allocator is protected by the mutex.
9090 const mutex = &closure.pool.mutex;
src/TypedValue.zig+1-1
......@@ -136,7 +136,7 @@ pub fn print(
136136 .address_space_type => return writer.writeAll("std.builtin.AddressSpace"),
137137 .float_mode_type => return writer.writeAll("std.builtin.FloatMode"),
138138 .reduce_op_type => return writer.writeAll("std.builtin.ReduceOp"),
139 .call_options_type => return writer.writeAll("std.builtin.CallOptions"),
139 .modifier_type => return writer.writeAll("std.builtin.CallModifier"),
140140 .prefetch_options_type => return writer.writeAll("std.builtin.PrefetchOptions"),
141141 .export_options_type => return writer.writeAll("std.builtin.ExportOptions"),
142142 .extern_options_type => return writer.writeAll("std.builtin.ExternOptions"),
src/Zir.zig+6-6
......@@ -2070,7 +2070,7 @@ pub const Inst = struct {
20702070 address_space_type,
20712071 float_mode_type,
20722072 reduce_op_type,
2073 call_options_type,
2073 modifier_type,
20742074 prefetch_options_type,
20752075 export_options_type,
20762076 extern_options_type,
......@@ -2345,9 +2345,9 @@ pub const Inst = struct {
23452345 .ty = Type.initTag(.type),
23462346 .val = Value.initTag(.reduce_op_type),
23472347 },
2348 .call_options_type = .{
2348 .modifier_type = .{
23492349 .ty = Type.initTag(.type),
2350 .val = Value.initTag(.call_options_type),
2350 .val = Value.initTag(.modifier_type),
23512351 },
23522352 .prefetch_options_type = .{
23532353 .ty = Type.initTag(.type),
......@@ -2832,7 +2832,7 @@ pub const Inst = struct {
28322832 callee: Ref,
28332833
28342834 pub const Flags = packed struct {
2835 /// std.builtin.CallOptions.Modifier in packed form
2835 /// std.builtin.CallModifier in packed form
28362836 pub const PackedModifier = u3;
28372837 pub const PackedArgsLen = u27;
28382838
......@@ -2844,7 +2844,7 @@ pub const Inst = struct {
28442844 comptime {
28452845 if (@sizeOf(Flags) != 4 or @bitSizeOf(Flags) != 32)
28462846 @compileError("Layout of Call.Flags needs to be updated!");
2847 if (@bitSizeOf(std.builtin.CallOptions.Modifier) != @bitSizeOf(PackedModifier))
2847 if (@bitSizeOf(std.builtin.CallModifier) != @bitSizeOf(PackedModifier))
28482848 @compileError("Call.Flags.PackedModifier needs to be updated!");
28492849 }
28502850 };
......@@ -2860,7 +2860,7 @@ pub const Inst = struct {
28602860 // Note: Flags *must* come first so that unusedResultExpr
28612861 // can find it when it goes to modify them.
28622862 flags: Flags,
2863 options: Ref,
2863 modifier: Ref,
28642864 callee: Ref,
28652865 args: Ref,
28662866
src/arch/aarch64/CodeGen.zig+1-1
......@@ -4110,7 +4110,7 @@ fn airFence(self: *Self) !void {
41104110 //return self.finishAirBookkeeping();
41114111}
41124112
4113fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) !void {
4113fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
41144114 if (modifier == .always_tail) return self.fail("TODO implement tail calls for aarch64", .{});
41154115 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
41164116 const callee = pl_op.operand;
src/arch/arm/CodeGen.zig+1-1
......@@ -4097,7 +4097,7 @@ fn airFence(self: *Self) !void {
40974097 //return self.finishAirBookkeeping();
40984098}
40994099
4100fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) !void {
4100fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
41014101 if (modifier == .always_tail) return self.fail("TODO implement tail calls for arm", .{});
41024102 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
41034103 const callee = pl_op.operand;
src/arch/riscv64/CodeGen.zig+1-1
......@@ -1672,7 +1672,7 @@ fn airFence(self: *Self) !void {
16721672 //return self.finishAirBookkeeping();
16731673}
16741674
1675fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) !void {
1675fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
16761676 if (modifier == .always_tail) return self.fail("TODO implement tail calls for riscv64", .{});
16771677 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
16781678 const fn_ty = self.air.typeOf(pl_op.operand);
src/arch/sparc64/CodeGen.zig+1-1
......@@ -1155,7 +1155,7 @@ fn airBreakpoint(self: *Self) !void {
11551155 return self.finishAirBookkeeping();
11561156}
11571157
1158fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) !void {
1158fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
11591159 if (modifier == .always_tail) return self.fail("TODO implement tail calls for {}", .{self.target.cpu.arch});
11601160
11611161 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
src/arch/wasm/CodeGen.zig+1-1
......@@ -2099,7 +2099,7 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
20992099 return func.finishAir(inst, .none, &.{un_op});
21002100}
21012101
2102fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) InnerError!void {
2102fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) InnerError!void {
21032103 if (modifier == .always_tail) return func.fail("TODO implement tail calls for wasm", .{});
21042104 const pl_op = func.air.instructions.items(.data)[inst].pl_op;
21052105 const extra = func.air.extraData(Air.Call, pl_op.payload);
src/arch/x86_64/CodeGen.zig+1-1
......@@ -3899,7 +3899,7 @@ fn airFence(self: *Self) !void {
38993899 //return self.finishAirBookkeeping();
39003900}
39013901
3902fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) !void {
3902fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier) !void {
39033903 if (modifier == .always_tail) return self.fail("TODO implement tail calls for x86_64", .{});
39043904 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
39053905 const callee = pl_op.operand;
src/codegen/c.zig+1-1
......@@ -3874,7 +3874,7 @@ fn airSlice(f: *Function, inst: Air.Inst.Index) !CValue {
38743874fn airCall(
38753875 f: *Function,
38763876 inst: Air.Inst.Index,
3877 modifier: std.builtin.CallOptions.Modifier,
3877 modifier: std.builtin.CallModifier,
38783878) !CValue {
38793879 // Not even allowed to call panic in a naked function.
38803880 if (f.object.dg.decl.ty.fnCallingConvention() == .Naked) return .none;
src/crash_report.zig+2-2
......@@ -549,8 +549,8 @@ const PanicSwitch = struct {
549549 // TODO: Tailcall is broken right now, but eventually this should be used
550550 // to avoid blowing up the stack. It's ok for now though, there are no
551551 // cycles in the state machine so the max stack usage is bounded.
552 //@call(.{.modifier = .always_tail}, func, args);
553 @call(.{}, func, args);
552 //@call(.always_tail, func, args);
553 @call(.auto, func, args);
554554 }
555555
556556 fn recover(
src/print_zir.zig+2-2
......@@ -801,7 +801,7 @@ const Writer = struct {
801801 try self.writeFlag(stream, "nosuspend ", extra.flags.is_nosuspend);
802802 try self.writeFlag(stream, "comptime ", extra.flags.is_comptime);
803803
804 try self.writeInstRef(stream, extra.options);
804 try self.writeInstRef(stream, extra.modifier);
805805 try stream.writeAll(", ");
806806 try self.writeInstRef(stream, extra.callee);
807807 try stream.writeAll(", ");
......@@ -1170,7 +1170,7 @@ const Writer = struct {
11701170 if (extra.data.flags.ensure_result_used) {
11711171 try stream.writeAll("nodiscard ");
11721172 }
1173 try stream.print(".{s}, ", .{@tagName(@intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier))});
1173 try stream.print(".{s}, ", .{@tagName(@intToEnum(std.builtin.CallModifier, extra.data.flags.packed_modifier))});
11741174 try self.writeInstRef(stream, extra.data.callee);
11751175 try stream.writeAll(", [");
11761176
src/type.zig+22-22
......@@ -129,7 +129,6 @@ pub const Type = extern union {
129129 .empty_struct,
130130 .empty_struct_literal,
131131 .@"struct",
132 .call_options,
133132 .prefetch_options,
134133 .export_options,
135134 .extern_options,
......@@ -147,6 +146,7 @@ pub const Type = extern union {
147146 .address_space,
148147 .float_mode,
149148 .reduce_op,
149 .modifier,
150150 => return .Enum,
151151
152152 .@"union",
......@@ -885,7 +885,6 @@ pub const Type = extern union {
885885
886886 // we can't compare these based on tags because it wouldn't detect if,
887887 // for example, a was resolved into .@"struct" but b was one of these tags.
888 .call_options,
889888 .prefetch_options,
890889 .export_options,
891890 .extern_options,
......@@ -914,6 +913,7 @@ pub const Type = extern union {
914913 .address_space,
915914 .float_mode,
916915 .reduce_op,
916 .modifier,
917917 => unreachable, // needed to resolve the type before now
918918
919919 .@"union", .union_safety_tagged, .union_tagged => {
......@@ -1194,7 +1194,6 @@ pub const Type = extern union {
11941194 },
11951195
11961196 // we can't hash these based on tags because they wouldn't match the expanded version.
1197 .call_options,
11981197 .prefetch_options,
11991198 .export_options,
12001199 .extern_options,
......@@ -1222,6 +1221,7 @@ pub const Type = extern union {
12221221 .address_space,
12231222 .float_mode,
12241223 .reduce_op,
1224 .modifier,
12251225 => unreachable, // needed to resolve the type before now
12261226
12271227 .@"union", .union_safety_tagged, .union_tagged => {
......@@ -1333,7 +1333,7 @@ pub const Type = extern union {
13331333 .address_space,
13341334 .float_mode,
13351335 .reduce_op,
1336 .call_options,
1336 .modifier,
13371337 .prefetch_options,
13381338 .export_options,
13391339 .extern_options,
......@@ -1665,7 +1665,7 @@ pub const Type = extern union {
16651665 .address_space => return writer.writeAll("std.builtin.AddressSpace"),
16661666 .float_mode => return writer.writeAll("std.builtin.FloatMode"),
16671667 .reduce_op => return writer.writeAll("std.builtin.ReduceOp"),
1668 .call_options => return writer.writeAll("std.builtin.CallOptions"),
1668 .modifier => return writer.writeAll("std.builtin.CallModifier"),
16691669 .prefetch_options => return writer.writeAll("std.builtin.PrefetchOptions"),
16701670 .export_options => return writer.writeAll("std.builtin.ExportOptions"),
16711671 .extern_options => return writer.writeAll("std.builtin.ExternOptions"),
......@@ -1943,7 +1943,7 @@ pub const Type = extern union {
19431943 .address_space => unreachable,
19441944 .float_mode => unreachable,
19451945 .reduce_op => unreachable,
1946 .call_options => unreachable,
1946 .modifier => unreachable,
19471947 .prefetch_options => unreachable,
19481948 .export_options => unreachable,
19491949 .extern_options => unreachable,
......@@ -2311,7 +2311,7 @@ pub const Type = extern union {
23112311 .address_space => return Value.initTag(.address_space_type),
23122312 .float_mode => return Value.initTag(.float_mode_type),
23132313 .reduce_op => return Value.initTag(.reduce_op_type),
2314 .call_options => return Value.initTag(.call_options_type),
2314 .modifier => return Value.initTag(.modifier_type),
23152315 .prefetch_options => return Value.initTag(.prefetch_options_type),
23162316 .export_options => return Value.initTag(.export_options_type),
23172317 .extern_options => return Value.initTag(.extern_options_type),
......@@ -2385,7 +2385,7 @@ pub const Type = extern union {
23852385 .address_space,
23862386 .float_mode,
23872387 .reduce_op,
2388 .call_options,
2388 .modifier,
23892389 .prefetch_options,
23902390 .export_options,
23912391 .extern_options,
......@@ -2631,7 +2631,7 @@ pub const Type = extern union {
26312631 .address_space,
26322632 .float_mode,
26332633 .reduce_op,
2634 .call_options,
2634 .modifier,
26352635 .prefetch_options,
26362636 .export_options,
26372637 .extern_options,
......@@ -2873,7 +2873,7 @@ pub const Type = extern union {
28732873 .address_space,
28742874 .float_mode,
28752875 .reduce_op,
2876 .call_options,
2876 .modifier,
28772877 .prefetch_options,
28782878 .export_options,
28792879 .extern_options,
......@@ -3257,7 +3257,7 @@ pub const Type = extern union {
32573257 .inferred_alloc_mut => unreachable,
32583258 .var_args_param => unreachable,
32593259 .generic_poison => unreachable,
3260 .call_options => unreachable, // missing call to resolveTypeFields
3260 .modifier => unreachable, // missing call to resolveTypeFields
32613261 .prefetch_options => unreachable, // missing call to resolveTypeFields
32623262 .export_options => unreachable, // missing call to resolveTypeFields
32633263 .extern_options => unreachable, // missing call to resolveTypeFields
......@@ -3753,7 +3753,7 @@ pub const Type = extern union {
37533753 .address_space,
37543754 .float_mode,
37553755 .reduce_op,
3756 .call_options,
3756 .modifier,
37573757 .prefetch_options,
37583758 .export_options,
37593759 .extern_options,
......@@ -4279,7 +4279,7 @@ pub const Type = extern union {
42794279 .address_space,
42804280 .float_mode,
42814281 .reduce_op,
4282 .call_options,
4282 .modifier,
42834283 .prefetch_options,
42844284 .export_options,
42854285 .extern_options,
......@@ -4306,7 +4306,7 @@ pub const Type = extern union {
43064306 .address_space,
43074307 .float_mode,
43084308 .reduce_op,
4309 .call_options,
4309 .modifier,
43104310 .prefetch_options,
43114311 .export_options,
43124312 .extern_options,
......@@ -4990,7 +4990,7 @@ pub const Type = extern union {
49904990 .address_space,
49914991 .float_mode,
49924992 .reduce_op,
4993 .call_options,
4993 .modifier,
49944994 .prefetch_options,
49954995 .export_options,
49964996 .extern_options,
......@@ -5165,7 +5165,7 @@ pub const Type = extern union {
51655165 .address_space,
51665166 .float_mode,
51675167 .reduce_op,
5168 .call_options,
5168 .modifier,
51695169 .prefetch_options,
51705170 .export_options,
51715171 .extern_options,
......@@ -5483,7 +5483,7 @@ pub const Type = extern union {
54835483 .address_space,
54845484 .float_mode,
54855485 .reduce_op,
5486 .call_options,
5486 .modifier,
54875487 .prefetch_options,
54885488 .export_options,
54895489 .extern_options,
......@@ -5565,7 +5565,7 @@ pub const Type = extern union {
55655565 .address_space,
55665566 .float_mode,
55675567 .reduce_op,
5568 .call_options,
5568 .modifier,
55695569 .prefetch_options,
55705570 .export_options,
55715571 .extern_options,
......@@ -5878,7 +5878,7 @@ pub const Type = extern union {
58785878 .address_space,
58795879 .float_mode,
58805880 .reduce_op,
5881 .call_options,
5881 .modifier,
58825882 .prefetch_options,
58835883 .export_options,
58845884 .extern_options,
......@@ -5926,7 +5926,7 @@ pub const Type = extern union {
59265926 .address_space,
59275927 .float_mode,
59285928 .reduce_op,
5929 .call_options,
5929 .modifier,
59305930 .prefetch_options,
59315931 .export_options,
59325932 .extern_options,
......@@ -5991,7 +5991,7 @@ pub const Type = extern union {
59915991 address_space,
59925992 float_mode,
59935993 reduce_op,
5994 call_options,
5994 modifier,
59955995 prefetch_options,
59965996 export_options,
59975997 extern_options,
......@@ -6131,7 +6131,7 @@ pub const Type = extern union {
61316131 .address_space,
61326132 .float_mode,
61336133 .reduce_op,
6134 .call_options,
6134 .modifier,
61356135 .prefetch_options,
61366136 .export_options,
61376137 .extern_options,
src/value.zig+5-5
......@@ -71,7 +71,7 @@ pub const Value = extern union {
7171 address_space_type,
7272 float_mode_type,
7373 reduce_op_type,
74 call_options_type,
74 modifier_type,
7575 prefetch_options_type,
7676 export_options_type,
7777 extern_options_type,
......@@ -264,7 +264,7 @@ pub const Value = extern union {
264264 .address_space_type,
265265 .float_mode_type,
266266 .reduce_op_type,
267 .call_options_type,
267 .modifier_type,
268268 .prefetch_options_type,
269269 .export_options_type,
270270 .extern_options_type,
......@@ -467,7 +467,7 @@ pub const Value = extern union {
467467 .address_space_type,
468468 .float_mode_type,
469469 .reduce_op_type,
470 .call_options_type,
470 .modifier_type,
471471 .prefetch_options_type,
472472 .export_options_type,
473473 .extern_options_type,
......@@ -723,7 +723,7 @@ pub const Value = extern union {
723723 .address_space_type => return out_stream.writeAll("std.builtin.AddressSpace"),
724724 .float_mode_type => return out_stream.writeAll("std.builtin.FloatMode"),
725725 .reduce_op_type => return out_stream.writeAll("std.builtin.ReduceOp"),
726 .call_options_type => return out_stream.writeAll("std.builtin.CallOptions"),
726 .modifier_type => return out_stream.writeAll("std.builtin.CallModifier"),
727727 .prefetch_options_type => return out_stream.writeAll("std.builtin.PrefetchOptions"),
728728 .export_options_type => return out_stream.writeAll("std.builtin.ExportOptions"),
729729 .extern_options_type => return out_stream.writeAll("std.builtin.ExternOptions"),
......@@ -963,7 +963,7 @@ pub const Value = extern union {
963963 .address_space_type => Type.initTag(.address_space),
964964 .float_mode_type => Type.initTag(.float_mode),
965965 .reduce_op_type => Type.initTag(.reduce_op),
966 .call_options_type => Type.initTag(.call_options),
966 .modifier_type => Type.initTag(.modifier),
967967 .prefetch_options_type => Type.initTag(.prefetch_options),
968968 .export_options_type => Type.initTag(.export_options),
969969 .extern_options_type => Type.initTag(.extern_options),
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/behavior/basic.zig+2-2
......@@ -966,8 +966,8 @@ test "generic function uses return type of other generic function" {
966966 fn call(
967967 f: anytype,
968968 args: anytype,
969 ) @TypeOf(@call(.{}, f, @as(@TypeOf(args), undefined))) {
970 return @call(.{}, f, args);
969 ) @TypeOf(@call(.auto, f, @as(@TypeOf(args), undefined))) {
970 return @call(.auto, f, args);
971971 }
972972
973973 fn func(arg: anytype) @TypeOf(arg) {
test/behavior/call.zig+26-26
......@@ -9,11 +9,11 @@ test "super basic invocations" {
99 return 1234;
1010 }
1111 }.foo;
12 try expect(@call(.{}, foo, .{}) == 1234);
13 comptime try expect(@call(.{ .modifier = .always_inline }, foo, .{}) == 1234);
12 try expect(@call(.auto, foo, .{}) == 1234);
13 comptime try expect(@call(.always_inline, foo, .{}) == 1234);
1414 {
1515 // comptime call without comptime keyword
16 const result = @call(.{ .modifier = .compile_time }, foo, .{}) == 1234;
16 const result = @call(.compile_time, foo, .{}) == 1234;
1717 comptime try expect(result);
1818 }
1919}
......@@ -31,25 +31,25 @@ test "basic invocations" {
3131 return 1234;
3232 }
3333 }.foo;
34 try expect(@call(.{}, foo, .{}) == 1234);
34 try expect(@call(.auto, foo, .{}) == 1234);
3535 comptime {
3636 // modifiers that allow comptime calls
37 try expect(@call(.{}, foo, .{}) == 1234);
38 try expect(@call(.{ .modifier = .no_async }, foo, .{}) == 1234);
39 try expect(@call(.{ .modifier = .always_tail }, foo, .{}) == 1234);
40 try expect(@call(.{ .modifier = .always_inline }, foo, .{}) == 1234);
37 try expect(@call(.auto, foo, .{}) == 1234);
38 try expect(@call(.no_async, foo, .{}) == 1234);
39 try expect(@call(.always_tail, foo, .{}) == 1234);
40 try expect(@call(.always_inline, foo, .{}) == 1234);
4141 }
4242 {
4343 // comptime call without comptime keyword
44 const result = @call(.{ .modifier = .compile_time }, foo, .{}) == 1234;
44 const result = @call(.compile_time, foo, .{}) == 1234;
4545 comptime try expect(result);
4646 }
4747 {
4848 // call of non comptime-known function
4949 var alias_foo = &foo;
50 try expect(@call(.{ .modifier = .no_async }, alias_foo, .{}) == 1234);
51 try expect(@call(.{ .modifier = .never_tail }, alias_foo, .{}) == 1234);
52 try expect(@call(.{ .modifier = .never_inline }, alias_foo, .{}) == 1234);
50 try expect(@call(.no_async, alias_foo, .{}) == 1234);
51 try expect(@call(.never_tail, alias_foo, .{}) == 1234);
52 try expect(@call(.never_inline, alias_foo, .{}) == 1234);
5353 }
5454}
5555
......@@ -66,23 +66,23 @@ test "tuple parameters" {
6666 }.add;
6767 var a: i32 = 12;
6868 var b: i32 = 34;
69 try expect(@call(.{}, add, .{ a, 34 }) == 46);
70 try expect(@call(.{}, add, .{ 12, b }) == 46);
71 try expect(@call(.{}, add, .{ a, b }) == 46);
72 try expect(@call(.{}, add, .{ 12, 34 }) == 46);
69 try expect(@call(.auto, add, .{ a, 34 }) == 46);
70 try expect(@call(.auto, add, .{ 12, b }) == 46);
71 try expect(@call(.auto, add, .{ a, b }) == 46);
72 try expect(@call(.auto, add, .{ 12, 34 }) == 46);
7373 if (false) {
74 comptime try expect(@call(.{}, add, .{ 12, 34 }) == 46); // TODO
74 comptime try expect(@call(.auto, add, .{ 12, 34 }) == 46); // TODO
7575 }
76 try expect(comptime @call(.{}, add, .{ 12, 34 }) == 46);
76 try expect(comptime @call(.auto, add, .{ 12, 34 }) == 46);
7777 {
7878 const separate_args0 = .{ a, b };
7979 const separate_args1 = .{ a, 34 };
8080 const separate_args2 = .{ 12, 34 };
8181 const separate_args3 = .{ 12, b };
82 try expect(@call(.{ .modifier = .always_inline }, add, separate_args0) == 46);
83 try expect(@call(.{ .modifier = .always_inline }, add, separate_args1) == 46);
84 try expect(@call(.{ .modifier = .always_inline }, add, separate_args2) == 46);
85 try expect(@call(.{ .modifier = .always_inline }, add, separate_args3) == 46);
82 try expect(@call(.always_inline, add, separate_args0) == 46);
83 try expect(@call(.always_inline, add, separate_args1) == 46);
84 try expect(@call(.always_inline, add, separate_args2) == 46);
85 try expect(@call(.always_inline, add, separate_args3) == 46);
8686 }
8787}
8888
......@@ -281,7 +281,7 @@ test "forced tail call" {
281281 if (n == 0) return a;
282282 if (n == 1) return b;
283283 return @call(
284 .{ .modifier = .always_tail },
284 .always_tail,
285285 fibonacciTailInternal,
286286 .{ n - 1, b, a + b },
287287 );
......@@ -322,7 +322,7 @@ test "inline call preserves tail call" {
322322 var buf: [max]u16 = undefined;
323323 buf[a] = a;
324324 a += 1;
325 return @call(.{ .modifier = .always_tail }, foo, .{});
325 return @call(.always_tail, foo, .{});
326326 }
327327 };
328328 S.foo();
......@@ -341,6 +341,6 @@ test "inline call doesn't re-evaluate non generic struct" {
341341 }
342342 };
343343 const ArgTuple = std.meta.ArgsTuple(@TypeOf(S.foo));
344 try @call(.{ .modifier = .always_inline }, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
345 comptime try @call(.{ .modifier = .always_inline }, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
344 try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
345 comptime try @call(.always_inline, S.foo, ArgTuple{.{ .a = 123, .b = 45 }});
346346}
test/cases/compile_errors/bad_usage_of_call.zig+12-11
......@@ -1,22 +1,22 @@
11export fn entry1() void {
2 @call(.{}, foo, {});
2 @call(.auto, foo, {});
33}
44export fn entry2() void {
5 comptime @call(.{ .modifier = .never_inline }, foo, .{});
5 comptime @call(.never_inline, foo, .{});
66}
77export fn entry3() void {
8 comptime @call(.{ .modifier = .never_tail }, foo, .{});
8 comptime @call(.never_tail, foo, .{});
99}
1010export fn entry4() void {
11 @call(.{ .modifier = .never_inline }, bar, .{});
11 @call(.never_inline, bar, .{});
1212}
1313export fn entry5(c: bool) void {
1414 var baz = if (c) &baz1 else &baz2;
15 @call(.{ .modifier = .compile_time }, baz, .{});
15 @call(.compile_time, baz, .{});
1616}
1717pub export fn entry() void {
1818 var call_me: *const fn () void = undefined;
19 @call(.{ .modifier = .always_inline }, call_me, .{});
19 @call(.always_inline, call_me, .{});
2020}
2121fn foo() void {}
2222fn bar() callconv(.Inline) void {}
......@@ -27,9 +27,10 @@ fn baz2() void {}
2727// backend=stage2
2828// target=native
2929//
30// :2:21: error: expected a tuple, found 'void'
31// :5:33: error: unable to perform 'never_inline' call at compile-time
32// :8:33: error: unable to perform 'never_tail' call at compile-time
30// :2:23: error: expected a tuple, found 'void'
31// :5:21: error: unable to perform 'never_inline' call at compile-time
32// :8:21: error: unable to perform 'never_tail' call at compile-time
3333// :11:5: error: no-inline call of inline function
34// :15:43: error: modifier 'compile_time' requires a comptime-known function
35// :19:44: error: modifier 'always_inline' requires a comptime-known function
34// :15:26: error: modifier 'compile_time' requires a comptime-known function
35// :19:27: error: modifier 'always_inline' requires a comptime-known function
36
test/cases/compile_errors/error_in_call_builtin_args.zig+4-4
......@@ -1,15 +1,15 @@
11fn foo(_: u32, _: u32) void {}
22pub export fn entry() void {
3 @call(.{}, foo, .{ 12, 12.34 });
3 @call(.auto, foo, .{ 12, 12.34 });
44}
55pub export fn entry1() void {
66 const args = .{ 12, 12.34 };
7 @call(.{}, foo, args);
7 @call(.auto, foo, args);
88}
99
1010// error
1111// backend=stage2
1212// target=native
1313//
14// :3:28: error: fractional component prevents float value '12.34' from coercion to type 'u32'
15// :7:21: error: fractional component prevents float value '12.34' from coercion to type 'u32'
14// :3:30: error: fractional component prevents float value '12.34' from coercion to type 'u32'
15// :7:23: error: fractional component prevents float value '12.34' from coercion to type 'u32'
test/cases/compile_errors/invalid_tail_call.zig+1-1
......@@ -2,7 +2,7 @@ fn myFn(_: usize) void {
22 return;
33}
44pub export fn entry() void {
5 @call(.{ .modifier = .always_tail }, myFn, .{0});
5 @call(.always_tail, myFn, .{0});
66}
77
88// error
test/cases/taill_call_noreturn.zig+1-1
......@@ -1,7 +1,7 @@
11const std = @import("std");
22const builtin = std.builtin;
33pub fn foo(message: []const u8, stack_trace: ?*builtin.StackTrace) noreturn {
4 @call(.{ .modifier = .always_tail }, bar, .{ message, stack_trace });
4 @call(.always_tail, bar, .{ message, stack_trace });
55}
66pub fn bar(message: []const u8, stack_trace: ?*builtin.StackTrace) noreturn {
77 _ = message;