Change name of "dataful" variant to "untagged"
This is in anticipation of a new enum layout, in which the niche optimization may be applied even when multiple variants have data.
This commit is contained in:
parent
f91ca2878a
commit
1a08b96a0b
12 changed files with 46 additions and 45 deletions
|
@ -99,7 +99,7 @@ const SINGLE_VARIANT_VIRTUAL_DISR: u64 = 0;
|
|||
/// compiler versions.
|
||||
///
|
||||
/// Niche-tag enums have one special variant, usually called the
|
||||
/// "dataful variant". This variant has a field that
|
||||
/// "untagged variant". This variant has a field that
|
||||
/// doubles as the tag of the enum. The variant is active when the value of
|
||||
/// that field is within a pre-defined range. Therefore the variant struct
|
||||
/// has a `DISCR_BEGIN` and `DISCR_END` field instead of `DISCR_EXACT` in
|
||||
|
@ -249,7 +249,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
None,
|
||||
),
|
||||
Variants::Multiple {
|
||||
tag_encoding: TagEncoding::Niche { dataful_variant, .. },
|
||||
tag_encoding: TagEncoding::Niche { untagged_variant, .. },
|
||||
ref variants,
|
||||
tag_field,
|
||||
..
|
||||
|
@ -260,7 +260,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
enum_type_di_node,
|
||||
variants.indices(),
|
||||
tag_field,
|
||||
Some(dataful_variant),
|
||||
Some(untagged_variant),
|
||||
),
|
||||
}
|
||||
},
|
||||
|
@ -391,7 +391,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
|
|||
enum_type_di_node: &'ll DIType,
|
||||
variant_indices: impl Iterator<Item = VariantIdx> + Clone,
|
||||
tag_field: usize,
|
||||
dataful_variant_index: Option<VariantIdx>,
|
||||
untagged_variant_index: Option<VariantIdx>,
|
||||
) -> SmallVec<&'ll DIType> {
|
||||
let tag_base_type = super::tag_base_type(cx, enum_type_and_layout);
|
||||
|
||||
|
@ -436,7 +436,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
|
|||
variant_names_type_di_node,
|
||||
tag_base_type,
|
||||
tag_field,
|
||||
dataful_variant_index,
|
||||
untagged_variant_index,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
|||
enum_or_generator_type_and_layout: TyAndLayout<'tcx>,
|
||||
enum_or_generator_type_di_node: &'ll DIType,
|
||||
variant_index: VariantIdx,
|
||||
dataful_variant_index: Option<VariantIdx>,
|
||||
untagged_variant_index: Option<VariantIdx>,
|
||||
variant_struct_type_di_node: &'ll DIType,
|
||||
variant_names_type_di_node: &'ll DIType,
|
||||
tag_base_type_di_node: &'ll DIType,
|
||||
|
@ -517,7 +517,7 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
|||
}
|
||||
}
|
||||
DiscrResult::Range(min, max) => {
|
||||
assert_eq!(Some(variant_index), dataful_variant_index);
|
||||
assert_eq!(Some(variant_index), untagged_variant_index);
|
||||
if is_128_bits {
|
||||
DiscrKind::Range128(min, max)
|
||||
} else {
|
||||
|
@ -757,7 +757,7 @@ fn build_union_fields_for_direct_tag_enum_or_generator<'ll, 'tcx>(
|
|||
discr_type_di_node: &'ll DIType,
|
||||
tag_base_type: Ty<'tcx>,
|
||||
tag_field: usize,
|
||||
dataful_variant_index: Option<VariantIdx>,
|
||||
untagged_variant_index: Option<VariantIdx>,
|
||||
) -> SmallVec<&'ll DIType> {
|
||||
let tag_base_type_di_node = type_di_node(cx, tag_base_type);
|
||||
let mut unions_fields = SmallVec::with_capacity(variant_field_infos.len() + 1);
|
||||
|
@ -776,7 +776,7 @@ fn build_union_fields_for_direct_tag_enum_or_generator<'ll, 'tcx>(
|
|||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
variant_member_info.variant_index,
|
||||
dataful_variant_index,
|
||||
untagged_variant_index,
|
||||
variant_member_info.variant_struct_type_di_node,
|
||||
discr_type_di_node,
|
||||
tag_base_type_di_node,
|
||||
|
|
|
@ -417,7 +417,7 @@ impl DiscrResult {
|
|||
/// Returns the discriminant value corresponding to the variant index.
|
||||
///
|
||||
/// Will return `None` if there is less than two variants (because then the enum won't have)
|
||||
/// a tag, and if this is the dataful variant of a niche-layout enum (because then there is no
|
||||
/// a tag, and if this is the untagged variant of a niche-layout enum (because then there is no
|
||||
/// single discriminant value).
|
||||
fn compute_discriminant_value<'ll, 'tcx>(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
|
@ -430,11 +430,11 @@ fn compute_discriminant_value<'ll, 'tcx>(
|
|||
enum_type_and_layout.ty.discriminant_for_variant(cx.tcx, variant_index).unwrap().val,
|
||||
),
|
||||
&Variants::Multiple {
|
||||
tag_encoding: TagEncoding::Niche { ref niche_variants, niche_start, dataful_variant },
|
||||
tag_encoding: TagEncoding::Niche { ref niche_variants, niche_start, untagged_variant },
|
||||
tag,
|
||||
..
|
||||
} => {
|
||||
if variant_index == dataful_variant {
|
||||
if variant_index == untagged_variant {
|
||||
let valid_range = enum_type_and_layout
|
||||
.for_variant(cx, variant_index)
|
||||
.largest_niche
|
||||
|
|
|
@ -378,7 +378,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
|
|||
///
|
||||
/// The DW_AT_discr_value is optional, and is omitted if
|
||||
/// - This is the only variant of a univariant enum (i.e. their is no discriminant)
|
||||
/// - This is the "dataful" variant of a niche-layout enum
|
||||
/// - This is the "untagged" variant of a niche-layout enum
|
||||
/// (where only the other variants are identified by a single value)
|
||||
///
|
||||
/// There is only ever a single member, the type of which is a struct that describes the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue