FreeTensor
Loading...
Searching...
No Matches
all_defs.h
Go to the documentation of this file.
1#ifndef FREE_TENSOR_ALL_DEFS_H
2#define FREE_TENSOR_ALL_DEFS_H
3
4#include <unordered_set>
5
6#include <analyze/find_stmt.h>
7#include <container_utils.h>
8
9namespace freetensor {
10
14inline std::vector<std::pair<ID, std::string>>
15allDefs(const Stmt &op, const std::unordered_set<AccessType> &atypes =
16 allAccessTypes | ranges::to<std::unordered_set>()) {
17 std::vector<std::pair<ID, std::string>> ret;
18 for (auto &&node : findAllStmt(op, [&](const Stmt &s) {
19 return s->nodeType() == ASTNodeType::VarDef &&
20 atypes.count(s.as<VarDefNode>()->buffer_->atype());
21 })) {
22 ret.emplace_back(node->id(), node.as<VarDefNode>()->name_);
23 }
24 return ret;
25}
26
27} // namespace freetensor
28
29#endif // FREE_TENSOR_ALL_DEFS_H
virtual ASTNodeType nodeType() const =0
Ref< U > as() const
Definition: ref.h:83
Definition: stmt.h:83
SubTree< Buffer > buffer_
Definition: stmt.h:86
std::string name_
Definition: stmt.h:85
Definition: allocator.h:9
std::vector< std::pair< ID, std::string > > allDefs(const Stmt &op, const std::unordered_set< AccessType > &atypes=allAccessTypes|ranges::to< std::unordered_set >())
Definition: all_defs.h:15
constexpr auto allAccessTypes
Definition: access_type.h:68
std::vector< Stmt > findAllStmt(const Stmt &ast, const ID &id)
Definition: find_stmt.cc:32