FreeTensor
Loading...
Searching...
No Matches
hoist_selected_var.h
Go to the documentation of this file.
1#ifndef FREE_TENSOR_HOIST_SELECTED_VAR_H
2#define FREE_TENSOR_HOIST_SELECTED_VAR_H
3
5#include <mutator.h>
6#include <selector.h>
7
8namespace freetensor {
9
10class HoistSelectedVar : public SymbolTable<Mutator> {
12
13 const std::unordered_set<ID> &toHoist_;
14
15 public:
16 HoistSelectedVar(const std::unordered_set<ID> &toHoist)
17 : toHoist_(toHoist) {}
18
19 protected:
20 using BaseClass::visit;
21 // We use unsual modify-before-recursion in this Mutator, and therefore
22 // there is no need to hoist a VarDef over another VarDef, and we can keep
23 // relative position of VarDef nodes
24 Stmt visit(const For &op) override;
25 Stmt visit(const If &op) override;
26 Stmt visit(const Assert &op) override;
27 Stmt visit(const Assume &op) override;
28 Stmt visit(const StmtSeq &op) override;
29};
30
47Stmt hoistSelectedVar(const Stmt &op, const std::string &selector);
48Stmt hoistSelectedVar(const Stmt &op, const Ref<Selector> &selector);
51} // namespace freetensor
52
53#endif // FREE_TENSOR_HOIST_SELECTED_VAR_H
Definition: hoist_selected_var.h:10
HoistSelectedVar(const std::unordered_set< ID > &toHoist)
Definition: hoist_selected_var.h:16
Stmt visit(const For &op) override
Definition: hoist_selected_var.cc:10
Definition: symbol_table.h:122
BaseClass::StmtRetType visit(const VarDef &op) override
Definition: symbol_table.h:167
Definition: allocator.h:9
Stmt hoistSelectedVar(const Stmt &op, const std::string &selector)
Definition: hoist_selected_var.cc:166
Ref< StmtNode > Stmt
Definition: ast.h:152