13 #ifndef CIRCT_DIALECT_HANDSHAKE_VISITORS_H
14 #define CIRCT_DIALECT_HANDSHAKE_VISITORS_H
17 #include "mlir/Dialect/Arith/IR/Arith.h"
18 #include "mlir/Dialect/Func/IR/FuncOps.h"
19 #include "llvm/ADT/TypeSwitch.h"
25 template <
typename ConcreteType,
typename ResultType = void,
26 typename... ExtraArgs>
30 auto *thisCast =
static_cast<ConcreteType *
>(
this);
31 return TypeSwitch<Operation *, ResultType>(op)
34 BranchOp, BufferOp, ConditionalBranchOp, ConstantOp, ControlMergeOp,
35 ForkOp, FuncOp, InstanceOp, JoinOp, LazyForkOp, LoadOp, MemoryOp,
36 ExternalMemoryOp, MergeOp, MuxOp, ReturnOp, SinkOp, SourceOp,
37 StoreOp, SyncOp, PackOp, UnpackOp>([&](
auto opNode) -> ResultType {
38 return thisCast->visitHandshake(opNode, args...);
40 .Default([&](
auto opNode) -> ResultType {
41 return thisCast->visitInvalidOp(op, args...);
47 op->emitOpError(
"is unsupported operation");
57 #define HANDLE(OPTYPE) \
58 ResultType visitHandshake(OPTYPE op, ExtraArgs... args) { \
59 return static_cast<ConcreteType *>(this)->visitUnhandledOp(op, args...); \
94 template <
typename ConcreteType,
typename ResultType = void,
95 typename... ExtraArgs>
99 auto *thisCast =
static_cast<ConcreteType *
>(
this);
100 return TypeSwitch<Operation *, ResultType>(op)
102 arith::IndexCastOp, arith::ExtUIOp, arith::ExtSIOp, arith::TruncIOp,
104 arith::CmpIOp, arith::AddIOp, arith::SubIOp, arith::MulIOp,
105 arith::DivSIOp, arith::RemSIOp, arith::DivUIOp, arith::RemUIOp,
106 arith::XOrIOp, arith::AndIOp, arith::OrIOp, arith::ShLIOp,
107 arith::ShRSIOp, arith::ShRUIOp, arith::SelectOp>(
108 [&](
auto opNode) -> ResultType {
109 return thisCast->visitStdExpr(opNode, args...);
111 .Default([&](
auto opNode) -> ResultType {
112 return thisCast->visitInvalidOp(op, args...);
118 op->emitOpError(
"is unsupported operation");
128 #define HANDLE(OPTYPE) \
129 ResultType visitStdExpr(OPTYPE op, ExtraArgs... args) { \
130 return static_cast<ConcreteType *>(this)->visitUnhandledOp(op, args...); \
HandshakeVisitor is a visitor for handshake nodes.
ResultType visitUnhandledOp(Operation *op, ExtraArgs... args)
This callback is invoked on any operations that are not handled by the concrete visitor.
ResultType visitInvalidOp(Operation *op, ExtraArgs... args)
This callback is invoked on any invalid operations.
ResultType dispatchHandshakeVisitor(Operation *op, ExtraArgs... args)
HANDLE(ConditionalBranchOp)
StdExprVisitor is a visitor for standard expression nodes.
ResultType visitInvalidOp(Operation *op, ExtraArgs... args)
This callback is invoked on any invalid operations.
ResultType visitUnhandledOp(Operation *op, ExtraArgs... args)
This callback is invoked on any operations that are not handled by the concrete visitor.
ResultType dispatchStdExprVisitor(Operation *op, ExtraArgs... args)
HANDLE(arith::IndexCastOp)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.