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);
47 llvm::errs() <<
"ssp-roundtrip: Unknown problem '" << problemName <<
"'\n";
52 struct RoundtripPass :
public RoundtripBase<RoundtripPass> {
53 void runOnOperation()
override;
57 void RoundtripPass::runOnOperation() {
58 auto moduleOp = getOperation();
61 bool check = checkInputConstraints || verifySolutionConstraints;
62 bool verify = verifySolutionConstraints;
64 SmallVector<InstanceOp> instanceOps;
65 OpBuilder
builder(&getContext());
66 for (
auto instOp : moduleOp.getOps<InstanceOp>()) {
67 builder.setInsertionPoint(instOp);
70 return signalPassFailure();
71 instanceOps.push_back(instOp);
74 llvm::for_each(instanceOps, [](InstanceOp op) { op.erase(); });
78 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()
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
mlir::raw_indented_ostream & errs()