22 #include "mlir/Pass/Pass.h"
23 #include "llvm/ADT/TypeSwitch.h"
27 #define GEN_PASS_DEF_VERIFYCLOCKEDASSERTLIKEPASS
28 #include "circt/Dialect/Verif/Passes.h.inc"
32 using namespace circt;
33 using namespace verif;
40 struct VerifyClockedAssertLikePass
41 : verif::impl::VerifyClockedAssertLikePassBase<
42 VerifyClockedAssertLikePass> {
46 llvm::SmallMapVector<Operation *, OperandRange::iterator, 16> worklist;
49 llvm::DenseSet<Operation *> handledOps;
52 void runOnOperation()
override;
55 void verify(Operation *clockedAssertLikeOp) {
57 Operation *
property = clockedAssertLikeOp->getOperand(0).getDefiningOp();
63 worklist.insert({property,
property->operand_begin()});
66 while (!worklist.empty()) {
67 auto &[op, operandIt] = worklist.back();
69 if (operandIt == op->operand_end()) {
71 if (isa<ltl::ClockOp>(op)) {
72 op->emitError(
"Nested clock or disable operations are not "
73 "allowed for clock_assertlike operations.");
78 handledOps.insert(op);
85 Value operand = *(operandIt++);
86 auto *defOp = operand.getDefiningOp();
89 if (!defOp || handledOps.contains(defOp))
92 worklist.insert({defOp, defOp->operand_begin()});
102 void VerifyClockedAssertLikePass::runOnOperation() {
103 getOperation()->walk([&](Operation *op) {
104 llvm::TypeSwitch<Operation *, void>(op)
105 .Case<verif::ClockedAssertOp, verif::ClockedAssumeOp,
106 verif::ClockedCoverOp>([&](
auto clockedOp) {
verify(clockedOp); })
107 .Default([&](
auto) {});
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.