mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Refactor: get rid of split_vars, construct valid LET ops
In FunC (and in Tolk before), tensor vars (actually occupying several stack slots) were represented as a single var in terms or IR vars (Ops): > var a = (1, 2); > LET (_i) = (_1, _2) Now, every tensor of N stack slots is represented as N IR vars. > LET (_i, _j) = (_1, _2) This will give an ability to control access to parts of a tensor when implementing `tensorVar.0` syntax.
This commit is contained in:
parent
989629a832
commit
565bc59735
17 changed files with 100 additions and 217 deletions
|
@ -26,40 +26,6 @@ namespace tolk {
|
|||
*
|
||||
*/
|
||||
|
||||
int CodeBlob::split_vars(bool strict) {
|
||||
int n = var_cnt, changes = 0;
|
||||
for (int j = 0; j < var_cnt; j++) {
|
||||
TmpVar& var = vars[j];
|
||||
int width_j = var.v_type->calc_width_on_stack();
|
||||
if (strict && width_j < 0) {
|
||||
throw ParseError{var.where, "variable does not have fixed width, cannot manipulate it"};
|
||||
}
|
||||
if (width_j == 1) {
|
||||
continue;
|
||||
}
|
||||
std::vector<TypePtr> comp_types;
|
||||
var.v_type->extract_components(comp_types);
|
||||
tolk_assert(width_j <= 254 && n <= 0x7fff00);
|
||||
tolk_assert((unsigned)width_j == comp_types.size());
|
||||
var.coord = ~((n << 8) + width_j);
|
||||
for (int i = 0; i < width_j; i++) {
|
||||
auto v = create_var(comp_types[i], vars[j].v_sym, vars[j].where);
|
||||
tolk_assert(v == n + i);
|
||||
tolk_assert(vars[v].idx == v);
|
||||
vars[v].coord = ((int)j << 8) + i + 1;
|
||||
}
|
||||
n += width_j;
|
||||
++changes;
|
||||
}
|
||||
if (!changes) {
|
||||
return 0;
|
||||
}
|
||||
for (auto& op : ops) {
|
||||
op.split_vars(vars);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
bool CodeBlob::compute_used_code_vars() {
|
||||
VarDescrList empty_var_info;
|
||||
return compute_used_code_vars(ops, empty_var_info, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue