Skip to content

Commit

Permalink
[Seq] Use a new pass generation mechanism (#4304)
Browse files Browse the repository at this point in the history
This applies a new pass generation method(ref:#3962) to seq dialect passes, that automatically defines a struct of options (e.g. `LowerSeqFIRRTLToSVOptions`) and creates a pass constructor to take the option.
  • Loading branch information
uenoku authored Nov 15, 2022
1 parent b1d65e4 commit 22d426c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
6 changes: 5 additions & 1 deletion include/circt/Dialect/Seq/SeqPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
namespace circt {
namespace seq {

#define GEN_PASS_DECL
#include "circt/Dialect/Seq/SeqPasses.h.inc"
#undef GEN_PASS_DECL

std::unique_ptr<mlir::Pass> createSeqLowerToSVPass();
std::unique_ptr<mlir::Pass>
createSeqFIRRTLLowerToSVPass(bool disableRegRandomization = false);
createSeqFIRRTLLowerToSVPass(const LowerSeqFIRRTLToSVOptions &options = {});
std::unique_ptr<mlir::Pass> createLowerSeqHLMemPass();

/// Generate the code for registering passes.
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/Seq/Transforms/LowerSeqHLMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ struct SimpleBehavioralMemoryLowering
}
};

struct LowerSeqHLMemPass : public LowerSeqHLMemBase<LowerSeqHLMemPass> {
struct LowerSeqHLMemPass
: public circt::seq::impl::LowerSeqHLMemBase<LowerSeqHLMemPass> {
void runOnOperation() override;
};

Expand Down
15 changes: 7 additions & 8 deletions lib/Dialect/Seq/Transforms/LowerSeqToSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ using namespace circt;
using namespace seq;

namespace {
struct SeqToSVPass : public LowerSeqToSVBase<SeqToSVPass> {
struct SeqToSVPass : public impl::LowerSeqToSVBase<SeqToSVPass> {
void runOnOperation() override;
};
struct SeqFIRRTLToSVPass : public LowerSeqFIRRTLToSVBase<SeqFIRRTLToSVPass> {
struct SeqFIRRTLToSVPass
: public impl::LowerSeqFIRRTLToSVBase<SeqFIRRTLToSVPass> {
void runOnOperation() override;
using LowerSeqFIRRTLToSVBase<SeqFIRRTLToSVPass>::disableRegRandomization;
using LowerSeqFIRRTLToSVBase<SeqFIRRTLToSVPass>::LowerSeqFIRRTLToSVBase;
};
} // anonymous namespace

Expand Down Expand Up @@ -520,10 +522,7 @@ std::unique_ptr<Pass> circt::seq::createSeqLowerToSVPass() {
return std::make_unique<SeqToSVPass>();
}

std::unique_ptr<Pass>
circt::seq::createSeqFIRRTLLowerToSVPass(bool disableRegRandomization) {
auto pass = std::make_unique<SeqFIRRTLToSVPass>();
if (disableRegRandomization)
pass->disableRegRandomization = disableRegRandomization;
return pass;
std::unique_ptr<Pass> circt::seq::createSeqFIRRTLLowerToSVPass(
const LowerSeqFIRRTLToSVOptions &options) {
return std::make_unique<SeqFIRRTLToSVPass>(options);
}
5 changes: 4 additions & 1 deletion lib/Dialect/Seq/Transforms/PassDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/SV/SVDialect.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "circt/Dialect/Seq/SeqPasses.h"
#include "mlir/Pass/Pass.h"

namespace circt {
namespace seq {

#define GEN_PASS_CLASSES
#define GEN_PASS_DEF_LOWERSEQFIRRTLTOSV
#define GEN_PASS_DEF_LOWERSEQHLMEM
#define GEN_PASS_DEF_LOWERSEQTOSV
#include "circt/Dialect/Seq/SeqPasses.h.inc"

} // namespace seq
Expand Down
4 changes: 2 additions & 2 deletions tools/firtool/firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr,
modulePM.addPass(createCSEPass());
}

pm.nest<hw::HWModuleOp>().addPass(
seq::createSeqFIRRTLLowerToSVPass(!isRandomEnabled(RandomKind::Reg)));
pm.nest<hw::HWModuleOp>().addPass(seq::createSeqFIRRTLLowerToSVPass(
{/*disableRandomization=*/!isRandomEnabled(RandomKind::Reg)}));
pm.addPass(sv::createHWMemSimImplPass(replSeqMem, ignoreReadEnableMem,
stripMuxPragmas,
!isRandomEnabled(RandomKind::Mem),
Expand Down

0 comments on commit 22d426c

Please sign in to comment.