Loading...
Searching...
No Matches
Halide::Internal::Scope< T > Class Template Reference

A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Let or a LetStmt, and that it should hide previous values with the same name until you leave the Let or LetStmt nodes This class helps with that. More...

`#include <Scope.h>`

## Classes

struct | PushToken
class | const_iterator
| Iterate through the scope. More...

## Public Member Functions

| Scope ()=default
| Scope (Scope &&that) noexcept=default
Scope & | operator= (Scope &&that) noexcept=default
| Scope (const Scope< T > &)=delete
Scope< T > & | operator= (const Scope< T > &)=delete
void | set_containing_scope (const Scope< T > *s)
| Set the parent scope.
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>
T2 | get (const std::string &name) const
| Retrieve the value referred to by a name.
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>
T2 & | ref (const std::string &name)
| Return a reference to an entry.
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>
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, or nullptr if it does not.
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>
T2 * | shallow_find (const std::string &name)
| A version of find that returns a non-const pointer, but ignores containing scope.
bool | contains (const std::string &name) const
| Tests if a name is in scope.
size_t | count (const std::string &name) const
| How many nested definitions of a single name exist?
size_t | size () const
| How many distinct names exist (does not count nested definitions of the same name).
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>
PushToken | push (const std::string &name, T2 &&value)
| Add a new (name, value) pair to the current scope.
template<typename T2 = T, typename = typename std::enable_if<std::is_same<T2, void>::value>::type>
PushToken | push (const std::string &name)
void | pop (const std::string &name)
| A name goes out of scope.
void | pop (PushToken p)
| Pop a name using a token returned by push instead of a string.
const_iterator | cbegin () const
const_iterator | cend () const
void | swap (Scope< T > &other) noexcept

## Static Public Member Functions

static const Scope< T > & | empty_scope ()
| A const ref to an empty scope.

## Detailed Description

template<typename T = void>
class Halide::Internal::Scope< T >

A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Let or a LetStmt, and that it should hide previous values with the same name until you leave the Let or LetStmt nodes This class helps with that.

Definition at line 94 of file Scope.h.

## Constructor & Destructor Documentation

## Scope() [1/3]

template<typename T = void>

Halide::Internal::Scope< T >::Scope | ( |  | ) |

default

Referenced by empty_scope(), operator=(), operator=(), Scope(), Scope(), set_containing_scope(), and swap().

## Scope() [2/3]

template<typename T = void>

Halide::Internal::Scope< T >::Scope | ( | Scope< T > && | that | ) |

default noexcept

References Scope().

## Scope() [3/3]

template<typename T = void>

Halide::Internal::Scope< T >::Scope | ( | const Scope< T > & |  | ) |

delete

References Scope().

## Member Function Documentation

## operator=() [1/2]

template<typename T = void>

Scope & Halide::Internal::Scope< T >::operator= | ( | Scope< T > && | that | ) |

default noexcept

References Scope().

## operator=() [2/2]

template<typename T = void>

Scope< T > & Halide::Internal::Scope< T >::operator= | ( | const Scope< T > & |  | ) |

delete

References Scope().

## set_containing_scope()

template<typename T = void>

void Halide::Internal::Scope< T >::set_containing_scope | ( | const Scope< T > * | s | ) |

inline

Set the parent scope.

If lookups fail in this scope, they check the containing scope before returning an error. Caller is responsible for managing the memory of the containing scope.

Definition at line 113 of file Scope.h.

References Scope().

## empty_scope()

template<typename T = void>

const Scope< T > & Halide::Internal::Scope< T >::empty_scope | ( |  | ) |

inline static

A const ref to an empty scope.

Useful for default function arguments, which would otherwise require a copy constructor (with llvm in c++98 mode)

Definition at line 120 of file Scope.h.

References Scope().

Referenced by Halide::Internal::box_provided(), Halide::Internal::box_provided(), Halide::Internal::box_required(), Halide::Internal::box_required(), Halide::Internal::box_touched(), Halide::Internal::box_touched(), Halide::Internal::boxes_provided(), Halide::Internal::boxes_provided(), Halide::Internal::boxes_required(), Halide::Internal::boxes_required(), Halide::Internal::boxes_touched(), Halide::Internal::boxes_touched(), Halide::Internal::can_prove(), Halide::Internal::constant_integer_bounds(), Halide::Internal::derivative_bounds(), Halide::Internal::expr_uses_var(), Halide::Internal::expr_uses_vars(), Halide::Internal::find_constant_bound(), Halide::Internal::is_monotonic(), Halide::Internal::lossless_cast(), Halide::Internal::simplify(), Halide::Internal::simplify(), Halide::Internal::solve_expression(), Halide::Internal::stmt_or_expr_uses_var(), Halide::Internal::stmt_or_expr_uses_vars(), Halide::Internal::stmt_uses_var(), and Halide::Internal::stmt_uses_vars().

