diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-04-06 10:14:34 +0200 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-04-11 05:22:00 -0400 |
| commit | ed9aa8f259d452cb344064ee412fc5af18877d55 (patch) | |
| tree | bc25fc044efda559430e3ea7d715936b179b37cf /src/codegen | |
| parent | 0132be7bf3fd02cfb8c31ffdeaddae918a76b295 (diff) | |
| download | zig-ed9aa8f259d452cb344064ee412fc5af18877d55.tar.gz zig-ed9aa8f259d452cb344064ee412fc5af18877d55.zip | |
compiler: Move int size/alignment functions to std.Target and std.zig.target.
This allows using them in e.g. compiler-rt.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c/Type.zig | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/codegen/c/Type.zig b/src/codegen/c/Type.zig index db7455ebb0..0b3066f9bd 100644 --- a/src/codegen/c/Type.zig +++ b/src/codegen/c/Type.zig @@ -1319,10 +1319,9 @@ pub const Pool = struct { }, else => { const target = &mod.resolved_target.result; - const abi_align = Type.intAbiAlignment(int_info.bits, target.*); - const abi_align_bytes = abi_align.toByteUnits().?; + const abi_align_bytes = std.zig.target.intAlignment(target.*, int_info.bits); const array_ctype = try pool.getArray(allocator, .{ - .len = @divExact(Type.intAbiSize(int_info.bits, target.*), abi_align_bytes), + .len = @divExact(std.zig.target.intByteSize(target.*, int_info.bits), abi_align_bytes), .elem_ctype = try pool.fromIntInfo(allocator, .{ .signedness = .unsigned, .bits = @intCast(abi_align_bytes * 8), @@ -1333,7 +1332,7 @@ pub const Pool = struct { .{ .name = .{ .index = .array }, .ctype = array_ctype, - .alignas = AlignAs.fromAbiAlignment(abi_align), + .alignas = AlignAs.fromAbiAlignment(.fromByteUnits(abi_align_bytes)), }, }; return pool.fromFields(allocator, .@"struct", &fields, kind); @@ -1437,7 +1436,7 @@ pub const Pool = struct { .name = .{ .index = .len }, .ctype = .usize, .alignas = AlignAs.fromAbiAlignment( - Type.intAbiAlignment(target.ptrBitWidth(), target.*), + .fromByteUnits(std.zig.target.intAlignment(target.*, target.ptrBitWidth())), ), }, }; @@ -1937,7 +1936,7 @@ pub const Pool = struct { .name = .{ .index = .len }, .ctype = .usize, .alignas = AlignAs.fromAbiAlignment( - Type.intAbiAlignment(target.ptrBitWidth(), target.*), + .fromByteUnits(std.zig.target.intAlignment(target.*, target.ptrBitWidth())), ), }, }; @@ -2057,7 +2056,7 @@ pub const Pool = struct { .name = .{ .index = .@"error" }, .ctype = error_set_ctype, .alignas = AlignAs.fromAbiAlignment( - Type.intAbiAlignment(error_set_bits, target.*), + .fromByteUnits(std.zig.target.intAlignment(target.*, error_set_bits)), ), }, .{ |
