15 #ifndef MLIR_SUPPORT_STACKFRAME_H
16 #define MLIR_SUPPORT_STACKFRAME_H
35 virtual void anchor();
46 template <
typename Derived>
59 template <
typename T,
typename... Args>
61 static_assert(std::is_base_of<StateStackFrame, T>::value,
62 "can only push instances of StackFrame on StateStack");
63 stack.push_back(std::make_unique<T>(std::forward<Args>(args)...));
73 static_assert(std::is_base_of<StateStackFrame, T>::value,
74 "expected T derived from StackFrame");
77 for (std::unique_ptr<StateStackFrame> &frame : llvm::reverse(stack)) {
78 if (T *ptr = dyn_cast_or_null<T>(frame.get())) {
105 template <
typename T,
typename HostClass = StateStack>
107 template <
typename... Args>
109 host.template stackPush<T>(std::forward<Args>(args)...);
120 template <
typename T>
122 static inline bool doit(const ::mlir::StateStackFrame &frame) {
123 return frame.getTypeID() == ::mlir::TypeID::get<T>();
Concrete CRTP base class for StateStack frames.
Common CRTP base class for StateStack frames.
virtual ~StateStackFrame()=default
StateStackFrame(TypeID typeID)
T * getStackTop()
Get the top instance of frame type T or nullptr if none are found.
WalkResult stackWalk(llvm::function_ref< WalkResult(T &)> callback)
Calls callback for every StateStack frame of type T starting from the top of the stack.
void stackPop()
Pops the last element from the StateStack.
void stackPush(Args &&...args)
Creates a stack frame of type T on StateStack.
This class provides an efficient unique identifier for a specific C++ type.
A utility result that is used to signal how to proceed with an ongoing walk:
static WalkResult advance()
bool wasInterrupted() const
Returns true if the walk was interrupted.
static WalkResult interrupt()
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
static bool doit(const ::mlir::StateStackFrame &frame)
RAII object calling stackPush/stackPop on construction/destruction.
SaveStateStack(HostClass &host, Args &&...args)