CIRCT  20.0.0git
VerifVisitors.h
Go to the documentation of this file.
1 //===- VerifVisitors.h - Verif 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_VERIF_VERIFVISITORS_H
10 #define CIRCT_DIALECT_VERIF_VERIFVISITORS_H
11 
13 #include "llvm/ADT/TypeSwitch.h"
14 
15 namespace circt {
16 namespace verif {
17 template <typename ConcreteType, typename ResultType = void,
18  typename... ExtraArgs>
19 class Visitor {
20 public:
21  ResultType dispatchVerifVisitor(Operation *op, ExtraArgs... args) {
22  auto *thisCast = static_cast<ConcreteType *>(this);
23  return TypeSwitch<Operation *, ResultType>(op)
24  .template Case<AssertOp, AssumeOp, CoverOp, ClockedAssertOp,
25  ClockedAssumeOp, ClockedCoverOp>(
26  [&](auto op) -> ResultType {
27  return thisCast->visitVerif(op, args...);
28  })
29  .Default([&](auto) -> ResultType {
30  return thisCast->visitInvalidVerif(op, args...);
31  });
32  }
33 
34  /// This callback is invoked on any non-verif operations.
35  ResultType visitInvalidVerif(Operation *op, ExtraArgs... args) {
36  op->emitOpError("is not a verif operation");
37  abort();
38  }
39 
40  /// This callback is invoked on any verif operations that were not handled by
41  /// their concrete `visitVerif(...)` callback.
42  ResultType visitUnhandledVerif(Operation *op, ExtraArgs... args) {
43  return ResultType();
44  }
45 
46 #define HANDLE(OPTYPE, OPKIND) \
47  ResultType visitVerif(OPTYPE op, ExtraArgs... args) { \
48  return static_cast<ConcreteType *>(this)->visit##OPKIND##Verif(op, \
49  args...); \
50  }
51 
52  HANDLE(AssertOp, Unhandled);
53  HANDLE(AssumeOp, Unhandled);
54  HANDLE(CoverOp, Unhandled);
55  HANDLE(ClockedAssertOp, Unhandled);
56  HANDLE(ClockedAssumeOp, Unhandled);
57  HANDLE(ClockedCoverOp, Unhandled);
58 #undef HANDLE
59 };
60 
61 } // namespace verif
62 } // namespace circt
63 
64 #endif // CIRCT_DIALECT_VERIF_VERIFVISITORS_H
ResultType dispatchVerifVisitor(Operation *op, ExtraArgs... args)
Definition: VerifVisitors.h:21
HANDLE(ClockedAssertOp, Unhandled)
HANDLE(ClockedAssumeOp, Unhandled)
HANDLE(AssertOp, Unhandled)
HANDLE(CoverOp, Unhandled)
HANDLE(AssumeOp, Unhandled)
HANDLE(ClockedCoverOp, Unhandled)
ResultType visitInvalidVerif(Operation *op, ExtraArgs... args)
This callback is invoked on any non-verif operations.
Definition: VerifVisitors.h:35
ResultType visitUnhandledVerif(Operation *op, ExtraArgs... args)
This callback is invoked on any verif operations that were not handled by their concrete visitVerif(....
Definition: VerifVisitors.h:42
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: verif.py:1