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 OnContextOp, ContextSwitchOp,
41 LabelDeclOp, LabelUniqueDeclOp, LabelOp,
43 FixedRegisterOp, VirtualRegisterOp,
45 TestOp, TargetOp, YieldOp,
47 RandomNumberInRangeOp,
49 SequenceOp, GetSequenceOp, SubstituteSequenceOp,
50 RandomizeSequenceOp, EmbedSequenceOp, InterleaveSequencesOp,
52 SetCreateOp, SetSelectRandomOp, SetDifferenceOp, SetUnionOp,
53 SetSizeOp>([&](
auto expr) -> ResultType {
54 return thisCast->visitOp(expr, args...);
56 .Default([&](
auto expr) -> ResultType {
57 if (op->getDialect() ==
58 op->getContext()->getLoadedDialect<RTGDialect>())
61 return thisCast->visitExternalOp(op, args...);
68 op->emitOpError(
"Unknown RTG operation: ") << op->getName();
80#define HANDLE(OPTYPE, OPKIND) \
81 ResultType visitOp(OPTYPE op, ExtraArgs... args) { \
82 return static_cast<ConcreteType *>(this)->visit##OPKIND##Op(op, args...); \
87 HANDLE(SubstituteSequenceOp, Unhandled);
88 HANDLE(RandomizeSequenceOp, Unhandled);
89 HANDLE(InterleaveSequencesOp, Unhandled);
91 HANDLE(RandomNumberInRangeOp, Unhandled);
95 HANDLE(SetSelectRandomOp, Unhandled);
116template <
typename ConcreteType,
typename ResultType = void,
117 typename... ExtraArgs>
121 auto *thisCast =
static_cast<ConcreteType *
>(
this);
122 return TypeSwitch<Type, ResultType>(type)
123 .template Case<SequenceType, SetType, BagType, DictType, LabelType,
124 IndexType, IntegerType>([&](
auto expr) -> ResultType {
125 return thisCast->visitType(expr, args...);
127 .
template Case<ContextResourceTypeInterface>(
128 [&](
auto expr) -> ResultType {
129 return thisCast->visitContextResourceType(expr, args...);
131 .Default([&](
auto expr) -> ResultType {
132 if (&type.getDialect() ==
133 type.getContext()->getLoadedDialect<RTGDialect>())
136 return thisCast->visitExternalType(type, args...);
143 llvm::errs() <<
"Unknown RTG type: " << type <<
"\n";
160#define HANDLE(TYPETYPE, TYPEKIND) \
161 ResultType visitType(TYPETYPE type, ExtraArgs... args) { \
162 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(EmbedSequenceOp, Unhandled)
HANDLE(OnContextOp, Unhandled)
HANDLE(BagCreateOp, Unhandled)
HANDLE(LabelUniqueDeclOp, Unhandled)
HANDLE(SetUnionOp, Unhandled)
HANDLE(ContextSwitchOp, Unhandled)
HANDLE(RandomizeSequenceOp, Unhandled)
HANDLE(VirtualRegisterOp, Unhandled)
HANDLE(BagDifferenceOp, Unhandled)
HANDLE(InterleaveSequencesOp, Unhandled)
HANDLE(FixedRegisterOp, Unhandled)
HANDLE(RandomNumberInRangeOp, Unhandled)
HANDLE(BagUnionOp, Unhandled)
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(SubstituteSequenceOp, Unhandled)
HANDLE(LabelDeclOp, 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(GetSequenceOp, 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.