13 #ifndef CIRCT_DIALECT_HW_HWVISITORS_H
14 #define CIRCT_DIALECT_HW_HWVISITORS_H
17 #include "llvm/ADT/TypeSwitch.h"
23 template <
typename ConcreteType,
typename ResultType = void,
24 typename... ExtraArgs>
28 auto *thisCast =
static_cast<ConcreteType *
>(
this);
29 return TypeSwitch<Operation *, ResultType>(op)
30 .template Case<ConstantOp, AggregateConstantOp,
32 ArraySliceOp, ArrayCreateOp, ArrayConcatOp, ArrayGetOp,
34 StructCreateOp, StructExtractOp, StructInjectOp,
36 UnionCreateOp, UnionExtractOp,
38 BitcastOp, ParamValueOp,
40 EnumConstantOp, EnumCmpOp>([&](
auto expr) -> ResultType {
41 return thisCast->visitTypeOp(expr, args...);
43 .Default([&](
auto expr) -> ResultType {
44 return thisCast->visitInvalidTypeOp(op, args...);
50 op->emitOpError(
"unknown HW combinational node");
60 #define HANDLE(OPTYPE, OPKIND) \
61 ResultType visitTypeOp(OPTYPE op, ExtraArgs... args) { \
62 return static_cast<ConcreteType *>(this)->visit##OPKIND##TypeOp(op, \
67 HANDLE(AggregateConstantOp, Unhandled);
85 template <
typename ConcreteType,
typename ResultType = void,
86 typename... ExtraArgs>
90 auto *thisCast =
static_cast<ConcreteType *
>(
this);
91 return TypeSwitch<Operation *, ResultType>(op)
92 .template Case<OutputOp, InstanceOp, InstanceChoiceOp, TypeScopeOp,
93 TypedeclOp>([&](
auto expr) -> ResultType {
94 return thisCast->visitStmt(expr, args...);
96 .Default([&](
auto expr) -> ResultType {
97 return thisCast->visitInvalidStmt(op, args...);
103 op->emitOpError(
"unknown hw statement");
123 #define HANDLE(OPTYPE, OPKIND) \
124 ResultType visitStmt(OPTYPE op, ExtraArgs... args) { \
125 return static_cast<ConcreteType *>(this)->visit##OPKIND##Stmt(op, \
This helps visit TypeOp nodes.
ResultType visitInvalidStmt(Operation *op, ExtraArgs... args)
This callback is invoked on any non-expression operations.
ResultType visitUnaryTypeOp(Operation *op, ExtraArgs... args)
HANDLE(InstanceOp, Unhandled)
HANDLE(TypeScopeOp, Unhandled)
ResultType visitUnhandledTypeOp(Operation *op, ExtraArgs... args)
This callback is invoked on any combinational operations that are not handled by the concrete visitor...
HANDLE(TypedeclOp, Unhandled)
HANDLE(OutputOp, Unhandled)
HANDLE(InstanceChoiceOp, Unhandled)
ResultType visitBinaryTypeOp(Operation *op, ExtraArgs... args)
This fallback is invoked on any binary node that isn't explicitly handled.
ResultType dispatchStmtVisitor(Operation *op, ExtraArgs... args)
This helps visit TypeOp nodes.
HANDLE(EnumCmpOp, Unhandled)
HANDLE(ParamValueOp, Unhandled)
HANDLE(AggregateConstantOp, Unhandled)
HANDLE(ConstantOp, Unhandled)
HANDLE(UnionExtractOp, Unhandled)
ResultType dispatchTypeOpVisitor(Operation *op, ExtraArgs... args)
HANDLE(ArrayGetOp, Unhandled)
HANDLE(ArraySliceOp, Unhandled)
HANDLE(StructExtractOp, Unhandled)
HANDLE(ArrayConcatOp, Unhandled)
HANDLE(StructCreateOp, Unhandled)
HANDLE(StructInjectOp, Unhandled)
HANDLE(ArrayCreateOp, Unhandled)
ResultType visitUnhandledTypeOp(Operation *op, ExtraArgs... args)
This callback is invoked on any combinational operations that are not handled by the concrete visitor...
ResultType visitInvalidTypeOp(Operation *op, ExtraArgs... args)
This callback is invoked on any non-expression operations.
HANDLE(UnionCreateOp, Unhandled)
HANDLE(BitcastOp, Unhandled)
HANDLE(EnumConstantOp, Unhandled)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.