rename to GetElementPointer, index -> indices

This commit is contained in:
HajagosNorbert 2023-11-13 15:45:38 +01:00
parent 90223022af
commit 9c21ac1388
No known key found for this signature in database
GPG key ID: 807F4444870DB673
12 changed files with 49 additions and 49 deletions

View file

@ -452,15 +452,15 @@ impl<'a, 'r> Ctx<'a, 'r> {
} => self.with_sym_layout(structure, |ctx, _def_line, layout| {
ctx.check_union_at_index(structure, layout, union_layout, tag_id, index)
}),
&Expr::UnionFieldPtrAtIndex {
&Expr::GetElementPointer {
structure,
union_layout,
index,
indices,
..
} => self.with_sym_layout(structure, |ctx, _def_line, layout| {
debug_assert!(index.len() >= 2);
debug_assert!(indices.len() >= 2);
ctx.check_union_field_ptr_at_index(structure, layout, union_layout, index[0] as _, index[1])
ctx.check_union_field_ptr_at_index(structure, layout, union_layout, indices[0] as _, indices[1])
}),
Expr::Array { elem_layout, elems } => {
for elem in elems.iter() {

View file

@ -205,12 +205,12 @@ fn specialize_drops_stmt<'a, 'i>(
// So if we UnionAtIndex, we must know the tag and we can use it to specialize the drop.
environment.symbol_tag.insert(*structure, *tag_id);
}
UnionFieldPtrAtIndex {
structure, index, ..
GetElementPointer {
structure, indices, ..
} => {
// Generated code might know the tag of the union without switching on it.
// So if we UnionFieldPtrAtIndex, we must know the tag and we can use it to specialize the drop.
environment.symbol_tag.insert(*structure, index[0] as u16);
// So if we GetElementPointer, we must know the tag and we can use it to specialize the drop.
environment.symbol_tag.insert(*structure, indices[0] as u16);
}
Array {
elems: children, ..

View file

@ -925,7 +925,7 @@ fn insert_refcount_operations_binding<'a>(
Expr::GetTagId { structure, .. }
| Expr::StructAtIndex { structure, .. }
| Expr::UnionAtIndex { structure, .. }
| Expr::UnionFieldPtrAtIndex { structure, .. } => {
| Expr::GetElementPointer { structure, .. } => {
// All structures are alive at this point and don't have to be copied in order to take an index out/get tag id/copy values to the stack.
// But we do want to make sure to decrement this item if it is the last reference.
let new_stmt = dec_borrowed!([*structure], stmt);
@ -938,7 +938,7 @@ fn insert_refcount_operations_binding<'a>(
match expr {
Expr::StructAtIndex { .. }
| Expr::UnionAtIndex { .. }
| Expr::UnionFieldPtrAtIndex { .. } => {
| Expr::GetElementPointer { .. } => {
insert_inc_stmt(arena, *binding, 1, new_stmt)
}
// No usage of an element of a reference counted symbol. No need to increment.

View file

@ -1892,10 +1892,10 @@ pub enum Expr<'a> {
union_layout: UnionLayout<'a>,
index: u64,
},
UnionFieldPtrAtIndex {
GetElementPointer {
structure: Symbol,
union_layout: UnionLayout<'a>,
index: &'a [u64],
indices: &'a [u64],
},
Array {
@ -2152,12 +2152,12 @@ impl<'a> Expr<'a> {
} => text!(alloc, "UnionAtIndex (Id {tag_id}) (Index {index}) ")
.append(symbol_to_doc(alloc, *structure, pretty)),
UnionFieldPtrAtIndex {
GetElementPointer {
structure,
index,
indices,
..
} => {
let it = index.iter().map(|num| alloc.as_string(num));
let it = indices.iter().map(|num| alloc.as_string(num));
let it = alloc.intersperse(it, ", ");
text!(
alloc,
@ -7947,14 +7947,14 @@ fn substitute_in_expr<'a>(
},
// currently only used for tail recursion modulo cons (TRMC)
UnionFieldPtrAtIndex {
GetElementPointer {
structure,
index,
indices,
union_layout,
} => match substitute(subs, *structure) {
Some(structure) => Some(UnionFieldPtrAtIndex {
Some(structure) => Some(GetElementPointer {
structure,
index,
indices,
union_layout: *union_layout,
}),
None => None,

View file

@ -907,13 +907,13 @@ impl<'a> TrmcEnv<'a> {
reuse: None,
};
let index = vec![in env.arena; cons_info.tag_id as u64, recursive_field_index as u64].into_bump_slice();
let indices = vec![in env.arena; cons_info.tag_id as u64, recursive_field_index as u64].into_bump_slice();
let let_tag = |next| Stmt::Let(*symbol, tag_expr, *layout, next);
let get_reference_expr = Expr::UnionFieldPtrAtIndex {
let get_reference_expr = Expr::GetElementPointer {
structure: *symbol,
union_layout: cons_info.tag_layout,
index,
indices,
};
let new_hole_symbol = env.named_unique_symbol("newHole");
@ -1091,7 +1091,7 @@ fn expr_contains_symbol(expr: &Expr, needle: Symbol) -> bool {
Expr::StructAtIndex { structure, .. }
| Expr::GetTagId { structure, .. }
| Expr::UnionAtIndex { structure, .. }
| Expr::UnionFieldPtrAtIndex { structure, .. } => needle == *structure,
| Expr::GetElementPointer { structure, .. } => needle == *structure,
Expr::Array { elems, .. } => elems.iter().any(|element| match element {
crate::ir::ListLiteralElement::Literal(_) => false,
crate::ir::ListLiteralElement::Symbol(symbol) => needle == *symbol,