1 #ifndef HALIDE_EXPR_USES_VAR_H 2 #define HALIDE_EXPR_USES_VAR_H 15 template<
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) {
40 include(scope.
get(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 {
100 template<
typename StmtOrExpr,
typename T>
112 template<
typename StmtOrExpr>
117 return stmt_or_expr_uses_vars<StmtOrExpr, void>(e, vars, s);
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...
A fragment of Halide syntax.
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...
A reference-counted handle to a statement node.
Load a value from a named symbol if predicate is true.
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...
A base class for algorithms that walk recursively over the IR without visiting the same node twice...
Allocate a multi-dimensional buffer of the given type and size.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
void push(const std::string &name, T2 &&value)
Add a new (name, value) pair to the current scope.
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.
Allocate a scratch area called with the given name, type, and size.
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...
A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Le...
T2 get(const std::string &name) const
Retrieve the value referred to by a name.
This defines the value of a function at a multi-dimensional location.
void visit(const IntImm *) override
These methods should call 'include' on the children to only visit them if they haven't been visited a...
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 ...
Not visible externally, similar to 'static' linkage in C.
Defines the Scope class, which is used for keeping track of names in a scope while traversing IR...
A let expression, like you might find in a functional language.
Subtypes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt) ...
The statement form of a let node.
bool contains(const std::string &name) const
Tests if a name is in scope.
ExprUsesVars(const Scope< T > &v, const Scope< Expr > *s=nullptr)
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...
Defines the base class for things that recursively walk over the IR.