1 | #pragma once |
2 | |
3 | #include <memory> |
4 | #include <unordered_map> |
5 | #include <functional> |
6 | #include <vector> |
7 | |
8 | // This file groups the set of helpers that need the Expr associated with a |
9 | // given SNode. Expr is part of the frontend, which somehow depends on the |
10 | // files inside "taichi/program". To make SNode fairly low-level and depend |
11 | // on less, we thus move SNode-Expr related utils away from SNode itself. |
12 | namespace taichi::lang { |
13 | class Expr; |
14 | class SNode; |
15 | class FieldExpression; |
16 | |
17 | using SNodeFieldMap = |
18 | std::unordered_map<const SNode *, std::shared_ptr<FieldExpression>>; |
19 | |
20 | void place_child(Expr *expr_arg, |
21 | const std::vector<int> &offset, |
22 | int id_in_bit_struct, |
23 | SNode *parent, |
24 | SNodeFieldMap *snode_to_exprs); |
25 | |
26 | void make_lazy_place(SNode *snode, |
27 | SNodeFieldMap *snode_to_fields, |
28 | const std::function<void(std::unique_ptr<SNode> &, |
29 | std::vector<Expr> &)> &collect); |
30 | |
31 | } // namespace taichi::lang |
32 | |