Commit 5f3b21a5b6
Changed files (2)
src/InternPool.zig
@@ -2858,7 +2858,7 @@ pub const static_keys = [_]Key{
/// This is specified with an integer literal and a corresponding comptime
/// assert below to break an unfortunate and arguably incorrect dependency loop
/// when compiling.
-pub const static_len = 84;
+pub const static_len = Zir.Inst.Index.static_len;
comptime {
//@compileLog(static_keys.len);
assert(static_len == static_keys.len);
src/Zir.zig
@@ -19,9 +19,7 @@ const BigIntConst = std.math.big.int.Const;
const BigIntMutable = std.math.big.int.Mutable;
const Ast = std.zig.Ast;
-const InternPool = @import("InternPool.zig");
const Zir = @This();
-const Module = @import("Module.zig");
const LazySrcLoc = std.zig.LazySrcLoc;
instructions: std.MultiArrayList(Inst).Slice,
@@ -2093,9 +2091,11 @@ pub const Inst = struct {
/// ZIR is structured so that the outermost "main" struct of any file
/// is always at index 0.
main_struct_inst = 0,
- ref_start_index = InternPool.static_len,
+ ref_start_index = static_len,
_,
+ pub const static_len = 84;
+
pub fn toRef(i: Index) Inst.Ref {
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
}
@@ -2109,7 +2109,7 @@ pub const Inst = struct {
/// ZIR is structured so that the outermost "main" struct of any file
/// is always at index 0.
main_struct_inst = 0,
- ref_start_index = InternPool.static_len,
+ ref_start_index = Index.static_len,
none = std.math.maxInt(u32),
_,
@@ -2127,97 +2127,98 @@ pub const Inst = struct {
/// The tag type is specified so that it is safe to bitcast between `[]u32`
/// and `[]Ref`.
pub const Ref = enum(u32) {
- u0_type = @intFromEnum(InternPool.Index.u0_type),
- i0_type = @intFromEnum(InternPool.Index.i0_type),
- u1_type = @intFromEnum(InternPool.Index.u1_type),
- u8_type = @intFromEnum(InternPool.Index.u8_type),
- i8_type = @intFromEnum(InternPool.Index.i8_type),
- u16_type = @intFromEnum(InternPool.Index.u16_type),
- i16_type = @intFromEnum(InternPool.Index.i16_type),
- u29_type = @intFromEnum(InternPool.Index.u29_type),
- u32_type = @intFromEnum(InternPool.Index.u32_type),
- i32_type = @intFromEnum(InternPool.Index.i32_type),
- u64_type = @intFromEnum(InternPool.Index.u64_type),
- i64_type = @intFromEnum(InternPool.Index.i64_type),
- u80_type = @intFromEnum(InternPool.Index.u80_type),
- u128_type = @intFromEnum(InternPool.Index.u128_type),
- i128_type = @intFromEnum(InternPool.Index.i128_type),
- usize_type = @intFromEnum(InternPool.Index.usize_type),
- isize_type = @intFromEnum(InternPool.Index.isize_type),
- c_char_type = @intFromEnum(InternPool.Index.c_char_type),
- c_short_type = @intFromEnum(InternPool.Index.c_short_type),
- c_ushort_type = @intFromEnum(InternPool.Index.c_ushort_type),
- c_int_type = @intFromEnum(InternPool.Index.c_int_type),
- c_uint_type = @intFromEnum(InternPool.Index.c_uint_type),
- c_long_type = @intFromEnum(InternPool.Index.c_long_type),
- c_ulong_type = @intFromEnum(InternPool.Index.c_ulong_type),
- c_longlong_type = @intFromEnum(InternPool.Index.c_longlong_type),
- c_ulonglong_type = @intFromEnum(InternPool.Index.c_ulonglong_type),
- c_longdouble_type = @intFromEnum(InternPool.Index.c_longdouble_type),
- f16_type = @intFromEnum(InternPool.Index.f16_type),
- f32_type = @intFromEnum(InternPool.Index.f32_type),
- f64_type = @intFromEnum(InternPool.Index.f64_type),
- f80_type = @intFromEnum(InternPool.Index.f80_type),
- f128_type = @intFromEnum(InternPool.Index.f128_type),
- anyopaque_type = @intFromEnum(InternPool.Index.anyopaque_type),
- bool_type = @intFromEnum(InternPool.Index.bool_type),
- void_type = @intFromEnum(InternPool.Index.void_type),
- type_type = @intFromEnum(InternPool.Index.type_type),
- anyerror_type = @intFromEnum(InternPool.Index.anyerror_type),
- comptime_int_type = @intFromEnum(InternPool.Index.comptime_int_type),
- comptime_float_type = @intFromEnum(InternPool.Index.comptime_float_type),
- noreturn_type = @intFromEnum(InternPool.Index.noreturn_type),
- anyframe_type = @intFromEnum(InternPool.Index.anyframe_type),
- null_type = @intFromEnum(InternPool.Index.null_type),
- undefined_type = @intFromEnum(InternPool.Index.undefined_type),
- enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type),
- atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type),
- atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type),
- calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type),
- address_space_type = @intFromEnum(InternPool.Index.address_space_type),
- float_mode_type = @intFromEnum(InternPool.Index.float_mode_type),
- reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type),
- call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type),
- prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type),
- export_options_type = @intFromEnum(InternPool.Index.export_options_type),
- extern_options_type = @intFromEnum(InternPool.Index.extern_options_type),
- type_info_type = @intFromEnum(InternPool.Index.type_info_type),
- manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type),
- manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type),
- manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type),
- single_const_pointer_to_comptime_int_type = @intFromEnum(InternPool.Index.single_const_pointer_to_comptime_int_type),
- slice_const_u8_type = @intFromEnum(InternPool.Index.slice_const_u8_type),
- slice_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.slice_const_u8_sentinel_0_type),
- optional_noreturn_type = @intFromEnum(InternPool.Index.optional_noreturn_type),
- anyerror_void_error_union_type = @intFromEnum(InternPool.Index.anyerror_void_error_union_type),
- adhoc_inferred_error_set_type = @intFromEnum(InternPool.Index.adhoc_inferred_error_set_type),
- generic_poison_type = @intFromEnum(InternPool.Index.generic_poison_type),
- empty_struct_type = @intFromEnum(InternPool.Index.empty_struct_type),
- undef = @intFromEnum(InternPool.Index.undef),
- zero = @intFromEnum(InternPool.Index.zero),
- zero_usize = @intFromEnum(InternPool.Index.zero_usize),
- zero_u8 = @intFromEnum(InternPool.Index.zero_u8),
- one = @intFromEnum(InternPool.Index.one),
- one_usize = @intFromEnum(InternPool.Index.one_usize),
- one_u8 = @intFromEnum(InternPool.Index.one_u8),
- four_u8 = @intFromEnum(InternPool.Index.four_u8),
- negative_one = @intFromEnum(InternPool.Index.negative_one),
- calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c),
- calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline),
- void_value = @intFromEnum(InternPool.Index.void_value),
- unreachable_value = @intFromEnum(InternPool.Index.unreachable_value),
- null_value = @intFromEnum(InternPool.Index.null_value),
- bool_true = @intFromEnum(InternPool.Index.bool_true),
- bool_false = @intFromEnum(InternPool.Index.bool_false),
- empty_struct = @intFromEnum(InternPool.Index.empty_struct),
- generic_poison = @intFromEnum(InternPool.Index.generic_poison),
+ u0_type,
+ i0_type,
+ u1_type,
+ u8_type,
+ i8_type,
+ u16_type,
+ i16_type,
+ u29_type,
+ u32_type,
+ i32_type,
+ u64_type,
+ i64_type,
+ u80_type,
+ u128_type,
+ i128_type,
+ 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,
+ c_longdouble_type,
+ f16_type,
+ f32_type,
+ f64_type,
+ f80_type,
+ f128_type,
+ anyopaque_type,
+ bool_type,
+ void_type,
+ type_type,
+ anyerror_type,
+ comptime_int_type,
+ comptime_float_type,
+ noreturn_type,
+ anyframe_type,
+ null_type,
+ undefined_type,
+ enum_literal_type,
+ atomic_order_type,
+ atomic_rmw_op_type,
+ calling_convention_type,
+ address_space_type,
+ float_mode_type,
+ reduce_op_type,
+ call_modifier_type,
+ prefetch_options_type,
+ export_options_type,
+ extern_options_type,
+ type_info_type,
+ manyptr_u8_type,
+ manyptr_const_u8_type,
+ manyptr_const_u8_sentinel_0_type,
+ single_const_pointer_to_comptime_int_type,
+ slice_const_u8_type,
+ slice_const_u8_sentinel_0_type,
+ optional_noreturn_type,
+ anyerror_void_error_union_type,
+ adhoc_inferred_error_set_type,
+ generic_poison_type,
+ empty_struct_type,
+ undef,
+ zero,
+ zero_usize,
+ zero_u8,
+ one,
+ one_usize,
+ one_u8,
+ four_u8,
+ negative_one,
+ calling_convention_c,
+ calling_convention_inline,
+ void_value,
+ unreachable_value,
+ null_value,
+ bool_true,
+ bool_false,
+ empty_struct,
+ generic_poison,
/// This tag is here to match Air and InternPool, however it is unused
/// for ZIR purposes.
- var_args_param_type = @intFromEnum(InternPool.Index.var_args_param_type),
+ var_args_param_type = std.math.maxInt(u32) - 1,
/// This Ref does not correspond to any ZIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
- none = @intFromEnum(InternPool.Index.none),
+ none = std.math.maxInt(u32),
+
_,
pub fn toIndex(inst: Ref) ?Index {