pub const Ref = enum(u32) {
u0_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,
u256_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,
ptr_usize_type,
ptr_const_comptime_int_type,
manyptr_u8_type,
manyptr_const_u8_type,
manyptr_const_u8_sentinel_0_type,
slice_const_u8_type,
slice_const_u8_sentinel_0_type,
manyptr_const_slice_const_u8_type,
slice_const_slice_const_u8_type,
optional_type_type,
manyptr_const_type_type,
slice_const_type_type,
vector_8_i8_type,
vector_16_i8_type,
vector_32_i8_type,
vector_64_i8_type,
vector_1_u8_type,
vector_2_u8_type,
vector_4_u8_type,
vector_8_u8_type,
vector_16_u8_type,
vector_32_u8_type,
vector_64_u8_type,
vector_2_i16_type,
vector_4_i16_type,
vector_8_i16_type,
vector_16_i16_type,
vector_32_i16_type,
vector_4_u16_type,
vector_8_u16_type,
vector_16_u16_type,
vector_32_u16_type,
vector_2_i32_type,
vector_4_i32_type,
vector_8_i32_type,
vector_16_i32_type,
vector_4_u32_type,
vector_8_u32_type,
vector_16_u32_type,
vector_2_i64_type,
vector_4_i64_type,
vector_8_i64_type,
vector_2_u64_type,
vector_4_u64_type,
vector_8_u64_type,
vector_1_u128_type,
vector_2_u128_type,
vector_1_u256_type,
vector_4_f16_type,
vector_8_f16_type,
vector_16_f16_type,
vector_32_f16_type,
vector_2_f32_type,
vector_4_f32_type,
vector_8_f32_type,
vector_16_f32_type,
vector_2_f64_type,
vector_4_f64_type,
vector_8_f64_type,
optional_noreturn_type,
anyerror_void_error_union_type,
adhoc_inferred_error_set_type,
generic_poison_type,
empty_tuple_type,
undef,
undef_bool,
undef_usize,
undef_u1,
zero,
zero_usize,
zero_u1,
zero_u8,
one,
one_usize,
one_u1,
one_u8,
four_u8,
negative_one,
void_value,
unreachable_value,
null_value,
bool_true,
bool_false,
empty_tuple,
/// This Ref does not correspond to any ZIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
none = std.math.maxInt(u32),
_,
pub const static_len = @typeInfo(@This()).@"enum".field_names.len - 1;
pub fn toIndex(inst: Ref) ?Index {
assert(inst != .none);
const ref_int = @backingInt(inst);
if (ref_int >= static_len) {
return @fromBackingInt(@intCast(ref_int - static_len));
} else {
return null;
}
}
pub fn toIndexAllowNone(inst: Ref) ?Index {
if (inst == .none) return null;
return toIndex(inst);
}
}
A reference to ZIR instruction, or to an InternPool index, or neither.
If the integer tag value is < InternPool.static_len, then it corresponds to an InternPool index. Otherwise, this refers to a ZIR instruction.
The tag type is specified so that it is safe to bitcast between
[]u32and[]Ref.