CIRCT 20.0.0git
Loading...
Searching...
No Matches
LTLVisitors.h
Go to the documentation of this file.
1//===- LTLVisitors.h - LTL dialect visitors ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef CIRCT_DIALECT_LTL_LTLVISITORS_H
10#define CIRCT_DIALECT_LTL_LTLVISITORS_H
11
13#include "llvm/ADT/TypeSwitch.h"
14
15namespace circt {
16namespace ltl {
17template <typename ConcreteType, typename ResultType = void,
18 typename... ExtraArgs>
19class Visitor {
20public:
21 ResultType dispatchLTLVisitor(Operation *op, ExtraArgs... args) {
22 auto *thisCast = static_cast<ConcreteType *>(this);
23 return TypeSwitch<Operation *, ResultType>(op)
24 .template Case<AndOp, OrOp, DelayOp, ConcatOp, RepeatOp, NotOp,
25 ImplicationOp, UntilOp, EventuallyOp, ClockOp,
26 IntersectOp, NonConsecutiveRepeatOp, GoToRepeatOp>(
27 [&](auto op) -> ResultType {
28 return thisCast->visitLTL(op, args...);
29 })
30 .Default([&](auto) -> ResultType {
31 return thisCast->visitInvalidLTL(op, args...);
32 });
33 }
34
35 /// This callback is invoked on any non-LTL operations.
36 ResultType visitInvalidLTL(Operation *op, ExtraArgs... args) {
37 op->emitOpError("is not an LTL operation");
38 abort();
39 }
40
41 /// This callback is invoked on any LTL operations that were not handled by
42 /// their concrete `visitLTL(...)` callback.
43 ResultType visitUnhandledLTL(Operation *op, ExtraArgs... args) {
44 return ResultType();
45 }
46
47#define HANDLE(OPTYPE, OPKIND) \
48 ResultType visitLTL(OPTYPE op, ExtraArgs... args) { \
49 return static_cast<ConcreteType *>(this)->visit##OPKIND##LTL(op, args...); \
50 }
51
52 HANDLE(AndOp, Unhandled);
53 HANDLE(OrOp, Unhandled);
54 HANDLE(DelayOp, Unhandled);
55 HANDLE(ConcatOp, Unhandled);
56 HANDLE(RepeatOp, Unhandled);
57 HANDLE(NotOp, Unhandled);
58 HANDLE(ImplicationOp, Unhandled);
59 HANDLE(UntilOp, Unhandled);
60 HANDLE(EventuallyOp, Unhandled);
61 HANDLE(ClockOp, Unhandled);
62 HANDLE(IntersectOp, Unhandled);
63 HANDLE(NonConsecutiveRepeatOp, Unhandled);
64 HANDLE(GoToRepeatOp, Unhandled);
65#undef HANDLE
66};
67
68} // namespace ltl
69} // namespace circt
70
71#endif // CIRCT_DIALECT_LTL_LTLVISITORS_H
HANDLE(UntilOp, Unhandled)
ResultType visitInvalidLTL(Operation *op, ExtraArgs... args)
This callback is invoked on any non-LTL operations.
Definition LTLVisitors.h:36
HANDLE(GoToRepeatOp, Unhandled)
HANDLE(AndOp, Unhandled)
HANDLE(DelayOp, Unhandled)
HANDLE(EventuallyOp, Unhandled)
ResultType dispatchLTLVisitor(Operation *op, ExtraArgs... args)
Definition LTLVisitors.h:21
HANDLE(NotOp, Unhandled)
HANDLE(ClockOp, Unhandled)
HANDLE(RepeatOp, Unhandled)
HANDLE(NonConsecutiveRepeatOp, Unhandled)
HANDLE(ConcatOp, Unhandled)
HANDLE(IntersectOp, Unhandled)
ResultType visitUnhandledLTL(Operation *op, ExtraArgs... args)
This callback is invoked on any LTL operations that were not handled by their concrete visitLTL(....
Definition LTLVisitors.h:43
HANDLE(OrOp, Unhandled)
HANDLE(ImplicationOp, Unhandled)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition ltl.py:1