13#ifndef CIRCT_DIALECT_RTG_IR_RTGVISITORS_H
14#define CIRCT_DIALECT_RTG_IR_RTGVISITORS_H
21#include "llvm/ADT/TypeSwitch.h"
27template <
typename ConcreteType,
typename ResultType = void,
28 typename... ExtraArgs>
32 auto *thisCast =
static_cast<ConcreteType *
>(
this);
33 return TypeSwitch<Operation *, ResultType>(op)
36 BagCreateOp, BagSelectRandomOp, BagDifferenceOp, BagUnionOp,
39 LabelDeclOp, LabelUniqueDeclOp, LabelOp,
41 FixedRegisterOp, VirtualRegisterOp,
43 TestOp, TargetOp, YieldOp,
45 SequenceOp, SequenceClosureOp, InvokeSequenceOp,
47 SetCreateOp, SetSelectRandomOp, SetDifferenceOp, SetUnionOp,
48 SetSizeOp>([&](
auto expr) -> ResultType {
49 return thisCast->visitOp(expr, args...);
51 .
template Case<ContextResourceOpInterface>(
52 [&](
auto expr) -> ResultType {
53 return thisCast->visitContextResourceOp(expr, args...);
55 .Default([&](
auto expr) -> ResultType {
56 if (op->getDialect() ==
57 op->getContext()->getLoadedDialect<RTGDialect>())
60 return thisCast->visitExternalOp(op, args...);
67 op->emitOpError(
"Unknown RTG operation: ") << op->getName();
84#define HANDLE(OPTYPE, OPKIND) \
85 ResultType visitOp(OPTYPE op, ExtraArgs... args) { \
86 return static_cast<ConcreteType *>(this)->visit##OPKIND##Op(op, args...); \
90 HANDLE(SequenceClosureOp, Unhandled);
93 HANDLE(SetSelectRandomOp, Unhandled);
98 HANDLE(BagSelectRandomOp, Unhandled);
114template <
typename ConcreteType,
typename ResultType = void,
115 typename... ExtraArgs>
119 auto *thisCast =
static_cast<ConcreteType *
>(
this);
120 return TypeSwitch<Type, ResultType>(type)
121 .template Case<SequenceType, SetType, BagType, DictType, LabelType,
122 IndexType, IntegerType>([&](
auto expr) -> ResultType {
123 return thisCast->visitType(expr, args...);
125 .
template Case<ContextResourceTypeInterface>(
126 [&](
auto expr) -> ResultType {
127 return thisCast->visitContextResourceType(expr, args...);
129 .Default([&](
auto expr) -> ResultType {
130 if (&type.getDialect() ==
131 type.getContext()->getLoadedDialect<RTGDialect>())
134 return thisCast->visitExternalType(type, args...);
141 llvm::errs() <<
"Unknown RTG type: " << type <<
"\n";
158#define HANDLE(TYPETYPE, TYPEKIND) \
159 ResultType visitType(TYPETYPE type, ExtraArgs... args) { \
160 return static_cast<ConcreteType *>(this)->visit##TYPEKIND##Type(type, \
This helps visit TypeOp nodes.
HANDLE(YieldOp, Unhandled)
ResultType visitExternalOp(Operation *op, ExtraArgs... args)
HANDLE(TestOp, Unhandled)
ResultType visitInvalidTypeOp(Operation *op, ExtraArgs... args)
This callback is invoked on any RTG operations not handled properly by the TypeSwitch.
HANDLE(BagUniqueSizeOp, Unhandled)
HANDLE(BagCreateOp, Unhandled)
HANDLE(LabelUniqueDeclOp, Unhandled)
HANDLE(SetUnionOp, Unhandled)
HANDLE(VirtualRegisterOp, Unhandled)
HANDLE(BagDifferenceOp, Unhandled)
HANDLE(FixedRegisterOp, Unhandled)
HANDLE(BagUnionOp, Unhandled)
ResultType visitContextResourceOp(ContextResourceOpInterface op, ExtraArgs... args)
HANDLE(SetDifferenceOp, Unhandled)
HANDLE(TargetOp, Unhandled)
HANDLE(SetSizeOp, Unhandled)
HANDLE(SetCreateOp, Unhandled)
HANDLE(SetSelectRandomOp, Unhandled)
HANDLE(BagSelectRandomOp, Unhandled)
ResultType dispatchOpVisitor(Operation *op, ExtraArgs... args)
HANDLE(LabelDeclOp, Unhandled)
HANDLE(SequenceClosureOp, Unhandled)
ResultType visitUnhandledOp(Operation *op, ExtraArgs... args)
This callback is invoked on any operations that are not handled by the concrete visitor.
HANDLE(LabelOp, Unhandled)
HANDLE(SequenceOp, Unhandled)
HANDLE(InvokeSequenceOp, Unhandled)
This helps visit TypeOp nodes.
HANDLE(BagType, Unhandled)
ResultType dispatchTypeVisitor(Type type, ExtraArgs... args)
HANDLE(IndexType, Unhandled)
HANDLE(DictType, Unhandled)
HANDLE(IntegerType, Unhandled)
HANDLE(SequenceType, Unhandled)
HANDLE(SetType, Unhandled)
HANDLE(LabelType, Unhandled)
ResultType visitExternalType(Type type, ExtraArgs... args)
ResultType visitContextResourceType(ContextResourceTypeInterface type, ExtraArgs... args)
ResultType visitInvalidType(Type type, ExtraArgs... args)
This callback is invoked on any RTG types not handled properly by the TypeSwitch.
ResultType visitUnhandledType(Type type, ExtraArgs... args)
This callback is invoked on any types that are not handled by the concrete visitor.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.