aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c/Type.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2024-08-26 23:53:01 +0100
committerGitHub <noreply@github.com>2024-08-26 23:53:01 +0100
commit492cc2ef8d1d21d96e25541c22ab885a31c62770 (patch)
tree68a56acd898e308845054123f0cf6816761d3fa1 /src/codegen/c/Type.zig
parent849c31a6cc3d1e554f97c2ccf7aaa886070cfadd (diff)
parent61e8a6c0082778e9d7a120fb5b9c30ebf85d586b (diff)
downloadzig-492cc2ef8d1d21d96e25541c22ab885a31c62770.tar.gz
zig-492cc2ef8d1d21d96e25541c22ab885a31c62770.zip
Merge pull request #21208 from Rexicon226/pt-begone
Cleanup type resolution and finish `zcu` rename
Diffstat (limited to 'src/codegen/c/Type.zig')
-rw-r--r--src/codegen/c/Type.zig25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/codegen/c/Type.zig b/src/codegen/c/Type.zig
index 63b7e4fd52..018b0586d0 100644
--- a/src/codegen/c/Type.zig
+++ b/src/codegen/c/Type.zig
@@ -1344,6 +1344,7 @@ pub const Pool = struct {
kind: Kind,
) !CType {
const ip = &pt.zcu.intern_pool;
+ const zcu = pt.zcu;
switch (ty.toIntern()) {
.u0_type,
.i0_type,
@@ -1476,7 +1477,7 @@ pub const Pool = struct {
),
.alignas = AlignAs.fromAlignment(.{
.@"align" = ptr_info.flags.alignment,
- .abi = Type.fromInterned(ptr_info.child).abiAlignment(pt),
+ .abi = Type.fromInterned(ptr_info.child).abiAlignment(zcu),
}),
};
break :elem_ctype if (elem.alignas.abiOrder().compare(.gte))
@@ -1552,7 +1553,7 @@ pub const Pool = struct {
.{
.name = .{ .index = .array },
.ctype = array_ctype,
- .alignas = AlignAs.fromAbiAlignment(elem_type.abiAlignment(pt)),
+ .alignas = AlignAs.fromAbiAlignment(elem_type.abiAlignment(zcu)),
},
};
return pool.fromFields(allocator, .@"struct", &fields, kind);
@@ -1578,7 +1579,7 @@ pub const Pool = struct {
.{
.name = .{ .index = .array },
.ctype = vector_ctype,
- .alignas = AlignAs.fromAbiAlignment(elem_type.abiAlignment(pt)),
+ .alignas = AlignAs.fromAbiAlignment(elem_type.abiAlignment(zcu)),
},
};
return pool.fromFields(allocator, .@"struct", &fields, kind);
@@ -1613,7 +1614,7 @@ pub const Pool = struct {
.name = .{ .index = .payload },
.ctype = payload_ctype,
.alignas = AlignAs.fromAbiAlignment(
- Type.fromInterned(payload_type).abiAlignment(pt),
+ Type.fromInterned(payload_type).abiAlignment(zcu),
),
},
};
@@ -1649,7 +1650,7 @@ pub const Pool = struct {
.{
.name = .{ .index = .payload },
.ctype = payload_ctype,
- .alignas = AlignAs.fromAbiAlignment(payload_type.abiAlignment(pt)),
+ .alignas = AlignAs.fromAbiAlignment(payload_type.abiAlignment(zcu)),
},
};
return pool.fromFields(allocator, .@"struct", &fields, kind);
@@ -1663,7 +1664,7 @@ pub const Pool = struct {
.tag = .@"struct",
.name = .{ .index = ip_index },
});
- if (kind.isForward()) return if (ty.hasRuntimeBitsIgnoreComptime(pt))
+ if (kind.isForward()) return if (ty.hasRuntimeBitsIgnoreComptime(zcu))
fwd_decl
else
CType.void;
@@ -1696,7 +1697,7 @@ pub const Pool = struct {
String.fromUnnamed(@intCast(field_index));
const field_alignas = AlignAs.fromAlignment(.{
.@"align" = loaded_struct.fieldAlign(ip, field_index),
- .abi = field_type.abiAlignment(pt),
+ .abi = field_type.abiAlignment(zcu),
});
pool.addHashedExtraAssumeCapacityTo(scratch, &hasher, Field, .{
.name = field_name.index,
@@ -1758,7 +1759,7 @@ pub const Pool = struct {
.name = field_name.index,
.ctype = field_ctype.index,
.flags = .{ .alignas = AlignAs.fromAbiAlignment(
- field_type.abiAlignment(pt),
+ field_type.abiAlignment(zcu),
) },
});
}
@@ -1802,7 +1803,7 @@ pub const Pool = struct {
.tag = if (has_tag) .@"struct" else .@"union",
.name = .{ .index = ip_index },
});
- if (kind.isForward()) return if (ty.hasRuntimeBitsIgnoreComptime(pt))
+ if (kind.isForward()) return if (ty.hasRuntimeBitsIgnoreComptime(zcu))
fwd_decl
else
CType.void;
@@ -1836,7 +1837,7 @@ pub const Pool = struct {
);
const field_alignas = AlignAs.fromAlignment(.{
.@"align" = loaded_union.fieldAlign(ip, field_index),
- .abi = field_type.abiAlignment(pt),
+ .abi = field_type.abiAlignment(zcu),
});
pool.addHashedExtraAssumeCapacityTo(scratch, &hasher, Field, .{
.name = field_name.index,
@@ -1881,7 +1882,7 @@ pub const Pool = struct {
struct_fields[struct_fields_len] = .{
.name = .{ .index = .tag },
.ctype = tag_ctype,
- .alignas = AlignAs.fromAbiAlignment(tag_type.abiAlignment(pt)),
+ .alignas = AlignAs.fromAbiAlignment(tag_type.abiAlignment(zcu)),
};
struct_fields_len += 1;
}
@@ -1929,7 +1930,7 @@ pub const Pool = struct {
},
.@"packed" => return pool.fromIntInfo(allocator, .{
.signedness = .unsigned,
- .bits = @intCast(ty.bitSize(pt)),
+ .bits = @intCast(ty.bitSize(zcu)),
}, mod, kind),
}
},