19 #include "mlir/Pass/Pass.h"
23 #define GEN_PASS_DEF_ROUNDTRIP
24 #include "circt/Dialect/SSP/SSPPasses.h.inc"
28 using namespace circt;
29 using namespace scheduling;
32 template <
typename ProblemT>
35 auto prob = loadProblem<ProblemT>(instOp);
37 if (check && failed(prob.check()))
39 if (
verify && failed(prob.verify()))
42 return saveProblem<ProblemT>(prob, builder);
47 auto problemName = instOp.getProblemName();
49 if (problemName ==
"Problem")
50 return roundtripAs<Problem>(instOp, check,
verify, builder);
51 if (problemName ==
"CyclicProblem")
52 return roundtripAs<CyclicProblem>(instOp, check,
verify, builder);
53 if (problemName ==
"SharedOperatorsProblem")
54 return roundtripAs<SharedOperatorsProblem>(instOp, check,
verify, builder);
55 if (problemName ==
"ModuloProblem")
56 return roundtripAs<ModuloProblem>(instOp, check,
verify, builder);
57 if (problemName ==
"ChainingProblem")
58 return roundtripAs<ChainingProblem>(instOp, check,
verify, builder);
59 if (problemName ==
"ChainingCyclicProblem")
60 return roundtripAs<ChainingCyclicProblem>(instOp, check,
verify, builder);
62 llvm::errs() <<
"ssp-roundtrip: Unknown problem '" << problemName <<
"'\n";
67 struct RoundtripPass :
public circt::ssp::impl::RoundtripBase<RoundtripPass> {
68 void runOnOperation()
override;
72 void RoundtripPass::runOnOperation() {
73 auto moduleOp = getOperation();
76 bool check = checkInputConstraints || verifySolutionConstraints;
77 bool verify = verifySolutionConstraints;
79 SmallVector<InstanceOp> instanceOps;
80 OpBuilder builder(&getContext());
81 for (
auto instOp : moduleOp.getOps<InstanceOp>()) {
82 builder.setInsertionPoint(instOp);
85 return signalPassFailure();
86 instanceOps.push_back(instOp);
89 llvm::for_each(instanceOps, [](InstanceOp op) { op.erase(); });
93 return std::make_unique<RoundtripPass>();
static InstanceOp roundtrip(InstanceOp instOp, bool check, bool verify, OpBuilder &builder)
static InstanceOp roundtripAs(InstanceOp instOp, bool check, bool verify, OpBuilder &builder)
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
std::unique_ptr< mlir::Pass > createRoundtripPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.