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

@ -6448,7 +6448,7 @@ fn checkCallArgumentCount(
.Optional => {
var buf: Type.Payload.ElemType = undefined;
const opt_child = callee_ty.optionalChild(&buf);
if (opt_child.zigTypeTag(mod) == .Fn or (opt_child.isSinglePointer() and
if (opt_child.zigTypeTag(mod) == .Fn or (opt_child.isSinglePointer(mod) and
opt_child.childType().zigTypeTag(mod) == .Fn))
{
const msg = msg: {
@ -31421,6 +31421,8 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.enum_literal,
.type_info,
=> true,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -31443,17 +31445,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -31798,6 +31789,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
.bool_false => unreachable,
.empty_struct => unreachable,
.generic_poison => unreachable,
.var_args_param_type => unreachable,
.type_info_type => return sema.getBuiltinType("Type"),
.extern_options_type => return sema.getBuiltinType("ExternOptions"),
@ -32977,17 +32969,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.bool,
.type,
.anyerror,
@ -33213,17 +33194,6 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
.i64 => return .i64_type,
.u128 => return .u128_type,
.i128 => return .i128_type,
.usize => return .usize_type,
.isize => return .isize_type,
.c_char => return .c_char_type,
.c_short => return .c_short_type,
.c_ushort => return .c_ushort_type,
.c_int => return .c_int_type,
.c_uint => return .c_uint_type,
.c_long => return .c_long_type,
.c_ulong => return .c_ulong_type,
.c_longlong => return .c_longlong_type,
.c_ulonglong => return .c_ulonglong_type,
.anyopaque => return .anyopaque_type,
.bool => return .bool_type,
.void => return .void_type,
@ -33664,6 +33634,8 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.enum_literal,
.type_info,
=> true,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -33686,17 +33658,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,

View file

@ -4326,7 +4326,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const atom = elf_file.getAtom(atom_index);
_ = try atom.getOrCreateOffsetTableEntry(elf_file);
const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
try self.genSetReg(Type.initTag(.usize), .x30, .{ .memory = got_addr });
try self.genSetReg(Type.usize, .x30, .{ .memory = got_addr });
} else if (self.bin_file.cast(link.File.MachO)) |macho_file| {
const atom = try macho_file.getOrCreateAtomForDecl(func.owner_decl);
const sym_index = macho_file.getAtom(atom).getSymbolIndex().?;
@ -4353,7 +4353,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const got_addr = p9.bases.data;
const got_index = decl_block.got_index.?;
const fn_got_addr = got_addr + got_index * ptr_bytes;
try self.genSetReg(Type.initTag(.usize), .x30, .{ .memory = fn_got_addr });
try self.genSetReg(Type.usize, .x30, .{ .memory = fn_got_addr });
} else unreachable;
_ = try self.addInst(.{
@ -5968,7 +5968,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst);
try self.genSetStack(ptr_ty, stack_offset, ptr);
try self.genSetStack(Type.initTag(.usize), stack_offset - ptr_bytes, .{ .immediate = array_len });
try self.genSetStack(Type.usize, stack_offset - ptr_bytes, .{ .immediate = array_len });
break :result MCValue{ .stack_offset = stack_offset };
};
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });

View file

@ -4308,7 +4308,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const atom = elf_file.getAtom(atom_index);
_ = try atom.getOrCreateOffsetTableEntry(elf_file);
const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
try self.genSetReg(Type.initTag(.usize), .lr, .{ .memory = got_addr });
try self.genSetReg(Type.usize, .lr, .{ .memory = got_addr });
} else if (self.bin_file.cast(link.File.MachO)) |_| {
unreachable; // unsupported architecture for MachO
} else {
@ -4326,7 +4326,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
assert(ty.zigTypeTag(mod) == .Pointer);
const mcv = try self.resolveInst(callee);
try self.genSetReg(Type.initTag(.usize), .lr, mcv);
try self.genSetReg(Type.usize, .lr, mcv);
}
// TODO: add Instruction.supportedOn
@ -5694,7 +5694,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
if (extra_offset) {
const offset = if (off <= math.maxInt(u8)) blk: {
break :blk Instruction.ExtraLoadStoreOffset.imm(@intCast(u8, off));
} else Instruction.ExtraLoadStoreOffset.reg(try self.copyToTmpRegister(Type.initTag(.usize), MCValue{ .immediate = off }));
} else Instruction.ExtraLoadStoreOffset.reg(try self.copyToTmpRegister(Type.usize, MCValue{ .immediate = off }));
_ = try self.addInst(.{
.tag = tag,
@ -5710,7 +5710,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
} else {
const offset = if (off <= math.maxInt(u12)) blk: {
break :blk Instruction.Offset.imm(@intCast(u12, off));
} else Instruction.Offset.reg(try self.copyToTmpRegister(Type.initTag(.usize), MCValue{ .immediate = off }), .none);
} else Instruction.Offset.reg(try self.copyToTmpRegister(Type.usize, MCValue{ .immediate = off }), .none);
_ = try self.addInst(.{
.tag = tag,
@ -5916,7 +5916,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
const stack_offset = try self.allocMem(8, 8, inst);
try self.genSetStack(ptr_ty, stack_offset, ptr);
try self.genSetStack(Type.initTag(.usize), stack_offset - 4, .{ .immediate = array_len });
try self.genSetStack(Type.usize, stack_offset - 4, .{ .immediate = array_len });
break :result MCValue{ .stack_offset = stack_offset };
};
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });

View file

@ -1749,7 +1749,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
const atom = elf_file.getAtom(atom_index);
_ = try atom.getOrCreateOffsetTableEntry(elf_file);
const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
try self.genSetReg(Type.initTag(.usize), .ra, .{ .memory = got_addr });
try self.genSetReg(Type.usize, .ra, .{ .memory = got_addr });
_ = try self.addInst(.{
.tag = .jalr,
.data = .{ .i_type = .{

View file

@ -883,7 +883,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2);
try self.genSetStack(ptr_ty, stack_offset, ptr);
try self.genSetStack(Type.initTag(.usize), stack_offset - ptr_bytes, .{ .immediate = array_len });
try self.genSetStack(Type.usize, stack_offset - ptr_bytes, .{ .immediate = array_len });
break :result MCValue{ .stack_offset = stack_offset };
};
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
@ -1352,7 +1352,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
break :blk @intCast(u32, atom.getOffsetTableAddress(elf_file));
} else unreachable;
try self.genSetReg(Type.initTag(.usize), .o7, .{ .memory = got_addr });
try self.genSetReg(Type.usize, .o7, .{ .memory = got_addr });
_ = try self.addInst(.{
.tag = .jmpl,

View file

@ -371,7 +371,7 @@ pub fn generateSymbol(
// generate length
switch (try generateSymbol(bin_file, src_loc, .{
.ty = Type.initTag(.usize),
.ty = Type.usize,
.val = slice.len,
}, code, debug_output, reloc_info)) {
.ok => {},

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});

View file

@ -121,17 +121,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
=> return .Int,
.error_set,
@ -621,19 +610,6 @@ pub const Type = struct {
switch (a.tag()) {
.generic_poison => unreachable,
// Detect that e.g. u64 != usize, even if the bits match on a particular target.
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.bool,
.void,
.type,
@ -1013,22 +989,6 @@ pub const Type = struct {
switch (ty.tag()) {
.generic_poison => unreachable,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
=> |ty_tag| {
std.hash.autoHash(hasher, std.builtin.TypeId.Int);
std.hash.autoHash(hasher, ty_tag);
},
.bool => std.hash.autoHash(hasher, std.builtin.TypeId.Bool),
.void => std.hash.autoHash(hasher, std.builtin.TypeId.Void),
.type => std.hash.autoHash(hasher, std.builtin.TypeId.Type),
@ -1345,17 +1305,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -1631,17 +1580,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -2020,17 +1958,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -2322,17 +2249,6 @@ pub const Type = struct {
.i32 => return Value.initTag(.i32_type),
.u64 => return Value.initTag(.u64_type),
.i64 => return Value.initTag(.i64_type),
.usize => return Value.initTag(.usize_type),
.isize => return Value.initTag(.isize_type),
.c_char => return Value.initTag(.c_char_type),
.c_short => return Value.initTag(.c_short_type),
.c_ushort => return Value.initTag(.c_ushort_type),
.c_int => return Value.initTag(.c_int_type),
.c_uint => return Value.initTag(.c_uint_type),
.c_long => return Value.initTag(.c_long_type),
.c_ulong => return Value.initTag(.c_ulong_type),
.c_longlong => return Value.initTag(.c_longlong_type),
.c_ulonglong => return Value.initTag(.c_ulonglong_type),
.anyopaque => return Value.initTag(.anyopaque_type),
.bool => return Value.initTag(.bool_type),
.void => return Value.initTag(.void_type),
@ -2462,17 +2378,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.bool,
.anyerror,
.const_slice_u8,
@ -2713,6 +2618,8 @@ pub const Type = struct {
.type_info,
.generic_poison,
=> false,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -2734,17 +2641,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.bool,
.void,
.manyptr_u8,
@ -3040,7 +2936,7 @@ pub const Type = struct {
.export_options,
.extern_options,
.@"anyframe",
=> return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
=> return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
.c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) },
.c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },
@ -3089,6 +2985,7 @@ pub const Type = struct {
.noreturn => unreachable,
.generic_poison => unreachable,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -3130,8 +3027,6 @@ pub const Type = struct {
return AbiAlignmentAdvanced{ .scalar = target_util.defaultFunctionAlignment(target) };
},
.isize,
.usize,
.single_const_pointer_to_comptime_int,
.const_slice_u8,
.const_slice_u8_sentinel_0,
@ -3153,16 +3048,6 @@ pub const Type = struct {
.anyframe_T,
=> return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
.c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) },
.c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },
.c_ushort => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ushort) },
.c_int => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.int) },
.c_uint => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.uint) },
.c_long => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.long) },
.c_ulong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ulong) },
.c_longlong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.longlong) },
.c_ulonglong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ulonglong) },
// TODO revisit this when we have the concept of the error tag type
.anyerror_void_error_union,
.anyerror,
@ -3491,7 +3376,7 @@ pub const Type = struct {
.usize,
.isize,
.@"anyframe",
=> return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
=> return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
.c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) },
.c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },
@ -3524,6 +3409,7 @@ pub const Type = struct {
.type_info => unreachable,
.noreturn => unreachable,
.generic_poison => unreachable,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -3666,8 +3552,6 @@ pub const Type = struct {
return AbiSizeAdvanced{ .scalar = result };
},
.isize,
.usize,
.@"anyframe",
.anyframe_T,
.optional_single_const_pointer,
@ -3694,16 +3578,6 @@ pub const Type = struct {
else => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
},
.c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) },
.c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },
.c_ushort => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ushort) },
.c_int => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.int) },
.c_uint => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.uint) },
.c_long => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.long) },
.c_ulong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ulong) },
.c_longlong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.longlong) },
.c_ulonglong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ulonglong) },
// TODO revisit this when we have the concept of the error tag type
.anyerror_void_error_union,
.anyerror,
@ -3856,7 +3730,7 @@ pub const Type = struct {
.usize,
.isize,
.@"anyframe",
=> return target.cpu.arch.ptrBitWidth(),
=> return target.ptrBitWidth(),
.c_char => return target.c_type_bit_size(.char),
.c_short => return target.c_type_bit_size(.short),
@ -3896,6 +3770,7 @@ pub const Type = struct {
.export_options => unreachable, // missing call to resolveTypeFields
.extern_options => unreachable, // missing call to resolveTypeFields
.type_info => unreachable, // missing call to resolveTypeFields
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -4000,8 +3875,6 @@ pub const Type = struct {
return payload.len * 8 * elem_size + elem_bit_size;
},
.isize,
.usize,
.@"anyframe",
.anyframe_T,
=> return target.ptrBitWidth(),
@ -4040,16 +3913,6 @@ pub const Type = struct {
.manyptr_const_u8_sentinel_0,
=> return target.ptrBitWidth(),
.c_char => return target.c_type_bit_size(.char),
.c_short => return target.c_type_bit_size(.short),
.c_ushort => return target.c_type_bit_size(.ushort),
.c_int => return target.c_type_bit_size(.int),
.c_uint => return target.c_type_bit_size(.uint),
.c_long => return target.c_type_bit_size(.long),
.c_ulong => return target.c_type_bit_size(.ulong),
.c_longlong => return target.c_type_bit_size(.longlong),
.c_ulonglong => return target.c_type_bit_size(.ulonglong),
.error_set,
.error_set_single,
.anyerror_void_error_union,
@ -4876,12 +4739,6 @@ pub const Type = struct {
};
return switch (ty.tag()) {
.i8,
.isize,
.c_char,
.c_short,
.c_int,
.c_long,
.c_longlong,
.i16,
.i32,
.i64,
@ -4903,11 +4760,6 @@ pub const Type = struct {
else => return false,
};
return switch (ty.tag()) {
.usize,
.c_ushort,
.c_uint,
.c_ulong,
.c_ulonglong,
.u1,
.u8,
.u16,
@ -4938,13 +4790,26 @@ pub const Type = struct {
if (ty.ip_index != .none) switch (mod.intern_pool.indexToKey(ty.ip_index)) {
.int_type => |int_type| return int_type,
.ptr_type => @panic("TODO"),
.array_type => @panic("TODO"),
.ptr_type => unreachable,
.array_type => unreachable,
.vector_type => @panic("TODO"),
.optional_type => @panic("TODO"),
.error_union_type => @panic("TODO"),
.simple_type => @panic("TODO"),
.struct_type => unreachable,
.optional_type => unreachable,
.error_union_type => unreachable,
.simple_type => |t| switch (t) {
.usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
.isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
.c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
.c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
.c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
.c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
.c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
.c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
.c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
.c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
.c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
else => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => unreachable,
.simple_value => unreachable,
.extern_func => unreachable,
@ -4965,17 +4830,6 @@ pub const Type = struct {
.i64 => return .{ .signedness = .signed, .bits = 64 },
.u128 => return .{ .signedness = .unsigned, .bits = 128 },
.i128 => return .{ .signedness = .signed, .bits = 128 },
.usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
.isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
.c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
.c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
.c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
.c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
.c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
.c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
.c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
.c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
.c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
.enum_full, .enum_nonexhaustive => ty = ty.cast(Payload.EnumFull).?.data.tag_ty,
.enum_numbered => ty = ty.castTag(.enum_numbered).?.data.tag_ty,
@ -5003,19 +4857,19 @@ pub const Type = struct {
};
}
pub fn isNamedInt(self: Type) bool {
return switch (self.tag()) {
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
pub fn isNamedInt(ty: Type) bool {
return switch (ty.ip_index) {
.usize_type,
.isize_type,
.c_char_type,
.c_short_type,
.c_ushort_type,
.c_int_type,
.c_uint_type,
.c_long_type,
.c_ulong_type,
.c_longlong_type,
.c_ulonglong_type,
=> true,
else => false,
@ -5180,17 +5034,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
=> true,
else => false,
@ -5284,17 +5127,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.bool,
.type,
.anyerror,
@ -5502,6 +5334,8 @@ pub const Type = struct {
.enum_literal,
.type_info,
=> true,
.var_args_param => unreachable,
},
.struct_type => @panic("TODO"),
.union_type => @panic("TODO"),
@ -5524,17 +5358,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -6372,17 +6195,6 @@ pub const Type = struct {
i64,
u128,
i128,
usize,
isize,
c_char,
c_short,
c_ushort,
c_int,
c_uint,
c_long,
c_ulong,
c_longlong,
c_ulonglong,
anyopaque,
bool,
void,
@ -6480,17 +6292,6 @@ pub const Type = struct {
.i64,
.u128,
.i128,
.usize,
.isize,
.c_char,
.c_short,
.c_ushort,
.c_int,
.c_uint,
.c_long,
.c_ulong,
.c_longlong,
.c_ulonglong,
.anyopaque,
.bool,
.void,
@ -6859,9 +6660,13 @@ pub const Type = struct {
pub const @"u29" = initTag(.u29);
pub const @"u32" = initTag(.u32);
pub const @"u64" = initTag(.u64);
pub const @"u128" = initTag(.u128);
pub const @"i8" = initTag(.i8);
pub const @"i16" = initTag(.i16);
pub const @"i32" = initTag(.i32);
pub const @"i64" = initTag(.i64);
pub const @"i128" = initTag(.i128);
pub const @"f16": Type = .{ .ip_index = .f16_type, .legacy = undefined };
pub const @"f32": Type = .{ .ip_index = .f32_type, .legacy = undefined };
@ -6870,8 +6675,8 @@ pub const Type = struct {
pub const @"f128": Type = .{ .ip_index = .f128_type, .legacy = undefined };
pub const @"bool" = initTag(.bool);
pub const @"usize" = initTag(.usize);
pub const @"isize" = initTag(.isize);
pub const @"usize": Type = .{ .ip_index = .usize_type, .legacy = undefined };
pub const @"isize": Type = .{ .ip_index = .isize_type, .legacy = undefined };
pub const @"comptime_int": Type = .{ .ip_index = .comptime_int_type, .legacy = undefined };
pub const @"comptime_float": Type = .{ .ip_index = .comptime_float_type, .legacy = undefined };
pub const @"void" = initTag(.void);
@ -6879,8 +6684,18 @@ pub const Type = struct {
pub const @"anyerror" = initTag(.anyerror);
pub const @"anyopaque" = initTag(.anyopaque);
pub const @"null" = initTag(.null);
pub const @"undefined" = initTag(.undefined);
pub const @"noreturn" = initTag(.noreturn);
pub const @"c_char": Type = .{ .ip_index = .c_char_type, .legacy = undefined };
pub const @"c_short": Type = .{ .ip_index = .c_short_type, .legacy = undefined };
pub const @"c_ushort": Type = .{ .ip_index = .c_ushort_type, .legacy = undefined };
pub const @"c_int": Type = .{ .ip_index = .c_int_type, .legacy = undefined };
pub const @"c_uint": Type = .{ .ip_index = .c_uint_type, .legacy = undefined };
pub const @"c_long": Type = .{ .ip_index = .c_long_type, .legacy = undefined };
pub const @"c_ulong": Type = .{ .ip_index = .c_ulong_type, .legacy = undefined };
pub const @"c_longlong": Type = .{ .ip_index = .c_longlong_type, .legacy = undefined };
pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type, .legacy = undefined };
pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type, .legacy = undefined };
pub const err_int = Type.u16;

View file

@ -951,45 +951,45 @@ pub const Value = struct {
}
return switch (self.tag()) {
.ty => self.castTag(.ty).?.data,
.u1_type => Type.initTag(.u1),
.u8_type => Type.initTag(.u8),
.i8_type => Type.initTag(.i8),
.u16_type => Type.initTag(.u16),
.i16_type => Type.initTag(.i16),
.u29_type => Type.initTag(.u29),
.u32_type => Type.initTag(.u32),
.i32_type => Type.initTag(.i32),
.u64_type => Type.initTag(.u64),
.i64_type => Type.initTag(.i64),
.u128_type => Type.initTag(.u128),
.i128_type => Type.initTag(.i128),
.usize_type => Type.initTag(.usize),
.isize_type => Type.initTag(.isize),
.c_char_type => Type.initTag(.c_char),
.c_short_type => Type.initTag(.c_short),
.c_ushort_type => Type.initTag(.c_ushort),
.c_int_type => Type.initTag(.c_int),
.c_uint_type => Type.initTag(.c_uint),
.c_long_type => Type.initTag(.c_long),
.c_ulong_type => Type.initTag(.c_ulong),
.c_longlong_type => Type.initTag(.c_longlong),
.c_ulonglong_type => Type.initTag(.c_ulonglong),
.u1_type => Type.u1,
.u8_type => Type.u8,
.i8_type => Type.i8,
.u16_type => Type.u16,
.i16_type => Type.i16,
.u29_type => Type.u29,
.u32_type => Type.u32,
.i32_type => Type.i32,
.u64_type => Type.u64,
.i64_type => Type.i64,
.u128_type => Type.u128,
.i128_type => Type.i128,
.usize_type => Type.usize,
.isize_type => Type.isize,
.c_char_type => Type.c_char,
.c_short_type => Type.c_short,
.c_ushort_type => Type.c_ushort,
.c_int_type => Type.c_int,
.c_uint_type => Type.c_uint,
.c_long_type => Type.c_long,
.c_ulong_type => Type.c_ulong,
.c_longlong_type => Type.c_longlong,
.c_ulonglong_type => Type.c_ulonglong,
.c_longdouble_type => Type.c_longdouble,
.f16_type => Type.f16,
.f32_type => Type.f32,
.f64_type => Type.f64,
.f80_type => Type.f80,
.f128_type => Type.f128,
.anyopaque_type => Type.initTag(.anyopaque),
.bool_type => Type.initTag(.bool),
.void_type => Type.initTag(.void),
.type_type => Type.initTag(.type),
.anyerror_type => Type.initTag(.anyerror),
.comptime_int_type => Type.initTag(.comptime_int),
.anyopaque_type => Type.anyopaque,
.bool_type => Type.bool,
.void_type => Type.void,
.type_type => Type.type,
.anyerror_type => Type.anyerror,
.comptime_int_type => Type.comptime_int,
.comptime_float_type => Type.comptime_float,
.noreturn_type => Type.initTag(.noreturn),
.null_type => Type.initTag(.null),
.undefined_type => Type.initTag(.undefined),
.noreturn_type => Type.noreturn,
.null_type => Type.null,
.undefined_type => Type.undefined,
.single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int),
.anyframe_type => Type.initTag(.@"anyframe"),
.const_slice_u8_type => Type.initTag(.const_slice_u8),