authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-11 16:01:58-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-02-11 16:01:58-08:00
logd3565ed6b48c9c66128f181e7b90b5348504cb3f
tree99a03080830c1f9433046427feb18f90cade6c09
parentd98f09e4f67fb2848be6052466db035450326605
parentbb4f4c043e7dde4e8b9fcbf0af9329d3fd08ff7b
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7749 from tadeokondrak/6429-callconv-inline

Replace inline fn with callconv(.Inline)

51 files changed, 326 insertions(+), 332 deletions(-)

doc/langref.html.in+2-2
......@@ -4240,9 +4240,9 @@ fn _start() callconv(.Naked) noreturn {
42404240 abort();
42414241}
42424242
4243// The inline specifier forces a function to be inlined at all call sites.
4243// The inline calling convention forces a function to be inlined at all call sites.
42444244// If the function cannot be inlined, it is a compile-time error.
4245inline fn shiftLeftOne(a: u32) u32 {
4245fn shiftLeftOne(a: u32) callconv(.Inline) u32 {
42464246 return a << 1;
42474247}
42484248
lib/std/builtin.zig+2-9
......@@ -155,6 +155,7 @@ pub const CallingConvention = enum {
155155 C,
156156 Naked,
157157 Async,
158 Inline,
158159 Interrupt,
159160 Signal,
160161 Stdcall,
......@@ -404,21 +405,13 @@ pub const TypeInfo = union(enum) {
404405 /// therefore must be kept in sync with the compiler implementation.
405406 pub const FnDecl = struct {
406407 fn_type: type,
407 inline_type: Inline,
408 is_noinline: bool,
408409 is_var_args: bool,
409410 is_extern: bool,
410411 is_export: bool,
411412 lib_name: ?[]const u8,
412413 return_type: type,
413414 arg_names: []const []const u8,
414
415 /// This data structure is used by the Zig language code generation and
416 /// therefore must be kept in sync with the compiler implementation.
417 pub const Inline = enum {
418 Auto,
419 Always,
420 Never,
421 };
422415 };
423416 };
424417 };
lib/std/c/builtins.zig+49-49
......@@ -6,70 +6,70 @@
66
77const std = @import("std");
88
9pub inline fn __builtin_bswap16(val: u16) callconv(.C) u16 { return @byteSwap(u16, val); }
10pub inline fn __builtin_bswap32(val: u32) callconv(.C) u32 { return @byteSwap(u32, val); }
11pub inline fn __builtin_bswap64(val: u64) callconv(.C) u64 { return @byteSwap(u64, val); }
9pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { return @byteSwap(u16, val); }
10pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { return @byteSwap(u32, val); }
11pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { return @byteSwap(u64, val); }
1212
13pub inline fn __builtin_signbit(val: f64) callconv(.C) c_int { return @boolToInt(std.math.signbit(val)); }
14pub inline fn __builtin_signbitf(val: f32) callconv(.C) c_int { return @boolToInt(std.math.signbit(val)); }
13pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); }
14pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); }
1515
16pub inline fn __builtin_popcount(val: c_uint) callconv(.C) c_int {
16pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int {
1717 // popcount of a c_uint will never exceed the capacity of a c_int
1818 @setRuntimeSafety(false);
1919 return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val)));
2020}
21pub inline fn __builtin_ctz(val: c_uint) callconv(.C) c_int {
21pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int {
2222 // Returns the number of trailing 0-bits in val, starting at the least significant bit position.
2323 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
2424 @setRuntimeSafety(false);
2525 return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val)));
2626}
27pub inline fn __builtin_clz(val: c_uint) callconv(.C) c_int {
27pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int {
2828 // Returns the number of leading 0-bits in x, starting at the most significant bit position.
2929 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
3030 @setRuntimeSafety(false);
3131 return @bitCast(c_int, @as(c_uint, @clz(c_uint, val)));
3232}
3333
34pub inline fn __builtin_sqrt(val: f64) callconv(.C) f64 { return @sqrt(val); }
35pub inline fn __builtin_sqrtf(val: f32) callconv(.C) f32 { return @sqrt(val); }
36
37pub inline fn __builtin_sin(val: f64) callconv(.C) f64 { return @sin(val); }
38pub inline fn __builtin_sinf(val: f32) callconv(.C) f32 { return @sin(val); }
39pub inline fn __builtin_cos(val: f64) callconv(.C) f64 { return @cos(val); }
40pub inline fn __builtin_cosf(val: f32) callconv(.C) f32 { return @cos(val); }
41
42pub inline fn __builtin_exp(val: f64) callconv(.C) f64 { return @exp(val); }
43pub inline fn __builtin_expf(val: f32) callconv(.C) f32 { return @exp(val); }
44pub inline fn __builtin_exp2(val: f64) callconv(.C) f64 { return @exp2(val); }
45pub inline fn __builtin_exp2f(val: f32) callconv(.C) f32 { return @exp2(val); }
46pub inline fn __builtin_log(val: f64) callconv(.C) f64 { return @log(val); }
47pub inline fn __builtin_logf(val: f32) callconv(.C) f32 { return @log(val); }
48pub inline fn __builtin_log2(val: f64) callconv(.C) f64 { return @log2(val); }
49pub inline fn __builtin_log2f(val: f32) callconv(.C) f32 { return @log2(val); }
50pub inline fn __builtin_log10(val: f64) callconv(.C) f64 { return @log10(val); }
51pub inline fn __builtin_log10f(val: f32) callconv(.C) f32 { return @log10(val); }
34pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { return @sqrt(val); }
35pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { return @sqrt(val); }
36
37pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { return @sin(val); }
38pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { return @sin(val); }
39pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { return @cos(val); }
40pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { return @cos(val); }
41
42pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { return @exp(val); }
43pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { return @exp(val); }
44pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { return @exp2(val); }
45pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { return @exp2(val); }
46pub fn __builtin_log(val: f64) callconv(.Inline) f64 { return @log(val); }
47pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { return @log(val); }
48pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { return @log2(val); }
49pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { return @log2(val); }
50pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { return @log10(val); }
51pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { return @log10(val); }
5252
5353// Standard C Library bug: The absolute value of the most negative integer remains negative.
54pub inline fn __builtin_abs(val: c_int) callconv(.C) c_int { return std.math.absInt(val) catch std.math.minInt(c_int); }
55pub inline fn __builtin_fabs(val: f64) callconv(.C) f64 { return @fabs(val); }
56pub inline fn __builtin_fabsf(val: f32) callconv(.C) f32 { return @fabs(val); }
57
58pub inline fn __builtin_floor(val: f64) callconv(.C) f64 { return @floor(val); }
59pub inline fn __builtin_floorf(val: f32) callconv(.C) f32 { return @floor(val); }
60pub inline fn __builtin_ceil(val: f64) callconv(.C) f64 { return @ceil(val); }
61pub inline fn __builtin_ceilf(val: f32) callconv(.C) f32 { return @ceil(val); }
62pub inline fn __builtin_trunc(val: f64) callconv(.C) f64 { return @trunc(val); }
63pub inline fn __builtin_truncf(val: f32) callconv(.C) f32 { return @trunc(val); }
64pub inline fn __builtin_round(val: f64) callconv(.C) f64 { return @round(val); }
65pub inline fn __builtin_roundf(val: f32) callconv(.C) f32 { return @round(val); }
66
67pub inline fn __builtin_strlen(s: [*c]const u8) callconv(.C) usize { return std.mem.lenZ(s); }
68pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.C) c_int {
54pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { return std.math.absInt(val) catch std.math.minInt(c_int); }
55pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { return @fabs(val); }
56pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { return @fabs(val); }
57
58pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { return @floor(val); }
59pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { return @floor(val); }
60pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { return @ceil(val); }
61pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { return @ceil(val); }
62pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { return @trunc(val); }
63pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { return @trunc(val); }
64pub fn __builtin_round(val: f64) callconv(.Inline) f64 { return @round(val); }
65pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { return @round(val); }
66
67pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { return std.mem.lenZ(s); }
68pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int {
6969 return @as(c_int, std.cstr.cmp(s1, s2));
7070}
7171
72pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.C) usize {
72pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) usize {
7373 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
7474 // If it is not possible to determine which objects ptr points to at compile time,
7575 // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0
......@@ -79,37 +79,37 @@ pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.C)
7979 unreachable;
8080}
8181
82pub inline fn __builtin___memset_chk(
82pub fn __builtin___memset_chk(
8383 dst: ?*c_void,
8484 val: c_int,
8585 len: usize,
8686 remaining: usize,
87) callconv(.C) ?*c_void {
87) callconv(.Inline) ?*c_void {
8888 if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining");
8989 return __builtin_memset(dst, val, len);
9090}
9191
92pub inline fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.C) ?*c_void {
92pub fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.Inline) ?*c_void {
9393 const dst_cast = @ptrCast([*c]u8, dst);
9494 @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len);
9595 return dst;
9696}
9797
98pub inline fn __builtin___memcpy_chk(
98pub fn __builtin___memcpy_chk(
9999 noalias dst: ?*c_void,
100100 noalias src: ?*const c_void,
101101 len: usize,
102102 remaining: usize,
103) callconv(.C) ?*c_void {
103) callconv(.Inline) ?*c_void {
104104 if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining");
105105 return __builtin_memcpy(dst, src, len);
106106}
107107
108pub inline fn __builtin_memcpy(
108pub fn __builtin_memcpy(
109109 noalias dst: ?*c_void,
110110 noalias src: ?*const c_void,
111111 len: usize,
112) callconv(.C) ?*c_void {
112) callconv(.Inline) ?*c_void {
113113 const dst_cast = @ptrCast([*c]u8, dst);
114114 const src_cast = @ptrCast([*c]const u8, src);
115115
lib/std/compress/deflate.zig+1-1
......@@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type {
209209
210210 // Insert a single byte into the window.
211211 // Assumes there's enough space.
212 inline fn appendUnsafe(self: *WSelf, value: u8) void {
212 fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void {
213213 self.buf[self.wi] = value;
214214 self.wi = (self.wi + 1) & (self.buf.len - 1);
215215 self.el += 1;
lib/std/crypto/25519/curve25519.zig+2-2
......@@ -15,12 +15,12 @@ pub const Curve25519 = struct {
1515 x: Fe,
1616
1717 /// Decode a Curve25519 point from its compressed (X) coordinates.
18 pub inline fn fromBytes(s: [32]u8) Curve25519 {
18 pub fn fromBytes(s: [32]u8) callconv(.Inline) Curve25519 {
1919 return .{ .x = Fe.fromBytes(s) };
2020 }
2121
2222 /// Encode a Curve25519 point.
23 pub inline fn toBytes(p: Curve25519) [32]u8 {
23 pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 {
2424 return p.x.toBytes();
2525 }
2626
lib/std/crypto/25519/edwards25519.zig+3-3
......@@ -92,7 +92,7 @@ pub const Edwards25519 = struct {
9292 }
9393
9494 /// Flip the sign of the X coordinate.
95 pub inline fn neg(p: Edwards25519) Edwards25519 {
95 pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 {
9696 return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() };
9797 }
9898
......@@ -137,14 +137,14 @@ pub const Edwards25519 = struct {
137137 return p.add(q.neg());
138138 }
139139
140 inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void {
140 fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void {
141141 p.x.cMov(a.x, c);
142142 p.y.cMov(a.y, c);
143143 p.z.cMov(a.z, c);
144144 p.t.cMov(a.t, c);
145145 }
146146
147 inline fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) Edwards25519 {
147 fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) callconv(.Inline) Edwards25519 {
148148 var t = Edwards25519.identityElement;
149149 comptime var i: u8 = 1;
150150 inline while (i < pc.len) : (i += 1) {
lib/std/crypto/25519/field.zig+14-14
......@@ -52,7 +52,7 @@ pub const Fe = struct {
5252 pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } };
5353
5454 /// Return true if the field element is zero
55 pub inline fn isZero(fe: Fe) bool {
55 pub fn isZero(fe: Fe) callconv(.Inline) bool {
5656 var reduced = fe;
5757 reduced.reduce();
5858 const limbs = reduced.limbs;
......@@ -60,7 +60,7 @@ pub const Fe = struct {
6060 }
6161
6262 /// Return true if both field elements are equivalent
63 pub inline fn equivalent(a: Fe, b: Fe) bool {
63 pub fn equivalent(a: Fe, b: Fe) callconv(.Inline) bool {
6464 return a.sub(b).isZero();
6565 }
6666
......@@ -164,7 +164,7 @@ pub const Fe = struct {
164164 }
165165
166166 /// Add a field element
167 pub inline fn add(a: Fe, b: Fe) Fe {
167 pub fn add(a: Fe, b: Fe) callconv(.Inline) Fe {
168168 var fe: Fe = undefined;
169169 comptime var i = 0;
170170 inline while (i < 5) : (i += 1) {
......@@ -174,7 +174,7 @@ pub const Fe = struct {
174174 }
175175
176176 /// Substract a field elememnt
177 pub inline fn sub(a: Fe, b: Fe) Fe {
177 pub fn sub(a: Fe, b: Fe) callconv(.Inline) Fe {
178178 var fe = b;
179179 comptime var i = 0;
180180 inline while (i < 4) : (i += 1) {
......@@ -193,17 +193,17 @@ pub const Fe = struct {
193193 }
194194
195195 /// Negate a field element
196 pub inline fn neg(a: Fe) Fe {
196 pub fn neg(a: Fe) callconv(.Inline) Fe {
197197 return zero.sub(a);
198198 }
199199
200200 /// Return true if a field element is negative
201 pub inline fn isNegative(a: Fe) bool {
201 pub fn isNegative(a: Fe) callconv(.Inline) bool {
202202 return (a.toBytes()[0] & 1) != 0;
203203 }
204204
205205 /// Conditonally replace a field element with `a` if `c` is positive
206 pub inline fn cMov(fe: *Fe, a: Fe, c: u64) void {
206 pub fn cMov(fe: *Fe, a: Fe, c: u64) callconv(.Inline) void {
207207 const mask: u64 = 0 -% c;
208208 var x = fe.*;
209209 comptime var i = 0;
......@@ -244,7 +244,7 @@ pub const Fe = struct {
244244 }
245245 }
246246
247 inline fn _carry128(r: *[5]u128) Fe {
247 fn _carry128(r: *[5]u128) callconv(.Inline) Fe {
248248 var rs: [5]u64 = undefined;
249249 comptime var i = 0;
250250 inline while (i < 4) : (i += 1) {
......@@ -265,7 +265,7 @@ pub const Fe = struct {
265265 }
266266
267267 /// Multiply two field elements
268 pub inline fn mul(a: Fe, b: Fe) Fe {
268 pub fn mul(a: Fe, b: Fe) callconv(.Inline) Fe {
269269 var ax: [5]u128 = undefined;
270270 var bx: [5]u128 = undefined;
271271 var a19: [5]u128 = undefined;
......@@ -288,7 +288,7 @@ pub const Fe = struct {
288288 return _carry128(&r);
289289 }
290290
291 inline fn _sq(a: Fe, double: comptime bool) Fe {
291 fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe {
292292 var ax: [5]u128 = undefined;
293293 var r: [5]u128 = undefined;
294294 comptime var i = 0;
......@@ -317,17 +317,17 @@ pub const Fe = struct {
317317 }
318318
319319 /// Square a field element
320 pub inline fn sq(a: Fe) Fe {
320 pub fn sq(a: Fe) callconv(.Inline) Fe {
321321 return _sq(a, false);
322322 }
323323
324324 /// Square and double a field element
325 pub inline fn sq2(a: Fe) Fe {
325 pub fn sq2(a: Fe) callconv(.Inline) Fe {
326326 return _sq(a, true);
327327 }
328328
329329 /// Multiply a field element with a small (32-bit) integer
330 pub inline fn mul32(a: Fe, comptime n: u32) Fe {
330 pub fn mul32(a: Fe, comptime n: u32) callconv(.Inline) Fe {
331331 const sn = @intCast(u128, n);
332332 var fe: Fe = undefined;
333333 var x: u128 = 0;
......@@ -342,7 +342,7 @@ pub const Fe = struct {
342342 }
343343
344344 /// Square a field element `n` times
345 inline fn sqn(a: Fe, comptime n: comptime_int) Fe {
345 fn sqn(a: Fe, comptime n: comptime_int) callconv(.Inline) Fe {
346346 var i: usize = 0;
347347 var fe = a;
348348 while (i < n) : (i += 1) {
lib/std/crypto/25519/ristretto255.zig+4-4
......@@ -42,7 +42,7 @@ pub const Ristretto255 = struct {
4242 }
4343
4444 /// Reject the neutral element.
45 pub inline fn rejectIdentity(p: Ristretto255) !void {
45 pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) !void {
4646 return p.p.rejectIdentity();
4747 }
4848
......@@ -141,19 +141,19 @@ pub const Ristretto255 = struct {
141141 }
142142
143143 /// Double a Ristretto255 element.
144 pub inline fn dbl(p: Ristretto255) Ristretto255 {
144 pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 {
145145 return .{ .p = p.p.dbl() };
146146 }
147147
148148 /// Add two Ristretto255 elements.
149 pub inline fn add(p: Ristretto255, q: Ristretto255) Ristretto255 {
149 pub fn add(p: Ristretto255, q: Ristretto255) callconv(.Inline) Ristretto255 {
150150 return .{ .p = p.p.add(q.p) };
151151 }
152152
153153 /// Multiply a Ristretto255 element with a scalar.
154154 /// Return error.WeakPublicKey if the resulting element is
155155 /// the identity element.
156 pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) !Ristretto255 {
156 pub fn mul(p: Ristretto255, s: [encoded_length]u8) callconv(.Inline) !Ristretto255 {
157157 return Ristretto255{ .p = try p.p.mul(s) };
158158 }
159159
lib/std/crypto/25519/scalar.zig+1-1
......@@ -46,7 +46,7 @@ pub fn reduce64(s: [64]u8) [32]u8 {
4646
4747/// Perform the X25519 "clamping" operation.
4848/// The scalar is then guaranteed to be a multiple of the cofactor.
49pub inline fn clamp(s: *[32]u8) void {
49pub fn clamp(s: *[32]u8) callconv(.Inline) void {
5050 s[0] &= 248;
5151 s[31] = (s[31] & 127) | 64;
5252}
lib/std/crypto/aegis.zig+2-2
......@@ -35,7 +35,7 @@ const State128L = struct {
3535 return state;
3636 }
3737
38 inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void {
38 fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void {
3939 const blocks = &state.blocks;
4040 const tmp = blocks[7];
4141 comptime var i: usize = 7;
......@@ -207,7 +207,7 @@ const State256 = struct {
207207 return state;
208208 }
209209
210 inline fn update(state: *State256, d: AesBlock) void {
210 fn update(state: *State256, d: AesBlock) callconv(.Inline) void {
211211 const blocks = &state.blocks;
212212 const tmp = blocks[5].encrypt(blocks[0]);
213213 comptime var i: usize = 5;
lib/std/crypto/aes/aesni.zig+16-16
......@@ -19,24 +19,24 @@ pub const Block = struct {
1919 repr: BlockVec,
2020
2121 /// Convert a byte sequence into an internal representation.
22 pub inline fn fromBytes(bytes: *const [16]u8) Block {
22 pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block {
2323 const repr = mem.bytesToValue(BlockVec, bytes);
2424 return Block{ .repr = repr };
2525 }
2626
2727 /// Convert the internal representation of a block into a byte sequence.
28 pub inline fn toBytes(block: Block) [16]u8 {
28 pub fn toBytes(block: Block) callconv(.Inline) [16]u8 {
2929 return mem.toBytes(block.repr);
3030 }
3131
3232 /// XOR the block with a byte sequence.
33 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
33 pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 {
3434 const x = block.repr ^ fromBytes(bytes).repr;
3535 return mem.toBytes(x);
3636 }
3737
3838 /// Encrypt a block with a round key.
39 pub inline fn encrypt(block: Block, round_key: Block) Block {
39 pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block {
4040 return Block{
4141 .repr = asm (
4242 \\ vaesenc %[rk], %[in], %[out]
......@@ -48,7 +48,7 @@ pub const Block = struct {
4848 }
4949
5050 /// Encrypt a block with the last round key.
51 pub inline fn encryptLast(block: Block, round_key: Block) Block {
51 pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block {
5252 return Block{
5353 .repr = asm (
5454 \\ vaesenclast %[rk], %[in], %[out]
......@@ -60,7 +60,7 @@ pub const Block = struct {
6060 }
6161
6262 /// Decrypt a block with a round key.
63 pub inline fn decrypt(block: Block, inv_round_key: Block) Block {
63 pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block {
6464 return Block{
6565 .repr = asm (
6666 \\ vaesdec %[rk], %[in], %[out]
......@@ -72,7 +72,7 @@ pub const Block = struct {
7272 }
7373
7474 /// Decrypt a block with the last round key.
75 pub inline fn decryptLast(block: Block, inv_round_key: Block) Block {
75 pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block {
7676 return Block{
7777 .repr = asm (
7878 \\ vaesdeclast %[rk], %[in], %[out]
......@@ -84,17 +84,17 @@ pub const Block = struct {
8484 }
8585
8686 /// Apply the bitwise XOR operation to the content of two blocks.
87 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
87 pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
8888 return Block{ .repr = block1.repr ^ block2.repr };
8989 }
9090
9191 /// Apply the bitwise AND operation to the content of two blocks.
92 pub inline fn andBlocks(block1: Block, block2: Block) Block {
92 pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
9393 return Block{ .repr = block1.repr & block2.repr };
9494 }
9595
9696 /// Apply the bitwise OR operation to the content of two blocks.
97 pub inline fn orBlocks(block1: Block, block2: Block) Block {
97 pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
9898 return Block{ .repr = block1.repr | block2.repr };
9999 }
100100
......@@ -114,7 +114,7 @@ pub const Block = struct {
114114 };
115115
116116 /// Encrypt multiple blocks in parallel, each their own round key.
117 pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
117 pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block {
118118 comptime var i = 0;
119119 var out: [count]Block = undefined;
120120 inline while (i < count) : (i += 1) {
......@@ -124,7 +124,7 @@ pub const Block = struct {
124124 }
125125
126126 /// Decrypt multiple blocks in parallel, each their own round key.
127 pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
127 pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block {
128128 comptime var i = 0;
129129 var out: [count]Block = undefined;
130130 inline while (i < count) : (i += 1) {
......@@ -134,7 +134,7 @@ pub const Block = struct {
134134 }
135135
136136 /// Encrypt multiple blocks in parallel with the same round key.
137 pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
137 pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
138138 comptime var i = 0;
139139 var out: [count]Block = undefined;
140140 inline while (i < count) : (i += 1) {
......@@ -144,7 +144,7 @@ pub const Block = struct {
144144 }
145145
146146 /// Decrypt multiple blocks in parallel with the same round key.
147 pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
147 pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
148148 comptime var i = 0;
149149 var out: [count]Block = undefined;
150150 inline while (i < count) : (i += 1) {
......@@ -154,7 +154,7 @@ pub const Block = struct {
154154 }
155155
156156 /// Encrypt multiple blocks in parallel with the same last round key.
157 pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
157 pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
158158 comptime var i = 0;
159159 var out: [count]Block = undefined;
160160 inline while (i < count) : (i += 1) {
......@@ -164,7 +164,7 @@ pub const Block = struct {
164164 }
165165
166166 /// Decrypt multiple blocks in parallel with the same last round key.
167 pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
167 pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
168168 comptime var i = 0;
169169 var out: [count]Block = undefined;
170170 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/armcrypto.zig+16-16
......@@ -19,18 +19,18 @@ pub const Block = struct {
1919 repr: BlockVec,
2020
2121 /// Convert a byte sequence into an internal representation.
22 pub inline fn fromBytes(bytes: *const [16]u8) Block {
22 pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block {
2323 const repr = mem.bytesToValue(BlockVec, bytes);
2424 return Block{ .repr = repr };
2525 }
2626
2727 /// Convert the internal representation of a block into a byte sequence.
28 pub inline fn toBytes(block: Block) [16]u8 {
28 pub fn toBytes(block: Block) callconv(.Inline) [16]u8 {
2929 return mem.toBytes(block.repr);
3030 }
3131
3232 /// XOR the block with a byte sequence.
33 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
33 pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 {
3434 const x = block.repr ^ fromBytes(bytes).repr;
3535 return mem.toBytes(x);
3636 }
......@@ -38,7 +38,7 @@ pub const Block = struct {
3838 const zero = Vector(2, u64){ 0, 0 };
3939
4040 /// Encrypt a block with a round key.
41 pub inline fn encrypt(block: Block, round_key: Block) Block {
41 pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block {
4242 return Block{
4343 .repr = asm (
4444 \\ mov %[out].16b, %[in].16b
......@@ -54,7 +54,7 @@ pub const Block = struct {
5454 }
5555
5656 /// Encrypt a block with the last round key.
57 pub inline fn encryptLast(block: Block, round_key: Block) Block {
57 pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block {
5858 return Block{
5959 .repr = asm (
6060 \\ mov %[out].16b, %[in].16b
......@@ -69,7 +69,7 @@ pub const Block = struct {
6969 }
7070
7171 /// Decrypt a block with a round key.
72 pub inline fn decrypt(block: Block, inv_round_key: Block) Block {
72 pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block {
7373 return Block{
7474 .repr = asm (
7575 \\ mov %[out].16b, %[in].16b
......@@ -85,7 +85,7 @@ pub const Block = struct {
8585 }
8686
8787 /// Decrypt a block with the last round key.
88 pub inline fn decryptLast(block: Block, inv_round_key: Block) Block {
88 pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block {
8989 return Block{
9090 .repr = asm (
9191 \\ mov %[out].16b, %[in].16b
......@@ -100,17 +100,17 @@ pub const Block = struct {
100100 }
101101
102102 /// Apply the bitwise XOR operation to the content of two blocks.
103 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
103 pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
104104 return Block{ .repr = block1.repr ^ block2.repr };
105105 }
106106
107107 /// Apply the bitwise AND operation to the content of two blocks.
108 pub inline fn andBlocks(block1: Block, block2: Block) Block {
108 pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
109109 return Block{ .repr = block1.repr & block2.repr };
110110 }
111111
112112 /// Apply the bitwise OR operation to the content of two blocks.
113 pub inline fn orBlocks(block1: Block, block2: Block) Block {
113 pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
114114 return Block{ .repr = block1.repr | block2.repr };
115115 }
116116
......@@ -120,7 +120,7 @@ pub const Block = struct {
120120 pub const optimal_parallel_blocks = 8;
121121
122122 /// Encrypt multiple blocks in parallel, each their own round key.
123 pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
123 pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block {
124124 comptime var i = 0;
125125 var out: [count]Block = undefined;
126126 inline while (i < count) : (i += 1) {
......@@ -130,7 +130,7 @@ pub const Block = struct {
130130 }
131131
132132 /// Decrypt multiple blocks in parallel, each their own round key.
133 pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
133 pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block {
134134 comptime var i = 0;
135135 var out: [count]Block = undefined;
136136 inline while (i < count) : (i += 1) {
......@@ -140,7 +140,7 @@ pub const Block = struct {
140140 }
141141
142142 /// Encrypt multiple blocks in parallel with the same round key.
143 pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
143 pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
144144 comptime var i = 0;
145145 var out: [count]Block = undefined;
146146 inline while (i < count) : (i += 1) {
......@@ -150,7 +150,7 @@ pub const Block = struct {
150150 }
151151
152152 /// Decrypt multiple blocks in parallel with the same round key.
153 pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
153 pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
154154 comptime var i = 0;
155155 var out: [count]Block = undefined;
156156 inline while (i < count) : (i += 1) {
......@@ -160,7 +160,7 @@ pub const Block = struct {
160160 }
161161
162162 /// Encrypt multiple blocks in parallel with the same last round key.
163 pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
163 pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
164164 comptime var i = 0;
165165 var out: [count]Block = undefined;
166166 inline while (i < count) : (i += 1) {
......@@ -170,7 +170,7 @@ pub const Block = struct {
170170 }
171171
172172 /// Decrypt multiple blocks in parallel with the same last round key.
173 pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
173 pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block {
174174 comptime var i = 0;
175175 var out: [count]Block = undefined;
176176 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/soft.zig+10-10
......@@ -18,7 +18,7 @@ pub const Block = struct {
1818 repr: BlockVec align(16),
1919
2020 /// Convert a byte sequence into an internal representation.
21 pub inline fn fromBytes(bytes: *const [16]u8) Block {
21 pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block {
2222 const s0 = mem.readIntBig(u32, bytes[0..4]);
2323 const s1 = mem.readIntBig(u32, bytes[4..8]);
2424 const s2 = mem.readIntBig(u32, bytes[8..12]);
......@@ -27,7 +27,7 @@ pub const Block = struct {
2727 }
2828
2929 /// Convert the internal representation of a block into a byte sequence.
30 pub inline fn toBytes(block: Block) [16]u8 {
30 pub fn toBytes(block: Block) callconv(.Inline) [16]u8 {
3131 var bytes: [16]u8 = undefined;
3232 mem.writeIntBig(u32, bytes[0..4], block.repr[0]);
3333 mem.writeIntBig(u32, bytes[4..8], block.repr[1]);
......@@ -37,7 +37,7 @@ pub const Block = struct {
3737 }
3838
3939 /// XOR the block with a byte sequence.
40 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
40 pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 {
4141 const block_bytes = block.toBytes();
4242 var x: [16]u8 = undefined;
4343 comptime var i: usize = 0;
......@@ -48,7 +48,7 @@ pub const Block = struct {
4848 }
4949
5050 /// Encrypt a block with a round key.
51 pub inline fn encrypt(block: Block, round_key: Block) Block {
51 pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block {
5252 const src = &block.repr;
5353
5454 const s0 = block.repr[0];
......@@ -65,7 +65,7 @@ pub const Block = struct {
6565 }
6666
6767 /// Encrypt a block with the last round key.
68 pub inline fn encryptLast(block: Block, round_key: Block) Block {
68 pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block {
6969 const src = &block.repr;
7070
7171 const t0 = block.repr[0];
......@@ -87,7 +87,7 @@ pub const Block = struct {
8787 }
8888
8989 /// Decrypt a block with a round key.
90 pub inline fn decrypt(block: Block, round_key: Block) Block {
90 pub fn decrypt(block: Block, round_key: Block) callconv(.Inline) Block {
9191 const src = &block.repr;
9292
9393 const s0 = block.repr[0];
......@@ -104,7 +104,7 @@ pub const Block = struct {
104104 }
105105
106106 /// Decrypt a block with the last round key.
107 pub inline fn decryptLast(block: Block, round_key: Block) Block {
107 pub fn decryptLast(block: Block, round_key: Block) callconv(.Inline) Block {
108108 const src = &block.repr;
109109
110110 const t0 = block.repr[0];
......@@ -126,7 +126,7 @@ pub const Block = struct {
126126 }
127127
128128 /// Apply the bitwise XOR operation to the content of two blocks.
129 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
129 pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
130130 var x: BlockVec = undefined;
131131 comptime var i = 0;
132132 inline while (i < 4) : (i += 1) {
......@@ -136,7 +136,7 @@ pub const Block = struct {
136136 }
137137
138138 /// Apply the bitwise AND operation to the content of two blocks.
139 pub inline fn andBlocks(block1: Block, block2: Block) Block {
139 pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
140140 var x: BlockVec = undefined;
141141 comptime var i = 0;
142142 inline while (i < 4) : (i += 1) {
......@@ -146,7 +146,7 @@ pub const Block = struct {
146146 }
147147
148148 /// Apply the bitwise OR operation to the content of two blocks.
149 pub inline fn orBlocks(block1: Block, block2: Block) Block {
149 pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block {
150150 var x: BlockVec = undefined;
151151 comptime var i = 0;
152152 inline while (i < 4) : (i += 1) {
lib/std/crypto/blake3.zig+3-3
......@@ -66,7 +66,7 @@ const CompressVectorized = struct {
6666 const Lane = Vector(4, u32);
6767 const Rows = [4]Lane;
6868
69 inline fn g(comptime even: bool, rows: *Rows, m: Lane) void {
69 fn g(comptime even: bool, rows: *Rows, m: Lane) callconv(.Inline) void {
7070 rows[0] +%= rows[1] +% m;
7171 rows[3] ^= rows[0];
7272 rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16);
......@@ -75,13 +75,13 @@ const CompressVectorized = struct {
7575 rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12);
7676 }
7777
78 inline fn diagonalize(rows: *Rows) void {
78 fn diagonalize(rows: *Rows) callconv(.Inline) void {
7979 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 });
8080 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
8181 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 });
8282 }
8383
84 inline fn undiagonalize(rows: *Rows) void {
84 fn undiagonalize(rows: *Rows) callconv(.Inline) void {
8585 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 });
8686 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
8787 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 });
lib/std/crypto/chacha20.zig+6-6
......@@ -35,7 +35,7 @@ const ChaCha20VecImpl = struct {
3535 };
3636 }
3737
38 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
38 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
3939 x.* = input;
4040
4141 var r: usize = 0;
......@@ -80,7 +80,7 @@ const ChaCha20VecImpl = struct {
8080 }
8181 }
8282
83 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {
83 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
8484 var i: usize = 0;
8585 while (i < 4) : (i += 1) {
8686 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);
......@@ -90,7 +90,7 @@ const ChaCha20VecImpl = struct {
9090 }
9191 }
9292
93 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
93 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
9494 x[0] +%= ctx[0];
9595 x[1] +%= ctx[1];
9696 x[2] +%= ctx[2];
......@@ -190,7 +190,7 @@ const ChaCha20NonVecImpl = struct {
190190 };
191191 }
192192
193 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
193 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
194194 x.* = input;
195195
196196 const rounds = comptime [_]QuarterRound{
......@@ -219,7 +219,7 @@ const ChaCha20NonVecImpl = struct {
219219 }
220220 }
221221
222 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {
222 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
223223 var i: usize = 0;
224224 while (i < 4) : (i += 1) {
225225 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]);
......@@ -229,7 +229,7 @@ const ChaCha20NonVecImpl = struct {
229229 }
230230 }
231231
232 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
232 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
233233 var i: usize = 0;
234234 while (i < 16) : (i += 1) {
235235 x[i] +%= ctx[i];
lib/std/crypto/ghash.zig+2-2
......@@ -95,7 +95,7 @@ pub const Ghash = struct {
9595 }
9696 }
9797
98 inline fn clmul_pclmul(x: u64, y: u64) u64 {
98 fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 {
9999 const Vector = std.meta.Vector;
100100 const product = asm (
101101 \\ vpclmulqdq $0x00, %[x], %[y], %[out]
......@@ -106,7 +106,7 @@ pub const Ghash = struct {
106106 return product[0];
107107 }
108108
109 inline fn clmul_pmull(x: u64, y: u64) u64 {
109 fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 {
110110 const Vector = std.meta.Vector;
111111 const product = asm (
112112 \\ pmull %[out].1q, %[x].1d, %[y].1d
lib/std/crypto/gimli.zig+2-2
......@@ -48,7 +48,7 @@ pub const State = struct {
4848 return mem.asBytes(&self.data);
4949 }
5050
51 inline fn endianSwap(self: *Self) void {
51 fn endianSwap(self: *Self) callconv(.Inline) void {
5252 for (self.data) |*w| {
5353 w.* = mem.littleToNative(u32, w.*);
5454 }
......@@ -116,7 +116,7 @@ pub const State = struct {
116116
117117 const Lane = Vector(4, u32);
118118
119 inline fn shift(x: Lane, comptime n: comptime_int) Lane {
119 fn shift(x: Lane, comptime n: comptime_int) callconv(.Inline) Lane {
120120 return x << @splat(4, @as(u5, n));
121121 }
122122
lib/std/crypto/salsa20.zig+3-3
......@@ -37,7 +37,7 @@ const Salsa20VecImpl = struct {
3737 };
3838 }
3939
40 inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
40 fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void {
4141 const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] };
4242 const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] };
4343 const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] };
......@@ -211,7 +211,7 @@ const Salsa20NonVecImpl = struct {
211211 d: u6,
212212 };
213213
214 inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound {
214 fn Rp(a: usize, b: usize, c: usize, d: u6) callconv(.Inline) QuarterRound {
215215 return QuarterRound{
216216 .a = a,
217217 .b = b,
......@@ -220,7 +220,7 @@ const Salsa20NonVecImpl = struct {
220220 };
221221 }
222222
223 inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
223 fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void {
224224 const arx_steps = comptime [_]QuarterRound{
225225 Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18),
226226 Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18),
lib/std/elf.zig+8-8
......@@ -720,10 +720,10 @@ pub const Elf32_Rel = extern struct {
720720 r_offset: Elf32_Addr,
721721 r_info: Elf32_Word,
722722
723 pub inline fn r_sym(self: @This()) u24 {
723 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
724724 return @truncate(u24, self.r_info >> 8);
725725 }
726 pub inline fn r_type(self: @This()) u8 {
726 pub fn r_type(self: @This()) callconv(.Inline) u8 {
727727 return @truncate(u8, self.r_info & 0xff);
728728 }
729729};
......@@ -731,10 +731,10 @@ pub const Elf64_Rel = extern struct {
731731 r_offset: Elf64_Addr,
732732 r_info: Elf64_Xword,
733733
734 pub inline fn r_sym(self: @This()) u32 {
734 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
735735 return @truncate(u32, self.r_info >> 32);
736736 }
737 pub inline fn r_type(self: @This()) u32 {
737 pub fn r_type(self: @This()) callconv(.Inline) u32 {
738738 return @truncate(u32, self.r_info & 0xffffffff);
739739 }
740740};
......@@ -743,10 +743,10 @@ pub const Elf32_Rela = extern struct {
743743 r_info: Elf32_Word,
744744 r_addend: Elf32_Sword,
745745
746 pub inline fn r_sym(self: @This()) u24 {
746 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
747747 return @truncate(u24, self.r_info >> 8);
748748 }
749 pub inline fn r_type(self: @This()) u8 {
749 pub fn r_type(self: @This()) callconv(.Inline) u8 {
750750 return @truncate(u8, self.r_info & 0xff);
751751 }
752752};
......@@ -755,10 +755,10 @@ pub const Elf64_Rela = extern struct {
755755 r_info: Elf64_Xword,
756756 r_addend: Elf64_Sxword,
757757
758 pub inline fn r_sym(self: @This()) u32 {
758 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
759759 return @truncate(u32, self.r_info >> 32);
760760 }
761 pub inline fn r_type(self: @This()) u32 {
761 pub fn r_type(self: @This()) callconv(.Inline) u32 {
762762 return @truncate(u32, self.r_info & 0xffffffff);
763763 }
764764};
lib/std/fmt/parse_float.zig+4-4
......@@ -52,21 +52,21 @@ const Z96 = struct {
5252 d2: u32,
5353
5454 // d = s >> 1
55 inline fn shiftRight1(d: *Z96, s: Z96) void {
55 fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void {
5656 d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31);
5757 d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31);
5858 d.d2 = s.d2 >> 1;
5959 }
6060
6161 // d = s << 1
62 inline fn shiftLeft1(d: *Z96, s: Z96) void {
62 fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void {
6363 d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31);
6464 d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31);
6565 d.d0 = s.d0 << 1;
6666 }
6767
6868 // d += s
69 inline fn add(d: *Z96, s: Z96) void {
69 fn add(d: *Z96, s: Z96) callconv(.Inline) void {
7070 var w = @as(u64, d.d0) + @as(u64, s.d0);
7171 d.d0 = @truncate(u32, w);
7272
......@@ -80,7 +80,7 @@ const Z96 = struct {
8080 }
8181
8282 // d -= s
83 inline fn sub(d: *Z96, s: Z96) void {
83 fn sub(d: *Z96, s: Z96) callconv(.Inline) void {
8484 var w = @as(u64, d.d0) -% @as(u64, s.d0);
8585 d.d0 = @truncate(u32, w);
8686
lib/std/hash/cityhash.zig+1-1
......@@ -6,7 +6,7 @@
66const std = @import("std");
77const builtin = @import("builtin");
88
9inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 {
9fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 {
1010 // ptr + offset doesn't work at comptime so we need this instead.
1111 return @ptrCast([*]const u8, &ptr[offset]);
1212}
lib/std/os/bits/freebsd.zig+4-4
......@@ -815,16 +815,16 @@ pub const sigval = extern union {
815815pub const _SIG_WORDS = 4;
816816pub const _SIG_MAXSIG = 128;
817817
818pub inline fn _SIG_IDX(sig: usize) usize {
818pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
819819 return sig - 1;
820820}
821pub inline fn _SIG_WORD(sig: usize) usize {
821pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
822822 return_SIG_IDX(sig) >> 5;
823823}
824pub inline fn _SIG_BIT(sig: usize) usize {
824pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
825825 return 1 << (_SIG_IDX(sig) & 31);
826826}
827pub inline fn _SIG_VALID(sig: usize) usize {
827pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
828828 return sig <= _SIG_MAXSIG and sig > 0;
829829}
830830
lib/std/os/bits/netbsd.zig+4-4
......@@ -796,16 +796,16 @@ pub const _ksiginfo = extern struct {
796796pub const _SIG_WORDS = 4;
797797pub const _SIG_MAXSIG = 128;
798798
799pub inline fn _SIG_IDX(sig: usize) usize {
799pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
800800 return sig - 1;
801801}
802pub inline fn _SIG_WORD(sig: usize) usize {
802pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
803803 return_SIG_IDX(sig) >> 5;
804804}
805pub inline fn _SIG_BIT(sig: usize) usize {
805pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
806806 return 1 << (_SIG_IDX(sig) & 31);
807807}
808pub inline fn _SIG_VALID(sig: usize) usize {
808pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
809809 return sig <= _SIG_MAXSIG and sig > 0;
810810}
811811
lib/std/os/linux.zig+1-1
......@@ -126,7 +126,7 @@ pub fn fork() usize {
126126/// It is advised to avoid this function and use clone instead, because
127127/// the compiler is not aware of how vfork affects control flow and you may
128128/// see different results in optimized builds.
129pub inline fn vfork() usize {
129pub fn vfork() callconv(.Inline) usize {
130130 return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});
131131}
132132
lib/std/os/linux/tls.zig+1-1
......@@ -300,7 +300,7 @@ fn initTLS() void {
300300 };
301301}
302302
303inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T {
303fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T {
304304 return @ptrCast(*T, @alignCast(@alignOf(*T), ptr));
305305}
306306
lib/std/os/windows.zig+1-1
......@@ -1669,7 +1669,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace {
16691669 return path_space;
16701670}
16711671
1672inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID {
1672fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID {
16731673 return (s << 10) | p;
16741674}
16751675
lib/std/start.zig+2-2
......@@ -262,7 +262,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret
262262
263263// This is marked inline because for some reason LLVM in release mode fails to inline it,
264264// and we want fewer call frames in stack traces.
265inline fn initEventLoopAndCallMain() u8 {
265fn initEventLoopAndCallMain() callconv(.Inline) u8 {
266266 if (std.event.Loop.instance) |loop| {
267267 if (!@hasDecl(root, "event_loop")) {
268268 loop.init() catch |err| {
......@@ -291,7 +291,7 @@ inline fn initEventLoopAndCallMain() u8 {
291291// and we want fewer call frames in stack traces.
292292// TODO This function is duplicated from initEventLoopAndCallMain instead of using generics
293293// because it is working around stage1 compiler bugs.
294inline fn initEventLoopAndCallWinMain() std.os.windows.INT {
294fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT {
295295 if (std.event.Loop.instance) |loop| {
296296 if (!@hasDecl(root, "event_loop")) {
297297 loop.init() catch |err| {
lib/std/zig/ast.zig+9
......@@ -1357,6 +1357,7 @@ pub const Node = struct {
13571357 extern_export_inline_token: TokenIndex,
13581358 is_extern_prototype: void, // TODO: Remove once extern fn rewriting is
13591359 is_async: void, // TODO: remove once async fn rewriting is
1360 is_inline: void, // TODO: remove once inline fn rewriting is
13601361 });
13611362
13621363 pub const RequiredFields = struct {
......@@ -1523,6 +1524,14 @@ pub const Node = struct {
15231524 self.setTrailer(.is_async, value);
15241525 }
15251526
1527 pub fn getIsInline(self: *const FnProto) ?void {
1528 return self.getTrailer(.is_inline);
1529 }
1530
1531 pub fn setIsInline(self: *FnProto, value: void) void {
1532 self.setTrailer(.is_inline, value);
1533 }
1534
15261535 fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) {
15271536 const trailers_start = @alignCast(
15281537 @alignOf(ParamDecl),
lib/std/zig/parse.zig+9-2
......@@ -493,9 +493,15 @@ const Parser = struct {
493493 extern_export_inline_token: ?TokenIndex = null,
494494 lib_name: ?*Node = null,
495495 }) !?*Node {
496 // TODO: Remove once extern/async fn rewriting is
497 var is_async: ?void = null;
496 // TODO: Remove once extern/async/inline fn rewriting is
498497 var is_extern_prototype: ?void = null;
498 var is_async: ?void = null;
499 var is_inline: ?void = null;
500 if (fields.extern_export_inline_token != null and
501 p.token_ids[fields.extern_export_inline_token.?] == .Keyword_inline)
502 {
503 is_inline = {};
504 }
499505 const cc_token: ?TokenIndex = blk: {
500506 if (p.eatToken(.Keyword_extern)) |token| {
501507 is_extern_prototype = {};
......@@ -573,6 +579,7 @@ const Parser = struct {
573579 .callconv_expr = callconv_expr,
574580 .is_extern_prototype = is_extern_prototype,
575581 .is_async = is_async,
582 .is_inline = is_inline,
576583 });
577584 std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params);
578585
lib/std/zig/parser_test.zig+3-3
......@@ -2355,17 +2355,17 @@ test "zig fmt: functions" {
23552355 \\extern fn puts(s: *const u8) c_int;
23562356 \\extern "c" fn puts(s: *const u8) c_int;
23572357 \\export fn puts(s: *const u8) c_int;
2358 \\inline fn puts(s: *const u8) c_int;
2358 \\fn puts(s: *const u8) callconv(.Inline) c_int;
23592359 \\noinline fn puts(s: *const u8) c_int;
23602360 \\pub extern fn puts(s: *const u8) c_int;
23612361 \\pub extern "c" fn puts(s: *const u8) c_int;
23622362 \\pub export fn puts(s: *const u8) c_int;
2363 \\pub inline fn puts(s: *const u8) c_int;
2363 \\pub fn puts(s: *const u8) callconv(.Inline) c_int;
23642364 \\pub noinline fn puts(s: *const u8) c_int;
23652365 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;
23662366 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;
23672367 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;
2368 \\pub inline fn puts(s: *const u8) align(2 + 2) c_int;
2368 \\pub fn puts(s: *const u8) align(2 + 2) callconv(.Inline) c_int;
23692369 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;
23702370 \\
23712371 );
lib/std/zig/render.zig+3-1
......@@ -1558,7 +1558,7 @@ fn renderExpression(
15581558 }
15591559
15601560 if (fn_proto.getExternExportInlineToken()) |extern_export_inline_token| {
1561 if (fn_proto.getIsExternPrototype() == null)
1561 if (fn_proto.getIsExternPrototype() == null and fn_proto.getIsInline() == null)
15621562 try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline
15631563 }
15641564
......@@ -1664,6 +1664,8 @@ fn renderExpression(
16641664 try ais.writer().writeAll("callconv(.C) ");
16651665 } else if (fn_proto.getIsAsync() != null) {
16661666 try ais.writer().writeAll("callconv(.Async) ");
1667 } else if (fn_proto.getIsInline() != null) {
1668 try ais.writer().writeAll("callconv(.Inline) ");
16671669 }
16681670
16691671 switch (fn_proto.return_type) {
lib/std/zig/system/x86.zig+2-2
......@@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void
1919 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
2020}
2121
22inline fn bit(input: u32, offset: u5) bool {
22fn bit(input: u32, offset: u5) callconv(.Inline) bool {
2323 return (input >> offset) & 1 != 0;
2424}
2525
26inline fn hasMask(input: u32, mask: u32) bool {
26fn hasMask(input: u32, mask: u32) callconv(.Inline) bool {
2727 return (input & mask) == mask;
2828}
2929
src/Module.zig+19-16
......@@ -1087,14 +1087,23 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
10871087 if (fn_proto.getSectionExpr()) |sect_expr| {
10881088 return self.failNode(&fn_type_scope.base, sect_expr, "TODO implement function section expression", .{});
10891089 }
1090 if (fn_proto.getCallconvExpr()) |callconv_expr| {
1091 return self.failNode(
1092 &fn_type_scope.base,
1093 callconv_expr,
1094 "TODO implement function calling convention expression",
1095 .{},
1096 );
1097 }
1090
1091 const enum_literal_type = try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{
1092 .ty = Type.initTag(.type),
1093 .val = Value.initTag(.enum_literal_type),
1094 });
1095 const enum_literal_type_rl: astgen.ResultLoc = .{ .ty = enum_literal_type };
1096 const cc = if (fn_proto.getCallconvExpr()) |callconv_expr|
1097 try astgen.expr(self, &fn_type_scope.base, enum_literal_type_rl, callconv_expr)
1098 else
1099 try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{
1100 .ty = Type.initTag(.enum_literal),
1101 .val = try Value.Tag.enum_literal.create(
1102 &fn_type_scope_arena.allocator,
1103 try fn_type_scope_arena.allocator.dupe(u8, "Unspecified"),
1104 ),
1105 });
1106
10981107 const return_type_expr = switch (fn_proto.return_type) {
10991108 .Explicit => |node| node,
11001109 .InferErrorSet => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement inferred error sets", .{}),
......@@ -1105,6 +1114,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
11051114 const fn_type_inst = try astgen.addZIRInst(self, &fn_type_scope.base, fn_src, zir.Inst.FnType, .{
11061115 .return_type = return_type_inst,
11071116 .param_types = param_types,
1117 .cc = cc,
11081118 }, .{});
11091119
11101120 if (std.builtin.mode == .Debug and self.comp.verbose_ir) {
......@@ -1230,14 +1240,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
12301240 };
12311241 };
12321242
1233 const is_inline = blk: {
1234 if (fn_proto.getExternExportInlineToken()) |maybe_inline_token| {
1235 if (tree.token_ids[maybe_inline_token] == .Keyword_inline) {
1236 break :blk true;
1237 }
1238 }
1239 break :blk false;
1240 };
1243 const is_inline = fn_type.fnCallingConvention() == .Inline;
12411244 const anal_state = ([2]Fn.Analysis{ .queued, .inline_only })[@boolToInt(is_inline)];
12421245
12431246 new_func.* = .{
src/link/MachO.zig+1-1
......@@ -2366,7 +2366,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 {
23662366 return min_pos - start;
23672367}
23682368
2369inline fn checkForCollision(start: u64, end: u64, off: u64, size: u64) ?u64 {
2369fn checkForCollision(start: u64, end: u64, off: u64, size: u64) callconv(.Inline) ?u64 {
23702370 const increased_size = padToIdeal(size);
23712371 const test_end = off + increased_size;
23722372 if (end > off and start < test_end) {
src/stage1/all_types.hpp+3-9
......@@ -74,6 +74,7 @@ enum CallingConvention {
7474 CallingConventionC,
7575 CallingConventionNaked,
7676 CallingConventionAsync,
77 CallingConventionInline,
7778 CallingConventionInterrupt,
7879 CallingConventionSignal,
7980 CallingConventionStdcall,
......@@ -703,12 +704,6 @@ enum NodeType {
703704 NodeTypeAnyTypeField,
704705};
705706
706enum FnInline {
707 FnInlineAuto,
708 FnInlineAlways,
709 FnInlineNever,
710};
711
712707struct AstNodeFnProto {
713708 Buf *name;
714709 ZigList<AstNode *> params;
......@@ -725,13 +720,12 @@ struct AstNodeFnProto {
725720 AstNode *callconv_expr;
726721 Buf doc_comments;
727722
728 FnInline fn_inline;
729
730723 VisibMod visib_mod;
731724 bool auto_err_set;
732725 bool is_var_args;
733726 bool is_extern;
734727 bool is_export;
728 bool is_noinline;
735729};
736730
737731struct AstNodeFnDef {
......@@ -1719,7 +1713,6 @@ struct ZigFn {
17191713
17201714 LLVMValueRef valgrind_client_request_array;
17211715
1722 FnInline fn_inline;
17231716 FnAnalState anal_state;
17241717
17251718 uint32_t align_bytes;
......@@ -1728,6 +1721,7 @@ struct ZigFn {
17281721 bool calls_or_awaits_errorable_fn;
17291722 bool is_cold;
17301723 bool is_test;
1724 bool is_noinline;
17311725};
17321726
17331727uint32_t fn_table_entry_hash(ZigFn*);
src/stage1/analyze.cpp+15-5
......@@ -973,6 +973,7 @@ const char *calling_convention_name(CallingConvention cc) {
973973 case CallingConventionAPCS: return "APCS";
974974 case CallingConventionAAPCS: return "AAPCS";
975975 case CallingConventionAAPCSVFP: return "AAPCSVFP";
976 case CallingConventionInline: return "Inline";
976977 }
977978 zig_unreachable();
978979}
......@@ -981,6 +982,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
981982 switch (cc) {
982983 case CallingConventionUnspecified:
983984 case CallingConventionAsync:
985 case CallingConventionInline:
984986 return true;
985987 case CallingConventionC:
986988 case CallingConventionNaked:
......@@ -1007,7 +1009,8 @@ ZigType *get_stack_trace_type(CodeGen *g) {
10071009}
10081010
10091011bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {
1010 if (fn_type_id->cc == CallingConventionUnspecified) {
1012 if (fn_type_id->cc == CallingConventionUnspecified
1013 || fn_type_id->cc == CallingConventionInline) {
10111014 return handle_is_ptr(g, fn_type_id->return_type);
10121015 }
10131016 if (fn_type_id->cc != CallingConventionC) {
......@@ -1888,6 +1891,7 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
18881891 case CallingConventionC:
18891892 case CallingConventionNaked:
18901893 case CallingConventionAsync:
1894 case CallingConventionInline:
18911895 break;
18921896 case CallingConventionInterrupt:
18931897 if (g->zig_target->arch != ZigLLVM_x86
......@@ -3587,7 +3591,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i
35873591 }
35883592}
35893593
3590static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {
3594static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {
35913595 ZigFn *fn_entry = heap::c_allocator.create<ZigFn>();
35923596 fn_entry->ir_executable = heap::c_allocator.create<IrExecutableSrc>();
35933597
......@@ -3597,7 +3601,7 @@ static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {
35973601 fn_entry->analyzed_executable.backward_branch_quota = &fn_entry->prealloc_backward_branch_quota;
35983602 fn_entry->analyzed_executable.fn_entry = fn_entry;
35993603 fn_entry->ir_executable->fn_entry = fn_entry;
3600 fn_entry->fn_inline = inline_value;
3604 fn_entry->is_noinline = is_noinline;
36013605
36023606 return fn_entry;
36033607}
......@@ -3606,7 +3610,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {
36063610 assert(proto_node->type == NodeTypeFnProto);
36073611 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
36083612
3609 ZigFn *fn_entry = create_fn_raw(g, fn_proto->fn_inline);
3613 ZigFn *fn_entry = create_fn_raw(g, fn_proto->is_noinline);
36103614
36113615 fn_entry->proto_node = proto_node;
36123616 fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr :
......@@ -3739,6 +3743,12 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
37393743 fn_table_entry->type_entry = g->builtin_types.entry_invalid;
37403744 tld_fn->base.resolution = TldResolutionInvalid;
37413745 return;
3746 case CallingConventionInline:
3747 add_node_error(g, fn_def_node,
3748 buf_sprintf("exported function cannot be inline"));
3749 fn_table_entry->type_entry = g->builtin_types.entry_invalid;
3750 tld_fn->base.resolution = TldResolutionInvalid;
3751 return;
37423752 case CallingConventionC:
37433753 case CallingConventionNaked:
37443754 case CallingConventionInterrupt:
......@@ -3774,7 +3784,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
37743784 fn_table_entry->inferred_async_node = fn_table_entry->proto_node;
37753785 }
37763786 } else if (source_node->type == NodeTypeTestDecl) {
3777 ZigFn *fn_table_entry = create_fn_raw(g, FnInlineAuto);
3787 ZigFn *fn_table_entry = create_fn_raw(g, false);
37783788
37793789 get_fully_qualified_decl_name(g, &fn_table_entry->symbol_name, &tld_fn->base, true);
37803790
src/stage1/ast_render.cpp+3-8
......@@ -123,13 +123,8 @@ static const char *export_string(bool is_export) {
123123// zig_unreachable();
124124//}
125125
126static const char *inline_string(FnInline fn_inline) {
127 switch (fn_inline) {
128 case FnInlineAlways: return "inline ";
129 case FnInlineNever: return "noinline ";
130 case FnInlineAuto: return "";
131 }
132 zig_unreachable();
126static const char *inline_string(bool is_inline) {
127 return is_inline ? "inline" : "";
133128}
134129
135130static const char *const_or_var_string(bool is_const) {
......@@ -446,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
446441 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);
447442 const char *extern_str = extern_string(node->data.fn_proto.is_extern);
448443 const char *export_str = export_string(node->data.fn_proto.is_export);
449 const char *inline_str = inline_string(node->data.fn_proto.fn_inline);
444 const char *inline_str = inline_string(node->data.fn_proto.is_noinline);
450445 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);
451446 if (node->data.fn_proto.name != nullptr) {
452447 print_symbol(ar, node->data.fn_proto.name);
src/stage1/codegen.cpp+18-28
......@@ -159,6 +159,7 @@ static const char *get_mangled_name(CodeGen *g, const char *original_name) {
159159static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
160160 switch (cc) {
161161 case CallingConventionUnspecified:
162 case CallingConventionInline:
162163 return ZigLLVM_Fast;
163164 case CallingConventionC:
164165 return ZigLLVM_C;
......@@ -350,6 +351,7 @@ static bool cc_want_sret_attr(CallingConvention cc) {
350351 return true;
351352 case CallingConventionAsync:
352353 case CallingConventionUnspecified:
354 case CallingConventionInline:
353355 return false;
354356 }
355357 zig_unreachable();
......@@ -452,20 +454,11 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
452454 }
453455 }
454456
455 switch (fn->fn_inline) {
456 case FnInlineAlways:
457 addLLVMFnAttr(llvm_fn, "alwaysinline");
458 g->inline_fns.append(fn);
459 break;
460 case FnInlineNever:
461 addLLVMFnAttr(llvm_fn, "noinline");
462 break;
463 case FnInlineAuto:
464 if (fn->alignstack_value != 0) {
465 addLLVMFnAttr(llvm_fn, "noinline");
466 }
467 break;
468 }
457 if (cc == CallingConventionInline)
458 addLLVMFnAttr(llvm_fn, "alwaysinline");
459
460 if (fn->is_noinline || (cc != CallingConventionInline && fn->alignstack_value != 0))
461 addLLVMFnAttr(llvm_fn, "noinline");
469462
470463 if (cc == CallingConventionNaked) {
471464 addLLVMFnAttr(llvm_fn, "naked");
......@@ -532,7 +525,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
532525 addLLVMFnAttr(llvm_fn, "nounwind");
533526 add_uwtable_attr(g, llvm_fn);
534527 addLLVMFnAttr(llvm_fn, "nobuiltin");
535 if (codegen_have_frame_pointer(g) && fn->fn_inline != FnInlineAlways) {
528 if (codegen_have_frame_pointer(g) && cc != CallingConventionInline) {
536529 ZigLLVMAddFunctionAttr(llvm_fn, "frame-pointer", "all");
537530 }
538531 if (fn->section_name) {
......@@ -9043,19 +9036,16 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
90439036 static_assert(CallingConventionC == 1, "");
90449037 static_assert(CallingConventionNaked == 2, "");
90459038 static_assert(CallingConventionAsync == 3, "");
9046 static_assert(CallingConventionInterrupt == 4, "");
9047 static_assert(CallingConventionSignal == 5, "");
9048 static_assert(CallingConventionStdcall == 6, "");
9049 static_assert(CallingConventionFastcall == 7, "");
9050 static_assert(CallingConventionVectorcall == 8, "");
9051 static_assert(CallingConventionThiscall == 9, "");
9052 static_assert(CallingConventionAPCS == 10, "");
9053 static_assert(CallingConventionAAPCS == 11, "");
9054 static_assert(CallingConventionAAPCSVFP == 12, "");
9055
9056 static_assert(FnInlineAuto == 0, "");
9057 static_assert(FnInlineAlways == 1, "");
9058 static_assert(FnInlineNever == 2, "");
9039 static_assert(CallingConventionInline == 4, "");
9040 static_assert(CallingConventionInterrupt == 5, "");
9041 static_assert(CallingConventionSignal == 6, "");
9042 static_assert(CallingConventionStdcall == 7, "");
9043 static_assert(CallingConventionFastcall == 8, "");
9044 static_assert(CallingConventionVectorcall == 9, "");
9045 static_assert(CallingConventionThiscall == 10, "");
9046 static_assert(CallingConventionAPCS == 11, "");
9047 static_assert(CallingConventionAAPCS == 12, "");
9048 static_assert(CallingConventionAAPCSVFP == 13, "");
90599049
90609050 static_assert(BuiltinPtrSizeOne == 0, "");
90619051 static_assert(BuiltinPtrSizeMany == 1, "");
src/stage1/ir.cpp+12-11
......@@ -19000,7 +19000,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV
1900019000 } else if (init_val->type->id == ZigTypeIdFn &&
1900119001 init_val->special != ConstValSpecialUndef &&
1900219002 init_val->data.x_ptr.special == ConstPtrSpecialFunction &&
19003 init_val->data.x_ptr.data.fn.fn_entry->fn_inline == FnInlineAlways)
19003 init_val->data.x_ptr.data.fn.fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionInline)
1900419004 {
1900519005 var_class_requires_const = true;
1900619006 if (!var->src_is_const && !is_comptime_var) {
......@@ -19182,6 +19182,11 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport
1918219182 buf_sprintf("exported function cannot be async"));
1918319183 add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here"));
1918419184 } break;
19185 case CallingConventionInline: {
19186 ErrorMsg *msg = ir_add_error(ira, &target->base,
19187 buf_sprintf("exported function cannot be inline"));
19188 add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here"));
19189 } break;
1918519190 case CallingConventionC:
1918619191 case CallingConventionNaked:
1918719192 case CallingConventionInterrupt:
......@@ -21120,7 +21125,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
2112021125 if (type_is_invalid(return_type))
2112121126 return ira->codegen->invalid_inst_gen;
2112221127
21123 if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) {
21128 if (fn_entry != nullptr && fn_type_id->cc == CallingConventionInline && modifier == CallModifierNeverInline) {
2112421129 ir_add_error(ira, source_instr,
2112521130 buf_sprintf("no-inline call of inline function"));
2112621131 return ira->codegen->invalid_inst_gen;
......@@ -25219,10 +25224,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa
2521925224 if ((err = type_resolve(ira->codegen, type_info_fn_decl_type, ResolveStatusSizeKnown)))
2522025225 return err;
2522125226
25222 ZigType *type_info_fn_decl_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_decl_type);
25223 if ((err = type_resolve(ira->codegen, type_info_fn_decl_inline_type, ResolveStatusSizeKnown)))
25224 return err;
25225
2522625227 resolve_container_usingnamespace_decls(ira->codegen, decls_scope);
2522725228
2522825229 // The unresolved declarations are collected in a separate queue to avoid
......@@ -25365,11 +25366,11 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa
2536525366 fn_decl_fields[0]->special = ConstValSpecialStatic;
2536625367 fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type;
2536725368 fn_decl_fields[0]->data.x_type = fn_entry->type_entry;
25368 // inline_type: Data.FnDecl.Inline
25369 ensure_field_index(fn_decl_val->type, "inline_type", 1);
25369 // is_noinline: bool
25370 ensure_field_index(fn_decl_val->type, "is_noinline", 1);
2537025371 fn_decl_fields[1]->special = ConstValSpecialStatic;
25371 fn_decl_fields[1]->type = type_info_fn_decl_inline_type;
25372 bigint_init_unsigned(&fn_decl_fields[1]->data.x_enum_tag, fn_entry->fn_inline);
25372 fn_decl_fields[1]->type = ira->codegen->builtin_types.entry_bool;
25373 fn_decl_fields[1]->data.x_bool = fn_entry->is_noinline;
2537325374 // is_var_args: bool
2537425375 ensure_field_index(fn_decl_val->type, "is_var_args", 2);
2537525376 bool is_varargs = fn_node->is_var_args;
......@@ -30957,7 +30958,7 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS
3095730958 return ira->codegen->invalid_inst_gen;
3095830959 }
3095930960
30960 if (fn_entry->fn_inline == FnInlineAlways) {
30961 if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionInline) {
3096130962 ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function"));
3096230963 return ira->codegen->invalid_inst_gen;
3096330964 }
src/stage1/parser.cpp+3-14
......@@ -693,8 +693,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
693693 Token *first = eat_token_if(pc, TokenIdKeywordExport);
694694 if (first == nullptr)
695695 first = eat_token_if(pc, TokenIdKeywordExtern);
696 if (first == nullptr)
697 first = eat_token_if(pc, TokenIdKeywordInline);
698696 if (first == nullptr)
699697 first = eat_token_if(pc, TokenIdKeywordNoInline);
700698 if (first != nullptr) {
......@@ -702,7 +700,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
702700 if (first->id == TokenIdKeywordExtern)
703701 lib_name = eat_token_if(pc, TokenIdStringLiteral);
704702
705 if (first->id != TokenIdKeywordInline && first->id != TokenIdKeywordNoInline) {
703 if (first->id != TokenIdKeywordNoInline) {
706704 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);
707705 AstNode *var_decl = ast_parse_var_decl(pc);
708706 if (var_decl != nullptr) {
......@@ -739,17 +737,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
739737 if (!fn_proto->data.fn_proto.is_extern)
740738 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
741739 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
742 switch (first->id) {
743 case TokenIdKeywordInline:
744 fn_proto->data.fn_proto.fn_inline = FnInlineAlways;
745 break;
746 case TokenIdKeywordNoInline:
747 fn_proto->data.fn_proto.fn_inline = FnInlineNever;
748 break;
749 default:
750 fn_proto->data.fn_proto.fn_inline = FnInlineAuto;
751 break;
752 }
740 if (first->id == TokenIdKeywordNoInline)
741 fn_proto->data.fn_proto.is_noinline = true;
753742 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);
754743
755744 AstNode *res = fn_proto;
src/tracy.zig+1-1
......@@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
3131 pub fn end(self: Ctx) void {}
3232};
3333
34pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
34pub fn trace(comptime src: std.builtin.SourceLocation) callconv(.Inline) Ctx {
3535 if (!enable) return .{};
3636
3737 const loc: ___tracy_source_location_data = .{
src/translate_c.zig+12-4
......@@ -4716,7 +4716,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
47164716 const scope = &c.global_scope.base;
47174717
47184718 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
4719 const inline_tok = try appendToken(c, .Keyword_inline, "inline");
47204719 const fn_tok = try appendToken(c, .Keyword_fn, "fn");
47214720 const name_tok = try appendIdentifier(c, name);
47224721 _ = try appendToken(c, .LParen, "(");
......@@ -4744,6 +4743,11 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
47444743
47454744 _ = try appendToken(c, .RParen, ")");
47464745
4746 _ = try appendToken(c, .Keyword_callconv, "callconv");
4747 _ = try appendToken(c, .LParen, "(");
4748 const callconv_expr = try transCreateNodeEnumLiteral(c, "Inline");
4749 _ = try appendToken(c, .RParen, ")");
4750
47474751 const block_lbrace = try appendToken(c, .LBrace, "{");
47484752
47494753 const return_kw = try appendToken(c, .Keyword_return, "return");
......@@ -4783,8 +4787,8 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
47834787 }, .{
47844788 .visib_token = pub_tok,
47854789 .name_token = name_tok,
4786 .extern_export_inline_token = inline_tok,
47874790 .body_node = &block.base,
4791 .callconv_expr = callconv_expr,
47884792 });
47894793 mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items);
47904794 return &fn_proto.base;
......@@ -5734,7 +5738,6 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
57345738 const scope = &block_scope.base;
57355739
57365740 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
5737 const inline_tok = try appendToken(c, .Keyword_inline, "inline");
57385741 const fn_tok = try appendToken(c, .Keyword_fn, "fn");
57395742 const name_tok = try appendIdentifier(c, m.name);
57405743 _ = try appendToken(c, .LParen, "(");
......@@ -5779,6 +5782,11 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
57795782
57805783 _ = try appendToken(c, .RParen, ")");
57815784
5785 _ = try appendToken(c, .Keyword_callconv, "callconv");
5786 _ = try appendToken(c, .LParen, "(");
5787 const callconv_expr = try transCreateNodeEnumLiteral(c, "Inline");
5788 _ = try appendToken(c, .RParen, ")");
5789
57825790 const type_of = try c.createBuiltinCall("@TypeOf", 1);
57835791
57845792 const return_kw = try appendToken(c, .Keyword_return, "return");
......@@ -5810,9 +5818,9 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
58105818 .return_type = .{ .Explicit = &type_of.base },
58115819 }, .{
58125820 .visib_token = pub_tok,
5813 .extern_export_inline_token = inline_tok,
58145821 .name_token = name_tok,
58155822 .body_node = block_node,
5823 .callconv_expr = callconv_expr,
58165824 });
58175825 mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items);
58185826
src/type.zig+3-1
......@@ -552,7 +552,9 @@ pub const Type = extern union {
552552 if (i != 0) try out_stream.writeAll(", ");
553553 try param_type.format("", .{}, out_stream);
554554 }
555 try out_stream.writeAll(") ");
555 try out_stream.writeAll(") callconv(.");
556 try out_stream.writeAll(@tagName(payload.cc));
557 try out_stream.writeAll(")");
556558 ty = payload.return_type;
557559 continue;
558560 },
src/zir.zig+3-6
......@@ -863,9 +863,7 @@ pub const Inst = struct {
863863 fn_type: *Inst,
864864 body: Body,
865865 },
866 kw_args: struct {
867 is_inline: bool = false,
868 },
866 kw_args: struct {},
869867 };
870868
871869 pub const FnType = struct {
......@@ -875,10 +873,9 @@ pub const Inst = struct {
875873 positionals: struct {
876874 param_types: []*Inst,
877875 return_type: *Inst,
876 cc: *Inst,
878877 },
879 kw_args: struct {
880 cc: std.builtin.CallingConvention = .Unspecified,
881 },
878 kw_args: struct {},
882879 };
883880
884881 pub const IntType = struct {
src/zir_sema.zig+13-19
......@@ -980,18 +980,8 @@ fn zirCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst {
980980
981981 const b = try mod.requireFunctionBlock(scope, inst.base.src);
982982 const is_comptime_call = b.is_comptime or inst.kw_args.modifier == .compile_time;
983 const is_inline_call = is_comptime_call or inst.kw_args.modifier == .always_inline or blk: {
984 // This logic will get simplified by
985 // https://github.com/ziglang/zig/issues/6429
986 if (try mod.resolveDefinedValue(scope, func)) |func_val| {
987 const module_fn = switch (func_val.tag()) {
988 .function => func_val.castTag(.function).?.data,
989 else => break :blk false,
990 };
991 break :blk module_fn.state == .inline_only;
992 }
993 break :blk false;
994 };
983 const is_inline_call = is_comptime_call or inst.kw_args.modifier == .always_inline or
984 func.ty.fnCallingConvention() == .Inline;
995985 if (is_inline_call) {
996986 const func_val = try mod.resolveConstValue(scope, func);
997987 const module_fn = switch (func_val.tag()) {
......@@ -1075,7 +1065,7 @@ fn zirFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst {
10751065 const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type);
10761066 const new_func = try scope.arena().create(Module.Fn);
10771067 new_func.* = .{
1078 .state = if (fn_inst.kw_args.is_inline) .inline_only else .queued,
1068 .state = if (fn_type.fnCallingConvention() == .Inline) .inline_only else .queued,
10791069 .zir = fn_inst.positionals.body,
10801070 .body = undefined,
10811071 .owner_decl = scope.ownerDecl().?,
......@@ -1305,22 +1295,26 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*
13051295 const tracy = trace(@src());
13061296 defer tracy.end();
13071297 const return_type = try resolveType(mod, scope, fntype.positionals.return_type);
1298 const cc_tv = try resolveInstConst(mod, scope, fntype.positionals.cc);
1299 const cc_str = cc_tv.val.castTag(.enum_literal).?.data;
1300 const cc = std.meta.stringToEnum(std.builtin.CallingConvention, cc_str) orelse
1301 return mod.fail(scope, fntype.positionals.cc.src, "Unknown calling convention {s}", .{cc_str});
13081302
13091303 // Hot path for some common function types.
13101304 if (fntype.positionals.param_types.len == 0) {
1311 if (return_type.zigTypeTag() == .NoReturn and fntype.kw_args.cc == .Unspecified) {
1305 if (return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) {
13121306 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_noreturn_no_args));
13131307 }
13141308
1315 if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .Unspecified) {
1309 if (return_type.zigTypeTag() == .Void and cc == .Unspecified) {
13161310 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_void_no_args));
13171311 }
13181312
1319 if (return_type.zigTypeTag() == .NoReturn and fntype.kw_args.cc == .Naked) {
1313 if (return_type.zigTypeTag() == .NoReturn and cc == .Naked) {
13201314 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_naked_noreturn_no_args));
13211315 }
13221316
1323 if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .C) {
1317 if (return_type.zigTypeTag() == .Void and cc == .C) {
13241318 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_ccc_void_no_args));
13251319 }
13261320 }
......@@ -1337,9 +1331,9 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*
13371331 }
13381332
13391333 const fn_ty = try Type.Tag.function.create(arena, .{
1340 .cc = fntype.kw_args.cc,
1341 .return_type = return_type,
13421334 .param_types = param_types,
1335 .return_type = return_type,
1336 .cc = cc,
13431337 });
13441338 return mod.constType(scope, fntype.base.src, fn_ty);
13451339}
test/cli.zig+1-1
......@@ -113,7 +113,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
113113 \\ return num * num;
114114 \\}
115115 \\extern fn zig_panic() noreturn;
116 \\pub inline fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
116 \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
117117 \\ zig_panic();
118118 \\}
119119 );
test/compile_errors.zig+6-6
......@@ -1648,7 +1648,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
16481648 \\ @call(.{ .modifier = .compile_time }, baz, .{});
16491649 \\}
16501650 \\fn foo() void {}
1651 \\inline fn bar() void {}
1651 \\fn bar() callconv(.Inline) void {}
16521652 \\fn baz1() void {}
16531653 \\fn baz2() void {}
16541654 , &[_][]const u8{
......@@ -3944,7 +3944,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39443944 \\export fn entry() void {
39453945 \\ var a = b;
39463946 \\}
3947 \\inline fn b() void { }
3947 \\fn b() callconv(.Inline) void { }
39483948 , &[_][]const u8{
39493949 "tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var",
39503950 "tmp.zig:4:1: note: declared here",
......@@ -6782,11 +6782,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
67826782 // \\export fn foo() void {
67836783 // \\ bar();
67846784 // \\}
6785 // \\inline fn bar() void {
6785 // \\fn bar() callconv(.Inline) void {
67866786 // \\ baz();
67876787 // \\ quux();
67886788 // \\}
6789 // \\inline fn baz() void {
6789 // \\fn baz() callconv(.Inline) void {
67906790 // \\ bar();
67916791 // \\ quux();
67926792 // \\}
......@@ -6799,7 +6799,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
67996799 // \\export fn foo() void {
68006800 // \\ quux(@ptrToInt(bar));
68016801 // \\}
6802 // \\inline fn bar() void { }
6802 // \\fn bar() callconv(.Inline) void { }
68036803 // \\extern fn quux(usize) void;
68046804 //, &[_][]const u8{
68056805 // "tmp.zig:4:1: error: unable to inline function",
......@@ -7207,7 +7207,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
72077207 \\export fn entry() void {
72087208 \\ foo();
72097209 \\}
7210 \\inline fn foo() void {
7210 \\fn foo() callconv(.Inline) void {
72117211 \\ @setAlignStack(16);
72127212 \\}
72137213 , &[_][]const u8{
test/stage1/behavior/fn.zig+1-1
......@@ -113,7 +113,7 @@ test "assign inline fn to const variable" {
113113 a();
114114}
115115
116inline fn inlineFn() void {}
116fn inlineFn() callconv(.Inline) void {}
117117
118118test "pass by non-copying value" {
119119 expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);
test/stage2/cbe.zig+1-1
......@@ -179,7 +179,7 @@ pub fn addCases(ctx: *TestContext) !void {
179179 \\ return y - 1;
180180 \\}
181181 \\
182 \\inline fn rec(n: usize) usize {
182 \\fn rec(n: usize) callconv(.Inline) usize {
183183 \\ if (n <= 1) return n;
184184 \\ return rec(n - 1);
185185 \\}
test/stage2/test.zig+5-5
......@@ -255,7 +255,7 @@ pub fn addCases(ctx: *TestContext) !void {
255255 \\ exit(y - 6);
256256 \\}
257257 \\
258 \\inline fn add(a: usize, b: usize, c: usize) usize {
258 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
259259 \\ return a + b + c;
260260 \\}
261261 \\
......@@ -1228,7 +1228,7 @@ pub fn addCases(ctx: *TestContext) !void {
12281228 \\ exit(y - 6);
12291229 \\}
12301230 \\
1231 \\inline fn add(a: usize, b: usize, c: usize) usize {
1231 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
12321232 \\ if (a == 10) @compileError("bad");
12331233 \\ return a + b + c;
12341234 \\}
......@@ -1251,7 +1251,7 @@ pub fn addCases(ctx: *TestContext) !void {
12511251 \\ exit(y - 6);
12521252 \\}
12531253 \\
1254 \\inline fn add(a: usize, b: usize, c: usize) usize {
1254 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
12551255 \\ if (a == 10) @compileError("bad");
12561256 \\ return a + b + c;
12571257 \\}
......@@ -1277,7 +1277,7 @@ pub fn addCases(ctx: *TestContext) !void {
12771277 \\ exit(y - 21);
12781278 \\}
12791279 \\
1280 \\inline fn fibonacci(n: usize) usize {
1280 \\fn fibonacci(n: usize) callconv(.Inline) usize {
12811281 \\ if (n <= 2) return n;
12821282 \\ return fibonacci(n - 2) + fibonacci(n - 1);
12831283 \\}
......@@ -1300,7 +1300,7 @@ pub fn addCases(ctx: *TestContext) !void {
13001300 \\ exit(y - 21);
13011301 \\}
13021302 \\
1303 \\inline fn fibonacci(n: usize) usize {
1303 \\fn fibonacci(n: usize) callconv(.Inline) usize {
13041304 \\ if (n <= 2) return n;
13051305 \\ return fibonacci(n - 2) + fibonacci(n - 1);
13061306 \\}
test/translate_c.zig+16-16
......@@ -43,7 +43,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
4343 ,
4444 \\pub const VALUE = ((((1 + (2 * 3)) + (4 * 5)) + 6) << 7) | @boolToInt(8 == 9);
4545 ,
46 \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf(((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16)) {
46 \\pub fn _AL_READ3BYTES(p: anytype) callconv(.Inline) @TypeOf(((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16)) {
4747 \\ return ((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16);
4848 \\}
4949 });
......@@ -116,7 +116,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
116116 \\};
117117 \\pub const Color = struct_Color;
118118 ,
119 \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) {
119 \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) {
120120 \\ return type_1;
121121 \\}
122122 ,
......@@ -148,7 +148,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
148148 cases.add("correct semicolon after infixop",
149149 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
150150 , &[_][]const u8{
151 \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) {
151 \\pub fn __ferror_unlocked_body(_fp: anytype) callconv(.Inline) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) {
152152 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;
153153 \\}
154154 });
......@@ -157,7 +157,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
157157 \\#define FOO(x) ((x >= 0) + (x >= 0))
158158 \\#define BAR 1 && 2 > 4
159159 , &[_][]const u8{
160 \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) {
160 \\pub fn FOO(x: anytype) callconv(.Inline) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) {
161161 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);
162162 \\}
163163 ,
......@@ -208,7 +208,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
208208 \\ break :blk bar;
209209 \\};
210210 ,
211 \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) {
211 \\pub fn bar(x: anytype) callconv(.Inline) @TypeOf(baz(1, 2)) {
212212 \\ return blk: {
213213 \\ _ = &x;
214214 \\ _ = 3;
......@@ -1590,13 +1590,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15901590 , &[_][]const u8{
15911591 \\pub extern var fn_ptr: ?fn () callconv(.C) void;
15921592 ,
1593 \\pub inline fn foo() void {
1593 \\pub fn foo() callconv(.Inline) void {
15941594 \\ return fn_ptr.?();
15951595 \\}
15961596 ,
15971597 \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8;
15981598 ,
1599 \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 {
1599 \\pub fn bar(arg_1: c_int, arg_2: f32) callconv(.Inline) u8 {
16001600 \\ return fn_ptr2.?(arg_1, arg_2);
16011601 \\}
16021602 });
......@@ -1629,7 +1629,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
16291629 ,
16301630 \\pub const glClearPFN = PFNGLCLEARPROC;
16311631 ,
1632 \\pub inline fn glClearUnion(arg_2: GLbitfield) void {
1632 \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void {
16331633 \\ return glProcs.gl.Clear.?(arg_2);
16341634 \\}
16351635 ,
......@@ -1650,15 +1650,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
16501650 , &[_][]const u8{
16511651 \\pub extern var c: c_int;
16521652 ,
1653 \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * 2) {
1653 \\pub fn BASIC(c_1: anytype) callconv(.Inline) @TypeOf(c_1 * 2) {
16541654 \\ return c_1 * 2;
16551655 \\}
16561656 ,
1657 \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) {
1657 \\pub fn FOO(L: anytype, b: anytype) callconv(.Inline) @TypeOf(L + b) {
16581658 \\ return L + b;
16591659 \\}
16601660 ,
1661 \\pub inline fn BAR() @TypeOf(c * c) {
1661 \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) {
16621662 \\ return c * c;
16631663 \\}
16641664 });
......@@ -2310,7 +2310,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
23102310 cases.add("macro call",
23112311 \\#define CALL(arg) bar(arg)
23122312 , &[_][]const u8{
2313 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
2313 \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) {
23142314 \\ return bar(arg);
23152315 \\}
23162316 });
......@@ -2872,7 +2872,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
28722872 \\#define BAR (void*) a
28732873 \\#define BAZ (uint32_t)(2)
28742874 , &[_][]const u8{
2875 \\pub inline fn FOO(bar: anytype) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) {
2875 \\pub fn FOO(bar: anytype) callconv(.Inline) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) {
28762876 \\ return baz((@import("std").meta.cast(?*c_void, baz)));
28772877 \\}
28782878 ,
......@@ -2914,11 +2914,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
29142914 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))
29152915 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
29162916 , &[_][]const u8{
2917 \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) {
2917 \\pub fn MIN(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b < a) b else a) {
29182918 \\ return if (b < a) b else a;
29192919 \\}
29202920 ,
2921 \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) {
2921 \\pub fn MAX(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b > a) b else a) {
29222922 \\ return if (b > a) b else a;
29232923 \\}
29242924 });
......@@ -3106,7 +3106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
31063106 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
31073107 \\
31083108 , &[_][]const u8{
3109 \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) {
3109 \\pub fn DefaultScreen(dpy: anytype) callconv(.Inline) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) {
31103110 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;
31113111 \\}
31123112 });