## get()

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>

T2 Halide::Internal::Scope< T >::get | ( | const std::string & | name | ) | const

inline

Retrieve the value referred to by a name.

Definition at line 128 of file Scope.h.

References internal_error.

## ref()

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>

T2 & Halide::Internal::Scope< T >::ref | ( | const std::string & | name | ) |

inline

Return a reference to an entry.

Does not consider the containing scope.

Definition at line 144 of file Scope.h.

References internal_error.

## find()

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>

const T2 * Halide::Internal::Scope< T >::find | ( | const std::string & | name | ) | const

inline

Returns a const pointer to an entry if it exists in this scope or any containing scope, or nullptr if it does not.

Use this instead of if (scope.contains(foo)) { ... scope.get(foo) ... } to avoid doing two lookups.

Definition at line 159 of file Scope.h.

## shallow_find()

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>

T2 * Halide::Internal::Scope< T >::shallow_find | ( | const std::string & | name | ) |

inline

A version of find that returns a non-const pointer, but ignores containing scope.

Definition at line 175 of file Scope.h.

## contains()

template<typename T = void>

bool Halide::Internal::Scope< T >::contains | ( | const std::string & | name | ) | const

inline

Tests if a name is in scope.

If you plan to use the value if it is, call find instead.

Definition at line 186 of file Scope.h.

## count()

template<typename T = void>

size_t Halide::Internal::Scope< T >::count | ( | const std::string & | name | ) | const

inline

How many nested definitions of a single name exist?

Definition at line 199 of file Scope.h.

## size()

template<typename T = void>

size_t Halide::Internal::Scope< T >::size | ( |  | ) | const

inline

How many distinct names exist (does not count nested definitions of the same name).

Definition at line 209 of file Scope.h.

## push() [1/2]

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<!std::is_same<T2, void>::value>::type>

PushToken Halide::Internal::Scope< T >::push | ( | const std::string & | name,
|  | T2 && | value )

inline

Add a new (name, value) pair to the current scope.

Hide old values that have this name until we pop this name. Returns a token that can be used to pop the same value without doing a fresh lookup.

Definition at line 223 of file Scope.h.

Referenced by Halide::Internal::stmt_or_expr_uses_var().

## push() [2/2]

template<typename T = void>
template<typename T2 = T, typename = typename std::enable_if<std::is_same<T2, void>::value>::type>

PushToken Halide::Internal::Scope< T >::push | ( | const std::string & | name | ) |

inline

Definition at line 231 of file Scope.h.

## pop() [1/2]

template<typename T = void>

void Halide::Internal::Scope< T >::pop | ( | const std::string & | name | ) |

inline

A name goes out of scope.

Restore whatever its old value was (or remove it entirely if there was nothing else of the same name in an outer scope)

Definition at line 240 of file Scope.h.

References internal_assert.

## pop() [2/2]

template<typename T = void>

void Halide::Internal::Scope< T >::pop | ( | PushToken | p | ) |

inline

Pop a name using a token returned by push instead of a string.

Definition at line 251 of file Scope.h.

References Halide::Internal::Scope< T >::PushToken::iter.

## cbegin()

template<typename T = void>

const_iterator Halide::Internal::Scope< T >::cbegin | ( |  | ) | const

inline

Definition at line 292 of file Scope.h.

Referenced by Halide::Internal::operator<<().

## cend()

template<typename T = void>

const_iterator Halide::Internal::Scope< T >::cend | ( |  | ) | const

inline

Definition at line 296 of file Scope.h.

Referenced by Halide::Internal::operator<<().

## swap()

template<typename T = void>

void Halide::Internal::Scope< T >::swap | ( | Scope< T > & | other | ) |

inline noexcept

Definition at line 300 of file Scope.h.

References Scope().

The documentation for this class was generated from the following files:

- src/ModulusRemainder.h
- src/Scope.h