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 []u32
and []Ref.
u0_typei0_typeu1_typeu8_typei8_typeu16_typei16_typeu29_typeu32_typei32_typeu64_typei64_typeu80_typeu128_typei128_typeusize_typeisize_typec_char_typec_short_typec_ushort_typec_int_typec_uint_typec_long_typec_ulong_typec_longlong_typec_ulonglong_typec_longdouble_typef16_typef32_typef64_typef80_typef128_typeanyopaque_typebool_typevoid_typetype_typeanyerror_typecomptime_int_typecomptime_float_typenoreturn_typeanyframe_typenull_typeundefined_typeenum_literal_typemanyptr_u8_typemanyptr_const_u8_typemanyptr_const_u8_sentinel_0_typesingle_const_pointer_to_comptime_int_typeslice_const_u8_typeslice_const_u8_sentinel_0_typevector_16_i8_typevector_32_i8_typevector_16_u8_typevector_32_u8_typevector_8_i16_typevector_16_i16_typevector_8_u16_typevector_16_u16_typevector_4_i32_typevector_8_i32_typevector_4_u32_typevector_8_u32_typevector_2_i64_typevector_4_i64_typevector_2_u64_typevector_4_u64_typevector_4_f16_typevector_8_f16_typevector_2_f32_typevector_4_f32_typevector_8_f32_typevector_2_f64_typevector_4_f64_typeoptional_noreturn_typeanyerror_void_error_union_typeadhoc_inferred_error_set_typegeneric_poison_typeempty_tuple_typeundefzerozero_usizezero_u8oneone_usizeone_u8four_u8negative_onevoid_valueunreachable_valuenull_valuebool_truebool_falseempty_tuplenone = std.math.maxInt(u32)This Ref does not correspond to any ZIR instruction or constant value and may instead be used as a sentinel to indicate null.
_inst: Refpub fn toIndex(inst: Ref) ?Index {
assert(inst != .none);
const ref_int = @intFromEnum(inst);
if (ref_int >= @intFromEnum(Index.ref_start_index)) {
return @enumFromInt(ref_int - @intFromEnum(Index.ref_start_index));
} else {
return null;
}
}pub const Ref = enum(u32) {
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,
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,
vector_16_i8_type,
vector_32_i8_type,
vector_16_u8_type,
vector_32_u8_type,
vector_8_i16_type,
vector_16_i16_type,
vector_8_u16_type,
vector_16_u16_type,
vector_4_i32_type,
vector_8_i32_type,
vector_4_u32_type,
vector_8_u32_type,
vector_2_i64_type,
vector_4_i64_type,
vector_2_u64_type,
vector_4_u64_type,
vector_4_f16_type,
vector_8_f16_type,
vector_2_f32_type,
vector_4_f32_type,
vector_8_f32_type,
vector_2_f64_type,
vector_4_f64_type,
optional_noreturn_type,
anyerror_void_error_union_type,
adhoc_inferred_error_set_type,
generic_poison_type,
empty_tuple_type,
undef,
zero,
zero_usize,
zero_u8,
one,
one_usize,
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 fn toIndex(inst: Ref) ?Index {
assert(inst != .none);
const ref_int = @intFromEnum(inst);
if (ref_int >= @intFromEnum(Index.ref_start_index)) {
return @enumFromInt(ref_int - @intFromEnum(Index.ref_start_index));
} else {
return null;
}
}
pub fn toIndexAllowNone(inst: Ref) ?Index {
if (inst == .none) return null;
return toIndex(inst);
}
}