authorgravatar for gbell12907@gmail.comCMDRZero <gbell12907@gmail.com> 2025-09-17 19:49:34-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-22 12:21:43+02:00
log64e4f9db8fa6fc47b0a2ef3143edacf472fb8c48
tree7566214af13ad8d95ade48e53c4013acfbe23f7c
parent16894c484c316c110a843ee15514790cc589dbfa

Implement partially ordered operator precedence


108 files changed, 727 insertions(+), 411 deletions(-)

lib/c/math.zig+2-2
...@@ -355,7 +355,7 @@ fn pow10f(x: f32) callconv(.c) f32 {...@@ -355,7 +355,7 @@ fn pow10f(x: f32) callconv(.c) f32 {
355fn rint(x: f64) callconv(.c) f64 {355fn rint(x: f64) callconv(.c) f64 {
356 const toint: f64 = 1.0 / math.floatEps(f64);356 const toint: f64 = 1.0 / math.floatEps(f64);
357 const a: u64 = @bitCast(x);357 const a: u64 = @bitCast(x);
358 const e = a >> 52 & 0x7ff;358 const e = (a >> 52) & 0x7ff;
359 const s = a >> 63;359 const s = a >> 63;
360 var y: f64 = undefined;360 var y: f64 = undefined;
361361
...@@ -376,7 +376,7 @@ fn rint(x: f64) callconv(.c) f64 {...@@ -376,7 +376,7 @@ fn rint(x: f64) callconv(.c) f64 {
376fn rintf(x: f32) callconv(.c) f32 {376fn rintf(x: f32) callconv(.c) f32 {
377 const toint: f32 = 1.0 / math.floatEps(f32);377 const toint: f32 = 1.0 / math.floatEps(f32);
378 const a: u32 = @bitCast(x);378 const a: u32 = @bitCast(x);
379 const e = a >> 23 & 0xff;379 const e = (a >> 23) & 0xff;
380 const s = a >> 31;380 const s = a >> 31;
381 var y: f32 = undefined;381 var y: f32 = undefined;
382382
lib/c/stdlib/drand48.zig+6-6
...@@ -30,7 +30,7 @@ var lcg: Lcg = .init(0, default_multiplier, default_addend);...@@ -30,7 +30,7 @@ var lcg: Lcg = .init(0, default_multiplier, default_addend);
30var seed48_xi: [3]c_ushort = undefined;30var seed48_xi: [3]c_ushort = undefined;
3131
32fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {32fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {
33 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);33 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
3434
35 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);35 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
36 const next_xi = separate_lcg.next();36 const next_xi = separate_lcg.next();
...@@ -40,7 +40,7 @@ fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {...@@ -40,7 +40,7 @@ fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {
40}40}
4141
42fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {42fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
43 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);43 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
4444
45 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);45 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
46 const next_xi = separate_lcg.next();46 const next_xi = separate_lcg.next();
...@@ -50,7 +50,7 @@ fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {...@@ -50,7 +50,7 @@ fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
50}50}
5151
52fn nrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {52fn nrand48(xsubi: *[3]c_ushort) callconv(.c) c_long {
53 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);53 const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | ((@as(u48, @as(u16, @truncate(xsubi[1])))) << 16)) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);
5454
55 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);55 var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
56 const next_xi = separate_lcg.next();56 const next_xi = separate_lcg.next();
...@@ -74,14 +74,14 @@ fn mrand48() callconv(.c) c_long {...@@ -74,14 +74,14 @@ fn mrand48() callconv(.c) c_long {
74// 0..3 is `Xi`, 3..6 is `a`, 6 is `c`74// 0..3 is `Xi`, 3..6 is `a`, 6 is `c`
75// first low 16-bits, then mid, then high.75// first low 16-bits, then mid, then high.
76fn lcong48(param: *[7]c_ushort) callconv(.c) void {76fn lcong48(param: *[7]c_ushort) callconv(.c) void {
77 lcg.xi = (@as(u48, @as(u16, @truncate(param[0]))) | (@as(u48, @as(u16, @truncate(param[1])))) << 16) | (@as(u48, @as(u16, @truncate(param[2]))) << 32);77 lcg.xi = (@as(u48, @as(u16, @truncate(param[0]))) | ((@as(u48, @as(u16, @truncate(param[1])))) << 16)) | (@as(u48, @as(u16, @truncate(param[2]))) << 32);
78 lcg.a = (@as(u48, @as(u16, @truncate(param[3]))) | (@as(u48, @as(u16, @truncate(param[4])))) << 16) | (@as(u48, @as(u16, @truncate(param[5]))) << 32);78 lcg.a = (@as(u48, @as(u16, @truncate(param[3]))) | ((@as(u48, @as(u16, @truncate(param[4])))) << 16)) | (@as(u48, @as(u16, @truncate(param[5]))) << 32);
79 lcg.c = @as(u16, @truncate(param[6]));79 lcg.c = @as(u16, @truncate(param[6]));
80}80}
8181
82fn seed48(seed16v: *[3]c_ushort) callconv(.c) *[3]c_ushort {82fn seed48(seed16v: *[3]c_ushort) callconv(.c) *[3]c_ushort {
83 seed48_xi = .{ @truncate(lcg.xi & 0xFFFF), @truncate((lcg.xi >> 16) & 0xFFFF), @truncate((lcg.xi >> 32) & 0xFFFF) };83 seed48_xi = .{ @truncate(lcg.xi & 0xFFFF), @truncate((lcg.xi >> 16) & 0xFFFF), @truncate((lcg.xi >> 32) & 0xFFFF) };
84 const xi = (@as(u48, @as(u16, @truncate(seed16v[0]))) | (@as(u48, @as(u16, @truncate(seed16v[1])))) << 16) | (@as(u48, @as(u16, @truncate(seed16v[2]))) << 32);84 const xi = (@as(u48, @as(u16, @truncate(seed16v[0]))) | ((@as(u48, @as(u16, @truncate(seed16v[1])))) << 16)) | (@as(u48, @as(u16, @truncate(seed16v[2]))) << 32);
85 lcg = .init(xi, default_multiplier, default_addend);85 lcg = .init(xi, default_multiplier, default_addend);
86 return &seed48_xi;86 return &seed48_xi;
87}87}
lib/compiler/Maker/Step/Compile.zig+1-1
...@@ -45,7 +45,7 @@ pub fn make(...@@ -45,7 +45,7 @@ pub fn make(
4545
46 try lowerZigArgs(arena, compile_index, maker, progress_node, &argv, false);46 try lowerZigArgs(arena, compile_index, maker, progress_node, &argv, false);
4747
48 const incremental = conf_comp.flags4.incremental.toBool() orelse graph.incremental == true;48 const incremental = conf_comp.flags4.incremental.toBool() orelse graph.incremental orelse false;
4949
50 const opt_cache_digest = Step.evalZigProcess(50 const opt_cache_digest = Step.evalZigProcess(
51 compile_index,51 compile_index,
lib/compiler/aro/aro/Compilation.zig+3-3
...@@ -287,7 +287,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {...@@ -287,7 +287,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
287 const gnuc_version = comp.langopts.gnuc_version orelse comp.langopts.emulate.defaultGccVersion();287 const gnuc_version = comp.langopts.gnuc_version orelse comp.langopts.emulate.defaultGccVersion();
288 if (gnuc_version > 0) {288 if (gnuc_version > 0) {
289 try w.print("#define __GNUC__ {d}\n", .{gnuc_version / 10_000});289 try w.print("#define __GNUC__ {d}\n", .{gnuc_version / 10_000});
290 try w.print("#define __GNUC_MINOR__ {d}\n", .{gnuc_version / 100 % 100});290 try w.print("#define __GNUC_MINOR__ {d}\n", .{(gnuc_version / 100) % 100});
291 try w.print("#define __GNUC_PATCHLEVEL__ {d}\n", .{gnuc_version % 100});291 try w.print("#define __GNUC_PATCHLEVEL__ {d}\n", .{gnuc_version % 100});
292 }292 }
293293
...@@ -962,7 +962,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {...@@ -962,7 +962,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
962 try define(w, "__ARM_ARCH_EXT_IDIV__");962 try define(w, "__ARM_ARCH_EXT_IDIV__");
963 }963 }
964 var sat = false;964 var sat = false;
965 if (arm_version == 6 and !target.cpu.has(.arm, .mclass) or arm_version > 6) {965 if ((arm_version == 6 and !target.cpu.has(.arm, .mclass)) or arm_version > 6) {
966 try define(w, "__ARM_FEATURE_SAT");966 try define(w, "__ARM_FEATURE_SAT");
967 sat = true;967 sat = true;
968 }968 }
...@@ -2856,7 +2856,7 @@ test "addSourceFromBuffer - exhaustive check for carriage return elimination" {...@@ -2856,7 +2856,7 @@ test "addSourceFromBuffer - exhaustive check for carriage return elimination" {
2856 if (buf[j] == alphabet[0]) buf[j - 1] = alphabet[(idx + 1) % alen] else break;2856 if (buf[j] == alphabet[0]) buf[j - 1] = alphabet[(idx + 1) % alen] else break;
2857 }2857 }
2858 }2858 }
2859 try std.testing.expect(source_count == std.math.powi(usize, alen, alen) catch unreachable);2859 try std.testing.expect(source_count == (std.math.powi(usize, alen, alen) catch unreachable));
2860}2860}
28612861
2862test "ignore BOM at beginning of file" {2862test "ignore BOM at beginning of file" {
lib/compiler/aro/aro/Driver.zig+1-1
...@@ -1373,7 +1373,7 @@ fn getOutFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) !...@@ -1373,7 +1373,7 @@ fn getOutFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) !
1373 if (d.only_preprocess_and_compile) ".s" else d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch),1373 if (d.only_preprocess_and_compile) ".s" else d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch),
1374 };1374 };
1375 return d.output_name orelse1375 return d.output_name orelse
1376 mem.print(buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args);1376 (mem.print(buf, fmt_template, fmt_args) catch return d.fatal("Filename too long for filesystem: " ++ fmt_template, fmt_args));
1377 }1377 }
13781378
1379 return d.getRandomFilename(buf, d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch));1379 return d.getRandomFilename(buf, d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch));
lib/compiler/aro/aro/Parser.zig+1-1
...@@ -7084,7 +7084,7 @@ pub const Result = struct {...@@ -7084,7 +7084,7 @@ pub const Result = struct {
7084 const b_child_qt = b.qt.get(p.comp, .pointer).?.child;7084 const b_child_qt = b.qt.get(p.comp, .pointer).?.child;
70857085
7086 if (!a_child_qt.eql(b_child_qt, p.comp)) try p.err(tok, .incompatible_pointers, .{ a.qt, b.qt });7086 if (!a_child_qt.eql(b_child_qt, p.comp)) try p.err(tok, .incompatible_pointers, .{ a.qt, b.qt });
7087 if (a.qt.childType(p.comp).sizeofOrNull(p.comp) orelse 1 == 0) try p.err(tok, .subtract_pointers_zero_elem_size, .{a.qt.childType(p.comp)});7087 if ((a.qt.childType(p.comp).sizeofOrNull(p.comp) orelse 1) == 0) try p.err(tok, .subtract_pointers_zero_elem_size, .{a.qt.childType(p.comp)});
7088 a.qt = p.comp.type_store.ptrdiff;7088 a.qt = p.comp.type_store.ptrdiff;
7089 }7089 }
70907090
lib/compiler/aro/aro/Preprocessor.zig+3-3
...@@ -310,13 +310,13 @@ pub const InitOptions = struct {...@@ -310,13 +310,13 @@ pub const InitOptions = struct {
310};310};
311311
312pub fn init(comp: *Compilation, options: InitOptions) !Preprocessor {312pub fn init(comp: *Compilation, options: InitOptions) !Preprocessor {
313 const source_epoch: SourceEpoch = options.source_epoch orelse comp.environment.sourceEpoch(comp.io) catch |er| switch (er) {313 const source_epoch: SourceEpoch = options.source_epoch orelse (comp.environment.sourceEpoch(comp.io) catch |er| switch (er) {
314 error.InvalidEpoch => blk: {314 error.InvalidEpoch => blk: {
315 const diagnostic: Diagnostic = .invalid_source_epoch;315 const diagnostic: Diagnostic = .invalid_source_epoch;
316 try comp.diagnostics.add(.{ .text = diagnostic.fmt, .kind = diagnostic.kind, .opt = diagnostic.opt, .location = null });316 try comp.diagnostics.add(.{ .text = diagnostic.fmt, .kind = diagnostic.kind, .opt = diagnostic.opt, .location = null });
317 break :blk .default;317 break :blk .default;
318 },318 },
319 };319 });
320320
321 var pp: Preprocessor = .{321 var pp: Preprocessor = .{
322 .comp = comp,322 .comp = comp,
...@@ -3882,7 +3882,7 @@ pub fn prettyPrintTokens(pp: *Preprocessor, w: *std.Io.Writer, macro_dump_mode:...@@ -3882,7 +3882,7 @@ pub fn prettyPrintTokens(pp: *Preprocessor, w: *std.Io.Writer, macro_dump_mode:
3882 },3882 },
3883 .keyword_pragma => {3883 .keyword_pragma => {
3884 const pragma_name = pp.expandedSlice(pp.tokens.get(i + 1));3884 const pragma_name = pp.expandedSlice(pp.tokens.get(i + 1));
3885 const end_idx = mem.findScalarPos(Token.Id, tok_ids, i, .nl) orelse i + 1;3885 const end_idx = mem.findScalarPos(Token.Id, tok_ids, i, .nl) orelse (i + 1);
3886 const pragma_len = @as(u32, @intCast(end_idx)) - i;3886 const pragma_len = @as(u32, @intCast(end_idx)) - i;
38873887
3888 if (pp.comp.getPragma(pragma_name)) |prag| {3888 if (pp.comp.getPragma(pragma_name)) |prag| {
lib/compiler/aro/aro/Preprocessor/Parser.zig+1-1
...@@ -323,7 +323,7 @@ fn binaryExpr(p: *Parser, min_prec: Token.Precedence, eval: bool) Error!?Value {...@@ -323,7 +323,7 @@ fn binaryExpr(p: *Parser, min_prec: Token.Precedence, eval: bool) Error!?Value {
323 const else_res = try p.binaryExpr(op_prec, eval_else) orelse return null;323 const else_res = try p.binaryExpr(op_prec, eval_else) orelse return null;
324324
325 lhs = if (lhs.toBool()) rhs else else_res;325 lhs = if (lhs.toBool()) rhs else else_res;
326 if (eval and rhs == .unsigned or else_res == .unsigned) {326 if ((eval and rhs == .unsigned) or else_res == .unsigned) {
327 try lhs.toUnsigned(p, operator, "right");327 try lhs.toUnsigned(p, operator, "right");
328 }328 }
329 },329 },
lib/compiler/aro/aro/char_info.zig+2-2
...@@ -492,7 +492,7 @@ pub fn isXidStart(c: u21) bool {...@@ -492,7 +492,7 @@ pub fn isXidStart(c: u21) bool {
492 assert(c > 0x7F);492 assert(c > 0x7F);
493 const idx = c / 8 / tables.chunk;493 const idx = c / 8 / tables.chunk;
494 const chunk: usize = if (idx < tables.trie_start.len) tables.trie_start[idx] else 0;494 const chunk: usize = if (idx < tables.trie_start.len) tables.trie_start[idx] else 0;
495 const offset = chunk * tables.chunk / 2 + c / 8 % tables.chunk;495 const offset = chunk * tables.chunk / 2 + (c / 8) % tables.chunk;
496 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;496 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;
497}497}
498498
...@@ -500,7 +500,7 @@ pub fn isXidContinue(c: u21) bool {...@@ -500,7 +500,7 @@ pub fn isXidContinue(c: u21) bool {
500 assert(c > 0x7F);500 assert(c > 0x7F);
501 const idx = c / 8 / tables.chunk;501 const idx = c / 8 / tables.chunk;
502 const chunk: usize = if (idx < tables.trie_continue.len) tables.trie_continue[idx] else 0;502 const chunk: usize = if (idx < tables.trie_continue.len) tables.trie_continue[idx] else 0;
503 const offset = chunk * tables.chunk / 2 + c / 8 % tables.chunk;503 const offset = chunk * tables.chunk / 2 + (c / 8) % tables.chunk;
504 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;504 return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0;
505}505}
506506
lib/compiler/aro/aro/record_layout.zig+1-1
...@@ -324,7 +324,7 @@ const SysVContext = struct {...@@ -324,7 +324,7 @@ const SysVContext = struct {
324324
325 // On Clang, the alignment requested by annotations is not respected if it is325 // On Clang, the alignment requested by annotations is not respected if it is
326 // larger than the value of #pragma pack. See test case 0083.326 // larger than the value of #pragma pack. See test case 0083.
327 if (annotation_alignment <= self.max_field_align_bits orelse std.math.maxInt(u29)) {327 if (annotation_alignment <= (self.max_field_align_bits orelse std.math.maxInt(u29))) {
328 field_align_bits = @max(field_align_bits, annotation_alignment);328 field_align_bits = @max(field_align_bits, annotation_alignment);
329 }329 }
330 // On Clang, if there are no packing annotations and the field would cross a330 // On Clang, if there are no packing annotations and the field would cross a
lib/compiler_rt/absv.zig+1-1
...@@ -11,7 +11,7 @@ pub inline fn absv(comptime ST: type, a: ST) ST {...@@ -11,7 +11,7 @@ pub inline fn absv(comptime ST: type, a: ST) ST {
11 // compute the integer absolute value (abs) without branching11 // compute the integer absolute value (abs) without branching
12 var x: ST = a;12 var x: ST = a;
13 const N: UT = @bitSizeOf(ST);13 const N: UT = @bitSizeOf(ST);
14 const sign: ST = a >> N - 1;14 const sign: ST = a >> (N - 1);
15 x +%= sign;15 x +%= sign;
16 x ^= sign;16 x ^= sign;
17 if (x < 0) @panic("integer overflow");17 if (x < 0) @panic("integer overflow");
lib/compiler_rt/addf3.zig+1-1
...@@ -259,7 +259,7 @@ inline fn addf3(comptime T: type, a: T, b: T) T {...@@ -259,7 +259,7 @@ inline fn addf3(comptime T: type, a: T, b: T) T {
259 // adjust the exponent:259 // adjust the exponent:
260 if (aSignificand & (integerBit << 4) != 0) {260 if (aSignificand & (integerBit << 4) != 0) {
261 const sticky = aSignificand & 1;261 const sticky = aSignificand & 1;
262 aSignificand = aSignificand >> 1 | sticky;262 aSignificand = (aSignificand >> 1) | sticky;
263 aExponent += 1;263 aExponent += 1;
264 }264 }
265 }265 }
lib/compiler_rt/atomics.zig+1-1
...@@ -241,7 +241,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {...@@ -241,7 +241,7 @@ fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
241 while (true) {241 while (true) {
242 const old = @as(T, @truncate((wide_old & mask) >> inner_shift));242 const old = @as(T, @truncate((wide_old & mask) >> inner_shift));
243 const new = update(val, old);243 const new = update(val, old);
244 const wide_new = wide_old & ~mask | (@as(WideAtomic, new) << inner_shift);244 const wide_new = (wide_old & ~mask) | (@as(WideAtomic, new) << inner_shift);
245 if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .seq_cst, .seq_cst)) |new_wide_old| {245 if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .seq_cst, .seq_cst)) |new_wide_old| {
246 wide_old = new_wide_old;246 wide_old = new_wide_old;
247 } else {247 } else {
lib/compiler_rt/comparef.zig+4-4
...@@ -130,13 +130,13 @@ fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {...@@ -130,13 +130,13 @@ fn __aeabi_fcmplt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
130 return @intFromBool(cmp_f32(a, b) == .lt);130 return @intFromBool(cmp_f32(a, b) == .lt);
131}131}
132fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {132fn __aeabi_fcmple(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
133 return @intFromBool(cmp_f32(a, b) orelse .gt != .gt);133 return @intFromBool((cmp_f32(a, b) orelse .gt) != .gt);
134}134}
135fn __gesf2(a: compiler_rt.f32.Abi, b: compiler_rt.f32.Abi) callconv(.c) Order {135fn __gesf2(a: compiler_rt.f32.Abi, b: compiler_rt.f32.Abi) callconv(.c) Order {
136 return cmp_f32(compiler_rt.f32.fromAbi(a), compiler_rt.f32.fromAbi(b)) orelse .lt;136 return cmp_f32(compiler_rt.f32.fromAbi(a), compiler_rt.f32.fromAbi(b)) orelse .lt;
137}137}
138fn __aeabi_fcmpge(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {138fn __aeabi_fcmpge(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
139 return @intFromBool(cmp_f32(a, b) orelse .lt != .lt);139 return @intFromBool((cmp_f32(a, b) orelse .lt) != .lt);
140}140}
141fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {141fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 {
142 return @intFromBool(cmp_f32(a, b) == .gt);142 return @intFromBool(cmp_f32(a, b) == .gt);
...@@ -164,13 +164,13 @@ fn __aeabi_dcmplt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {...@@ -164,13 +164,13 @@ fn __aeabi_dcmplt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
164 return @intFromBool(cmp_f64(a, b) == .lt);164 return @intFromBool(cmp_f64(a, b) == .lt);
165}165}
166fn __aeabi_dcmple(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {166fn __aeabi_dcmple(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
167 return @intFromBool(cmp_f64(a, b) orelse .gt != .gt);167 return @intFromBool((cmp_f64(a, b) orelse .gt) != .gt);
168}168}
169fn __gedf2(a: compiler_rt.f64.Abi, b: compiler_rt.f64.Abi) callconv(.c) Order {169fn __gedf2(a: compiler_rt.f64.Abi, b: compiler_rt.f64.Abi) callconv(.c) Order {
170 return cmp_f64(compiler_rt.f64.fromAbi(a), compiler_rt.f64.fromAbi(b)) orelse .lt;170 return cmp_f64(compiler_rt.f64.fromAbi(a), compiler_rt.f64.fromAbi(b)) orelse .lt;
171}171}
172fn __aeabi_dcmpge(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {172fn __aeabi_dcmpge(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
173 return @intFromBool(cmp_f64(a, b) orelse .lt != .lt);173 return @intFromBool((cmp_f64(a, b) orelse .lt) != .lt);
174}174}
175fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {175fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 {
176 return @intFromBool(cmp_f64(a, b) == .gt);176 return @intFromBool(cmp_f64(a, b) == .gt);
lib/compiler_rt/divdf3.zig+8-8
...@@ -119,12 +119,12 @@ pub fn div_f64(a: f64, b: f64) f64 {...@@ -119,12 +119,12 @@ pub fn div_f64(a: f64, b: f64) f64 {
119 // with each iteration, so after three iterations, we have about 28 binary119 // with each iteration, so after three iterations, we have about 28 binary
120 // digits of accuracy.120 // digits of accuracy.
121 var correction32: u32 = undefined;121 var correction32: u32 = undefined;
122 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);122 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
123 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);123 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
124 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);124 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
125 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);125 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
126 correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1);126 correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1);
127 recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31);127 recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31);
128128
129 // recip32 might have overflowed to exactly zero in the preceding129 // recip32 might have overflowed to exactly zero in the preceding
130 // computation if the high word of b is exactly 1.0. This would sabotage130 // computation if the high word of b is exactly 1.0. This would sabotage
...@@ -137,10 +137,10 @@ pub fn div_f64(a: f64, b: f64) f64 {...@@ -137,10 +137,10 @@ pub fn div_f64(a: f64, b: f64) f64 {
137 const q63blo: u32 = @truncate(bSignificand << 11);137 const q63blo: u32 = @truncate(bSignificand << 11);
138 var correction: u64 = undefined;138 var correction: u64 = undefined;
139 var reciprocal: u64 = undefined;139 var reciprocal: u64 = undefined;
140 correction = ~(@as(u64, recip32) *% q31b +% (@as(u64, recip32) *% q63blo >> 32)) +% 1;140 correction = ~(@as(u64, recip32) *% q31b +% ((@as(u64, recip32) *% q63blo) >> 32)) +% 1;
141 const cHi: u32 = @truncate(correction >> 32);141 const cHi: u32 = @truncate(correction >> 32);
142 const cLo: u32 = @truncate(correction);142 const cLo: u32 = @truncate(correction);
143 reciprocal = @as(u64, recip32) *% cHi +% (@as(u64, recip32) *% cLo >> 32);143 reciprocal = @as(u64, recip32) *% cHi +% ((@as(u64, recip32) *% cLo) >> 32);
144144
145 // We already adjusted the 32-bit estimate, now we need to adjust the final145 // We already adjusted the 32-bit estimate, now we need to adjust the final
146 // 64-bit reciprocal estimate downward to ensure that it is strictly smaller146 // 64-bit reciprocal estimate downward to ensure that it is strictly smaller
lib/compiler_rt/divsf3.zig+7-7
...@@ -126,12 +126,12 @@ pub fn div_f32(a: f32, b: f32) f32 {...@@ -126,12 +126,12 @@ pub fn div_f32(a: f32, b: f32) f32 {
126 // with each iteration, so after three iterations, we have about 28 binary126 // with each iteration, so after three iterations, we have about 28 binary
127 // digits of accuracy.127 // digits of accuracy.
128 var correction: u32 = undefined;128 var correction: u32 = undefined;
129 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);129 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
130 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);130 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
131 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);131 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
132 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);132 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
133 correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1);133 correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1);
134 reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31);134 reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31);
135135
136 // Exhaustive testing shows that the error in reciprocal after three steps136 // Exhaustive testing shows that the error in reciprocal after three steps
137 // is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our137 // is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our
...@@ -153,7 +153,7 @@ pub fn div_f32(a: f32, b: f32) f32 {...@@ -153,7 +153,7 @@ pub fn div_f32(a: f32, b: f32) f32 {
153 // is the error in the reciprocal of b scaled by the maximum153 // is the error in the reciprocal of b scaled by the maximum
154 // possible value of a. As a consequence of this error bound,154 // possible value of a. As a consequence of this error bound,
155 // either q or nextafter(q) is the correctly rounded155 // either q or nextafter(q) is the correctly rounded
156 var quotient: Z = @truncate(@as(u64, reciprocal) *% (aSignificand << 1) >> 32);156 var quotient: Z = @truncate((@as(u64, reciprocal) *% (aSignificand << 1)) >> 32);
157157
158 // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).158 // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
159 // In either case, we are going to compute a residual of the form159 // In either case, we are going to compute a residual of the form
lib/compiler_rt/divtf3.zig+10-10
...@@ -119,16 +119,16 @@ pub fn div_f128(a: f128, b: f128) f128 {...@@ -119,16 +119,16 @@ pub fn div_f128(a: f128, b: f128) f128 {
119 // This doubles the number of correct binary digits in the approximation119 // This doubles the number of correct binary digits in the approximation
120 // with each iteration.120 // with each iteration.
121 var correction64: u64 = undefined;121 var correction64: u64 = undefined;
122 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);122 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
123 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);123 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
124 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);124 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
125 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);125 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
126 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);126 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
127 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);127 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
128 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);128 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
129 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);129 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
130 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);130 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
131 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);131 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
132132
133 // The reciprocal may have overflowed to zero if the upper half of b is133 // The reciprocal may have overflowed to zero if the upper half of b is
134 // exactly 1.0. This would sabatoge the full-width final stage of the134 // exactly 1.0. This would sabatoge the full-width final stage of the
lib/compiler_rt/divxf3.zig+10-10
...@@ -102,16 +102,16 @@ pub fn div_f80(a: f80, b: f80) f80 {...@@ -102,16 +102,16 @@ pub fn div_f80(a: f80, b: f80) f80 {
102 // This doubles the number of correct binary digits in the approximation102 // This doubles the number of correct binary digits in the approximation
103 // with each iteration.103 // with each iteration.
104 var correction64: u64 = undefined;104 var correction64: u64 = undefined;
105 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);105 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
106 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);106 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
107 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);107 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
108 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);108 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
109 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);109 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
110 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);110 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
111 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);111 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
112 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);112 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
113 correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1);113 correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1);
114 recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63);114 recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63);
115115
116 // The reciprocal may have overflowed to zero if the upper half of b is116 // The reciprocal may have overflowed to zero if the upper half of b is
117 // exactly 1.0. This would sabatoge the full-width final stage of the117 // exactly 1.0. This would sabatoge the full-width final stage of the
lib/compiler_rt/elf/tls.zig+1-1
...@@ -251,7 +251,7 @@ fn setThreadPointer(addr: usize) void {...@@ -251,7 +251,7 @@ fn setThreadPointer(addr: usize) void {
251 // Update the %gs selector251 // Update the %gs selector
252 asm volatile ("movl %[gs_val], %%gs"252 asm volatile ("movl %[gs_val], %%gs"
253 :253 :
254 : [gs_val] "r" (gdt_entry_number << 3 | 3),254 : [gs_val] "r" ((gdt_entry_number << 3) | 3),
255 );255 );
256 },256 },
257 .x86_64 => {257 .x86_64 => {
lib/compiler_rt/extendf.zig+2-2
...@@ -165,7 +165,7 @@ pub fn f128_floatCast_f80(a: f80) f128 {...@@ -165,7 +165,7 @@ pub fn f128_floatCast_f80(a: f80) f128 {
165 }165 }
166166
167 // Apply the signbit to (dst_t)abs(a).167 // Apply the signbit to (dst_t)abs(a).
168 const result: u128 = abs_result | @as(u128, sign) << (dst_bits - 16);168 const result: u128 = abs_result | (@as(u128, sign) << (dst_bits - 16));
169 return @bitCast(result);169 return @bitCast(result);
170}170}
171171
...@@ -232,7 +232,7 @@ inline fn extendf(comptime dst_t: type, comptime src_t: type, f: src_t) dst_t {...@@ -232,7 +232,7 @@ inline fn extendf(comptime dst_t: type, comptime src_t: type, f: src_t) dst_t {
232 }232 }
233233
234 // Apply the signbit to (dst_t)abs(a).234 // Apply the signbit to (dst_t)abs(a).
235 const result: dst_rep_t = absResult | @as(dst_rep_t, sign) << (dstBits - srcBits);235 const result: dst_rep_t = absResult | (@as(dst_rep_t, sign) << (dstBits - srcBits));
236 return @bitCast(result);236 return @bitCast(result);
237}237}
238238
lib/compiler_rt/floor_ceil.zig+4-4
...@@ -141,13 +141,13 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {...@@ -141,13 +141,13 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
141 const m = (@as(U, 1) << @intCast(mantissa - e)) - 1;141 const m = (@as(U, 1) << @intCast(mantissa - e)) - 1;
142 if (u & m == 0) return x;142 if (u & m == 0) return x;
143 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);143 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
144 if (u >> bits - 1 == @intFromBool(op == .floor)) u += m;144 if (u >> (bits - 1) == @intFromBool(op == .floor)) u += m;
145 return @bitCast(u & ~m);145 return @bitCast(u & ~m);
146 } else {146 } else {
147 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);147 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120);
148 return switch (op) {148 return switch (op) {
149 .floor => if (u >> bits - 1 == 0) 0.0 else if (u << 1 != 0) -1.0 else x,149 .floor => if (u >> (bits - 1) == 0) 0.0 else if (u << 1 != 0) -1.0 else x,
150 .ceil => if (u >> bits - 1 != 0) -0.0 else if (u << 1 != 0) 1.0 else x,150 .ceil => if (u >> (bits - 1) != 0) -0.0 else if (u << 1 != 0) 1.0 else x,
151 };151 };
152 }152 }
153 },153 },
...@@ -155,7 +155,7 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {...@@ -155,7 +155,7 @@ inline fn impl(comptime T: type, comptime op: enum { floor, ceil }, x: T) T {
155 const e = (u >> mantissa) & mask;155 const e = (u >> mantissa) & mask;
156 if (e >= bias + math.floatFractionalBits(T) or x == 0) return x;156 if (e >= bias + math.floatFractionalBits(T) or x == 0) return x;
157157
158 const positive = u >> @bitSizeOf(T) - 1 == 0;158 const positive = u >> (@bitSizeOf(T) - 1) == 0;
159 const y: T = if (positive)159 const y: T = if (positive)
160 x + C - C - x160 x + C - C - x
161 else161 else
lib/compiler_rt/fmod.zig+2-2
...@@ -204,8 +204,8 @@ pub fn fmod_f128(a: f128, b: f128) f128 {...@@ -204,8 +204,8 @@ pub fn fmod_f128(a: f128, b: f128) f128 {
204 }204 }
205205
206 // OR in extra non-stored mantissa digit206 // OR in extra non-stored mantissa digit
207 var highA: u64 = (aPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | 1 << 48;207 var highA: u64 = (aPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | (1 << 48);
208 const highB: u64 = (bPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | 1 << 48;208 const highB: u64 = (bPtr_u64[high_index] & (std.math.maxInt(u64) >> 16)) | (1 << 48);
209 var lowA: u64 = aPtr_u64[low_index];209 var lowA: u64 = aPtr_u64[low_index];
210 const lowB: u64 = bPtr_u64[low_index];210 const lowB: u64 = bPtr_u64[low_index];
211211
lib/compiler_rt/mulf3.zig+1-1
...@@ -237,7 +237,7 @@ fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {...@@ -237,7 +237,7 @@ fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
237 lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count));237 lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count));
238 hi.* = hi.* >> @intCast(count);238 hi.* = hi.* >> @intCast(count);
239 } else if (count < 2 * typeWidth) {239 } else if (count < 2 * typeWidth) {
240 inexact = (hi.* << @intCast(2 * typeWidth -% count) | lo.*) != 0;240 inexact = ((hi.* << @intCast(2 * typeWidth -% count)) | lo.*) != 0;
241 lo.* = hi.* >> @intCast(count -% typeWidth);241 lo.* = hi.* >> @intCast(count -% typeWidth);
242 hi.* = 0;242 hi.* = 0;
243 } else {243 } else {
lib/compiler_rt/rem_pio2l.zig+1-1
...@@ -37,7 +37,7 @@ pub fn rem_pio2l(comptime T: type, x: T, y: *[2]T) i32 {...@@ -37,7 +37,7 @@ pub fn rem_pio2l(comptime T: type, x: T, y: *[2]T) i32 {
37 const se = ld.signExponent(x_val);37 const se = ld.signExponent(x_val);
38 const top = ld.mantissaTop(x_val);38 const top = ld.mantissaTop(x_val);
39 const lhs = (@as(u32, se & 0x7fff) << 16) | top;39 const lhs = (@as(u32, se & 0x7fff) << 16) | top;
40 const rhs: u32 = ((0x3fff + 25) << 16) | 0x921f >> 1 | 0x8000;40 const rhs: u32 = ((0x3fff + 25) << 16) | (0x921f >> 1) | 0x8000;
41 return lhs < rhs;41 return lhs < rhs;
42 }42 }
4343
lib/compiler_rt/sqrt.zig+5-5
...@@ -523,15 +523,15 @@ const rsqrt_tab: [128]u16 = .{...@@ -523,15 +523,15 @@ const rsqrt_tab: [128]u16 = .{
523};523};
524524
525inline fn mul16(a: u16, b: u16) u16 {525inline fn mul16(a: u16, b: u16) u16 {
526 return @intCast(@as(u32, a) * b >> 16);526 return @intCast((@as(u32, a) * b) >> 16);
527}527}
528528
529inline fn mul32(a: u32, b: u32) u32 {529inline fn mul32(a: u32, b: u32) u32 {
530 return @intCast(@as(u64, a) * b >> 32);530 return @intCast((@as(u64, a) * b) >> 32);
531}531}
532532
533inline fn mul64(a: u64, b: u64) u64 {533inline fn mul64(a: u64, b: u64) u64 {
534 return @intCast(@as(u128, a) * b >> 64);534 return @intCast((@as(u128, a) * b) >> 64);
535}535}
536536
537inline fn mul80(a: u80, b: u80) u80 {537inline fn mul80(a: u80, b: u80) u80 {
...@@ -539,7 +539,7 @@ inline fn mul80(a: u80, b: u80) u80 {...@@ -539,7 +539,7 @@ inline fn mul80(a: u80, b: u80) u80 {
539 const alo = a & 0xFF_FFFF_FFFF;539 const alo = a & 0xFF_FFFF_FFFF;
540 const bhi = b >> 40;540 const bhi = b >> 40;
541 const blo = b & 0xFF_FFFF_FFFF;541 const blo = b & 0xFF_FFFF_FFFF;
542 return ahi * bhi + (ahi * blo >> 40) + (alo * bhi >> 40);542 return ahi * bhi + ((ahi * blo) >> 40) + ((alo * bhi) >> 40);
543}543}
544544
545inline fn mul128(a: u128, b: u128) u128 {545inline fn mul128(a: u128, b: u128) u128 {
...@@ -547,7 +547,7 @@ inline fn mul128(a: u128, b: u128) u128 {...@@ -547,7 +547,7 @@ inline fn mul128(a: u128, b: u128) u128 {
547 const alo = a & 0xFFFF_FFFF_FFFF_FFFF;547 const alo = a & 0xFFFF_FFFF_FFFF_FFFF;
548 const bhi = b >> 64;548 const bhi = b >> 64;
549 const blo = b & 0xFFFF_FFFF_FFFF_FFFF;549 const blo = b & 0xFFFF_FFFF_FFFF_FFFF;
550 return ahi * bhi + (ahi * blo >> 64) + (alo * bhi >> 64);550 return ahi * bhi + ((ahi * blo) >> 64) + ((alo * bhi) >> 64);
551}551}
552552
553inline fn mul80_tail(a: u80, b: u80) u80 {553inline fn mul80_tail(a: u80, b: u80) u80 {
lib/compiler_rt/truncf.zig+3-3
...@@ -279,7 +279,7 @@ inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {...@@ -279,7 +279,7 @@ inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
279 absResult = 0;279 absResult = 0;
280 } else {280 } else {
281 const sticky: src_rep_t = @intFromBool(significand << @intCast(srcBits - shift) != 0);281 const sticky: src_rep_t = @intFromBool(significand << @intCast(srcBits - shift) != 0);
282 const denormalizedSignificand: src_rep_t = significand >> @intCast(shift) | sticky;282 const denormalizedSignificand: src_rep_t = (significand >> @intCast(shift)) | sticky;
283 absResult = @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits));283 absResult = @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits));
284 const roundBits: src_rep_t = denormalizedSignificand & roundMask;284 const roundBits: src_rep_t = denormalizedSignificand & roundMask;
285 if (roundBits > halfway) {285 if (roundBits > halfway) {
...@@ -362,7 +362,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {...@@ -362,7 +362,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
362 abs_result = 0;362 abs_result = 0;
363 } else {363 } else {
364 const sticky = @intFromBool(a_rep.fraction << @intCast(shift) != 0);364 const sticky = @intFromBool(a_rep.fraction << @intCast(shift) != 0);
365 const denormalized_significand = a_rep.fraction >> @intCast(shift) | sticky;365 const denormalized_significand = (a_rep.fraction >> @intCast(shift)) | sticky;
366 abs_result = @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits));366 abs_result = @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits));
367 const round_bits = denormalized_significand & round_mask;367 const round_bits = denormalized_significand & round_mask;
368 if (round_bits > halfway) {368 if (round_bits > halfway) {
...@@ -375,7 +375,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {...@@ -375,7 +375,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
375 }375 }
376 }376 }
377377
378 const result align(@alignOf(dst_t)) = abs_result | @as(dst_rep_t, sign) << dst_bits - 16;378 const result align(@alignOf(dst_t)) = abs_result | (@as(dst_rep_t, sign) << (dst_bits - 16));
379 return @bitCast(result);379 return @bitCast(result);
380}380}
381381
lib/std/Io/Dispatch.zig+2-2
...@@ -1931,10 +1931,10 @@ const BatchWaiter = struct {...@@ -1931,10 +1931,10 @@ const BatchWaiter = struct {
19311931
1932fn batchAwaitAsync(userdata: ?*anyopaque, batch: *Io.Batch) Io.Cancelable!void {1932fn batchAwaitAsync(userdata: ?*anyopaque, batch: *Io.Batch) Io.Cancelable!void {
1933 const ev: *Evented = @ptrCast(@alignCast(userdata));1933 const ev: *Evented = @ptrCast(@alignCast(userdata));
1934 const queue = ev.batchDrainSubmitted(batch, false) catch |err| switch (err) {1934 const queue = (ev.batchDrainSubmitted(batch, false) catch |err| switch (err) {
1935 error.ConcurrencyUnavailable => unreachable, // passed concurrency=false1935 error.ConcurrencyUnavailable => unreachable, // passed concurrency=false
1936 error.Canceled => |e| return e,1936 error.Canceled => |e| return e,
1937 } orelse return;1937 }) orelse return;
1938 if (batch.pending.head == .none) return;1938 if (batch.pending.head == .none) return;
1939 var waiter: BatchWaiter = .{1939 var waiter: BatchWaiter = .{
1940 .sleeper = .init(ev.queue, Thread.current().currentFiber()),1940 .sleeper = .init(ev.queue, Thread.current().currentFiber()),
lib/std/Io/Kqueue.zig+1-1
...@@ -164,7 +164,7 @@ pub const InitError = Allocator.Error || CreateFileDescriptorError;...@@ -164,7 +164,7 @@ pub const InitError = Allocator.Error || CreateFileDescriptorError;
164pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {164pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
165 assert(options.n_threads != 0);165 assert(options.n_threads != 0);
166166
167 const n_threads = @max(1, options.n_threads orelse std.Thread.getCpuCount() catch 1);167 const n_threads = @max(1, options.n_threads orelse (std.Thread.getCpuCount() catch 1));
168 const threads_size = n_threads * @sizeOf(Thread);168 const threads_size = n_threads * @sizeOf(Thread);
169 const idle_stack_end_offset = std.mem.alignForward(usize, threads_size + idle_stack_size, std.heap.page_size_max);169 const idle_stack_end_offset = std.mem.alignForward(usize, threads_size + idle_stack_size, std.heap.page_size_max);
170 const allocated_slice = try gpa.alignedAlloc(u8, .of(Thread), idle_stack_end_offset);170 const allocated_slice = try gpa.alignedAlloc(u8, .of(Thread), idle_stack_end_offset);
lib/std/Io/Threaded/test.zig+1-1
...@@ -36,7 +36,7 @@ fn put(io: Io, queue: *Io.Queue(u8)) void {...@@ -36,7 +36,7 @@ fn put(io: Io, queue: *Io.Queue(u8)) void {
36}36}
3737
38fn get(io: Io, queue: *Io.Queue(u8)) void {38fn get(io: Io, queue: *Io.Queue(u8)) void {
39 assert(queue.getOneUncancelable(io) catch unreachable == 42);39 assert((queue.getOneUncancelable(io) catch unreachable) == 42);
40}40}
4141
42test "concurrent vs concurrent prevents deadlock via oversubscription" {42test "concurrent vs concurrent prevents deadlock via oversubscription" {
lib/std/Io/Writer.zig+1-1
...@@ -1827,7 +1827,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi...@@ -1827,7 +1827,7 @@ pub fn printFloatHex(w: *Writer, value: anytype, case: std.fmt.Case, opt_precisi
1827 // Restore the alignment.1827 // Restore the alignment.
1828 mantissa <<= @as(std.math.Log2Int(TU), @intCast((mantissa_digits - precision) * 4));1828 mantissa <<= @as(std.math.Log2Int(TU), @intCast((mantissa_digits - precision) * 4));
18291829
1830 const overflow = mantissa & (1 << 1 + mantissa_digits * 4) != 0;1830 const overflow = mantissa & (1 << (1 + mantissa_digits * 4)) != 0;
1831 // Prefer a normalized result in case of overflow.1831 // Prefer a normalized result in case of overflow.
1832 if (overflow) {1832 if (overflow) {
1833 mantissa >>= 1;1833 mantissa >>= 1;
lib/std/Io/net/HostName.zig+1-1
...@@ -230,7 +230,7 @@ pub fn expand(noalias packet: []const u8, start_i: usize, noalias dest_buffer: [...@@ -230,7 +230,7 @@ pub fn expand(noalias packet: []const u8, start_i: usize, noalias dest_buffer: [
230 i += 1 + label_len;230 i += 1 + label_len;
231 } else {231 } else {
232 return .{232 return .{
233 len orelse i - start_i + 1,233 len orelse (i - start_i + 1),
234 try .init(dest[0..dest_i]),234 try .init(dest[0..dest_i]),
235 };235 };
236 }236 }
lib/std/base64.zig+3-3
...@@ -148,7 +148,7 @@ pub const Base64Encoder = struct {...@@ -148,7 +148,7 @@ pub const Base64Encoder = struct {
148 if (idx + 2 < source.len) {148 if (idx + 2 < source.len) {
149 dest[out_idx] = encoder.alphabet_chars[source[idx] >> 2];149 dest[out_idx] = encoder.alphabet_chars[source[idx] >> 2];
150 dest[out_idx + 1] = encoder.alphabet_chars[((source[idx] & 0x3) << 4) | (source[idx + 1] >> 4)];150 dest[out_idx + 1] = encoder.alphabet_chars[((source[idx] & 0x3) << 4) | (source[idx + 1] >> 4)];
151 dest[out_idx + 2] = encoder.alphabet_chars[(source[idx + 1] & 0xf) << 2 | (source[idx + 2] >> 6)];151 dest[out_idx + 2] = encoder.alphabet_chars[((source[idx + 1] & 0xf) << 2) | (source[idx + 2] >> 6)];
152 dest[out_idx + 3] = encoder.alphabet_chars[source[idx + 2] & 0x3f];152 dest[out_idx + 3] = encoder.alphabet_chars[source[idx + 2] & 0x3f];
153 out_idx += 4;153 out_idx += 4;
154 } else if (idx + 1 < source.len) {154 } else if (idx + 1 < source.len) {
...@@ -282,7 +282,7 @@ pub const Base64Decoder = struct {...@@ -282,7 +282,7 @@ pub const Base64Decoder = struct {
282 dest_idx += 1;282 dest_idx += 1;
283 }283 }
284 }284 }
285 if (acc_len > 4 or (acc & (@as(u12, 1) << acc_len) - 1) != 0) {285 if (acc_len > 4 or (acc & ((@as(u12, 1) << acc_len) - 1)) != 0) {
286 return error.InvalidPadding;286 return error.InvalidPadding;
287 }287 }
288 if (leftover_idx == null) return;288 if (leftover_idx == null) return;
...@@ -357,7 +357,7 @@ pub const Base64DecoderWithIgnore = struct {...@@ -357,7 +357,7 @@ pub const Base64DecoderWithIgnore = struct {
357 dest_idx += 1;357 dest_idx += 1;
358 }358 }
359 }359 }
360 if (acc_len > 4 or (acc & (@as(u12, 1) << acc_len) - 1) != 0) {360 if (acc_len > 4 or (acc & ((@as(u12, 1) << acc_len) - 1)) != 0) {
361 return error.InvalidPadding;361 return error.InvalidPadding;
362 }362 }
363 const padding_len = acc_len / 2;363 const padding_len = acc_len / 2;
lib/std/bit_set.zig+4-4
...@@ -468,11 +468,11 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {...@@ -468,11 +468,11 @@ pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
468468
469 if (start_mask_index == end_mask_index) {469 if (start_mask_index == end_mask_index) {
470 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;470 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;
471 var mask2 = std.math.boolMask(MaskInt, true) >> (mask_len - 1) - (end_bit - 1);471 var mask2 = std.math.boolMask(MaskInt, true) >> ((mask_len - 1) - (end_bit - 1));
472 self.masks[start_mask_index] &= ~(mask1 & mask2);472 self.masks[start_mask_index] &= ~(mask1 & mask2);
473473
474 mask1 = std.math.boolMask(MaskInt, value) << start_bit;474 mask1 = std.math.boolMask(MaskInt, value) << start_bit;
475 mask2 = std.math.boolMask(MaskInt, value) >> (mask_len - 1) - (end_bit - 1);475 mask2 = std.math.boolMask(MaskInt, value) >> ((mask_len - 1) - (end_bit - 1));
476 self.masks[start_mask_index] |= mask1 & mask2;476 self.masks[start_mask_index] |= mask1 & mask2;
477 } else {477 } else {
478 var bulk_mask_index: usize = undefined;478 var bulk_mask_index: usize = undefined;
...@@ -875,11 +875,11 @@ pub const Dynamic = struct {...@@ -875,11 +875,11 @@ pub const Dynamic = struct {
875875
876 if (start_mask_index == end_mask_index) {876 if (start_mask_index == end_mask_index) {
877 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;877 var mask1 = std.math.boolMask(MaskInt, true) << start_bit;
878 var mask2 = std.math.boolMask(MaskInt, true) >> (@bitSizeOf(MaskInt) - 1) - (end_bit - 1);878 var mask2 = std.math.boolMask(MaskInt, true) >> ((@bitSizeOf(MaskInt) - 1) - (end_bit - 1));
879 self.masks[start_mask_index] &= ~(mask1 & mask2);879 self.masks[start_mask_index] &= ~(mask1 & mask2);
880880
881 mask1 = std.math.boolMask(MaskInt, value) << start_bit;881 mask1 = std.math.boolMask(MaskInt, value) << start_bit;
882 mask2 = std.math.boolMask(MaskInt, value) >> (@bitSizeOf(MaskInt) - 1) - (end_bit - 1);882 mask2 = std.math.boolMask(MaskInt, value) >> ((@bitSizeOf(MaskInt) - 1) - (end_bit - 1));
883 self.masks[start_mask_index] |= mask1 & mask2;883 self.masks[start_mask_index] |= mask1 & mask2;
884 } else {884 } else {
885 var bulk_mask_index: usize = undefined;885 var bulk_mask_index: usize = undefined;
lib/std/coff.zig+1-1
...@@ -2035,7 +2035,7 @@ pub const ArchiveMemberHeader = extern struct {...@@ -2035,7 +2035,7 @@ pub const ArchiveMemberHeader = extern struct {
2035 if (trim.len == 0) return error.BadName;2035 if (trim.len == 0) return error.BadName;
2036 return if (trim[0] == '/') name: {2036 return if (trim[0] == '/') name: {
2037 if (trim.len == 1 or2037 if (trim.len == 1 or
2038 trim.len == 2 and trim[1] == '/')2038 (trim.len == 2 and trim[1] == '/'))
2039 break :name trim;2039 break :name trim;
20402040
2041 const offset = std.fmt.parseUnsigned(u50, trim[1..], 10) catch2041 const offset = std.fmt.parseUnsigned(u50, trim[1..], 10) catch
lib/std/compress/flate/Compress.zig+2-2
...@@ -1333,8 +1333,8 @@ const huffman = struct {...@@ -1333,8 +1333,8 @@ const huffman = struct {
13331333
1334 const incomplete_allowed = smith.value(bool);1334 const incomplete_allowed = smith.value(bool);
1335 while (nfreqs < @as(u8, @intFromBool(!incomplete_allowed)) + 1 or1335 while (nfreqs < @as(u8, @intFromBool(!incomplete_allowed)) + 1 or
1336 nfreqs != freqs_buf.len and freqs_limit != 0 and1336 (nfreqs != freqs_buf.len and freqs_limit != 0 and
1337 smith.eosWeightedSimple(15, 1))1337 smith.eosWeightedSimple(15, 1)))
1338 {1338 {
1339 const f = smith.valueWeighted(u16, &.{1339 const f = smith.valueWeighted(u16, &.{
1340 .rangeAtMost(u16, 0, @min(31, freqs_limit), @max(freqs_limit, 1)),1340 .rangeAtMost(u16, 0, @min(31, freqs_limit), @max(freqs_limit, 1)),
lib/std/crypto/aes/soft.zig+1-1
...@@ -728,7 +728,7 @@ pub const Aes256 = struct {...@@ -728,7 +728,7 @@ pub const Aes256 = struct {
728// constants728// constants
729729
730// Rijndael's irreducible polynomial.730// Rijndael's irreducible polynomial.
731const poly: u9 = 1 << 8 | 1 << 4 | 1 << 3 | 1 << 1 | 1 << 0; // x⁸ + x⁴ + x³ + x + 1731const poly: u9 = (1 << 8) | (1 << 4) | (1 << 3) | (1 << 1) | (1 << 0); // x⁸ + x⁴ + x³ + x + 1
732732
733// Powers of x mod poly in GF(2).733// Powers of x mod poly in GF(2).
734const powx = init: {734const powx = init: {
lib/std/crypto/codecs/base64_hex_ct.zig+1-1
...@@ -29,7 +29,7 @@ pub const hex = struct {...@@ -29,7 +29,7 @@ pub const hex = struct {
29 const c: u16 = v & 0xf;29 const c: u16 = v & 0xf;
30 const off = if (case == .upper) 32 else 0;30 const off = if (case == .upper) 32 else 0;
31 const x =31 const x =
32 ((87 - off + c + (((c -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff) << 8 |32 (((87 - off + c + (((c -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff) << 8) |
33 ((87 - off + b + (((b -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff);33 ((87 - off + b + (((b -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff);
34 encoded[i * 2] = @truncate(x);34 encoded[i * 2] = @truncate(x);
35 encoded[i * 2 + 1] = @truncate(x >> 8);35 encoded[i * 2 + 1] = @truncate(x >> 8);
lib/std/crypto/ml_kem.zig+1-1
...@@ -1264,7 +1264,7 @@ const Poly = struct {...@@ -1264,7 +1264,7 @@ const Poly = struct {
1264 const b1 = @as(i16, buf[3 * i + 1]);1264 const b1 = @as(i16, buf[3 * i + 1]);
1265 const b2 = @as(i16, buf[3 * i + 2]);1265 const b2 = @as(i16, buf[3 * i + 2]);
1266 ret.cs[2 * i] = b0 | ((b1 & 0xf) << 8);1266 ret.cs[2 * i] = b0 | ((b1 & 0xf) << 8);
1267 ret.cs[2 * i + 1] = (b1 >> 4) | b2 << 4;1267 ret.cs[2 * i + 1] = (b1 >> 4) | (b2 << 4);
1268 }1268 }
1269 return ret;1269 return ret;
1270 }1270 }
lib/std/crypto/scrypt.zig+1-1
...@@ -82,7 +82,7 @@ fn blockMix(tmp: *align(16) [16]u32, in: []align(16) const u32, out: []align(16)...@@ -82,7 +82,7 @@ fn blockMix(tmp: *align(16) [16]u32, in: []align(16) const u32, out: []align(16)
8282
83fn integerify(b: []align(16) const u32, r: u30) u64 {83fn integerify(b: []align(16) const u32, r: u30) u64 {
84 const j = (2 * r - 1) * 16;84 const j = (2 * r - 1) * 16;
85 return @as(u64, b[j]) | @as(u64, b[j + 1]) << 32;85 return @as(u64, b[j]) | (@as(u64, b[j + 1]) << 32);
86}86}
8787
88fn smix(b: []align(16) u8, r: u30, n: usize, v: []align(16) u32, xy: []align(16) u32) void {88fn smix(b: []align(16) u8, r: u30, n: usize, v: []align(16) u32, xy: []align(16) u32) void {
lib/std/crypto/sha2.zig+1-1
...@@ -557,7 +557,7 @@ fn Sha2x64(comptime iv: Iv64, digest_bits: comptime_int) type {...@@ -557,7 +557,7 @@ fn Sha2x64(comptime iv: Iv64, digest_bits: comptime_int) type {
557 }557 }
558558
559 if (digest_bits % 8 != 0) @compileError("impl doesn't support non-byte digest_len");559 if (digest_bits % 8 != 0) @compileError("impl doesn't support non-byte digest_len");
560 const bytes_left = digest_bits / 8 % 8;560 const bytes_left = (digest_bits / 8) % 8;
561 if (bytes_left > 0) {561 if (bytes_left > 0) {
562 const rest = d.s[(digest_bits / 64)];562 const rest = d.s[(digest_bits / 64)];
563 var buf: [8]u8 = undefined;563 var buf: [8]u8 = undefined;
lib/std/debug.zig+1-1
...@@ -1306,7 +1306,7 @@ fn printLineInfo(...@@ -1306,7 +1306,7 @@ fn printLineInfo(
1306 try writer.print("0x{x} in {s} ({s})", .{1306 try writer.print("0x{x} in {s} ({s})", .{
1307 address,1307 address,
1308 symbol.name orelse "???",1308 symbol.name orelse "???",
1309 symbol.compile_unit_name orelse debug_info.getModuleName(io, address) catch "???",1309 symbol.compile_unit_name orelse (debug_info.getModuleName(io, address) catch "???"),
1310 });1310 });
1311 t.setColor(.reset) catch {};1311 t.setColor(.reset) catch {};
1312 try writer.writeAll("\n");1312 try writer.writeAll("\n");
lib/std/debug/SelfInfo/Elf.zig+4-4
...@@ -16,11 +16,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {...@@ -16,11 +16,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
16 const gpa = std.debug.getDebugInfoAllocator();16 const gpa = std.debug.getDebugInfoAllocator();
17 for (si.modules.items) |*mod| {17 for (si.modules.items) |*mod| {
18 unwind: {18 unwind: {
19 const u = &(mod.unwind orelse break :unwind catch break :unwind);19 const u = &((mod.unwind orelse break :unwind) catch break :unwind);
20 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);20 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);
21 }21 }
22 loaded: {22 loaded: {
23 const l = &(mod.loaded_elf orelse break :loaded catch break :loaded);23 const l = &((mod.loaded_elf orelse break :loaded) catch break :loaded);
24 l.file.deinit(gpa);24 l.file.deinit(gpa);
25 }25 }
26 }26 }
...@@ -431,11 +431,11 @@ fn findModule(si: *SelfInfo, gpa: Allocator, io: Io, address: usize, lock: enum...@@ -431,11 +431,11 @@ fn findModule(si: *SelfInfo, gpa: Allocator, io: Io, address: usize, lock: enum
431 }431 }
432 for (si.modules.items) |*mod| {432 for (si.modules.items) |*mod| {
433 unwind: {433 unwind: {
434 const u = &(mod.unwind orelse break :unwind catch break :unwind);434 const u = &((mod.unwind orelse break :unwind) catch break :unwind);
435 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);435 for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa);
436 }436 }
437 loaded: {437 loaded: {
438 const l = &(mod.loaded_elf orelse break :loaded catch break :loaded);438 const l = &((mod.loaded_elf orelse break :loaded) catch break :loaded);
439 l.file.deinit(gpa);439 l.file.deinit(gpa);
440 }440 }
441 }441 }
lib/std/debug/SelfInfo/MachO.zig+2-2
...@@ -11,11 +11,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {...@@ -11,11 +11,11 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
11 const gpa = std.debug.getDebugInfoAllocator();11 const gpa = std.debug.getDebugInfoAllocator();
12 for (si.modules.keys()) |*module| {12 for (si.modules.keys()) |*module| {
13 unwind: {13 unwind: {
14 const u = &(module.unwind orelse break :unwind catch break :unwind);14 const u = &((module.unwind orelse break :unwind) catch break :unwind);
15 if (u.dwarf) |*dwarf| dwarf.deinit(gpa);15 if (u.dwarf) |*dwarf| dwarf.deinit(gpa);
16 }16 }
17 file: {17 file: {
18 const f = &(module.file orelse break :file catch break :file);18 const f = &((module.file orelse break :file) catch break :file);
19 f.deinit(gpa);19 f.deinit(gpa);
20 }20 }
21 }21 }
lib/std/debug/SelfInfo/Windows.zig+4-4
...@@ -280,7 +280,7 @@ const Module = struct {...@@ -280,7 +280,7 @@ const Module = struct {
280 // we have no information to add to the address280 // we have no information to add to the address
281 break :pdb;281 break :pdb;
282 };282 };
283 const module = pdb.getModule(mod_index) catch |err| switch (err) {283 const module = (pdb.getModule(mod_index) catch |err| switch (err) {
284 error.InvalidDebugInfo,284 error.InvalidDebugInfo,
285 error.MissingDebugInfo,285 error.MissingDebugInfo,
286 error.OutOfMemory,286 error.OutOfMemory,
...@@ -289,7 +289,7 @@ const Module = struct {...@@ -289,7 +289,7 @@ const Module = struct {
289 error.ReadFailed,289 error.ReadFailed,
290 error.EndOfStream,290 error.EndOfStream,
291 => return error.InvalidDebugInfo,291 => return error.InvalidDebugInfo,
292 } orelse {292 }) orelse {
293 return error.InvalidDebugInfo; // bad module index293 return error.InvalidDebugInfo; // bad module index
294 };294 };
295295
...@@ -539,9 +539,9 @@ const Module = struct {...@@ -539,9 +539,9 @@ const Module = struct {
539 }539 }
540540
541 var opt_pdb: ?Pdb = pdb: {541 var opt_pdb: ?Pdb = pdb: {
542 const path = coff_obj.getPdbPath() catch {542 const path = (coff_obj.getPdbPath() catch {
543 return error.InvalidDebugInfo;543 return error.InvalidDebugInfo;
544 } orelse {544 }) orelse {
545 break :pdb null;545 break :pdb null;
546 };546 };
547 const pdb_file_open_result = if (fs.path.isAbsolute(path)) res: {547 const pdb_file_open_result = if (fs.path.isAbsolute(path)) res: {
lib/std/dynamic_library.zig+7-7
...@@ -13,7 +13,7 @@ const posix = std.posix;...@@ -13,7 +13,7 @@ const posix = std.posix;
13/// Platform-specific functionality is available through the `inner` field.13/// Platform-specific functionality is available through the `inner` field.
14pub const DynLib = struct {14pub const DynLib = struct {
15 const InnerType = switch (native_os) {15 const InnerType = switch (native_os) {
16 .linux => if (!builtin.link_libc or builtin.abi == .musl and builtin.link_mode == .static)16 .linux => if (!builtin.link_libc or (builtin.abi == .musl and builtin.link_mode == .static))
17 ElfDynLib17 ElfDynLib
18 else18 else
19 DlDynLib,19 DlDynLib,
...@@ -434,15 +434,15 @@ pub const ElfDynLib = struct {...@@ -434,15 +434,15 @@ pub const ElfDynLib = struct {
434 pub fn lookupAddress(self: *const ElfDynLib, vername: []const u8, name: []const u8) ?usize {434 pub fn lookupAddress(self: *const ElfDynLib, vername: []const u8, name: []const u8) ?usize {
435 const maybe_versym = if (self.verdef == null) null else self.versym;435 const maybe_versym = if (self.verdef == null) null else self.versym;
436436
437 const OK_TYPES = (1 << elf.STT_NOTYPE | 1 << elf.STT_OBJECT | 1 << elf.STT_FUNC | 1 << elf.STT_COMMON);437 const OK_TYPES = (1 << elf.STT_NOTYPE) | (1 << elf.STT_OBJECT) | (1 << elf.STT_FUNC) | (1 << elf.STT_COMMON);
438 const OK_BINDS = (1 << elf.STB_GLOBAL | 1 << elf.STB_WEAK | 1 << elf.STB_GNU_UNIQUE);438 const OK_BINDS = (1 << elf.STB_GLOBAL) | (1 << elf.STB_WEAK) | (1 << elf.STB_GNU_UNIQUE);
439439
440 switch (self.hash_table) {440 switch (self.hash_table) {
441 .dt_hash => |hashtab| {441 .dt_hash => |hashtab| {
442 var i: usize = 0;442 var i: usize = 0;
443 while (i < hashtab[1]) : (i += 1) {443 while (i < hashtab[1]) : (i += 1) {
444 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info & 0xf)) & OK_TYPES)) continue;444 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info & 0xf))) & OK_TYPES) continue;
445 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info >> 4)) & OK_BINDS)) continue;445 if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info >> 4))) & OK_BINDS) continue;
446 if (0 == self.syms[i].st_shndx) continue;446 if (0 == self.syms[i].st_shndx) continue;
447 if (!mem.eql(u8, name, mem.sliceTo(self.strings + self.syms[i].st_name, 0))) continue;447 if (!mem.eql(u8, name, mem.sliceTo(self.strings + self.syms[i].st_name, 0))) continue;
448 if (maybe_versym) |versym| {448 if (maybe_versym) |versym| {
...@@ -494,8 +494,8 @@ pub const ElfDynLib = struct {...@@ -494,8 +494,8 @@ pub const ElfDynLib = struct {
494 const symbol_index = current_index + gnu_hash_header.symoffset;494 const symbol_index = current_index + gnu_hash_header.symoffset;
495 const symbol = self.syms[symbol_index];495 const symbol = self.syms[symbol_index];
496496
497 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info & 0xf)) & OK_TYPES)) continue;497 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info & 0xf))) & OK_TYPES) continue;
498 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info >> 4)) & OK_BINDS)) continue;498 if (0 == (@as(u32, 1) << @as(u5, @intCast(symbol.st_info >> 4))) & OK_BINDS) continue;
499 if (0 == symbol.st_shndx) continue;499 if (0 == symbol.st_shndx) continue;
500500
501 const symbol_name = mem.sliceTo(self.strings + symbol.st_name, 0);501 const symbol_name = mem.sliceTo(self.strings + symbol.st_name, 0);
lib/std/fmt/parse_float/common.zig+1-1
...@@ -82,7 +82,7 @@ pub fn isDigit(c: u8, comptime base: u8) bool {...@@ -82,7 +82,7 @@ pub fn isDigit(c: u8, comptime base: u8) bool {
82 return if (base == 10)82 return if (base == 10)
83 '0' <= c and c <= '9'83 '0' <= c and c <= '9'
84 else84 else
85 '0' <= c and c <= '9' or 'a' <= c and c <= 'f' or 'A' <= c and c <= 'F';85 ('0' <= c and c <= '9') or ('a' <= c and c <= 'f') or ('A' <= c and c <= 'F');
86}86}
8787
88/// Returns the underlying storage type used for the mantissa of floating-point type.88/// Returns the underlying storage type used for the mantissa of floating-point type.
lib/std/hash/cityhash.zig+1-1
...@@ -222,7 +222,7 @@ pub const CityHash64 = struct {...@@ -222,7 +222,7 @@ pub const CityHash64 = struct {
222 const c: u8 = str[str.len - 1];222 const c: u8 = str[str.len - 1];
223 const y: u32 = @as(u32, @intCast(a)) +% (@as(u32, @intCast(b)) << 8);223 const y: u32 = @as(u32, @intCast(a)) +% (@as(u32, @intCast(b)) << 8);
224 const z: u32 = @as(u32, @truncate(str.len)) +% (@as(u32, @intCast(c)) << 2);224 const z: u32 = @as(u32, @truncate(str.len)) +% (@as(u32, @intCast(c)) << 2);
225 return shiftmix(@as(u64, @intCast(y)) *% k2 ^ @as(u64, @intCast(z)) *% k0) *% k2;225 return shiftmix((@as(u64, @intCast(y)) *% k2) ^ (@as(u64, @intCast(z)) *% k0)) *% k2;
226 }226 }
227 return k2;227 return k2;
228 }228 }
lib/std/hash/xxhash.zig+1-1
...@@ -398,7 +398,7 @@ pub const XxHash32 = struct {...@@ -398,7 +398,7 @@ pub const XxHash32 = struct {
398 }398 }
399399
400 fn avalanche(value: u32) u32 {400 fn avalanche(value: u32) u32 {
401 var acc = value ^ value >> 15;401 var acc = value ^ (value >> 15);
402 acc *%= prime_2;402 acc *%= prime_2;
403 acc ^= acc >> 13;403 acc ^= acc >> 13;
404 acc *%= prime_3;404 acc *%= prime_3;
lib/std/hash_map.zig+1-1
...@@ -2019,7 +2019,7 @@ test "getOrPutAdapted" {...@@ -2019,7 +2019,7 @@ test "getOrPutAdapted" {
2019 const AdaptedContext = struct {2019 const AdaptedContext = struct {
2020 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {2020 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {
2021 _ = self;2021 _ = self;
2022 return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key;2022 return (std.fmt.parseInt(u64, adapted_key, 10) catch unreachable) == test_key;
2023 }2023 }
2024 fn hash(self: @This(), adapted_key: []const u8) u64 {2024 fn hash(self: @This(), adapted_key: []const u8) u64 {
2025 _ = self;2025 _ = self;
lib/std/heap/SafeAllocator.zig+1-1
...@@ -211,7 +211,7 @@ const Bucket = struct {...@@ -211,7 +211,7 @@ const Bucket = struct {
211211
212 fn of(s: *SafeAllocator, ptr: [*]u8) *Bucket {212 fn of(s: *SafeAllocator, ptr: [*]u8) *Bucket {
213 const size_log2 = s.bucket_size_log2;213 const size_log2 = s.bucket_size_log2;
214 return @ptrFromInt(@intFromPtr(ptr) >> @intCast(size_log2) << @intCast(size_log2));214 return @ptrFromInt((@intFromPtr(ptr) >> @intCast(size_log2)) << @intCast(size_log2));
215 }215 }
216216
217 fn fillAt(s: *SafeAllocator, ptr: [*]const u8) u32 {217 fn fillAt(s: *SafeAllocator, ptr: [*]const u8) u32 {
lib/std/math.zig+14-14
...@@ -710,7 +710,7 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T {...@@ -710,7 +710,7 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T {
710710
711 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {711 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
712 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));712 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
713 return x >> ar | x << (1 +% ~ar);713 return (x >> ar) | (x << (1 +% ~ar));
714 } else {714 } else {
715 const ar = @mod(r, @typeInfo(T).int.bits);715 const ar = @mod(r, @typeInfo(T).int.bits);
716 return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar);716 return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar);
...@@ -753,7 +753,7 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T {...@@ -753,7 +753,7 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T {
753753
754 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {754 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
755 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));755 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
756 return x << ar | x >> 1 +% ~ar;756 return (x << ar) | (x >> (1 +% ~ar));
757 } else {757 } else {
758 const ar = @mod(r, @typeInfo(T).int.bits);758 const ar = @mod(r, @typeInfo(T).int.bits);
759 return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar);759 return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar);
...@@ -1542,21 +1542,21 @@ pub const Order = enum {...@@ -1542,21 +1542,21 @@ pub const Order = enum {
1542 const neg: i32 = -1;1542 const neg: i32 = -1;
1543 const zero: i32 = 0;1543 const zero: i32 = 0;
1544 const pos: i32 = 1;1544 const pos: i32 = 1;
1545 try testing.expect(order(zero, neg).differ() orelse1545 try testing.expect((order(zero, neg).differ() orelse
1546 order(pos, zero) == .gt);1546 order(pos, zero)) == .gt);
1547 try testing.expect(order(zero, zero).differ() orelse1547 try testing.expect((order(zero, zero).differ() orelse
1548 order(zero, zero) == .eq);1548 order(zero, zero)) == .eq);
1549 try testing.expect(order(pos, pos).differ() orelse1549 try testing.expect((order(pos, pos).differ() orelse
1550 order(neg, zero) == .lt);1550 order(neg, zero)) == .lt);
1551 try testing.expect(order(zero, zero).differ() orelse1551 try testing.expect((order(zero, zero).differ() orelse
1552 order(pos, neg).differ() orelse1552 order(pos, neg).differ() orelse
1553 order(neg, zero) == .gt);1553 order(neg, zero)) == .gt);
1554 try testing.expect(order(pos, pos).differ() orelse1554 try testing.expect((order(pos, pos).differ() orelse
1555 order(pos, pos).differ() orelse1555 order(pos, pos).differ() orelse
1556 order(neg, neg) == .eq);1556 order(neg, neg)) == .eq);
1557 try testing.expect(order(zero, pos).differ() orelse1557 try testing.expect((order(zero, pos).differ() orelse
1558 order(neg, pos).differ() orelse1558 order(neg, pos).differ() orelse
1559 order(pos, neg) == .lt);1559 order(pos, neg)) == .lt);
1560 }1560 }
15611561
1562 pub fn compare(self: Order, op: CompareOperator) bool {1562 pub fn compare(self: Order, op: CompareOperator) bool {
lib/std/math/acos.zig+1-1
...@@ -176,7 +176,7 @@ fn acosBinary64(x: f64) f64 {...@@ -176,7 +176,7 @@ fn acosBinary64(x: f64) f64 {
176 // |x| >= 1 or nan176 // |x| >= 1 or nan
177 if (ix >= 0x3ff0_0000) {177 if (ix >= 0x3ff0_0000) {
178 const lx: u32 = @truncate(@as(u64, @bitCast(x)));178 const lx: u32 = @truncate(@as(u64, @bitCast(x)));
179 if ((ix - 0x3ff0_0000 | lx) == 0) {179 if (((ix - 0x3ff0_0000) | lx) == 0) {
180 if (hx >> 31 != 0) {180 if (hx >> 31 != 0) {
181 return 2.0 * pio2_hi + 0x1.0p-120;181 return 2.0 * pio2_hi + 0x1.0p-120;
182 }182 }
lib/std/math/asin.zig+1-1
...@@ -156,7 +156,7 @@ fn asinBinary64(x: f64) f64 {...@@ -156,7 +156,7 @@ fn asinBinary64(x: f64) f64 {
156 if (ix >= 0x3ff0_0000) {156 if (ix >= 0x3ff0_0000) {
157 const lx: u32 = @truncate(@as(u64, @bitCast(x)));157 const lx: u32 = @truncate(@as(u64, @bitCast(x)));
158 // asin(1) = +-pi/2 with inexact158 // asin(1) = +-pi/2 with inexact
159 if ((ix - 0x3ff0_0000 | lx) == 0) {159 if (((ix - 0x3ff0_0000) | lx) == 0) {
160 return x * pio2_hi + 0x1.0p-120;160 return x * pio2_hi + 0x1.0p-120;
161 }161 }
162 return 0.0 / (x - x);162 return 0.0 / (x - x);
lib/std/math/big/int.zig+3-3
...@@ -2401,7 +2401,7 @@ pub const Const = struct {...@@ -2401,7 +2401,7 @@ pub const Const = struct {
2401 const shift: usize = @intCast(exponent - @bitSizeOf(Repr.Normalized.Fraction));2401 const shift: usize = @intCast(exponent - @bitSizeOf(Repr.Normalized.Fraction));
2402 mantissa.shiftRight(normalized_abs, shift);2402 mantissa.shiftRight(normalized_abs, shift);
2403 const final_limb_index = (shift - 1) / limb_bits;2403 const final_limb_index = (shift - 1) / limb_bits;
2404 const round_bits = normalized_abs.limbs[final_limb_index] << @truncate(-%shift) |2404 const round_bits = (normalized_abs.limbs[final_limb_index] << @truncate(-%shift)) |
2405 @intFromBool(!std.mem.allEqual(Limb, normalized_abs.limbs[0..final_limb_index], 0));2405 @intFromBool(!std.mem.allEqual(Limb, normalized_abs.limbs[0..final_limb_index], 0));
2406 if (round_bits == 0) break :exactness .exact;2406 if (round_bits == 0) break :exactness .exact;
2407 round: switch (round) {2407 round: switch (round) {
...@@ -4902,10 +4902,10 @@ test "format" {...@@ -4902,10 +4902,10 @@ test "format" {
4902 try a.set(20000000000000000000); // > maxInt(u64)4902 try a.set(20000000000000000000); // > maxInt(u64)
4903 try testFormat(a, "20000000000000000000");4903 try testFormat(a, "20000000000000000000");
49044904
4905 try a.set(1 << 64 * @sizeOf(usize) * 8);4905 try a.set(1 << (64 * @sizeOf(usize) * 8));
4906 try testFormat(a, "(BigInt)");4906 try testFormat(a, "(BigInt)");
49074907
4908 try a.set(-(1 << 64 * @sizeOf(usize) * 8));4908 try a.set(-(1 << (64 * @sizeOf(usize) * 8)));
4909 try testFormat(a, "(BigInt)");4909 try testFormat(a, "(BigInt)");
4910}4910}
49114911
lib/std/math/big/int_test.zig+16-16
...@@ -2489,14 +2489,14 @@ test "truncate to minimum signed integer" {...@@ -2489,14 +2489,14 @@ test "truncate to minimum signed integer" {
2489 .len = undefined,2489 .len = undefined,
2490 .positive = undefined,2490 .positive = undefined,
2491 };2491 };
2492 res.truncate(.{ .positive = true, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .signed, @bitSizeOf(Limb));2492 res.truncate(.{ .positive = true, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .signed, @bitSizeOf(Limb));
2493 try testing.expect(res.toConst().orderAgainstScalar(-1 << @bitSizeOf(Limb) - 1).compare(.eq));2493 try testing.expect(res.toConst().orderAgainstScalar(-1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2494 res.truncate(.{ .positive = false, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .signed, @bitSizeOf(Limb));2494 res.truncate(.{ .positive = false, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .signed, @bitSizeOf(Limb));
2495 try testing.expect(res.toConst().orderAgainstScalar(-1 << @bitSizeOf(Limb) - 1).compare(.eq));2495 try testing.expect(res.toConst().orderAgainstScalar(-1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2496 res.truncate(.{ .positive = true, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .unsigned, @bitSizeOf(Limb));2496 res.truncate(.{ .positive = true, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .unsigned, @bitSizeOf(Limb));
2497 try testing.expect(res.toConst().orderAgainstScalar(1 << @bitSizeOf(Limb) - 1).compare(.eq));2497 try testing.expect(res.toConst().orderAgainstScalar(1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2498 res.truncate(.{ .positive = false, .limbs = &.{1 << @bitSizeOf(Limb) - 1} }, .unsigned, @bitSizeOf(Limb));2498 res.truncate(.{ .positive = false, .limbs = &.{1 << (@bitSizeOf(Limb) - 1)} }, .unsigned, @bitSizeOf(Limb));
2499 try testing.expect(res.toConst().orderAgainstScalar(1 << @bitSizeOf(Limb) - 1).compare(.eq));2499 try testing.expect(res.toConst().orderAgainstScalar(1 << (@bitSizeOf(Limb) - 1)).compare(.eq));
2500}2500}
25012501
2502test "saturate single signed positive" {2502test "saturate single signed positive" {
...@@ -3880,7 +3880,7 @@ test "clz" {...@@ -3880,7 +3880,7 @@ test "clz" {
3880 try testing.expectEqual(0, neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1));3880 try testing.expectEqual(0, neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1));
38813881
3882 const neg_limb_msb_squared: std.math.big.int.Const = .{3882 const neg_limb_msb_squared: std.math.big.int.Const = .{
3883 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },3883 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
3884 .positive = false,3884 .positive = false,
3885 };3885 };
3886 try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2));3886 try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2));
...@@ -3896,7 +3896,7 @@ test "clz" {...@@ -3896,7 +3896,7 @@ test "clz" {
3896 try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1));3896 try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1));
38973897
3898 const neg_limb_msb: std.math.big.int.Const = .{3898 const neg_limb_msb: std.math.big.int.Const = .{
3899 .limbs = &.{1 << @bitSizeOf(Limb) - 1},3899 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
3900 .positive = false,3900 .positive = false,
3901 };3901 };
3902 try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb)));3902 try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb)));
...@@ -3936,7 +3936,7 @@ test "clz" {...@@ -3936,7 +3936,7 @@ test "clz" {
3936 try testing.expectEqual(@bitSizeOf(Limb) * 2, one.clz(@bitSizeOf(Limb) * 2 + 1));3936 try testing.expectEqual(@bitSizeOf(Limb) * 2, one.clz(@bitSizeOf(Limb) * 2 + 1));
39373937
3938 const limb_msb: std.math.big.int.Const = .{3938 const limb_msb: std.math.big.int.Const = .{
3939 .limbs = &.{1 << @bitSizeOf(Limb) - 1},3939 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
3940 .positive = true,3940 .positive = true,
3941 };3941 };
3942 try testing.expectEqual(0, limb_msb.clz(@bitSizeOf(Limb)));3942 try testing.expectEqual(0, limb_msb.clz(@bitSizeOf(Limb)));
...@@ -3956,7 +3956,7 @@ test "clz" {...@@ -3956,7 +3956,7 @@ test "clz" {
3956 try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max.clz(@bitSizeOf(Limb) * 2 + 1));3956 try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max.clz(@bitSizeOf(Limb) * 2 + 1));
39573957
3958 const limb_msb_squared: std.math.big.int.Const = .{3958 const limb_msb_squared: std.math.big.int.Const = .{
3959 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },3959 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
3960 .positive = true,3960 .positive = true,
3961 };3961 };
3962 try testing.expectEqual(0, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1));3962 try testing.expectEqual(0, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1));
...@@ -3992,7 +3992,7 @@ test "ctz" {...@@ -3992,7 +3992,7 @@ test "ctz" {
3992 try testing.expectEqual(@bitSizeOf(Limb) + 1, neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1));3992 try testing.expectEqual(@bitSizeOf(Limb) + 1, neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1));
39933993
3994 const neg_limb_msb_squared: std.math.big.int.Const = .{3994 const neg_limb_msb_squared: std.math.big.int.Const = .{
3995 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },3995 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
3996 .positive = false,3996 .positive = false,
3997 };3997 };
3998 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2));3998 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2));
...@@ -4008,7 +4008,7 @@ test "ctz" {...@@ -4008,7 +4008,7 @@ test "ctz" {
4008 try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));4008 try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));
40094009
4010 const neg_limb_msb: std.math.big.int.Const = .{4010 const neg_limb_msb: std.math.big.int.Const = .{
4011 .limbs = &.{1 << @bitSizeOf(Limb) - 1},4011 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
4012 .positive = false,4012 .positive = false,
4013 };4013 };
4014 try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb)));4014 try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb)));
...@@ -4048,7 +4048,7 @@ test "ctz" {...@@ -4048,7 +4048,7 @@ test "ctz" {
4048 try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 + 1));4048 try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 + 1));
40494049
4050 const limb_msb: std.math.big.int.Const = .{4050 const limb_msb: std.math.big.int.Const = .{
4051 .limbs = &.{1 << @bitSizeOf(Limb) - 1},4051 .limbs = &.{1 << (@bitSizeOf(Limb) - 1)},
4052 .positive = true,4052 .positive = true,
4053 };4053 };
4054 try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb)));4054 try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb)));
...@@ -4068,7 +4068,7 @@ test "ctz" {...@@ -4068,7 +4068,7 @@ test "ctz" {
4068 try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));4068 try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 + 1));
40694069
4070 const limb_msb_squared: std.math.big.int.Const = .{4070 const limb_msb_squared: std.math.big.int.Const = .{
4071 .limbs = &.{ 0, 1 << @bitSizeOf(Limb) - 2 },4071 .limbs = &.{ 0, 1 << (@bitSizeOf(Limb) - 2) },
4072 .positive = true,4072 .positive = true,
4073 };4073 };
4074 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 - 1));4074 try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, limb_msb_squared.ctz(@bitSizeOf(Limb) * 2 - 1));
lib/std/math/float.zig+2-2
...@@ -281,7 +281,7 @@ pub inline fn nan(comptime Type: type) Type {...@@ -281,7 +281,7 @@ pub inline fn nan(comptime Type: type) Type {
281 return reconstructFloat(281 return reconstructFloat(
282 RuntimeType,282 RuntimeType,
283 floatExponentMax(RuntimeType) + 1,283 floatExponentMax(RuntimeType) + 1,
284 mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 1),284 mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 1)),
285 );285 );
286}286}
287287
...@@ -297,7 +297,7 @@ pub inline fn snan(comptime Type: type) Type {...@@ -297,7 +297,7 @@ pub inline fn snan(comptime Type: type) Type {
297 return reconstructFloat(297 return reconstructFloat(
298 RuntimeType,298 RuntimeType,
299 floatExponentMax(RuntimeType) + 1,299 floatExponentMax(RuntimeType) + 1,
300 mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 2),300 mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 2)),
301 );301 );
302}302}
303303
lib/std/mem.zig+1-1
...@@ -4354,7 +4354,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {...@@ -4354,7 +4354,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
4354 @compileError("expected many item pointer, got " ++ @typeName(T));4354 @compileError("expected many item pointer, got " ++ @typeName(T));
43554355
4356 // Do nothing if the pointer is already well-aligned.4356 // Do nothing if the pointer is already well-aligned.
4357 if (align_to <= info.pointer.attrs.@"align" orelse @alignOf(info.pointer.child))4357 if (align_to <= (info.pointer.attrs.@"align" orelse @alignOf(info.pointer.child)))
4358 return 0;4358 return 0;
43594359
4360 // Calculate the aligned base address with an eye out for overflow.4360 // Calculate the aligned base address with an eye out for overflow.
lib/std/os/linux/vdso.zig+4-4
...@@ -62,13 +62,13 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {...@@ -62,13 +62,13 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
62 const hashtab = maybe_hashtab orelse return 0;62 const hashtab = maybe_hashtab orelse return 0;
63 if (maybe_verdef == null) maybe_versym = null;63 if (maybe_verdef == null) maybe_versym = null;
6464
65 const OK_TYPES = (1 << elf.STT_NOTYPE | 1 << elf.STT_OBJECT | 1 << elf.STT_FUNC | 1 << elf.STT_COMMON);65 const OK_TYPES = (1 << elf.STT_NOTYPE) | (1 << elf.STT_OBJECT) | (1 << elf.STT_FUNC) | (1 << elf.STT_COMMON);
66 const OK_BINDS = (1 << elf.STB_GLOBAL | 1 << elf.STB_WEAK | 1 << elf.STB_GNU_UNIQUE);66 const OK_BINDS = (1 << elf.STB_GLOBAL) | (1 << elf.STB_WEAK) | (1 << elf.STB_GNU_UNIQUE);
6767
68 var i: usize = 0;68 var i: usize = 0;
69 while (i < hashtab[1]) : (i += 1) {69 while (i < hashtab[1]) : (i += 1) {
70 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info & 0xf)) & OK_TYPES)) continue;70 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info & 0xf))) & OK_TYPES) continue;
71 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info >> 4)) & OK_BINDS)) continue;71 if (0 == (@as(u32, 1) << @as(u5, @intCast(syms[i].st_info >> 4))) & OK_BINDS) continue;
72 if (0 == syms[i].st_shndx) continue;72 if (0 == syms[i].st_shndx) continue;
73 const sym_name = @as([*:0]u8, @ptrCast(strings + syms[i].st_name));73 const sym_name = @as([*:0]u8, @ptrCast(strings + syms[i].st_name));
74 if (!mem.eql(u8, name, mem.sliceTo(sym_name, 0))) continue;74 if (!mem.eql(u8, name, mem.sliceTo(sym_name, 0))) continue;
lib/std/os/uefi/status.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const testing = @import("std").testing;1const testing = @import("std").testing;
22
3const high_bit = 1 << @typeInfo(usize).int.bits - 1;3const high_bit = 1 << (@typeInfo(usize).int.bits - 1);
44
5pub const Status = enum(usize) {5pub const Status = enum(usize) {
6 /// The operation completed successfully.6 /// The operation completed successfully.
lib/std/unicode.zig+1-1
...@@ -485,7 +485,7 @@ pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 {...@@ -485,7 +485,7 @@ pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 {
485 const high_half: u21 = surrogate_pair[0];485 const high_half: u21 = surrogate_pair[0];
486 const low_half = surrogate_pair[1];486 const low_half = surrogate_pair[1];
487 if (!utf16IsLowSurrogate(low_half)) return error.ExpectedSecondSurrogateHalf;487 if (!utf16IsLowSurrogate(low_half)) return error.ExpectedSecondSurrogateHalf;
488 return 0x10000 + ((high_half & 0x03ff) << 10) | (low_half & 0x03ff);488 return (0x10000 + ((high_half & 0x03ff) << 10)) | (low_half & 0x03ff);
489}489}
490490
491pub const Utf16LeIterator = struct {491pub const Utf16LeIterator = struct {
lib/std/zig/Ast.zig+32
...@@ -555,6 +555,33 @@ pub fn renderError(tree: Ast, parse_error: Error, w: *Writer) Writer.Error!void...@@ -555,6 +555,33 @@ pub fn renderError(tree: Ast, parse_error: Error, w: *Writer) Writer.Error!void
555 .var_const_decl => {555 .var_const_decl => {
556 return w.writeAll("use 'var' or 'const' to declare variable");556 return w.writeAll("use 'var' or 'const' to declare variable");
557 },557 },
558 .ambiguous_operator_precedence => {
559 return w.print("ambiguous operator precedence with operators … {s} … {s} …; use parentheses to disambiguate", .{
560 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
561 tree.tokenTag(parse_error.token).lexeme().?,
562 });
563 },
564 .previous_ambiguous_operator => {
565 return w.writeAll("previous ambiguous operator here");
566 },
567 .illegal_chained_operators => {
568 return w.print("repetition of non-chainable operators … {s} … {s} …; use parentheses to disambiguate", .{
569 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
570 tree.tokenTag(parse_error.token).lexeme().?,
571 });
572 },
573 .hint_operator_precedence_left => {
574 return w.print("did you mean `(… {s} …) {s} …` ?", .{
575 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
576 tree.tokenTag(parse_error.token).lexeme().?,
577 });
578 },
579 .hint_operator_precedence_right => {
580 return w.print("did you mean `… {s} (… {s} …)` ?", .{
581 tree.tokenTag(parse_error.token - @as(u32, @intCast(parse_error.extra.offset))).lexeme().?,
582 tree.tokenTag(parse_error.token).lexeme().?,
583 });
584 },
558585
559 .invalid_byte => {586 .invalid_byte => {
560 const tok_slice = tree.source[tree.tokens.items(.start)[parse_error.token]..];587 const tok_slice = tree.source[tree.tokens.items(.start)[parse_error.token]..];
...@@ -2893,6 +2920,11 @@ pub const Error = struct {...@@ -2893,6 +2920,11 @@ pub const Error = struct {
2893 expected_var_const,2920 expected_var_const,
2894 wrong_equal_var_decl,2921 wrong_equal_var_decl,
2895 var_const_decl,2922 var_const_decl,
2923 ambiguous_operator_precedence,
2924 previous_ambiguous_operator,
2925 hint_operator_precedence_left,
2926 hint_operator_precedence_right,
2927 illegal_chained_operators,
28962928
2897 zig_style_container,2929 zig_style_container,
2898 previous_field,2930 previous_field,
lib/std/zig/Ast/Render.zig+3-3
...@@ -1483,9 +1483,9 @@ fn renderThenElse(...@@ -1483,9 +1483,9 @@ fn renderThenElse(
1483 last_else_token = error_token + 1; // |1483 last_else_token = error_token + 1; // |
1484 }1484 }
14851485
1486 const indent_else_expr = indent_then_expr and1486 const indent_else_expr = (indent_then_expr and
1487 !nodeIsBlock(tree.nodeTag(else_expr)) and1487 !nodeIsBlock(tree.nodeTag(else_expr)) and
1488 !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr)) or1488 !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr))) or
1489 tree.tokenTag(tree.firstToken(else_expr)) ==1489 tree.tokenTag(tree.firstToken(else_expr)) ==
1490 .multiline_string_literal_line;1490 .multiline_string_literal_line;
1491 if (indent_else_expr) {1491 if (indent_else_expr) {
...@@ -3195,7 +3195,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {...@@ -3195,7 +3195,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool {
3195 }3195 }
3196 }3196 }
31973197
3198 index = 1 + (newline orelse end - 1);3198 index = 1 + (newline orelse (end - 1));
31993199
3200 const comment_content = mem.trimStart(u8, trimmed_comment["//".len..], &std.ascii.whitespace);3200 const comment_content = mem.trimStart(u8, trimmed_comment["//".len..], &std.ascii.whitespace);
3201 if (ais.disabled_offset != null and mem.eql(u8, comment_content, "zig fmt: on")) {3201 if (ais.disabled_offset != null and mem.eql(u8, comment_content, "zig fmt: on")) {
lib/std/zig/Parse.zig+301-54
...@@ -1512,7 +1512,7 @@ fn expectAssignExpr(p: *Parse) !Node.Index {...@@ -1512,7 +1512,7 @@ fn expectAssignExpr(p: *Parse) !Node.Index {
1512}1512}
15131513
1514fn parseExpr(p: *Parse) Error!?Node.Index {1514fn parseExpr(p: *Parse) Error!?Node.Index {
1515 return p.parseExprPrecedence(0);1515 return p.parseExprPrecedence(.start, p.tok_i);
1516}1516}
15171517
1518fn expectExpr(p: *Parse) Error!Node.Index {1518fn expectExpr(p: *Parse) Error!Node.Index {
...@@ -1524,67 +1524,317 @@ const Assoc = enum {...@@ -1524,67 +1524,317 @@ const Assoc = enum {
1524 none,1524 none,
1525};1525};
15261526
1527const PrecClass = struct {
1528 group: Group,
1529 assoc: Assoc = Assoc.left,
1530
1531 const Group = enum {
1532 const num_distinct = std.meta.fieldNames(Group).len;
1533
1534 arithmetic_product_chainable,
1535 arithmetic_mod_nonchainable,
1536 arithmetic_sum,
1537
1538 bitwise_shift,
1539 bitwise_and,
1540 bitwise_xor,
1541 bitwise_or,
1542
1543 comparison,
1544
1545 bool_and,
1546 bool_or,
1547
1548 recovery_orelse,
1549 recovery_catch,
1550
1551 root,
1552
1553 /// For this to work correctly we require that all subgroups are strictly adjacent
1554 /// Major groups are defined by the first text before an underscore
1555 const Major: type = b: {
1556 var major_names: []const []const u8 = &.{};
1557 for (std.meta.fieldNames(Group)) |fieldname| {
1558 var major_name: []const u8 = fieldname[0..];
1559 for (fieldname, 0..) |c, i| {
1560 if (c == '_') {
1561 major_name = fieldname[0..i];
1562 break;
1563 }
1564 }
1565 if (major_names.len == 0 or !std.mem.eql(u8, major_name, major_names[major_names.len - 1])) {
1566 major_names = major_names ++ &[1][]const u8{major_name};
1567 }
1568 }
1569
1570 const IntType = std.math.IntFittingRange(0, major_names.len - 1);
1571 var values: [major_names.len]IntType = undefined;
1572 for (0..major_names.len) |i| values[i] = i;
1573
1574 break :b @Enum(
1575 IntType,
1576 .exhaustive,
1577 major_names,
1578 &values,
1579 );
1580 };
1581 };
1582
1583 pub const start: PrecClass = .{ .group = .root };
1584
1585 pub const Rel = enum(i2) {
1586 lt = -1,
1587 eq = 0,
1588 gt = 1,
1589
1590 fn inverted(self: Rel) Rel {
1591 return @enumFromInt(-@intFromEnum(self));
1592 }
1593 };
1594
1595 const PrecedenceArray = [Group.num_distinct][Group.num_distinct]?Rel;
1596
1597 fn setMajorRelation(prec_array: *PrecedenceArray, major_a: Group.Major, rel: Rel, major_b: Group.Major) void {
1598 for (std.meta.fieldNames(Group), 0..) |fieldname_i, i| {
1599 if (!std.mem.startsWith(u8, fieldname_i, @tagName(major_a))) continue;
1600
1601 for (std.meta.fieldNames(Group), 0..) |fieldname_j, j| {
1602 if (!std.mem.startsWith(u8, fieldname_j, @tagName(major_b))) continue;
1603
1604 prec_array.*[i][j] = rel;
1605 }
1606 }
1607 }
1608
1609 fn setMinorRelation(prec_array: *PrecedenceArray, minor_a: Group, rel: Rel, minor_b: Group) void {
1610 prec_array.*[@intFromEnum(minor_a)][@intFromEnum(minor_b)] = rel;
1611 }
1612
1613 /// Arithmetic_* > Comparison
1614 /// Bitwise_* > Comparison
1615 /// Comparison > Bool_* > Root
1616 /// Recovery > Root
1617 ///
1618 /// *_Product > *_Sum
1619 ///
1620 /// order[y][x] --> y cmp x
1621 const precedence_ordering = b: {
1622 @setEvalBranchQuota(20_000);
1623 const major_greater_than_relations = [_][2]Group.Major{
1624 // zig fmt: off
1625 .{ .arithmetic, .comparison },
1626 .{ .bitwise, .comparison },
1627 .{ .comparison, .bool },
1628 .{ .bool, .root },
1629 .{ .recovery, .root },
1630 // zig fmt: on
1631 };
1632
1633 var order: PrecedenceArray = @splat(@splat(null));
1634
1635 for (major_greater_than_relations) |relation| {
1636 setMajorRelation(&order, relation[0], .gt, relation[1]);
1637 }
1638
1639 setMinorRelation(&order, .arithmetic_mod_nonchainable, .gt, .arithmetic_sum);
1640 setMinorRelation(&order, .arithmetic_product_chainable, .gt, .arithmetic_sum);
1641
1642 computeTransativeOrdering(&order);
1643 break :b order;
1644 };
1645
1646 /// Uses the table from Zig-0.16.0
1647 /// * / % *% *| ||
1648 /// + - ++ +% -% +| -|
1649 /// << >> <<|
1650 /// & ^ | orelse catch
1651 /// == != < > <= >=
1652 /// and
1653 /// or
1654 const v16_precedence_ordering = b: {
1655 @setEvalBranchQuota(20_000);
1656
1657 var order: PrecedenceArray = @splat(@splat(null));
1658
1659 setMinorRelation(&order, .arithmetic_product_chainable, .eq, .arithmetic_mod_nonchainable);
1660 setMinorRelation(&order, .arithmetic_mod_nonchainable, .gt, .arithmetic_sum);
1661 setMinorRelation(&order, .arithmetic_product_chainable, .gt, .arithmetic_sum);
1662
1663 setMinorRelation(&order, .arithmetic_sum, .gt, .bitwise_shift);
1664
1665 // Here since the transative ordering computer cant leverage equals to derive a = b < c --> a < c, we have to manually list these
1666 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_and);
1667 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_xor);
1668 setMinorRelation(&order, .bitwise_shift, .gt, .bitwise_or);
1669 setMinorRelation(&order, .bitwise_shift, .gt, .recovery_catch);
1670 setMinorRelation(&order, .bitwise_shift, .gt, .recovery_orelse);
1671
1672 setMinorRelation(&order, .bitwise_and, .eq, .bitwise_xor);
1673 setMinorRelation(&order, .bitwise_xor, .eq, .bitwise_or);
1674 setMinorRelation(&order, .bitwise_or, .eq, .recovery_catch);
1675 setMinorRelation(&order, .recovery_catch, .eq, .recovery_orelse);
1676 setMinorRelation(&order, .recovery_orelse, .eq, .bitwise_and);
1677
1678 setMinorRelation(&order, .bitwise_and, .gt, .comparison);
1679 setMinorRelation(&order, .bitwise_xor, .gt, .comparison);
1680 setMinorRelation(&order, .bitwise_or, .gt, .comparison);
1681 setMinorRelation(&order, .recovery_catch, .gt, .comparison);
1682 setMinorRelation(&order, .recovery_orelse, .gt, .comparison);
1683
1684 setMinorRelation(&order, .comparison, .gt, .bool_and);
1685
1686 setMinorRelation(&order, .bool_and, .gt, .bool_or);
1687
1688 setMinorRelation(&order, .bool_or, .gt, .root);
1689
1690 computeTransativeOrdering(&order);
1691 for (order) |row| {
1692 for (row) |item| {
1693 if (item == null) @compileError("Null entry in old precedence ordering which had none.");
1694 }
1695 }
1696 break :b order;
1697 };
1698
1699 pub fn cmp(lhs: PrecClass, rhs: PrecClass) ?Rel {
1700 return PrecClass.precedence_ordering[@intFromEnum(lhs.group)][@intFromEnum(rhs.group)];
1701 }
1702
1703 pub fn v16_cmp(lhs: PrecClass, rhs: PrecClass) Rel {
1704 return PrecClass.v16_precedence_ordering[@intFromEnum(lhs.group)][@intFromEnum(rhs.group)].?;
1705 }
1706
1707 fn computeTransativeOrdering(order: *PrecedenceArray) void {
1708 for (0..Group.num_distinct) |i| for (0..Group.num_distinct) |j| for (0..Group.num_distinct) |k| {
1709 if (order[i][k] == order[k][j] and order[i][k] != null) order[i][j] = order[i][k];
1710 };
1711 for (0..Group.num_distinct) |i| for (0..Group.num_distinct) |j| {
1712 if (i == j) order[i][j] = .eq;
1713 if (order[i][j] == null and order[j][i] != null) order[i][j] = order[j][i].?.inverted();
1714 };
1715 }
1716};
1717
1527const OperInfo = struct {1718const OperInfo = struct {
1528 prec: i8,1719 prec: PrecClass,
1529 tag: Node.Tag,1720 tag: Node.Tag,
1530 assoc: Assoc = Assoc.left,
1531};1721};
15321722
1533// A table of binary operator information. Higher precedence numbers are1723const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = .start, .tag = Node.Tag.root }, 0, .{
1534// stickier. All operators at the same precedence level should have the same1724 // zig fmt: off
1535// associativity.1725 .keyword_or = .{ .prec = .{ .group = .bool_or }, .tag = .bool_or },
1536const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = -1, .tag = Node.Tag.root }, 0, .{1726
1537 .keyword_or = .{ .prec = 10, .tag = .bool_or },1727 .keyword_and = .{ .prec = .{ .group = .bool_and }, .tag = .bool_and },
15381728
1539 .keyword_and = .{ .prec = 20, .tag = .bool_and },1729 .equal_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .equal_equal },
15401730 .bang_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .bang_equal },
1541 .equal_equal = .{ .prec = 30, .tag = .equal_equal, .assoc = Assoc.none },1731 .angle_bracket_left = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_than },
1542 .bang_equal = .{ .prec = 30, .tag = .bang_equal, .assoc = Assoc.none },1732 .angle_bracket_right = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_than },
1543 .angle_bracket_left = .{ .prec = 30, .tag = .less_than, .assoc = Assoc.none },1733 .angle_bracket_left_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_or_equal },
1544 .angle_bracket_right = .{ .prec = 30, .tag = .greater_than, .assoc = Assoc.none },1734 .angle_bracket_right_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_or_equal },
1545 .angle_bracket_left_equal = .{ .prec = 30, .tag = .less_or_equal, .assoc = Assoc.none },1735
1546 .angle_bracket_right_equal = .{ .prec = 30, .tag = .greater_or_equal, .assoc = Assoc.none },1736 .ampersand = .{ .prec = .{ .group = .bitwise_and }, .tag = .bit_and },
15471737 .caret = .{ .prec = .{ .group = .bitwise_xor }, .tag = .bit_xor },
1548 .ampersand = .{ .prec = 40, .tag = .bit_and },1738 .pipe = .{ .prec = .{ .group = .bitwise_or }, .tag = .bit_or },
1549 .caret = .{ .prec = 40, .tag = .bit_xor },1739
1550 .pipe = .{ .prec = 40, .tag = .bit_or },1740 .keyword_orelse = .{ .prec = .{ .group = .recovery_orelse }, .tag = .@"orelse" },
1551 .keyword_orelse = .{ .prec = 40, .tag = .@"orelse" },1741 .keyword_catch = .{ .prec = .{ .group = .recovery_catch }, .tag = .@"catch" },
1552 .keyword_catch = .{ .prec = 40, .tag = .@"catch" },1742
15531743 .angle_bracket_angle_bracket_left = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl },
1554 .angle_bracket_angle_bracket_left = .{ .prec = 50, .tag = .shl },1744 .angle_bracket_angle_bracket_left_pipe = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl_sat },
1555 .angle_bracket_angle_bracket_left_pipe = .{ .prec = 50, .tag = .shl_sat },1745 .angle_bracket_angle_bracket_right = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shr },
1556 .angle_bracket_angle_bracket_right = .{ .prec = 50, .tag = .shr },1746
15571747 .plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add },
1558 .plus = .{ .prec = 60, .tag = .add },1748 .minus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub },
1559 .minus = .{ .prec = 60, .tag = .sub },1749 .plus_plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .array_cat },
1560 .plus_plus = .{ .prec = 60, .tag = .array_cat },1750 .plus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_wrap },
1561 .plus_percent = .{ .prec = 60, .tag = .add_wrap },1751 .minus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_wrap },
1562 .minus_percent = .{ .prec = 60, .tag = .sub_wrap },1752 .plus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_sat },
1563 .plus_pipe = .{ .prec = 60, .tag = .add_sat },1753 .minus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_sat },
1564 .minus_pipe = .{ .prec = 60, .tag = .sub_sat },1754
15651755 .pipe_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .merge_error_sets },
1566 .pipe_pipe = .{ .prec = 70, .tag = .merge_error_sets },1756 .asterisk = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul },
1567 .asterisk = .{ .prec = 70, .tag = .mul },1757 .slash = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .div },
1568 .slash = .{ .prec = 70, .tag = .div },1758 .asterisk_percent = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_wrap },
1569 .percent = .{ .prec = 70, .tag = .mod },1759 .asterisk_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_sat },
1570 .asterisk_percent = .{ .prec = 70, .tag = .mul_wrap },1760
1571 .asterisk_pipe = .{ .prec = 70, .tag = .mul_sat },1761 .percent = .{ .prec = .{ .group = .arithmetic_mod_nonchainable, .assoc = Assoc.none }, .tag = .mod },
1762 // zig fmt: on
1572});1763});
15731764
1574fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {1765fn parseExprPrecedence(p: *Parse, min_exc_prec: PrecClass, prev_token_const: u32) Error!?Node.Index {
1575 assert(min_prec >= 0);
1576 var node = try p.parsePrefixExpr() orelse return null;1766 var node = try p.parsePrefixExpr() orelse return null;
15771767
1578 var banned_prec: i8 = -1;1768 var prev_operator_token = prev_token_const;
15791769
1580 while (true) {1770 while (true) {
1581 const tok_tag = p.tokenTag(p.tok_i);1771 const tok_tag = p.tokenTag(p.tok_i);
1582 const info = operTable[@as(usize, @intCast(@backingInt(tok_tag)))];1772 const info = operTable[@intFromEnum(tok_tag)];
1583 if (info.prec < min_prec) {1773
1774 const rel = info.prec.cmp(min_exc_prec) orelse b: {
1775 const prev_op_tok_tag = p.tokenTag(prev_operator_token);
1776 const prev_op_info = operTable[@intFromEnum(prev_op_tok_tag)];
1777 const v16_rel = prev_op_info.prec.v16_cmp(info.prec);
1778 try p.warnMsg(.{
1779 .tag = .ambiguous_operator_precedence,
1780 .is_note = false,
1781 .token = p.tok_i,
1782 .extra = .{ .offset = p.tok_i - prev_operator_token },
1783 });
1784 try p.warnMsg(.{
1785 .tag = .previous_ambiguous_operator,
1786 .is_note = true,
1787 .token = prev_operator_token,
1788 });
1789 if (v16_rel == .gt or v16_rel == .eq) {
1790 try p.warnMsg(.{
1791 .tag = .hint_operator_precedence_left,
1792 .is_note = true,
1793 .token = p.tok_i,
1794 .extra = .{ .offset = p.tok_i - prev_operator_token },
1795 });
1796 } else {
1797 try p.warnMsg(.{
1798 .tag = .hint_operator_precedence_right,
1799 .is_note = true,
1800 .token = p.tok_i,
1801 .extra = .{ .offset = p.tok_i - prev_operator_token },
1802 });
1803 }
1804 break :b .gt;
1805 };
1806
1807 if (rel == .lt) {
1584 break;1808 break;
1585 }1809 }
1586 if (info.prec == banned_prec) {1810
1587 return p.fail(.chained_comparison_operators);1811 if (min_exc_prec.group == info.prec.group and min_exc_prec.assoc == .none and info.prec.assoc == .none) {
1812 //Special cased check to maintain the old more helpful error for chained comparisons.
1813 if (info.prec.group == .comparison) {
1814 try p.warn(.chained_comparison_operators);
1815 } else {
1816 try p.warnMsg(.{
1817 .tag = .illegal_chained_operators,
1818 .is_note = false,
1819 .token = p.tok_i,
1820 .extra = .{ .offset = p.tok_i - prev_operator_token },
1821 });
1822 try p.warnMsg(.{
1823 .tag = .previous_ambiguous_operator,
1824 .is_note = true,
1825 .token = prev_operator_token,
1826 });
1827 try p.warnMsg(.{
1828 .tag = .hint_operator_precedence_left,
1829 .is_note = true,
1830 .token = p.tok_i,
1831 .extra = .{ .offset = p.tok_i - prev_operator_token },
1832 });
1833 }
1834 }
1835
1836 if (rel == .eq) {
1837 break;
1588 }1838 }
15891839
1590 const oper_token = p.nextToken();1840 const oper_token = p.nextToken();
...@@ -1614,7 +1864,8 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {...@@ -1614,7 +1864,8 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {
1614 }1864 }
1615 }1865 }
16161866
1617 const rhs = try p.parseExprPrecedence(info.prec + 1) orelse {1867 prev_operator_token = oper_token;
1868 const rhs = try p.parseExprPrecedence(info.prec, prev_operator_token) orelse {
1618 try p.warn(.expected_expr);1869 try p.warn(.expected_expr);
1619 return node;1870 return node;
1620 };1871 };
...@@ -1624,10 +1875,6 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {...@@ -1624,10 +1875,6 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index {
1624 .main_token = oper_token,1875 .main_token = oper_token,
1625 .data = .{ .node_and_node = .{ node, rhs } },1876 .data = .{ .node_and_node = .{ node, rhs } },
1626 });1877 });
1627
1628 if (info.assoc == Assoc.none) {
1629 banned_prec = info.prec;
1630 }
1631 }1878 }
16321879
1633 return node;1880 return node;
lib/std/zig/TokenSmith.zig+1-1
...@@ -160,7 +160,7 @@ pub fn gen(smith: *Smith) TokenSmith {...@@ -160,7 +160,7 @@ pub fn gen(smith: *Smith) TokenSmith {
160 var no_period = false;160 var no_period = false;
161 var not_exponent = true;161 var not_exponent = true;
162 for (t.source_buf[t.source_len..][0..len], 0..) |*c, i| {162 for (t.source_buf[t.source_len..][0..len], 0..) |*c, i| {
163 const invalid_period = no_period and c.* == '.' or i + 1 == len;163 const invalid_period = (no_period and c.* == '.') or i + 1 == len;
164 const is_exponent = c.* == '-' or c.* == '+';164 const is_exponent = c.* == '-' or c.* == '+';
165 const invalid_exponent = not_exponent and is_exponent;165 const invalid_exponent = not_exponent and is_exponent;
166 const valid_exponent = !not_exponent and is_exponent;166 const valid_exponent = !not_exponent and is_exponent;
lib/std/zig/llvm/BitcodeReader.zig+1-1
...@@ -404,7 +404,7 @@ fn readFixed(bc: *BitcodeReader, comptime T: type, bits: u7) !T {...@@ -404,7 +404,7 @@ fn readFixed(bc: *BitcodeReader, comptime T: type, bits: u7) !T {
404 if (bc.bit_offset == 0) bc.bit_buffer = try bc.read32Bits();404 if (bc.bit_offset == 0) bc.bit_buffer = try bc.read32Bits();
405 const chunk_len = @min(@as(u6, 32) - bc.bit_offset, remaining);405 const chunk_len = @min(@as(u6, 32) - bc.bit_offset, remaining);
406 const chunk_mask = @as(u32, std.math.maxInt(u32)) >> @intCast(32 - chunk_len);406 const chunk_mask = @as(u32, std.math.maxInt(u32)) >> @intCast(32 - chunk_len);
407 result |= @as(T, @intCast(bc.bit_buffer >> bc.bit_offset & chunk_mask)) << @intCast(shift);407 result |= @as(T, @intCast((bc.bit_buffer >> bc.bit_offset) & chunk_mask)) << @intCast(shift);
408 shift += @intCast(chunk_len);408 shift += @intCast(chunk_len);
409 remaining -= chunk_len;409 remaining -= chunk_len;
410 bc.bit_offset = @truncate(bc.bit_offset + chunk_len);410 bc.bit_offset = @truncate(bc.bit_offset + chunk_len);
lib/std/zig/llvm/Builder.zig+26-26
...@@ -1076,7 +1076,7 @@ pub const Type = enum(u32) {...@@ -1076,7 +1076,7 @@ pub const Type = enum(u32) {
1076 child: Type,1076 child: Type,
10771077
1078 fn length(self: Array) u64 {1078 fn length(self: Array) u64 {
1079 return @as(u64, self.len_hi) << 32 | self.len_lo;1079 return (@as(u64, self.len_hi) << 32) | self.len_lo;
1080 }1080 }
1081 };1081 };
10821082
...@@ -9520,7 +9520,7 @@ pub const Metadata = packed struct(u32) {...@@ -9520,7 +9520,7 @@ pub const Metadata = packed struct(u32) {
9520 size_in_bits_hi: u32,9520 size_in_bits_hi: u32,
95219521
9522 pub fn bitSize(self: BasicType) u64 {9522 pub fn bitSize(self: BasicType) u64 {
9523 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;9523 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
9524 }9524 }
9525 };9525 };
95269526
...@@ -9537,10 +9537,10 @@ pub const Metadata = packed struct(u32) {...@@ -9537,10 +9537,10 @@ pub const Metadata = packed struct(u32) {
9537 fields_tuple: Metadata.Optional,9537 fields_tuple: Metadata.Optional,
95389538
9539 pub fn bitSize(self: CompositeType) u64 {9539 pub fn bitSize(self: CompositeType) u64 {
9540 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;9540 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
9541 }9541 }
9542 pub fn bitAlign(self: CompositeType) u64 {9542 pub fn bitAlign(self: CompositeType) u64 {
9543 return @as(u64, self.align_in_bits_hi) << 32 | self.align_in_bits_lo;9543 return (@as(u64, self.align_in_bits_hi) << 32) | self.align_in_bits_lo;
9544 }9544 }
9545 };9545 };
95469546
...@@ -9558,13 +9558,13 @@ pub const Metadata = packed struct(u32) {...@@ -9558,13 +9558,13 @@ pub const Metadata = packed struct(u32) {
9558 offset_in_bits_hi: u32,9558 offset_in_bits_hi: u32,
95599559
9560 pub fn bitSize(self: DerivedType) u64 {9560 pub fn bitSize(self: DerivedType) u64 {
9561 return @as(u64, self.size_in_bits_hi) << 32 | self.size_in_bits_lo;9561 return (@as(u64, self.size_in_bits_hi) << 32) | self.size_in_bits_lo;
9562 }9562 }
9563 pub fn bitAlign(self: DerivedType) u64 {9563 pub fn bitAlign(self: DerivedType) u64 {
9564 return @as(u64, self.align_in_bits_hi) << 32 | self.align_in_bits_lo;9564 return (@as(u64, self.align_in_bits_hi) << 32) | self.align_in_bits_lo;
9565 }9565 }
9566 pub fn bitOffset(self: DerivedType) u64 {9566 pub fn bitOffset(self: DerivedType) u64 {
9567 return @as(u64, self.offset_in_bits_hi) << 32 | self.offset_in_bits_lo;9567 return (@as(u64, self.offset_in_bits_hi) << 32) | self.offset_in_bits_lo;
9568 }9568 }
9569 };9569 };
95709570
...@@ -12457,7 +12457,7 @@ fn doubleConstAssumeCapacity(self: *Builder, val: f64) Constant {...@@ -12457,7 +12457,7 @@ fn doubleConstAssumeCapacity(self: *Builder, val: f64) Constant {
12457 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .double) return false;12457 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .double) return false;
12458 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];12458 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
12459 const rhs_extra = ctx.builder.constantExtraData(Constant.Double, rhs_data);12459 const rhs_extra = ctx.builder.constantExtraData(Constant.Double, rhs_data);
12460 return @as(u64, @bitCast(lhs_key)) == @as(u64, rhs_extra.hi) << 32 | rhs_extra.lo;12460 return @as(u64, @bitCast(lhs_key)) == (@as(u64, rhs_extra.hi) << 32) | rhs_extra.lo;
12461 }12461 }
12462 };12462 };
12463 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });12463 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
...@@ -12488,8 +12488,8 @@ fn fp128ConstAssumeCapacity(self: *Builder, val: f128) Constant {...@@ -12488,8 +12488,8 @@ fn fp128ConstAssumeCapacity(self: *Builder, val: f128) Constant {
12488 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .fp128) return false;12488 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .fp128) return false;
12489 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];12489 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
12490 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);12490 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);
12491 return @as(u128, @bitCast(lhs_key)) == @as(u128, rhs_extra.hi_hi) << 96 |12491 return @as(u128, @bitCast(lhs_key)) == (@as(u128, rhs_extra.hi_hi) << 96) |
12492 @as(u128, rhs_extra.hi_lo) << 64 | @as(u128, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo;12492 (@as(u128, rhs_extra.hi_lo) << 64) | (@as(u128, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo;
12493 }12493 }
12494 };12494 };
12495 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });12495 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
...@@ -12522,8 +12522,8 @@ fn x86_fp80ConstAssumeCapacity(self: *Builder, val: f80) Constant {...@@ -12522,8 +12522,8 @@ fn x86_fp80ConstAssumeCapacity(self: *Builder, val: f80) Constant {
12522 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .x86_fp80) return false;12522 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .x86_fp80) return false;
12523 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];12523 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
12524 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp80, rhs_data);12524 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp80, rhs_data);
12525 return @as(u80, @bitCast(lhs_key)) == @as(u80, rhs_extra.hi) << 64 |12525 return @as(u80, @bitCast(lhs_key)) == (@as(u80, rhs_extra.hi) << 64) |
12526 @as(u80, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo;12526 (@as(u80, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo;
12527 }12527 }
12528 };12528 };
12529 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });12529 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
...@@ -12555,8 +12555,8 @@ fn ppc_fp128ConstAssumeCapacity(self: *Builder, val: [2]f64) Constant {...@@ -12555,8 +12555,8 @@ fn ppc_fp128ConstAssumeCapacity(self: *Builder, val: [2]f64) Constant {
12555 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .ppc_fp128) return false;12555 if (ctx.builder.constant_items.items(.tag)[rhs_index] != .ppc_fp128) return false;
12556 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];12556 const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index];
12557 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);12557 const rhs_extra = ctx.builder.constantExtraData(Constant.Fp128, rhs_data);
12558 return @as(u64, @bitCast(lhs_key[0])) == @as(u64, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo and12558 return @as(u64, @bitCast(lhs_key[0])) == (@as(u64, rhs_extra.lo_hi) << 32) | rhs_extra.lo_lo and
12559 @as(u64, @bitCast(lhs_key[1])) == @as(u64, rhs_extra.hi_hi) << 32 | rhs_extra.hi_lo;12559 @as(u64, @bitCast(lhs_key[1])) == (@as(u64, rhs_extra.hi_hi) << 32) | rhs_extra.hi_lo;
12560 }12560 }
12561 };12561 };
12562 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });12562 const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self });
...@@ -15225,18 +15225,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco...@@ -15225,18 +15225,18 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
15225 for (limbs) |*limb| {15225 for (limbs) |*limb| {
15226 const val = std.mem.littleToNative(i64, @bitCast(limb.*));15226 const val = std.mem.littleToNative(i64, @bitCast(limb.*));
15227 limb.* = @bitCast(if (val >= 0)15227 limb.* = @bitCast(if (val >= 0)
15228 val << 1 | 015228 (val << 1) | 0
15229 else15229 else
15230 -%val << 1 | 1);15230 (-%val << 1) | 1);
15231 }15231 }
15232 try constants_block.writeUnabbrev(5, record.items);15232 try constants_block.writeUnabbrev(5, record.items);
15233 continue;15233 continue;
15234 };15234 };
15235 try constants_block.writeAbbrev(ConstantsBlock.Integer{15235 try constants_block.writeAbbrev(ConstantsBlock.Integer{
15236 .value = @bitCast(if (val >= 0)15236 .value = @bitCast(if (val >= 0)
15237 val << 1 | 015237 (val << 1) | 0
15238 else15238 else
15239 -%val << 1 | 1),15239 (-%val << 1) | 1),
15240 });15240 });
15241 },15241 },
15242 .half,15242 .half,
...@@ -15252,8 +15252,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco...@@ -15252,8 +15252,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
15252 .x86_fp80 => {15252 .x86_fp80 => {
15253 const extra = self.constantExtraData(Constant.Fp80, data);15253 const extra = self.constantExtraData(Constant.Fp80, data);
15254 try constants_block.writeAbbrev(ConstantsBlock.Fp80{15254 try constants_block.writeAbbrev(ConstantsBlock.Fp80{
15255 .hi = @as(u64, extra.hi) << 48 | @as(u64, extra.lo_hi) << 16 |15255 .hi = (@as(u64, extra.hi) << 48) | (@as(u64, extra.lo_hi) << 16) |
15256 extra.lo_lo >> 16,15256 (extra.lo_lo >> 16),
15257 .lo = @truncate(extra.lo_lo),15257 .lo = @truncate(extra.lo_lo),
15258 });15258 });
15259 },15259 },
...@@ -15262,8 +15262,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco...@@ -15262,8 +15262,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
15262 => {15262 => {
15263 const extra = self.constantExtraData(Constant.Fp128, data);15263 const extra = self.constantExtraData(Constant.Fp128, data);
15264 try constants_block.writeAbbrev(ConstantsBlock.Fp128{15264 try constants_block.writeAbbrev(ConstantsBlock.Fp128{
15265 .lo = @as(u64, extra.lo_hi) << 32 | @as(u64, extra.lo_lo),15265 .lo = (@as(u64, extra.lo_hi) << 32) | @as(u64, extra.lo_lo),
15266 .hi = @as(u64, extra.hi_hi) << 32 | @as(u64, extra.hi_lo),15266 .hi = (@as(u64, extra.hi_hi) << 32) | @as(u64, extra.hi_lo),
15267 });15267 });
15268 },15268 },
15269 .array,15269 .array,
...@@ -15724,9 +15724,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco...@@ -15724,9 +15724,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
15724 for (limbs) |*limb| {15724 for (limbs) |*limb| {
15725 const val = std.mem.littleToNative(i64, @bitCast(limb.*));15725 const val = std.mem.littleToNative(i64, @bitCast(limb.*));
15726 limb.* = @bitCast(if (val >= 0)15726 limb.* = @bitCast(if (val >= 0)
15727 val << 1 | 015727 (val << 1) | 0
15728 else15728 else
15729 -%val << 1 | 1);15729 (-%val << 1) | 1);
15730 }15730 }
15731 try metadata_block.writeUnabbrev(@backingInt(MetadataBlock.Code.ENUMERATOR), record.items);15731 try metadata_block.writeUnabbrev(@backingInt(MetadataBlock.Code.ENUMERATOR), record.items);
15732 continue;15732 continue;
...@@ -15736,9 +15736,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco...@@ -15736,9 +15736,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
15736 .bit_width = extra.bit_width,15736 .bit_width = extra.bit_width,
15737 .name = extra.name,15737 .name = extra.name,
15738 .value = @bitCast(if (val >= 0)15738 .value = @bitCast(if (val >= 0)
15739 val << 1 | 015739 (val << 1) | 0
15740 else15740 else
15741 -%val << 1 | 1),15741 (-%val << 1) | 1),
15742 }, metadata_adapter);15742 }, metadata_adapter);
15743 },15743 },
15744 .subrange => {15744 .subrange => {
lib/std/zig/llvm/bitcode_writer.zig+1-1
...@@ -102,7 +102,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {...@@ -102,7 +102,7 @@ pub fn BitcodeWriter(comptime types: []const type) type {
102 // If input is larger than one VBR block can store102 // If input is larger than one VBR block can store
103 // then store vbr_bits - 1 bits and a continue bit103 // then store vbr_bits - 1 bits and a continue bit
104 while (in_buffer > mask) {104 while (in_buffer > mask) {
105 try self.writeBits(in_buffer & mask | continue_bit, vbr_bits);105 try self.writeBits((in_buffer & mask) | continue_bit, vbr_bits);
106 in_buffer >>= @intCast(vbr_bits - 1);106 in_buffer >>= @intCast(vbr_bits - 1);
107 }107 }
108108
lib/std/zig/parser_test.zig+42-6
...@@ -3046,19 +3046,14 @@ test "zig fmt: precedence" {...@@ -3046,19 +3046,14 @@ test "zig fmt: precedence" {
3046 \\ !(a{});3046 \\ !(a{});
3047 \\ a + b{};3047 \\ a + b{};
3048 \\ (a + b){};3048 \\ (a + b){};
3049 \\ a << b + c;
3050 \\ (a << b) + c;3049 \\ (a << b) + c;
3051 \\ a & b << c;
3052 \\ (a & b) << c;3050 \\ (a & b) << c;
3053 \\ a ^ b & c;
3054 \\ (a ^ b) & c;3051 \\ (a ^ b) & c;
3055 \\ a | b ^ c;
3056 \\ (a | b) ^ c;3052 \\ (a | b) ^ c;
3057 \\ a == b | c;3053 \\ a == b | c;
3058 \\ (a == b) | c;3054 \\ (a == b) | c;
3059 \\ a and b == c;3055 \\ a and b == c;
3060 \\ (a and b) == c;3056 \\ (a and b) == c;
3061 \\ a or b and c;
3062 \\ (a or b) and c;3057 \\ (a or b) and c;
3063 \\ (a or b) and c;3058 \\ (a or b) and c;
3064 \\ a == b and c == d;3059 \\ a == b and c == d;
...@@ -3067,6 +3062,47 @@ test "zig fmt: precedence" {...@@ -3067,6 +3062,47 @@ test "zig fmt: precedence" {
3067 );3062 );
3068}3063}
30693064
3065test "zig fmt: ambiguous precedence" {
3066 try testError(
3067 \\test "ambiguous precedence" {
3068 \\ a & b << c;
3069 \\ a << b + c;
3070 \\ a << b | c;
3071 \\ a ^ b & c;
3072 \\ a | b ^ c;
3073 \\ a or b and c;
3074 \\ a orelse b catch c;
3075 \\ a % b % c;
3076 \\}
3077 \\
3078 , &[_]Error{
3079 .ambiguous_operator_precedence,
3080 .previous_ambiguous_operator,
3081 .hint_operator_precedence_right,
3082 .ambiguous_operator_precedence,
3083 .previous_ambiguous_operator,
3084 .hint_operator_precedence_right,
3085 .ambiguous_operator_precedence,
3086 .previous_ambiguous_operator,
3087 .hint_operator_precedence_left,
3088 .ambiguous_operator_precedence,
3089 .previous_ambiguous_operator,
3090 .hint_operator_precedence_left,
3091 .ambiguous_operator_precedence,
3092 .previous_ambiguous_operator,
3093 .hint_operator_precedence_left,
3094 .ambiguous_operator_precedence,
3095 .previous_ambiguous_operator,
3096 .hint_operator_precedence_right,
3097 .ambiguous_operator_precedence,
3098 .previous_ambiguous_operator,
3099 .hint_operator_precedence_left,
3100 .illegal_chained_operators,
3101 .previous_ambiguous_operator,
3102 .hint_operator_precedence_left,
3103 });
3104}
3105
3070test "zig fmt: prefix operators" {3106test "zig fmt: prefix operators" {
3071 try testCanonical(3107 try testCanonical(
3072 \\test "prefix operators" {3108 \\test "prefix operators" {
...@@ -7205,7 +7241,7 @@ test "recovery: missing comma" {...@@ -7205,7 +7241,7 @@ test "recovery: missing comma" {
7205 \\ 2 => {}7241 \\ 2 => {}
7206 \\ 3 => {}7242 \\ 3 => {}
7207 \\ else => {7243 \\ else => {
7208 \\ foo & bar +;7244 \\ foo & bar &;
7209 \\ }7245 \\ }
7210 \\ }7246 \\ }
7211 \\}7247 \\}
lib/std/zig/system.zig+5-5
...@@ -266,8 +266,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {...@@ -266,8 +266,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
266 // Minor * 1(0),000 summed has been convention since FreeBSD 2.2 (1997)266 // Minor * 1(0),000 summed has been convention since FreeBSD 2.2 (1997)
267 // e.g. 492101 = 4.11-STABLE = 4.(9+2)267 // e.g. 492101 = 4.11-STABLE = 4.(9+2)
268 const major = value / 100_000;268 const major = value / 100_000;
269 const minor1 = value % 100_000 / 10_000; // usually 0 since 5.1269 const minor1 = (value % 100_000) / 10_000; // usually 0 since 5.1
270 const minor2 = value % 10_000 / 1_000; // 0 before 5.1, minor version since270 const minor2 = (value % 10_000) / 1_000; // 0 before 5.1, minor version since
271 const patch = value % 1_000;271 const patch = value % 1_000;
272 os.version_range.semver.min = .{ .major = major, .minor = minor1 + minor2, .patch = patch };272 os.version_range.semver.min = .{ .major = major, .minor = minor1 + minor2, .patch = patch };
273 os.version_range.semver.max = os.version_range.semver.min;273 os.version_range.semver.max = os.version_range.semver.min;
...@@ -280,8 +280,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {...@@ -280,8 +280,8 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
280 // r = 0 (*)280 // r = 0 (*)
281 // p = patchlevel281 // p = patchlevel
282 const major = value / 100_000_000;282 const major = value / 100_000_000;
283 const minor = value % 100_000_000 / 1_000_000;283 const minor = (value % 100_000_000) / 1_000_000;
284 const patch = value % 10_000 / 100;284 const patch = (value % 10_000) / 100;
285 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };285 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };
286 os.version_range.semver.max = os.version_range.semver.min;286 os.version_range.semver.max = os.version_range.semver.min;
287 },287 },
...@@ -292,7 +292,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {...@@ -292,7 +292,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
292 // m = minor; odd-numbers indicate current dev branch292 // m = minor; odd-numbers indicate current dev branch
293 // p = patch293 // p = patch
294 const major = value / 100_000;294 const major = value / 100_000;
295 const minor = value % 100_000 / 100;295 const minor = (value % 100_000) / 100;
296 const patch = value % 100;296 const patch = value % 100;
297 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };297 os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch };
298 os.version_range.semver.max = os.version_range.semver.min;298 os.version_range.semver.max = os.version_range.semver.min;
lib/std/zig/system/windows.zig+2-2
...@@ -25,7 +25,7 @@ pub fn detectRuntimeVersion() WindowsVersion {...@@ -25,7 +25,7 @@ pub fn detectRuntimeVersion() WindowsVersion {
25 // `---` `` ``--> Sub-version (Starting from Windows 10 onwards)25 // `---` `` ``--> Sub-version (Starting from Windows 10 onwards)
26 // \ `--> Service pack (Always zero in the constants defined)26 // \ `--> Service pack (Always zero in the constants defined)
27 // `--> OS version (Major & minor)27 // `--> OS version (Major & minor)
28 const os_ver: u16 = @as(u16, @intCast(version_info.dwMajorVersion & 0xff)) << 8 |28 const os_ver: u16 = (@as(u16, @intCast(version_info.dwMajorVersion & 0xff)) << 8) |
29 @as(u16, @intCast(version_info.dwMinorVersion & 0xff));29 @as(u16, @intCast(version_info.dwMinorVersion & 0xff));
30 const sp_ver: u8 = 0;30 const sp_ver: u8 = 0;
31 const sub_ver: u8 = if (os_ver >= 0x0A00) subver: {31 const sub_ver: u8 = if (os_ver >= 0x0A00) subver: {
...@@ -40,7 +40,7 @@ pub fn detectRuntimeVersion() WindowsVersion {...@@ -40,7 +40,7 @@ pub fn detectRuntimeVersion() WindowsVersion {
40 break :subver @as(u8, @truncate(last_idx));40 break :subver @as(u8, @truncate(last_idx));
41 } else 0;41 } else 0;
4242
43 const version: u32 = @as(u32, os_ver) << 16 | @as(u16, sp_ver) << 8 | sub_ver;43 const version: u32 = (@as(u32, os_ver) << 16) | (@as(u16, sp_ver) << 8) | sub_ver;
4444
45 return @as(WindowsVersion, @fromBackingInt(@intCast(version)));45 return @as(WindowsVersion, @fromBackingInt(@intCast(version)));
46}46}
src/Air.zig+1-1
...@@ -1505,7 +1505,7 @@ pub const ShuffleTwoMask = enum(u32) {...@@ -1505,7 +1505,7 @@ pub const ShuffleTwoMask = enum(u32) {
1505 return @fromBackingInt(@intCast(idx << 1));1505 return @fromBackingInt(@intCast(idx << 1));
1506 }1506 }
1507 pub fn bElem(idx: u32) ShuffleTwoMask {1507 pub fn bElem(idx: u32) ShuffleTwoMask {
1508 return @fromBackingInt(@intCast(idx << 1 | 1));1508 return @fromBackingInt(@intCast((idx << 1) | 1));
1509 }1509 }
1510 pub const Unwrapped = union(enum) {1510 pub const Unwrapped = union(enum) {
1511 /// The resulting element is this index into the first runtime vector.1511 /// The resulting element is this index into the first runtime vector.
src/Compilation.zig+2-2
...@@ -1990,7 +1990,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -1990,7 +1990,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
1990 .path = try options.dirs.global_cache.join(arena, &.{zir_sub_dir}),1990 .path = try options.dirs.global_cache.join(arena, &.{zir_sub_dir}),
1991 };1991 };
19921992
1993 const std_mod = options.std_mod orelse Module.create(arena, .{1993 const std_mod = options.std_mod orelse (Module.create(arena, .{
1994 .paths = .{1994 .paths = .{
1995 .root = try .fromRoot(arena, options.dirs, .zig_lib, "std"),1995 .root = try .fromRoot(arena, options.dirs, .zig_lib, "std"),
1996 .root_src_path = "std.zig",1996 .root_src_path = "std.zig",
...@@ -2015,7 +2015,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -2015,7 +2015,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
2015 error.StackProtectorUnsupportedByTarget => unreachable,2015 error.StackProtectorUnsupportedByTarget => unreachable,
2016 error.StackProtectorUnavailableWithoutLibC => unreachable,2016 error.StackProtectorUnavailableWithoutLibC => unreachable,
2017 error.PatchableFunctionEntryUnsupportedByBackend => unreachable,2017 error.PatchableFunctionEntryUnsupportedByBackend => unreachable,
2018 };2018 });
20192019
2020 const zcu = try arena.create(Zcu);2020 const zcu = try arena.create(Zcu);
2021 zcu.* = .{2021 zcu.* = .{
src/IncrementalDebugServer.zig+2-2
...@@ -243,7 +243,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const...@@ -243,7 +243,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
243 for (zcu.incremental_debug_state.types.keys()) |type_ip_index| {243 for (zcu.incremental_debug_state.types.keys()) |type_ip_index| {
244 const ty: Type = .fromInterned(type_ip_index);244 const ty: Type = .fromInterned(type_ip_index);
245 const ty_name = ty.containerTypeName(ip).fqn.toSlice(ip);245 const ty_name = ty.containerTypeName(ip).fqn.toSlice(ip);
246 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {246 const success = switch ((@as(u2, @intFromBool(anchor_start)) << 1) | @intFromBool(anchor_end)) {
247 0b00 => std.mem.find(u8, ty_name, query) != null,247 0b00 => std.mem.find(u8, ty_name, query) != null,
248 0b01 => std.mem.endsWith(u8, ty_name, query),248 0b01 => std.mem.endsWith(u8, ty_name, query),
249 0b10 => std.mem.startsWith(u8, ty_name, query),249 0b10 => std.mem.startsWith(u8, ty_name, query),
...@@ -264,7 +264,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const...@@ -264,7 +264,7 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
264 for (zcu.incremental_debug_state.navs.keys()) |nav_index| {264 for (zcu.incremental_debug_state.navs.keys()) |nav_index| {
265 const nav = ip.getNav(nav_index);265 const nav = ip.getNav(nav_index);
266 const nav_fqn = nav.fqn.toSlice(ip);266 const nav_fqn = nav.fqn.toSlice(ip);
267 const success = switch (@as(u2, @intFromBool(anchor_start)) << 1 | @intFromBool(anchor_end)) {267 const success = switch ((@as(u2, @intFromBool(anchor_start)) << 1) | @intFromBool(anchor_end)) {
268 0b00 => std.mem.find(u8, nav_fqn, query) != null,268 0b00 => std.mem.find(u8, nav_fqn, query) != null,
269 0b01 => std.mem.endsWith(u8, nav_fqn, query),269 0b01 => std.mem.endsWith(u8, nav_fqn, query),
270 0b10 => std.mem.startsWith(u8, nav_fqn, query),270 0b10 => std.mem.startsWith(u8, nav_fqn, query),
src/InternPool.zig+18-18
...@@ -215,7 +215,7 @@ pub const TrackedInst = extern struct {...@@ -215,7 +215,7 @@ pub const TrackedInst = extern struct {
215 };215 };
216 pub fn unwrap(tracked_inst_index: TrackedInst.Index, ip: *const InternPool) Unwrapped {216 pub fn unwrap(tracked_inst_index: TrackedInst.Index, ip: *const InternPool) Unwrapped {
217 return .{217 return .{
218 .tid = @fromBackingInt(@intCast(@backingInt(tracked_inst_index) >> ip.tid_shift_32 & ip.getTidMask())),218 .tid = @fromBackingInt(@intCast((@backingInt(tracked_inst_index) >> ip.tid_shift_32) & ip.getTidMask())),
219 .index = @backingInt(tracked_inst_index) & ip.getIndexMask(u32),219 .index = @backingInt(tracked_inst_index) & ip.getIndexMask(u32),
220 };220 };
221 }221 }
...@@ -517,7 +517,7 @@ pub const ComptimeUnit = extern struct {...@@ -517,7 +517,7 @@ pub const ComptimeUnit = extern struct {
517 };517 };
518 fn unwrap(id: Id, ip: *const InternPool) Unwrapped {518 fn unwrap(id: Id, ip: *const InternPool) Unwrapped {
519 return .{519 return .{
520 .tid = @fromBackingInt(@intCast(@backingInt(id) >> ip.tid_shift_32 & ip.getTidMask())),520 .tid = @fromBackingInt(@intCast((@backingInt(id) >> ip.tid_shift_32) & ip.getTidMask())),
521 .index = @backingInt(id) & ip.getIndexMask(u31),521 .index = @backingInt(id) & ip.getIndexMask(u31),
522 };522 };
523 }523 }
...@@ -655,7 +655,7 @@ pub const Nav = struct {...@@ -655,7 +655,7 @@ pub const Nav = struct {
655 };655 };
656 fn unwrap(nav_index: Nav.Index, ip: *const InternPool) Unwrapped {656 fn unwrap(nav_index: Nav.Index, ip: *const InternPool) Unwrapped {
657 return .{657 return .{
658 .tid = @fromBackingInt(@intCast(@backingInt(nav_index) >> ip.tid_shift_30 & ip.getTidMask())),658 .tid = @fromBackingInt(@intCast((@backingInt(nav_index) >> ip.tid_shift_30) & ip.getTidMask())),
659 .index = @backingInt(nav_index) & ip.getIndexMask(u30),659 .index = @backingInt(nav_index) & ip.getIndexMask(u30),
660 };660 };
661 }661 }
...@@ -1627,7 +1627,7 @@ pub const MapIndex = enum(u32) {...@@ -1627,7 +1627,7 @@ pub const MapIndex = enum(u32) {
1627 };1627 };
1628 fn unwrap(map_index: MapIndex, ip: *const InternPool) Unwrapped {1628 fn unwrap(map_index: MapIndex, ip: *const InternPool) Unwrapped {
1629 return .{1629 return .{
1630 .tid = @fromBackingInt(@intCast(@backingInt(map_index) >> ip.tid_shift_32 & ip.getTidMask())),1630 .tid = @fromBackingInt(@intCast((@backingInt(map_index) >> ip.tid_shift_32) & ip.getTidMask())),
1631 .index = @backingInt(map_index) & ip.getIndexMask(u32),1631 .index = @backingInt(map_index) & ip.getIndexMask(u32),
1632 };1632 };
1633 }1633 }
...@@ -1648,14 +1648,14 @@ pub const NamespaceIndex = enum(u32) {...@@ -1648,14 +1648,14 @@ pub const NamespaceIndex = enum(u32) {
1648 assert(unwrapped.bucket_index <= ip.getIndexMask(u32) >> Local.namespaces_bucket_width);1648 assert(unwrapped.bucket_index <= ip.getIndexMask(u32) >> Local.namespaces_bucket_width);
1649 assert(unwrapped.index <= Local.namespaces_bucket_mask);1649 assert(unwrapped.index <= Local.namespaces_bucket_mask);
1650 return @fromBackingInt(@intCast(@shlExact(@as(u32, @backingInt(unwrapped.tid)), ip.tid_shift_32) |1650 return @fromBackingInt(@intCast(@shlExact(@as(u32, @backingInt(unwrapped.tid)), ip.tid_shift_32) |
1651 unwrapped.bucket_index << Local.namespaces_bucket_width |1651 (unwrapped.bucket_index << Local.namespaces_bucket_width) |
1652 unwrapped.index));1652 unwrapped.index));
1653 }1653 }
1654 };1654 };
1655 fn unwrap(namespace_index: NamespaceIndex, ip: *const InternPool) Unwrapped {1655 fn unwrap(namespace_index: NamespaceIndex, ip: *const InternPool) Unwrapped {
1656 const index = @backingInt(namespace_index) & ip.getIndexMask(u32);1656 const index = @backingInt(namespace_index) & ip.getIndexMask(u32);
1657 return .{1657 return .{
1658 .tid = @fromBackingInt(@intCast(@backingInt(namespace_index) >> ip.tid_shift_32 & ip.getTidMask())),1658 .tid = @fromBackingInt(@intCast((@backingInt(namespace_index) >> ip.tid_shift_32) & ip.getTidMask())),
1659 .bucket_index = index >> Local.namespaces_bucket_width,1659 .bucket_index = index >> Local.namespaces_bucket_width,
1660 .index = index & Local.namespaces_bucket_mask,1660 .index = index & Local.namespaces_bucket_mask,
1661 };1661 };
...@@ -1696,7 +1696,7 @@ pub const FileIndex = enum(u32) {...@@ -1696,7 +1696,7 @@ pub const FileIndex = enum(u32) {
1696 };1696 };
1697 pub fn unwrap(file_index: FileIndex, ip: *const InternPool) Unwrapped {1697 pub fn unwrap(file_index: FileIndex, ip: *const InternPool) Unwrapped {
1698 return .{1698 return .{
1699 .tid = @fromBackingInt(@intCast(@backingInt(file_index) >> ip.tid_shift_32 & ip.getTidMask())),1699 .tid = @fromBackingInt(@intCast((@backingInt(file_index) >> ip.tid_shift_32) & ip.getTidMask())),
1700 .index = @backingInt(file_index) & ip.getIndexMask(u32),1700 .index = @backingInt(file_index) & ip.getIndexMask(u32),
1701 };1701 };
1702 }1702 }
...@@ -1755,7 +1755,7 @@ pub const String = enum(u32) {...@@ -1755,7 +1755,7 @@ pub const String = enum(u32) {
1755 };1755 };
1756 fn unwrap(string: String, ip: *const InternPool) Unwrapped {1756 fn unwrap(string: String, ip: *const InternPool) Unwrapped {
1757 return .{1757 return .{
1758 .tid = @fromBackingInt(@intCast(@backingInt(string) >> ip.tid_shift_32 & ip.getTidMask())),1758 .tid = @fromBackingInt(@intCast((@backingInt(string) >> ip.tid_shift_32) & ip.getTidMask())),
1759 .index = @backingInt(string) & ip.getIndexMask(u32),1759 .index = @backingInt(string) & ip.getIndexMask(u32),
1760 };1760 };
1761 }1761 }
...@@ -4199,7 +4199,7 @@ pub const Index = enum(u32) {...@@ -4199,7 +4199,7 @@ pub const Index = enum(u32) {
4199 };4199 };
4200 pub fn unwrap(index: Index, ip: *const InternPool) Unwrapped {4200 pub fn unwrap(index: Index, ip: *const InternPool) Unwrapped {
4201 return .{4201 return .{
4202 .tid = @fromBackingInt(@intCast(@backingInt(index) >> ip.tid_shift_30 & ip.getTidMask())),4202 .tid = @fromBackingInt(@intCast((@backingInt(index) >> ip.tid_shift_30) & ip.getTidMask())),
4203 .index = @backingInt(index) & ip.getIndexMask(u30),4203 .index = @backingInt(index) & ip.getIndexMask(u30),
4204 };4204 };
4205 }4205 }
...@@ -6062,7 +6062,7 @@ pub const PtrNav = struct {...@@ -6062,7 +6062,7 @@ pub const PtrNav = struct {
6062 };6062 };
6063 }6063 }
6064 fn byteOffset(data: @This()) u64 {6064 fn byteOffset(data: @This()) u64 {
6065 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6065 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6066 }6066 }
6067};6067};
60686068
...@@ -6080,7 +6080,7 @@ pub const PtrUav = struct {...@@ -6080,7 +6080,7 @@ pub const PtrUav = struct {
6080 };6080 };
6081 }6081 }
6082 fn byteOffset(data: @This()) u64 {6082 fn byteOffset(data: @This()) u64 {
6083 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6083 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6084 }6084 }
6085};6085};
60866086
...@@ -6101,7 +6101,7 @@ pub const PtrUavAligned = struct {...@@ -6101,7 +6101,7 @@ pub const PtrUavAligned = struct {
6101 };6101 };
6102 }6102 }
6103 fn byteOffset(data: @This()) u64 {6103 fn byteOffset(data: @This()) u64 {
6104 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6104 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6105 }6105 }
6106};6106};
61076107
...@@ -6119,7 +6119,7 @@ pub const PtrComptimeAlloc = struct {...@@ -6119,7 +6119,7 @@ pub const PtrComptimeAlloc = struct {
6119 };6119 };
6120 }6120 }
6121 fn byteOffset(data: @This()) u64 {6121 fn byteOffset(data: @This()) u64 {
6122 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6122 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6123 }6123 }
6124};6124};
61256125
...@@ -6137,7 +6137,7 @@ pub const PtrComptimeField = struct {...@@ -6137,7 +6137,7 @@ pub const PtrComptimeField = struct {
6137 };6137 };
6138 }6138 }
6139 fn byteOffset(data: @This()) u64 {6139 fn byteOffset(data: @This()) u64 {
6140 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6140 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6141 }6141 }
6142};6142};
61436143
...@@ -6155,7 +6155,7 @@ pub const PtrBase = struct {...@@ -6155,7 +6155,7 @@ pub const PtrBase = struct {
6155 };6155 };
6156 }6156 }
6157 fn byteOffset(data: @This()) u64 {6157 fn byteOffset(data: @This()) u64 {
6158 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6158 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6159 }6159 }
6160};6160};
61616161
...@@ -6175,7 +6175,7 @@ pub const PtrBaseIndex = struct {...@@ -6175,7 +6175,7 @@ pub const PtrBaseIndex = struct {
6175 };6175 };
6176 }6176 }
6177 fn byteOffset(data: @This()) u64 {6177 fn byteOffset(data: @This()) u64 {
6178 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6178 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6179 }6179 }
6180};6180};
61816181
...@@ -6191,7 +6191,7 @@ pub const PtrInt = struct {...@@ -6191,7 +6191,7 @@ pub const PtrInt = struct {
6191 };6191 };
6192 }6192 }
6193 fn byteOffset(data: @This()) u64 {6193 fn byteOffset(data: @This()) u64 {
6194 return @as(u64, data.byte_offset_a) << 32 | data.byte_offset_b;6194 return (@as(u64, data.byte_offset_a) << 32) | data.byte_offset_b;
6195 }6195 }
6196};6196};
61976197
...@@ -12634,7 +12634,7 @@ const PackedCallingConvention = packed struct(u18) {...@@ -12634,7 +12634,7 @@ const PackedCallingConvention = packed struct(u18) {
12634 std.lang.CallingConvention.SpirvFragmentOptions => .{12634 std.lang.CallingConvention.SpirvFragmentOptions => .{
12635 .tag = tag,12635 .tag = tag,
12636 .incoming_stack_alignment = .none,12636 .incoming_stack_alignment = .none,
12637 .extra = @as(u4, @backingInt(pl.depth_assumption)) << 1 | @intFromBool(pl.pixel_centered_integer),12637 .extra = (@as(u4, @backingInt(pl.depth_assumption)) << 1) | @intFromBool(pl.pixel_centered_integer),
12638 },12638 },
12639 std.lang.CallingConvention.SpirvMeshOptions => .{12639 std.lang.CallingConvention.SpirvMeshOptions => .{
12640 .tag = tag,12640 .tag = tag,
src/Sema.zig+2-2
...@@ -29942,10 +29942,10 @@ fn coerceVarArgParam(...@@ -29942,10 +29942,10 @@ fn coerceVarArgParam(
29942 if (!uncasted_ty.validateExtern(.param_ty, zcu)) break :int inst;29942 if (!uncasted_ty.validateExtern(.param_ty, zcu)) break :int inst;
29943 const target = zcu.getTarget();29943 const target = zcu.getTarget();
29944 const uncasted_info = uncasted_ty.intInfo(zcu);29944 const uncasted_info = uncasted_ty.intInfo(zcu);
29945 if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {29945 if (uncasted_info.bits <= (target.cTypeBitSize(switch (uncasted_info.signedness) {
29946 .signed => .int,29946 .signed => .int,
29947 .unsigned => .uint,29947 .unsigned => .uint,
29948 }) orelse break :int inst) break :int try sema.coerce(block, switch (uncasted_info.signedness) {29948 }) orelse break :int inst)) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
29949 .signed => .c_int,29949 .signed => .c_int,
29950 .unsigned => .c_uint,29950 .unsigned => .c_uint,
29951 }, inst, inst_src);29951 }, inst, inst_src);
src/codegen/aarch64/Assemble.zig+2-2
...@@ -164,7 +164,7 @@ const matchers = matchers: {...@@ -164,7 +164,7 @@ const matchers = matchers: {
164 return @call(.auto, encode, args);164 return @call(.auto, encode, args);
165 } else if (pattern_token[0] == '<') {165 } else if (pattern_token[0] == '<') {
166 const symbol_name = comptime pattern_token[1 .. std.mem.findScalarPos(u8, pattern_token, 1, '|') orelse166 const symbol_name = comptime pattern_token[1 .. std.mem.findScalarPos(u8, pattern_token, 1, '|') orelse
167 pattern_token.len - 1];167 (pattern_token.len - 1)];
168 const symbol = @field(Symbol, symbol_name);168 const symbol = @field(Symbol, symbol_name);
169 const symbol_ptr = &@field(symbols, symbol_name);169 const symbol_ptr = &@field(symbols, symbol_name);
170 const symbol_value = zonCast(SymbolSpec, @field(instruction.symbols, symbol_name), .{}).parse(source_token) orelse {170 const symbol_value = zonCast(SymbolSpec, @field(instruction.symbols, symbol_name), .{}).parse(source_token) orelse {
...@@ -453,7 +453,7 @@ const SymbolSpec = union(enum) {...@@ -453,7 +453,7 @@ const SymbolSpec = union(enum) {
453 } else {453 } else {
454 const Repr = std.math.FloatRepr(f16);454 const Repr = std.math.FloatRepr(f16);
455 const repr: Repr = @bitCast(fimm);455 const repr: Repr = @bitCast(fimm);
456 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 != 0 or switch (repr.exponent) {456 if ((repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5)) != 0 or switch (repr.exponent) {
457 .denormal, .infinite => true,457 .denormal, .infinite => true,
458 else => std.math.cast(i3, repr.exponent.unbias() - 1) == null,458 else => std.math.cast(i3, repr.exponent.unbias() - 1) == null,
459 }) {459 }) {
src/codegen/aarch64/Disassemble.zig+4-4
...@@ -31,7 +31,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr...@@ -31,7 +31,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
31 .unallocated => break :unallocated,31 .unallocated => break :unallocated,
32 .pc_relative_addressing => |pc_relative_addressing| {32 .pc_relative_addressing => |pc_relative_addressing| {
33 const group = pc_relative_addressing.group;33 const group = pc_relative_addressing.group;
34 const imm = (@as(i33, group.immhi) << 2 | @as(i33, group.immlo) << 0) + @as(i33, switch (group.op) {34 const imm = ((@as(i33, group.immhi) << 2) | (@as(i33, group.immlo) << 0)) + @as(i33, switch (group.op) {
35 .adr => aarch64.encoding.Instruction.size,35 .adr => aarch64.encoding.Instruction.size,
36 .adrp => 0,36 .adrp => 0,
37 });37 });
...@@ -311,7 +311,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr...@@ -311,7 +311,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
311 .hint => |hint| return writer.print("{f}{s}#0x{x}", .{311 .hint => |hint| return writer.print("{f}{s}#0x{x}", .{
312 fmtCase(.hint, dis.case),312 fmtCase(.hint, dis.case),
313 dis.mnemonic_operands_separator,313 dis.mnemonic_operands_separator,
314 @as(u7, hint.CRm) << 3 | @as(u7, hint.op2) << 0,314 (@as(u7, hint.CRm) << 3) | (@as(u7, hint.op2) << 0),
315 }),315 }),
316 else => |decoded| return writer.print("{f}", .{fmtCase(decoded, dis.case)}),316 else => |decoded| return writer.print("{f}", .{fmtCase(decoded, dis.case)}),
317 },317 },
...@@ -365,8 +365,8 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr...@@ -365,8 +365,8 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr
365 dis.mnemonic_operands_separator,365 dis.mnemonic_operands_separator,
366 group.Rt.decode(.{}).general(@fromBackingInt(@intCast(group.b5))).fmtCase(dis.case),366 group.Rt.decode(.{}).general(@fromBackingInt(@intCast(group.b5))).fmtCase(dis.case),
367 dis.operands_separator,367 dis.operands_separator,
368 @as(u6, group.b5) << 5 |368 (@as(u6, group.b5) << 5) |
369 @as(u6, group.b40) << 0,369 (@as(u6, group.b40) << 0),
370 dis.operands_separator,370 dis.operands_separator,
371 @as(u8, if (imm < 0) '-' else '+'),371 @as(u8, if (imm < 0) '-' else '+'),
372 @abs(imm) << 2,372 @abs(imm) << 2,
src/codegen/aarch64/Mir.zig+3-3
...@@ -208,7 +208,7 @@ fn emitReloc(...@@ -208,7 +208,7 @@ fn emitReloc(
208 };208 };
209 try atom.addReloc(gpa, .{209 try atom.addReloc(gpa, .{
210 .r_offset = offset,210 .r_offset = offset,
211 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),211 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
212 .r_addend = @bitCast(addend),212 .r_addend = @bitCast(addend),
213 }, zo);213 }, zo);
214 } else if (lf.cast(.macho)) |mf| {214 } else if (lf.cast(.macho)) |mf| {
...@@ -265,7 +265,7 @@ fn emitReloc(...@@ -265,7 +265,7 @@ fn emitReloc(
265 };265 };
266 try atom.addReloc(gpa, .{266 try atom.addReloc(gpa, .{
267 .r_offset = offset,267 .r_offset = offset,
268 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),268 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
269 .r_addend = @bitCast(addend),269 .r_addend = @bitCast(addend),
270 }, zo);270 }, zo);
271 } else if (lf.cast(.macho)) |mf| {271 } else if (lf.cast(.macho)) |mf| {
...@@ -328,7 +328,7 @@ fn emitReloc(...@@ -328,7 +328,7 @@ fn emitReloc(
328 };328 };
329 try atom.addReloc(gpa, .{329 try atom.addReloc(gpa, .{
330 .r_offset = offset,330 .r_offset = offset,
331 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(r_type),331 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(r_type),
332 .r_addend = @bitCast(addend),332 .r_addend = @bitCast(addend),
333 }, zo);333 }, zo);
334 } else if (lf.cast(.macho)) |mf| {334 } else if (lf.cast(.macho)) |mf| {
src/codegen/aarch64/Select.zig+4-4
...@@ -8099,7 +8099,7 @@ fn movImmediate(isel: *Select, dst_reg: Register, src_imm: u64) !void {...@@ -8099,7 +8099,7 @@ fn movImmediate(isel: *Select, dst_reg: Register, src_imm: u64) !void {
8099 .{ .immediate = .{8099 .{ .immediate = .{
8100 .N = @fromBackingInt(@intCast(elem_width >> 6)),8100 .N = @fromBackingInt(@intCast(elem_width >> 6)),
8101 .immr = hi + mid_masked,8101 .immr = hi + mid_masked,
8102 .imms = ((((lo + hi) & smask) | mid_masked) - 1) | -%@as(u6, @truncate(elem_width)) << 1,8102 .imms = ((((lo + hi) & smask) | mid_masked) - 1) | (-%@as(u6, @truncate(elem_width)) << 1),
8103 } },8103 } },
8104 ));8104 ));
8105 }8105 }
...@@ -10831,7 +10831,7 @@ pub const Value = struct {...@@ -10831,7 +10831,7 @@ pub const Value = struct {
10831 if (feat_fp16) {10831 if (feat_fp16) {
10832 const Repr = std.math.FloatRepr(f16);10832 const Repr = std.math.FloatRepr(f16);
10833 const repr: Repr = @bitCast(imm);10833 const repr: Repr = @bitCast(imm);
10834 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {10834 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
10835 .denormal, .infinite => false,10835 .denormal, .infinite => false,
10836 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,10836 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
10837 }) break :free try isel.emit(.fmov(mat.ra.h(), .{ .immediate = imm }));10837 }) break :free try isel.emit(.fmov(mat.ra.h(), .{ .immediate = imm }));
...@@ -10855,7 +10855,7 @@ pub const Value = struct {...@@ -10855,7 +10855,7 @@ pub const Value = struct {
10855 } };10855 } };
10856 const Repr = std.math.FloatRepr(f32);10856 const Repr = std.math.FloatRepr(f32);
10857 const repr: Repr = @bitCast(imm);10857 const repr: Repr = @bitCast(imm);
10858 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {10858 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
10859 .denormal, .infinite => false,10859 .denormal, .infinite => false,
10860 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,10860 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
10861 }) break :free try isel.emit(.fmov(mat.ra.s(), .{ .immediate = @floatCast(imm) }));10861 }) break :free try isel.emit(.fmov(mat.ra.s(), .{ .immediate = @floatCast(imm) }));
...@@ -10878,7 +10878,7 @@ pub const Value = struct {...@@ -10878,7 +10878,7 @@ pub const Value = struct {
10878 } };10878 } };
10879 const Repr = std.math.FloatRepr(f64);10879 const Repr = std.math.FloatRepr(f64);
10880 const repr: Repr = @bitCast(imm);10880 const repr: Repr = @bitCast(imm);
10881 if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 == 0 and switch (repr.exponent) {10881 if (repr.mantissa & (std.math.maxInt(Repr.Mantissa) >> 5) == 0 and switch (repr.exponent) {
10882 .denormal, .infinite => false,10882 .denormal, .infinite => false,
10883 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,10883 else => std.math.cast(i3, repr.exponent.unbias() - 1) != null,
10884 }) break :free try isel.emit(.fmov(mat.ra.d(), .{ .immediate = @floatCast(imm) }));10884 }) break :free try isel.emit(.fmov(mat.ra.d(), .{ .immediate = @floatCast(imm) }));
src/codegen/aarch64/encoding.zig+19-19
...@@ -11886,9 +11886,9 @@ pub const Instruction = packed union {...@@ -11886,9 +11886,9 @@ pub const Instruction = packed union {
11886 .cmode = switch (arrangement) {11886 .cmode = switch (arrangement) {
11887 else => unreachable,11887 else => unreachable,
11888 .@"4h", .@"8h" => @as(u3, 0b100) |11888 .@"4h", .@"8h" => @as(u3, 0b100) |
11889 @as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,11889 (@as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
11890 .@"2s", .@"4s" => @as(u3, 0b000) |11890 .@"2s", .@"4s" => @as(u3, 0b000) |
11891 @as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,11891 (@as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
11892 },11892 },
11893 .imm3 = @intCast(shifted_immediate.immediate >> 5),11893 .imm3 = @intCast(shifted_immediate.immediate >> 5),
11894 .Q = arrangement.size(),11894 .Q = arrangement.size(),
...@@ -12384,7 +12384,7 @@ pub const Instruction = packed union {...@@ -12384,7 +12384,7 @@ pub const Instruction = packed union {
12384 .dup = .{12384 .dup = .{
12385 .Rd = d.alias.encode(.{ .V = true }),12385 .Rd = d.alias.encode(.{ .V = true }),
12386 .Rn = n.alias.encode(.{ .V = true }),12386 .Rn = n.alias.encode(.{ .V = true }),
12387 .imm5 = @shlExact(@as(u5, n.format.element.index) << 1 | @as(u5, 0b1), @backingInt(elem_size)),12387 .imm5 = @shlExact((@as(u5, n.format.element.index) << 1) | @as(u5, 0b1), @backingInt(elem_size)),
12388 },12388 },
12389 } } };12389 } } };
12390 },12390 },
...@@ -12400,7 +12400,7 @@ pub const Instruction = packed union {...@@ -12400,7 +12400,7 @@ pub const Instruction = packed union {
12400 .Rd = d.alias.encode(.{ .V = true }),12400 .Rd = d.alias.encode(.{ .V = true }),
12401 .Rn = n.alias.encode(.{ .V = true }),12401 .Rn = n.alias.encode(.{ .V = true }),
12402 .imm4 = .element,12402 .imm4 = .element,
12403 .imm5 = @shlExact(@as(u5, element.index) << 1 | @as(u5, 0b1), @backingInt(elem_size)),12403 .imm5 = @shlExact((@as(u5, element.index) << 1) | @as(u5, 0b1), @backingInt(elem_size)),
12404 .Q = arrangement.size(),12404 .Q = arrangement.size(),
12405 },12405 },
12406 } } };12406 } } };
...@@ -14195,7 +14195,7 @@ pub const Instruction = packed union {...@@ -14195,7 +14195,7 @@ pub const Instruction = packed union {
14195 .Rd = d.alias.encode(.{ .V = true }),14195 .Rd = d.alias.encode(.{ .V = true }),
14196 .Rn = n.alias.encode(.{ .V = true }),14196 .Rn = n.alias.encode(.{ .V = true }),
14197 .imm4 = .{ .element = element.index << @intCast(@backingInt(elem_size)) },14197 .imm4 = .{ .element = element.index << @intCast(@backingInt(elem_size)) },
14198 .imm5 = (@as(u5, d.format.element.index) << 1 | @as(u5, 0b1) << 0) << @backingInt(elem_size),14198 .imm5 = ((@as(u5, d.format.element.index) << 1) | (@as(u5, 0b1) << 0)) << @backingInt(elem_size),
14199 .op = .element,14199 .op = .element,
14200 },14200 },
14201 } } };14201 } } };
...@@ -14211,7 +14211,7 @@ pub const Instruction = packed union {...@@ -14211,7 +14211,7 @@ pub const Instruction = packed union {
14211 .Rd = d.alias.encode(.{ .V = true }),14211 .Rd = d.alias.encode(.{ .V = true }),
14212 .Rn = n.alias.encode(.{}),14212 .Rn = n.alias.encode(.{}),
14213 .imm4 = .{ .general = .general },14213 .imm4 = .{ .general = .general },
14214 .imm5 = (@as(u5, d.format.element.index) << 1 | @as(u5, 0b1) << 0) << @backingInt(elem_size),14214 .imm5 = ((@as(u5, d.format.element.index) << 1) | (@as(u5, 0b1) << 0)) << @backingInt(elem_size),
14215 .op = .general,14215 .op = .general,
14216 },14216 },
14217 } } };14217 } } };
...@@ -15072,16 +15072,16 @@ pub const Instruction = packed union {...@@ -15072,16 +15072,16 @@ pub const Instruction = packed union {
15072 .lsl => |amount| switch (arrangement) {15072 .lsl => |amount| switch (arrangement) {
15073 else => unreachable,15073 else => unreachable,
15074 .@"8b", .@"16b" => @as(u4, 0b1110) |15074 .@"8b", .@"16b" => @as(u4, 0b1110) |
15075 @as(u4, @as(u0, @intCast(@shrExact(amount, 3)))) << 1,15075 (@as(u4, @as(u0, @intCast(@shrExact(amount, 3)))) << 1),
15076 .@"4h", .@"8h" => @as(u4, 0b1000) |15076 .@"4h", .@"8h" => @as(u4, 0b1000) |
15077 @as(u4, @as(u1, @intCast(@shrExact(amount, 3)))) << 1,15077 (@as(u4, @as(u1, @intCast(@shrExact(amount, 3)))) << 1),
15078 .@"2s", .@"4s" => @as(u4, 0b0000) |15078 .@"2s", .@"4s" => @as(u4, 0b0000) |
15079 @as(u4, @as(u2, @intCast(@shrExact(amount, 3)))) << 1,15079 (@as(u4, @as(u2, @intCast(@shrExact(amount, 3)))) << 1),
15080 },15080 },
15081 .msl => |amount| switch (arrangement) {15081 .msl => |amount| switch (arrangement) {
15082 else => unreachable,15082 else => unreachable,
15083 .@"2s", .@"4s" => @as(u4, 0b1100) |15083 .@"2s", .@"4s" => @as(u4, 0b1100) |
15084 @as(u4, @as(u1, @intCast(@shrExact(amount, 3) - 1))) << 0,15084 (@as(u4, @as(u1, @intCast(@shrExact(amount, 3) - 1))) << 0),
15085 },15085 },
15086 .replicate => switch (arrangement) {15086 .replicate => switch (arrangement) {
15087 else => unreachable,15087 else => unreachable,
...@@ -15345,9 +15345,9 @@ pub const Instruction = packed union {...@@ -15345,9 +15345,9 @@ pub const Instruction = packed union {
15345 .cmode = switch (arrangement) {15345 .cmode = switch (arrangement) {
15346 else => unreachable,15346 else => unreachable,
15347 .@"4h", .@"8h" => @as(u3, 0b100) |15347 .@"4h", .@"8h" => @as(u3, 0b100) |
15348 @as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,15348 (@as(u3, @as(u1, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
15349 .@"2s", .@"4s" => @as(u3, 0b000) |15349 .@"2s", .@"4s" => @as(u3, 0b000) |
15350 @as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0,15350 (@as(u3, @as(u2, @intCast(@shrExact(shifted_immediate.lsl, 3)))) << 0),
15351 },15351 },
15352 .imm3 = @intCast(shifted_immediate.immediate >> 5),15352 .imm3 = @intCast(shifted_immediate.immediate >> 5),
15353 .Q = arrangement.size(),15353 .Q = arrangement.size(),
...@@ -15660,9 +15660,9 @@ pub const Instruction = packed union {...@@ -15660,9 +15660,9 @@ pub const Instruction = packed union {
15660 .Rn = n.alias.encode(.{ .V = true }),15660 .Rn = n.alias.encode(.{ .V = true }),
15661 .imm5 = switch (vs) {15661 .imm5 = switch (vs) {
15662 else => unreachable,15662 else => unreachable,
15663 .byte => @as(u5, @as(u4, @intCast(n.format.element.index))) << 1 | @as(u5, 0b1) << 0,15663 .byte => (@as(u5, @as(u4, @intCast(n.format.element.index))) << 1) | (@as(u5, 0b1) << 0),
15664 .half => @as(u5, @as(u3, @intCast(n.format.element.index))) << 2 | @as(u5, 0b10) << 0,15664 .half => (@as(u5, @as(u3, @intCast(n.format.element.index))) << 2) | (@as(u5, 0b10) << 0),
15665 .single => @as(u5, @as(u2, @intCast(n.format.element.index))) << 3 | @as(u5, 0b100) << 0,15665 .single => (@as(u5, @as(u2, @intCast(n.format.element.index))) << 3) | (@as(u5, 0b100) << 0),
15666 },15666 },
15667 .Q = sf,15667 .Q = sf,
15668 },15668 },
...@@ -16492,10 +16492,10 @@ pub const Instruction = packed union {...@@ -16492,10 +16492,10 @@ pub const Instruction = packed union {
16492 .Rn = n.alias.encode(.{ .V = true }),16492 .Rn = n.alias.encode(.{ .V = true }),
16493 .imm5 = switch (vs) {16493 .imm5 = switch (vs) {
16494 else => unreachable,16494 else => unreachable,
16495 .byte => @as(u5, @as(u4, @intCast(n.format.element.index))) << 1 | @as(u5, 0b1) << 0,16495 .byte => (@as(u5, @as(u4, @intCast(n.format.element.index))) << 1) | (@as(u5, 0b1) << 0),
16496 .half => @as(u5, @as(u3, @intCast(n.format.element.index))) << 2 | @as(u5, 0b10) << 0,16496 .half => (@as(u5, @as(u3, @intCast(n.format.element.index))) << 2) | (@as(u5, 0b10) << 0),
16497 .single => @as(u5, @as(u2, @intCast(n.format.element.index))) << 3 | @as(u5, 0b100) << 0,16497 .single => (@as(u5, @as(u2, @intCast(n.format.element.index))) << 3) | (@as(u5, 0b100) << 0),
16498 .double => @as(u5, @as(u1, @intCast(n.format.element.index))) << 4 | @as(u5, 0b1000) << 0,16498 .double => (@as(u5, @as(u1, @intCast(n.format.element.index))) << 4) | (@as(u5, 0b1000) << 0),
16499 },16499 },
16500 .Q = sf,16500 .Q = sf,
16501 },16501 },
src/codegen/loongarch/Mir.zig+1-1
...@@ -181,7 +181,7 @@ fn emitReloc(...@@ -181,7 +181,7 @@ fn emitReloc(
181 const atom = zo.symbol(@backingInt(atom_index)).atom(ef).?;181 const atom = zo.symbol(@backingInt(atom_index)).atom(ef).?;
182 try atom.addReloc(zcu.gpa, .{182 try atom.addReloc(zcu.gpa, .{
183 .r_offset = offset,183 .r_offset = offset,
184 .r_info = @as(u64, @backingInt(sym_index)) << 32 | @backingInt(reloc_type),184 .r_info = (@as(u64, @backingInt(sym_index)) << 32) | @backingInt(reloc_type),
185 .r_addend = @bitCast(addend),185 .r_addend = @bitCast(addend),
186 }, zo);186 }, zo);
187 } else unreachable;187 } else unreachable;
src/codegen/riscv64/CodeGen.zig+2-2
...@@ -1764,7 +1764,7 @@ fn finishAir(...@@ -1764,7 +1764,7 @@ fn finishAir(
1764) !void {1764) !void {
1765 const tomb_bits = func.liveness.getTombBits(inst);1765 const tomb_bits = func.liveness.getTombBits(inst);
1766 for (0.., operands) |op_index, op| {1766 for (0.., operands) |op_index, op| {
1767 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;1767 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
1768 if (func.reused_operands.isSet(op_index)) continue;1768 if (func.reused_operands.isSet(op_index)) continue;
1769 try func.processDeath(op.toIndexAllowNone() orelse continue);1769 try func.processDeath(op.toIndexAllowNone() orelse continue);
1770 }1770 }
...@@ -6272,7 +6272,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {...@@ -6272,7 +6272,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
6272 "";6272 "";
62736273
6274 op.* = switch (args.items[6274 op.* = switch (args.items[
6275 arg_map.get(op_str["%[".len .. mod_index orelse op_str.len - "]".len]) orelse6275 arg_map.get(op_str["%[".len .. mod_index orelse (op_str.len - "]".len)]) orelse
6276 return func.fail("no matching constraint: '{s}'", .{op_str})6276 return func.fail("no matching constraint: '{s}'", .{op_str})
6277 ]) {6277 ]) {
6278 .lea_symbol => |sym_off| if (mem.eql(u8, modifier, "plt")) blk: {6278 .lea_symbol => |sym_off| if (mem.eql(u8, modifier, "plt")) blk: {
src/codegen/riscv64/encoding.zig+2-2
...@@ -582,8 +582,8 @@ pub const Instruction = union(Lir.Format) {...@@ -582,8 +582,8 @@ pub const Instruction = union(Lir.Format) {
582582
583 .opcode = opcode,583 .opcode = opcode,
584 .funct3 = @backingInt(amo.width),584 .funct3 = @backingInt(amo.width),
585 .funct7 = @as(u7, amo.funct5) << 2 |585 .funct7 = (@as(u7, amo.funct5) << 2) |
586 @as(u7, @intFromBool(ops[3].barrier == .rl)) << 1 |586 (@as(u7, @intFromBool(ops[3].barrier == .rl)) << 1) |
587 @as(u7, @intFromBool(ops[4].barrier == .aq)),587 @as(u7, @intFromBool(ops[4].barrier == .aq)),
588 },588 },
589 else => unreachable,589 else => unreachable,
src/codegen/sparc64/CodeGen.zig+2-2
...@@ -3475,11 +3475,11 @@ fn finishAirBookkeeping(self: *Self) void {...@@ -3475,11 +3475,11 @@ fn finishAirBookkeeping(self: *Self) void {
3475fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Air.Liveness.bpi - 1]Air.Inst.Ref) void {3475fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Air.Liveness.bpi - 1]Air.Inst.Ref) void {
3476 const tomb_bits = self.liveness.getTombBits(inst);3476 const tomb_bits = self.liveness.getTombBits(inst);
3477 for (0.., operands) |op_index, op| {3477 for (0.., operands) |op_index, op| {
3478 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;3478 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
3479 if (self.reused_operands.isSet(op_index)) continue;3479 if (self.reused_operands.isSet(op_index)) continue;
3480 self.processDeath(op.toIndexAllowNone() orelse continue);3480 self.processDeath(op.toIndexAllowNone() orelse continue);
3481 }3481 }
3482 if (tomb_bits & 1 << (Air.Liveness.bpi - 1) == 0) {3482 if (tomb_bits & (1 << (Air.Liveness.bpi - 1)) == 0) {
3483 log.debug("%{d} => {}", .{ inst, result });3483 log.debug("%{d} => {}", .{ inst, result });
3484 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];3484 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
3485 branch.inst_table.putAssumeCapacityNoClobber(inst, result);3485 branch.inst_table.putAssumeCapacityNoClobber(inst, result);
src/codegen/spirv/CodeGen.zig+1-1
...@@ -1191,7 +1191,7 @@ fn constInt(cg: *CodeGen, ty: Type, value: anytype) !Id {...@@ -1191,7 +1191,7 @@ fn constInt(cg: *CodeGen, ty: Type, value: anytype) !Id {
1191 const truncated_value = if (backing_bits == 64)1191 const truncated_value = if (backing_bits == 64)
1192 value641192 value64
1193 else1193 else
1194 value64 & (@as(u64, 1) << @intCast(backing_bits)) - 1;1194 value64 & ((@as(u64, 1) << @intCast(backing_bits)) - 1);
11951195
1196 break :blk switch (backing_bits) {1196 break :blk switch (backing_bits) {
1197 1...32 => .{ .uint32 = @truncate(truncated_value) },1197 1...32 => .{ .uint32 = @truncate(truncated_value) },
src/codegen/x86_64/CodeGen.zig+17-17
...@@ -173255,7 +173255,7 @@ fn finishAir(...@@ -173255,7 +173255,7 @@ fn finishAir(
173255) !void {173255) !void {
173256 const tomb_bits = self.liveness.getTombBits(inst);173256 const tomb_bits = self.liveness.getTombBits(inst);
173257 for (0.., operands) |op_index, op| {173257 for (0.., operands) |op_index, op| {
173258 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;173258 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
173259 if (self.reused_operands.isSet(op_index)) continue;173259 if (self.reused_operands.isSet(op_index)) continue;
173260 try self.processDeath(op.toIndexAllowNone() orelse continue, .{});173260 try self.processDeath(op.toIndexAllowNone() orelse continue, .{});
173261 }173261 }
...@@ -176321,7 +176321,7 @@ fn lowerSwitchBr(...@@ -176321,7 +176321,7 @@ fn lowerSwitchBr(
176321 const unsigned_condition_ty = try cg.pt.intType(.unsigned, cg.intInfo(condition_ty).?.bits);176321 const unsigned_condition_ty = try cg.pt.intType(.unsigned, cg.intInfo(condition_ty).?.bits);
176322176322
176323 const ExpectedContents = extern struct {176323 const ExpectedContents = extern struct {
176324 liveness_deaths: [1 << 8 | 1]Air.Inst.Index,176324 liveness_deaths: [(1 << 8) | 1]Air.Inst.Index,
176325 bigint_limbs: [std.math.big.int.calcTwosCompLimbCount(1 << 10)]std.math.big.Limb,176325 bigint_limbs: [std.math.big.int.calcTwosCompLimbCount(1 << 10)]std.math.big.Limb,
176326 relocs: [1 << 6]Mir.Inst.Index,176326 relocs: [1 << 6]Mir.Inst.Index,
176327 };176327 };
...@@ -177310,7 +177310,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177310,7 +177310,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177310 else177310 else
177311 "";177311 "";
177312 op.* = switch (args[177312 op.* = switch (args[
177313 arg_map.get(op_str["%[".len .. colon orelse op_str.len - "]".len]) orelse177313 arg_map.get(op_str["%[".len .. colon orelse (op_str.len - "]".len)]) orelse
177314 return self.fail("no matching constraint: '{s}'", .{op_str})177314 return self.fail("no matching constraint: '{s}'", .{op_str})
177315 ]) {177315 ]) {
177316 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or177316 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or
...@@ -177454,7 +177454,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177454,7 +177454,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177454 else177454 else
177455 "";177455 "";
177456 break :disp switch (args[177456 break :disp switch (args[
177457 arg_map.get(op_str["%[".len .. colon orelse open - "]".len]) orelse177457 arg_map.get(op_str["%[".len .. colon orelse (open - "]".len)]) orelse
177458 return self.fail("no matching constraint: '{s}'", .{op_str})177458 return self.fail("no matching constraint: '{s}'", .{op_str})
177459 ]) {177459 ]) {
177460 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or177460 .immediate => |imm| if (std.mem.eql(u8, modifier, "") or
...@@ -179566,7 +179566,7 @@ fn atomicOp(...@@ -179566,7 +179566,7 @@ fn atomicOp(
179566 };179566 };
179567 defer if (mem_lock) |lock| self.register_manager.unlockReg(lock);179567 defer if (mem_lock) |lock| self.register_manager.unlockReg(lock);
179568179568
179569 const use_sse = rmw_op orelse .Xchg != .Xchg and val_ty.isRuntimeFloat();179569 const use_sse = (rmw_op orelse .Xchg) != .Xchg and val_ty.isRuntimeFloat();
179570 const strat: enum { lock, loop, libcall } = if (use_sse) .loop else switch (rmw_op orelse .Xchg) {179570 const strat: enum { lock, loop, libcall } = if (use_sse) .loop else switch (rmw_op orelse .Xchg) {
179571 .Xchg,179571 .Xchg,
179572 .Add,179572 .Add,
...@@ -179626,7 +179626,7 @@ fn atomicOp(...@@ -179626,7 +179626,7 @@ fn atomicOp(
179626179626
179627 try self.asmRegisterMemory(.{ ._, .mov }, registerAlias(.rax, val_abi_size), ptr_mem);179627 try self.asmRegisterMemory(.{ ._, .mov }, registerAlias(.rax, val_abi_size), ptr_mem);
179628 const loop: Mir.Inst.Index = @intCast(self.mir_instructions.len);179628 const loop: Mir.Inst.Index = @intCast(self.mir_instructions.len);
179629 if (!use_sse and rmw_op orelse .Xchg != .Xchg) {179629 if (!use_sse and (rmw_op orelse .Xchg) != .Xchg) {
179630 try self.genSetReg(tmp_reg, val_ty, .{ .register = .rax }, .{});179630 try self.genSetReg(tmp_reg, val_ty, .{ .register = .rax }, .{});
179631 }179631 }
179632 if (rmw_op) |op| if (use_sse) {179632 if (rmw_op) |op| if (use_sse) {
...@@ -188854,7 +188854,7 @@ const Temp = struct {...@@ -188854,7 +188854,7 @@ const Temp = struct {
188854 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {188854 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {
188855 if (op_temp.index == temp.index) continue;188855 if (op_temp.index == temp.index) continue;
188856 if (op_temp.tracking(cg).short != .dead) try op_temp.die(cg);188856 if (op_temp.tracking(cg).short != .dead) try op_temp.die(cg);
188857 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;188857 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
188858 if (cg.reused_operands.isSet(op_index)) continue;188858 if (cg.reused_operands.isSet(op_index)) continue;
188859 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});188859 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});
188860 }188860 }
...@@ -188916,7 +188916,7 @@ const Temp = struct {...@@ -188916,7 +188916,7 @@ const Temp = struct {
188916 }188916 }
188917 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {188917 for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| {
188918 if (op_temp.index != temp.index) continue;188918 if (op_temp.index != temp.index) continue;
188919 if (tomb_bits & @as(Air.Liveness.Bpi, 1) << @intCast(op_index) == 0) continue;188919 if (tomb_bits & (@as(Air.Liveness.Bpi, 1) << @intCast(op_index)) == 0) continue;
188920 if (cg.reused_operands.isSet(op_index)) continue;188920 if (cg.reused_operands.isSet(op_index)) continue;
188921 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});188921 try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{});
188922 }188922 }
...@@ -190117,9 +190117,9 @@ const Select = struct {...@@ -190117,9 +190117,9 @@ const Select = struct {
190117 (@as(u64, std.math.maxInt(u64)) >> @intCast(res_scalar_info.bits - scalar_info.bits))),190117 (@as(u64, std.math.maxInt(u64)) >> @intCast(res_scalar_info.bits - scalar_info.bits))),
190118 .@"0x1p63_mem" => switch (res_scalar_info.bits) {190118 .@"0x1p63_mem" => switch (res_scalar_info.bits) {
190119 else => unreachable,190119 else => unreachable,
190120 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << 64 - 16,190120 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << (64 - 16),
190121 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << 64 - 32,190121 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << (64 - 32),
190122 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << 64 - 64,190122 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << (64 - 64),
190123 },190123 },
190124 };190124 };
190125 const shift: u6 = @intCast(64 - res_scalar_info.bits);190125 const shift: u6 = @intCast(64 - res_scalar_info.bits);
...@@ -191518,8 +191518,8 @@ const Select = struct {...@@ -191518,8 +191518,8 @@ const Select = struct {
191518 @as(SignedImm, @intCast(s.cg.nonBoolScalarBitSize(op.flags.base.ref.typeOf(s)))),191518 @as(SignedImm, @intCast(s.cg.nonBoolScalarBitSize(op.flags.base.ref.typeOf(s)))),
191519 .log2_src0_elem_size => @intCast(std.math.log2(Select.Operand.Ref.src0.typeOf(s).indexableElem(s.cg.pt.zcu).abiSize(s.cg.pt.zcu))),191519 .log2_src0_elem_size => @intCast(std.math.log2(Select.Operand.Ref.src0.typeOf(s).indexableElem(s.cg.pt.zcu).abiSize(s.cg.pt.zcu))),
191520 .elem_mask => @as(u8, std.math.maxInt(u8)) >> @intCast(191520 .elem_mask => @as(u8, std.math.maxInt(u8)) >> @intCast(
191521 8 - ((s.cg.unalignedSize(op.flags.base.ref.typeOf(s)) - 1) %191521 8 - (((s.cg.unalignedSize(op.flags.base.ref.typeOf(s)) - 1) %
191522 @divExact(op.flags.base.size.bitSize(s.cg.target), 8) + 1 >>191522 @divExact(op.flags.base.size.bitSize(s.cg.target), 8) + 1) >>
191523 op.flags.index.scale.toLog2()),191523 op.flags.index.scale.toLog2()),
191524 ),191524 ),
191525 inline .smin, .smax, .umax, .smin_shr_src1, .smax_shr_src1, .umax_shr_src1 => |adjust| switch (op.flags.base.size) {191525 inline .smin, .smax, .umax, .smin_shr_src1, .smax_shr_src1, .umax_shr_src1 => |adjust| switch (op.flags.base.size) {
...@@ -191548,7 +191548,7 @@ const Select = struct {...@@ -191548,7 +191548,7 @@ const Select = struct {
191548 },191548 },
191549 .repeat => switch (SignedImm) {191549 .repeat => switch (SignedImm) {
191550 else => unreachable,191550 else => unreachable,
191551 i64 => return @as(i64, op.imm) << 32 | @as(u32, @bitCast(op.imm)),191551 i64 => return (@as(i64, op.imm) << 32) | @as(u32, @bitCast(op.imm)),
191552 },191552 },
191553 };191553 };
191554 const rhs = op.flags.adjust.rhs.toLog2();191554 const rhs = op.flags.adjust.rhs.toLog2();
...@@ -191559,10 +191559,10 @@ const Select = struct {...@@ -191559,10 +191559,10 @@ const Select = struct {
191559 break :op_res op_res[0];191559 break :op_res op_res[0];
191560 },191560 },
191561 .div => @shrExact(lhs, rhs),191561 .div => @shrExact(lhs, rhs),
191562 .div_8_down => lhs >> 3 & @as(SignedImm, -1) << rhs,191562 .div_8_down => (lhs >> 3) & (@as(SignedImm, -1) << rhs),
191563 .rem_8_mul => lhs & ((@as(SignedImm, 8) << rhs) - 1),191563 .rem_8_mul => lhs & ((@as(SignedImm, 8) << rhs) - 1),
191564 .up_2_mul => ((lhs - 1) & @as(SignedImm, -2) << rhs) + (@as(SignedImm, 2) << rhs),191564 .up_2_mul => ((lhs - 1) & (@as(SignedImm, -2) << rhs)) + (@as(SignedImm, 2) << rhs),
191565 .up_32_mul => ((lhs - 1) & @as(SignedImm, -32) << rhs) + (@as(SignedImm, 32) << rhs),191565 .up_32_mul => ((lhs - 1) & (@as(SignedImm, -32) << rhs)) + (@as(SignedImm, 32) << rhs),
191566 };191566 };
191567 const disp: SignedImm = @bitCast(@as(UnsignedImm, @as(u32, @bitCast(op.imm))));191567 const disp: SignedImm = @bitCast(@as(UnsignedImm, @as(u32, @bitCast(op.imm))));
191568 return switch (op.flags.adjust.sign) {191568 return switch (op.flags.adjust.sign) {
src/codegen/x86_64/Disassembler.zig+1-1
...@@ -378,7 +378,7 @@ fn parseEncoding(dis: *Disassembler, prefixes: Prefixes) !?Encoding {...@@ -378,7 +378,7 @@ fn parseEncoding(dis: *Disassembler, prefixes: Prefixes) !?Encoding {
378}378}
379379
380fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Register {380fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Register {
381 const reg_id: u4 = @as(u4, @intCast(@intFromBool(is_extended))) << 3 | low_enc;381 const reg_id: u4 = (@as(u4, @intCast(@intFromBool(is_extended))) << 3) | low_enc;
382 const reg = @as(Register, @fromBackingInt(@intCast(reg_id))).toBitSize(bit_size);382 const reg = @as(Register, @fromBackingInt(@intCast(reg_id))).toBitSize(bit_size);
383 return switch (reg) {383 return switch (reg) {
384 .spl => if (rex.present or rex.isSet()) .spl else .ah,384 .spl => if (rex.present or rex.isSet()) .spl else .ah,
src/codegen/x86_64/Emit.zig+6-6
...@@ -694,13 +694,13 @@ pub fn emitMir(emit: *Emit) Error!void {...@@ -694,13 +694,13 @@ pub fn emitMir(emit: *Emit) Error!void {
694694
695 for (emit.table_relocs.items) |table_reloc| try atom.addReloc(gpa, .{695 for (emit.table_relocs.items) |table_reloc| try atom.addReloc(gpa, .{
696 .r_offset = table_reloc.source_offset,696 .r_offset = table_reloc.source_offset,
697 .r_info = @as(u64, @backingInt(emit.atom_id)) << 32 | @backingInt(std.elf.R_X86_64.@"32S"),697 .r_info = (@as(u64, @backingInt(emit.atom_id)) << 32) | @backingInt(std.elf.R_X86_64.@"32S"),
698 .r_addend = @as(i64, table_offset) + table_reloc.target_offset,698 .r_addend = @as(i64, table_offset) + table_reloc.target_offset,
699 }, zo);699 }, zo);
700 for (emit.lower.mir.table) |entry| {700 for (emit.lower.mir.table) |entry| {
701 try atom.addReloc(gpa, .{701 try atom.addReloc(gpa, .{
702 .r_offset = table_offset,702 .r_offset = table_offset,
703 .r_info = @as(u64, @backingInt(emit.atom_id)) << 32 | @backingInt(std.elf.R_X86_64.@"64"),703 .r_info = (@as(u64, @backingInt(emit.atom_id)) << 32) | @backingInt(std.elf.R_X86_64.@"64"),
704 .r_addend = emit.code_offset_mapping.items[entry],704 .r_addend = emit.code_offset_mapping.items[entry],
705 }, zo);705 }, zo);
706 table_offset += ptr_size;706 table_offset += ptr_size;
...@@ -812,7 +812,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI...@@ -812,7 +812,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
812 .PC32;812 .PC32;
813 try atom.addReloc(gpa, .{813 try atom.addReloc(gpa, .{
814 .r_offset = end_offset - 4,814 .r_offset = end_offset - 4,
815 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),815 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
816 .r_addend = if (emit.pic) reloc.off - 4 else reloc.off,816 .r_addend = if (emit.pic) reloc.off - 4 else reloc.off,
817 }, zo);817 }, zo);
818 } else if (emit.bin_file.cast(.macho)) |macho_file| {818 } else if (emit.bin_file.cast(.macho)) |macho_file| {
...@@ -854,7 +854,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI...@@ -854,7 +854,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
854 const r_type: std.elf.R_X86_64 = .PLT32;854 const r_type: std.elf.R_X86_64 = .PLT32;
855 try atom.addReloc(gpa, .{855 try atom.addReloc(gpa, .{
856 .r_offset = end_offset - 4,856 .r_offset = end_offset - 4,
857 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),857 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
858 .r_addend = reloc.off - 4,858 .r_addend = reloc.off - 4,
859 }, zo);859 }, zo);
860 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(860 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
...@@ -894,7 +894,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI...@@ -894,7 +894,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
894 const r_type: std.elf.R_X86_64 = if (emit.pic) .TLSLD else unreachable;894 const r_type: std.elf.R_X86_64 = if (emit.pic) .TLSLD else unreachable;
895 try atom.addReloc(gpa, .{895 try atom.addReloc(gpa, .{
896 .r_offset = end_offset - 4,896 .r_offset = end_offset - 4,
897 .r_info = @as(u64, @backingInt(target_symbol)) << 32 | @backingInt(r_type),897 .r_info = (@as(u64, @backingInt(target_symbol)) << 32) | @backingInt(r_type),
898 .r_addend = reloc.off - 4,898 .r_addend = reloc.off - 4,
899 }, zo);899 }, zo);
900 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(900 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
...@@ -912,7 +912,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI...@@ -912,7 +912,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
912 const r_type: std.elf.R_X86_64 = if (emit.pic) .DTPOFF32 else .TPOFF32;912 const r_type: std.elf.R_X86_64 = if (emit.pic) .DTPOFF32 else .TPOFF32;
913 try atom.addReloc(gpa, .{913 try atom.addReloc(gpa, .{
914 .r_offset = end_offset - 4,914 .r_offset = end_offset - 4,
915 .r_info = @as(u64, @backingInt(target.symbol)) << 32 | @backingInt(r_type),915 .r_info = (@as(u64, @backingInt(target.symbol)) << 32) | @backingInt(r_type),
916 .r_addend = reloc.off,916 .r_addend = reloc.off,
917 }, zo);917 }, zo);
918 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(918 } else if (emit.bin_file.cast(.elf2)) |elf| try elf.addReloc(
src/codegen/x86_64/Mir.zig+1-1
...@@ -1949,7 +1949,7 @@ pub const Memory = struct {...@@ -1949,7 +1949,7 @@ pub const Memory = struct {
1949 assert(mem.info.base == .reg);1949 assert(mem.info.base == .reg);
1950 return encoder.Instruction.Memory.initMoffs(1950 return encoder.Instruction.Memory.initMoffs(
1951 @fromBackingInt(@intCast(mem.base)),1951 @fromBackingInt(@intCast(mem.base)),
1952 @as(u64, mem.extra) << 32 | mem.off,1952 (@as(u64, mem.extra) << 32) | mem.off,
1953 );1953 );
1954 },1954 },
1955 }1955 }
src/codegen/x86_64/bits.zig+1-1
...@@ -664,7 +664,7 @@ pub const Register = enum(u8) {...@@ -664,7 +664,7 @@ pub const Register = enum(u8) {
664 .general_purpose, .gphi => if (reg.isExtended())664 .general_purpose, .gphi => if (reg.isExtended())
665 reg.enc()665 reg.enc()
666 else666 else
667 @as(u3, @truncate(@as(u24, 0o54673120) >> @as(u5, reg.enc()) * 3)),667 @as(u3, @truncate(@as(u24, 0o54673120) >> (@as(u5, reg.enc()) * 3))),
668 .sse => 17 + @as(u6, reg.enc()),668 .sse => 17 + @as(u6, reg.enc()),
669 .x87 => 33 + @as(u6, reg.enc()),669 .x87 => 33 + @as(u6, reg.enc()),
670 .mmx => 41 + @as(u6, reg.enc()),670 .mmx => 41 + @as(u6, reg.enc()),
src/codegen/x86_64/encoder.zig+14-14
...@@ -844,25 +844,25 @@ fn Encoder(comptime opts: Options) type {...@@ -844,25 +844,25 @@ fn Encoder(comptime opts: Options) type {
844 try self.w.writeByte(0b1100_0100);844 try self.w.writeByte(0b1100_0100);
845845
846 try self.w.writeByte(846 try self.w.writeByte(
847 @as(u8, ~@intFromBool(fields.r)) << 7 |847 (@as(u8, ~@intFromBool(fields.r)) << 7) |
848 @as(u8, ~@intFromBool(fields.x)) << 6 |848 (@as(u8, ~@intFromBool(fields.x)) << 6) |
849 @as(u8, ~@intFromBool(fields.b)) << 5 |849 (@as(u8, ~@intFromBool(fields.b)) << 5) |
850 @as(u8, @backingInt(fields.m)) << 0,850 (@as(u8, @backingInt(fields.m)) << 0),
851 );851 );
852852
853 try self.w.writeByte(853 try self.w.writeByte(
854 @as(u8, @intFromBool(fields.w)) << 7 |854 (@as(u8, @intFromBool(fields.w)) << 7) |
855 @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |855 (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) |
856 @as(u8, @intFromBool(fields.l)) << 2 |856 (@as(u8, @intFromBool(fields.l)) << 2) |
857 @as(u8, @backingInt(fields.p)) << 0,857 (@as(u8, @backingInt(fields.p)) << 0),
858 );858 );
859 } else {859 } else {
860 try self.w.writeByte(0b1100_0101);860 try self.w.writeByte(0b1100_0101);
861 try self.w.writeByte(861 try self.w.writeByte(
862 @as(u8, ~@intFromBool(fields.r)) << 7 |862 (@as(u8, ~@intFromBool(fields.r)) << 7) |
863 @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 |863 (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) |
864 @as(u8, @intFromBool(fields.l)) << 2 |864 (@as(u8, @intFromBool(fields.l)) << 2) |
865 @as(u8, @backingInt(fields.p)) << 0,865 (@as(u8, @backingInt(fields.p)) << 0),
866 );866 );
867 }867 }
868 }868 }
...@@ -910,7 +910,7 @@ fn Encoder(comptime opts: Options) type {...@@ -910,7 +910,7 @@ fn Encoder(comptime opts: Options) type {
910 ///910 ///
911 /// Remember to add a REX prefix byte if reg or rm are extended!911 /// Remember to add a REX prefix byte if reg or rm are extended!
912 pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) !void {912 pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) !void {
913 try self.w.writeByte(@as(u8, mod) << 6 | @as(u8, reg_or_opx) << 3 | rm);913 try self.w.writeByte((@as(u8, mod) << 6) | (@as(u8, reg_or_opx) << 3) | rm);
914 }914 }
915915
916 /// Construct a ModR/M byte using direct r/m addressing916 /// Construct a ModR/M byte using direct r/m addressing
...@@ -996,7 +996,7 @@ fn Encoder(comptime opts: Options) type {...@@ -996,7 +996,7 @@ fn Encoder(comptime opts: Options) type {
996 ///996 ///
997 /// Remember to add a REX prefix byte if index or base are extended!997 /// Remember to add a REX prefix byte if index or base are extended!
998 pub fn sib(self: Self, scale: u2, index: u3, base: u3) !void {998 pub fn sib(self: Self, scale: u2, index: u3, base: u3) !void {
999 try self.w.writeByte(@as(u8, scale) << 6 | @as(u8, index) << 3 | base);999 try self.w.writeByte((@as(u8, scale) << 6) | (@as(u8, index) << 3) | base);
1000 }1000 }
10011001
1002 /// Construct a SIB byte with scale * index + base, no frills.1002 /// Construct a SIB byte with scale * index + base, no frills.
src/fmt.zig+2-1
...@@ -323,7 +323,8 @@ fn fmtPathDir(...@@ -323,7 +323,8 @@ fn fmtPathDir(
323323
324 if (mem.startsWith(u8, entry.name, ".")) continue;324 if (mem.startsWith(u8, entry.name, ".")) continue;
325325
326 if (is_dir or entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) {326 const is_zig_or_zon = entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"));
327 if (is_dir or is_zig_or_zon) {
327 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });328 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });
328 defer fmt.gpa.free(full_path);329 defer fmt.gpa.free(full_path);
329330
src/link/Dwarf.zig+3-3
...@@ -697,7 +697,7 @@ const Unit = struct {...@@ -697,7 +697,7 @@ const Unit = struct {
697 fw.writeByte(DW.LNS.extended_op) catch unreachable;697 fw.writeByte(DW.LNS.extended_op) catch unreachable;
698 const extended_op_bytes = fw.end;698 const extended_op_bytes = fw.end;
699 var op_len_bytes: u5 = 1;699 var op_len_bytes: u5 = 1;
700 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << 7 * op_len_bytes)) {700 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << (7 * op_len_bytes))) {
701 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,701 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,
702 .eq => {702 .eq => {
703 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte703 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
...@@ -893,7 +893,7 @@ const Entry = struct {...@@ -893,7 +893,7 @@ const Entry = struct {
893 fw.writeUleb128(try dwarf.refAbbrevCode(.pad_n)) catch unreachable;893 fw.writeUleb128(try dwarf.refAbbrevCode(.pad_n)) catch unreachable;
894 const abbrev_code_bytes = fw.end;894 const abbrev_code_bytes = fw.end;
895 var block_len_bytes: u5 = 1;895 var block_len_bytes: u5 = 1;
896 while (true) switch (std.math.order(len - abbrev_code_bytes - block_len_bytes, @as(u32, 1) << 7 * block_len_bytes)) {896 while (true) switch (std.math.order(len - abbrev_code_bytes - block_len_bytes, @as(u32, 1) << (7 * block_len_bytes))) {
897 .lt => break fw.writeUleb128(len - abbrev_code_bytes - block_len_bytes) catch unreachable,897 .lt => break fw.writeUleb128(len - abbrev_code_bytes - block_len_bytes) catch unreachable,
898 .eq => {898 .eq => {
899 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte899 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
...@@ -915,7 +915,7 @@ const Entry = struct {...@@ -915,7 +915,7 @@ const Entry = struct {
915 fw.writeByte(DW.LNS.extended_op) catch unreachable;915 fw.writeByte(DW.LNS.extended_op) catch unreachable;
916 const extended_op_bytes = fw.end;916 const extended_op_bytes = fw.end;
917 var op_len_bytes: u5 = 1;917 var op_len_bytes: u5 = 1;
918 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << 7 * op_len_bytes)) {918 while (true) switch (std.math.order(len - extended_op_bytes - op_len_bytes, @as(u32, 1) << (7 * op_len_bytes))) {
919 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,919 .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable,
920 .eq => {920 .eq => {
921 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte921 // no length will ever work, so undercount and futz with the leb encoding to make up the missing byte
src/link/Dwarf2.zig+2-2
...@@ -1891,7 +1891,7 @@ pub fn genDebugInfoPadding(dwarf: *Dwarf, di_w: *std.Io.Writer, size: u64) std.I...@@ -1891,7 +1891,7 @@ pub fn genDebugInfoPadding(dwarf: *Dwarf, di_w: *std.Io.Writer, size: u64) std.I
1891 var block_len_size: u5 = 1;1891 var block_len_size: u5 = 1;
1892 while (true) switch (std.math.order(1892 while (true) switch (std.math.order(
1893 size - abbrev_code_size - block_len_size,1893 size - abbrev_code_size - block_len_size,
1894 @as(u64, 1) << 7 * block_len_size,1894 @as(u64, 1) << (7 * block_len_size),
1895 )) {1895 )) {
1896 .lt => break try di_w.writeUleb128(size - abbrev_code_size - block_len_size),1896 .lt => break try di_w.writeUleb128(size - abbrev_code_size - block_len_size),
1897 .eq => {1897 .eq => {
...@@ -2023,7 +2023,7 @@ pub fn genDebugLinePadding(dl_w: *std.Io.Writer, size: u64) std.Io.Writer.Error!...@@ -2023,7 +2023,7 @@ pub fn genDebugLinePadding(dl_w: *std.Io.Writer, size: u64) std.Io.Writer.Error!
2023 var op_len_size: u5 = 1;2023 var op_len_size: u5 = 1;
2024 while (true) switch (std.math.order(2024 while (true) switch (std.math.order(
2025 size - extended_op_size - op_len_size,2025 size - extended_op_size - op_len_size,
2026 @as(u64, 1) << 7 * op_len_size,2026 @as(u64, 1) << (7 * op_len_size),
2027 )) {2027 )) {
2028 .lt => break try dl_w.writeUleb128(size - extended_op_size - op_len_size),2028 .lt => break try dl_w.writeUleb128(size - extended_op_size - op_len_size),
2029 .eq => {2029 .eq => {
src/link/Elf2.zig+4-4
...@@ -7694,11 +7694,11 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load...@@ -7694,11 +7694,11 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load
7694 {7694 {
7695 break :load_object;7695 break :load_object;
7696 }7696 }
7697 const member = header.name() orelse member: {7697 const member = header.name() orelse (member: {
7698 const strtab_offset = header.nameOffset() catch |err| switch (err) {7698 const strtab_offset = (header.nameOffset() catch |err| switch (err) {
7699 error.Overflow => break :member error.Overflow,7699 error.Overflow => break :member error.Overflow,
7700 error.InvalidCharacter => break :load_object,7700 error.InvalidCharacter => break :load_object,
7701 } orelse break :load_object;7701 }) orelse break :load_object;
7702 const strtab_written = strtab.written();7702 const strtab_written = strtab.written();
7703 if (strtab_offset > strtab_written.len) break :member error.Overflow;7703 if (strtab_offset > strtab_written.len) break :member error.Overflow;
7704 const member = std.mem.sliceTo(strtab_written[strtab_offset..], '\n');7704 const member = std.mem.sliceTo(strtab_written[strtab_offset..], '\n');
...@@ -7708,7 +7708,7 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load...@@ -7708,7 +7708,7 @@ fn loadArchive(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) (Load
7708 member;7708 member;
7709 } catch |err| switch (err) {7709 } catch |err| switch (err) {
7710 error.Overflow => return diags.failParse(path, "bad member name offset", .{}),7710 error.Overflow => return diags.failParse(path, "bad member name offset", .{}),
7711 };7711 });
7712 try elf.loadObject(path, member, fr, .{ .offset = offset, .size = size });7712 try elf.loadObject(path, member, fr, .{ .offset = offset, .size = size });
7713 }7713 }
7714 try fr.seekTo(std.mem.alignForward(u64, offset + size, 2));7714 try fr.seekTo(std.mem.alignForward(u64, offset + size, 2));
src/link/MachO/UnwindInfo.zig+1-1
...@@ -228,7 +228,7 @@ pub fn generate(info: *UnwindInfo, macho_file: *MachO) !void {...@@ -228,7 +228,7 @@ pub fn generate(info: *UnwindInfo, macho_file: *MachO) !void {
228 if (next.getAtomAddress(macho_file) >= range_start_max) {228 if (next.getAtomAddress(macho_file) >= range_start_max) {
229 break;229 break;
230 } else if (info.getCommonEncoding(next.enc) != null or230 } else if (info.getCommonEncoding(next.enc) != null or
231 page.getPageEncoding(next.enc) != null and !is_dwarf)231 (page.getPageEncoding(next.enc) != null and !is_dwarf))
232 {232 {
233 i += 1;233 i += 1;
234 space_left -= 1;234 space_left -= 1;
src/link/MachO/load_commands.zig+2-2
...@@ -266,8 +266,8 @@ pub fn writeDylibIdLC(macho_file: *MachO, writer: *Writer) !void {...@@ -266,8 +266,8 @@ pub fn writeDylibIdLC(macho_file: *MachO, writer: *Writer) !void {
266 try writeDylibLC(.{266 try writeDylibLC(.{
267 .cmd = .ID_DYLIB,267 .cmd = .ID_DYLIB,
268 .name = install_name,268 .name = install_name,
269 .current_version = @as(u32, @intCast(curr.major << 16 | curr.minor << 8 | curr.patch)),269 .current_version = @as(u32, @intCast((curr.major << 16) | (curr.minor << 8) | curr.patch)),
270 .compatibility_version = @as(u32, @intCast(compat.major << 16 | compat.minor << 8 | compat.patch)),270 .compatibility_version = @as(u32, @intCast((compat.major << 16) | (compat.minor << 8) | compat.patch)),
271 }, writer);271 }, writer);
272}272}
273273
src/link/Wasm/Flush.zig+1-1
...@@ -1128,7 +1128,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {...@@ -1128,7 +1128,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
1128 // indirect function table elements1128 // indirect function table elements
1129 const table_index: u32 = @intCast(1129 const table_index: u32 = @intCast(
1130 wasm.table_imports.getIndex(wasm.preloaded_strings.__indirect_function_table) orelse1130 wasm.table_imports.getIndex(wasm.preloaded_strings.__indirect_function_table) orelse
1131 wasm.table_imports.entries.len + wasm.tables.getIndex(.__indirect_function_table).?,1131 (wasm.table_imports.entries.len + wasm.tables.getIndex(.__indirect_function_table).?),
1132 );1132 );
1133 // passive with implicit 0-index table or set table index manually1133 // passive with implicit 0-index table or set table index manually
1134 const flags: u32 = if (table_index == 0) 0x0 else 0x02;1134 const flags: u32 = if (table_index == 0) 0x0 else 0x02;
src/link/riscv.zig+2-2
...@@ -90,8 +90,8 @@ fn bitSlice(...@@ -90,8 +90,8 @@ fn bitSlice(
90 value: anytype,90 value: anytype,
91 comptime high: comptime_int,91 comptime high: comptime_int,
92 comptime low: comptime_int,92 comptime low: comptime_int,
93) std.math.IntFittingRange(0, 1 << high - low) {93) std.math.IntFittingRange(0, 1 << (high - low)) {
94 return @truncate((value >> low) & (1 << (high - low + 1)) - 1);94 return @truncate((value >> low) & ((1 << (high - low + 1)) - 1));
95}95}
9696
97pub const Eflags = packed struct(u32) {97pub const Eflags = packed struct(u32) {
src/main.zig+1-1
...@@ -3524,7 +3524,7 @@ fn buildOutputType(...@@ -3524,7 +3524,7 @@ fn buildOutputType(
3524 };3524 };
35253525
3526 const thread_limit = @min(3526 const thread_limit = @min(
3527 @max(n_jobs orelse std.Thread.getCpuCount() catch 1, 1),3527 @max(n_jobs orelse (std.Thread.getCpuCount() catch 1), 1),
3528 std.math.maxInt(Zcu.PerThread.IdBacking),3528 std.math.maxInt(Zcu.PerThread.IdBacking),
3529 );3529 );
3530 try setThreadLimit(arena, thread_limit);3530 try setThreadLimit(arena, thread_limit);
test/Runner.zig+4-4
...@@ -811,7 +811,7 @@ pub const DelimitedReader = struct {...@@ -811,7 +811,7 @@ pub const DelimitedReader = struct {
811 const d: *DelimitedReader = @fieldParentPtr("interface", r);811 const d: *DelimitedReader = @fieldParentPtr("interface", r);
812 const block = try d.unlimited.peekGreedy(d.delimiter.len);812 const block = try d.unlimited.peekGreedy(d.delimiter.len);
813 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse813 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse
814 block.len - d.delimiter.len + 1);814 (block.len - d.delimiter.len + 1));
815 if (d.remaining == .nothing) return error.EndOfStream;815 if (d.remaining == .nothing) return error.EndOfStream;
816 const n = try d.unlimited.stream(w, limit.min(d.remaining));816 const n = try d.unlimited.stream(w, limit.min(d.remaining));
817 d.remaining = d.remaining.subtract(n).?;817 d.remaining = d.remaining.subtract(n).?;
...@@ -821,7 +821,7 @@ pub const DelimitedReader = struct {...@@ -821,7 +821,7 @@ pub const DelimitedReader = struct {
821 const d: *DelimitedReader = @fieldParentPtr("interface", r);821 const d: *DelimitedReader = @fieldParentPtr("interface", r);
822 const block = try d.unlimited.peekGreedy(d.delimiter.len);822 const block = try d.unlimited.peekGreedy(d.delimiter.len);
823 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse823 d.remaining = .limited(std.mem.findPos(u8, block, d.remaining.toInt().?, d.delimiter) orelse
824 block.len - d.delimiter.len + 1);824 (block.len - d.delimiter.len + 1));
825 if (d.remaining == .nothing) return error.EndOfStream;825 if (d.remaining == .nothing) return error.EndOfStream;
826 const n = try d.unlimited.discard(limit.min(d.remaining));826 const n = try d.unlimited.discard(limit.min(d.remaining));
827 d.remaining = d.remaining.subtract(n).?;827 d.remaining = d.remaining.subtract(n).?;
...@@ -1397,9 +1397,9 @@ fn handleCommand(...@@ -1397,9 +1397,9 @@ fn handleCommand(
1397 return update.fail("compiler failed to send terminating error_bundle", .{});1397 return update.fail("compiler failed to send terminating error_bundle", .{});
1398 },1398 },
1399 }1399 }
1400 assert(contents_r.discardRemaining() catch |err| switch (err) {1400 assert((contents_r.discardRemaining() catch |err| switch (err) {
1401 error.ReadFailed => return error.ContentsReadFailed,1401 error.ReadFailed => return error.ContentsReadFailed,
1402 } == 0);1402 }) == 0);
1403 switch (cmd) {1403 switch (cmd) {
1404 .todo, .skip => {},1404 .todo, .skip => {},
1405 else => update.allow_skip = false,1405 else => update.allow_skip = false,
test/behavior/bitcast.zig+1-1
...@@ -470,7 +470,7 @@ test "@bitCast of packed struct with void field and multiple integers" {...@@ -470,7 +470,7 @@ test "@bitCast of packed struct with void field and multiple integers" {
470 fn doTheTest(x: u8, y: u8) !void {470 fn doTheTest(x: u8, y: u8) !void {
471 const foo = @as(@This(), .{ .x = x, .v = {}, .y = y });471 const foo = @as(@This(), .{ .x = x, .v = {}, .y = y });
472 const as_int: u16 = @bitCast(foo);472 const as_int: u16 = @bitCast(foo);
473 try expect(as_int == @as(u16, y) << 8 | x);473 try expect(as_int == (@as(u16, y) << 8) | x);
474 }474 }
475 };475 };
476 try S.doTheTest(123, 45);476 try S.doTheTest(123, 45);
test/behavior/error.zig+1-1
...@@ -209,7 +209,7 @@ fn testErrorSetType() !void {...@@ -209,7 +209,7 @@ fn testErrorSetType() !void {
209209
210 const a: MyErrSet!i32 = 5678;210 const a: MyErrSet!i32 = 5678;
211 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;211 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;
212 try expect(b catch error.OutOfMemory == error.OutOfMemory);212 try expect((b catch error.OutOfMemory) == error.OutOfMemory);
213213
214 if (a) |value| try expect(value == 5678) else |err| switch (err) {214 if (a) |value| try expect(value == 5678) else |err| switch (err) {
215 error.OutOfMemory => unreachable,215 error.OutOfMemory => unreachable,
test/behavior/math.zig+3-3
...@@ -49,10 +49,10 @@ fn testThreeExprInARow(f: bool, t: bool) !void {...@@ -49,10 +49,10 @@ fn testThreeExprInARow(f: bool, t: bool) !void {
49 try assertFalse(1 | 2 | 4 != 7);49 try assertFalse(1 | 2 | 4 != 7);
50 try assertFalse(3 ^ 6 ^ 8 != 13);50 try assertFalse(3 ^ 6 ^ 8 != 13);
51 try assertFalse(7 & 14 & 28 != 4);51 try assertFalse(7 & 14 & 28 != 4);
52 try assertFalse(9 << 1 << 2 != 9 << 3);52 try assertFalse((9 << 1) << 2 != 9 << 3);
53 try assertFalse(90 >> 1 >> 2 != 90 >> 3);53 try assertFalse((90 >> 1) >> 2 != 90 >> 3);
54 try assertFalse(100 - 1 + 1000 != 1099);54 try assertFalse(100 - 1 + 1000 != 1099);
55 try assertFalse(5 * 4 / 2 % 3 != 1);55 try assertFalse((5 * 4 / 2) % 3 != 1);
56 try assertFalse(@as(i32, @as(i32, 5)) != 5);56 try assertFalse(@as(i32, @as(i32, 5)) != 5);
57 try assertFalse(!!false);57 try assertFalse(!!false);
58 try assertFalse(@as(i32, 7) != --(@as(i32, 7)));58 try assertFalse(@as(i32, 7) != --(@as(i32, 7)));
test/behavior/try.zig+3-3
...@@ -186,9 +186,9 @@ test "try ptr propagation mutate" {...@@ -186,9 +186,9 @@ test "try ptr propagation mutate" {
186 res1.* += 1;186 res1.* += 1;
187 res2.* += 1;187 res2.* += 1;
188188
189 try expect(f0 catch unreachable == 1);189 try expect((f0 catch unreachable) == 1);
190 try expect(f1 catch unreachable == 2);190 try expect((f1 catch unreachable) == 2);
191 try expect(f2 catch unreachable == 3);191 try expect((f2 catch unreachable) == 3);
192192
193 try expect(res0.* == 1);193 try expect(res0.* == 1);
194 try expect(res1.* == 2);194 try expect(res1.* == 2);
test/behavior/x86_64/binary.zig+2-2
...@@ -5503,7 +5503,7 @@ inline fn shrExact(comptime Type: type, lhs: Type, rhs: Type) Type {...@@ -5503,7 +5503,7 @@ inline fn shrExact(comptime Type: type, lhs: Type, rhs: Type) Type {
5503 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);5503 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
5504 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);5504 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5505 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;5505 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
5506 return @shrExact(lhs >> final_rhs << final_rhs, final_rhs);5506 return @shrExact((lhs >> final_rhs) << final_rhs, final_rhs);
5507}5507}
5508test shrExact {5508test shrExact {
5509 const test_shr_exact = binary(shrExact, .{});5509 const test_shr_exact = binary(shrExact, .{});
...@@ -5527,7 +5527,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type {...@@ -5527,7 +5527,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type {
5527 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);5527 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
5528 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);5528 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5529 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;5529 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
5530 return @shlExact(lhs << final_rhs >> final_rhs, final_rhs);5530 return @shlExact((lhs << final_rhs) >> final_rhs, final_rhs);
5531}5531}
5532test shlExactUnsafe {5532test shlExactUnsafe {
5533 const test_shl_exact_unsafe = binary(shlExactUnsafe, .{});5533 const test_shl_exact_unsafe = binary(shlExactUnsafe, .{});
test/behavior/x86_64/cast.zig+4-4
...@@ -14502,15 +14502,15 @@ inline fn intCast(comptime Result: type, comptime Type: type, rhs: Type, comptim...@@ -14502,15 +14502,15 @@ inline fn intCast(comptime Result: type, comptime Type: type, rhs: Type, comptim
14502 // TODO: if (bits == 0) rhs else rhs >> bits,14502 // TODO: if (bits == 0) rhs else rhs >> bits,
14503 .shift => |bits| if (bits == 0) rhs else switch (@typeInfo(Type)) {14503 .shift => |bits| if (bits == 0) rhs else switch (@typeInfo(Type)) {
14504 .int => if (ct_rhs < 0)14504 .int => if (ct_rhs < 0)
14505 rhs | imin(Type) >> bits14505 rhs | (imin(Type) >> bits)
14506 else14506 else
14507 rhs & imax(Type) >> bits,14507 rhs & (imax(Type) >> bits),
14508 .vector => rhs | @select(14508 .vector => (rhs | @select(
14509 Scalar(Type),14509 Scalar(Type),
14510 ct_rhs < @as(Type, @splat(0)),14510 ct_rhs < @as(Type, @splat(0)),
14511 @as(Type, @splat(imin(Scalar(Type)) >> bits)),14511 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
14512 @as(Type, @splat(0)),14512 @as(Type, @splat(0)),
14513 ) & ~@select(14513 )) & ~@select(
14514 Scalar(Type),14514 Scalar(Type),
14515 ct_rhs >= @as(Type, @splat(0)),14515 ct_rhs >= @as(Type, @splat(0)),
14516 @as(Type, @splat(imin(Scalar(Type)) >> bits)),14516 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
tools/loongarch/OpcodeDesc.zig+2-2
...@@ -95,10 +95,10 @@ pub const Format = struct {...@@ -95,10 +95,10 @@ pub const Format = struct {
95 const index: Slot.Index = try .parse(&reader);95 const index: Slot.Index = try .parse(&reader);
96 const length = try takeInteger(u5, &reader);96 const length = try takeInteger(u5, &reader);
97 const post_proc = post_proc: {97 const post_proc = post_proc: {
98 if ('p' == reader.peekByte() catch |err| switch (err) {98 if ('p' == (reader.peekByte() catch |err| switch (err) {
99 error.EndOfStream => ' ',99 error.EndOfStream => ' ',
100 else => return err,100 else => return err,
101 }) {101 })) {
102 reader.toss(1);102 reader.toss(1);
103 break :post_proc try Slot.PostProcess.parse(&reader);103 break :post_proc try Slot.PostProcess.parse(&reader);
104 } else break :post_proc Slot.PostProcess.none;104 } else break :post_proc Slot.PostProcess.none;