authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-03 16:33:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:40:04-07:00
logbcd4bb8afbea84d86fd8758b581b141e7086b16b
tree51991831c5fe4a6ddccb2bf7297f33f72e990931
parent4cd8a40b3b34d4e68853088dd637a9da9b6a8891

stage2: move named int types to InternPool


10 files changed, 121 insertions(+), 345 deletions(-)

src/Sema.zig+6-45
......@@ -6448,7 +6448,7 @@ fn checkCallArgumentCount(
64486448 .Optional => {
64496449 var buf: Type.Payload.ElemType = undefined;
64506450 const opt_child = callee_ty.optionalChild(&buf);
6451 if (opt_child.zigTypeTag(mod) == .Fn or (opt_child.isSinglePointer() and
6451 if (opt_child.zigTypeTag(mod) == .Fn or (opt_child.isSinglePointer(mod) and
64526452 opt_child.childType().zigTypeTag(mod) == .Fn))
64536453 {
64546454 const msg = msg: {
......@@ -31421,6 +31421,8 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
3142131421 .enum_literal,
3142231422 .type_info,
3142331423 => true,
31424
31425 .var_args_param => unreachable,
3142431426 },
3142531427 .struct_type => @panic("TODO"),
3142631428 .union_type => @panic("TODO"),
......@@ -31443,17 +31445,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
3144331445 .i64,
3144431446 .u128,
3144531447 .i128,
31446 .usize,
31447 .isize,
31448 .c_char,
31449 .c_short,
31450 .c_ushort,
31451 .c_int,
31452 .c_uint,
31453 .c_long,
31454 .c_ulong,
31455 .c_longlong,
31456 .c_ulonglong,
3145731448 .anyopaque,
3145831449 .bool,
3145931450 .void,
......@@ -31798,6 +31789,7 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
3179831789 .bool_false => unreachable,
3179931790 .empty_struct => unreachable,
3180031791 .generic_poison => unreachable,
31792 .var_args_param_type => unreachable,
3180131793
3180231794 .type_info_type => return sema.getBuiltinType("Type"),
3180331795 .extern_options_type => return sema.getBuiltinType("ExternOptions"),
......@@ -32977,17 +32969,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3297732969 .i64,
3297832970 .u128,
3297932971 .i128,
32980 .usize,
32981 .isize,
32982 .c_char,
32983 .c_short,
32984 .c_ushort,
32985 .c_int,
32986 .c_uint,
32987 .c_long,
32988 .c_ulong,
32989 .c_longlong,
32990 .c_ulonglong,
3299132972 .bool,
3299232973 .type,
3299332974 .anyerror,
......@@ -33213,17 +33194,6 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
3321333194 .i64 => return .i64_type,
3321433195 .u128 => return .u128_type,
3321533196 .i128 => return .i128_type,
33216 .usize => return .usize_type,
33217 .isize => return .isize_type,
33218 .c_char => return .c_char_type,
33219 .c_short => return .c_short_type,
33220 .c_ushort => return .c_ushort_type,
33221 .c_int => return .c_int_type,
33222 .c_uint => return .c_uint_type,
33223 .c_long => return .c_long_type,
33224 .c_ulong => return .c_ulong_type,
33225 .c_longlong => return .c_longlong_type,
33226 .c_ulonglong => return .c_ulonglong_type,
3322733197 .anyopaque => return .anyopaque_type,
3322833198 .bool => return .bool_type,
3322933199 .void => return .void_type,
......@@ -33664,6 +33634,8 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
3366433634 .enum_literal,
3366533635 .type_info,
3366633636 => true,
33637
33638 .var_args_param => unreachable,
3366733639 },
3366833640 .struct_type => @panic("TODO"),
3366933641 .union_type => @panic("TODO"),
......@@ -33686,17 +33658,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
3368633658 .i64,
3368733659 .u128,
3368833660 .i128,
33689 .usize,
33690 .isize,
33691 .c_char,
33692 .c_short,
33693 .c_ushort,
33694 .c_int,
33695 .c_uint,
33696 .c_long,
33697 .c_ulong,
33698 .c_longlong,
33699 .c_ulonglong,
3370033661 .anyopaque,
3370133662 .bool,
3370233663 .void,
src/arch/aarch64/CodeGen.zig+3-3
......@@ -4326,7 +4326,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
43264326 const atom = elf_file.getAtom(atom_index);
43274327 _ = try atom.getOrCreateOffsetTableEntry(elf_file);
43284328 const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
4329 try self.genSetReg(Type.initTag(.usize), .x30, .{ .memory = got_addr });
4329 try self.genSetReg(Type.usize, .x30, .{ .memory = got_addr });
43304330 } else if (self.bin_file.cast(link.File.MachO)) |macho_file| {
43314331 const atom = try macho_file.getOrCreateAtomForDecl(func.owner_decl);
43324332 const sym_index = macho_file.getAtom(atom).getSymbolIndex().?;
......@@ -4353,7 +4353,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
43534353 const got_addr = p9.bases.data;
43544354 const got_index = decl_block.got_index.?;
43554355 const fn_got_addr = got_addr + got_index * ptr_bytes;
4356 try self.genSetReg(Type.initTag(.usize), .x30, .{ .memory = fn_got_addr });
4356 try self.genSetReg(Type.usize, .x30, .{ .memory = fn_got_addr });
43574357 } else unreachable;
43584358
43594359 _ = try self.addInst(.{
......@@ -5968,7 +5968,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
59685968
59695969 const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst);
59705970 try self.genSetStack(ptr_ty, stack_offset, ptr);
5971 try self.genSetStack(Type.initTag(.usize), stack_offset - ptr_bytes, .{ .immediate = array_len });
5971 try self.genSetStack(Type.usize, stack_offset - ptr_bytes, .{ .immediate = array_len });
59725972 break :result MCValue{ .stack_offset = stack_offset };
59735973 };
59745974 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/arm/CodeGen.zig+5-5
......@@ -4308,7 +4308,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
43084308 const atom = elf_file.getAtom(atom_index);
43094309 _ = try atom.getOrCreateOffsetTableEntry(elf_file);
43104310 const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
4311 try self.genSetReg(Type.initTag(.usize), .lr, .{ .memory = got_addr });
4311 try self.genSetReg(Type.usize, .lr, .{ .memory = got_addr });
43124312 } else if (self.bin_file.cast(link.File.MachO)) |_| {
43134313 unreachable; // unsupported architecture for MachO
43144314 } else {
......@@ -4326,7 +4326,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
43264326 assert(ty.zigTypeTag(mod) == .Pointer);
43274327 const mcv = try self.resolveInst(callee);
43284328
4329 try self.genSetReg(Type.initTag(.usize), .lr, mcv);
4329 try self.genSetReg(Type.usize, .lr, mcv);
43304330 }
43314331
43324332 // TODO: add Instruction.supportedOn
......@@ -5694,7 +5694,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
56945694 if (extra_offset) {
56955695 const offset = if (off <= math.maxInt(u8)) blk: {
56965696 break :blk Instruction.ExtraLoadStoreOffset.imm(@intCast(u8, off));
5697 } else Instruction.ExtraLoadStoreOffset.reg(try self.copyToTmpRegister(Type.initTag(.usize), MCValue{ .immediate = off }));
5697 } else Instruction.ExtraLoadStoreOffset.reg(try self.copyToTmpRegister(Type.usize, MCValue{ .immediate = off }));
56985698
56995699 _ = try self.addInst(.{
57005700 .tag = tag,
......@@ -5710,7 +5710,7 @@ fn genSetReg(self: *Self, ty: Type, reg: Register, mcv: MCValue) InnerError!void
57105710 } else {
57115711 const offset = if (off <= math.maxInt(u12)) blk: {
57125712 break :blk Instruction.Offset.imm(@intCast(u12, off));
5713 } else Instruction.Offset.reg(try self.copyToTmpRegister(Type.initTag(.usize), MCValue{ .immediate = off }), .none);
5713 } else Instruction.Offset.reg(try self.copyToTmpRegister(Type.usize, MCValue{ .immediate = off }), .none);
57145714
57155715 _ = try self.addInst(.{
57165716 .tag = tag,
......@@ -5916,7 +5916,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
59165916
59175917 const stack_offset = try self.allocMem(8, 8, inst);
59185918 try self.genSetStack(ptr_ty, stack_offset, ptr);
5919 try self.genSetStack(Type.initTag(.usize), stack_offset - 4, .{ .immediate = array_len });
5919 try self.genSetStack(Type.usize, stack_offset - 4, .{ .immediate = array_len });
59205920 break :result MCValue{ .stack_offset = stack_offset };
59215921 };
59225922 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
src/arch/riscv64/CodeGen.zig+1-1
......@@ -1749,7 +1749,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
17491749 const atom = elf_file.getAtom(atom_index);
17501750 _ = try atom.getOrCreateOffsetTableEntry(elf_file);
17511751 const got_addr = @intCast(u32, atom.getOffsetTableAddress(elf_file));
1752 try self.genSetReg(Type.initTag(.usize), .ra, .{ .memory = got_addr });
1752 try self.genSetReg(Type.usize, .ra, .{ .memory = got_addr });
17531753 _ = try self.addInst(.{
17541754 .tag = .jalr,
17551755 .data = .{ .i_type = .{
src/arch/sparc64/CodeGen.zig+2-2
......@@ -883,7 +883,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void {
883883
884884 const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2);
885885 try self.genSetStack(ptr_ty, stack_offset, ptr);
886 try self.genSetStack(Type.initTag(.usize), stack_offset - ptr_bytes, .{ .immediate = array_len });
886 try self.genSetStack(Type.usize, stack_offset - ptr_bytes, .{ .immediate = array_len });
887887 break :result MCValue{ .stack_offset = stack_offset };
888888 };
889889 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
13521352 break :blk @intCast(u32, atom.getOffsetTableAddress(elf_file));
13531353 } else unreachable;
13541354
1355 try self.genSetReg(Type.initTag(.usize), .o7, .{ .memory = got_addr });
1355 try self.genSetReg(Type.usize, .o7, .{ .memory = got_addr });
13561356
13571357 _ = try self.addInst(.{
13581358 .tag = .jmpl,
src/codegen.zig+1-1
......@@ -371,7 +371,7 @@ pub fn generateSymbol(
371371
372372 // generate length
373373 switch (try generateSymbol(bin_file, src_loc, .{
374 .ty = Type.initTag(.usize),
374 .ty = Type.usize,
375375 .val = slice.len,
376376 }, code, debug_output, reloc_info)) {
377377 .ok => {},
src/codegen/c/type.zig+12-12
......@@ -1359,18 +1359,18 @@ pub const CType = extern union {
13591359 self.* = undefined;
13601360 if (!ty.isFnOrHasRuntimeBitsIgnoreComptime(mod))
13611361 self.init(.void)
1362 else if (ty.isAbiInt(mod)) switch (ty.tag()) {
1363 .usize => self.init(.uintptr_t),
1364 .isize => self.init(.intptr_t),
1365 .c_char => self.init(.char),
1366 .c_short => self.init(.short),
1367 .c_ushort => self.init(.@"unsigned short"),
1368 .c_int => self.init(.int),
1369 .c_uint => self.init(.@"unsigned int"),
1370 .c_long => self.init(.long),
1371 .c_ulong => self.init(.@"unsigned long"),
1372 .c_longlong => self.init(.@"long long"),
1373 .c_ulonglong => self.init(.@"unsigned long long"),
1362 else if (ty.isAbiInt(mod)) switch (ty.ip_index) {
1363 .usize_type => self.init(.uintptr_t),
1364 .isize_type => self.init(.intptr_t),
1365 .c_char_type => self.init(.char),
1366 .c_short_type => self.init(.short),
1367 .c_ushort_type => self.init(.@"unsigned short"),
1368 .c_int_type => self.init(.int),
1369 .c_uint_type => self.init(.@"unsigned int"),
1370 .c_long_type => self.init(.long),
1371 .c_ulong_type => self.init(.@"unsigned long"),
1372 .c_longlong_type => self.init(.@"long long"),
1373 .c_ulonglong_type => self.init(.@"unsigned long long"),
13741374 else => switch (tagFromIntInfo(ty.intInfo(mod))) {
13751375 .void => unreachable,
13761376 else => |t| self.init(t),
src/codegen/spirv.zig+1-1
......@@ -2499,7 +2499,7 @@ pub const DeclGen = struct {
24992499 const elem_ty = ptr_ty.elemType2(mod); // use elemType() so that we get T for *[N]T.
25002500 const elem_ty_ref = try self.resolveType(elem_ty, .direct);
25012501 const elem_ptr_ty_ref = try self.spv.ptrType(elem_ty_ref, spvStorageClass(ptr_ty.ptrAddressSpace()));
2502 if (ptr_ty.isSinglePointer()) {
2502 if (ptr_ty.isSinglePointer(mod)) {
25032503 // Pointer-to-array. In this case, the resulting pointer is not of the same type
25042504 // as the ptr_ty (we want a *T, not a *[N]T), and hence we need to use accessChain.
25052505 return try self.accessChain(elem_ptr_ty_ref, ptr_id, &.{index_id});
src/type.zig+58-243
......@@ -121,17 +121,6 @@ pub const Type = struct {
121121 .i64,
122122 .u128,
123123 .i128,
124 .usize,
125 .isize,
126 .c_char,
127 .c_short,
128 .c_ushort,
129 .c_int,
130 .c_uint,
131 .c_long,
132 .c_ulong,
133 .c_longlong,
134 .c_ulonglong,
135124 => return .Int,
136125
137126 .error_set,
......@@ -621,19 +610,6 @@ pub const Type = struct {
621610 switch (a.tag()) {
622611 .generic_poison => unreachable,
623612
624 // Detect that e.g. u64 != usize, even if the bits match on a particular target.
625 .usize,
626 .isize,
627 .c_char,
628 .c_short,
629 .c_ushort,
630 .c_int,
631 .c_uint,
632 .c_long,
633 .c_ulong,
634 .c_longlong,
635 .c_ulonglong,
636
637613 .bool,
638614 .void,
639615 .type,
......@@ -1013,22 +989,6 @@ pub const Type = struct {
1013989 switch (ty.tag()) {
1014990 .generic_poison => unreachable,
1015991
1016 .usize,
1017 .isize,
1018 .c_char,
1019 .c_short,
1020 .c_ushort,
1021 .c_int,
1022 .c_uint,
1023 .c_long,
1024 .c_ulong,
1025 .c_longlong,
1026 .c_ulonglong,
1027 => |ty_tag| {
1028 std.hash.autoHash(hasher, std.builtin.TypeId.Int);
1029 std.hash.autoHash(hasher, ty_tag);
1030 },
1031
1032992 .bool => std.hash.autoHash(hasher, std.builtin.TypeId.Bool),
1033993 .void => std.hash.autoHash(hasher, std.builtin.TypeId.Void),
1034994 .type => std.hash.autoHash(hasher, std.builtin.TypeId.Type),
......@@ -1345,17 +1305,6 @@ pub const Type = struct {
13451305 .i64,
13461306 .u128,
13471307 .i128,
1348 .usize,
1349 .isize,
1350 .c_char,
1351 .c_short,
1352 .c_ushort,
1353 .c_int,
1354 .c_uint,
1355 .c_long,
1356 .c_ulong,
1357 .c_longlong,
1358 .c_ulonglong,
13591308 .anyopaque,
13601309 .bool,
13611310 .void,
......@@ -1631,17 +1580,6 @@ pub const Type = struct {
16311580 .i64,
16321581 .u128,
16331582 .i128,
1634 .usize,
1635 .isize,
1636 .c_char,
1637 .c_short,
1638 .c_ushort,
1639 .c_int,
1640 .c_uint,
1641 .c_long,
1642 .c_ulong,
1643 .c_longlong,
1644 .c_ulonglong,
16451583 .anyopaque,
16461584 .bool,
16471585 .void,
......@@ -2020,17 +1958,6 @@ pub const Type = struct {
20201958 .i64,
20211959 .u128,
20221960 .i128,
2023 .usize,
2024 .isize,
2025 .c_char,
2026 .c_short,
2027 .c_ushort,
2028 .c_int,
2029 .c_uint,
2030 .c_long,
2031 .c_ulong,
2032 .c_longlong,
2033 .c_ulonglong,
20341961 .anyopaque,
20351962 .bool,
20361963 .void,
......@@ -2322,17 +2249,6 @@ pub const Type = struct {
23222249 .i32 => return Value.initTag(.i32_type),
23232250 .u64 => return Value.initTag(.u64_type),
23242251 .i64 => return Value.initTag(.i64_type),
2325 .usize => return Value.initTag(.usize_type),
2326 .isize => return Value.initTag(.isize_type),
2327 .c_char => return Value.initTag(.c_char_type),
2328 .c_short => return Value.initTag(.c_short_type),
2329 .c_ushort => return Value.initTag(.c_ushort_type),
2330 .c_int => return Value.initTag(.c_int_type),
2331 .c_uint => return Value.initTag(.c_uint_type),
2332 .c_long => return Value.initTag(.c_long_type),
2333 .c_ulong => return Value.initTag(.c_ulong_type),
2334 .c_longlong => return Value.initTag(.c_longlong_type),
2335 .c_ulonglong => return Value.initTag(.c_ulonglong_type),
23362252 .anyopaque => return Value.initTag(.anyopaque_type),
23372253 .bool => return Value.initTag(.bool_type),
23382254 .void => return Value.initTag(.void_type),
......@@ -2462,17 +2378,6 @@ pub const Type = struct {
24622378 .i64,
24632379 .u128,
24642380 .i128,
2465 .usize,
2466 .isize,
2467 .c_char,
2468 .c_short,
2469 .c_ushort,
2470 .c_int,
2471 .c_uint,
2472 .c_long,
2473 .c_ulong,
2474 .c_longlong,
2475 .c_ulonglong,
24762381 .bool,
24772382 .anyerror,
24782383 .const_slice_u8,
......@@ -2713,6 +2618,8 @@ pub const Type = struct {
27132618 .type_info,
27142619 .generic_poison,
27152620 => false,
2621
2622 .var_args_param => unreachable,
27162623 },
27172624 .struct_type => @panic("TODO"),
27182625 .union_type => @panic("TODO"),
......@@ -2734,17 +2641,6 @@ pub const Type = struct {
27342641 .i64,
27352642 .u128,
27362643 .i128,
2737 .usize,
2738 .isize,
2739 .c_char,
2740 .c_short,
2741 .c_ushort,
2742 .c_int,
2743 .c_uint,
2744 .c_long,
2745 .c_ulong,
2746 .c_longlong,
2747 .c_ulonglong,
27482644 .bool,
27492645 .void,
27502646 .manyptr_u8,
......@@ -3040,7 +2936,7 @@ pub const Type = struct {
30402936 .export_options,
30412937 .extern_options,
30422938 .@"anyframe",
3043 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
2939 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
30442940
30452941 .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) },
30462942 .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },
......@@ -3089,6 +2985,7 @@ pub const Type = struct {
30892985
30902986 .noreturn => unreachable,
30912987 .generic_poison => unreachable,
2988 .var_args_param => unreachable,
30922989 },
30932990 .struct_type => @panic("TODO"),
30942991 .union_type => @panic("TODO"),
......@@ -3130,8 +3027,6 @@ pub const Type = struct {
31303027 return AbiAlignmentAdvanced{ .scalar = target_util.defaultFunctionAlignment(target) };
31313028 },
31323029
3133 .isize,
3134 .usize,
31353030 .single_const_pointer_to_comptime_int,
31363031 .const_slice_u8,
31373032 .const_slice_u8_sentinel_0,
......@@ -3153,16 +3048,6 @@ pub const Type = struct {
31533048 .anyframe_T,
31543049 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
31553050
3156 .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) },
3157 .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },
3158 .c_ushort => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ushort) },
3159 .c_int => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.int) },
3160 .c_uint => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.uint) },
3161 .c_long => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.long) },
3162 .c_ulong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ulong) },
3163 .c_longlong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.longlong) },
3164 .c_ulonglong => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ulonglong) },
3165
31663051 // TODO revisit this when we have the concept of the error tag type
31673052 .anyerror_void_error_union,
31683053 .anyerror,
......@@ -3491,7 +3376,7 @@ pub const Type = struct {
34913376 .usize,
34923377 .isize,
34933378 .@"anyframe",
3494 => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
3379 => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
34953380
34963381 .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) },
34973382 .c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },
......@@ -3524,6 +3409,7 @@ pub const Type = struct {
35243409 .type_info => unreachable,
35253410 .noreturn => unreachable,
35263411 .generic_poison => unreachable,
3412 .var_args_param => unreachable,
35273413 },
35283414 .struct_type => @panic("TODO"),
35293415 .union_type => @panic("TODO"),
......@@ -3666,8 +3552,6 @@ pub const Type = struct {
36663552 return AbiSizeAdvanced{ .scalar = result };
36673553 },
36683554
3669 .isize,
3670 .usize,
36713555 .@"anyframe",
36723556 .anyframe_T,
36733557 .optional_single_const_pointer,
......@@ -3694,16 +3578,6 @@ pub const Type = struct {
36943578 else => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) },
36953579 },
36963580
3697 .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) },
3698 .c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },
3699 .c_ushort => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ushort) },
3700 .c_int => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.int) },
3701 .c_uint => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.uint) },
3702 .c_long => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.long) },
3703 .c_ulong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ulong) },
3704 .c_longlong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.longlong) },
3705 .c_ulonglong => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ulonglong) },
3706
37073581 // TODO revisit this when we have the concept of the error tag type
37083582 .anyerror_void_error_union,
37093583 .anyerror,
......@@ -3856,7 +3730,7 @@ pub const Type = struct {
38563730 .usize,
38573731 .isize,
38583732 .@"anyframe",
3859 => return target.cpu.arch.ptrBitWidth(),
3733 => return target.ptrBitWidth(),
38603734
38613735 .c_char => return target.c_type_bit_size(.char),
38623736 .c_short => return target.c_type_bit_size(.short),
......@@ -3896,6 +3770,7 @@ pub const Type = struct {
38963770 .export_options => unreachable, // missing call to resolveTypeFields
38973771 .extern_options => unreachable, // missing call to resolveTypeFields
38983772 .type_info => unreachable, // missing call to resolveTypeFields
3773 .var_args_param => unreachable,
38993774 },
39003775 .struct_type => @panic("TODO"),
39013776 .union_type => @panic("TODO"),
......@@ -4000,8 +3875,6 @@ pub const Type = struct {
40003875 return payload.len * 8 * elem_size + elem_bit_size;
40013876 },
40023877
4003 .isize,
4004 .usize,
40053878 .@"anyframe",
40063879 .anyframe_T,
40073880 => return target.ptrBitWidth(),
......@@ -4040,16 +3913,6 @@ pub const Type = struct {
40403913 .manyptr_const_u8_sentinel_0,
40413914 => return target.ptrBitWidth(),
40423915
4043 .c_char => return target.c_type_bit_size(.char),
4044 .c_short => return target.c_type_bit_size(.short),
4045 .c_ushort => return target.c_type_bit_size(.ushort),
4046 .c_int => return target.c_type_bit_size(.int),
4047 .c_uint => return target.c_type_bit_size(.uint),
4048 .c_long => return target.c_type_bit_size(.long),
4049 .c_ulong => return target.c_type_bit_size(.ulong),
4050 .c_longlong => return target.c_type_bit_size(.longlong),
4051 .c_ulonglong => return target.c_type_bit_size(.ulonglong),
4052
40533916 .error_set,
40543917 .error_set_single,
40553918 .anyerror_void_error_union,
......@@ -4876,12 +4739,6 @@ pub const Type = struct {
48764739 };
48774740 return switch (ty.tag()) {
48784741 .i8,
4879 .isize,
4880 .c_char,
4881 .c_short,
4882 .c_int,
4883 .c_long,
4884 .c_longlong,
48854742 .i16,
48864743 .i32,
48874744 .i64,
......@@ -4903,11 +4760,6 @@ pub const Type = struct {
49034760 else => return false,
49044761 };
49054762 return switch (ty.tag()) {
4906 .usize,
4907 .c_ushort,
4908 .c_uint,
4909 .c_ulong,
4910 .c_ulonglong,
49114763 .u1,
49124764 .u8,
49134765 .u16,
......@@ -4938,13 +4790,26 @@ pub const Type = struct {
49384790
49394791 if (ty.ip_index != .none) switch (mod.intern_pool.indexToKey(ty.ip_index)) {
49404792 .int_type => |int_type| return int_type,
4941 .ptr_type => @panic("TODO"),
4942 .array_type => @panic("TODO"),
4793 .ptr_type => unreachable,
4794 .array_type => unreachable,
49434795 .vector_type => @panic("TODO"),
4944 .optional_type => @panic("TODO"),
4945 .error_union_type => @panic("TODO"),
4946 .simple_type => @panic("TODO"),
4947 .struct_type => unreachable,
4796 .optional_type => unreachable,
4797 .error_union_type => unreachable,
4798 .simple_type => |t| switch (t) {
4799 .usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
4800 .isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
4801 .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
4802 .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
4803 .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
4804 .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
4805 .c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
4806 .c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
4807 .c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
4808 .c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
4809 .c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
4810 else => unreachable,
4811 },
4812 .struct_type => @panic("TODO"),
49484813 .union_type => unreachable,
49494814 .simple_value => unreachable,
49504815 .extern_func => unreachable,
......@@ -4965,17 +4830,6 @@ pub const Type = struct {
49654830 .i64 => return .{ .signedness = .signed, .bits = 64 },
49664831 .u128 => return .{ .signedness = .unsigned, .bits = 128 },
49674832 .i128 => return .{ .signedness = .signed, .bits = 128 },
4968 .usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
4969 .isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
4970 .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
4971 .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
4972 .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
4973 .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
4974 .c_uint => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
4975 .c_long => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
4976 .c_ulong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
4977 .c_longlong => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
4978 .c_ulonglong => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
49794833
49804834 .enum_full, .enum_nonexhaustive => ty = ty.cast(Payload.EnumFull).?.data.tag_ty,
49814835 .enum_numbered => ty = ty.castTag(.enum_numbered).?.data.tag_ty,
......@@ -5003,19 +4857,19 @@ pub const Type = struct {
50034857 };
50044858 }
50054859
5006 pub fn isNamedInt(self: Type) bool {
5007 return switch (self.tag()) {
5008 .usize,
5009 .isize,
5010 .c_char,
5011 .c_short,
5012 .c_ushort,
5013 .c_int,
5014 .c_uint,
5015 .c_long,
5016 .c_ulong,
5017 .c_longlong,
5018 .c_ulonglong,
4860 pub fn isNamedInt(ty: Type) bool {
4861 return switch (ty.ip_index) {
4862 .usize_type,
4863 .isize_type,
4864 .c_char_type,
4865 .c_short_type,
4866 .c_ushort_type,
4867 .c_int_type,
4868 .c_uint_type,
4869 .c_long_type,
4870 .c_ulong_type,
4871 .c_longlong_type,
4872 .c_ulonglong_type,
50194873 => true,
50204874
50214875 else => false,
......@@ -5180,17 +5034,6 @@ pub const Type = struct {
51805034 .i64,
51815035 .u128,
51825036 .i128,
5183 .usize,
5184 .isize,
5185 .c_char,
5186 .c_short,
5187 .c_ushort,
5188 .c_int,
5189 .c_uint,
5190 .c_long,
5191 .c_ulong,
5192 .c_longlong,
5193 .c_ulonglong,
51945037 => true,
51955038
51965039 else => false,
......@@ -5284,17 +5127,6 @@ pub const Type = struct {
52845127 .i64,
52855128 .u128,
52865129 .i128,
5287 .usize,
5288 .isize,
5289 .c_char,
5290 .c_short,
5291 .c_ushort,
5292 .c_int,
5293 .c_uint,
5294 .c_long,
5295 .c_ulong,
5296 .c_longlong,
5297 .c_ulonglong,
52985130 .bool,
52995131 .type,
53005132 .anyerror,
......@@ -5502,6 +5334,8 @@ pub const Type = struct {
55025334 .enum_literal,
55035335 .type_info,
55045336 => true,
5337
5338 .var_args_param => unreachable,
55055339 },
55065340 .struct_type => @panic("TODO"),
55075341 .union_type => @panic("TODO"),
......@@ -5524,17 +5358,6 @@ pub const Type = struct {
55245358 .i64,
55255359 .u128,
55265360 .i128,
5527 .usize,
5528 .isize,
5529 .c_char,
5530 .c_short,
5531 .c_ushort,
5532 .c_int,
5533 .c_uint,
5534 .c_long,
5535 .c_ulong,
5536 .c_longlong,
5537 .c_ulonglong,
55385361 .anyopaque,
55395362 .bool,
55405363 .void,
......@@ -6372,17 +6195,6 @@ pub const Type = struct {
63726195 i64,
63736196 u128,
63746197 i128,
6375 usize,
6376 isize,
6377 c_char,
6378 c_short,
6379 c_ushort,
6380 c_int,
6381 c_uint,
6382 c_long,
6383 c_ulong,
6384 c_longlong,
6385 c_ulonglong,
63866198 anyopaque,
63876199 bool,
63886200 void,
......@@ -6480,17 +6292,6 @@ pub const Type = struct {
64806292 .i64,
64816293 .u128,
64826294 .i128,
6483 .usize,
6484 .isize,
6485 .c_char,
6486 .c_short,
6487 .c_ushort,
6488 .c_int,
6489 .c_uint,
6490 .c_long,
6491 .c_ulong,
6492 .c_longlong,
6493 .c_ulonglong,
64946295 .anyopaque,
64956296 .bool,
64966297 .void,
......@@ -6859,9 +6660,13 @@ pub const Type = struct {
68596660 pub const @"u29" = initTag(.u29);
68606661 pub const @"u32" = initTag(.u32);
68616662 pub const @"u64" = initTag(.u64);
6663 pub const @"u128" = initTag(.u128);
68626664
6665 pub const @"i8" = initTag(.i8);
6666 pub const @"i16" = initTag(.i16);
68636667 pub const @"i32" = initTag(.i32);
68646668 pub const @"i64" = initTag(.i64);
6669 pub const @"i128" = initTag(.i128);
68656670
68666671 pub const @"f16": Type = .{ .ip_index = .f16_type, .legacy = undefined };
68676672 pub const @"f32": Type = .{ .ip_index = .f32_type, .legacy = undefined };
......@@ -6870,8 +6675,8 @@ pub const Type = struct {
68706675 pub const @"f128": Type = .{ .ip_index = .f128_type, .legacy = undefined };
68716676
68726677 pub const @"bool" = initTag(.bool);
6873 pub const @"usize" = initTag(.usize);
6874 pub const @"isize" = initTag(.isize);
6678 pub const @"usize": Type = .{ .ip_index = .usize_type, .legacy = undefined };
6679 pub const @"isize": Type = .{ .ip_index = .isize_type, .legacy = undefined };
68756680 pub const @"comptime_int": Type = .{ .ip_index = .comptime_int_type, .legacy = undefined };
68766681 pub const @"comptime_float": Type = .{ .ip_index = .comptime_float_type, .legacy = undefined };
68776682 pub const @"void" = initTag(.void);
......@@ -6879,8 +6684,18 @@ pub const Type = struct {
68796684 pub const @"anyerror" = initTag(.anyerror);
68806685 pub const @"anyopaque" = initTag(.anyopaque);
68816686 pub const @"null" = initTag(.null);
6687 pub const @"undefined" = initTag(.undefined);
68826688 pub const @"noreturn" = initTag(.noreturn);
68836689
6690 pub const @"c_char": Type = .{ .ip_index = .c_char_type, .legacy = undefined };
6691 pub const @"c_short": Type = .{ .ip_index = .c_short_type, .legacy = undefined };
6692 pub const @"c_ushort": Type = .{ .ip_index = .c_ushort_type, .legacy = undefined };
6693 pub const @"c_int": Type = .{ .ip_index = .c_int_type, .legacy = undefined };
6694 pub const @"c_uint": Type = .{ .ip_index = .c_uint_type, .legacy = undefined };
6695 pub const @"c_long": Type = .{ .ip_index = .c_long_type, .legacy = undefined };
6696 pub const @"c_ulong": Type = .{ .ip_index = .c_ulong_type, .legacy = undefined };
6697 pub const @"c_longlong": Type = .{ .ip_index = .c_longlong_type, .legacy = undefined };
6698 pub const @"c_ulonglong": Type = .{ .ip_index = .c_ulonglong_type, .legacy = undefined };
68846699 pub const @"c_longdouble": Type = .{ .ip_index = .c_longdouble_type, .legacy = undefined };
68856700
68866701 pub const err_int = Type.u16;
src/value.zig+32-32
......@@ -951,45 +951,45 @@ pub const Value = struct {
951951 }
952952 return switch (self.tag()) {
953953 .ty => self.castTag(.ty).?.data,
954 .u1_type => Type.initTag(.u1),
955 .u8_type => Type.initTag(.u8),
956 .i8_type => Type.initTag(.i8),
957 .u16_type => Type.initTag(.u16),
958 .i16_type => Type.initTag(.i16),
959 .u29_type => Type.initTag(.u29),
960 .u32_type => Type.initTag(.u32),
961 .i32_type => Type.initTag(.i32),
962 .u64_type => Type.initTag(.u64),
963 .i64_type => Type.initTag(.i64),
964 .u128_type => Type.initTag(.u128),
965 .i128_type => Type.initTag(.i128),
966 .usize_type => Type.initTag(.usize),
967 .isize_type => Type.initTag(.isize),
968 .c_char_type => Type.initTag(.c_char),
969 .c_short_type => Type.initTag(.c_short),
970 .c_ushort_type => Type.initTag(.c_ushort),
971 .c_int_type => Type.initTag(.c_int),
972 .c_uint_type => Type.initTag(.c_uint),
973 .c_long_type => Type.initTag(.c_long),
974 .c_ulong_type => Type.initTag(.c_ulong),
975 .c_longlong_type => Type.initTag(.c_longlong),
976 .c_ulonglong_type => Type.initTag(.c_ulonglong),
954 .u1_type => Type.u1,
955 .u8_type => Type.u8,
956 .i8_type => Type.i8,
957 .u16_type => Type.u16,
958 .i16_type => Type.i16,
959 .u29_type => Type.u29,
960 .u32_type => Type.u32,
961 .i32_type => Type.i32,
962 .u64_type => Type.u64,
963 .i64_type => Type.i64,
964 .u128_type => Type.u128,
965 .i128_type => Type.i128,
966 .usize_type => Type.usize,
967 .isize_type => Type.isize,
968 .c_char_type => Type.c_char,
969 .c_short_type => Type.c_short,
970 .c_ushort_type => Type.c_ushort,
971 .c_int_type => Type.c_int,
972 .c_uint_type => Type.c_uint,
973 .c_long_type => Type.c_long,
974 .c_ulong_type => Type.c_ulong,
975 .c_longlong_type => Type.c_longlong,
976 .c_ulonglong_type => Type.c_ulonglong,
977977 .c_longdouble_type => Type.c_longdouble,
978978 .f16_type => Type.f16,
979979 .f32_type => Type.f32,
980980 .f64_type => Type.f64,
981981 .f80_type => Type.f80,
982982 .f128_type => Type.f128,
983 .anyopaque_type => Type.initTag(.anyopaque),
984 .bool_type => Type.initTag(.bool),
985 .void_type => Type.initTag(.void),
986 .type_type => Type.initTag(.type),
987 .anyerror_type => Type.initTag(.anyerror),
988 .comptime_int_type => Type.initTag(.comptime_int),
983 .anyopaque_type => Type.anyopaque,
984 .bool_type => Type.bool,
985 .void_type => Type.void,
986 .type_type => Type.type,
987 .anyerror_type => Type.anyerror,
988 .comptime_int_type => Type.comptime_int,
989989 .comptime_float_type => Type.comptime_float,
990 .noreturn_type => Type.initTag(.noreturn),
991 .null_type => Type.initTag(.null),
992 .undefined_type => Type.initTag(.undefined),
990 .noreturn_type => Type.noreturn,
991 .null_type => Type.null,
992 .undefined_type => Type.undefined,
993993 .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int),
994994 .anyframe_type => Type.initTag(.@"anyframe"),
995995 .const_slice_u8_type => Type.initTag(.const_slice_u8),