authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2022-12-30 02:26:06-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-02 13:56:32-07:00
log9c951cc8745256cbf94839b401abbb6afd35cae2
treee5756de84b707fa773d00bbbfa1f1f55495dc1f1
parentcac652f81be23cce8857298a8402036edf061e9d

fmt fixups


3 files changed, 10 insertions(+), 23 deletions(-)

src/codegen/c.zig+9-20
......@@ -1110,7 +1110,6 @@ pub const DeclGen = struct {
11101110 // MSVC throws C2078 if an array of size 65536 or greater is initialized with a string literal
11111111 const max_string_initializer_len = 65535;
11121112
1113
11141113 const ai = ty.arrayInfo();
11151114 if (ai.elem_type.eql(Type.u8, dg.module)) {
11161115 if (ai.len <= max_string_initializer_len) {
......@@ -1134,7 +1133,7 @@ pub const DeclGen = struct {
11341133 if (index != 0) try writer.writeByte(',');
11351134 const elem_val = try val.elemValue(dg.module, arena_allocator, index);
11361135 const elem_val_u8 = if (elem_val.isUndef()) undefPattern(u8) else @intCast(u8, elem_val.toUnsignedInt(target));
1137 try writer.print("'\\x{x}'", .{ elem_val_u8 });
1136 try writer.print("'\\x{x}'", .{elem_val_u8});
11381137 }
11391138 if (ai.sentinel) |s| {
11401139 if (index != 0) try writer.writeByte(',');
......@@ -1350,7 +1349,7 @@ pub const DeclGen = struct {
13501349 try dg.renderIntCast(writer, ty, cast_context, field_ty, .FunctionArgument);
13511350 }
13521351
1353 if (needs_closing_paren) try writer.writeByte(')') ;
1352 if (needs_closing_paren) try writer.writeByte(')');
13541353 if (eff_index != eff_num_fields - 1) try writer.writeAll(", ");
13551354
13561355 bit_offset_val_pl.data += field_ty.bitSize(target);
......@@ -2254,7 +2253,7 @@ pub const DeclGen = struct {
22542253 if (dest_bits <= 64 and src_bits <= 64) {
22552254 const needs_cast = src_int_info == null or
22562255 (toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
2257 dest_int_info.signedness != src_int_info.?.signedness);
2256 dest_int_info.signedness != src_int_info.?.signedness);
22582257
22592258 if (needs_cast) {
22602259 try w.writeByte('(');
......@@ -2567,7 +2566,7 @@ pub const DeclGen = struct {
25672566 } else if (ty.isRuntimeFloat()) {
25682567 try ty.print(writer, dg.module);
25692568 } else if (ty.isPtrAtRuntime()) {
2570 try writer.print("p{d}", .{ ty.bitSize(target) });
2569 try writer.print("p{d}", .{ty.bitSize(target)});
25712570 } else if (ty.zigTypeTag() == .Bool) {
25722571 try writer.print("u8", .{});
25732572 } else return dg.fail("TODO: CBE: implement renderTypeForBuiltinFnName for type {}", .{
......@@ -2633,12 +2632,7 @@ pub const DeclGen = struct {
26332632 const c_bits = toCIntBits(int_info.bits);
26342633 if (c_bits == null or c_bits.? > 128)
26352634 return dg.fail("TODO implement integer constants larger than 128 bits", .{});
2636 return std.fmt.Formatter(formatIntLiteral){ .data = .{
2637 .ty = ty,
2638 .val = val,
2639 .mod = dg.module,
2640 .location = location
2641 } };
2635 return std.fmt.Formatter(formatIntLiteral){ .data = .{ .ty = ty, .val = val, .mod = dg.module, .location = location } };
26422636 }
26432637};
26442638
......@@ -3668,9 +3662,9 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue {
36683662 }
36693663 try f.writeCValue(writer, operand, .FunctionArgument);
36703664 if (c_bits == 128) try writer.writeByte(')');
3671 try writer.print(", {})", .{ try f.fmtIntLiteral(Type.u8, shift_val) });
3665 try writer.print(", {})", .{try f.fmtIntLiteral(Type.u8, shift_val)});
36723666 if (c_bits == 128) try writer.writeByte(')');
3673 try writer.print(", {})", .{ try f.fmtIntLiteral(Type.u8, shift_val) });
3667 try writer.print(", {})", .{try f.fmtIntLiteral(Type.u8, shift_val)});
36743668 },
36753669 }
36763670
......@@ -7227,12 +7221,7 @@ fn undefPattern(comptime IntType: type) IntType {
72277221 return @bitCast(IntType, @as(UnsignedType, (1 << (int_info.bits | 1)) / 3));
72287222}
72297223
7230const FormatIntLiteralContext = struct {
7231 ty: Type,
7232 val: Value,
7233 mod: *Module,
7234 location: ?ValueRenderLocation = null
7235};
7224const FormatIntLiteralContext = struct { ty: Type, val: Value, mod: *Module, location: ?ValueRenderLocation = null };
72367225fn formatIntLiteral(
72377226 data: FormatIntLiteralContext,
72387227 comptime fmt: []const u8,
......@@ -7324,7 +7313,7 @@ fn formatIntLiteral(
73247313 } else {
73257314 try writer.print("zig_as_{c}{d}(", .{ signAbbrev(int_info.signedness), c_bits });
73267315 }
7327 }
7316 },
73287317 }
73297318
73307319 const limbs_count_64 = @divExact(64, @bitSizeOf(BigIntLimb));
test/behavior/atomics.zig+1-1
......@@ -251,7 +251,7 @@ test "atomicrmw with ints" {
251251 }
252252
253253 // TODO: Use the max atomic bit size for the target, maybe builtin?
254 const bit_values = [_]usize{ 8 } ++ if (builtin.cpu.arch == .x86_64) [_]usize{ 16, 32, 64 } else [_]usize{ };
254 const bit_values = [_]usize{8} ++ if (builtin.cpu.arch == .x86_64) [_]usize{ 16, 32, 64 } else [_]usize{};
255255 inline for (bit_values) |bits| {
256256 try testAtomicRmwInt(.unsigned, bits);
257257 comptime try testAtomicRmwInt(.unsigned, bits);
test/behavior/math.zig-2
......@@ -377,7 +377,6 @@ fn testBinaryNot(x: u16) !void {
377377 try expect(~x == 0b0101010101010101);
378378}
379379
380
381380test "binary not 128-bit" {
382381 try expect(comptime x: {
383382 break :x ~@as(u128, 0x55555555_55555555_55555555_55555555) == 0xaaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa;
......@@ -667,7 +666,6 @@ test "128-bit multiplication" {
667666 var c = a * b;
668667 try expect(c == 0x63ffffffffffffff9c);
669668 }
670
671669}
672670
673671test "@addWithOverflow" {