Skip to content

Commit

Permalink
[NFCI][Calyx] Refactor TableGen Pass includes (#7182)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzi-hielscher authored Jun 14, 2024
1 parent 0e22c2b commit 2554a14
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 45 deletions.
1 change: 1 addition & 0 deletions include/circt/Dialect/Calyx/CalyxPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Support/LLVM.h"
#include "mlir/Pass/Pass.h"
#include <memory>

namespace circt {
Expand Down
15 changes: 12 additions & 3 deletions lib/Dialect/Calyx/Transforms/ClkResetInsertion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
#include "circt/Support/LLVM.h"
Expand All @@ -20,6 +19,14 @@
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_CLKINSERTION
#define GEN_PASS_DEF_RESETINSERTION
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;
Expand All @@ -43,13 +50,15 @@ static void doPortPassthrough(ComponentOp comp, Value fromPort,
}
}

struct ClkInsertionPass : public ClkInsertionBase<ClkInsertionPass> {
struct ClkInsertionPass
: public circt::calyx::impl::ClkInsertionBase<ClkInsertionPass> {
void runOnOperation() override {
doPortPassthrough(getOperation(), getOperation().getClkPort(), "clk");
}
};

struct ResetInsertionPass : public ResetInsertionBase<ResetInsertionPass> {
struct ResetInsertionPass
: public circt::calyx::impl::ResetInsertionBase<ResetInsertionPass> {
void runOnOperation() override {
doPortPassthrough(getOperation(), getOperation().getResetPort(), "reset");
}
Expand Down
11 changes: 9 additions & 2 deletions lib/Dialect/Calyx/Transforms/CompileControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxHelpers.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
Expand All @@ -20,6 +19,13 @@
#include "mlir/IR/PatternMatch.h"
#include "llvm/ADT/TypeSwitch.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_COMPILECONTROL
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;
Expand Down Expand Up @@ -179,7 +185,8 @@ void CompileControlVisitor::visit(SeqOp seq, ComponentOp &component) {

namespace {

struct CompileControlPass : public CompileControlBase<CompileControlPass> {
struct CompileControlPass
: public circt::calyx::impl::CompileControlBase<CompileControlPass> {
void runOnOperation() override;
};

Expand Down
11 changes: 9 additions & 2 deletions lib/Dialect/Calyx/Transforms/GICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
#include "circt/Support/LLVM.h"
Expand All @@ -20,14 +19,22 @@
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_GROUPINVARIANTCODEMOTION
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;

namespace {

struct GroupInvariantCodeMotionPass
: public GroupInvariantCodeMotionBase<GroupInvariantCodeMotionPass> {
: public circt::calyx::impl::GroupInvariantCodeMotionBase<
GroupInvariantCodeMotionPass> {
void runOnOperation() override {
auto wires = getOperation().getWiresOp();
for (auto groupOp : wires.getOps<GroupOp>()) {
Expand Down
11 changes: 9 additions & 2 deletions lib/Dialect/Calyx/Transforms/GoInsertion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@
//
//===----------------------------------------------------------------------===//

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxHelpers.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
#include "circt/Support/LLVM.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OperationSupport.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_GOINSERTION
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;

namespace {

struct GoInsertionPass : public GoInsertionBase<GoInsertionPass> {
struct GoInsertionPass
: public circt::calyx::impl::GoInsertionBase<GoInsertionPass> {
void runOnOperation() override;
};

Expand Down
32 changes: 0 additions & 32 deletions lib/Dialect/Calyx/Transforms/PassDetails.h

This file was deleted.

10 changes: 8 additions & 2 deletions lib/Dialect/Calyx/Transforms/RemoveCombGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
/// }
/// ```

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
#include "circt/Support/LLVM.h"
Expand All @@ -81,6 +80,13 @@
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_REMOVECOMBGROUPS
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;
Expand Down Expand Up @@ -203,7 +209,7 @@ struct RemoveCombGroupsPattern : public OpRewritePattern<calyx::CombGroupOp> {
};

struct RemoveCombGroupsPass
: public RemoveCombGroupsBase<RemoveCombGroupsPass> {
: public circt::calyx::impl::RemoveCombGroupsBase<RemoveCombGroupsPass> {
void runOnOperation() override;

/// Removes 'with' groups from an operation and instead schedules the group
Expand Down
11 changes: 9 additions & 2 deletions lib/Dialect/Calyx/Transforms/RemoveGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
//
//===----------------------------------------------------------------------===//

#include "PassDetails.h"
#include "circt/Dialect/Calyx/CalyxHelpers.h"
#include "circt/Dialect/Calyx/CalyxOps.h"
#include "circt/Dialect/Calyx/CalyxPasses.h"
#include "circt/Support/LLVM.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OperationSupport.h"

namespace circt {
namespace calyx {
#define GEN_PASS_DEF_REMOVEGROUPS
#include "circt/Dialect/Calyx/CalyxPasses.h.inc"
} // namespace calyx
} // namespace circt

using namespace circt;
using namespace calyx;
using namespace mlir;
Expand Down Expand Up @@ -94,7 +100,8 @@ void inlineGroups(ComponentOp component) {

namespace {

struct RemoveGroupsPass : public RemoveGroupsBase<RemoveGroupsPass> {
struct RemoveGroupsPass
: public circt::calyx::impl::RemoveGroupsBase<RemoveGroupsPass> {
void runOnOperation() override;
};

Expand Down

0 comments on commit 2554a14

Please sign in to comment.