stage2: move named int types to InternPool

This commit is contained in:
Andrew Kelley
2023-05-03 16:33:16 -07:00
parent 4cd8a40b3b
commit bcd4bb8afb
10 changed files with 121 additions and 345 deletions

View File

@@ -1359,18 +1359,18 @@ pub const CType = extern union {
self.* = undefined;
if (!ty.isFnOrHasRuntimeBitsIgnoreComptime(mod))
self.init(.void)
else if (ty.isAbiInt(mod)) switch (ty.tag()) {
.usize => self.init(.uintptr_t),
.isize => self.init(.intptr_t),
.c_char => self.init(.char),
.c_short => self.init(.short),
.c_ushort => self.init(.@"unsigned short"),
.c_int => self.init(.int),
.c_uint => self.init(.@"unsigned int"),
.c_long => self.init(.long),
.c_ulong => self.init(.@"unsigned long"),
.c_longlong => self.init(.@"long long"),
.c_ulonglong => self.init(.@"unsigned long long"),
else if (ty.isAbiInt(mod)) switch (ty.ip_index) {
.usize_type => self.init(.uintptr_t),
.isize_type => self.init(.intptr_t),
.c_char_type => self.init(.char),
.c_short_type => self.init(.short),
.c_ushort_type => self.init(.@"unsigned short"),
.c_int_type => self.init(.int),
.c_uint_type => self.init(.@"unsigned int"),
.c_long_type => self.init(.long),
.c_ulong_type => self.init(.@"unsigned long"),
.c_longlong_type => self.init(.@"long long"),
.c_ulonglong_type => self.init(.@"unsigned long long"),
else => switch (tagFromIntInfo(ty.intInfo(mod))) {
.void => unreachable,
else => |t| self.init(t),

View File

@@ -2499,7 +2499,7 @@ pub const DeclGen = struct {
const elem_ty = ptr_ty.elemType2(mod); // use elemType() so that we get T for *[N]T.
const elem_ty_ref = try self.resolveType(elem_ty, .direct);
const elem_ptr_ty_ref = try self.spv.ptrType(elem_ty_ref, spvStorageClass(ptr_ty.ptrAddressSpace()));
if (ptr_ty.isSinglePointer()) {
if (ptr_ty.isSinglePointer(mod)) {
// Pointer-to-array. In this case, the resulting pointer is not of the same type
// as the ptr_ty (we want a *T, not a *[N]T), and hence we need to use accessChain.
return try self.accessChain(elem_ptr_ty_ref, ptr_id, &.{index_id});