diff options
| author | Jacob Young <amazingjacob@gmail.com> | 2025-01-10 15:36:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 15:36:21 -0500 |
| commit | 6cfc9c0e02cb1ccf9edfbdc64fcca285fea022fb (patch) | |
| tree | 24805abd8c8d59ce75c8de4c057482a7e1dc5399 /src/codegen/c.zig | |
| parent | b36ea592b86ef20473697ded24a27bb644941de8 (diff) | |
| parent | 02692ad78cbdc1086abc4e37739e512c9203f486 (diff) | |
| download | zig-6cfc9c0e02cb1ccf9edfbdc64fcca285fea022fb.tar.gz zig-6cfc9c0e02cb1ccf9edfbdc64fcca285fea022fb.zip | |
Merge pull request #22459 from jacobly0/fix-miscomps
cbe/x86_64: fix more miscomps
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 8873c1d5df..5ce1ecc21c 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -7419,7 +7419,9 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { .@"packed" => { try f.writeCValue(writer, local, .Other); try writer.writeAll(" = "); - const int_info = inst_ty.intInfo(zcu); + + const backing_int_ty: Type = .fromInterned(loaded_struct.backingIntTypeUnordered(ip)); + const int_info = backing_int_ty.intInfo(zcu); const bit_offset_ty = try pt.intType(.unsigned, Type.smallestUnsignedBits(int_info.bits - 1)); @@ -7450,6 +7452,12 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { try f.object.dg.renderTypeForBuiltinFnName(writer, inst_ty); try writer.writeByte('('); + if (field_ty.isAbiInt(zcu)) { + try writer.writeAll("zig_and_"); + try f.object.dg.renderTypeForBuiltinFnName(writer, inst_ty); + try writer.writeByte('('); + } + if (inst_ty.isAbiInt(zcu) and (field_ty.isAbiInt(zcu) or field_ty.isPtrAtRuntime(zcu))) { try f.renderIntCast(writer, inst_ty, element, .{}, field_ty, .FunctionArgument); } else { @@ -7467,6 +7475,17 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { try f.writeCValue(writer, element, .Other); } + if (field_ty.isAbiInt(zcu)) { + try writer.writeAll(", "); + const field_int_info = field_ty.intInfo(zcu); + const field_mask = if (int_info.signedness == .signed and int_info.bits == field_int_info.bits) + try pt.intValue(backing_int_ty, -1) + else + try (try pt.intType(.unsigned, field_int_info.bits)).maxIntScalar(pt, backing_int_ty); + try f.object.dg.renderValue(writer, field_mask, .FunctionArgument); + try writer.writeByte(')'); + } + try writer.print(", {}", .{ try f.fmtIntLiteral(try pt.intValue(bit_offset_ty, bit_offset)), }); |
