24#ifndef TVM_IR_SCOPE_STACK_H_
25#define TVM_IR_SCOPE_STACK_H_
27#include <tvm/ffi/error.h>
61 size_t size()
const {
return stack_.size(); }
64 bool empty()
const {
return stack_.empty(); }
95 stack_.emplace_back();
98 ~Guard()
noexcept(
false) { stack->pop_back(); }
100 if constexpr (std::is_void_v<
decltype(body())>) {
118 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:64
auto WithNewScope(F &&body) -> decltype(body())
Execute body within a new scope.
Definition scope_stack.h:94
size_t size() const
Return the number of active scopes.
Definition scope_stack.h:61
T & Current()
Access the current (innermost) scope element.
Definition scope_stack.h:74
const T & Current() const
Const access to the current (innermost) scope element.
Definition scope_stack.h:80
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40