| author | |
| committer | |
| log | 64e4f9db8fa6fc47b0a2ef3143edacf472fb8c48 |
| tree | 7566214af13ad8d95ade48e53c4013acfbe23f7c |
| parent | 16894c484c316c110a843ee15514790cc589dbfa |
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 | 355 | fn rint(x: f64) callconv(.c) f64 { |
| 356 | 356 | const toint: f64 = 1.0 / math.floatEps(f64); |
| 357 | 357 | const a: u64 = @bitCast(x); |
| 358 | const e = a >> 52 & 0x7ff; | |
| 358 | const e = (a >> 52) & 0x7ff; | |
| 359 | 359 | const s = a >> 63; |
| 360 | 360 | var y: f64 = undefined; |
| 361 | 361 | |
| ... | ... | @@ -376,7 +376,7 @@ fn rint(x: f64) callconv(.c) f64 { |
| 376 | 376 | fn rintf(x: f32) callconv(.c) f32 { |
| 377 | 377 | const toint: f32 = 1.0 / math.floatEps(f32); |
| 378 | 378 | const a: u32 = @bitCast(x); |
| 379 | const e = a >> 23 & 0xff; | |
| 379 | const e = (a >> 23) & 0xff; | |
| 380 | 380 | const s = a >> 31; |
| 381 | 381 | var y: f32 = undefined; |
| 382 | 382 |
lib/c/stdlib/drand48.zig+6-6| ... | ... | @@ -30,7 +30,7 @@ var lcg: Lcg = .init(0, default_multiplier, default_addend); |
| 30 | 30 | var seed48_xi: [3]c_ushort = undefined; |
| 31 | 31 | |
| 32 | 32 | fn 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); | |
| 34 | 34 | |
| 35 | 35 | var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c); |
| 36 | 36 | const next_xi = separate_lcg.next(); |
| ... | ... | @@ -40,7 +40,7 @@ fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 { |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | fn 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); | |
| 44 | 44 | |
| 45 | 45 | var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c); |
| 46 | 46 | const next_xi = separate_lcg.next(); |
| ... | ... | @@ -50,7 +50,7 @@ fn jrand48(xsubi: *[3]c_ushort) callconv(.c) c_long { |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | fn 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); | |
| 54 | 54 | |
| 55 | 55 | var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c); |
| 56 | 56 | const next_xi = separate_lcg.next(); |
| ... | ... | @@ -74,14 +74,14 @@ fn mrand48() callconv(.c) c_long { |
| 74 | 74 | // 0..3 is `Xi`, 3..6 is `a`, 6 is `c` |
| 75 | 75 | // first low 16-bits, then mid, then high. |
| 76 | 76 | fn 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); | |
| 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); | |
| 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); | |
| 79 | 79 | lcg.c = @as(u16, @truncate(param[6])); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | fn seed48(seed16v: *[3]c_ushort) callconv(.c) *[3]c_ushort { |
| 83 | 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 | 85 | lcg = .init(xi, default_multiplier, default_addend); |
| 86 | 86 | return &seed48_xi; |
| 87 | 87 | } |
lib/compiler/Maker/Step/Compile.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ pub fn make( |
| 45 | 45 | |
| 46 | 46 | try lowerZigArgs(arena, compile_index, maker, progress_node, &argv, false); |
| 47 | 47 | |
| 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; | |
| 49 | 49 | |
| 50 | 50 | const opt_cache_digest = Step.evalZigProcess( |
| 51 | 51 | compile_index, |
lib/compiler/aro/aro/Compilation.zig+3-3| ... | ... | @@ -287,7 +287,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void { |
| 287 | 287 | const gnuc_version = comp.langopts.gnuc_version orelse comp.langopts.emulate.defaultGccVersion(); |
| 288 | 288 | if (gnuc_version > 0) { |
| 289 | 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 | 291 | try w.print("#define __GNUC_PATCHLEVEL__ {d}\n", .{gnuc_version % 100}); |
| 292 | 292 | } |
| 293 | 293 | |
| ... | ... | @@ -962,7 +962,7 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void { |
| 962 | 962 | try define(w, "__ARM_ARCH_EXT_IDIV__"); |
| 963 | 963 | } |
| 964 | 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 | 966 | try define(w, "__ARM_FEATURE_SAT"); |
| 967 | 967 | sat = true; |
| 968 | 968 | } |
| ... | ... | @@ -2856,7 +2856,7 @@ test "addSourceFromBuffer - exhaustive check for carriage return elimination" { |
| 2856 | 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 | } |
| 2861 | 2861 | |
| 2862 | 2862 | test "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 | 1373 | if (d.only_preprocess_and_compile) ".s" else d.comp.target.ofmt.fileExt(d.comp.target.cpu.arch), |
| 1374 | 1374 | }; |
| 1375 | 1375 | 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 | } |
| 1378 | 1378 | |
| 1379 | 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 | 7084 | const b_child_qt = b.qt.get(p.comp, .pointer).?.child; |
| 7085 | 7085 | |
| 7086 | 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 | 7088 | a.qt = p.comp.type_store.ptrdiff; |
| 7089 | 7089 | } |
| 7090 | 7090 |
lib/compiler/aro/aro/Preprocessor.zig+3-3| ... | ... | @@ -310,13 +310,13 @@ pub const InitOptions = struct { |
| 310 | 310 | }; |
| 311 | 311 | |
| 312 | 312 | pub 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 | 314 | error.InvalidEpoch => blk: { |
| 315 | 315 | const diagnostic: Diagnostic = .invalid_source_epoch; |
| 316 | 316 | try comp.diagnostics.add(.{ .text = diagnostic.fmt, .kind = diagnostic.kind, .opt = diagnostic.opt, .location = null }); |
| 317 | 317 | break :blk .default; |
| 318 | 318 | }, |
| 319 | }; | |
| 319 | }); | |
| 320 | 320 | |
| 321 | 321 | var pp: Preprocessor = .{ |
| 322 | 322 | .comp = comp, |
| ... | ... | @@ -3882,7 +3882,7 @@ pub fn prettyPrintTokens(pp: *Preprocessor, w: *std.Io.Writer, macro_dump_mode: |
| 3882 | 3882 | }, |
| 3883 | 3883 | .keyword_pragma => { |
| 3884 | 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 | 3886 | const pragma_len = @as(u32, @intCast(end_idx)) - i; |
| 3887 | 3887 | |
| 3888 | 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 | 323 | const else_res = try p.binaryExpr(op_prec, eval_else) orelse return null; |
| 324 | 324 | |
| 325 | 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 | 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 | 492 | assert(c > 0x7F); |
| 493 | 493 | const idx = c / 8 / tables.chunk; |
| 494 | 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 | 496 | return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0; |
| 497 | 497 | } |
| 498 | 498 | |
| ... | ... | @@ -500,7 +500,7 @@ pub fn isXidContinue(c: u21) bool { |
| 500 | 500 | assert(c > 0x7F); |
| 501 | 501 | const idx = c / 8 / tables.chunk; |
| 502 | 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 | 504 | return (tables.leaf[offset] >> (@as(u3, @intCast(c % 8)))) & 1 != 0; |
| 505 | 505 | } |
| 506 | 506 |
lib/compiler/aro/aro/record_layout.zig+1-1| ... | ... | @@ -324,7 +324,7 @@ const SysVContext = struct { |
| 324 | 324 | |
| 325 | 325 | // On Clang, the alignment requested by annotations is not respected if it is |
| 326 | 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 | 328 | field_align_bits = @max(field_align_bits, annotation_alignment); |
| 329 | 329 | } |
| 330 | 330 | // 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 | 11 | // compute the integer absolute value (abs) without branching |
| 12 | 12 | var x: ST = a; |
| 13 | 13 | const N: UT = @bitSizeOf(ST); |
| 14 | const sign: ST = a >> N - 1; | |
| 14 | const sign: ST = a >> (N - 1); | |
| 15 | 15 | x +%= sign; |
| 16 | 16 | x ^= sign; |
| 17 | 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 | 259 | // adjust the exponent: |
| 260 | 260 | if (aSignificand & (integerBit << 4) != 0) { |
| 261 | 261 | const sticky = aSignificand & 1; |
| 262 | aSignificand = aSignificand >> 1 | sticky; | |
| 262 | aSignificand = (aSignificand >> 1) | sticky; | |
| 263 | 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 | 241 | while (true) { |
| 242 | 242 | const old = @as(T, @truncate((wide_old & mask) >> inner_shift)); |
| 243 | 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 | 245 | if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .seq_cst, .seq_cst)) |new_wide_old| { |
| 246 | 246 | wide_old = new_wide_old; |
| 247 | 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 | 130 | return @intFromBool(cmp_f32(a, b) == .lt); |
| 131 | 131 | } |
| 132 | 132 | fn __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 | } |
| 135 | 135 | fn __gesf2(a: compiler_rt.f32.Abi, b: compiler_rt.f32.Abi) callconv(.c) Order { |
| 136 | 136 | return cmp_f32(compiler_rt.f32.fromAbi(a), compiler_rt.f32.fromAbi(b)) orelse .lt; |
| 137 | 137 | } |
| 138 | 138 | fn __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 | } |
| 141 | 141 | fn __aeabi_fcmpgt(a: f32, b: f32) callconv(.{ .arm_aapcs = .{} }) i32 { |
| 142 | 142 | return @intFromBool(cmp_f32(a, b) == .gt); |
| ... | ... | @@ -164,13 +164,13 @@ fn __aeabi_dcmplt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 { |
| 164 | 164 | return @intFromBool(cmp_f64(a, b) == .lt); |
| 165 | 165 | } |
| 166 | 166 | fn __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 | } |
| 169 | 169 | fn __gedf2(a: compiler_rt.f64.Abi, b: compiler_rt.f64.Abi) callconv(.c) Order { |
| 170 | 170 | return cmp_f64(compiler_rt.f64.fromAbi(a), compiler_rt.f64.fromAbi(b)) orelse .lt; |
| 171 | 171 | } |
| 172 | 172 | fn __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 | } |
| 175 | 175 | fn __aeabi_dcmpgt(a: f64, b: f64) callconv(.{ .arm_aapcs = .{} }) i32 { |
| 176 | 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 | 119 | // with each iteration, so after three iterations, we have about 28 binary |
| 120 | 120 | // digits of accuracy. |
| 121 | 121 | var correction32: u32 = undefined; |
| 122 | correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1); | |
| 123 | recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31); | |
| 124 | correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1); | |
| 125 | recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31); | |
| 126 | correction32 = @truncate(~(@as(u64, recip32) *% q31b >> 32) +% 1); | |
| 127 | recip32 = @truncate(@as(u64, recip32) *% correction32 >> 31); | |
| 122 | correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1); | |
| 123 | recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31); | |
| 124 | correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1); | |
| 125 | recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31); | |
| 126 | correction32 = @truncate(~((@as(u64, recip32) *% q31b) >> 32) +% 1); | |
| 127 | recip32 = @truncate((@as(u64, recip32) *% correction32) >> 31); | |
| 128 | 128 | |
| 129 | 129 | // recip32 might have overflowed to exactly zero in the preceding |
| 130 | 130 | // 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 | 137 | const q63blo: u32 = @truncate(bSignificand << 11); |
| 138 | 138 | var correction: u64 = undefined; |
| 139 | 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 | 141 | const cHi: u32 = @truncate(correction >> 32); |
| 142 | 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); | |
| 144 | 144 | |
| 145 | 145 | // We already adjusted the 32-bit estimate, now we need to adjust the final |
| 146 | 146 | // 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 | 126 | // with each iteration, so after three iterations, we have about 28 binary |
| 127 | 127 | // digits of accuracy. |
| 128 | 128 | var correction: u32 = undefined; |
| 129 | correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1); | |
| 130 | reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31); | |
| 131 | correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1); | |
| 132 | reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31); | |
| 133 | correction = @truncate(~(@as(u64, reciprocal) *% q31b >> 32) +% 1); | |
| 134 | reciprocal = @truncate(@as(u64, reciprocal) *% correction >> 31); | |
| 129 | correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1); | |
| 130 | reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31); | |
| 131 | correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1); | |
| 132 | reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31); | |
| 133 | correction = @truncate(~((@as(u64, reciprocal) *% q31b) >> 32) +% 1); | |
| 134 | reciprocal = @truncate((@as(u64, reciprocal) *% correction) >> 31); | |
| 135 | 135 | |
| 136 | 136 | // Exhaustive testing shows that the error in reciprocal after three steps |
| 137 | 137 | // 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 | 153 | // is the error in the reciprocal of b scaled by the maximum |
| 154 | 154 | // possible value of a. As a consequence of this error bound, |
| 155 | 155 | // 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); | |
| 157 | 157 | |
| 158 | 158 | // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). |
| 159 | 159 | // 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 | 119 | // This doubles the number of correct binary digits in the approximation |
| 120 | 120 | // with each iteration. |
| 121 | 121 | var correction64: u64 = undefined; |
| 122 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 123 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 124 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 125 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 126 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 127 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 128 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 129 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 130 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 131 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 122 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 123 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 124 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 125 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 126 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 127 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 128 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 129 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 130 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 131 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 132 | 132 | |
| 133 | 133 | // The reciprocal may have overflowed to zero if the upper half of b is |
| 134 | 134 | // 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 | 102 | // This doubles the number of correct binary digits in the approximation |
| 103 | 103 | // with each iteration. |
| 104 | 104 | var correction64: u64 = undefined; |
| 105 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 106 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 107 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 108 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 109 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 110 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 111 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 112 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 113 | correction64 = @truncate(~(@as(u128, recip64) *% q63b >> 64) +% 1); | |
| 114 | recip64 = @truncate(@as(u128, recip64) *% correction64 >> 63); | |
| 105 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 106 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 107 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 108 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 109 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 110 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 111 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 112 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 113 | correction64 = @truncate(~((@as(u128, recip64) *% q63b) >> 64) +% 1); | |
| 114 | recip64 = @truncate((@as(u128, recip64) *% correction64) >> 63); | |
| 115 | 115 | |
| 116 | 116 | // The reciprocal may have overflowed to zero if the upper half of b is |
| 117 | 117 | // 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 | 251 | // Update the %gs selector |
| 252 | 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 | 257 | .x86_64 => { |
lib/compiler_rt/extendf.zig+2-2| ... | ... | @@ -165,7 +165,7 @@ pub fn f128_floatCast_f80(a: f80) f128 { |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 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 | 169 | return @bitCast(result); |
| 170 | 170 | } |
| 171 | 171 | |
| ... | ... | @@ -232,7 +232,7 @@ inline fn extendf(comptime dst_t: type, comptime src_t: type, f: src_t) dst_t { |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 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 | 236 | return @bitCast(result); |
| 237 | 237 | } |
| 238 | 238 |
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 | 141 | const m = (@as(U, 1) << @intCast(mantissa - e)) - 1; |
| 142 | 142 | if (u & m == 0) return x; |
| 143 | 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 | 145 | return @bitCast(u & ~m); |
| 146 | 146 | } else { |
| 147 | 147 | if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1.0p120); |
| 148 | 148 | return switch (op) { |
| 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, | |
| 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, | |
| 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 | 155 | const e = (u >> mantissa) & mask; |
| 156 | 156 | if (e >= bias + math.floatFractionalBits(T) or x == 0) return x; |
| 157 | 157 | |
| 158 | const positive = u >> @bitSizeOf(T) - 1 == 0; | |
| 158 | const positive = u >> (@bitSizeOf(T) - 1) == 0; | |
| 159 | 159 | const y: T = if (positive) |
| 160 | 160 | x + C - C - x |
| 161 | 161 | else |
lib/compiler_rt/fmod.zig+2-2| ... | ... | @@ -204,8 +204,8 @@ pub fn fmod_f128(a: f128, b: f128) f128 { |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // OR in extra non-stored mantissa digit |
| 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; | |
| 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); | |
| 209 | 209 | var lowA: u64 = aPtr_u64[low_index]; |
| 210 | 210 | const lowB: u64 = bPtr_u64[low_index]; |
| 211 | 211 |
lib/compiler_rt/mulf3.zig+1-1| ... | ... | @@ -237,7 +237,7 @@ fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool { |
| 237 | 237 | lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count)); |
| 238 | 238 | hi.* = hi.* >> @intCast(count); |
| 239 | 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 | 241 | lo.* = hi.* >> @intCast(count -% typeWidth); |
| 242 | 242 | hi.* = 0; |
| 243 | 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 | 37 | const se = ld.signExponent(x_val); |
| 38 | 38 | const top = ld.mantissaTop(x_val); |
| 39 | 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 | 41 | return lhs < rhs; |
| 42 | 42 | } |
| 43 | 43 |
lib/compiler_rt/sqrt.zig+5-5| ... | ... | @@ -523,15 +523,15 @@ const rsqrt_tab: [128]u16 = .{ |
| 523 | 523 | }; |
| 524 | 524 | |
| 525 | 525 | inline 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 | } |
| 528 | 528 | |
| 529 | 529 | inline 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 | } |
| 532 | 532 | |
| 533 | 533 | inline 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 | } |
| 536 | 536 | |
| 537 | 537 | inline fn mul80(a: u80, b: u80) u80 { |
| ... | ... | @@ -539,7 +539,7 @@ inline fn mul80(a: u80, b: u80) u80 { |
| 539 | 539 | const alo = a & 0xFF_FFFF_FFFF; |
| 540 | 540 | const bhi = b >> 40; |
| 541 | 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 | } |
| 544 | 544 | |
| 545 | 545 | inline fn mul128(a: u128, b: u128) u128 { |
| ... | ... | @@ -547,7 +547,7 @@ inline fn mul128(a: u128, b: u128) u128 { |
| 547 | 547 | const alo = a & 0xFFFF_FFFF_FFFF_FFFF; |
| 548 | 548 | const bhi = b >> 64; |
| 549 | 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 | } |
| 552 | 552 | |
| 553 | 553 | inline 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 | 279 | absResult = 0; |
| 280 | 280 | } else { |
| 281 | 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 | 283 | absResult = @intCast(denormalizedSignificand >> (srcSigBits - dstSigBits)); |
| 284 | 284 | const roundBits: src_rep_t = denormalizedSignificand & roundMask; |
| 285 | 285 | if (roundBits > halfway) { |
| ... | ... | @@ -362,7 +362,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { |
| 362 | 362 | abs_result = 0; |
| 363 | 363 | } else { |
| 364 | 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 | 366 | abs_result = @intCast(denormalized_significand >> (src_sig_bits - dst_sig_bits)); |
| 367 | 367 | const round_bits = denormalized_significand & round_mask; |
| 368 | 368 | if (round_bits > halfway) { |
| ... | ... | @@ -375,7 +375,7 @@ inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t { |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 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 | 379 | return @bitCast(result); |
| 380 | 380 | } |
| 381 | 381 |
lib/std/Io/Dispatch.zig+2-2| ... | ... | @@ -1931,10 +1931,10 @@ const BatchWaiter = struct { |
| 1931 | 1931 | |
| 1932 | 1932 | fn batchAwaitAsync(userdata: ?*anyopaque, batch: *Io.Batch) Io.Cancelable!void { |
| 1933 | 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 | 1935 | error.ConcurrencyUnavailable => unreachable, // passed concurrency=false |
| 1936 | 1936 | error.Canceled => |e| return e, |
| 1937 | } orelse return; | |
| 1937 | }) orelse return; | |
| 1938 | 1938 | if (batch.pending.head == .none) return; |
| 1939 | 1939 | var waiter: BatchWaiter = .{ |
| 1940 | 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 | 164 | pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void { |
| 165 | 165 | assert(options.n_threads != 0); |
| 166 | 166 | |
| 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 | 168 | const threads_size = n_threads * @sizeOf(Thread); |
| 169 | 169 | const idle_stack_end_offset = std.mem.alignForward(usize, threads_size + idle_stack_size, std.heap.page_size_max); |
| 170 | 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 | 36 | } |
| 37 | 37 | |
| 38 | 38 | fn 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 | } |
| 41 | 41 | |
| 42 | 42 | test "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 | 1827 | // Restore the alignment. |
| 1828 | 1828 | mantissa <<= @as(std.math.Log2Int(TU), @intCast((mantissa_digits - precision) * 4)); |
| 1829 | 1829 | |
| 1830 | const overflow = mantissa & (1 << 1 + mantissa_digits * 4) != 0; | |
| 1830 | const overflow = mantissa & (1 << (1 + mantissa_digits * 4)) != 0; | |
| 1831 | 1831 | // Prefer a normalized result in case of overflow. |
| 1832 | 1832 | if (overflow) { |
| 1833 | 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 | 230 | i += 1 + label_len; |
| 231 | 231 | } else { |
| 232 | 232 | return .{ |
| 233 | len orelse i - start_i + 1, | |
| 233 | len orelse (i - start_i + 1), | |
| 234 | 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 | 148 | if (idx + 2 < source.len) { |
| 149 | 149 | dest[out_idx] = encoder.alphabet_chars[source[idx] >> 2]; |
| 150 | 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 | 152 | dest[out_idx + 3] = encoder.alphabet_chars[source[idx + 2] & 0x3f]; |
| 153 | 153 | out_idx += 4; |
| 154 | 154 | } else if (idx + 1 < source.len) { |
| ... | ... | @@ -282,7 +282,7 @@ pub const Base64Decoder = struct { |
| 282 | 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 | 286 | return error.InvalidPadding; |
| 287 | 287 | } |
| 288 | 288 | if (leftover_idx == null) return; |
| ... | ... | @@ -357,7 +357,7 @@ pub const Base64DecoderWithIgnore = struct { |
| 357 | 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 | 361 | return error.InvalidPadding; |
| 362 | 362 | } |
| 363 | 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 | 468 | |
| 469 | 469 | if (start_mask_index == end_mask_index) { |
| 470 | 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 | 472 | self.masks[start_mask_index] &= ~(mask1 & mask2); |
| 473 | 473 | |
| 474 | 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 | 476 | self.masks[start_mask_index] |= mask1 & mask2; |
| 477 | 477 | } else { |
| 478 | 478 | var bulk_mask_index: usize = undefined; |
| ... | ... | @@ -875,11 +875,11 @@ pub const Dynamic = struct { |
| 875 | 875 | |
| 876 | 876 | if (start_mask_index == end_mask_index) { |
| 877 | 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 | 879 | self.masks[start_mask_index] &= ~(mask1 & mask2); |
| 880 | 880 | |
| 881 | 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 | 883 | self.masks[start_mask_index] |= mask1 & mask2; |
| 884 | 884 | } else { |
| 885 | 885 | var bulk_mask_index: usize = undefined; |
lib/std/coff.zig+1-1| ... | ... | @@ -2035,7 +2035,7 @@ pub const ArchiveMemberHeader = extern struct { |
| 2035 | 2035 | if (trim.len == 0) return error.BadName; |
| 2036 | 2036 | return if (trim[0] == '/') name: { |
| 2037 | 2037 | if (trim.len == 1 or |
| 2038 | trim.len == 2 and trim[1] == '/') | |
| 2038 | (trim.len == 2 and trim[1] == '/')) | |
| 2039 | 2039 | break :name trim; |
| 2040 | 2040 | |
| 2041 | 2041 | 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 | 1333 | |
| 1334 | 1334 | const incomplete_allowed = smith.value(bool); |
| 1335 | 1335 | while (nfreqs < @as(u8, @intFromBool(!incomplete_allowed)) + 1 or |
| 1336 | nfreqs != freqs_buf.len and freqs_limit != 0 and | |
| 1337 | smith.eosWeightedSimple(15, 1)) | |
| 1336 | (nfreqs != freqs_buf.len and freqs_limit != 0 and | |
| 1337 | smith.eosWeightedSimple(15, 1))) | |
| 1338 | 1338 | { |
| 1339 | 1339 | const f = smith.valueWeighted(u16, &.{ |
| 1340 | 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 | 728 | // constants |
| 729 | 729 | |
| 730 | 730 | // Rijndael's irreducible polynomial. |
| 731 | const poly: u9 = 1 << 8 | 1 << 4 | 1 << 3 | 1 << 1 | 1 << 0; // x⁸ + x⁴ + x³ + x + 1 | |
| 731 | const poly: u9 = (1 << 8) | (1 << 4) | (1 << 3) | (1 << 1) | (1 << 0); // x⁸ + x⁴ + x³ + x + 1 | |
| 732 | 732 | |
| 733 | 733 | // Powers of x mod poly in GF(2). |
| 734 | 734 | const powx = init: { |
lib/std/crypto/codecs/base64_hex_ct.zig+1-1| ... | ... | @@ -29,7 +29,7 @@ pub const hex = struct { |
| 29 | 29 | const c: u16 = v & 0xf; |
| 30 | 30 | const off = if (case == .upper) 32 else 0; |
| 31 | 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 | 33 | ((87 - off + b + (((b -% 10) >> 8) & ~@as(u16, 38 - off))) & 0xff); |
| 34 | 34 | encoded[i * 2] = @truncate(x); |
| 35 | 35 | encoded[i * 2 + 1] = @truncate(x >> 8); |
lib/std/crypto/ml_kem.zig+1-1| ... | ... | @@ -1264,7 +1264,7 @@ const Poly = struct { |
| 1264 | 1264 | const b1 = @as(i16, buf[3 * i + 1]); |
| 1265 | 1265 | const b2 = @as(i16, buf[3 * i + 2]); |
| 1266 | 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 | 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 | 82 | |
| 83 | 83 | fn integerify(b: []align(16) const u32, r: u30) u64 { |
| 84 | 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 | } |
| 87 | 87 | |
| 88 | 88 | fn 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 | 557 | } |
| 558 | 558 | |
| 559 | 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 | 561 | if (bytes_left > 0) { |
| 562 | 562 | const rest = d.s[(digest_bits / 64)]; |
| 563 | 563 | var buf: [8]u8 = undefined; |
lib/std/debug.zig+1-1| ... | ... | @@ -1306,7 +1306,7 @@ fn printLineInfo( |
| 1306 | 1306 | try writer.print("0x{x} in {s} ({s})", .{ |
| 1307 | 1307 | address, |
| 1308 | 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 | 1311 | t.setColor(.reset) catch {}; |
| 1312 | 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 | 16 | const gpa = std.debug.getDebugInfoAllocator(); |
| 17 | 17 | for (si.modules.items) |*mod| { |
| 18 | 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 | 20 | for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa); |
| 21 | 21 | } |
| 22 | 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 | 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 | 431 | } |
| 432 | 432 | for (si.modules.items) |*mod| { |
| 433 | 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 | 435 | for (u.buf[0..u.len]) |*unwind| unwind.deinit(gpa); |
| 436 | 436 | } |
| 437 | 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 | 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 | const gpa = std.debug.getDebugInfoAllocator(); |
| 12 | 12 | for (si.modules.keys()) |*module| { |
| 13 | 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 | 15 | if (u.dwarf) |*dwarf| dwarf.deinit(gpa); |
| 16 | 16 | } |
| 17 | 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 | 19 | f.deinit(gpa); |
| 20 | 20 | } |
| 21 | 21 | } |
lib/std/debug/SelfInfo/Windows.zig+4-4| ... | ... | @@ -280,7 +280,7 @@ const Module = struct { |
| 280 | 280 | // we have no information to add to the address |
| 281 | 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 | 284 | error.InvalidDebugInfo, |
| 285 | 285 | error.MissingDebugInfo, |
| 286 | 286 | error.OutOfMemory, |
| ... | ... | @@ -289,7 +289,7 @@ const Module = struct { |
| 289 | 289 | error.ReadFailed, |
| 290 | 290 | error.EndOfStream, |
| 291 | 291 | => return error.InvalidDebugInfo, |
| 292 | } orelse { | |
| 292 | }) orelse { | |
| 293 | 293 | return error.InvalidDebugInfo; // bad module index |
| 294 | 294 | }; |
| 295 | 295 | |
| ... | ... | @@ -539,9 +539,9 @@ const Module = struct { |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | var opt_pdb: ?Pdb = pdb: { |
| 542 | const path = coff_obj.getPdbPath() catch { | |
| 542 | const path = (coff_obj.getPdbPath() catch { | |
| 543 | 543 | return error.InvalidDebugInfo; |
| 544 | } orelse { | |
| 544 | }) orelse { | |
| 545 | 545 | break :pdb null; |
| 546 | 546 | }; |
| 547 | 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 | 13 | /// Platform-specific functionality is available through the `inner` field. |
| 14 | 14 | pub const DynLib = struct { |
| 15 | 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 | 17 | ElfDynLib |
| 18 | 18 | else |
| 19 | 19 | DlDynLib, |
| ... | ... | @@ -434,15 +434,15 @@ pub const ElfDynLib = struct { |
| 434 | 434 | pub fn lookupAddress(self: *const ElfDynLib, vername: []const u8, name: []const u8) ?usize { |
| 435 | 435 | const maybe_versym = if (self.verdef == null) null else self.versym; |
| 436 | 436 | |
| 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); | |
| 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); | |
| 439 | 439 | |
| 440 | 440 | switch (self.hash_table) { |
| 441 | 441 | .dt_hash => |hashtab| { |
| 442 | 442 | var i: usize = 0; |
| 443 | 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; | |
| 445 | if (0 == (@as(u32, 1) << @as(u5, @intCast(self.syms[i].st_info >> 4)) & OK_BINDS)) 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; | |
| 446 | 446 | if (0 == self.syms[i].st_shndx) continue; |
| 447 | 447 | if (!mem.eql(u8, name, mem.sliceTo(self.strings + self.syms[i].st_name, 0))) continue; |
| 448 | 448 | if (maybe_versym) |versym| { |
| ... | ... | @@ -494,8 +494,8 @@ pub const ElfDynLib = struct { |
| 494 | 494 | const symbol_index = current_index + gnu_hash_header.symoffset; |
| 495 | 495 | const symbol = self.syms[symbol_index]; |
| 496 | 496 | |
| 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; | |
| 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; | |
| 499 | 499 | if (0 == symbol.st_shndx) continue; |
| 500 | 500 | |
| 501 | 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 | 82 | return if (base == 10) |
| 83 | 83 | '0' <= c and c <= '9' |
| 84 | 84 | 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 | } |
| 87 | 87 | |
| 88 | 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 | 222 | const c: u8 = str[str.len - 1]; |
| 223 | 223 | const y: u32 = @as(u32, @intCast(a)) +% (@as(u32, @intCast(b)) << 8); |
| 224 | 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 | 227 | return k2; |
| 228 | 228 | } |
lib/std/hash/xxhash.zig+1-1| ... | ... | @@ -398,7 +398,7 @@ pub const XxHash32 = struct { |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | fn avalanche(value: u32) u32 { |
| 401 | var acc = value ^ value >> 15; | |
| 401 | var acc = value ^ (value >> 15); | |
| 402 | 402 | acc *%= prime_2; |
| 403 | 403 | acc ^= acc >> 13; |
| 404 | 404 | acc *%= prime_3; |
lib/std/hash_map.zig+1-1| ... | ... | @@ -2019,7 +2019,7 @@ test "getOrPutAdapted" { |
| 2019 | 2019 | const AdaptedContext = struct { |
| 2020 | 2020 | fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { |
| 2021 | 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 | 2024 | fn hash(self: @This(), adapted_key: []const u8) u64 { |
| 2025 | 2025 | _ = self; |
lib/std/heap/SafeAllocator.zig+1-1| ... | ... | @@ -211,7 +211,7 @@ const Bucket = struct { |
| 211 | 211 | |
| 212 | 212 | fn of(s: *SafeAllocator, ptr: [*]u8) *Bucket { |
| 213 | 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 | } |
| 216 | 216 | |
| 217 | 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 | 710 | |
| 711 | 711 | if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { |
| 712 | 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 | 714 | } else { |
| 715 | 715 | const ar = @mod(r, @typeInfo(T).int.bits); |
| 716 | 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 | 753 | |
| 754 | 754 | if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) { |
| 755 | 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 | 757 | } else { |
| 758 | 758 | const ar = @mod(r, @typeInfo(T).int.bits); |
| 759 | 759 | return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar); |
| ... | ... | @@ -1542,21 +1542,21 @@ pub const Order = enum { |
| 1542 | 1542 | const neg: i32 = -1; |
| 1543 | 1543 | const zero: i32 = 0; |
| 1544 | 1544 | const pos: i32 = 1; |
| 1545 | try testing.expect(order(zero, neg).differ() orelse | |
| 1546 | order(pos, zero) == .gt); | |
| 1547 | try testing.expect(order(zero, zero).differ() orelse | |
| 1548 | order(zero, zero) == .eq); | |
| 1549 | try testing.expect(order(pos, pos).differ() orelse | |
| 1550 | order(neg, zero) == .lt); | |
| 1551 | try testing.expect(order(zero, zero).differ() orelse | |
| 1545 | try testing.expect((order(zero, neg).differ() orelse | |
| 1546 | order(pos, zero)) == .gt); | |
| 1547 | try testing.expect((order(zero, zero).differ() orelse | |
| 1548 | order(zero, zero)) == .eq); | |
| 1549 | try testing.expect((order(pos, pos).differ() orelse | |
| 1550 | order(neg, zero)) == .lt); | |
| 1551 | try testing.expect((order(zero, zero).differ() orelse | |
| 1552 | 1552 | order(pos, neg).differ() orelse |
| 1553 | order(neg, zero) == .gt); | |
| 1554 | try testing.expect(order(pos, pos).differ() orelse | |
| 1553 | order(neg, zero)) == .gt); | |
| 1554 | try testing.expect((order(pos, pos).differ() orelse | |
| 1555 | 1555 | order(pos, pos).differ() orelse |
| 1556 | order(neg, neg) == .eq); | |
| 1557 | try testing.expect(order(zero, pos).differ() orelse | |
| 1556 | order(neg, neg)) == .eq); | |
| 1557 | try testing.expect((order(zero, pos).differ() orelse | |
| 1558 | 1558 | order(neg, pos).differ() orelse |
| 1559 | order(pos, neg) == .lt); | |
| 1559 | order(pos, neg)) == .lt); | |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 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 | 176 | // |x| >= 1 or nan |
| 177 | 177 | if (ix >= 0x3ff0_0000) { |
| 178 | 178 | const lx: u32 = @truncate(@as(u64, @bitCast(x))); |
| 179 | if ((ix - 0x3ff0_0000 | lx) == 0) { | |
| 179 | if (((ix - 0x3ff0_0000) | lx) == 0) { | |
| 180 | 180 | if (hx >> 31 != 0) { |
| 181 | 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 | 156 | if (ix >= 0x3ff0_0000) { |
| 157 | 157 | const lx: u32 = @truncate(@as(u64, @bitCast(x))); |
| 158 | 158 | // asin(1) = +-pi/2 with inexact |
| 159 | if ((ix - 0x3ff0_0000 | lx) == 0) { | |
| 159 | if (((ix - 0x3ff0_0000) | lx) == 0) { | |
| 160 | 160 | return x * pio2_hi + 0x1.0p-120; |
| 161 | 161 | } |
| 162 | 162 | return 0.0 / (x - x); |
lib/std/math/big/int.zig+3-3| ... | ... | @@ -2401,7 +2401,7 @@ pub const Const = struct { |
| 2401 | 2401 | const shift: usize = @intCast(exponent - @bitSizeOf(Repr.Normalized.Fraction)); |
| 2402 | 2402 | mantissa.shiftRight(normalized_abs, shift); |
| 2403 | 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 | 2405 | @intFromBool(!std.mem.allEqual(Limb, normalized_abs.limbs[0..final_limb_index], 0)); |
| 2406 | 2406 | if (round_bits == 0) break :exactness .exact; |
| 2407 | 2407 | round: switch (round) { |
| ... | ... | @@ -4902,10 +4902,10 @@ test "format" { |
| 4902 | 4902 | try a.set(20000000000000000000); // > maxInt(u64) |
| 4903 | 4903 | try testFormat(a, "20000000000000000000"); |
| 4904 | 4904 | |
| 4905 | try a.set(1 << 64 * @sizeOf(usize) * 8); | |
| 4905 | try a.set(1 << (64 * @sizeOf(usize) * 8)); | |
| 4906 | 4906 | try testFormat(a, "(BigInt)"); |
| 4907 | 4907 | |
| 4908 | try a.set(-(1 << 64 * @sizeOf(usize) * 8)); | |
| 4908 | try a.set(-(1 << (64 * @sizeOf(usize) * 8))); | |
| 4909 | 4909 | try testFormat(a, "(BigInt)"); |
| 4910 | 4910 | } |
| 4911 | 4911 |
lib/std/math/big/int_test.zig+16-16| ... | ... | @@ -2489,14 +2489,14 @@ test "truncate to minimum signed integer" { |
| 2489 | 2489 | .len = undefined, |
| 2490 | 2490 | .positive = undefined, |
| 2491 | 2491 | }; |
| 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)); | |
| 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)); | |
| 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)); | |
| 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)); | |
| 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)); | |
| 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)); | |
| 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)); | |
| 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)); | |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | 2502 | test "saturate single signed positive" { |
| ... | ... | @@ -3880,7 +3880,7 @@ test "clz" { |
| 3880 | 3880 | try testing.expectEqual(0, neg_limb_max_squared_plus_one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3881 | 3881 | |
| 3882 | 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 | 3884 | .positive = false, |
| 3885 | 3885 | }; |
| 3886 | 3886 | try testing.expectEqual(0, neg_limb_msb_squared.clz(@bitSizeOf(Limb) * 2)); |
| ... | ... | @@ -3896,7 +3896,7 @@ test "clz" { |
| 3896 | 3896 | try testing.expectEqual(0, neg_limb_max.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3897 | 3897 | |
| 3898 | 3898 | const neg_limb_msb: std.math.big.int.Const = .{ |
| 3899 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | |
| 3899 | .limbs = &.{1 << (@bitSizeOf(Limb) - 1)}, | |
| 3900 | 3900 | .positive = false, |
| 3901 | 3901 | }; |
| 3902 | 3902 | try testing.expectEqual(0, neg_limb_msb.clz(@bitSizeOf(Limb))); |
| ... | ... | @@ -3936,7 +3936,7 @@ test "clz" { |
| 3936 | 3936 | try testing.expectEqual(@bitSizeOf(Limb) * 2, one.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3937 | 3937 | |
| 3938 | 3938 | const limb_msb: std.math.big.int.Const = .{ |
| 3939 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | |
| 3939 | .limbs = &.{1 << (@bitSizeOf(Limb) - 1)}, | |
| 3940 | 3940 | .positive = true, |
| 3941 | 3941 | }; |
| 3942 | 3942 | try testing.expectEqual(0, limb_msb.clz(@bitSizeOf(Limb))); |
| ... | ... | @@ -3956,7 +3956,7 @@ test "clz" { |
| 3956 | 3956 | try testing.expectEqual(@bitSizeOf(Limb) + 1, limb_max.clz(@bitSizeOf(Limb) * 2 + 1)); |
| 3957 | 3957 | |
| 3958 | 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 | 3960 | .positive = true, |
| 3961 | 3961 | }; |
| 3962 | 3962 | try testing.expectEqual(0, limb_msb_squared.clz(@bitSizeOf(Limb) * 2 - 1)); |
| ... | ... | @@ -3992,7 +3992,7 @@ test "ctz" { |
| 3992 | 3992 | try testing.expectEqual(@bitSizeOf(Limb) + 1, neg_limb_max_squared_plus_one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 3993 | 3993 | |
| 3994 | 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 | 3996 | .positive = false, |
| 3997 | 3997 | }; |
| 3998 | 3998 | try testing.expectEqual(@bitSizeOf(Limb) * 2 - 2, neg_limb_msb_squared.ctz(@bitSizeOf(Limb) * 2)); |
| ... | ... | @@ -4008,7 +4008,7 @@ test "ctz" { |
| 4008 | 4008 | try testing.expectEqual(0, neg_limb_max.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 4009 | 4009 | |
| 4010 | 4010 | const neg_limb_msb: std.math.big.int.Const = .{ |
| 4011 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | |
| 4011 | .limbs = &.{1 << (@bitSizeOf(Limb) - 1)}, | |
| 4012 | 4012 | .positive = false, |
| 4013 | 4013 | }; |
| 4014 | 4014 | try testing.expectEqual(@bitSizeOf(Limb) - 1, neg_limb_msb.ctz(@bitSizeOf(Limb))); |
| ... | ... | @@ -4048,7 +4048,7 @@ test "ctz" { |
| 4048 | 4048 | try testing.expectEqual(0, one.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 4049 | 4049 | |
| 4050 | 4050 | const limb_msb: std.math.big.int.Const = .{ |
| 4051 | .limbs = &.{1 << @bitSizeOf(Limb) - 1}, | |
| 4051 | .limbs = &.{1 << (@bitSizeOf(Limb) - 1)}, | |
| 4052 | 4052 | .positive = true, |
| 4053 | 4053 | }; |
| 4054 | 4054 | try testing.expectEqual(@bitSizeOf(Limb) - 1, limb_msb.ctz(@bitSizeOf(Limb))); |
| ... | ... | @@ -4068,7 +4068,7 @@ test "ctz" { |
| 4068 | 4068 | try testing.expectEqual(0, limb_max.ctz(@bitSizeOf(Limb) * 2 + 1)); |
| 4069 | 4069 | |
| 4070 | 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 | 4072 | .positive = true, |
| 4073 | 4073 | }; |
| 4074 | 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 | 281 | return reconstructFloat( |
| 282 | 282 | RuntimeType, |
| 283 | 283 | floatExponentMax(RuntimeType) + 1, |
| 284 | mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 1), | |
| 284 | mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 1)), | |
| 285 | 285 | ); |
| 286 | 286 | } |
| 287 | 287 | |
| ... | ... | @@ -297,7 +297,7 @@ pub inline fn snan(comptime Type: type) Type { |
| 297 | 297 | return reconstructFloat( |
| 298 | 298 | RuntimeType, |
| 299 | 299 | floatExponentMax(RuntimeType) + 1, |
| 300 | mantissaOne(RuntimeType) | 1 << (floatFractionalBits(RuntimeType) - 2), | |
| 300 | mantissaOne(RuntimeType) | (1 << (floatFractionalBits(RuntimeType) - 2)), | |
| 301 | 301 | ); |
| 302 | 302 | } |
| 303 | 303 |
lib/std/mem.zig+1-1| ... | ... | @@ -4354,7 +4354,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize { |
| 4354 | 4354 | @compileError("expected many item pointer, got " ++ @typeName(T)); |
| 4355 | 4355 | |
| 4356 | 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 | 4358 | return 0; |
| 4359 | 4359 | |
| 4360 | 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 | 62 | const hashtab = maybe_hashtab orelse return 0; |
| 63 | 63 | if (maybe_verdef == null) maybe_versym = null; |
| 64 | 64 | |
| 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); | |
| 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); | |
| 67 | 67 | |
| 68 | 68 | var i: usize = 0; |
| 69 | 69 | while (i < hashtab[1]) : (i += 1) { |
| 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; | |
| 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; | |
| 72 | 72 | if (0 == syms[i].st_shndx) continue; |
| 73 | 73 | const sym_name = @as([*:0]u8, @ptrCast(strings + syms[i].st_name)); |
| 74 | 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 | 1 | const testing = @import("std").testing; |
| 2 | 2 | |
| 3 | const high_bit = 1 << @typeInfo(usize).int.bits - 1; | |
| 3 | const high_bit = 1 << (@typeInfo(usize).int.bits - 1); | |
| 4 | 4 | |
| 5 | 5 | pub const Status = enum(usize) { |
| 6 | 6 | /// The operation completed successfully. |
lib/std/unicode.zig+1-1| ... | ... | @@ -485,7 +485,7 @@ pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 { |
| 485 | 485 | const high_half: u21 = surrogate_pair[0]; |
| 486 | 486 | const low_half = surrogate_pair[1]; |
| 487 | 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 | } |
| 490 | 490 | |
| 491 | 491 | pub 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 | 555 | .var_const_decl => { |
| 556 | 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 | }, | |
| 558 | 585 | |
| 559 | 586 | .invalid_byte => { |
| 560 | 587 | const tok_slice = tree.source[tree.tokens.items(.start)[parse_error.token]..]; |
| ... | ... | @@ -2893,6 +2920,11 @@ pub const Error = struct { |
| 2893 | 2920 | expected_var_const, |
| 2894 | 2921 | wrong_equal_var_decl, |
| 2895 | 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, | |
| 2896 | 2928 | |
| 2897 | 2929 | zig_style_container, |
| 2898 | 2930 | previous_field, |
lib/std/zig/Ast/Render.zig+3-3| ... | ... | @@ -1483,9 +1483,9 @@ fn renderThenElse( |
| 1483 | 1483 | last_else_token = error_token + 1; // | |
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | const indent_else_expr = indent_then_expr and | |
| 1486 | const indent_else_expr = (indent_then_expr and | |
| 1487 | 1487 | !nodeIsBlock(tree.nodeTag(else_expr)) and |
| 1488 | !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr)) or | |
| 1488 | !nodeIsIfForWhileSwitch(tree.nodeTag(else_expr))) or | |
| 1489 | 1489 | tree.tokenTag(tree.firstToken(else_expr)) == |
| 1490 | 1490 | .multiline_string_literal_line; |
| 1491 | 1491 | if (indent_else_expr) { |
| ... | ... | @@ -3195,7 +3195,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool { |
| 3195 | 3195 | } |
| 3196 | 3196 | } |
| 3197 | 3197 | |
| 3198 | index = 1 + (newline orelse end - 1); | |
| 3198 | index = 1 + (newline orelse (end - 1)); | |
| 3199 | 3199 | |
| 3200 | 3200 | const comment_content = mem.trimStart(u8, trimmed_comment["//".len..], &std.ascii.whitespace); |
| 3201 | 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 | 1512 | } |
| 1513 | 1513 | |
| 1514 | 1514 | fn parseExpr(p: *Parse) Error!?Node.Index { |
| 1515 | return p.parseExprPrecedence(0); | |
| 1515 | return p.parseExprPrecedence(.start, p.tok_i); | |
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | 1518 | fn expectExpr(p: *Parse) Error!Node.Index { |
| ... | ... | @@ -1524,67 +1524,317 @@ const Assoc = enum { |
| 1524 | 1524 | none, |
| 1525 | 1525 | }; |
| 1526 | 1526 | |
| 1527 | const 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 | ||
| 1527 | 1718 | const OperInfo = struct { |
| 1528 | prec: i8, | |
| 1719 | prec: PrecClass, | |
| 1529 | 1720 | tag: Node.Tag, |
| 1530 | assoc: Assoc = Assoc.left, | |
| 1531 | 1721 | }; |
| 1532 | 1722 | |
| 1533 | // A table of binary operator information. Higher precedence numbers are | |
| 1534 | // stickier. All operators at the same precedence level should have the same | |
| 1535 | // associativity. | |
| 1536 | const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = -1, .tag = Node.Tag.root }, 0, .{ | |
| 1537 | .keyword_or = .{ .prec = 10, .tag = .bool_or }, | |
| 1538 | ||
| 1539 | .keyword_and = .{ .prec = 20, .tag = .bool_and }, | |
| 1540 | ||
| 1541 | .equal_equal = .{ .prec = 30, .tag = .equal_equal, .assoc = Assoc.none }, | |
| 1542 | .bang_equal = .{ .prec = 30, .tag = .bang_equal, .assoc = Assoc.none }, | |
| 1543 | .angle_bracket_left = .{ .prec = 30, .tag = .less_than, .assoc = Assoc.none }, | |
| 1544 | .angle_bracket_right = .{ .prec = 30, .tag = .greater_than, .assoc = Assoc.none }, | |
| 1545 | .angle_bracket_left_equal = .{ .prec = 30, .tag = .less_or_equal, .assoc = Assoc.none }, | |
| 1546 | .angle_bracket_right_equal = .{ .prec = 30, .tag = .greater_or_equal, .assoc = Assoc.none }, | |
| 1547 | ||
| 1548 | .ampersand = .{ .prec = 40, .tag = .bit_and }, | |
| 1549 | .caret = .{ .prec = 40, .tag = .bit_xor }, | |
| 1550 | .pipe = .{ .prec = 40, .tag = .bit_or }, | |
| 1551 | .keyword_orelse = .{ .prec = 40, .tag = .@"orelse" }, | |
| 1552 | .keyword_catch = .{ .prec = 40, .tag = .@"catch" }, | |
| 1553 | ||
| 1554 | .angle_bracket_angle_bracket_left = .{ .prec = 50, .tag = .shl }, | |
| 1555 | .angle_bracket_angle_bracket_left_pipe = .{ .prec = 50, .tag = .shl_sat }, | |
| 1556 | .angle_bracket_angle_bracket_right = .{ .prec = 50, .tag = .shr }, | |
| 1557 | ||
| 1558 | .plus = .{ .prec = 60, .tag = .add }, | |
| 1559 | .minus = .{ .prec = 60, .tag = .sub }, | |
| 1560 | .plus_plus = .{ .prec = 60, .tag = .array_cat }, | |
| 1561 | .plus_percent = .{ .prec = 60, .tag = .add_wrap }, | |
| 1562 | .minus_percent = .{ .prec = 60, .tag = .sub_wrap }, | |
| 1563 | .plus_pipe = .{ .prec = 60, .tag = .add_sat }, | |
| 1564 | .minus_pipe = .{ .prec = 60, .tag = .sub_sat }, | |
| 1565 | ||
| 1566 | .pipe_pipe = .{ .prec = 70, .tag = .merge_error_sets }, | |
| 1567 | .asterisk = .{ .prec = 70, .tag = .mul }, | |
| 1568 | .slash = .{ .prec = 70, .tag = .div }, | |
| 1569 | .percent = .{ .prec = 70, .tag = .mod }, | |
| 1570 | .asterisk_percent = .{ .prec = 70, .tag = .mul_wrap }, | |
| 1571 | .asterisk_pipe = .{ .prec = 70, .tag = .mul_sat }, | |
| 1723 | const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec = .start, .tag = Node.Tag.root }, 0, .{ | |
| 1724 | // zig fmt: off | |
| 1725 | .keyword_or = .{ .prec = .{ .group = .bool_or }, .tag = .bool_or }, | |
| 1726 | ||
| 1727 | .keyword_and = .{ .prec = .{ .group = .bool_and }, .tag = .bool_and }, | |
| 1728 | ||
| 1729 | .equal_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .equal_equal }, | |
| 1730 | .bang_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .bang_equal }, | |
| 1731 | .angle_bracket_left = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_than }, | |
| 1732 | .angle_bracket_right = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_than }, | |
| 1733 | .angle_bracket_left_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .less_or_equal }, | |
| 1734 | .angle_bracket_right_equal = .{ .prec = .{ .group = .comparison, .assoc = Assoc.none }, .tag = .greater_or_equal }, | |
| 1735 | ||
| 1736 | .ampersand = .{ .prec = .{ .group = .bitwise_and }, .tag = .bit_and }, | |
| 1737 | .caret = .{ .prec = .{ .group = .bitwise_xor }, .tag = .bit_xor }, | |
| 1738 | .pipe = .{ .prec = .{ .group = .bitwise_or }, .tag = .bit_or }, | |
| 1739 | ||
| 1740 | .keyword_orelse = .{ .prec = .{ .group = .recovery_orelse }, .tag = .@"orelse" }, | |
| 1741 | .keyword_catch = .{ .prec = .{ .group = .recovery_catch }, .tag = .@"catch" }, | |
| 1742 | ||
| 1743 | .angle_bracket_angle_bracket_left = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl }, | |
| 1744 | .angle_bracket_angle_bracket_left_pipe = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shl_sat }, | |
| 1745 | .angle_bracket_angle_bracket_right = .{ .prec = .{ .group = .bitwise_shift, .assoc = Assoc.none }, .tag = .shr }, | |
| 1746 | ||
| 1747 | .plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add }, | |
| 1748 | .minus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub }, | |
| 1749 | .plus_plus = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .array_cat }, | |
| 1750 | .plus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_wrap }, | |
| 1751 | .minus_percent = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_wrap }, | |
| 1752 | .plus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .add_sat }, | |
| 1753 | .minus_pipe = .{ .prec = .{ .group = .arithmetic_sum }, .tag = .sub_sat }, | |
| 1754 | ||
| 1755 | .pipe_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .merge_error_sets }, | |
| 1756 | .asterisk = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul }, | |
| 1757 | .slash = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .div }, | |
| 1758 | .asterisk_percent = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_wrap }, | |
| 1759 | .asterisk_pipe = .{ .prec = .{ .group = .arithmetic_product_chainable }, .tag = .mul_sat }, | |
| 1760 | ||
| 1761 | .percent = .{ .prec = .{ .group = .arithmetic_mod_nonchainable, .assoc = Assoc.none }, .tag = .mod }, | |
| 1762 | // zig fmt: on | |
| 1572 | 1763 | }); |
| 1573 | 1764 | |
| 1574 | fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index { | |
| 1575 | assert(min_prec >= 0); | |
| 1765 | fn parseExprPrecedence(p: *Parse, min_exc_prec: PrecClass, prev_token_const: u32) Error!?Node.Index { | |
| 1576 | 1766 | var node = try p.parsePrefixExpr() orelse return null; |
| 1577 | 1767 | |
| 1578 | var banned_prec: i8 = -1; | |
| 1768 | var prev_operator_token = prev_token_const; | |
| 1579 | 1769 | |
| 1580 | 1770 | while (true) { |
| 1581 | 1771 | const tok_tag = p.tokenTag(p.tok_i); |
| 1582 | const info = operTable[@as(usize, @intCast(@backingInt(tok_tag)))]; | |
| 1583 | if (info.prec < min_prec) { | |
| 1772 | const info = operTable[@intFromEnum(tok_tag)]; | |
| 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 | 1808 | break; |
| 1585 | 1809 | } |
| 1586 | if (info.prec == banned_prec) { | |
| 1587 | return p.fail(.chained_comparison_operators); | |
| 1810 | ||
| 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 | } |
| 1589 | 1839 | |
| 1590 | 1840 | const oper_token = p.nextToken(); |
| ... | ... | @@ -1614,7 +1864,8 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index { |
| 1614 | 1864 | } |
| 1615 | 1865 | } |
| 1616 | 1866 | |
| 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 | 1869 | try p.warn(.expected_expr); |
| 1619 | 1870 | return node; |
| 1620 | 1871 | }; |
| ... | ... | @@ -1624,10 +1875,6 @@ fn parseExprPrecedence(p: *Parse, min_prec: i32) Error!?Node.Index { |
| 1624 | 1875 | .main_token = oper_token, |
| 1625 | 1876 | .data = .{ .node_and_node = .{ node, rhs } }, |
| 1626 | 1877 | }); |
| 1627 | ||
| 1628 | if (info.assoc == Assoc.none) { | |
| 1629 | banned_prec = info.prec; | |
| 1630 | } | |
| 1631 | 1878 | } |
| 1632 | 1879 | |
| 1633 | 1880 | return node; |
lib/std/zig/TokenSmith.zig+1-1| ... | ... | @@ -160,7 +160,7 @@ pub fn gen(smith: *Smith) TokenSmith { |
| 160 | 160 | var no_period = false; |
| 161 | 161 | var not_exponent = true; |
| 162 | 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 | 164 | const is_exponent = c.* == '-' or c.* == '+'; |
| 165 | 165 | const invalid_exponent = not_exponent and is_exponent; |
| 166 | 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 | 404 | if (bc.bit_offset == 0) bc.bit_buffer = try bc.read32Bits(); |
| 405 | 405 | const chunk_len = @min(@as(u6, 32) - bc.bit_offset, remaining); |
| 406 | 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 | 408 | shift += @intCast(chunk_len); |
| 409 | 409 | remaining -= chunk_len; |
| 410 | 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 | 1076 | child: Type, |
| 1077 | 1077 | |
| 1078 | 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 | }; |
| 1082 | 1082 | |
| ... | ... | @@ -9520,7 +9520,7 @@ pub const Metadata = packed struct(u32) { |
| 9520 | 9520 | size_in_bits_hi: u32, |
| 9521 | 9521 | |
| 9522 | 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 | }; |
| 9526 | 9526 | |
| ... | ... | @@ -9537,10 +9537,10 @@ pub const Metadata = packed struct(u32) { |
| 9537 | 9537 | fields_tuple: Metadata.Optional, |
| 9538 | 9538 | |
| 9539 | 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 | 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 | }; |
| 9546 | 9546 | |
| ... | ... | @@ -9558,13 +9558,13 @@ pub const Metadata = packed struct(u32) { |
| 9558 | 9558 | offset_in_bits_hi: u32, |
| 9559 | 9559 | |
| 9560 | 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 | 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 | 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 | }; |
| 9570 | 9570 | |
| ... | ... | @@ -12457,7 +12457,7 @@ fn doubleConstAssumeCapacity(self: *Builder, val: f64) Constant { |
| 12457 | 12457 | if (ctx.builder.constant_items.items(.tag)[rhs_index] != .double) return false; |
| 12458 | 12458 | const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index]; |
| 12459 | 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 | 12463 | const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self }); |
| ... | ... | @@ -12488,8 +12488,8 @@ fn fp128ConstAssumeCapacity(self: *Builder, val: f128) Constant { |
| 12488 | 12488 | if (ctx.builder.constant_items.items(.tag)[rhs_index] != .fp128) return false; |
| 12489 | 12489 | const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index]; |
| 12490 | 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 | | |
| 12492 | @as(u128, rhs_extra.hi_lo) << 64 | @as(u128, rhs_extra.lo_hi) << 32 | rhs_extra.lo_lo; | |
| 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; | |
| 12493 | 12493 | } |
| 12494 | 12494 | }; |
| 12495 | 12495 | const gop = self.constant_map.getOrPutAssumeCapacityAdapted(val, Adapter{ .builder = self }); |
| ... | ... | @@ -12522,8 +12522,8 @@ fn x86_fp80ConstAssumeCapacity(self: *Builder, val: f80) Constant { |
| 12522 | 12522 | if (ctx.builder.constant_items.items(.tag)[rhs_index] != .x86_fp80) return false; |
| 12523 | 12523 | const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index]; |
| 12524 | 12524 | const rhs_extra = ctx.builder.constantExtraData(Constant.Fp80, rhs_data); |
| 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; | |
| 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; | |
| 12527 | 12527 | } |
| 12528 | 12528 | }; |
| 12529 | 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 | 12555 | if (ctx.builder.constant_items.items(.tag)[rhs_index] != .ppc_fp128) return false; |
| 12556 | 12556 | const rhs_data = ctx.builder.constant_items.items(.data)[rhs_index]; |
| 12557 | 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 and | |
| 12559 | @as(u64, @bitCast(lhs_key[1])) == @as(u64, rhs_extra.hi_hi) << 32 | rhs_extra.hi_lo; | |
| 12558 | 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; | |
| 12560 | 12560 | } |
| 12561 | 12561 | }; |
| 12562 | 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 | 15225 | for (limbs) |*limb| { |
| 15226 | 15226 | const val = std.mem.littleToNative(i64, @bitCast(limb.*)); |
| 15227 | 15227 | limb.* = @bitCast(if (val >= 0) |
| 15228 | val << 1 | 0 | |
| 15228 | (val << 1) | 0 | |
| 15229 | 15229 | else |
| 15230 | -%val << 1 | 1); | |
| 15230 | (-%val << 1) | 1); | |
| 15231 | 15231 | } |
| 15232 | 15232 | try constants_block.writeUnabbrev(5, record.items); |
| 15233 | 15233 | continue; |
| 15234 | 15234 | }; |
| 15235 | 15235 | try constants_block.writeAbbrev(ConstantsBlock.Integer{ |
| 15236 | 15236 | .value = @bitCast(if (val >= 0) |
| 15237 | val << 1 | 0 | |
| 15237 | (val << 1) | 0 | |
| 15238 | 15238 | else |
| 15239 | -%val << 1 | 1), | |
| 15239 | (-%val << 1) | 1), | |
| 15240 | 15240 | }); |
| 15241 | 15241 | }, |
| 15242 | 15242 | .half, |
| ... | ... | @@ -15252,8 +15252,8 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco |
| 15252 | 15252 | .x86_fp80 => { |
| 15253 | 15253 | const extra = self.constantExtraData(Constant.Fp80, data); |
| 15254 | 15254 | try constants_block.writeAbbrev(ConstantsBlock.Fp80{ |
| 15255 | .hi = @as(u64, extra.hi) << 48 | @as(u64, extra.lo_hi) << 16 | | |
| 15256 | extra.lo_lo >> 16, | |
| 15255 | .hi = (@as(u64, extra.hi) << 48) | (@as(u64, extra.lo_hi) << 16) | | |
| 15256 | (extra.lo_lo >> 16), | |
| 15257 | 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 | 15262 | => { |
| 15263 | 15263 | const extra = self.constantExtraData(Constant.Fp128, data); |
| 15264 | 15264 | try constants_block.writeAbbrev(ConstantsBlock.Fp128{ |
| 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), | |
| 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), | |
| 15267 | 15267 | }); |
| 15268 | 15268 | }, |
| 15269 | 15269 | .array, |
| ... | ... | @@ -15724,9 +15724,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco |
| 15724 | 15724 | for (limbs) |*limb| { |
| 15725 | 15725 | const val = std.mem.littleToNative(i64, @bitCast(limb.*)); |
| 15726 | 15726 | limb.* = @bitCast(if (val >= 0) |
| 15727 | val << 1 | 0 | |
| 15727 | (val << 1) | 0 | |
| 15728 | 15728 | else |
| 15729 | -%val << 1 | 1); | |
| 15729 | (-%val << 1) | 1); | |
| 15730 | 15730 | } |
| 15731 | 15731 | try metadata_block.writeUnabbrev(@backingInt(MetadataBlock.Code.ENUMERATOR), record.items); |
| 15732 | 15732 | continue; |
| ... | ... | @@ -15736,9 +15736,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco |
| 15736 | 15736 | .bit_width = extra.bit_width, |
| 15737 | 15737 | .name = extra.name, |
| 15738 | 15738 | .value = @bitCast(if (val >= 0) |
| 15739 | val << 1 | 0 | |
| 15739 | (val << 1) | 0 | |
| 15740 | 15740 | else |
| 15741 | -%val << 1 | 1), | |
| 15741 | (-%val << 1) | 1), | |
| 15742 | 15742 | }, metadata_adapter); |
| 15743 | 15743 | }, |
| 15744 | 15744 | .subrange => { |
lib/std/zig/llvm/bitcode_writer.zig+1-1| ... | ... | @@ -102,7 +102,7 @@ pub fn BitcodeWriter(comptime types: []const type) type { |
| 102 | 102 | // If input is larger than one VBR block can store |
| 103 | 103 | // then store vbr_bits - 1 bits and a continue bit |
| 104 | 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 | 106 | in_buffer >>= @intCast(vbr_bits - 1); |
| 107 | 107 | } |
| 108 | 108 |
lib/std/zig/parser_test.zig+42-6| ... | ... | @@ -3046,19 +3046,14 @@ test "zig fmt: precedence" { |
| 3046 | 3046 | \\ !(a{}); |
| 3047 | 3047 | \\ a + b{}; |
| 3048 | 3048 | \\ (a + b){}; |
| 3049 | \\ a << b + c; | |
| 3050 | 3049 | \\ (a << b) + c; |
| 3051 | \\ a & b << c; | |
| 3052 | 3050 | \\ (a & b) << c; |
| 3053 | \\ a ^ b & c; | |
| 3054 | 3051 | \\ (a ^ b) & c; |
| 3055 | \\ a | b ^ c; | |
| 3056 | 3052 | \\ (a | b) ^ c; |
| 3057 | 3053 | \\ a == b | c; |
| 3058 | 3054 | \\ (a == b) | c; |
| 3059 | 3055 | \\ a and b == c; |
| 3060 | 3056 | \\ (a and b) == c; |
| 3061 | \\ a or b and c; | |
| 3062 | 3057 | \\ (a or b) and c; |
| 3063 | 3058 | \\ (a or b) and c; |
| 3064 | 3059 | \\ a == b and c == d; |
| ... | ... | @@ -3067,6 +3062,47 @@ test "zig fmt: precedence" { |
| 3067 | 3062 | ); |
| 3068 | 3063 | } |
| 3069 | 3064 | |
| 3065 | test "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 | ||
| 3070 | 3106 | test "zig fmt: prefix operators" { |
| 3071 | 3107 | try testCanonical( |
| 3072 | 3108 | \\test "prefix operators" { |
| ... | ... | @@ -7205,7 +7241,7 @@ test "recovery: missing comma" { |
| 7205 | 7241 | \\ 2 => {} |
| 7206 | 7242 | \\ 3 => {} |
| 7207 | 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 | 266 | // Minor * 1(0),000 summed has been convention since FreeBSD 2.2 (1997) |
| 267 | 267 | // e.g. 492101 = 4.11-STABLE = 4.(9+2) |
| 268 | 268 | const major = value / 100_000; |
| 269 | 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 since | |
| 269 | 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 since | |
| 271 | 271 | const patch = value % 1_000; |
| 272 | 272 | os.version_range.semver.min = .{ .major = major, .minor = minor1 + minor2, .patch = patch }; |
| 273 | 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 | 280 | // r = 0 (*) |
| 281 | 281 | // p = patchlevel |
| 282 | 282 | const major = value / 100_000_000; |
| 283 | const minor = value % 100_000_000 / 1_000_000; | |
| 284 | const patch = value % 10_000 / 100; | |
| 283 | const minor = (value % 100_000_000) / 1_000_000; | |
| 284 | const patch = (value % 10_000) / 100; | |
| 285 | 285 | os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch }; |
| 286 | 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 | 292 | // m = minor; odd-numbers indicate current dev branch |
| 293 | 293 | // p = patch |
| 294 | 294 | const major = value / 100_000; |
| 295 | const minor = value % 100_000 / 100; | |
| 295 | const minor = (value % 100_000) / 100; | |
| 296 | 296 | const patch = value % 100; |
| 297 | 297 | os.version_range.semver.min = .{ .major = major, .minor = minor, .patch = patch }; |
| 298 | 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 | 25 | // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) |
| 26 | 26 | // \ `--> Service pack (Always zero in the constants defined) |
| 27 | 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 | 29 | @as(u16, @intCast(version_info.dwMinorVersion & 0xff)); |
| 30 | 30 | const sp_ver: u8 = 0; |
| 31 | 31 | const sub_ver: u8 = if (os_ver >= 0x0A00) subver: { |
| ... | ... | @@ -40,7 +40,7 @@ pub fn detectRuntimeVersion() WindowsVersion { |
| 40 | 40 | break :subver @as(u8, @truncate(last_idx)); |
| 41 | 41 | } else 0; |
| 42 | 42 | |
| 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; | |
| 44 | 44 | |
| 45 | 45 | return @as(WindowsVersion, @fromBackingInt(@intCast(version))); |
| 46 | 46 | } |
src/Air.zig+1-1| ... | ... | @@ -1505,7 +1505,7 @@ pub const ShuffleTwoMask = enum(u32) { |
| 1505 | 1505 | return @fromBackingInt(@intCast(idx << 1)); |
| 1506 | 1506 | } |
| 1507 | 1507 | pub fn bElem(idx: u32) ShuffleTwoMask { |
| 1508 | return @fromBackingInt(@intCast(idx << 1 | 1)); | |
| 1508 | return @fromBackingInt(@intCast((idx << 1) | 1)); | |
| 1509 | 1509 | } |
| 1510 | 1510 | pub const Unwrapped = union(enum) { |
| 1511 | 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 | 1990 | .path = try options.dirs.global_cache.join(arena, &.{zir_sub_dir}), |
| 1991 | 1991 | }; |
| 1992 | 1992 | |
| 1993 | const std_mod = options.std_mod orelse Module.create(arena, .{ | |
| 1993 | const std_mod = options.std_mod orelse (Module.create(arena, .{ | |
| 1994 | 1994 | .paths = .{ |
| 1995 | 1995 | .root = try .fromRoot(arena, options.dirs, .zig_lib, "std"), |
| 1996 | 1996 | .root_src_path = "std.zig", |
| ... | ... | @@ -2015,7 +2015,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2015 | 2015 | error.StackProtectorUnsupportedByTarget => unreachable, |
| 2016 | 2016 | error.StackProtectorUnavailableWithoutLibC => unreachable, |
| 2017 | 2017 | error.PatchableFunctionEntryUnsupportedByBackend => unreachable, |
| 2018 | }; | |
| 2018 | }); | |
| 2019 | 2019 | |
| 2020 | 2020 | const zcu = try arena.create(Zcu); |
| 2021 | 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 | 243 | for (zcu.incremental_debug_state.types.keys()) |type_ip_index| { |
| 244 | 244 | const ty: Type = .fromInterned(type_ip_index); |
| 245 | 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 | 247 | 0b00 => std.mem.find(u8, ty_name, query) != null, |
| 248 | 248 | 0b01 => std.mem.endsWith(u8, ty_name, query), |
| 249 | 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 | 264 | for (zcu.incremental_debug_state.navs.keys()) |nav_index| { |
| 265 | 265 | const nav = ip.getNav(nav_index); |
| 266 | 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 | 268 | 0b00 => std.mem.find(u8, nav_fqn, query) != null, |
| 269 | 269 | 0b01 => std.mem.endsWith(u8, nav_fqn, query), |
| 270 | 270 | 0b10 => std.mem.startsWith(u8, nav_fqn, query), |
src/InternPool.zig+18-18| ... | ... | @@ -215,7 +215,7 @@ pub const TrackedInst = extern struct { |
| 215 | 215 | }; |
| 216 | 216 | pub fn unwrap(tracked_inst_index: TrackedInst.Index, ip: *const InternPool) Unwrapped { |
| 217 | 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 | 219 | .index = @backingInt(tracked_inst_index) & ip.getIndexMask(u32), |
| 220 | 220 | }; |
| 221 | 221 | } |
| ... | ... | @@ -517,7 +517,7 @@ pub const ComptimeUnit = extern struct { |
| 517 | 517 | }; |
| 518 | 518 | fn unwrap(id: Id, ip: *const InternPool) Unwrapped { |
| 519 | 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 | 521 | .index = @backingInt(id) & ip.getIndexMask(u31), |
| 522 | 522 | }; |
| 523 | 523 | } |
| ... | ... | @@ -655,7 +655,7 @@ pub const Nav = struct { |
| 655 | 655 | }; |
| 656 | 656 | fn unwrap(nav_index: Nav.Index, ip: *const InternPool) Unwrapped { |
| 657 | 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 | 659 | .index = @backingInt(nav_index) & ip.getIndexMask(u30), |
| 660 | 660 | }; |
| 661 | 661 | } |
| ... | ... | @@ -1627,7 +1627,7 @@ pub const MapIndex = enum(u32) { |
| 1627 | 1627 | }; |
| 1628 | 1628 | fn unwrap(map_index: MapIndex, ip: *const InternPool) Unwrapped { |
| 1629 | 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 | 1631 | .index = @backingInt(map_index) & ip.getIndexMask(u32), |
| 1632 | 1632 | }; |
| 1633 | 1633 | } |
| ... | ... | @@ -1648,14 +1648,14 @@ pub const NamespaceIndex = enum(u32) { |
| 1648 | 1648 | assert(unwrapped.bucket_index <= ip.getIndexMask(u32) >> Local.namespaces_bucket_width); |
| 1649 | 1649 | assert(unwrapped.index <= Local.namespaces_bucket_mask); |
| 1650 | 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 | 1652 | unwrapped.index)); |
| 1653 | 1653 | } |
| 1654 | 1654 | }; |
| 1655 | 1655 | fn unwrap(namespace_index: NamespaceIndex, ip: *const InternPool) Unwrapped { |
| 1656 | 1656 | const index = @backingInt(namespace_index) & ip.getIndexMask(u32); |
| 1657 | 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 | 1659 | .bucket_index = index >> Local.namespaces_bucket_width, |
| 1660 | 1660 | .index = index & Local.namespaces_bucket_mask, |
| 1661 | 1661 | }; |
| ... | ... | @@ -1696,7 +1696,7 @@ pub const FileIndex = enum(u32) { |
| 1696 | 1696 | }; |
| 1697 | 1697 | pub fn unwrap(file_index: FileIndex, ip: *const InternPool) Unwrapped { |
| 1698 | 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 | 1700 | .index = @backingInt(file_index) & ip.getIndexMask(u32), |
| 1701 | 1701 | }; |
| 1702 | 1702 | } |
| ... | ... | @@ -1755,7 +1755,7 @@ pub const String = enum(u32) { |
| 1755 | 1755 | }; |
| 1756 | 1756 | fn unwrap(string: String, ip: *const InternPool) Unwrapped { |
| 1757 | 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 | 1759 | .index = @backingInt(string) & ip.getIndexMask(u32), |
| 1760 | 1760 | }; |
| 1761 | 1761 | } |
| ... | ... | @@ -4199,7 +4199,7 @@ pub const Index = enum(u32) { |
| 4199 | 4199 | }; |
| 4200 | 4200 | pub fn unwrap(index: Index, ip: *const InternPool) Unwrapped { |
| 4201 | 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 | 4203 | .index = @backingInt(index) & ip.getIndexMask(u30), |
| 4204 | 4204 | }; |
| 4205 | 4205 | } |
| ... | ... | @@ -6062,7 +6062,7 @@ pub const PtrNav = struct { |
| 6062 | 6062 | }; |
| 6063 | 6063 | } |
| 6064 | 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 | }; |
| 6068 | 6068 | |
| ... | ... | @@ -6080,7 +6080,7 @@ pub const PtrUav = struct { |
| 6080 | 6080 | }; |
| 6081 | 6081 | } |
| 6082 | 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 | }; |
| 6086 | 6086 | |
| ... | ... | @@ -6101,7 +6101,7 @@ pub const PtrUavAligned = struct { |
| 6101 | 6101 | }; |
| 6102 | 6102 | } |
| 6103 | 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 | }; |
| 6107 | 6107 | |
| ... | ... | @@ -6119,7 +6119,7 @@ pub const PtrComptimeAlloc = struct { |
| 6119 | 6119 | }; |
| 6120 | 6120 | } |
| 6121 | 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 | }; |
| 6125 | 6125 | |
| ... | ... | @@ -6137,7 +6137,7 @@ pub const PtrComptimeField = struct { |
| 6137 | 6137 | }; |
| 6138 | 6138 | } |
| 6139 | 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 | }; |
| 6143 | 6143 | |
| ... | ... | @@ -6155,7 +6155,7 @@ pub const PtrBase = struct { |
| 6155 | 6155 | }; |
| 6156 | 6156 | } |
| 6157 | 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 | }; |
| 6161 | 6161 | |
| ... | ... | @@ -6175,7 +6175,7 @@ pub const PtrBaseIndex = struct { |
| 6175 | 6175 | }; |
| 6176 | 6176 | } |
| 6177 | 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 | }; |
| 6181 | 6181 | |
| ... | ... | @@ -6191,7 +6191,7 @@ pub const PtrInt = struct { |
| 6191 | 6191 | }; |
| 6192 | 6192 | } |
| 6193 | 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 | }; |
| 6197 | 6197 | |
| ... | ... | @@ -12634,7 +12634,7 @@ const PackedCallingConvention = packed struct(u18) { |
| 12634 | 12634 | std.lang.CallingConvention.SpirvFragmentOptions => .{ |
| 12635 | 12635 | .tag = tag, |
| 12636 | 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 | 12639 | std.lang.CallingConvention.SpirvMeshOptions => .{ |
| 12640 | 12640 | .tag = tag, |
src/Sema.zig+2-2| ... | ... | @@ -29942,10 +29942,10 @@ fn coerceVarArgParam( |
| 29942 | 29942 | if (!uncasted_ty.validateExtern(.param_ty, zcu)) break :int inst; |
| 29943 | 29943 | const target = zcu.getTarget(); |
| 29944 | 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 | 29946 | .signed => .int, |
| 29947 | 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 | 29949 | .signed => .c_int, |
| 29950 | 29950 | .unsigned => .c_uint, |
| 29951 | 29951 | }, inst, inst_src); |
src/codegen/aarch64/Assemble.zig+2-2| ... | ... | @@ -164,7 +164,7 @@ const matchers = matchers: { |
| 164 | 164 | return @call(.auto, encode, args); |
| 165 | 165 | } else if (pattern_token[0] == '<') { |
| 166 | 166 | 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 | 168 | const symbol = @field(Symbol, symbol_name); |
| 169 | 169 | const symbol_ptr = &@field(symbols, symbol_name); |
| 170 | 170 | const symbol_value = zonCast(SymbolSpec, @field(instruction.symbols, symbol_name), .{}).parse(source_token) orelse { |
| ... | ... | @@ -453,7 +453,7 @@ const SymbolSpec = union(enum) { |
| 453 | 453 | } else { |
| 454 | 454 | const Repr = std.math.FloatRepr(f16); |
| 455 | 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 | 457 | .denormal, .infinite => true, |
| 458 | 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 | 31 | .unallocated => break :unallocated, |
| 32 | 32 | .pc_relative_addressing => |pc_relative_addressing| { |
| 33 | 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 | 35 | .adr => aarch64.encoding.Instruction.size, |
| 36 | 36 | .adrp => 0, |
| 37 | 37 | }); |
| ... | ... | @@ -311,7 +311,7 @@ pub fn printInstruction(dis: Disassemble, inst: aarch64.encoding.Instruction, wr |
| 311 | 311 | .hint => |hint| return writer.print("{f}{s}#0x{x}", .{ |
| 312 | 312 | fmtCase(.hint, dis.case), |
| 313 | 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 | 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 | 365 | dis.mnemonic_operands_separator, |
| 366 | 366 | group.Rt.decode(.{}).general(@fromBackingInt(@intCast(group.b5))).fmtCase(dis.case), |
| 367 | 367 | dis.operands_separator, |
| 368 | @as(u6, group.b5) << 5 | | |
| 369 | @as(u6, group.b40) << 0, | |
| 368 | (@as(u6, group.b5) << 5) | | |
| 369 | (@as(u6, group.b40) << 0), | |
| 370 | 370 | dis.operands_separator, |
| 371 | 371 | @as(u8, if (imm < 0) '-' else '+'), |
| 372 | 372 | @abs(imm) << 2, |
src/codegen/aarch64/Mir.zig+3-3| ... | ... | @@ -208,7 +208,7 @@ fn emitReloc( |
| 208 | 208 | }; |
| 209 | 209 | try atom.addReloc(gpa, .{ |
| 210 | 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 | 212 | .r_addend = @bitCast(addend), |
| 213 | 213 | }, zo); |
| 214 | 214 | } else if (lf.cast(.macho)) |mf| { |
| ... | ... | @@ -265,7 +265,7 @@ fn emitReloc( |
| 265 | 265 | }; |
| 266 | 266 | try atom.addReloc(gpa, .{ |
| 267 | 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 | 269 | .r_addend = @bitCast(addend), |
| 270 | 270 | }, zo); |
| 271 | 271 | } else if (lf.cast(.macho)) |mf| { |
| ... | ... | @@ -328,7 +328,7 @@ fn emitReloc( |
| 328 | 328 | }; |
| 329 | 329 | try atom.addReloc(gpa, .{ |
| 330 | 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 | 332 | .r_addend = @bitCast(addend), |
| 333 | 333 | }, zo); |
| 334 | 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 | 8099 | .{ .immediate = .{ |
| 8100 | 8100 | .N = @fromBackingInt(@intCast(elem_width >> 6)), |
| 8101 | 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 | 10831 | if (feat_fp16) { |
| 10832 | 10832 | const Repr = std.math.FloatRepr(f16); |
| 10833 | 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 | 10835 | .denormal, .infinite => false, |
| 10836 | 10836 | else => std.math.cast(i3, repr.exponent.unbias() - 1) != null, |
| 10837 | 10837 | }) break :free try isel.emit(.fmov(mat.ra.h(), .{ .immediate = imm })); |
| ... | ... | @@ -10855,7 +10855,7 @@ pub const Value = struct { |
| 10855 | 10855 | } }; |
| 10856 | 10856 | const Repr = std.math.FloatRepr(f32); |
| 10857 | 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 | 10859 | .denormal, .infinite => false, |
| 10860 | 10860 | else => std.math.cast(i3, repr.exponent.unbias() - 1) != null, |
| 10861 | 10861 | }) break :free try isel.emit(.fmov(mat.ra.s(), .{ .immediate = @floatCast(imm) })); |
| ... | ... | @@ -10878,7 +10878,7 @@ pub const Value = struct { |
| 10878 | 10878 | } }; |
| 10879 | 10879 | const Repr = std.math.FloatRepr(f64); |
| 10880 | 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 | 10882 | .denormal, .infinite => false, |
| 10883 | 10883 | else => std.math.cast(i3, repr.exponent.unbias() - 1) != null, |
| 10884 | 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 | 11886 | .cmode = switch (arrangement) { |
| 11887 | 11887 | else => unreachable, |
| 11888 | 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 | 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 | 11893 | .imm3 = @intCast(shifted_immediate.immediate >> 5), |
| 11894 | 11894 | .Q = arrangement.size(), |
| ... | ... | @@ -12384,7 +12384,7 @@ pub const Instruction = packed union { |
| 12384 | 12384 | .dup = .{ |
| 12385 | 12385 | .Rd = d.alias.encode(.{ .V = true }), |
| 12386 | 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 | 12400 | .Rd = d.alias.encode(.{ .V = true }), |
| 12401 | 12401 | .Rn = n.alias.encode(.{ .V = true }), |
| 12402 | 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 | 12404 | .Q = arrangement.size(), |
| 12405 | 12405 | }, |
| 12406 | 12406 | } } }; |
| ... | ... | @@ -14195,7 +14195,7 @@ pub const Instruction = packed union { |
| 14195 | 14195 | .Rd = d.alias.encode(.{ .V = true }), |
| 14196 | 14196 | .Rn = n.alias.encode(.{ .V = true }), |
| 14197 | 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 | 14199 | .op = .element, |
| 14200 | 14200 | }, |
| 14201 | 14201 | } } }; |
| ... | ... | @@ -14211,7 +14211,7 @@ pub const Instruction = packed union { |
| 14211 | 14211 | .Rd = d.alias.encode(.{ .V = true }), |
| 14212 | 14212 | .Rn = n.alias.encode(.{}), |
| 14213 | 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 | 14215 | .op = .general, |
| 14216 | 14216 | }, |
| 14217 | 14217 | } } }; |
| ... | ... | @@ -15072,16 +15072,16 @@ pub const Instruction = packed union { |
| 15072 | 15072 | .lsl => |amount| switch (arrangement) { |
| 15073 | 15073 | else => unreachable, |
| 15074 | 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 | 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 | 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 | 15081 | .msl => |amount| switch (arrangement) { |
| 15082 | 15082 | else => unreachable, |
| 15083 | 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 | 15086 | .replicate => switch (arrangement) { |
| 15087 | 15087 | else => unreachable, |
| ... | ... | @@ -15345,9 +15345,9 @@ pub const Instruction = packed union { |
| 15345 | 15345 | .cmode = switch (arrangement) { |
| 15346 | 15346 | else => unreachable, |
| 15347 | 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 | 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 | 15352 | .imm3 = @intCast(shifted_immediate.immediate >> 5), |
| 15353 | 15353 | .Q = arrangement.size(), |
| ... | ... | @@ -15660,9 +15660,9 @@ pub const Instruction = packed union { |
| 15660 | 15660 | .Rn = n.alias.encode(.{ .V = true }), |
| 15661 | 15661 | .imm5 = switch (vs) { |
| 15662 | 15662 | else => unreachable, |
| 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, | |
| 15665 | .single => @as(u5, @as(u2, @intCast(n.format.element.index))) << 3 | @as(u5, 0b100) << 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), | |
| 15665 | .single => (@as(u5, @as(u2, @intCast(n.format.element.index))) << 3) | (@as(u5, 0b100) << 0), | |
| 15666 | 15666 | }, |
| 15667 | 15667 | .Q = sf, |
| 15668 | 15668 | }, |
| ... | ... | @@ -16492,10 +16492,10 @@ pub const Instruction = packed union { |
| 16492 | 16492 | .Rn = n.alias.encode(.{ .V = true }), |
| 16493 | 16493 | .imm5 = switch (vs) { |
| 16494 | 16494 | else => unreachable, |
| 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, | |
| 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, | |
| 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), | |
| 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), | |
| 16499 | 16499 | }, |
| 16500 | 16500 | .Q = sf, |
| 16501 | 16501 | }, |
src/codegen/loongarch/Mir.zig+1-1| ... | ... | @@ -181,7 +181,7 @@ fn emitReloc( |
| 181 | 181 | const atom = zo.symbol(@backingInt(atom_index)).atom(ef).?; |
| 182 | 182 | try atom.addReloc(zcu.gpa, .{ |
| 183 | 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 | 185 | .r_addend = @bitCast(addend), |
| 186 | 186 | }, zo); |
| 187 | 187 | } else unreachable; |
src/codegen/riscv64/CodeGen.zig+2-2| ... | ... | @@ -1764,7 +1764,7 @@ fn finishAir( |
| 1764 | 1764 | ) !void { |
| 1765 | 1765 | const tomb_bits = func.liveness.getTombBits(inst); |
| 1766 | 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 | 1768 | if (func.reused_operands.isSet(op_index)) continue; |
| 1769 | 1769 | try func.processDeath(op.toIndexAllowNone() orelse continue); |
| 1770 | 1770 | } |
| ... | ... | @@ -6272,7 +6272,7 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void { |
| 6272 | 6272 | ""; |
| 6273 | 6273 | |
| 6274 | 6274 | op.* = switch (args.items[ |
| 6275 | arg_map.get(op_str["%[".len .. mod_index orelse op_str.len - "]".len]) orelse | |
| 6275 | arg_map.get(op_str["%[".len .. mod_index orelse (op_str.len - "]".len)]) orelse | |
| 6276 | 6276 | return func.fail("no matching constraint: '{s}'", .{op_str}) |
| 6277 | 6277 | ]) { |
| 6278 | 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 | 582 | |
| 583 | 583 | .opcode = opcode, |
| 584 | 584 | .funct3 = @backingInt(amo.width), |
| 585 | .funct7 = @as(u7, amo.funct5) << 2 | | |
| 586 | @as(u7, @intFromBool(ops[3].barrier == .rl)) << 1 | | |
| 585 | .funct7 = (@as(u7, amo.funct5) << 2) | | |
| 586 | (@as(u7, @intFromBool(ops[3].barrier == .rl)) << 1) | | |
| 587 | 587 | @as(u7, @intFromBool(ops[4].barrier == .aq)), |
| 588 | 588 | }, |
| 589 | 589 | else => unreachable, |
src/codegen/sparc64/CodeGen.zig+2-2| ... | ... | @@ -3475,11 +3475,11 @@ fn finishAirBookkeeping(self: *Self) void { |
| 3475 | 3475 | fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Air.Liveness.bpi - 1]Air.Inst.Ref) void { |
| 3476 | 3476 | const tomb_bits = self.liveness.getTombBits(inst); |
| 3477 | 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 | 3479 | if (self.reused_operands.isSet(op_index)) continue; |
| 3480 | 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 | 3483 | log.debug("%{d} => {}", .{ inst, result }); |
| 3484 | 3484 | const branch = &self.branch_stack.items[self.branch_stack.items.len - 1]; |
| 3485 | 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 | 1191 | const truncated_value = if (backing_bits == 64) |
| 1192 | 1192 | value64 |
| 1193 | 1193 | else |
| 1194 | value64 & (@as(u64, 1) << @intCast(backing_bits)) - 1; | |
| 1194 | value64 & ((@as(u64, 1) << @intCast(backing_bits)) - 1); | |
| 1195 | 1195 | |
| 1196 | 1196 | break :blk switch (backing_bits) { |
| 1197 | 1197 | 1...32 => .{ .uint32 = @truncate(truncated_value) }, |
src/codegen/x86_64/CodeGen.zig+17-17| ... | ... | @@ -173255,7 +173255,7 @@ fn finishAir( |
| 173255 | 173255 | ) !void { |
| 173256 | 173256 | const tomb_bits = self.liveness.getTombBits(inst); |
| 173257 | 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 | 173259 | if (self.reused_operands.isSet(op_index)) continue; |
| 173260 | 173260 | try self.processDeath(op.toIndexAllowNone() orelse continue, .{}); |
| 173261 | 173261 | } |
| ... | ... | @@ -176321,7 +176321,7 @@ fn lowerSwitchBr( |
| 176321 | 176321 | const unsigned_condition_ty = try cg.pt.intType(.unsigned, cg.intInfo(condition_ty).?.bits); |
| 176322 | 176322 | |
| 176323 | 176323 | const ExpectedContents = extern struct { |
| 176324 | liveness_deaths: [1 << 8 | 1]Air.Inst.Index, | |
| 176324 | liveness_deaths: [(1 << 8) | 1]Air.Inst.Index, | |
| 176325 | 176325 | bigint_limbs: [std.math.big.int.calcTwosCompLimbCount(1 << 10)]std.math.big.Limb, |
| 176326 | 176326 | relocs: [1 << 6]Mir.Inst.Index, |
| 176327 | 176327 | }; |
| ... | ... | @@ -177310,7 +177310,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 177310 | 177310 | else |
| 177311 | 177311 | ""; |
| 177312 | 177312 | op.* = switch (args[ |
| 177313 | arg_map.get(op_str["%[".len .. colon orelse op_str.len - "]".len]) orelse | |
| 177313 | arg_map.get(op_str["%[".len .. colon orelse (op_str.len - "]".len)]) orelse | |
| 177314 | 177314 | return self.fail("no matching constraint: '{s}'", .{op_str}) |
| 177315 | 177315 | ]) { |
| 177316 | 177316 | .immediate => |imm| if (std.mem.eql(u8, modifier, "") or |
| ... | ... | @@ -177454,7 +177454,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 177454 | 177454 | else |
| 177455 | 177455 | ""; |
| 177456 | 177456 | break :disp switch (args[ |
| 177457 | arg_map.get(op_str["%[".len .. colon orelse open - "]".len]) orelse | |
| 177457 | arg_map.get(op_str["%[".len .. colon orelse (open - "]".len)]) orelse | |
| 177458 | 177458 | return self.fail("no matching constraint: '{s}'", .{op_str}) |
| 177459 | 177459 | ]) { |
| 177460 | 177460 | .immediate => |imm| if (std.mem.eql(u8, modifier, "") or |
| ... | ... | @@ -179566,7 +179566,7 @@ fn atomicOp( |
| 179566 | 179566 | }; |
| 179567 | 179567 | defer if (mem_lock) |lock| self.register_manager.unlockReg(lock); |
| 179568 | 179568 | |
| 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 | 179570 | const strat: enum { lock, loop, libcall } = if (use_sse) .loop else switch (rmw_op orelse .Xchg) { |
| 179571 | 179571 | .Xchg, |
| 179572 | 179572 | .Add, |
| ... | ... | @@ -179626,7 +179626,7 @@ fn atomicOp( |
| 179626 | 179626 | |
| 179627 | 179627 | try self.asmRegisterMemory(.{ ._, .mov }, registerAlias(.rax, val_abi_size), ptr_mem); |
| 179628 | 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 | 179630 | try self.genSetReg(tmp_reg, val_ty, .{ .register = .rax }, .{}); |
| 179631 | 179631 | } |
| 179632 | 179632 | if (rmw_op) |op| if (use_sse) { |
| ... | ... | @@ -188854,7 +188854,7 @@ const Temp = struct { |
| 188854 | 188854 | for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| { |
| 188855 | 188855 | if (op_temp.index == temp.index) continue; |
| 188856 | 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 | 188858 | if (cg.reused_operands.isSet(op_index)) continue; |
| 188859 | 188859 | try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{}); |
| 188860 | 188860 | } |
| ... | ... | @@ -188916,7 +188916,7 @@ const Temp = struct { |
| 188916 | 188916 | } |
| 188917 | 188917 | for (0.., op_refs, op_temps) |op_index, op_ref, op_temp| { |
| 188918 | 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 | 188920 | if (cg.reused_operands.isSet(op_index)) continue; |
| 188921 | 188921 | try cg.processDeath(op_ref.toIndexAllowNone() orelse continue, .{}); |
| 188922 | 188922 | } |
| ... | ... | @@ -190117,9 +190117,9 @@ const Select = struct { |
| 190117 | 190117 | (@as(u64, std.math.maxInt(u64)) >> @intCast(res_scalar_info.bits - scalar_info.bits))), |
| 190118 | 190118 | .@"0x1p63_mem" => switch (res_scalar_info.bits) { |
| 190119 | 190119 | else => unreachable, |
| 190120 | 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << 64 - 16, | |
| 190121 | 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << 64 - 32, | |
| 190122 | 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << 64 - 64, | |
| 190120 | 16 => @as(i64, @as(i16, @bitCast(@as(f16, 0x1p63)))) << (64 - 16), | |
| 190121 | 32 => @as(i64, @as(i32, @bitCast(@as(f32, 0x1p63)))) << (64 - 32), | |
| 190122 | 64 => @as(i64, @as(i64, @bitCast(@as(f64, 0x1p63)))) << (64 - 64), | |
| 190123 | 190123 | }, |
| 190124 | 190124 | }; |
| 190125 | 190125 | const shift: u6 = @intCast(64 - res_scalar_info.bits); |
| ... | ... | @@ -191518,8 +191518,8 @@ const Select = struct { |
| 191518 | 191518 | @as(SignedImm, @intCast(s.cg.nonBoolScalarBitSize(op.flags.base.ref.typeOf(s)))), |
| 191519 | 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 | 191520 | .elem_mask => @as(u8, std.math.maxInt(u8)) >> @intCast( |
| 191521 | 8 - ((s.cg.unalignedSize(op.flags.base.ref.typeOf(s)) - 1) % | |
| 191522 | @divExact(op.flags.base.size.bitSize(s.cg.target), 8) + 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) >> | |
| 191523 | 191523 | op.flags.index.scale.toLog2()), |
| 191524 | 191524 | ), |
| 191525 | 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 | 191548 | }, |
| 191549 | 191549 | .repeat => switch (SignedImm) { |
| 191550 | 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 | 191554 | const rhs = op.flags.adjust.rhs.toLog2(); |
| ... | ... | @@ -191559,10 +191559,10 @@ const Select = struct { |
| 191559 | 191559 | break :op_res op_res[0]; |
| 191560 | 191560 | }, |
| 191561 | 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 | 191563 | .rem_8_mul => lhs & ((@as(SignedImm, 8) << rhs) - 1), |
| 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), | |
| 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), | |
| 191566 | 191566 | }; |
| 191567 | 191567 | const disp: SignedImm = @bitCast(@as(UnsignedImm, @as(u32, @bitCast(op.imm)))); |
| 191568 | 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 | 378 | } |
| 379 | 379 | |
| 380 | 380 | fn 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 | 382 | const reg = @as(Register, @fromBackingInt(@intCast(reg_id))).toBitSize(bit_size); |
| 383 | 383 | return switch (reg) { |
| 384 | 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 | 694 | |
| 695 | 695 | for (emit.table_relocs.items) |table_reloc| try atom.addReloc(gpa, .{ |
| 696 | 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 | 698 | .r_addend = @as(i64, table_offset) + table_reloc.target_offset, |
| 699 | 699 | }, zo); |
| 700 | 700 | for (emit.lower.mir.table) |entry| { |
| 701 | 701 | try atom.addReloc(gpa, .{ |
| 702 | 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 | 704 | .r_addend = emit.code_offset_mapping.items[entry], |
| 705 | 705 | }, zo); |
| 706 | 706 | table_offset += ptr_size; |
| ... | ... | @@ -812,7 +812,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI |
| 812 | 812 | .PC32; |
| 813 | 813 | try atom.addReloc(gpa, .{ |
| 814 | 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 | 816 | .r_addend = if (emit.pic) reloc.off - 4 else reloc.off, |
| 817 | 817 | }, zo); |
| 818 | 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 | 854 | const r_type: std.elf.R_X86_64 = .PLT32; |
| 855 | 855 | try atom.addReloc(gpa, .{ |
| 856 | 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 | 858 | .r_addend = reloc.off - 4, |
| 859 | 859 | }, zo); |
| 860 | 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 | 894 | const r_type: std.elf.R_X86_64 = if (emit.pic) .TLSLD else unreachable; |
| 895 | 895 | try atom.addReloc(gpa, .{ |
| 896 | 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 | 898 | .r_addend = reloc.off - 4, |
| 899 | 899 | }, zo); |
| 900 | 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 | 912 | const r_type: std.elf.R_X86_64 = if (emit.pic) .DTPOFF32 else .TPOFF32; |
| 913 | 913 | try atom.addReloc(gpa, .{ |
| 914 | 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 | 916 | .r_addend = reloc.off, |
| 917 | 917 | }, zo); |
| 918 | 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 | 1949 | assert(mem.info.base == .reg); |
| 1950 | 1950 | return encoder.Instruction.Memory.initMoffs( |
| 1951 | 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 | 664 | .general_purpose, .gphi => if (reg.isExtended()) |
| 665 | 665 | reg.enc() |
| 666 | 666 | 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 | 668 | .sse => 17 + @as(u6, reg.enc()), |
| 669 | 669 | .x87 => 33 + @as(u6, reg.enc()), |
| 670 | 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 | 844 | try self.w.writeByte(0b1100_0100); |
| 845 | 845 | |
| 846 | 846 | try self.w.writeByte( |
| 847 | @as(u8, ~@intFromBool(fields.r)) << 7 | | |
| 848 | @as(u8, ~@intFromBool(fields.x)) << 6 | | |
| 849 | @as(u8, ~@intFromBool(fields.b)) << 5 | | |
| 850 | @as(u8, @backingInt(fields.m)) << 0, | |
| 847 | (@as(u8, ~@intFromBool(fields.r)) << 7) | | |
| 848 | (@as(u8, ~@intFromBool(fields.x)) << 6) | | |
| 849 | (@as(u8, ~@intFromBool(fields.b)) << 5) | | |
| 850 | (@as(u8, @backingInt(fields.m)) << 0), | |
| 851 | 851 | ); |
| 852 | 852 | |
| 853 | 853 | try self.w.writeByte( |
| 854 | @as(u8, @intFromBool(fields.w)) << 7 | | |
| 855 | @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 | | |
| 856 | @as(u8, @intFromBool(fields.l)) << 2 | | |
| 857 | @as(u8, @backingInt(fields.p)) << 0, | |
| 854 | (@as(u8, @intFromBool(fields.w)) << 7) | | |
| 855 | (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) | | |
| 856 | (@as(u8, @intFromBool(fields.l)) << 2) | | |
| 857 | (@as(u8, @backingInt(fields.p)) << 0), | |
| 858 | 858 | ); |
| 859 | 859 | } else { |
| 860 | 860 | try self.w.writeByte(0b1100_0101); |
| 861 | 861 | try self.w.writeByte( |
| 862 | @as(u8, ~@intFromBool(fields.r)) << 7 | | |
| 863 | @as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3 | | |
| 864 | @as(u8, @intFromBool(fields.l)) << 2 | | |
| 865 | @as(u8, @backingInt(fields.p)) << 0, | |
| 862 | (@as(u8, ~@intFromBool(fields.r)) << 7) | | |
| 863 | (@as(u8, ~@as(u4, @intCast(fields.v.enc()))) << 3) | | |
| 864 | (@as(u8, @intFromBool(fields.l)) << 2) | | |
| 865 | (@as(u8, @backingInt(fields.p)) << 0), | |
| 866 | 866 | ); |
| 867 | 867 | } |
| 868 | 868 | } |
| ... | ... | @@ -910,7 +910,7 @@ fn Encoder(comptime opts: Options) type { |
| 910 | 910 | /// |
| 911 | 911 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 912 | 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 | } |
| 915 | 915 | |
| 916 | 916 | /// Construct a ModR/M byte using direct r/m addressing |
| ... | ... | @@ -996,7 +996,7 @@ fn Encoder(comptime opts: Options) type { |
| 996 | 996 | /// |
| 997 | 997 | /// Remember to add a REX prefix byte if index or base are extended! |
| 998 | 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 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /// Construct a SIB byte with scale * index + base, no frills. |
src/fmt.zig+2-1| ... | ... | @@ -323,7 +323,8 @@ fn fmtPathDir( |
| 323 | 323 | |
| 324 | 324 | if (mem.startsWith(u8, entry.name, ".")) continue; |
| 325 | 325 | |
| 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 | 328 | const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name }); |
| 328 | 329 | defer fmt.gpa.free(full_path); |
| 329 | 330 |
src/link/Dwarf.zig+3-3| ... | ... | @@ -697,7 +697,7 @@ const Unit = struct { |
| 697 | 697 | fw.writeByte(DW.LNS.extended_op) catch unreachable; |
| 698 | 698 | const extended_op_bytes = fw.end; |
| 699 | 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 | 701 | .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable, |
| 702 | 702 | .eq => { |
| 703 | 703 | // 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 | 893 | fw.writeUleb128(try dwarf.refAbbrevCode(.pad_n)) catch unreachable; |
| 894 | 894 | const abbrev_code_bytes = fw.end; |
| 895 | 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 | 897 | .lt => break fw.writeUleb128(len - abbrev_code_bytes - block_len_bytes) catch unreachable, |
| 898 | 898 | .eq => { |
| 899 | 899 | // 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 | 915 | fw.writeByte(DW.LNS.extended_op) catch unreachable; |
| 916 | 916 | const extended_op_bytes = fw.end; |
| 917 | 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 | 919 | .lt => break fw.writeUleb128(len - extended_op_bytes - op_len_bytes) catch unreachable, |
| 920 | 920 | .eq => { |
| 921 | 921 | // 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 | 1891 | var block_len_size: u5 = 1; |
| 1892 | 1892 | while (true) switch (std.math.order( |
| 1893 | 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 | 1896 | .lt => break try di_w.writeUleb128(size - abbrev_code_size - block_len_size), |
| 1897 | 1897 | .eq => { |
| ... | ... | @@ -2023,7 +2023,7 @@ pub fn genDebugLinePadding(dl_w: *std.Io.Writer, size: u64) std.Io.Writer.Error! |
| 2023 | 2023 | var op_len_size: u5 = 1; |
| 2024 | 2024 | while (true) switch (std.math.order( |
| 2025 | 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 | 2028 | .lt => break try dl_w.writeUleb128(size - extended_op_size - op_len_size), |
| 2029 | 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 | 7694 | { |
| 7695 | 7695 | break :load_object; |
| 7696 | 7696 | } |
| 7697 | const member = header.name() orelse member: { | |
| 7698 | const strtab_offset = header.nameOffset() catch |err| switch (err) { | |
| 7697 | const member = header.name() orelse (member: { | |
| 7698 | const strtab_offset = (header.nameOffset() catch |err| switch (err) { | |
| 7699 | 7699 | error.Overflow => break :member error.Overflow, |
| 7700 | 7700 | error.InvalidCharacter => break :load_object, |
| 7701 | } orelse break :load_object; | |
| 7701 | }) orelse break :load_object; | |
| 7702 | 7702 | const strtab_written = strtab.written(); |
| 7703 | 7703 | if (strtab_offset > strtab_written.len) break :member error.Overflow; |
| 7704 | 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 | 7708 | member; |
| 7709 | 7709 | } catch |err| switch (err) { |
| 7710 | 7710 | error.Overflow => return diags.failParse(path, "bad member name offset", .{}), |
| 7711 | }; | |
| 7711 | }); | |
| 7712 | 7712 | try elf.loadObject(path, member, fr, .{ .offset = offset, .size = size }); |
| 7713 | 7713 | } |
| 7714 | 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 | 228 | if (next.getAtomAddress(macho_file) >= range_start_max) { |
| 229 | 229 | break; |
| 230 | 230 | } 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 | 233 | i += 1; |
| 234 | 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 | 266 | try writeDylibLC(.{ |
| 267 | 267 | .cmd = .ID_DYLIB, |
| 268 | 268 | .name = install_name, |
| 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)), | |
| 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)), | |
| 271 | 271 | }, writer); |
| 272 | 272 | } |
| 273 | 273 |
src/link/Wasm/Flush.zig+1-1| ... | ... | @@ -1128,7 +1128,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 1128 | 1128 | // indirect function table elements |
| 1129 | 1129 | const table_index: u32 = @intCast( |
| 1130 | 1130 | 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 | 1133 | // passive with implicit 0-index table or set table index manually |
| 1134 | 1134 | const flags: u32 = if (table_index == 0) 0x0 else 0x02; |
src/link/riscv.zig+2-2| ... | ... | @@ -90,8 +90,8 @@ fn bitSlice( |
| 90 | 90 | value: anytype, |
| 91 | 91 | comptime high: comptime_int, |
| 92 | 92 | comptime low: comptime_int, |
| 93 | ) std.math.IntFittingRange(0, 1 << high - low) { | |
| 94 | return @truncate((value >> low) & (1 << (high - low + 1)) - 1); | |
| 93 | ) std.math.IntFittingRange(0, 1 << (high - low)) { | |
| 94 | return @truncate((value >> low) & ((1 << (high - low + 1)) - 1)); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | pub const Eflags = packed struct(u32) { |
src/main.zig+1-1| ... | ... | @@ -3524,7 +3524,7 @@ fn buildOutputType( |
| 3524 | 3524 | }; |
| 3525 | 3525 | |
| 3526 | 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 | 3528 | std.math.maxInt(Zcu.PerThread.IdBacking), |
| 3529 | 3529 | ); |
| 3530 | 3530 | try setThreadLimit(arena, thread_limit); |
test/Runner.zig+4-4| ... | ... | @@ -811,7 +811,7 @@ pub const DelimitedReader = struct { |
| 811 | 811 | const d: *DelimitedReader = @fieldParentPtr("interface", r); |
| 812 | 812 | const block = try d.unlimited.peekGreedy(d.delimiter.len); |
| 813 | 813 | 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 | 815 | if (d.remaining == .nothing) return error.EndOfStream; |
| 816 | 816 | const n = try d.unlimited.stream(w, limit.min(d.remaining)); |
| 817 | 817 | d.remaining = d.remaining.subtract(n).?; |
| ... | ... | @@ -821,7 +821,7 @@ pub const DelimitedReader = struct { |
| 821 | 821 | const d: *DelimitedReader = @fieldParentPtr("interface", r); |
| 822 | 822 | const block = try d.unlimited.peekGreedy(d.delimiter.len); |
| 823 | 823 | 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 | 825 | if (d.remaining == .nothing) return error.EndOfStream; |
| 826 | 826 | const n = try d.unlimited.discard(limit.min(d.remaining)); |
| 827 | 827 | d.remaining = d.remaining.subtract(n).?; |
| ... | ... | @@ -1397,9 +1397,9 @@ fn handleCommand( |
| 1397 | 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 | 1401 | error.ReadFailed => return error.ContentsReadFailed, |
| 1402 | } == 0); | |
| 1402 | }) == 0); | |
| 1403 | 1403 | switch (cmd) { |
| 1404 | 1404 | .todo, .skip => {}, |
| 1405 | 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 | 470 | fn doTheTest(x: u8, y: u8) !void { |
| 471 | 471 | const foo = @as(@This(), .{ .x = x, .v = {}, .y = y }); |
| 472 | 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 | 476 | try S.doTheTest(123, 45); |
test/behavior/error.zig+1-1| ... | ... | @@ -209,7 +209,7 @@ fn testErrorSetType() !void { |
| 209 | 209 | |
| 210 | 210 | const a: MyErrSet!i32 = 5678; |
| 211 | 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); | |
| 213 | 213 | |
| 214 | 214 | if (a) |value| try expect(value == 5678) else |err| switch (err) { |
| 215 | 215 | error.OutOfMemory => unreachable, |
test/behavior/math.zig+3-3| ... | ... | @@ -49,10 +49,10 @@ fn testThreeExprInARow(f: bool, t: bool) !void { |
| 49 | 49 | try assertFalse(1 | 2 | 4 != 7); |
| 50 | 50 | try assertFalse(3 ^ 6 ^ 8 != 13); |
| 51 | 51 | try assertFalse(7 & 14 & 28 != 4); |
| 52 | try assertFalse(9 << 1 << 2 != 9 << 3); | |
| 53 | try assertFalse(90 >> 1 >> 2 != 90 >> 3); | |
| 52 | try assertFalse((9 << 1) << 2 != 9 << 3); | |
| 53 | try assertFalse((90 >> 1) >> 2 != 90 >> 3); | |
| 54 | 54 | try assertFalse(100 - 1 + 1000 != 1099); |
| 55 | try assertFalse(5 * 4 / 2 % 3 != 1); | |
| 55 | try assertFalse((5 * 4 / 2) % 3 != 1); | |
| 56 | 56 | try assertFalse(@as(i32, @as(i32, 5)) != 5); |
| 57 | 57 | try assertFalse(!!false); |
| 58 | 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 | 186 | res1.* += 1; |
| 187 | 187 | res2.* += 1; |
| 188 | 188 | |
| 189 | try expect(f0 catch unreachable == 1); | |
| 190 | try expect(f1 catch unreachable == 2); | |
| 191 | try expect(f2 catch unreachable == 3); | |
| 189 | try expect((f0 catch unreachable) == 1); | |
| 190 | try expect((f1 catch unreachable) == 2); | |
| 191 | try expect((f2 catch unreachable) == 3); | |
| 192 | 192 | |
| 193 | 193 | try expect(res0.* == 1); |
| 194 | 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 | 5503 | const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); |
| 5504 | 5504 | const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); |
| 5505 | 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 | } |
| 5508 | 5508 | test shrExact { |
| 5509 | 5509 | const test_shr_exact = binary(shrExact, .{}); |
| ... | ... | @@ -5527,7 +5527,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type { |
| 5527 | 5527 | const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); |
| 5528 | 5528 | const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); |
| 5529 | 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 | } |
| 5532 | 5532 | test shlExactUnsafe { |
| 5533 | 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 | 14502 | // TODO: if (bits == 0) rhs else rhs >> bits, |
| 14503 | 14503 | .shift => |bits| if (bits == 0) rhs else switch (@typeInfo(Type)) { |
| 14504 | 14504 | .int => if (ct_rhs < 0) |
| 14505 | rhs | imin(Type) >> bits | |
| 14505 | rhs | (imin(Type) >> bits) | |
| 14506 | 14506 | else |
| 14507 | rhs & imax(Type) >> bits, | |
| 14508 | .vector => rhs | @select( | |
| 14507 | rhs & (imax(Type) >> bits), | |
| 14508 | .vector => (rhs | @select( | |
| 14509 | 14509 | Scalar(Type), |
| 14510 | 14510 | ct_rhs < @as(Type, @splat(0)), |
| 14511 | 14511 | @as(Type, @splat(imin(Scalar(Type)) >> bits)), |
| 14512 | 14512 | @as(Type, @splat(0)), |
| 14513 | ) & ~@select( | |
| 14513 | )) & ~@select( | |
| 14514 | 14514 | Scalar(Type), |
| 14515 | 14515 | ct_rhs >= @as(Type, @splat(0)), |
| 14516 | 14516 | @as(Type, @splat(imin(Scalar(Type)) >> bits)), |
tools/loongarch/OpcodeDesc.zig+2-2| ... | ... | @@ -95,10 +95,10 @@ pub const Format = struct { |
| 95 | 95 | const index: Slot.Index = try .parse(&reader); |
| 96 | 96 | const length = try takeInteger(u5, &reader); |
| 97 | 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 | 99 | error.EndOfStream => ' ', |
| 100 | 100 | else => return err, |
| 101 | }) { | |
| 101 | })) { | |
| 102 | 102 | reader.toss(1); |
| 103 | 103 | break :post_proc try Slot.PostProcess.parse(&reader); |
| 104 | 104 | } else break :post_proc Slot.PostProcess.none; |