[NFCI][DC][FSM][Handshake][Pipeline] Refactor TableGen Pass includes (#7181)

This commit is contained in:
fzi-hielscher 2024-06-18 13:26:12 +02:00 committed by GitHub
parent a49e31d60e
commit 15ae39ec07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 132 additions and 168 deletions

View File

@ -27,6 +27,9 @@ namespace circt {
namespace handshake {
class FuncOp;
#define GEN_PASS_DECL
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
createHandshakeDotPrintPass();
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>

View File

@ -10,9 +10,17 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/DC/DCOps.h"
#include "circt/Dialect/DC/DCPasses.h"
#include "mlir/Pass/Pass.h"
namespace circt {
namespace dc {
#define GEN_PASS_DEF_DCMATERIALIZEFORKSSINKS
#define GEN_PASS_DEF_DCDEMATERIALIZEFORKSSINKS
#include "circt/Dialect/DC/DCPasses.h.inc"
} // namespace dc
} // namespace circt
using namespace circt;
using namespace dc;
@ -132,7 +140,8 @@ static LogicalResult addSinkOps(Block &block, OpBuilder &rewriter) {
namespace {
struct DCMaterializeForksSinksPass
: public DCMaterializeForksSinksBase<DCMaterializeForksSinksPass> {
: public circt::dc::impl::DCMaterializeForksSinksBase<
DCMaterializeForksSinksPass> {
void runOnOperation() override {
auto *op = getOperation();
OpBuilder builder(op);
@ -151,7 +160,8 @@ struct DCMaterializeForksSinksPass
};
struct DCDematerializeForksSinksPass
: public DCDematerializeForksSinksBase<DCDematerializeForksSinksPass> {
: public circt::dc::impl::DCDematerializeForksSinksBase<
DCDematerializeForksSinksPass> {
void runOnOperation() override {
auto *op = getOperation();
op->walk([&](dc::SinkOp sinkOp) { sinkOp.erase(); });

View File

@ -1,37 +0,0 @@
//===- PassDetails.h - DC pass class details --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Contains the stuff shared between the different DC passes.
//
//===----------------------------------------------------------------------===//
// clang-tidy seems to expect the absolute path in the
// header guard on some systems, so just disable it.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef DIALECT_DC_TRANSFORMS_PASSDETAILS_H
#define DIALECT_DC_TRANSFORMS_PASSDETAILS_H
#include "circt/Dialect/Comb/CombDialect.h"
#include "circt/Dialect/DC/DCOps.h"
#include "circt/Dialect/ESI/ESIDialect.h"
#include "circt/Dialect/HW/HWDialect.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Pass/Pass.h"
namespace circt {
namespace dc {
#define GEN_PASS_CLASSES
#include "circt/Dialect/DC/DCPasses.h.inc"
} // namespace dc
} // namespace circt
#endif // DIALECT_DC_TRANSFORMS_PASSDETAILS_H

View File

@ -1,31 +0,0 @@
//===- PassDetails.h - FSM pass class details -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Stuff shared between the different FSM passes.
//
//===----------------------------------------------------------------------===//
// clang-tidy seems to expect the absolute path in the header guard on some
// systems, so just disable it.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef DIALECT_FSM_TRANSFORMS_PASSDETAILS_H
#define DIALECT_FSM_TRANSFORMS_PASSDETAILS_H
#include "circt/Dialect/FSM/FSMOps.h"
#include "mlir/Pass/Pass.h"
namespace circt {
namespace fsm {
#define GEN_PASS_CLASSES
#include "circt/Dialect/FSM/Passes.h.inc"
} // namespace fsm
} // namespace circt
#endif // DIALECT_FSM_TRANSFORMS_PASSDETAILS_H

View File

@ -10,18 +10,27 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/FSM/FSMGraph.h"
#include "circt/Dialect/FSM/FSMOps.h"
#include "circt/Dialect/FSM/FSMPasses.h"
#include "circt/Dialect/HW/HWInstanceGraph.h"
#include "mlir/Pass/Pass.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
namespace circt {
namespace fsm {
#define GEN_PASS_DEF_PRINTFSMGRAPH
#include "circt/Dialect/FSM/Passes.h.inc"
} // namespace fsm
} // namespace circt
using namespace circt;
using namespace fsm;
namespace {
struct PrintFSMGraphPass : public PrintFSMGraphBase<PrintFSMGraphPass> {
struct PrintFSMGraphPass
: public circt::fsm::impl::PrintFSMGraphBase<PrintFSMGraphPass> {
PrintFSMGraphPass(raw_ostream &os) : os(os) {}
void runOnOperation() override {
getOperation().walk([&](fsm::MachineOp machine) {

View File

@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Support/LLVM.h"
@ -18,11 +17,21 @@
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Support/IndentedOstream.h"
#include "llvm/ADT/TypeSwitch.h"
#include <optional>
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKEDOTPRINT
#define GEN_PASS_DEF_HANDSHAKEOPCOUNT
#define GEN_PASS_DEF_HANDSHAKEADDIDS
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -34,7 +43,8 @@ static bool isControlOp(Operation *op) {
namespace {
struct HandshakeDotPrintPass
: public HandshakeDotPrintBase<HandshakeDotPrintPass> {
: public circt::handshake::impl::HandshakeDotPrintBase<
HandshakeDotPrintPass> {
void runOnOperation() override {
ModuleOp m = getOperation();
@ -100,7 +110,8 @@ private:
};
struct HandshakeOpCountPass
: public HandshakeOpCountBase<HandshakeOpCountPass> {
: public circt::handshake::impl::HandshakeOpCountBase<
HandshakeOpCountPass> {
void runOnOperation() override {
ModuleOp m = getOperation();
@ -580,7 +591,8 @@ std::string HandshakeDotPrintPass::dotPrint(mlir::raw_indented_ostream &os,
}
namespace {
struct HandshakeAddIDsPass : public HandshakeAddIDsBase<HandshakeAddIDsPass> {
struct HandshakeAddIDsPass
: public circt::handshake::impl::HandshakeAddIDsBase<HandshakeAddIDsPass> {
void runOnOperation() override {
handshake::FuncOp funcOp = getOperation();
auto *ctx = &getContext();

View File

@ -10,13 +10,21 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/DialectConversion.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKEREMOVEBUFFERS
#define GEN_PASS_DEF_HANDSHAKEINSERTBUFFERS
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -34,7 +42,8 @@ struct RemoveHandshakeBuffers : public OpRewritePattern<handshake::BufferOp> {
};
struct HandshakeRemoveBuffersPass
: public HandshakeRemoveBuffersBase<HandshakeRemoveBuffersPass> {
: public circt::handshake::impl::HandshakeRemoveBuffersBase<
HandshakeRemoveBuffersPass> {
void runOnOperation() override {
handshake::FuncOp op = getOperation();
ConversionTarget target(getContext());
@ -186,7 +195,8 @@ LogicalResult circt::handshake::bufferRegion(Region &r, OpBuilder &builder,
namespace {
struct HandshakeInsertBuffersPass
: public HandshakeInsertBuffersBase<HandshakeInsertBuffersPass> {
: public circt::handshake::impl::HandshakeInsertBuffersBase<
HandshakeInsertBuffersPass> {
HandshakeInsertBuffersPass(const std::string &strategy, unsigned bufferSize) {
this->strategy = strategy;
this->bufferSize = bufferSize;

View File

@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Support/BackedgeBuilder.h"
@ -18,9 +17,17 @@
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/DialectConversion.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKELEGALIZEMEMREFS
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -28,7 +35,8 @@ using namespace mlir;
namespace {
struct HandshakeLegalizeMemrefsPass
: public HandshakeLegalizeMemrefsBase<HandshakeLegalizeMemrefsPass> {
: public circt::handshake::impl::HandshakeLegalizeMemrefsBase<
HandshakeLegalizeMemrefsPass> {
void runOnOperation() override {
func::FuncOp op = getOperation();
if (op.isExternal())

View File

@ -10,14 +10,21 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Support/BackedgeBuilder.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/DialectConversion.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKELOCKFUNCTIONS
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -68,7 +75,8 @@ LogicalResult handshake::lockRegion(Region &r, OpBuilder &rewriter) {
namespace {
struct HandshakeLockFunctionsPass
: public HandshakeLockFunctionsBase<HandshakeLockFunctionsPass> {
: public circt::handshake::impl::HandshakeLockFunctionsBase<
HandshakeLockFunctionsPass> {
void runOnOperation() override {
handshake::FuncOp op = getOperation();
if (op.isExternal())

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Conversion/HandshakeToHW.h"
#include "circt/Dialect/Comb/CombDialect.h"
#include "circt/Dialect/ESI/ESIOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWTypes.h"
@ -20,10 +20,18 @@
#include "circt/Support/BackedgeBuilder.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/Support/Debug.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKELOWEREXTMEMTOHW
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -107,7 +115,8 @@ static HandshakeMemType getMemTypeForExtmem(Value v) {
namespace {
struct HandshakeLowerExtmemToHWPass
: public HandshakeLowerExtmemToHWBase<HandshakeLowerExtmemToHWPass> {
: public circt::handshake::impl::HandshakeLowerExtmemToHWBase<
HandshakeLowerExtmemToHWPass> {
HandshakeLowerExtmemToHWPass(std::optional<bool> createESIWrapper) {
if (createESIWrapper)

View File

@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Support/LLVM.h"
@ -22,9 +21,18 @@
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Support/IndentedOstream.h"
#include "llvm/ADT/TypeSwitch.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKEMATERIALIZEFORKSSINKS
#define GEN_PASS_DEF_HANDSHAKEDEMATERIALIZEFORKSSINKS
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -126,7 +134,7 @@ LogicalResult addSinkOps(Region &r, OpBuilder &rewriter) {
namespace {
struct HandshakeMaterializeForksSinksPass
: public HandshakeMaterializeForksSinksBase<
: public circt::handshake::impl::HandshakeMaterializeForksSinksBase<
HandshakeMaterializeForksSinksPass> {
void runOnOperation() override {
handshake::FuncOp op = getOperation();
@ -141,7 +149,7 @@ struct HandshakeMaterializeForksSinksPass
};
struct HandshakeDematerializeForksSinksPass
: public HandshakeDematerializeForksSinksBase<
: public circt::handshake::impl::HandshakeDematerializeForksSinksBase<
HandshakeDematerializeForksSinksPass> {
void runOnOperation() override {
handshake::FuncOp op = getOperation();

View File

@ -1,37 +0,0 @@
//===- PassDetails.h - Handshake pass class details -------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Contains the stuff shared between the different Handshake passes.
//
//===----------------------------------------------------------------------===//
// clang-tidy seems to expect the absolute path in the
// header guard on some systems, so just disable it.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef DIALECT_HANDSHAKE_TRANSFORMS_PASSDETAILS_H
#define DIALECT_HANDSHAKE_TRANSFORMS_PASSDETAILS_H
#include "circt/Dialect/Comb/CombDialect.h"
#include "circt/Dialect/ESI/ESIDialect.h"
#include "circt/Dialect/HW/HWDialect.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Pass/Pass.h"
namespace circt {
namespace handshake {
#define GEN_PASS_CLASSES
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
#endif // DIALECT_HANDSHAKE_TRANSFORMS_PASSDETAILS_H

View File

@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/ESI/ESIOps.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"

View File

@ -10,14 +10,21 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
namespace circt {
namespace handshake {
#define GEN_PASS_DEF_HANDSHAKESPLITMERGES
#include "circt/Dialect/Handshake/HandshakePasses.h.inc"
} // namespace handshake
} // namespace circt
using namespace circt;
using namespace handshake;
using namespace mlir;
@ -118,7 +125,8 @@ struct DeconstructCMergePattern
};
struct HandshakeSplitMerges
: public HandshakeSplitMergesBase<HandshakeSplitMerges> {
: public circt::handshake::impl::HandshakeSplitMergesBase<
HandshakeSplitMerges> {
void runOnOperation() override {
RewritePatternSet patterns(&getContext());
patterns.insert<DeconstructCMergePattern, DeconstructMergePattern>(

View File

@ -10,10 +10,19 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Dialect/Pipeline/PipelineOps.h"
#include "circt/Dialect/Pipeline/PipelinePasses.h"
#include "circt/Support/BackedgeBuilder.h"
#include "mlir/Pass/Pass.h"
#include "llvm/Support/Debug.h"
namespace circt {
namespace pipeline {
#define GEN_PASS_DEF_EXPLICITREGS
#include "circt/Dialect/Pipeline/PipelinePasses.h.inc"
} // namespace pipeline
} // namespace circt
using namespace mlir;
using namespace circt;
using namespace pipeline;
@ -28,7 +37,8 @@ struct NamedValue {
operator llvm::StringRef() const { return name.getValue(); }
};
class ExplicitRegsPass : public ExplicitRegsBase<ExplicitRegsPass> {
class ExplicitRegsPass
: public circt::pipeline::impl::ExplicitRegsBase<ExplicitRegsPass> {
public:
void runOnOperation() override;

View File

@ -1,35 +0,0 @@
//===- PassDetails.h - Pipeline pass class details --------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Contains the stuff shared between the different Pipeline passes.
//
//===----------------------------------------------------------------------===//
// clang-tidy seems to expect the absolute path in the
// header guard on some systems, so just disable it.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef DIALECT_PIPELINE_TRANSFORMS_PASSDETAILS_H
#define DIALECT_PIPELINE_TRANSFORMS_PASSDETAILS_H
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/Pipeline/PipelineOps.h"
#include "circt/Dialect/Pipeline/PipelinePasses.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "mlir/Pass/Pass.h"
namespace circt {
namespace pipeline {
#define GEN_PASS_CLASSES
#include "circt/Dialect/Pipeline/PipelinePasses.h.inc"
} // namespace pipeline
} // namespace circt
#endif // DIALECT_PIPELINE_TRANSFORMS_PASSDETAILS_H

View File

@ -10,18 +10,27 @@
//
//===----------------------------------------------------------------------===//
#include "PassDetails.h"
#include "circt/Analysis/DependenceAnalysis.h"
#include "circt/Analysis/SchedulingAnalysis.h"
#include "circt/Dialect/HW/HWOpInterfaces.h"
#include "circt/Dialect/Pipeline/PipelineOps.h"
#include "circt/Dialect/Pipeline/PipelinePasses.h"
#include "circt/Dialect/SSP/SSPOps.h"
#include "circt/Dialect/SSP/Utilities.h"
#include "circt/Scheduling/Algorithms.h"
#include "circt/Scheduling/Utilities.h"
#include "circt/Support/BackedgeBuilder.h"
#include "mlir/Pass/Pass.h"
#define DEBUG_TYPE "pipeline-schedule-linear"
namespace circt {
namespace pipeline {
#define GEN_PASS_DEF_SCHEDULELINEARPIPELINE
#include "circt/Dialect/Pipeline/PipelinePasses.h.inc"
} // namespace pipeline
} // namespace circt
using namespace mlir;
using namespace circt;
using namespace circt::scheduling;
@ -30,7 +39,8 @@ using namespace pipeline;
namespace {
class ScheduleLinearPipelinePass
: public ScheduleLinearPipelineBase<ScheduleLinearPipelinePass> {
: public circt::pipeline::impl::ScheduleLinearPipelineBase<
ScheduleLinearPipelinePass> {
public:
void runOnOperation() override;