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