mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Revert "Fix some usize -> u64 in List patterns"
This reverts commit e8a0b0930d
.
This commit is contained in:
parent
30712d352a
commit
a15cc0589c
3 changed files with 30 additions and 22 deletions
|
@ -1779,13 +1779,10 @@ fn test_to_comparison<'a>(
|
|||
let real_len = env.unique_symbol();
|
||||
let test_len = env.unique_symbol();
|
||||
|
||||
// TODO if we make a LowLevel for getting list lenth that returns
|
||||
// usize, then we could use usize here instead of u64, which
|
||||
// would be slightly more efficient on 32-bit targets.
|
||||
// Would let us change Layout::U64 to Layout::usize(env.target_info)
|
||||
// in here and in various related places that also rely on list length.
|
||||
stores.push((real_len, Layout::U64, real_len_expr));
|
||||
stores.push((test_len, Layout::U64, test_len_expr));
|
||||
let usize_layout = Layout::usize(env.target_info);
|
||||
|
||||
stores.push((real_len, usize_layout, real_len_expr));
|
||||
stores.push((test_len, usize_layout, test_len_expr));
|
||||
|
||||
let comparison = match bound {
|
||||
ListLenBound::Exact => (real_len, Comparator::Eq, test_len),
|
||||
|
@ -2340,7 +2337,7 @@ fn decide_to_branching<'a>(
|
|||
let len_symbol = env.unique_symbol();
|
||||
|
||||
let switch = Stmt::Switch {
|
||||
cond_layout: Layout::U64,
|
||||
cond_layout: Layout::usize(env.target_info),
|
||||
cond_symbol: len_symbol,
|
||||
branches: branches.into_bump_slice(),
|
||||
default_branch: (default_branch_info, env.arena.alloc(default_branch)),
|
||||
|
@ -2355,7 +2352,12 @@ fn decide_to_branching<'a>(
|
|||
arguments: env.arena.alloc([inner_cond_symbol]),
|
||||
});
|
||||
|
||||
Stmt::Let(len_symbol, len_expr, Layout::U64, env.arena.alloc(switch))
|
||||
Stmt::Let(
|
||||
len_symbol,
|
||||
len_expr,
|
||||
Layout::usize(env.target_info),
|
||||
env.arena.alloc(switch),
|
||||
)
|
||||
} else {
|
||||
Stmt::Switch {
|
||||
cond_layout: inner_cond_layout,
|
||||
|
|
|
@ -1397,12 +1397,15 @@ pub(crate) fn build_list_index_probe<'a>(
|
|||
list_sym: Symbol,
|
||||
list_index: &ListIndex,
|
||||
) -> (Symbol, impl DoubleEndedIterator<Item = Store<'a>>) {
|
||||
let usize_layout = Layout::usize(env.target_info);
|
||||
|
||||
let list_index = list_index.0;
|
||||
let index_sym = env.unique_symbol();
|
||||
|
||||
let (opt_len_store, opt_offset_store, index_store) = if list_index >= 0 {
|
||||
let index_expr = Expr::Literal(Literal::Int((list_index as i128).to_ne_bytes()));
|
||||
let index_store = (index_sym, Layout::U64, index_expr);
|
||||
|
||||
let index_store = (index_sym, usize_layout, index_expr);
|
||||
|
||||
(None, None, index_store)
|
||||
} else {
|
||||
|
@ -1427,9 +1430,9 @@ pub(crate) fn build_list_index_probe<'a>(
|
|||
arguments: env.arena.alloc([len_sym, offset_sym]),
|
||||
});
|
||||
|
||||
let len_store = (len_sym, Layout::U64, len_expr);
|
||||
let offset_store = (offset_sym, Layout::U64, offset_expr);
|
||||
let index_store = (index_sym, Layout::U64, index_expr);
|
||||
let len_store = (len_sym, usize_layout, len_expr);
|
||||
let offset_store = (offset_sym, usize_layout, offset_expr);
|
||||
let index_store = (index_sym, usize_layout, index_expr);
|
||||
|
||||
(Some(len_store), Some(offset_store), index_store)
|
||||
};
|
||||
|
@ -1557,6 +1560,8 @@ fn store_list_rest<'a>(
|
|||
if let Some((index, Some(rest_sym))) = opt_rest {
|
||||
is_productive = true;
|
||||
|
||||
let usize_layout = Layout::usize(env.target_info);
|
||||
|
||||
let total_dropped = list_arity.min_len();
|
||||
|
||||
let total_dropped_sym = env.unique_symbol();
|
||||
|
@ -1591,10 +1596,10 @@ fn store_list_rest<'a>(
|
|||
arguments: env.arena.alloc([list_sym, start_sym, rest_len_sym]),
|
||||
});
|
||||
let needed_stores = [
|
||||
(total_dropped_sym, total_dropped_expr, Layout::U64),
|
||||
(list_len_sym, list_len_expr, Layout::U64),
|
||||
(rest_len_sym, rest_len_expr, Layout::U64),
|
||||
(start_sym, start_expr, Layout::U64),
|
||||
(total_dropped_sym, total_dropped_expr, usize_layout),
|
||||
(list_len_sym, list_len_expr, usize_layout),
|
||||
(rest_len_sym, rest_len_expr, usize_layout),
|
||||
(start_sym, start_expr, usize_layout),
|
||||
(*rest_sym, rest_expr, list_layout),
|
||||
];
|
||||
for (sym, expr, lay) in needed_stores.into_iter().rev() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue