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
signature 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 {...@@ -4240,9 +4240,9 @@ fn _start() callconv(.Naked) noreturn {
4240 abort();4240 abort();
4241}4241}
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.
4244// If the function cannot be inlined, it is a compile-time error.4244// 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 {
4246 return a << 1;4246 return a << 1;
4247}4247}
42484248
lib/std/builtin.zig+2-9
...@@ -155,6 +155,7 @@ pub const CallingConvention = enum {...@@ -155,6 +155,7 @@ pub const CallingConvention = enum {
155 C,155 C,
156 Naked,156 Naked,
157 Async,157 Async,
158 Inline,
158 Interrupt,159 Interrupt,
159 Signal,160 Signal,
160 Stdcall,161 Stdcall,
...@@ -404,21 +405,13 @@ pub const TypeInfo = union(enum) {...@@ -404,21 +405,13 @@ pub const TypeInfo = union(enum) {
404 /// therefore must be kept in sync with the compiler implementation.405 /// therefore must be kept in sync with the compiler implementation.
405 pub const FnDecl = struct {406 pub const FnDecl = struct {
406 fn_type: type,407 fn_type: type,
407 inline_type: Inline,408 is_noinline: bool,
408 is_var_args: bool,409 is_var_args: bool,
409 is_extern: bool,410 is_extern: bool,
410 is_export: bool,411 is_export: bool,
411 lib_name: ?[]const u8,412 lib_name: ?[]const u8,
412 return_type: type,413 return_type: type,
413 arg_names: []const []const u8,414 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 };
422 };415 };
423 };416 };
424 };417 };
lib/std/c/builtins.zig+49-49
...@@ -6,70 +6,70 @@...@@ -6,70 +6,70 @@
66
7const std = @import("std");7const std = @import("std");
88
9pub inline fn __builtin_bswap16(val: u16) callconv(.C) u16 { return @byteSwap(u16, val); }9pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { return @byteSwap(u16, val); }
10pub inline fn __builtin_bswap32(val: u32) callconv(.C) u32 { return @byteSwap(u32, val); }10pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { return @byteSwap(u32, val); }
11pub inline fn __builtin_bswap64(val: u64) callconv(.C) u64 { return @byteSwap(u64, 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)); }13pub fn __builtin_signbit(val: f64) callconv(.Inline) 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)); }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 {
17 // popcount of a c_uint will never exceed the capacity of a c_int17 // popcount of a c_uint will never exceed the capacity of a c_int
18 @setRuntimeSafety(false);18 @setRuntimeSafety(false);
19 return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val)));19 return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val)));
20}20}
21pub inline fn __builtin_ctz(val: c_uint) callconv(.C) c_int {21pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int {
22 // Returns the number of trailing 0-bits in val, starting at the least significant bit position.22 // Returns the number of trailing 0-bits in val, starting at the least significant bit position.
23 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint23 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
24 @setRuntimeSafety(false);24 @setRuntimeSafety(false);
25 return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val)));25 return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val)));
26}26}
27pub inline fn __builtin_clz(val: c_uint) callconv(.C) c_int {27pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int {
28 // Returns the number of leading 0-bits in x, starting at the most significant bit position.28 // Returns the number of leading 0-bits in x, starting at the most significant bit position.
29 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint29 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
30 @setRuntimeSafety(false);30 @setRuntimeSafety(false);
31 return @bitCast(c_int, @as(c_uint, @clz(c_uint, val)));31 return @bitCast(c_int, @as(c_uint, @clz(c_uint, val)));
32}32}
3333
34pub inline fn __builtin_sqrt(val: f64) callconv(.C) f64 { return @sqrt(val); }34pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { return @sqrt(val); }
35pub inline fn __builtin_sqrtf(val: f32) callconv(.C) f32 { return @sqrt(val); }35pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { return @sqrt(val); }
3636
37pub inline fn __builtin_sin(val: f64) callconv(.C) f64 { return @sin(val); }37pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { return @sin(val); }
38pub inline fn __builtin_sinf(val: f32) callconv(.C) f32 { return @sin(val); }38pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { return @sin(val); }
39pub inline fn __builtin_cos(val: f64) callconv(.C) f64 { return @cos(val); }39pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { return @cos(val); }
40pub inline fn __builtin_cosf(val: f32) callconv(.C) f32 { return @cos(val); }40pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { return @cos(val); }
4141
42pub inline fn __builtin_exp(val: f64) callconv(.C) f64 { return @exp(val); }42pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { return @exp(val); }
43pub inline fn __builtin_expf(val: f32) callconv(.C) f32 { return @exp(val); }43pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { return @exp(val); }
44pub inline fn __builtin_exp2(val: f64) callconv(.C) f64 { return @exp2(val); }44pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { return @exp2(val); }
45pub inline fn __builtin_exp2f(val: f32) callconv(.C) f32 { return @exp2(val); }45pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { return @exp2(val); }
46pub inline fn __builtin_log(val: f64) callconv(.C) f64 { return @log(val); }46pub fn __builtin_log(val: f64) callconv(.Inline) f64 { return @log(val); }
47pub inline fn __builtin_logf(val: f32) callconv(.C) f32 { return @log(val); }47pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { return @log(val); }
48pub inline fn __builtin_log2(val: f64) callconv(.C) f64 { return @log2(val); }48pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { return @log2(val); }
49pub inline fn __builtin_log2f(val: f32) callconv(.C) f32 { return @log2(val); }49pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { return @log2(val); }
50pub inline fn __builtin_log10(val: f64) callconv(.C) f64 { return @log10(val); }50pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { return @log10(val); }
51pub inline fn __builtin_log10f(val: f32) callconv(.C) f32 { return @log10(val); }51pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { return @log10(val); }
5252
53// Standard C Library bug: The absolute value of the most negative integer remains negative.53// 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); }54pub fn __builtin_abs(val: c_int) callconv(.Inline) 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); }55pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { return @fabs(val); }
56pub inline fn __builtin_fabsf(val: f32) callconv(.C) f32 { return @fabs(val); }56pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { return @fabs(val); }
5757
58pub inline fn __builtin_floor(val: f64) callconv(.C) f64 { return @floor(val); }58pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { return @floor(val); }
59pub inline fn __builtin_floorf(val: f32) callconv(.C) f32 { return @floor(val); }59pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { return @floor(val); }
60pub inline fn __builtin_ceil(val: f64) callconv(.C) f64 { return @ceil(val); }60pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { return @ceil(val); }
61pub inline fn __builtin_ceilf(val: f32) callconv(.C) f32 { return @ceil(val); }61pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { return @ceil(val); }
62pub inline fn __builtin_trunc(val: f64) callconv(.C) f64 { return @trunc(val); }62pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { return @trunc(val); }
63pub inline fn __builtin_truncf(val: f32) callconv(.C) f32 { return @trunc(val); }63pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { return @trunc(val); }
64pub inline fn __builtin_round(val: f64) callconv(.C) f64 { return @round(val); }64pub fn __builtin_round(val: f64) callconv(.Inline) f64 { return @round(val); }
65pub inline fn __builtin_roundf(val: f32) callconv(.C) f32 { return @round(val); }65pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { return @round(val); }
6666
67pub inline fn __builtin_strlen(s: [*c]const u8) callconv(.C) usize { return std.mem.lenZ(s); }67pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { return std.mem.lenZ(s); }
68pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.C) c_int {68pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int {
69 return @as(c_int, std.cstr.cmp(s1, s2));69 return @as(c_int, std.cstr.cmp(s1, s2));
70}70}
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 {
73 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html73 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
74 // If it is not possible to determine which objects ptr points to at compile time,74 // If it is not possible to determine which objects ptr points to at compile time,
75 // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 075 // __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)...@@ -79,37 +79,37 @@ pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.C)
79 unreachable;79 unreachable;
80}80}
8181
82pub inline fn __builtin___memset_chk(82pub fn __builtin___memset_chk(
83 dst: ?*c_void,83 dst: ?*c_void,
84 val: c_int,84 val: c_int,
85 len: usize,85 len: usize,
86 remaining: usize,86 remaining: usize,
87) callconv(.C) ?*c_void {87) callconv(.Inline) ?*c_void {
88 if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining");88 if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining");
89 return __builtin_memset(dst, val, len);89 return __builtin_memset(dst, val, len);
90}90}
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 {
93 const dst_cast = @ptrCast([*c]u8, dst);93 const dst_cast = @ptrCast([*c]u8, dst);
94 @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len);94 @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len);
95 return dst;95 return dst;
96}96}
9797
98pub inline fn __builtin___memcpy_chk(98pub fn __builtin___memcpy_chk(
99 noalias dst: ?*c_void,99 noalias dst: ?*c_void,
100 noalias src: ?*const c_void,100 noalias src: ?*const c_void,
101 len: usize,101 len: usize,
102 remaining: usize,102 remaining: usize,
103) callconv(.C) ?*c_void {103) callconv(.Inline) ?*c_void {
104 if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining");104 if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining");
105 return __builtin_memcpy(dst, src, len);105 return __builtin_memcpy(dst, src, len);
106}106}
107107
108pub inline fn __builtin_memcpy(108pub fn __builtin_memcpy(
109 noalias dst: ?*c_void,109 noalias dst: ?*c_void,
110 noalias src: ?*const c_void,110 noalias src: ?*const c_void,
111 len: usize,111 len: usize,
112) callconv(.C) ?*c_void {112) callconv(.Inline) ?*c_void {
113 const dst_cast = @ptrCast([*c]u8, dst);113 const dst_cast = @ptrCast([*c]u8, dst);
114 const src_cast = @ptrCast([*c]const u8, src);114 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 {...@@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type {
209209
210 // Insert a single byte into the window.210 // Insert a single byte into the window.
211 // Assumes there's enough space.211 // Assumes there's enough space.
212 inline fn appendUnsafe(self: *WSelf, value: u8) void {212 fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void {
213 self.buf[self.wi] = value;213 self.buf[self.wi] = value;
214 self.wi = (self.wi + 1) & (self.buf.len - 1);214 self.wi = (self.wi + 1) & (self.buf.len - 1);
215 self.el += 1;215 self.el += 1;
lib/std/crypto/25519/curve25519.zig+2-2
...@@ -15,12 +15,12 @@ pub const Curve25519 = struct {...@@ -15,12 +15,12 @@ pub const Curve25519 = struct {
15 x: Fe,15 x: Fe,
1616
17 /// Decode a Curve25519 point from its compressed (X) coordinates.17 /// 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 {
19 return .{ .x = Fe.fromBytes(s) };19 return .{ .x = Fe.fromBytes(s) };
20 }20 }
2121
22 /// Encode a Curve25519 point.22 /// Encode a Curve25519 point.
23 pub inline fn toBytes(p: Curve25519) [32]u8 {23 pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 {
24 return p.x.toBytes();24 return p.x.toBytes();
25 }25 }
2626
lib/std/crypto/25519/edwards25519.zig+3-3
...@@ -92,7 +92,7 @@ pub const Edwards25519 = struct {...@@ -92,7 +92,7 @@ pub const Edwards25519 = struct {
92 }92 }
9393
94 /// Flip the sign of the X coordinate.94 /// Flip the sign of the X coordinate.
95 pub inline fn neg(p: Edwards25519) Edwards25519 {95 pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 {
96 return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() };96 return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() };
97 }97 }
9898
...@@ -137,14 +137,14 @@ pub const Edwards25519 = struct {...@@ -137,14 +137,14 @@ pub const Edwards25519 = struct {
137 return p.add(q.neg());137 return p.add(q.neg());
138 }138 }
139139
140 inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void {140 fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void {
141 p.x.cMov(a.x, c);141 p.x.cMov(a.x, c);
142 p.y.cMov(a.y, c);142 p.y.cMov(a.y, c);
143 p.z.cMov(a.z, c);143 p.z.cMov(a.z, c);
144 p.t.cMov(a.t, c);144 p.t.cMov(a.t, c);
145 }145 }
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 {
148 var t = Edwards25519.identityElement;148 var t = Edwards25519.identityElement;
149 comptime var i: u8 = 1;149 comptime var i: u8 = 1;
150 inline while (i < pc.len) : (i += 1) {150 inline while (i < pc.len) : (i += 1) {
lib/std/crypto/25519/field.zig+14-14
...@@ -52,7 +52,7 @@ pub const Fe = struct {...@@ -52,7 +52,7 @@ pub const Fe = struct {
52 pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } };52 pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } };
5353
54 /// Return true if the field element is zero54 /// 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 {
56 var reduced = fe;56 var reduced = fe;
57 reduced.reduce();57 reduced.reduce();
58 const limbs = reduced.limbs;58 const limbs = reduced.limbs;
...@@ -60,7 +60,7 @@ pub const Fe = struct {...@@ -60,7 +60,7 @@ pub const Fe = struct {
60 }60 }
6161
62 /// Return true if both field elements are equivalent62 /// 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 {
64 return a.sub(b).isZero();64 return a.sub(b).isZero();
65 }65 }
6666
...@@ -164,7 +164,7 @@ pub const Fe = struct {...@@ -164,7 +164,7 @@ pub const Fe = struct {
164 }164 }
165165
166 /// Add a field element166 /// 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 {
168 var fe: Fe = undefined;168 var fe: Fe = undefined;
169 comptime var i = 0;169 comptime var i = 0;
170 inline while (i < 5) : (i += 1) {170 inline while (i < 5) : (i += 1) {
...@@ -174,7 +174,7 @@ pub const Fe = struct {...@@ -174,7 +174,7 @@ pub const Fe = struct {
174 }174 }
175175
176 /// Substract a field elememnt176 /// 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 {
178 var fe = b;178 var fe = b;
179 comptime var i = 0;179 comptime var i = 0;
180 inline while (i < 4) : (i += 1) {180 inline while (i < 4) : (i += 1) {
...@@ -193,17 +193,17 @@ pub const Fe = struct {...@@ -193,17 +193,17 @@ pub const Fe = struct {
193 }193 }
194194
195 /// Negate a field element195 /// Negate a field element
196 pub inline fn neg(a: Fe) Fe {196 pub fn neg(a: Fe) callconv(.Inline) Fe {
197 return zero.sub(a);197 return zero.sub(a);
198 }198 }
199199
200 /// Return true if a field element is negative200 /// 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 {
202 return (a.toBytes()[0] & 1) != 0;202 return (a.toBytes()[0] & 1) != 0;
203 }203 }
204204
205 /// Conditonally replace a field element with `a` if `c` is positive205 /// 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 {
207 const mask: u64 = 0 -% c;207 const mask: u64 = 0 -% c;
208 var x = fe.*;208 var x = fe.*;
209 comptime var i = 0;209 comptime var i = 0;
...@@ -244,7 +244,7 @@ pub const Fe = struct {...@@ -244,7 +244,7 @@ pub const Fe = struct {
244 }244 }
245 }245 }
246246
247 inline fn _carry128(r: *[5]u128) Fe {247 fn _carry128(r: *[5]u128) callconv(.Inline) Fe {
248 var rs: [5]u64 = undefined;248 var rs: [5]u64 = undefined;
249 comptime var i = 0;249 comptime var i = 0;
250 inline while (i < 4) : (i += 1) {250 inline while (i < 4) : (i += 1) {
...@@ -265,7 +265,7 @@ pub const Fe = struct {...@@ -265,7 +265,7 @@ pub const Fe = struct {
265 }265 }
266266
267 /// Multiply two field elements267 /// 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 {
269 var ax: [5]u128 = undefined;269 var ax: [5]u128 = undefined;
270 var bx: [5]u128 = undefined;270 var bx: [5]u128 = undefined;
271 var a19: [5]u128 = undefined;271 var a19: [5]u128 = undefined;
...@@ -288,7 +288,7 @@ pub const Fe = struct {...@@ -288,7 +288,7 @@ pub const Fe = struct {
288 return _carry128(&r);288 return _carry128(&r);
289 }289 }
290290
291 inline fn _sq(a: Fe, double: comptime bool) Fe {291 fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe {
292 var ax: [5]u128 = undefined;292 var ax: [5]u128 = undefined;
293 var r: [5]u128 = undefined;293 var r: [5]u128 = undefined;
294 comptime var i = 0;294 comptime var i = 0;
...@@ -317,17 +317,17 @@ pub const Fe = struct {...@@ -317,17 +317,17 @@ pub const Fe = struct {
317 }317 }
318318
319 /// Square a field element319 /// Square a field element
320 pub inline fn sq(a: Fe) Fe {320 pub fn sq(a: Fe) callconv(.Inline) Fe {
321 return _sq(a, false);321 return _sq(a, false);
322 }322 }
323323
324 /// Square and double a field element324 /// Square and double a field element
325 pub inline fn sq2(a: Fe) Fe {325 pub fn sq2(a: Fe) callconv(.Inline) Fe {
326 return _sq(a, true);326 return _sq(a, true);
327 }327 }
328328
329 /// Multiply a field element with a small (32-bit) integer329 /// 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 {
331 const sn = @intCast(u128, n);331 const sn = @intCast(u128, n);
332 var fe: Fe = undefined;332 var fe: Fe = undefined;
333 var x: u128 = 0;333 var x: u128 = 0;
...@@ -342,7 +342,7 @@ pub const Fe = struct {...@@ -342,7 +342,7 @@ pub const Fe = struct {
342 }342 }
343343
344 /// Square a field element `n` times344 /// 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 {
346 var i: usize = 0;346 var i: usize = 0;
347 var fe = a;347 var fe = a;
348 while (i < n) : (i += 1) {348 while (i < n) : (i += 1) {
lib/std/crypto/25519/ristretto255.zig+4-4
...@@ -42,7 +42,7 @@ pub const Ristretto255 = struct {...@@ -42,7 +42,7 @@ pub const Ristretto255 = struct {
42 }42 }
4343
44 /// Reject the neutral element.44 /// Reject the neutral element.
45 pub inline fn rejectIdentity(p: Ristretto255) !void {45 pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) !void {
46 return p.p.rejectIdentity();46 return p.p.rejectIdentity();
47 }47 }
4848
...@@ -141,19 +141,19 @@ pub const Ristretto255 = struct {...@@ -141,19 +141,19 @@ pub const Ristretto255 = struct {
141 }141 }
142142
143 /// Double a Ristretto255 element.143 /// Double a Ristretto255 element.
144 pub inline fn dbl(p: Ristretto255) Ristretto255 {144 pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 {
145 return .{ .p = p.p.dbl() };145 return .{ .p = p.p.dbl() };
146 }146 }
147147
148 /// Add two Ristretto255 elements.148 /// 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 {
150 return .{ .p = p.p.add(q.p) };150 return .{ .p = p.p.add(q.p) };
151 }151 }
152152
153 /// Multiply a Ristretto255 element with a scalar.153 /// Multiply a Ristretto255 element with a scalar.
154 /// Return error.WeakPublicKey if the resulting element is154 /// Return error.WeakPublicKey if the resulting element is
155 /// the identity element.155 /// 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 {
157 return Ristretto255{ .p = try p.p.mul(s) };157 return Ristretto255{ .p = try p.p.mul(s) };
158 }158 }
159159
lib/std/crypto/25519/scalar.zig+1-1
...@@ -46,7 +46,7 @@ pub fn reduce64(s: [64]u8) [32]u8 {...@@ -46,7 +46,7 @@ pub fn reduce64(s: [64]u8) [32]u8 {
4646
47/// Perform the X25519 "clamping" operation.47/// Perform the X25519 "clamping" operation.
48/// The scalar is then guaranteed to be a multiple of the cofactor.48/// 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 {
50 s[0] &= 248;50 s[0] &= 248;
51 s[31] = (s[31] & 127) | 64;51 s[31] = (s[31] & 127) | 64;
52}52}
lib/std/crypto/aegis.zig+2-2
...@@ -35,7 +35,7 @@ const State128L = struct {...@@ -35,7 +35,7 @@ const State128L = struct {
35 return state;35 return state;
36 }36 }
3737
38 inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void {38 fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void {
39 const blocks = &state.blocks;39 const blocks = &state.blocks;
40 const tmp = blocks[7];40 const tmp = blocks[7];
41 comptime var i: usize = 7;41 comptime var i: usize = 7;
...@@ -207,7 +207,7 @@ const State256 = struct {...@@ -207,7 +207,7 @@ const State256 = struct {
207 return state;207 return state;
208 }208 }
209209
210 inline fn update(state: *State256, d: AesBlock) void {210 fn update(state: *State256, d: AesBlock) callconv(.Inline) void {
211 const blocks = &state.blocks;211 const blocks = &state.blocks;
212 const tmp = blocks[5].encrypt(blocks[0]);212 const tmp = blocks[5].encrypt(blocks[0]);
213 comptime var i: usize = 5;213 comptime var i: usize = 5;
lib/std/crypto/aes/aesni.zig+16-16
...@@ -19,24 +19,24 @@ pub const Block = struct {...@@ -19,24 +19,24 @@ pub const Block = struct {
19 repr: BlockVec,19 repr: BlockVec,
2020
21 /// Convert a byte sequence into an internal representation.21 /// 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 {
23 const repr = mem.bytesToValue(BlockVec, bytes);23 const repr = mem.bytesToValue(BlockVec, bytes);
24 return Block{ .repr = repr };24 return Block{ .repr = repr };
25 }25 }
2626
27 /// Convert the internal representation of a block into a byte sequence.27 /// 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 {
29 return mem.toBytes(block.repr);29 return mem.toBytes(block.repr);
30 }30 }
3131
32 /// XOR the block with a byte sequence.32 /// 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 {
34 const x = block.repr ^ fromBytes(bytes).repr;34 const x = block.repr ^ fromBytes(bytes).repr;
35 return mem.toBytes(x);35 return mem.toBytes(x);
36 }36 }
3737
38 /// Encrypt a block with a round key.38 /// 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 {
40 return Block{40 return Block{
41 .repr = asm (41 .repr = asm (
42 \\ vaesenc %[rk], %[in], %[out]42 \\ vaesenc %[rk], %[in], %[out]
...@@ -48,7 +48,7 @@ pub const Block = struct {...@@ -48,7 +48,7 @@ pub const Block = struct {
48 }48 }
4949
50 /// Encrypt a block with the last round key.50 /// 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 {
52 return Block{52 return Block{
53 .repr = asm (53 .repr = asm (
54 \\ vaesenclast %[rk], %[in], %[out]54 \\ vaesenclast %[rk], %[in], %[out]
...@@ -60,7 +60,7 @@ pub const Block = struct {...@@ -60,7 +60,7 @@ pub const Block = struct {
60 }60 }
6161
62 /// Decrypt a block with a round key.62 /// 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 {
64 return Block{64 return Block{
65 .repr = asm (65 .repr = asm (
66 \\ vaesdec %[rk], %[in], %[out]66 \\ vaesdec %[rk], %[in], %[out]
...@@ -72,7 +72,7 @@ pub const Block = struct {...@@ -72,7 +72,7 @@ pub const Block = struct {
72 }72 }
7373
74 /// Decrypt a block with the last round key.74 /// 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 {
76 return Block{76 return Block{
77 .repr = asm (77 .repr = asm (
78 \\ vaesdeclast %[rk], %[in], %[out]78 \\ vaesdeclast %[rk], %[in], %[out]
...@@ -84,17 +84,17 @@ pub const Block = struct {...@@ -84,17 +84,17 @@ pub const Block = struct {
84 }84 }
8585
86 /// Apply the bitwise XOR operation to the content of two blocks.86 /// 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 {
88 return Block{ .repr = block1.repr ^ block2.repr };88 return Block{ .repr = block1.repr ^ block2.repr };
89 }89 }
9090
91 /// Apply the bitwise AND operation to the content of two blocks.91 /// 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 {
93 return Block{ .repr = block1.repr & block2.repr };93 return Block{ .repr = block1.repr & block2.repr };
94 }94 }
9595
96 /// Apply the bitwise OR operation to the content of two blocks.96 /// 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 {
98 return Block{ .repr = block1.repr | block2.repr };98 return Block{ .repr = block1.repr | block2.repr };
99 }99 }
100100
...@@ -114,7 +114,7 @@ pub const Block = struct {...@@ -114,7 +114,7 @@ pub const Block = struct {
114 };114 };
115115
116 /// Encrypt multiple blocks in parallel, each their own round key.116 /// 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 {
118 comptime var i = 0;118 comptime var i = 0;
119 var out: [count]Block = undefined;119 var out: [count]Block = undefined;
120 inline while (i < count) : (i += 1) {120 inline while (i < count) : (i += 1) {
...@@ -124,7 +124,7 @@ pub const Block = struct {...@@ -124,7 +124,7 @@ pub const Block = struct {
124 }124 }
125125
126 /// Decrypt multiple blocks in parallel, each their own round key.126 /// 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 {
128 comptime var i = 0;128 comptime var i = 0;
129 var out: [count]Block = undefined;129 var out: [count]Block = undefined;
130 inline while (i < count) : (i += 1) {130 inline while (i < count) : (i += 1) {
...@@ -134,7 +134,7 @@ pub const Block = struct {...@@ -134,7 +134,7 @@ pub const Block = struct {
134 }134 }
135135
136 /// Encrypt multiple blocks in parallel with the same round key.136 /// 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 {
138 comptime var i = 0;138 comptime var i = 0;
139 var out: [count]Block = undefined;139 var out: [count]Block = undefined;
140 inline while (i < count) : (i += 1) {140 inline while (i < count) : (i += 1) {
...@@ -144,7 +144,7 @@ pub const Block = struct {...@@ -144,7 +144,7 @@ pub const Block = struct {
144 }144 }
145145
146 /// Decrypt multiple blocks in parallel with the same round key.146 /// 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 {
148 comptime var i = 0;148 comptime var i = 0;
149 var out: [count]Block = undefined;149 var out: [count]Block = undefined;
150 inline while (i < count) : (i += 1) {150 inline while (i < count) : (i += 1) {
...@@ -154,7 +154,7 @@ pub const Block = struct {...@@ -154,7 +154,7 @@ pub const Block = struct {
154 }154 }
155155
156 /// Encrypt multiple blocks in parallel with the same last round key.156 /// 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 {
158 comptime var i = 0;158 comptime var i = 0;
159 var out: [count]Block = undefined;159 var out: [count]Block = undefined;
160 inline while (i < count) : (i += 1) {160 inline while (i < count) : (i += 1) {
...@@ -164,7 +164,7 @@ pub const Block = struct {...@@ -164,7 +164,7 @@ pub const Block = struct {
164 }164 }
165165
166 /// Decrypt multiple blocks in parallel with the same last round key.166 /// 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 {
168 comptime var i = 0;168 comptime var i = 0;
169 var out: [count]Block = undefined;169 var out: [count]Block = undefined;
170 inline while (i < count) : (i += 1) {170 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/armcrypto.zig+16-16
...@@ -19,18 +19,18 @@ pub const Block = struct {...@@ -19,18 +19,18 @@ pub const Block = struct {
19 repr: BlockVec,19 repr: BlockVec,
2020
21 /// Convert a byte sequence into an internal representation.21 /// 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 {
23 const repr = mem.bytesToValue(BlockVec, bytes);23 const repr = mem.bytesToValue(BlockVec, bytes);
24 return Block{ .repr = repr };24 return Block{ .repr = repr };
25 }25 }
2626
27 /// Convert the internal representation of a block into a byte sequence.27 /// 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 {
29 return mem.toBytes(block.repr);29 return mem.toBytes(block.repr);
30 }30 }
3131
32 /// XOR the block with a byte sequence.32 /// 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 {
34 const x = block.repr ^ fromBytes(bytes).repr;34 const x = block.repr ^ fromBytes(bytes).repr;
35 return mem.toBytes(x);35 return mem.toBytes(x);
36 }36 }
...@@ -38,7 +38,7 @@ pub const Block = struct {...@@ -38,7 +38,7 @@ pub const Block = struct {
38 const zero = Vector(2, u64){ 0, 0 };38 const zero = Vector(2, u64){ 0, 0 };
3939
40 /// Encrypt a block with a round key.40 /// 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 {
42 return Block{42 return Block{
43 .repr = asm (43 .repr = asm (
44 \\ mov %[out].16b, %[in].16b44 \\ mov %[out].16b, %[in].16b
...@@ -54,7 +54,7 @@ pub const Block = struct {...@@ -54,7 +54,7 @@ pub const Block = struct {
54 }54 }
5555
56 /// Encrypt a block with the last round key.56 /// 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 {
58 return Block{58 return Block{
59 .repr = asm (59 .repr = asm (
60 \\ mov %[out].16b, %[in].16b60 \\ mov %[out].16b, %[in].16b
...@@ -69,7 +69,7 @@ pub const Block = struct {...@@ -69,7 +69,7 @@ pub const Block = struct {
69 }69 }
7070
71 /// Decrypt a block with a round key.71 /// 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 {
73 return Block{73 return Block{
74 .repr = asm (74 .repr = asm (
75 \\ mov %[out].16b, %[in].16b75 \\ mov %[out].16b, %[in].16b
...@@ -85,7 +85,7 @@ pub const Block = struct {...@@ -85,7 +85,7 @@ pub const Block = struct {
85 }85 }
8686
87 /// Decrypt a block with the last round key.87 /// 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 {
89 return Block{89 return Block{
90 .repr = asm (90 .repr = asm (
91 \\ mov %[out].16b, %[in].16b91 \\ mov %[out].16b, %[in].16b
...@@ -100,17 +100,17 @@ pub const Block = struct {...@@ -100,17 +100,17 @@ pub const Block = struct {
100 }100 }
101101
102 /// Apply the bitwise XOR operation to the content of two blocks.102 /// 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 {
104 return Block{ .repr = block1.repr ^ block2.repr };104 return Block{ .repr = block1.repr ^ block2.repr };
105 }105 }
106106
107 /// Apply the bitwise AND operation to the content of two blocks.107 /// 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 {
109 return Block{ .repr = block1.repr & block2.repr };109 return Block{ .repr = block1.repr & block2.repr };
110 }110 }
111111
112 /// Apply the bitwise OR operation to the content of two blocks.112 /// 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 {
114 return Block{ .repr = block1.repr | block2.repr };114 return Block{ .repr = block1.repr | block2.repr };
115 }115 }
116116
...@@ -120,7 +120,7 @@ pub const Block = struct {...@@ -120,7 +120,7 @@ pub const Block = struct {
120 pub const optimal_parallel_blocks = 8;120 pub const optimal_parallel_blocks = 8;
121121
122 /// Encrypt multiple blocks in parallel, each their own round key.122 /// 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 {
124 comptime var i = 0;124 comptime var i = 0;
125 var out: [count]Block = undefined;125 var out: [count]Block = undefined;
126 inline while (i < count) : (i += 1) {126 inline while (i < count) : (i += 1) {
...@@ -130,7 +130,7 @@ pub const Block = struct {...@@ -130,7 +130,7 @@ pub const Block = struct {
130 }130 }
131131
132 /// Decrypt multiple blocks in parallel, each their own round key.132 /// 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 {
134 comptime var i = 0;134 comptime var i = 0;
135 var out: [count]Block = undefined;135 var out: [count]Block = undefined;
136 inline while (i < count) : (i += 1) {136 inline while (i < count) : (i += 1) {
...@@ -140,7 +140,7 @@ pub const Block = struct {...@@ -140,7 +140,7 @@ pub const Block = struct {
140 }140 }
141141
142 /// Encrypt multiple blocks in parallel with the same round key.142 /// 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 {
144 comptime var i = 0;144 comptime var i = 0;
145 var out: [count]Block = undefined;145 var out: [count]Block = undefined;
146 inline while (i < count) : (i += 1) {146 inline while (i < count) : (i += 1) {
...@@ -150,7 +150,7 @@ pub const Block = struct {...@@ -150,7 +150,7 @@ pub const Block = struct {
150 }150 }
151151
152 /// Decrypt multiple blocks in parallel with the same round key.152 /// 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 {
154 comptime var i = 0;154 comptime var i = 0;
155 var out: [count]Block = undefined;155 var out: [count]Block = undefined;
156 inline while (i < count) : (i += 1) {156 inline while (i < count) : (i += 1) {
...@@ -160,7 +160,7 @@ pub const Block = struct {...@@ -160,7 +160,7 @@ pub const Block = struct {
160 }160 }
161161
162 /// Encrypt multiple blocks in parallel with the same last round key.162 /// 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 {
164 comptime var i = 0;164 comptime var i = 0;
165 var out: [count]Block = undefined;165 var out: [count]Block = undefined;
166 inline while (i < count) : (i += 1) {166 inline while (i < count) : (i += 1) {
...@@ -170,7 +170,7 @@ pub const Block = struct {...@@ -170,7 +170,7 @@ pub const Block = struct {
170 }170 }
171171
172 /// Decrypt multiple blocks in parallel with the same last round key.172 /// 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 {
174 comptime var i = 0;174 comptime var i = 0;
175 var out: [count]Block = undefined;175 var out: [count]Block = undefined;
176 inline while (i < count) : (i += 1) {176 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/soft.zig+10-10
...@@ -18,7 +18,7 @@ pub const Block = struct {...@@ -18,7 +18,7 @@ pub const Block = struct {
18 repr: BlockVec align(16),18 repr: BlockVec align(16),
1919
20 /// Convert a byte sequence into an internal representation.20 /// 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 {
22 const s0 = mem.readIntBig(u32, bytes[0..4]);22 const s0 = mem.readIntBig(u32, bytes[0..4]);
23 const s1 = mem.readIntBig(u32, bytes[4..8]);23 const s1 = mem.readIntBig(u32, bytes[4..8]);
24 const s2 = mem.readIntBig(u32, bytes[8..12]);24 const s2 = mem.readIntBig(u32, bytes[8..12]);
...@@ -27,7 +27,7 @@ pub const Block = struct {...@@ -27,7 +27,7 @@ pub const Block = struct {
27 }27 }
2828
29 /// Convert the internal representation of a block into a byte sequence.29 /// 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 {
31 var bytes: [16]u8 = undefined;31 var bytes: [16]u8 = undefined;
32 mem.writeIntBig(u32, bytes[0..4], block.repr[0]);32 mem.writeIntBig(u32, bytes[0..4], block.repr[0]);
33 mem.writeIntBig(u32, bytes[4..8], block.repr[1]);33 mem.writeIntBig(u32, bytes[4..8], block.repr[1]);
...@@ -37,7 +37,7 @@ pub const Block = struct {...@@ -37,7 +37,7 @@ pub const Block = struct {
37 }37 }
3838
39 /// XOR the block with a byte sequence.39 /// 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 {
41 const block_bytes = block.toBytes();41 const block_bytes = block.toBytes();
42 var x: [16]u8 = undefined;42 var x: [16]u8 = undefined;
43 comptime var i: usize = 0;43 comptime var i: usize = 0;
...@@ -48,7 +48,7 @@ pub const Block = struct {...@@ -48,7 +48,7 @@ pub const Block = struct {
48 }48 }
4949
50 /// Encrypt a block with a round key.50 /// 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 {
52 const src = &block.repr;52 const src = &block.repr;
5353
54 const s0 = block.repr[0];54 const s0 = block.repr[0];
...@@ -65,7 +65,7 @@ pub const Block = struct {...@@ -65,7 +65,7 @@ pub const Block = struct {
65 }65 }
6666
67 /// Encrypt a block with the last round key.67 /// 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 {
69 const src = &block.repr;69 const src = &block.repr;
7070
71 const t0 = block.repr[0];71 const t0 = block.repr[0];
...@@ -87,7 +87,7 @@ pub const Block = struct {...@@ -87,7 +87,7 @@ pub const Block = struct {
87 }87 }
8888
89 /// Decrypt a block with a round key.89 /// 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 {
91 const src = &block.repr;91 const src = &block.repr;
9292
93 const s0 = block.repr[0];93 const s0 = block.repr[0];
...@@ -104,7 +104,7 @@ pub const Block = struct {...@@ -104,7 +104,7 @@ pub const Block = struct {
104 }104 }
105105
106 /// Decrypt a block with the last round key.106 /// 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 {
108 const src = &block.repr;108 const src = &block.repr;
109109
110 const t0 = block.repr[0];110 const t0 = block.repr[0];
...@@ -126,7 +126,7 @@ pub const Block = struct {...@@ -126,7 +126,7 @@ pub const Block = struct {
126 }126 }
127127
128 /// Apply the bitwise XOR operation to the content of two blocks.128 /// 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 {
130 var x: BlockVec = undefined;130 var x: BlockVec = undefined;
131 comptime var i = 0;131 comptime var i = 0;
132 inline while (i < 4) : (i += 1) {132 inline while (i < 4) : (i += 1) {
...@@ -136,7 +136,7 @@ pub const Block = struct {...@@ -136,7 +136,7 @@ pub const Block = struct {
136 }136 }
137137
138 /// Apply the bitwise AND operation to the content of two blocks.138 /// 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 {
140 var x: BlockVec = undefined;140 var x: BlockVec = undefined;
141 comptime var i = 0;141 comptime var i = 0;
142 inline while (i < 4) : (i += 1) {142 inline while (i < 4) : (i += 1) {
...@@ -146,7 +146,7 @@ pub const Block = struct {...@@ -146,7 +146,7 @@ pub const Block = struct {
146 }146 }
147147
148 /// Apply the bitwise OR operation to the content of two blocks.148 /// 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 {
150 var x: BlockVec = undefined;150 var x: BlockVec = undefined;
151 comptime var i = 0;151 comptime var i = 0;
152 inline while (i < 4) : (i += 1) {152 inline while (i < 4) : (i += 1) {
lib/std/crypto/blake3.zig+3-3
...@@ -66,7 +66,7 @@ const CompressVectorized = struct {...@@ -66,7 +66,7 @@ const CompressVectorized = struct {
66 const Lane = Vector(4, u32);66 const Lane = Vector(4, u32);
67 const Rows = [4]Lane;67 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 {
70 rows[0] +%= rows[1] +% m;70 rows[0] +%= rows[1] +% m;
71 rows[3] ^= rows[0];71 rows[3] ^= rows[0];
72 rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16);72 rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16);
...@@ -75,13 +75,13 @@ const CompressVectorized = struct {...@@ -75,13 +75,13 @@ const CompressVectorized = struct {
75 rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12);75 rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12);
76 }76 }
7777
78 inline fn diagonalize(rows: *Rows) void {78 fn diagonalize(rows: *Rows) callconv(.Inline) void {
79 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 });79 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 });
80 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });80 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
81 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 });81 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 });
82 }82 }
8383
84 inline fn undiagonalize(rows: *Rows) void {84 fn undiagonalize(rows: *Rows) callconv(.Inline) void {
85 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 });85 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 });
86 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });86 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
87 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 });87 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 {...@@ -35,7 +35,7 @@ const ChaCha20VecImpl = struct {
35 };35 };
36 }36 }
3737
38 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {38 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
39 x.* = input;39 x.* = input;
4040
41 var r: usize = 0;41 var r: usize = 0;
...@@ -80,7 +80,7 @@ const ChaCha20VecImpl = struct {...@@ -80,7 +80,7 @@ const ChaCha20VecImpl = struct {
80 }80 }
81 }81 }
8282
83 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {83 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
84 var i: usize = 0;84 var i: usize = 0;
85 while (i < 4) : (i += 1) {85 while (i < 4) : (i += 1) {
86 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);86 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);
...@@ -90,7 +90,7 @@ const ChaCha20VecImpl = struct {...@@ -90,7 +90,7 @@ const ChaCha20VecImpl = struct {
90 }90 }
91 }91 }
9292
93 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {93 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
94 x[0] +%= ctx[0];94 x[0] +%= ctx[0];
95 x[1] +%= ctx[1];95 x[1] +%= ctx[1];
96 x[2] +%= ctx[2];96 x[2] +%= ctx[2];
...@@ -190,7 +190,7 @@ const ChaCha20NonVecImpl = struct {...@@ -190,7 +190,7 @@ const ChaCha20NonVecImpl = struct {
190 };190 };
191 }191 }
192192
193 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {193 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
194 x.* = input;194 x.* = input;
195195
196 const rounds = comptime [_]QuarterRound{196 const rounds = comptime [_]QuarterRound{
...@@ -219,7 +219,7 @@ const ChaCha20NonVecImpl = struct {...@@ -219,7 +219,7 @@ const ChaCha20NonVecImpl = struct {
219 }219 }
220 }220 }
221221
222 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {222 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
223 var i: usize = 0;223 var i: usize = 0;
224 while (i < 4) : (i += 1) {224 while (i < 4) : (i += 1) {
225 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]);225 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]);
...@@ -229,7 +229,7 @@ const ChaCha20NonVecImpl = struct {...@@ -229,7 +229,7 @@ const ChaCha20NonVecImpl = struct {
229 }229 }
230 }230 }
231231
232 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {232 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
233 var i: usize = 0;233 var i: usize = 0;
234 while (i < 16) : (i += 1) {234 while (i < 16) : (i += 1) {
235 x[i] +%= ctx[i];235 x[i] +%= ctx[i];
lib/std/crypto/ghash.zig+2-2
...@@ -95,7 +95,7 @@ pub const Ghash = struct {...@@ -95,7 +95,7 @@ pub const Ghash = struct {
95 }95 }
96 }96 }
9797
98 inline fn clmul_pclmul(x: u64, y: u64) u64 {98 fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 {
99 const Vector = std.meta.Vector;99 const Vector = std.meta.Vector;
100 const product = asm (100 const product = asm (
101 \\ vpclmulqdq $0x00, %[x], %[y], %[out]101 \\ vpclmulqdq $0x00, %[x], %[y], %[out]
...@@ -106,7 +106,7 @@ pub const Ghash = struct {...@@ -106,7 +106,7 @@ pub const Ghash = struct {
106 return product[0];106 return product[0];
107 }107 }
108108
109 inline fn clmul_pmull(x: u64, y: u64) u64 {109 fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 {
110 const Vector = std.meta.Vector;110 const Vector = std.meta.Vector;
111 const product = asm (111 const product = asm (
112 \\ pmull %[out].1q, %[x].1d, %[y].1d112 \\ pmull %[out].1q, %[x].1d, %[y].1d
lib/std/crypto/gimli.zig+2-2
...@@ -48,7 +48,7 @@ pub const State = struct {...@@ -48,7 +48,7 @@ pub const State = struct {
48 return mem.asBytes(&self.data);48 return mem.asBytes(&self.data);
49 }49 }
5050
51 inline fn endianSwap(self: *Self) void {51 fn endianSwap(self: *Self) callconv(.Inline) void {
52 for (self.data) |*w| {52 for (self.data) |*w| {
53 w.* = mem.littleToNative(u32, w.*);53 w.* = mem.littleToNative(u32, w.*);
54 }54 }
...@@ -116,7 +116,7 @@ pub const State = struct {...@@ -116,7 +116,7 @@ pub const State = struct {
116116
117 const Lane = Vector(4, u32);117 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 {
120 return x << @splat(4, @as(u5, n));120 return x << @splat(4, @as(u5, n));
121 }121 }
122122
lib/std/crypto/salsa20.zig+3-3
...@@ -37,7 +37,7 @@ const Salsa20VecImpl = struct {...@@ -37,7 +37,7 @@ const Salsa20VecImpl = struct {
37 };37 };
38 }38 }
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 {
41 const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] };41 const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] };
42 const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] };42 const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] };
43 const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] };43 const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] };
...@@ -211,7 +211,7 @@ const Salsa20NonVecImpl = struct {...@@ -211,7 +211,7 @@ const Salsa20NonVecImpl = struct {
211 d: u6,211 d: u6,
212 };212 };
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 {
215 return QuarterRound{215 return QuarterRound{
216 .a = a,216 .a = a,
217 .b = b,217 .b = b,
...@@ -220,7 +220,7 @@ const Salsa20NonVecImpl = struct {...@@ -220,7 +220,7 @@ const Salsa20NonVecImpl = struct {
220 };220 };
221 }221 }
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 {
224 const arx_steps = comptime [_]QuarterRound{224 const arx_steps = comptime [_]QuarterRound{
225 Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18),225 Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18),
226 Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18),226 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 {...@@ -720,10 +720,10 @@ pub const Elf32_Rel = extern struct {
720 r_offset: Elf32_Addr,720 r_offset: Elf32_Addr,
721 r_info: Elf32_Word,721 r_info: Elf32_Word,
722722
723 pub inline fn r_sym(self: @This()) u24 {723 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
724 return @truncate(u24, self.r_info >> 8);724 return @truncate(u24, self.r_info >> 8);
725 }725 }
726 pub inline fn r_type(self: @This()) u8 {726 pub fn r_type(self: @This()) callconv(.Inline) u8 {
727 return @truncate(u8, self.r_info & 0xff);727 return @truncate(u8, self.r_info & 0xff);
728 }728 }
729};729};
...@@ -731,10 +731,10 @@ pub const Elf64_Rel = extern struct {...@@ -731,10 +731,10 @@ pub const Elf64_Rel = extern struct {
731 r_offset: Elf64_Addr,731 r_offset: Elf64_Addr,
732 r_info: Elf64_Xword,732 r_info: Elf64_Xword,
733733
734 pub inline fn r_sym(self: @This()) u32 {734 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
735 return @truncate(u32, self.r_info >> 32);735 return @truncate(u32, self.r_info >> 32);
736 }736 }
737 pub inline fn r_type(self: @This()) u32 {737 pub fn r_type(self: @This()) callconv(.Inline) u32 {
738 return @truncate(u32, self.r_info & 0xffffffff);738 return @truncate(u32, self.r_info & 0xffffffff);
739 }739 }
740};740};
...@@ -743,10 +743,10 @@ pub const Elf32_Rela = extern struct {...@@ -743,10 +743,10 @@ pub const Elf32_Rela = extern struct {
743 r_info: Elf32_Word,743 r_info: Elf32_Word,
744 r_addend: Elf32_Sword,744 r_addend: Elf32_Sword,
745745
746 pub inline fn r_sym(self: @This()) u24 {746 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
747 return @truncate(u24, self.r_info >> 8);747 return @truncate(u24, self.r_info >> 8);
748 }748 }
749 pub inline fn r_type(self: @This()) u8 {749 pub fn r_type(self: @This()) callconv(.Inline) u8 {
750 return @truncate(u8, self.r_info & 0xff);750 return @truncate(u8, self.r_info & 0xff);
751 }751 }
752};752};
...@@ -755,10 +755,10 @@ pub const Elf64_Rela = extern struct {...@@ -755,10 +755,10 @@ pub const Elf64_Rela = extern struct {
755 r_info: Elf64_Xword,755 r_info: Elf64_Xword,
756 r_addend: Elf64_Sxword,756 r_addend: Elf64_Sxword,
757757
758 pub inline fn r_sym(self: @This()) u32 {758 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
759 return @truncate(u32, self.r_info >> 32);759 return @truncate(u32, self.r_info >> 32);
760 }760 }
761 pub inline fn r_type(self: @This()) u32 {761 pub fn r_type(self: @This()) callconv(.Inline) u32 {
762 return @truncate(u32, self.r_info & 0xffffffff);762 return @truncate(u32, self.r_info & 0xffffffff);
763 }763 }
764};764};
lib/std/fmt/parse_float.zig+4-4
...@@ -52,21 +52,21 @@ const Z96 = struct {...@@ -52,21 +52,21 @@ const Z96 = struct {
52 d2: u32,52 d2: u32,
5353
54 // d = s >> 154 // d = s >> 1
55 inline fn shiftRight1(d: *Z96, s: Z96) void {55 fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void {
56 d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31);56 d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31);
57 d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31);57 d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31);
58 d.d2 = s.d2 >> 1;58 d.d2 = s.d2 >> 1;
59 }59 }
6060
61 // d = s << 161 // d = s << 1
62 inline fn shiftLeft1(d: *Z96, s: Z96) void {62 fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void {
63 d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31);63 d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31);
64 d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31);64 d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31);
65 d.d0 = s.d0 << 1;65 d.d0 = s.d0 << 1;
66 }66 }
6767
68 // d += s68 // d += s
69 inline fn add(d: *Z96, s: Z96) void {69 fn add(d: *Z96, s: Z96) callconv(.Inline) void {
70 var w = @as(u64, d.d0) + @as(u64, s.d0);70 var w = @as(u64, d.d0) + @as(u64, s.d0);
71 d.d0 = @truncate(u32, w);71 d.d0 = @truncate(u32, w);
7272
...@@ -80,7 +80,7 @@ const Z96 = struct {...@@ -80,7 +80,7 @@ const Z96 = struct {
80 }80 }
8181
82 // d -= s82 // d -= s
83 inline fn sub(d: *Z96, s: Z96) void {83 fn sub(d: *Z96, s: Z96) callconv(.Inline) void {
84 var w = @as(u64, d.d0) -% @as(u64, s.d0);84 var w = @as(u64, d.d0) -% @as(u64, s.d0);
85 d.d0 = @truncate(u32, w);85 d.d0 = @truncate(u32, w);
8686
lib/std/hash/cityhash.zig+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6const std = @import("std");6const std = @import("std");
7const builtin = @import("builtin");7const 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 {
10 // ptr + offset doesn't work at comptime so we need this instead.10 // ptr + offset doesn't work at comptime so we need this instead.
11 return @ptrCast([*]const u8, &ptr[offset]);11 return @ptrCast([*]const u8, &ptr[offset]);
12}12}
lib/std/os/bits/freebsd.zig+4-4
...@@ -815,16 +815,16 @@ pub const sigval = extern union {...@@ -815,16 +815,16 @@ pub const sigval = extern union {
815pub const _SIG_WORDS = 4;815pub const _SIG_WORDS = 4;
816pub const _SIG_MAXSIG = 128;816pub const _SIG_MAXSIG = 128;
817817
818pub inline fn _SIG_IDX(sig: usize) usize {818pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
819 return sig - 1;819 return sig - 1;
820}820}
821pub inline fn _SIG_WORD(sig: usize) usize {821pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
822 return_SIG_IDX(sig) >> 5;822 return_SIG_IDX(sig) >> 5;
823}823}
824pub inline fn _SIG_BIT(sig: usize) usize {824pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
825 return 1 << (_SIG_IDX(sig) & 31);825 return 1 << (_SIG_IDX(sig) & 31);
826}826}
827pub inline fn _SIG_VALID(sig: usize) usize {827pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
828 return sig <= _SIG_MAXSIG and sig > 0;828 return sig <= _SIG_MAXSIG and sig > 0;
829}829}
830830
lib/std/os/bits/netbsd.zig+4-4
...@@ -796,16 +796,16 @@ pub const _ksiginfo = extern struct {...@@ -796,16 +796,16 @@ pub const _ksiginfo = extern struct {
796pub const _SIG_WORDS = 4;796pub const _SIG_WORDS = 4;
797pub const _SIG_MAXSIG = 128;797pub const _SIG_MAXSIG = 128;
798798
799pub inline fn _SIG_IDX(sig: usize) usize {799pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
800 return sig - 1;800 return sig - 1;
801}801}
802pub inline fn _SIG_WORD(sig: usize) usize {802pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
803 return_SIG_IDX(sig) >> 5;803 return_SIG_IDX(sig) >> 5;
804}804}
805pub inline fn _SIG_BIT(sig: usize) usize {805pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
806 return 1 << (_SIG_IDX(sig) & 31);806 return 1 << (_SIG_IDX(sig) & 31);
807}807}
808pub inline fn _SIG_VALID(sig: usize) usize {808pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
809 return sig <= _SIG_MAXSIG and sig > 0;809 return sig <= _SIG_MAXSIG and sig > 0;
810}810}
811811
lib/std/os/linux.zig+1-1
...@@ -126,7 +126,7 @@ pub fn fork() usize {...@@ -126,7 +126,7 @@ pub fn fork() usize {
126/// It is advised to avoid this function and use clone instead, because126/// It is advised to avoid this function and use clone instead, because
127/// the compiler is not aware of how vfork affects control flow and you may127/// the compiler is not aware of how vfork affects control flow and you may
128/// see different results in optimized builds.128/// see different results in optimized builds.
129pub inline fn vfork() usize {129pub fn vfork() callconv(.Inline) usize {
130 return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});130 return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});
131}131}
132132
lib/std/os/linux/tls.zig+1-1
...@@ -300,7 +300,7 @@ fn initTLS() void {...@@ -300,7 +300,7 @@ fn initTLS() void {
300 };300 };
301}301}
302302
303inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T {303fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T {
304 return @ptrCast(*T, @alignCast(@alignOf(*T), ptr));304 return @ptrCast(*T, @alignCast(@alignOf(*T), ptr));
305}305}
306306
lib/std/os/windows.zig+1-1
...@@ -1669,7 +1669,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace {...@@ -1669,7 +1669,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace {
1669 return path_space;1669 return path_space;
1670}1670}
16711671
1672inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID {1672fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID {
1673 return (s << 10) | p;1673 return (s << 10) | p;
1674}1674}
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...@@ -262,7 +262,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret
262262
263// This is marked inline because for some reason LLVM in release mode fails to inline it,263// This is marked inline because for some reason LLVM in release mode fails to inline it,
264// and we want fewer call frames in stack traces.264// and we want fewer call frames in stack traces.
265inline fn initEventLoopAndCallMain() u8 {265fn initEventLoopAndCallMain() callconv(.Inline) u8 {
266 if (std.event.Loop.instance) |loop| {266 if (std.event.Loop.instance) |loop| {
267 if (!@hasDecl(root, "event_loop")) {267 if (!@hasDecl(root, "event_loop")) {
268 loop.init() catch |err| {268 loop.init() catch |err| {
...@@ -291,7 +291,7 @@ inline fn initEventLoopAndCallMain() u8 {...@@ -291,7 +291,7 @@ inline fn initEventLoopAndCallMain() u8 {
291// and we want fewer call frames in stack traces.291// and we want fewer call frames in stack traces.
292// TODO This function is duplicated from initEventLoopAndCallMain instead of using generics292// TODO This function is duplicated from initEventLoopAndCallMain instead of using generics
293// because it is working around stage1 compiler bugs.293// because it is working around stage1 compiler bugs.
294inline fn initEventLoopAndCallWinMain() std.os.windows.INT {294fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT {
295 if (std.event.Loop.instance) |loop| {295 if (std.event.Loop.instance) |loop| {
296 if (!@hasDecl(root, "event_loop")) {296 if (!@hasDecl(root, "event_loop")) {
297 loop.init() catch |err| {297 loop.init() catch |err| {
lib/std/zig/ast.zig+9
...@@ -1357,6 +1357,7 @@ pub const Node = struct {...@@ -1357,6 +1357,7 @@ pub const Node = struct {
1357 extern_export_inline_token: TokenIndex,1357 extern_export_inline_token: TokenIndex,
1358 is_extern_prototype: void, // TODO: Remove once extern fn rewriting is1358 is_extern_prototype: void, // TODO: Remove once extern fn rewriting is
1359 is_async: void, // TODO: remove once async fn rewriting is1359 is_async: void, // TODO: remove once async fn rewriting is
1360 is_inline: void, // TODO: remove once inline fn rewriting is
1360 });1361 });
13611362
1362 pub const RequiredFields = struct {1363 pub const RequiredFields = struct {
...@@ -1523,6 +1524,14 @@ pub const Node = struct {...@@ -1523,6 +1524,14 @@ pub const Node = struct {
1523 self.setTrailer(.is_async, value);1524 self.setTrailer(.is_async, value);
1524 }1525 }
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
1526 fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) {1535 fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) {
1527 const trailers_start = @alignCast(1536 const trailers_start = @alignCast(
1528 @alignOf(ParamDecl),1537 @alignOf(ParamDecl),
lib/std/zig/parse.zig+9-2
...@@ -493,9 +493,15 @@ const Parser = struct {...@@ -493,9 +493,15 @@ const Parser = struct {
493 extern_export_inline_token: ?TokenIndex = null,493 extern_export_inline_token: ?TokenIndex = null,
494 lib_name: ?*Node = null,494 lib_name: ?*Node = null,
495 }) !?*Node {495 }) !?*Node {
496 // TODO: Remove once extern/async fn rewriting is496 // TODO: Remove once extern/async/inline fn rewriting is
497 var is_async: ?void = null;
498 var is_extern_prototype: ?void = null;497 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 }
499 const cc_token: ?TokenIndex = blk: {505 const cc_token: ?TokenIndex = blk: {
500 if (p.eatToken(.Keyword_extern)) |token| {506 if (p.eatToken(.Keyword_extern)) |token| {
501 is_extern_prototype = {};507 is_extern_prototype = {};
...@@ -573,6 +579,7 @@ const Parser = struct {...@@ -573,6 +579,7 @@ const Parser = struct {
573 .callconv_expr = callconv_expr,579 .callconv_expr = callconv_expr,
574 .is_extern_prototype = is_extern_prototype,580 .is_extern_prototype = is_extern_prototype,
575 .is_async = is_async,581 .is_async = is_async,
582 .is_inline = is_inline,
576 });583 });
577 std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params);584 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" {...@@ -2355,17 +2355,17 @@ test "zig fmt: functions" {
2355 \\extern fn puts(s: *const u8) c_int;2355 \\extern fn puts(s: *const u8) c_int;
2356 \\extern "c" fn puts(s: *const u8) c_int;2356 \\extern "c" fn puts(s: *const u8) c_int;
2357 \\export fn puts(s: *const u8) c_int;2357 \\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;
2359 \\noinline fn puts(s: *const u8) c_int;2359 \\noinline fn puts(s: *const u8) c_int;
2360 \\pub extern fn puts(s: *const u8) c_int;2360 \\pub extern fn puts(s: *const u8) c_int;
2361 \\pub extern "c" fn puts(s: *const u8) c_int;2361 \\pub extern "c" fn puts(s: *const u8) c_int;
2362 \\pub export fn puts(s: *const u8) c_int;2362 \\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;
2364 \\pub noinline fn puts(s: *const u8) c_int;2364 \\pub noinline fn puts(s: *const u8) c_int;
2365 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;2365 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;
2366 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;2366 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;
2367 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;2367 \\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;
2369 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;2369 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;
2370 \\2370 \\
2371 );2371 );
lib/std/zig/render.zig+3-1
...@@ -1558,7 +1558,7 @@ fn renderExpression(...@@ -1558,7 +1558,7 @@ fn renderExpression(
1558 }1558 }
15591559
1560 if (fn_proto.getExternExportInlineToken()) |extern_export_inline_token| {1560 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)
1562 try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline1562 try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline
1563 }1563 }
15641564
...@@ -1664,6 +1664,8 @@ fn renderExpression(...@@ -1664,6 +1664,8 @@ fn renderExpression(
1664 try ais.writer().writeAll("callconv(.C) ");1664 try ais.writer().writeAll("callconv(.C) ");
1665 } else if (fn_proto.getIsAsync() != null) {1665 } else if (fn_proto.getIsAsync() != null) {
1666 try ais.writer().writeAll("callconv(.Async) ");1666 try ais.writer().writeAll("callconv(.Async) ");
1667 } else if (fn_proto.getIsInline() != null) {
1668 try ais.writer().writeAll("callconv(.Inline) ");
1667 }1669 }
16681670
1669 switch (fn_proto.return_type) {1671 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...@@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void
19 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);19 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
20}20}
2121
22inline fn bit(input: u32, offset: u5) bool {22fn bit(input: u32, offset: u5) callconv(.Inline) bool {
23 return (input >> offset) & 1 != 0;23 return (input >> offset) & 1 != 0;
24}24}
2525
26inline fn hasMask(input: u32, mask: u32) bool {26fn hasMask(input: u32, mask: u32) callconv(.Inline) bool {
27 return (input & mask) == mask;27 return (input & mask) == mask;
28}28}
2929
src/Module.zig+19-16
...@@ -1087,14 +1087,23 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {...@@ -1087,14 +1087,23 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
1087 if (fn_proto.getSectionExpr()) |sect_expr| {1087 if (fn_proto.getSectionExpr()) |sect_expr| {
1088 return self.failNode(&fn_type_scope.base, sect_expr, "TODO implement function section expression", .{});1088 return self.failNode(&fn_type_scope.base, sect_expr, "TODO implement function section expression", .{});
1089 }1089 }
1090 if (fn_proto.getCallconvExpr()) |callconv_expr| {1090
1091 return self.failNode(1091 const enum_literal_type = try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{
1092 &fn_type_scope.base,1092 .ty = Type.initTag(.type),
1093 callconv_expr,1093 .val = Value.initTag(.enum_literal_type),
1094 "TODO implement function calling convention expression",1094 });
1095 .{},1095 const enum_literal_type_rl: astgen.ResultLoc = .{ .ty = enum_literal_type };
1096 );1096 const cc = if (fn_proto.getCallconvExpr()) |callconv_expr|
1097 }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
1098 const return_type_expr = switch (fn_proto.return_type) {1107 const return_type_expr = switch (fn_proto.return_type) {
1099 .Explicit => |node| node,1108 .Explicit => |node| node,
1100 .InferErrorSet => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement inferred error sets", .{}),1109 .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 {...@@ -1105,6 +1114,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
1105 const fn_type_inst = try astgen.addZIRInst(self, &fn_type_scope.base, fn_src, zir.Inst.FnType, .{1114 const fn_type_inst = try astgen.addZIRInst(self, &fn_type_scope.base, fn_src, zir.Inst.FnType, .{
1106 .return_type = return_type_inst,1115 .return_type = return_type_inst,
1107 .param_types = param_types,1116 .param_types = param_types,
1117 .cc = cc,
1108 }, .{});1118 }, .{});
11091119
1110 if (std.builtin.mode == .Debug and self.comp.verbose_ir) {1120 if (std.builtin.mode == .Debug and self.comp.verbose_ir) {
...@@ -1230,14 +1240,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {...@@ -1230,14 +1240,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
1230 };1240 };
1231 };1241 };
12321242
1233 const is_inline = blk: {1243 const is_inline = fn_type.fnCallingConvention() == .Inline;
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 };
1241 const anal_state = ([2]Fn.Analysis{ .queued, .inline_only })[@boolToInt(is_inline)];1244 const anal_state = ([2]Fn.Analysis{ .queued, .inline_only })[@boolToInt(is_inline)];
12421245
1243 new_func.* = .{1246 new_func.* = .{
src/link/MachO.zig+1-1
...@@ -2366,7 +2366,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 {...@@ -2366,7 +2366,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 {
2366 return min_pos - start;2366 return min_pos - start;
2367}2367}
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 {
2370 const increased_size = padToIdeal(size);2370 const increased_size = padToIdeal(size);
2371 const test_end = off + increased_size;2371 const test_end = off + increased_size;
2372 if (end > off and start < test_end) {2372 if (end > off and start < test_end) {
src/stage1/all_types.hpp+3-9
...@@ -74,6 +74,7 @@ enum CallingConvention {...@@ -74,6 +74,7 @@ enum CallingConvention {
74 CallingConventionC,74 CallingConventionC,
75 CallingConventionNaked,75 CallingConventionNaked,
76 CallingConventionAsync,76 CallingConventionAsync,
77 CallingConventionInline,
77 CallingConventionInterrupt,78 CallingConventionInterrupt,
78 CallingConventionSignal,79 CallingConventionSignal,
79 CallingConventionStdcall,80 CallingConventionStdcall,
...@@ -703,12 +704,6 @@ enum NodeType {...@@ -703,12 +704,6 @@ enum NodeType {
703 NodeTypeAnyTypeField,704 NodeTypeAnyTypeField,
704};705};
705706
706enum FnInline {
707 FnInlineAuto,
708 FnInlineAlways,
709 FnInlineNever,
710};
711
712struct AstNodeFnProto {707struct AstNodeFnProto {
713 Buf *name;708 Buf *name;
714 ZigList<AstNode *> params;709 ZigList<AstNode *> params;
...@@ -725,13 +720,12 @@ struct AstNodeFnProto {...@@ -725,13 +720,12 @@ struct AstNodeFnProto {
725 AstNode *callconv_expr;720 AstNode *callconv_expr;
726 Buf doc_comments;721 Buf doc_comments;
727722
728 FnInline fn_inline;
729
730 VisibMod visib_mod;723 VisibMod visib_mod;
731 bool auto_err_set;724 bool auto_err_set;
732 bool is_var_args;725 bool is_var_args;
733 bool is_extern;726 bool is_extern;
734 bool is_export;727 bool is_export;
728 bool is_noinline;
735};729};
736730
737struct AstNodeFnDef {731struct AstNodeFnDef {
...@@ -1719,7 +1713,6 @@ struct ZigFn {...@@ -1719,7 +1713,6 @@ struct ZigFn {
17191713
1720 LLVMValueRef valgrind_client_request_array;1714 LLVMValueRef valgrind_client_request_array;
17211715
1722 FnInline fn_inline;
1723 FnAnalState anal_state;1716 FnAnalState anal_state;
17241717
1725 uint32_t align_bytes;1718 uint32_t align_bytes;
...@@ -1728,6 +1721,7 @@ struct ZigFn {...@@ -1728,6 +1721,7 @@ struct ZigFn {
1728 bool calls_or_awaits_errorable_fn;1721 bool calls_or_awaits_errorable_fn;
1729 bool is_cold;1722 bool is_cold;
1730 bool is_test;1723 bool is_test;
1724 bool is_noinline;
1731};1725};
17321726
1733uint32_t fn_table_entry_hash(ZigFn*);1727uint32_t fn_table_entry_hash(ZigFn*);
src/stage1/analyze.cpp+15-5
...@@ -973,6 +973,7 @@ const char *calling_convention_name(CallingConvention cc) {...@@ -973,6 +973,7 @@ const char *calling_convention_name(CallingConvention cc) {
973 case CallingConventionAPCS: return "APCS";973 case CallingConventionAPCS: return "APCS";
974 case CallingConventionAAPCS: return "AAPCS";974 case CallingConventionAAPCS: return "AAPCS";
975 case CallingConventionAAPCSVFP: return "AAPCSVFP";975 case CallingConventionAAPCSVFP: return "AAPCSVFP";
976 case CallingConventionInline: return "Inline";
976 }977 }
977 zig_unreachable();978 zig_unreachable();
978}979}
...@@ -981,6 +982,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {...@@ -981,6 +982,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
981 switch (cc) {982 switch (cc) {
982 case CallingConventionUnspecified:983 case CallingConventionUnspecified:
983 case CallingConventionAsync:984 case CallingConventionAsync:
985 case CallingConventionInline:
984 return true;986 return true;
985 case CallingConventionC:987 case CallingConventionC:
986 case CallingConventionNaked:988 case CallingConventionNaked:
...@@ -1007,7 +1009,8 @@ ZigType *get_stack_trace_type(CodeGen *g) {...@@ -1007,7 +1009,8 @@ ZigType *get_stack_trace_type(CodeGen *g) {
1007}1009}
10081010
1009bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {1011bool 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) {
1011 return handle_is_ptr(g, fn_type_id->return_type);1014 return handle_is_ptr(g, fn_type_id->return_type);
1012 }1015 }
1013 if (fn_type_id->cc != CallingConventionC) {1016 if (fn_type_id->cc != CallingConventionC) {
...@@ -1888,6 +1891,7 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_...@@ -1888,6 +1891,7 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_
1888 case CallingConventionC:1891 case CallingConventionC:
1889 case CallingConventionNaked:1892 case CallingConventionNaked:
1890 case CallingConventionAsync:1893 case CallingConventionAsync:
1894 case CallingConventionInline:
1891 break;1895 break;
1892 case CallingConventionInterrupt:1896 case CallingConventionInterrupt:
1893 if (g->zig_target->arch != ZigLLVM_x861897 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...@@ -3587,7 +3591,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i
3587 }3591 }
3588}3592}
35893593
3590static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {3594static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {
3591 ZigFn *fn_entry = heap::c_allocator.create<ZigFn>();3595 ZigFn *fn_entry = heap::c_allocator.create<ZigFn>();
3592 fn_entry->ir_executable = heap::c_allocator.create<IrExecutableSrc>();3596 fn_entry->ir_executable = heap::c_allocator.create<IrExecutableSrc>();
35933597
...@@ -3597,7 +3601,7 @@ static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {...@@ -3597,7 +3601,7 @@ static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) {
3597 fn_entry->analyzed_executable.backward_branch_quota = &fn_entry->prealloc_backward_branch_quota;3601 fn_entry->analyzed_executable.backward_branch_quota = &fn_entry->prealloc_backward_branch_quota;
3598 fn_entry->analyzed_executable.fn_entry = fn_entry;3602 fn_entry->analyzed_executable.fn_entry = fn_entry;
3599 fn_entry->ir_executable->fn_entry = fn_entry;3603 fn_entry->ir_executable->fn_entry = fn_entry;
3600 fn_entry->fn_inline = inline_value;3604 fn_entry->is_noinline = is_noinline;
36013605
3602 return fn_entry;3606 return fn_entry;
3603}3607}
...@@ -3606,7 +3610,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {...@@ -3606,7 +3610,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {
3606 assert(proto_node->type == NodeTypeFnProto);3610 assert(proto_node->type == NodeTypeFnProto);
3607 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;3611 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
3611 fn_entry->proto_node = proto_node;3615 fn_entry->proto_node = proto_node;
3612 fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr :3616 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) {...@@ -3739,6 +3743,12 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
3739 fn_table_entry->type_entry = g->builtin_types.entry_invalid;3743 fn_table_entry->type_entry = g->builtin_types.entry_invalid;
3740 tld_fn->base.resolution = TldResolutionInvalid;3744 tld_fn->base.resolution = TldResolutionInvalid;
3741 return;3745 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;
3742 case CallingConventionC:3752 case CallingConventionC:
3743 case CallingConventionNaked:3753 case CallingConventionNaked:
3744 case CallingConventionInterrupt:3754 case CallingConventionInterrupt:
...@@ -3774,7 +3784,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {...@@ -3774,7 +3784,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
3774 fn_table_entry->inferred_async_node = fn_table_entry->proto_node;3784 fn_table_entry->inferred_async_node = fn_table_entry->proto_node;
3775 }3785 }
3776 } else if (source_node->type == NodeTypeTestDecl) {3786 } 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
3779 get_fully_qualified_decl_name(g, &fn_table_entry->symbol_name, &tld_fn->base, true);3789 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) {...@@ -123,13 +123,8 @@ static const char *export_string(bool is_export) {
123// zig_unreachable();123// zig_unreachable();
124//}124//}
125125
126static const char *inline_string(FnInline fn_inline) {126static const char *inline_string(bool is_inline) {
127 switch (fn_inline) {127 return is_inline ? "inline" : "";
128 case FnInlineAlways: return "inline ";
129 case FnInlineNever: return "noinline ";
130 case FnInlineAuto: return "";
131 }
132 zig_unreachable();
133}128}
134129
135static const char *const_or_var_string(bool is_const) {130static const char *const_or_var_string(bool is_const) {
...@@ -446,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -446,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
446 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);441 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);
447 const char *extern_str = extern_string(node->data.fn_proto.is_extern);442 const char *extern_str = extern_string(node->data.fn_proto.is_extern);
448 const char *export_str = export_string(node->data.fn_proto.is_export);443 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);
450 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);445 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);
451 if (node->data.fn_proto.name != nullptr) {446 if (node->data.fn_proto.name != nullptr) {
452 print_symbol(ar, node->data.fn_proto.name);447 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) {...@@ -159,6 +159,7 @@ static const char *get_mangled_name(CodeGen *g, const char *original_name) {
159static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {159static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
160 switch (cc) {160 switch (cc) {
161 case CallingConventionUnspecified:161 case CallingConventionUnspecified:
162 case CallingConventionInline:
162 return ZigLLVM_Fast;163 return ZigLLVM_Fast;
163 case CallingConventionC:164 case CallingConventionC:
164 return ZigLLVM_C;165 return ZigLLVM_C;
...@@ -350,6 +351,7 @@ static bool cc_want_sret_attr(CallingConvention cc) {...@@ -350,6 +351,7 @@ static bool cc_want_sret_attr(CallingConvention cc) {
350 return true;351 return true;
351 case CallingConventionAsync:352 case CallingConventionAsync:
352 case CallingConventionUnspecified:353 case CallingConventionUnspecified:
354 case CallingConventionInline:
353 return false;355 return false;
354 }356 }
355 zig_unreachable();357 zig_unreachable();
...@@ -452,20 +454,11 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -452,20 +454,11 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
452 }454 }
453 }455 }
454456
455 switch (fn->fn_inline) {457 if (cc == CallingConventionInline)
456 case FnInlineAlways:458 addLLVMFnAttr(llvm_fn, "alwaysinline");
457 addLLVMFnAttr(llvm_fn, "alwaysinline");459
458 g->inline_fns.append(fn);460 if (fn->is_noinline || (cc != CallingConventionInline && fn->alignstack_value != 0))
459 break;461 addLLVMFnAttr(llvm_fn, "noinline");
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 }
469462
470 if (cc == CallingConventionNaked) {463 if (cc == CallingConventionNaked) {
471 addLLVMFnAttr(llvm_fn, "naked");464 addLLVMFnAttr(llvm_fn, "naked");
...@@ -532,7 +525,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -532,7 +525,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
532 addLLVMFnAttr(llvm_fn, "nounwind");525 addLLVMFnAttr(llvm_fn, "nounwind");
533 add_uwtable_attr(g, llvm_fn);526 add_uwtable_attr(g, llvm_fn);
534 addLLVMFnAttr(llvm_fn, "nobuiltin");527 addLLVMFnAttr(llvm_fn, "nobuiltin");
535 if (codegen_have_frame_pointer(g) && fn->fn_inline != FnInlineAlways) {528 if (codegen_have_frame_pointer(g) && cc != CallingConventionInline) {
536 ZigLLVMAddFunctionAttr(llvm_fn, "frame-pointer", "all");529 ZigLLVMAddFunctionAttr(llvm_fn, "frame-pointer", "all");
537 }530 }
538 if (fn->section_name) {531 if (fn->section_name) {
...@@ -9043,19 +9036,16 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {...@@ -9043,19 +9036,16 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
9043 static_assert(CallingConventionC == 1, "");9036 static_assert(CallingConventionC == 1, "");
9044 static_assert(CallingConventionNaked == 2, "");9037 static_assert(CallingConventionNaked == 2, "");
9045 static_assert(CallingConventionAsync == 3, "");9038 static_assert(CallingConventionAsync == 3, "");
9046 static_assert(CallingConventionInterrupt == 4, "");9039 static_assert(CallingConventionInline == 4, "");
9047 static_assert(CallingConventionSignal == 5, "");9040 static_assert(CallingConventionInterrupt == 5, "");
9048 static_assert(CallingConventionStdcall == 6, "");9041 static_assert(CallingConventionSignal == 6, "");
9049 static_assert(CallingConventionFastcall == 7, "");9042 static_assert(CallingConventionStdcall == 7, "");
9050 static_assert(CallingConventionVectorcall == 8, "");9043 static_assert(CallingConventionFastcall == 8, "");
9051 static_assert(CallingConventionThiscall == 9, "");9044 static_assert(CallingConventionVectorcall == 9, "");
9052 static_assert(CallingConventionAPCS == 10, "");9045 static_assert(CallingConventionThiscall == 10, "");
9053 static_assert(CallingConventionAAPCS == 11, "");9046 static_assert(CallingConventionAPCS == 11, "");
9054 static_assert(CallingConventionAAPCSVFP == 12, "");9047 static_assert(CallingConventionAAPCS == 12, "");
90559048 static_assert(CallingConventionAAPCSVFP == 13, "");
9056 static_assert(FnInlineAuto == 0, "");
9057 static_assert(FnInlineAlways == 1, "");
9058 static_assert(FnInlineNever == 2, "");
90599049
9060 static_assert(BuiltinPtrSizeOne == 0, "");9050 static_assert(BuiltinPtrSizeOne == 0, "");
9061 static_assert(BuiltinPtrSizeMany == 1, "");9051 static_assert(BuiltinPtrSizeMany == 1, "");
src/stage1/ir.cpp+12-11
...@@ -19000,7 +19000,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV...@@ -19000,7 +19000,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV
19000 } else if (init_val->type->id == ZigTypeIdFn &&19000 } else if (init_val->type->id == ZigTypeIdFn &&
19001 init_val->special != ConstValSpecialUndef &&19001 init_val->special != ConstValSpecialUndef &&
19002 init_val->data.x_ptr.special == ConstPtrSpecialFunction &&19002 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)
19004 {19004 {
19005 var_class_requires_const = true;19005 var_class_requires_const = true;
19006 if (!var->src_is_const && !is_comptime_var) {19006 if (!var->src_is_const && !is_comptime_var) {
...@@ -19182,6 +19182,11 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport...@@ -19182,6 +19182,11 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport
19182 buf_sprintf("exported function cannot be async"));19182 buf_sprintf("exported function cannot be async"));
19183 add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here"));19183 add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here"));
19184 } break;19184 } 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;
19185 case CallingConventionC:19190 case CallingConventionC:
19186 case CallingConventionNaked:19191 case CallingConventionNaked:
19187 case CallingConventionInterrupt:19192 case CallingConventionInterrupt:
...@@ -21120,7 +21125,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -21120,7 +21125,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
21120 if (type_is_invalid(return_type))21125 if (type_is_invalid(return_type))
21121 return ira->codegen->invalid_inst_gen;21126 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) {
21124 ir_add_error(ira, source_instr,21129 ir_add_error(ira, source_instr,
21125 buf_sprintf("no-inline call of inline function"));21130 buf_sprintf("no-inline call of inline function"));
21126 return ira->codegen->invalid_inst_gen;21131 return ira->codegen->invalid_inst_gen;
...@@ -25219,10 +25224,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa...@@ -25219,10 +25224,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa
25219 if ((err = type_resolve(ira->codegen, type_info_fn_decl_type, ResolveStatusSizeKnown)))25224 if ((err = type_resolve(ira->codegen, type_info_fn_decl_type, ResolveStatusSizeKnown)))
25220 return err;25225 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
25226 resolve_container_usingnamespace_decls(ira->codegen, decls_scope);25227 resolve_container_usingnamespace_decls(ira->codegen, decls_scope);
2522725228
25228 // The unresolved declarations are collected in a separate queue to avoid25229 // 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...@@ -25365,11 +25366,11 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa
25365 fn_decl_fields[0]->special = ConstValSpecialStatic;25366 fn_decl_fields[0]->special = ConstValSpecialStatic;
25366 fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type;25367 fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type;
25367 fn_decl_fields[0]->data.x_type = fn_entry->type_entry;25368 fn_decl_fields[0]->data.x_type = fn_entry->type_entry;
25368 // inline_type: Data.FnDecl.Inline25369 // is_noinline: bool
25369 ensure_field_index(fn_decl_val->type, "inline_type", 1);25370 ensure_field_index(fn_decl_val->type, "is_noinline", 1);
25370 fn_decl_fields[1]->special = ConstValSpecialStatic;25371 fn_decl_fields[1]->special = ConstValSpecialStatic;
25371 fn_decl_fields[1]->type = type_info_fn_decl_inline_type;25372 fn_decl_fields[1]->type = ira->codegen->builtin_types.entry_bool;
25372 bigint_init_unsigned(&fn_decl_fields[1]->data.x_enum_tag, fn_entry->fn_inline);25373 fn_decl_fields[1]->data.x_bool = fn_entry->is_noinline;
25373 // is_var_args: bool25374 // is_var_args: bool
25374 ensure_field_index(fn_decl_val->type, "is_var_args", 2);25375 ensure_field_index(fn_decl_val->type, "is_var_args", 2);
25375 bool is_varargs = fn_node->is_var_args;25376 bool is_varargs = fn_node->is_var_args;
...@@ -30957,7 +30958,7 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS...@@ -30957,7 +30958,7 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS
30957 return ira->codegen->invalid_inst_gen;30958 return ira->codegen->invalid_inst_gen;
30958 }30959 }
3095930960
30960 if (fn_entry->fn_inline == FnInlineAlways) {30961 if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionInline) {
30961 ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function"));30962 ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function"));
30962 return ira->codegen->invalid_inst_gen;30963 return ira->codegen->invalid_inst_gen;
30963 }30964 }
src/stage1/parser.cpp+3-14
...@@ -693,8 +693,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B...@@ -693,8 +693,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
693 Token *first = eat_token_if(pc, TokenIdKeywordExport);693 Token *first = eat_token_if(pc, TokenIdKeywordExport);
694 if (first == nullptr)694 if (first == nullptr)
695 first = eat_token_if(pc, TokenIdKeywordExtern);695 first = eat_token_if(pc, TokenIdKeywordExtern);
696 if (first == nullptr)
697 first = eat_token_if(pc, TokenIdKeywordInline);
698 if (first == nullptr)696 if (first == nullptr)
699 first = eat_token_if(pc, TokenIdKeywordNoInline);697 first = eat_token_if(pc, TokenIdKeywordNoInline);
700 if (first != nullptr) {698 if (first != nullptr) {
...@@ -702,7 +700,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B...@@ -702,7 +700,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
702 if (first->id == TokenIdKeywordExtern)700 if (first->id == TokenIdKeywordExtern)
703 lib_name = eat_token_if(pc, TokenIdStringLiteral);701 lib_name = eat_token_if(pc, TokenIdStringLiteral);
704702
705 if (first->id != TokenIdKeywordInline && first->id != TokenIdKeywordNoInline) {703 if (first->id != TokenIdKeywordNoInline) {
706 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);704 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);
707 AstNode *var_decl = ast_parse_var_decl(pc);705 AstNode *var_decl = ast_parse_var_decl(pc);
708 if (var_decl != nullptr) {706 if (var_decl != nullptr) {
...@@ -739,17 +737,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B...@@ -739,17 +737,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
739 if (!fn_proto->data.fn_proto.is_extern)737 if (!fn_proto->data.fn_proto.is_extern)
740 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;738 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
741 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;739 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
742 switch (first->id) {740 if (first->id == TokenIdKeywordNoInline)
743 case TokenIdKeywordInline:741 fn_proto->data.fn_proto.is_noinline = true;
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 }
753 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);742 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);
754743
755 AstNode *res = fn_proto;744 AstNode *res = fn_proto;
src/tracy.zig+1-1
...@@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {...@@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
31 pub fn end(self: Ctx) void {}31 pub fn end(self: Ctx) void {}
32};32};
3333
34pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {34pub fn trace(comptime src: std.builtin.SourceLocation) callconv(.Inline) Ctx {
35 if (!enable) return .{};35 if (!enable) return .{};
3636
37 const loc: ___tracy_source_location_data = .{37 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...@@ -4716,7 +4716,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
4716 const scope = &c.global_scope.base;4716 const scope = &c.global_scope.base;
47174717
4718 const pub_tok = try appendToken(c, .Keyword_pub, "pub");4718 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
4719 const inline_tok = try appendToken(c, .Keyword_inline, "inline");
4720 const fn_tok = try appendToken(c, .Keyword_fn, "fn");4719 const fn_tok = try appendToken(c, .Keyword_fn, "fn");
4721 const name_tok = try appendIdentifier(c, name);4720 const name_tok = try appendIdentifier(c, name);
4722 _ = try appendToken(c, .LParen, "(");4721 _ = try appendToken(c, .LParen, "(");
...@@ -4744,6 +4743,11 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a...@@ -4744,6 +4743,11 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
47444743
4745 _ = try appendToken(c, .RParen, ")");4744 _ = 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
4747 const block_lbrace = try appendToken(c, .LBrace, "{");4751 const block_lbrace = try appendToken(c, .LBrace, "{");
47484752
4749 const return_kw = try appendToken(c, .Keyword_return, "return");4753 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...@@ -4783,8 +4787,8 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
4783 }, .{4787 }, .{
4784 .visib_token = pub_tok,4788 .visib_token = pub_tok,
4785 .name_token = name_tok,4789 .name_token = name_tok,
4786 .extern_export_inline_token = inline_tok,
4787 .body_node = &block.base,4790 .body_node = &block.base,
4791 .callconv_expr = callconv_expr,
4788 });4792 });
4789 mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items);4793 mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items);
4790 return &fn_proto.base;4794 return &fn_proto.base;
...@@ -5734,7 +5738,6 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {...@@ -5734,7 +5738,6 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
5734 const scope = &block_scope.base;5738 const scope = &block_scope.base;
57355739
5736 const pub_tok = try appendToken(c, .Keyword_pub, "pub");5740 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
5737 const inline_tok = try appendToken(c, .Keyword_inline, "inline");
5738 const fn_tok = try appendToken(c, .Keyword_fn, "fn");5741 const fn_tok = try appendToken(c, .Keyword_fn, "fn");
5739 const name_tok = try appendIdentifier(c, m.name);5742 const name_tok = try appendIdentifier(c, m.name);
5740 _ = try appendToken(c, .LParen, "(");5743 _ = try appendToken(c, .LParen, "(");
...@@ -5779,6 +5782,11 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {...@@ -5779,6 +5782,11 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
57795782
5780 _ = try appendToken(c, .RParen, ")");5783 _ = 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
5782 const type_of = try c.createBuiltinCall("@TypeOf", 1);5790 const type_of = try c.createBuiltinCall("@TypeOf", 1);
57835791
5784 const return_kw = try appendToken(c, .Keyword_return, "return");5792 const return_kw = try appendToken(c, .Keyword_return, "return");
...@@ -5810,9 +5818,9 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {...@@ -5810,9 +5818,9 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
5810 .return_type = .{ .Explicit = &type_of.base },5818 .return_type = .{ .Explicit = &type_of.base },
5811 }, .{5819 }, .{
5812 .visib_token = pub_tok,5820 .visib_token = pub_tok,
5813 .extern_export_inline_token = inline_tok,
5814 .name_token = name_tok,5821 .name_token = name_tok,
5815 .body_node = block_node,5822 .body_node = block_node,
5823 .callconv_expr = callconv_expr,
5816 });5824 });
5817 mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items);5825 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 {...@@ -552,7 +552,9 @@ pub const Type = extern union {
552 if (i != 0) try out_stream.writeAll(", ");552 if (i != 0) try out_stream.writeAll(", ");
553 try param_type.format("", .{}, out_stream);553 try param_type.format("", .{}, out_stream);
554 }554 }
555 try out_stream.writeAll(") ");555 try out_stream.writeAll(") callconv(.");
556 try out_stream.writeAll(@tagName(payload.cc));
557 try out_stream.writeAll(")");
556 ty = payload.return_type;558 ty = payload.return_type;
557 continue;559 continue;
558 },560 },
src/zir.zig+3-6
...@@ -863,9 +863,7 @@ pub const Inst = struct {...@@ -863,9 +863,7 @@ pub const Inst = struct {
863 fn_type: *Inst,863 fn_type: *Inst,
864 body: Body,864 body: Body,
865 },865 },
866 kw_args: struct {866 kw_args: struct {},
867 is_inline: bool = false,
868 },
869 };867 };
870868
871 pub const FnType = struct {869 pub const FnType = struct {
...@@ -875,10 +873,9 @@ pub const Inst = struct {...@@ -875,10 +873,9 @@ pub const Inst = struct {
875 positionals: struct {873 positionals: struct {
876 param_types: []*Inst,874 param_types: []*Inst,
877 return_type: *Inst,875 return_type: *Inst,
876 cc: *Inst,
878 },877 },
879 kw_args: struct {878 kw_args: struct {},
880 cc: std.builtin.CallingConvention = .Unspecified,
881 },
882 };879 };
883880
884 pub const IntType = struct {881 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 {...@@ -980,18 +980,8 @@ fn zirCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst {
980980
981 const b = try mod.requireFunctionBlock(scope, inst.base.src);981 const b = try mod.requireFunctionBlock(scope, inst.base.src);
982 const is_comptime_call = b.is_comptime or inst.kw_args.modifier == .compile_time;982 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: {983 const is_inline_call = is_comptime_call or inst.kw_args.modifier == .always_inline or
984 // This logic will get simplified by984 func.ty.fnCallingConvention() == .Inline;
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 };
995 if (is_inline_call) {985 if (is_inline_call) {
996 const func_val = try mod.resolveConstValue(scope, func);986 const func_val = try mod.resolveConstValue(scope, func);
997 const module_fn = switch (func_val.tag()) {987 const module_fn = switch (func_val.tag()) {
...@@ -1075,7 +1065,7 @@ fn zirFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst {...@@ -1075,7 +1065,7 @@ fn zirFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst {
1075 const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type);1065 const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type);
1076 const new_func = try scope.arena().create(Module.Fn);1066 const new_func = try scope.arena().create(Module.Fn);
1077 new_func.* = .{1067 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,
1079 .zir = fn_inst.positionals.body,1069 .zir = fn_inst.positionals.body,
1080 .body = undefined,1070 .body = undefined,
1081 .owner_decl = scope.ownerDecl().?,1071 .owner_decl = scope.ownerDecl().?,
...@@ -1305,22 +1295,26 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*...@@ -1305,22 +1295,26 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*
1305 const tracy = trace(@src());1295 const tracy = trace(@src());
1306 defer tracy.end();1296 defer tracy.end();
1307 const return_type = try resolveType(mod, scope, fntype.positionals.return_type);1297 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
1309 // Hot path for some common function types.1303 // Hot path for some common function types.
1310 if (fntype.positionals.param_types.len == 0) {1304 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) {
1312 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_noreturn_no_args));1306 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_noreturn_no_args));
1313 }1307 }
13141308
1315 if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .Unspecified) {1309 if (return_type.zigTypeTag() == .Void and cc == .Unspecified) {
1316 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_void_no_args));1310 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_void_no_args));
1317 }1311 }
13181312
1319 if (return_type.zigTypeTag() == .NoReturn and fntype.kw_args.cc == .Naked) {1313 if (return_type.zigTypeTag() == .NoReturn and cc == .Naked) {
1320 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_naked_noreturn_no_args));1314 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_naked_noreturn_no_args));
1321 }1315 }
13221316
1323 if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .C) {1317 if (return_type.zigTypeTag() == .Void and cc == .C) {
1324 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_ccc_void_no_args));1318 return mod.constType(scope, fntype.base.src, Type.initTag(.fn_ccc_void_no_args));
1325 }1319 }
1326 }1320 }
...@@ -1337,9 +1331,9 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*...@@ -1337,9 +1331,9 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*
1337 }1331 }
13381332
1339 const fn_ty = try Type.Tag.function.create(arena, .{1333 const fn_ty = try Type.Tag.function.create(arena, .{
1340 .cc = fntype.kw_args.cc,
1341 .return_type = return_type,
1342 .param_types = param_types,1334 .param_types = param_types,
1335 .return_type = return_type,
1336 .cc = cc,
1343 });1337 });
1344 return mod.constType(scope, fntype.base.src, fn_ty);1338 return mod.constType(scope, fntype.base.src, fn_ty);
1345}1339}
test/cli.zig+1-1
...@@ -113,7 +113,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {...@@ -113,7 +113,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
113 \\ return num * num;113 \\ return num * num;
114 \\}114 \\}
115 \\extern fn zig_panic() noreturn;115 \\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 {
117 \\ zig_panic();117 \\ zig_panic();
118 \\}118 \\}
119 );119 );
test/compile_errors.zig+6-6
...@@ -1648,7 +1648,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1648,7 +1648,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1648 \\ @call(.{ .modifier = .compile_time }, baz, .{});1648 \\ @call(.{ .modifier = .compile_time }, baz, .{});
1649 \\}1649 \\}
1650 \\fn foo() void {}1650 \\fn foo() void {}
1651 \\inline fn bar() void {}1651 \\fn bar() callconv(.Inline) void {}
1652 \\fn baz1() void {}1652 \\fn baz1() void {}
1653 \\fn baz2() void {}1653 \\fn baz2() void {}
1654 , &[_][]const u8{1654 , &[_][]const u8{
...@@ -3944,7 +3944,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3944,7 +3944,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3944 \\export fn entry() void {3944 \\export fn entry() void {
3945 \\ var a = b;3945 \\ var a = b;
3946 \\}3946 \\}
3947 \\inline fn b() void { }3947 \\fn b() callconv(.Inline) void { }
3948 , &[_][]const u8{3948 , &[_][]const u8{
3949 "tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var",3949 "tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var",
3950 "tmp.zig:4:1: note: declared here",3950 "tmp.zig:4:1: note: declared here",
...@@ -6782,11 +6782,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6782,11 +6782,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6782 // \\export fn foo() void {6782 // \\export fn foo() void {
6783 // \\ bar();6783 // \\ bar();
6784 // \\}6784 // \\}
6785 // \\inline fn bar() void {6785 // \\fn bar() callconv(.Inline) void {
6786 // \\ baz();6786 // \\ baz();
6787 // \\ quux();6787 // \\ quux();
6788 // \\}6788 // \\}
6789 // \\inline fn baz() void {6789 // \\fn baz() callconv(.Inline) void {
6790 // \\ bar();6790 // \\ bar();
6791 // \\ quux();6791 // \\ quux();
6792 // \\}6792 // \\}
...@@ -6799,7 +6799,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6799,7 +6799,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6799 // \\export fn foo() void {6799 // \\export fn foo() void {
6800 // \\ quux(@ptrToInt(bar));6800 // \\ quux(@ptrToInt(bar));
6801 // \\}6801 // \\}
6802 // \\inline fn bar() void { }6802 // \\fn bar() callconv(.Inline) void { }
6803 // \\extern fn quux(usize) void;6803 // \\extern fn quux(usize) void;
6804 //, &[_][]const u8{6804 //, &[_][]const u8{
6805 // "tmp.zig:4:1: error: unable to inline function",6805 // "tmp.zig:4:1: error: unable to inline function",
...@@ -7207,7 +7207,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7207,7 +7207,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7207 \\export fn entry() void {7207 \\export fn entry() void {
7208 \\ foo();7208 \\ foo();
7209 \\}7209 \\}
7210 \\inline fn foo() void {7210 \\fn foo() callconv(.Inline) void {
7211 \\ @setAlignStack(16);7211 \\ @setAlignStack(16);
7212 \\}7212 \\}
7213 , &[_][]const u8{7213 , &[_][]const u8{
test/stage1/behavior/fn.zig+1-1
...@@ -113,7 +113,7 @@ test "assign inline fn to const variable" {...@@ -113,7 +113,7 @@ test "assign inline fn to const variable" {
113 a();113 a();
114}114}
115115
116inline fn inlineFn() void {}116fn inlineFn() callconv(.Inline) void {}
117117
118test "pass by non-copying value" {118test "pass by non-copying value" {
119 expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);119 expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);
test/stage2/cbe.zig+1-1
...@@ -179,7 +179,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -179,7 +179,7 @@ pub fn addCases(ctx: *TestContext) !void {
179 \\ return y - 1;179 \\ return y - 1;
180 \\}180 \\}
181 \\181 \\
182 \\inline fn rec(n: usize) usize {182 \\fn rec(n: usize) callconv(.Inline) usize {
183 \\ if (n <= 1) return n;183 \\ if (n <= 1) return n;
184 \\ return rec(n - 1);184 \\ return rec(n - 1);
185 \\}185 \\}
test/stage2/test.zig+5-5
...@@ -255,7 +255,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -255,7 +255,7 @@ pub fn addCases(ctx: *TestContext) !void {
255 \\ exit(y - 6);255 \\ exit(y - 6);
256 \\}256 \\}
257 \\257 \\
258 \\inline fn add(a: usize, b: usize, c: usize) usize {258 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
259 \\ return a + b + c;259 \\ return a + b + c;
260 \\}260 \\}
261 \\261 \\
...@@ -1228,7 +1228,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1228,7 +1228,7 @@ pub fn addCases(ctx: *TestContext) !void {
1228 \\ exit(y - 6);1228 \\ exit(y - 6);
1229 \\}1229 \\}
1230 \\1230 \\
1231 \\inline fn add(a: usize, b: usize, c: usize) usize {1231 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
1232 \\ if (a == 10) @compileError("bad");1232 \\ if (a == 10) @compileError("bad");
1233 \\ return a + b + c;1233 \\ return a + b + c;
1234 \\}1234 \\}
...@@ -1251,7 +1251,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1251,7 +1251,7 @@ pub fn addCases(ctx: *TestContext) !void {
1251 \\ exit(y - 6);1251 \\ exit(y - 6);
1252 \\}1252 \\}
1253 \\1253 \\
1254 \\inline fn add(a: usize, b: usize, c: usize) usize {1254 \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize {
1255 \\ if (a == 10) @compileError("bad");1255 \\ if (a == 10) @compileError("bad");
1256 \\ return a + b + c;1256 \\ return a + b + c;
1257 \\}1257 \\}
...@@ -1277,7 +1277,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1277,7 +1277,7 @@ pub fn addCases(ctx: *TestContext) !void {
1277 \\ exit(y - 21);1277 \\ exit(y - 21);
1278 \\}1278 \\}
1279 \\1279 \\
1280 \\inline fn fibonacci(n: usize) usize {1280 \\fn fibonacci(n: usize) callconv(.Inline) usize {
1281 \\ if (n <= 2) return n;1281 \\ if (n <= 2) return n;
1282 \\ return fibonacci(n - 2) + fibonacci(n - 1);1282 \\ return fibonacci(n - 2) + fibonacci(n - 1);
1283 \\}1283 \\}
...@@ -1300,7 +1300,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1300,7 +1300,7 @@ pub fn addCases(ctx: *TestContext) !void {
1300 \\ exit(y - 21);1300 \\ exit(y - 21);
1301 \\}1301 \\}
1302 \\1302 \\
1303 \\inline fn fibonacci(n: usize) usize {1303 \\fn fibonacci(n: usize) callconv(.Inline) usize {
1304 \\ if (n <= 2) return n;1304 \\ if (n <= 2) return n;
1305 \\ return fibonacci(n - 2) + fibonacci(n - 1);1305 \\ return fibonacci(n - 2) + fibonacci(n - 1);
1306 \\}1306 \\}
test/translate_c.zig+16-16
...@@ -43,7 +43,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -43,7 +43,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
43 ,43 ,
44 \\pub const VALUE = ((((1 + (2 * 3)) + (4 * 5)) + 6) << 7) | @boolToInt(8 == 9);44 \\pub const VALUE = ((((1 + (2 * 3)) + (4 * 5)) + 6) << 7) | @boolToInt(8 == 9);
45 ,45 ,
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)) {
47 \\ 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);47 \\ 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);
48 \\}48 \\}
49 });49 });
...@@ -116,7 +116,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -116,7 +116,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
116 \\};116 \\};
117 \\pub const Color = struct_Color;117 \\pub const Color = struct_Color;
118 ,118 ,
119 \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) {119 \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) {
120 \\ return type_1;120 \\ return type_1;
121 \\}121 \\}
122 ,122 ,
...@@ -148,7 +148,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -148,7 +148,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
148 cases.add("correct semicolon after infixop",148 cases.add("correct semicolon after infixop",
149 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)149 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
150 , &[_][]const u8{150 , &[_][]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) {
152 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;152 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;
153 \\}153 \\}
154 });154 });
...@@ -157,7 +157,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -157,7 +157,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
157 \\#define FOO(x) ((x >= 0) + (x >= 0))157 \\#define FOO(x) ((x >= 0) + (x >= 0))
158 \\#define BAR 1 && 2 > 4158 \\#define BAR 1 && 2 > 4
159 , &[_][]const u8{159 , &[_][]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)) {
161 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);161 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);
162 \\}162 \\}
163 ,163 ,
...@@ -208,7 +208,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -208,7 +208,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
208 \\ break :blk bar;208 \\ break :blk bar;
209 \\};209 \\};
210 ,210 ,
211 \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) {211 \\pub fn bar(x: anytype) callconv(.Inline) @TypeOf(baz(1, 2)) {
212 \\ return blk: {212 \\ return blk: {
213 \\ _ = &x;213 \\ _ = &x;
214 \\ _ = 3;214 \\ _ = 3;
...@@ -1590,13 +1590,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1590,13 +1590,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1590 , &[_][]const u8{1590 , &[_][]const u8{
1591 \\pub extern var fn_ptr: ?fn () callconv(.C) void;1591 \\pub extern var fn_ptr: ?fn () callconv(.C) void;
1592 ,1592 ,
1593 \\pub inline fn foo() void {1593 \\pub fn foo() callconv(.Inline) void {
1594 \\ return fn_ptr.?();1594 \\ return fn_ptr.?();
1595 \\}1595 \\}
1596 ,1596 ,
1597 \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8;1597 \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8;
1598 ,1598 ,
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 {
1600 \\ return fn_ptr2.?(arg_1, arg_2);1600 \\ return fn_ptr2.?(arg_1, arg_2);
1601 \\}1601 \\}
1602 });1602 });
...@@ -1629,7 +1629,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1629,7 +1629,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1629 ,1629 ,
1630 \\pub const glClearPFN = PFNGLCLEARPROC;1630 \\pub const glClearPFN = PFNGLCLEARPROC;
1631 ,1631 ,
1632 \\pub inline fn glClearUnion(arg_2: GLbitfield) void {1632 \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void {
1633 \\ return glProcs.gl.Clear.?(arg_2);1633 \\ return glProcs.gl.Clear.?(arg_2);
1634 \\}1634 \\}
1635 ,1635 ,
...@@ -1650,15 +1650,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1650,15 +1650,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1650 , &[_][]const u8{1650 , &[_][]const u8{
1651 \\pub extern var c: c_int;1651 \\pub extern var c: c_int;
1652 ,1652 ,
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) {
1654 \\ return c_1 * 2;1654 \\ return c_1 * 2;
1655 \\}1655 \\}
1656 ,1656 ,
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) {
1658 \\ return L + b;1658 \\ return L + b;
1659 \\}1659 \\}
1660 ,1660 ,
1661 \\pub inline fn BAR() @TypeOf(c * c) {1661 \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) {
1662 \\ return c * c;1662 \\ return c * c;
1663 \\}1663 \\}
1664 });1664 });
...@@ -2310,7 +2310,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2310,7 +2310,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2310 cases.add("macro call",2310 cases.add("macro call",
2311 \\#define CALL(arg) bar(arg)2311 \\#define CALL(arg) bar(arg)
2312 , &[_][]const u8{2312 , &[_][]const u8{
2313 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {2313 \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) {
2314 \\ return bar(arg);2314 \\ return bar(arg);
2315 \\}2315 \\}
2316 });2316 });
...@@ -2872,7 +2872,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2872,7 +2872,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2872 \\#define BAR (void*) a2872 \\#define BAR (void*) a
2873 \\#define BAZ (uint32_t)(2)2873 \\#define BAZ (uint32_t)(2)
2874 , &[_][]const u8{2874 , &[_][]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)))) {
2876 \\ return baz((@import("std").meta.cast(?*c_void, baz)));2876 \\ return baz((@import("std").meta.cast(?*c_void, baz)));
2877 \\}2877 \\}
2878 ,2878 ,
...@@ -2914,11 +2914,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2914,11 +2914,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2914 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))2914 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))
2915 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))2915 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
2916 , &[_][]const u8{2916 , &[_][]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) {
2918 \\ return if (b < a) b else a;2918 \\ return if (b < a) b else a;
2919 \\}2919 \\}
2920 ,2920 ,
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) {
2922 \\ return if (b > a) b else a;2922 \\ return if (b > a) b else a;
2923 \\}2923 \\}
2924 });2924 });
...@@ -3106,7 +3106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -3106,7 +3106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3106 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)3106 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
3107 \\3107 \\
3108 , &[_][]const u8{3108 , &[_][]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) {
3110 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;3110 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;
3111 \\}3111 \\}
3112 });3112 });