Skip to content

Commit

Permalink
rename to GetElementPointer, index -> indices
Browse files Browse the repository at this point in the history
  • Loading branch information
HajagosNorbert committed Nov 13, 2023
1 parent 9022302 commit 9c21ac1
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 49 deletions.
10 changes: 5 additions & 5 deletions crates/compiler/alias_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1436,15 +1436,15 @@ fn expr_spec<'a>(
builder.add_get_tuple_field(block, variant_id, index)
}
},
UnionFieldPtrAtIndex {
index,
GetElementPointer {
indices,
structure,
union_layout,
..
} => {
debug_assert!(index.len() >= 2);
let tag_id = index[0] as u32;
let index = index[1];
debug_assert!(indices.len() >= 2);
let tag_id = indices[0] as u32;
let index = indices[1];
let tag_value_id = env.symbols[structure];

let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
Expand Down
10 changes: 5 additions & 5 deletions crates/compiler/gen_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<'a> LastSeenMap<'a> {
Expr::UnionAtIndex { structure, .. } => {
self.set_last_seen(*structure, stmt);
}
Expr::UnionFieldPtrAtIndex { structure, .. } => {
Expr::GetElementPointer { structure, .. } => {
self.set_last_seen(*structure, stmt);
}
Expr::Array { elems, .. } => {
Expand Down Expand Up @@ -849,14 +849,14 @@ trait Backend<'a> {
} => {
self.load_union_at_index(sym, structure, *tag_id, *index, union_layout);
}
Expr::UnionFieldPtrAtIndex {
Expr::GetElementPointer {
structure,
union_layout,
index,
indices,
..
} => {
debug_assert!(index.len() >= 2);
self.load_union_field_ptr_at_index(sym, structure, index[0] as u16, index[1], union_layout);
debug_assert!(indices.len() >= 2);
self.load_union_field_ptr_at_index(sym, structure, indices[0] as u16, indices[1], union_layout);
}
Expr::GetTagId {
structure,
Expand Down
10 changes: 5 additions & 5 deletions crates/compiler/gen_llvm/src/llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,15 +2003,15 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
}
}

UnionFieldPtrAtIndex {
GetElementPointer {
structure,
index,
indices,
union_layout,
..
} => {
debug_assert!(index.len() >= 2);
let tag_id = index[0];
let index = index[1] as usize;
debug_assert!(indices.len() >= 2);
let tag_id = indices[0];
let index = indices[1] as usize;
// cast the argument bytes into the desired shape for this tag
let argument = scope.load_symbol(structure);
let ret_repr = layout_interner.get_repr(layout);
Expand Down
10 changes: 5 additions & 5 deletions crates/compiler/gen_wasm/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,18 +1099,18 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
index,
} => self.expr_union_at_index(*structure, *tag_id, union_layout, *index, sym),

Expr::UnionFieldPtrAtIndex {
Expr::GetElementPointer {
structure,
union_layout,
index,
indices,
..
} => {
debug_assert!(index.len() >= 2);
debug_assert!(indices.len() >= 2);
self.expr_union_field_ptr_at_index(
*structure,
index[0] as u16,
indices[0] as u16,
union_layout,
index[1],
indices[1],
storage,
)
}
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/mono/src/debug/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/mono/src/drop_specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ..
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/mono/src/inc_dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions crates/compiler/mono/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/mono/src/tail_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/test_mono/generated/linked_list_filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ procedure Test.2 (#Derived_gen.0, #Derived_gen.1):
if Test.19 then
let #Derived_gen.9 : [<rnu><null>, C I64 *self] = NullPointer;
let Test.20 : [<rnu><null>, C I64 *self] = Reuse #Derived_gen.14 UpdateModeId { id: 1 } TagId(0) Test.7 #Derived_gen.9;
let #Derived_gen.10 : Ptr([<rnu><null>, C I64 *self]) = UnionFieldPtrAtIndex (Id 0) (Index 1) Test.20;
let #Derived_gen.10 : Ptr([<rnu><null>, C I64 *self]) = GetElementPointer (Indices [0, 1]) Test.20;
let #Derived_gen.11 : {} = lowlevel PtrStore #Derived_gen.5 Test.20;
jump #Derived_gen.4 Test.8 Test.5 #Derived_gen.10 #Derived_gen.6;
else
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/test_mono/generated/linked_list_map.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ procedure Test.2 (#Derived_gen.0, #Derived_gen.1):
let Test.20 : I64 = CallByName Test.10 Test.7;
let #Derived_gen.9 : [<rnu><null>, C I64 *self] = NullPointer;
let Test.19 : [<rnu><null>, C I64 *self] = Reuse #Derived_gen.14 UpdateModeId { id: 1 } TagId(0) Test.20 #Derived_gen.9;
let #Derived_gen.10 : Ptr([<rnu><null>, C I64 *self]) = UnionFieldPtrAtIndex (Id 0) (Index 1) Test.19;
let #Derived_gen.10 : Ptr([<rnu><null>, C I64 *self]) = GetElementPointer (Indices [0, 1]) Test.19;
let #Derived_gen.11 : {} = lowlevel PtrStore #Derived_gen.5 Test.19;
jump #Derived_gen.4 Test.4 Test.8 #Derived_gen.10 #Derived_gen.6;
in
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler/test_mono/generated/rb_tree_fbip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ procedure Test.3 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2):
let Test.232 : Int1 = false;
let #Derived_gen.10 : [<rnu>C *self I64 *self I32 Int1, <null>] = NullPointer;
let Test.231 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reuse #Derived_gen.166 UpdateModeId { id: 56 } TagId(1) #Derived_gen.10 Test.18 Test.19 Test.17 Test.232;
let #Derived_gen.11 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = UnionFieldPtrAtIndex (Id 1) (Index 0) Test.231;
let #Derived_gen.11 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = GetElementPointer (Indices [1, 0]) Test.231;
let #Derived_gen.12 : {} = lowlevel PtrStore #Derived_gen.6 Test.231;
jump #Derived_gen.5 Test.16 Test.10 Test.11 #Derived_gen.11 #Derived_gen.7;
in
Expand Down Expand Up @@ -206,7 +206,7 @@ procedure Test.3 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2):
let Test.170 : Int1 = false;
let #Derived_gen.21 : [<rnu>C *self I64 *self I32 Int1, <null>] = NullPointer;
let Test.169 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reuse #Derived_gen.288 UpdateModeId { id: 196 } TagId(1) Test.16 Test.18 #Derived_gen.21 Test.17 Test.170;
let #Derived_gen.22 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = UnionFieldPtrAtIndex (Id 1) (Index 2) Test.169;
let #Derived_gen.22 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = GetElementPointer (Indices [1, 2]) Test.169;
let #Derived_gen.23 : {} = lowlevel PtrStore #Derived_gen.6 Test.169;
jump #Derived_gen.5 Test.19 Test.10 Test.11 #Derived_gen.22 #Derived_gen.7;
in
Expand Down Expand Up @@ -412,7 +412,7 @@ procedure Test.3 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2):
let Test.249 : Int1 = true;
let #Derived_gen.34 : [<rnu>C *self I64 *self I32 Int1, <null>] = NullPointer;
let Test.248 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reuse #Derived_gen.364 UpdateModeId { id: 284 } TagId(1) #Derived_gen.34 Test.98 Test.99 Test.97 Test.249;
let #Derived_gen.35 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = UnionFieldPtrAtIndex (Id 1) (Index 0) Test.248;
let #Derived_gen.35 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = GetElementPointer (Indices [1, 0]) Test.248;
let #Derived_gen.36 : {} = lowlevel PtrStore #Derived_gen.6 Test.248;
jump #Derived_gen.5 Test.96 Test.10 Test.11 #Derived_gen.35 #Derived_gen.7;
else
Expand All @@ -421,7 +421,7 @@ procedure Test.3 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2):
let Test.245 : Int1 = true;
let #Derived_gen.37 : [<rnu>C *self I64 *self I32 Int1, <null>] = NullPointer;
let Test.244 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reuse #Derived_gen.364 UpdateModeId { id: 284 } TagId(1) Test.96 Test.98 #Derived_gen.37 Test.97 Test.245;
let #Derived_gen.38 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = UnionFieldPtrAtIndex (Id 1) (Index 2) Test.244;
let #Derived_gen.38 : Ptr([<rnu>C *self I64 *self I32 Int1, <null>]) = GetElementPointer (Indices [1, 2]) Test.244;
let #Derived_gen.39 : {} = lowlevel PtrStore #Derived_gen.6 Test.244;
jump #Derived_gen.5 Test.99 Test.10 Test.11 #Derived_gen.38 #Derived_gen.7;
else
Expand Down

0 comments on commit 9c21ac1

Please sign in to comment.