15 using namespace circt;
16 using namespace scheduling;
19 template <
typename ProblemT>
20 static InstanceOp
roundtripAs(InstanceOp instOp,
bool check,
bool verify,
22 auto prob = loadProblem<ProblemT>(instOp);
24 if (check && failed(prob.check()))
26 if (verify && failed(prob.verify()))
29 return saveProblem<ProblemT>(prob,
builder);
32 static InstanceOp
roundtrip(InstanceOp instOp,
bool check,
bool verify,
34 auto problemName = instOp.getProblemName();
36 if (problemName.equals(
"Problem"))
37 return roundtripAs<Problem>(instOp, check, verify,
builder);
38 if (problemName.equals(
"CyclicProblem"))
39 return roundtripAs<CyclicProblem>(instOp, check, verify,
builder);
40 if (problemName.equals(
"SharedOperatorsProblem"))
41 return roundtripAs<SharedOperatorsProblem>(instOp, check, verify,
builder);
42 if (problemName.equals(
"ModuloProblem"))
43 return roundtripAs<ModuloProblem>(instOp, check, verify,
builder);
44 if (problemName.equals(
"ChainingProblem"))
45 return roundtripAs<ChainingProblem>(instOp, check, verify,
builder);
46 if (problemName.equals(
"ChainingCyclicProblem"))
47 return roundtripAs<ChainingCyclicProblem>(instOp, check, verify,
builder);
49 llvm::errs() <<
"ssp-roundtrip: Unknown problem '" << problemName <<
"'\n";
54 struct RoundtripPass :
public RoundtripBase<RoundtripPass> {
55 void runOnOperation()
override;
59 void RoundtripPass::runOnOperation() {
60 auto moduleOp = getOperation();
63 bool check = checkInputConstraints || verifySolutionConstraints;
64 bool verify = verifySolutionConstraints;
66 SmallVector<InstanceOp> instanceOps;
67 OpBuilder
builder(&getContext());
68 for (
auto instOp : moduleOp.getOps<InstanceOp>()) {
69 builder.setInsertionPoint(instOp);
72 return signalPassFailure();
73 instanceOps.push_back(instOp);
76 llvm::for_each(instanceOps, [](InstanceOp op) { op.erase(); });
80 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)
std::unique_ptr< mlir::Pass > createRoundtripPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.