1#ifndef HALIDE_EXPR_USES_VAR_H
2#define HALIDE_EXPR_USES_VAR_H
15template<
typename T =
void>
22 void include(
const Expr &e)
override {
29 void include(
const Stmt &s)
override {
36 void visit_name(
const std::string &name) {
39 }
else if (
const Expr *e = scope.
find(name)) {
44 void visit(
const Variable *op)
override {
48 void visit(
const Load *op)
override {
53 void visit(
const Store *op)
override {
58 void visit(
const Call *op)
override {
63 void visit(
const Provide *op)
override {
68 void visit(
const LetStmt *op)
override {
73 void visit(
const Let *op)
override {
78 void visit(
const Realize *op)
override {
83 void visit(
const Allocate *op)
override {
100template<
typename StmtOrExpr,
typename T>
112template<
typename StmtOrExpr>
Subtypes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt)
Defines the base class for things that recursively walk over the IR.
Defines the Scope class, which is used for keeping track of names in a scope while traversing IR.
ExprUsesVars(const Scope< T > &v, const Scope< Expr > *s=nullptr)
A base class for algorithms that walk recursively over the IR without visiting the same node twice.
virtual void include(const Expr &)
By default these methods add the node to the visited set, and return whether or not it was already th...
void visit(const IntImm *) override
These methods should call 'include' on the children to only visit them if they haven't been visited a...
A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Le...
const T2 * find(const std::string &name) const
Returns a const pointer to an entry if it exists in this scope or any containing scope,...
bool contains(const std::string &name) const
Tests if a name is in scope.
PushToken push(const std::string &name, T2 &&value)
Add a new (name, value) pair to the current scope.
void set_containing_scope(const Scope< T > *s)
Set the parent scope.
bool stmt_uses_var(const Stmt &stmt, const std::string &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if a statement references or defines the given variable, additionally considering variables boun...
bool stmt_or_expr_uses_vars(const StmtOrExpr &e, const Scope< T > &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if a statement or expression references or defines any of the variables in a scope,...
bool stmt_uses_vars(const Stmt &stmt, const Scope< T > &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if a statement references or defines any of the variables in a scope, additionally considering v...
bool stmt_or_expr_uses_var(const StmtOrExpr &e, const std::string &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if a statement or expression references or defines the given variable, additionally considering ...
bool expr_uses_vars(const Expr &e, const Scope< T > &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if an expression references or defines any of the variables in a scope, additionally considering...
bool expr_uses_var(const Expr &e, const std::string &v, const Scope< Expr > &s=Scope< Expr >::empty_scope())
Test if an expression references or defines the given variable, additionally considering variables bo...
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
A fragment of Halide syntax.
Allocate a scratch area called with the given name, type, and size.
A let expression, like you might find in a functional language.
The statement form of a let node.
Load a value from a named symbol if predicate is true.
This defines the value of a function at a multi-dimensional location.
Allocate a multi-dimensional buffer of the given type and size.
A reference-counted handle to a statement node.
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.