24#ifndef TVM_IR_SCOPE_STACK_H_
25#define TVM_IR_SCOPE_STACK_H_
27#include <tvm/ffi/error.h>
60 auto rbegin()
const {
return stack_.rbegin(); }
61 auto rend()
const {
return stack_.rend(); }
64 size_t size()
const {
return stack_.size(); }
67 bool empty()
const {
return stack_.empty(); }
78 TVM_FFI_ICHECK(!stack_.empty());
84 TVM_FFI_ICHECK(!stack_.empty());
98 stack_.emplace_back();
100 std::deque<T>* stack;
101 ~Guard()
noexcept(
false) { stack->pop_back(); }
103 if constexpr (std::is_void_v<
decltype(body())>) {
121 std::deque<T> stack_;
A scope stack for maintaining hierarchical state during IR visiting.
Definition scope_stack.h:54
ScopeStack()
Construct with one initial scope level.
Definition scope_stack.h:57
bool empty() const
Return true if no scopes are active.
Definition scope_stack.h:67
auto WithNewScope(F &&body) -> decltype(body())
Execute body within a new scope.
Definition scope_stack.h:97
size_t size() const
Return the number of active scopes.
Definition scope_stack.h:64
auto rend() const
Definition scope_stack.h:61
T & Current()
Access the current (innermost) scope element.
Definition scope_stack.h:77
auto rbegin() const
Iterate active scopes from innermost to outermost.
Definition scope_stack.h:60
const T & Current() const
Const access to the current (innermost) scope element.
Definition scope_stack.h:83
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41