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)
38 BagCreateOp, BagSelectRandomOp, BagDifferenceOp, BagUnionOp,
39 BagUniqueSizeOp, BagConvertToSetOp,
41 OnContextOp, ContextSwitchOp,
43 StringToLabelOp, LabelUniqueDeclOp, LabelOp,
45 VirtualRegisterOp, RegisterToIndexOp, IndexToRegisterOp,
47 TestOp, TargetOp, YieldOp, ValidateOp, TestSuccessOp, TestFailureOp,
49 RandomNumberInRangeOp,
51 SequenceOp, GetSequenceOp, SubstituteSequenceOp,
52 RandomizeSequenceOp, EmbedSequenceOp, InterleaveSequencesOp,
54 SetCreateOp, SetSelectRandomOp, SetDifferenceOp, SetUnionOp,
55 SetSizeOp, SetCartesianProductOp, SetConvertToBagOp,
57 ArrayCreateOp, ArrayExtractOp, ArrayInjectOp, ArraySizeOp,
60 TupleCreateOp, TupleExtractOp,
62 IntToImmediateOp, ConcatImmediateOp, SliceImmediateOp,
64 MemoryAllocOp, MemoryBaseAddressOp, MemorySizeOp,
68 SpaceOp, StringDataOp, SegmentOp,
70 StringConcatOp, IntFormatOp, ImmediateFormatOp, RegisterFormatOp,
72 CommentOp, ConstraintOp, RandomScopeOp>(
73 [&](
auto expr) -> ResultType {
74 return thisCast->visitOp(expr, args...);
76 .Default([&](
auto expr) -> ResultType {
77 if (op->getDialect() ==
78 op->getContext()->getLoadedDialect<RTGDialect>())
81 return thisCast->visitExternalOp(op, args...);
88 op->emitOpError(
"Unknown RTG operation: ") << op->getName();
100#define HANDLE(OPTYPE, OPKIND) \
101 ResultType visitOp(OPTYPE op, ExtraArgs... args) { \
102 return static_cast<ConcreteType *>(this)->visit##OPKIND##Op(op, args...); \
110 HANDLE(InterleaveSequencesOp, Unhandled);
112 HANDLE(RandomNumberInRangeOp, Unhandled);
120 HANDLE(SetCartesianProductOp, Unhandled);
168template <
typename ConcreteType,
typename ResultType = void,
169 typename... ExtraArgs>
173 auto *thisCast =
static_cast<ConcreteType *
>(
this);
174 return TypeSwitch<Type, ResultType>(type)
175 .template Case<ImmediateType, SequenceType, SetType, BagType, DictType,
176 MapType, LabelType, IndexType, IntegerType>(
177 [&](
auto expr) -> ResultType {
178 return thisCast->visitType(expr, args...);
180 .
template Case<ContextResourceTypeInterface>(
181 [&](
auto expr) -> ResultType {
182 return thisCast->visitContextResourceType(expr, args...);
184 .Default([&](
auto expr) -> ResultType {
185 if (&type.getDialect() ==
186 type.getContext()->getLoadedDialect<RTGDialect>())
189 return thisCast->visitExternalType(type, args...);
196 llvm::errs() <<
"Unknown RTG type: " << type <<
"\n";
213#define HANDLE(TYPETYPE, TYPEKIND) \
214 ResultType visitType(TYPETYPE type, ExtraArgs... args) { \
215 return static_cast<ConcreteType *>(this)->visit##TYPEKIND##Type(type, \
This helps visit TypeOp nodes.
HANDLE(ConcatImmediateOp, Unhandled)
HANDLE(SegmentOp, Unhandled)
HANDLE(ValidateOp, Unhandled)
HANDLE(MemoryAllocOp, Unhandled)
HANDLE(YieldOp, Unhandled)
HANDLE(IntFormatOp, Unhandled)
HANDLE(ConstraintOp, Unhandled)
ResultType visitExternalOp(Operation *op, ExtraArgs... args)
HANDLE(TupleCreateOp, Unhandled)
HANDLE(MemorySizeOp, Unhandled)
HANDLE(MemoryBaseAddressOp, Unhandled)
HANDLE(TestOp, Unhandled)
HANDLE(ArrayInjectOp, 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(TestSuccessOp, Unhandled)
HANDLE(ConstantOp, Unhandled)
HANDLE(SpaceOp, Unhandled)
HANDLE(ArrayAppendOp, Unhandled)
HANDLE(TestFailureOp, Unhandled)
HANDLE(StringConcatOp, Unhandled)
HANDLE(SetUnionOp, Unhandled)
HANDLE(SliceImmediateOp, Unhandled)
HANDLE(ContextSwitchOp, Unhandled)
HANDLE(RandomizeSequenceOp, Unhandled)
HANDLE(IntToImmediateOp, Unhandled)
HANDLE(BagConvertToSetOp, Unhandled)
HANDLE(VirtualRegisterOp, Unhandled)
HANDLE(SetConvertToBagOp, Unhandled)
HANDLE(BagDifferenceOp, Unhandled)
HANDLE(InterleaveSequencesOp, Unhandled)
HANDLE(StringToLabelOp, Unhandled)
HANDLE(ImmediateFormatOp, Unhandled)
HANDLE(RandomNumberInRangeOp, Unhandled)
HANDLE(BagUnionOp, Unhandled)
HANDLE(StringDataOp, Unhandled)
HANDLE(SetCartesianProductOp, 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(RandomScopeOp, Unhandled)
HANDLE(CommentOp, Unhandled)
HANDLE(SubstituteSequenceOp, Unhandled)
HANDLE(RegisterToIndexOp, 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(IndexToRegisterOp, Unhandled)
HANDLE(MemoryBlockDeclareOp, Unhandled)
HANDLE(ArrayExtractOp, Unhandled)
HANDLE(ArrayCreateOp, Unhandled)
HANDLE(RegisterFormatOp, Unhandled)
HANDLE(SequenceOp, Unhandled)
HANDLE(TupleExtractOp, Unhandled)
HANDLE(ArraySizeOp, 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)
HANDLE(ImmediateType, Unhandled)
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.