Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HW] Moved and renamed arc/inlineModules to hw/flattenModules #6964

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/circt/Dialect/Arc/ArcPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ std::unique_ptr<mlir::Pass> createGroupResetsAndEnablesPass();
std::unique_ptr<mlir::Pass>
createInferMemoriesPass(const InferMemoriesOptions &options = {});
std::unique_ptr<mlir::Pass> createInlineArcsPass();
std::unique_ptr<mlir::Pass> createInlineModulesPass();
std::unique_ptr<mlir::Pass> createIsolateClocksPass();
std::unique_ptr<mlir::Pass> createLatencyRetimingPass();
std::unique_ptr<mlir::Pass> createLegalizeStateUpdatePass();
Expand Down
14 changes: 0 additions & 14 deletions include/circt/Dialect/Arc/ArcPasses.td
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ def InlineArcs : Pass<"arc-inline" , "mlir::ModuleOp"> {
];
}

def InlineModules : Pass<"arc-inline-modules", "mlir::ModuleOp"> {
let summary = "Eagerly inline private modules";
let description = [{
This pass eagerly inlines private HW modules into their instantiation sites.
After outlining combinational logic and registers into arcs, module bodies
become fairly lightweight. Since arc definitions now fulfill the purpose of
code reuse by allowing a single definition to be called multiple times, the
module hierarchy degenerates into a purely cosmetic construct. At that point
it is beneficial to fully flatten the module hierarchy to simplify further
analysis and optimization of state transfer arcs.
}];
let constructor = "circt::arc::createInlineModulesPass()";
}

def InferStateProperties : Pass<"arc-infer-state-properties",
"mlir::ModuleOp"> {
let summary = "Add resets and enables explicitly to the state operations";
Expand Down
1 change: 1 addition & 0 deletions include/circt/Dialect/HW/HWPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ std::unique_ptr<mlir::Pass> createFlattenIOPass(bool recursiveFlag = true,
bool flattenExternFlag = false,
char joinChar = '.');
std::unique_ptr<mlir::Pass> createVerifyInnerRefNamespacePass();
std::unique_ptr<mlir::Pass> createFlattenModulesPass();

/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
Expand Down
13 changes: 13 additions & 0 deletions include/circt/Dialect/HW/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ def FlattenIO : Pass<"hw-flatten-io", "mlir::ModuleOp"> {
];
}

def FlattenModules : Pass<"hw-flatten-modules", "mlir::ModuleOp"> {
let summary = "Eagerly inline private modules";
let description = [{
This pass eagerly inlines private HW modules into their instantiation sites.
This is necessary for verification purposes, as model checking backends do not
require or support the use of module hierarchy. For simulation, module hierarchies
degenerate into a purely cosmetic construct, at which point it is beneficial
to fully flatten the module hierarchy to simplify further analysis and
optimization of state transfer arcs.
}];
let constructor = "circt::hw::createFlattenModulesPass()";
}

def HWSpecialize : Pass<"hw-specialize", "mlir::ModuleOp"> {
let summary = "Specializes instances of parametric hw.modules";
let constructor = "circt::hw::createHWSpecializePass()";
Expand Down
1 change: 0 additions & 1 deletion lib/Dialect/Arc/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ add_circt_dialect_library(CIRCTArcTransforms
InferMemories.cpp
InferStateProperties.cpp
InlineArcs.cpp
InlineModules.cpp
IsolateClocks.cpp
LatencyRetiming.cpp
LegalizeStateUpdate.cpp
Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/HW/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_circt_dialect_library(CIRCTHWTransforms
PrintHWModuleGraph.cpp
FlattenIO.cpp
VerifyInnerRefNamespace.cpp
FlattenModules.cpp

DEPENDS
CIRCTHWTransformsIncGen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
//===- InlineModules.cpp --------------------------------------------------===//
//===- FlattenModules.cpp
//--------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "circt/Dialect/Arc/ArcOps.h"
#include "circt/Dialect/Arc/ArcPasses.h"
#include "circt/Dialect/HW/HWInstanceGraph.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWPasses.h"
#include "circt/Support/BackedgeBuilder.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/Support/Debug.h"

#define DEBUG_TYPE "arc-inline-modules"
#define DEBUG_TYPE "hw-flatten-modules"

namespace circt {
namespace arc {
#define GEN_PASS_DEF_INLINEMODULES
#include "circt/Dialect/Arc/ArcPasses.h.inc"
} // namespace arc
namespace hw {
#define GEN_PASS_DEF_FLATTENMODULES
#include "circt/Dialect/HW/Passes.h.inc"
} // namespace hw
} // namespace circt

using namespace circt;
using namespace arc;
using namespace hw;
using namespace igraph;
using mlir::InlinerInterface;

namespace {
struct InlineModulesPass
: public arc::impl::InlineModulesBase<InlineModulesPass> {
struct FlattenModulesPass
: public circt::hw::impl::FlattenModulesBase<FlattenModulesPass> {
void runOnOperation() override;
};

Expand Down Expand Up @@ -90,7 +89,7 @@ struct PrefixingInliner : public InlinerInterface {
};
} // namespace

void InlineModulesPass::runOnOperation() {
void FlattenModulesPass::runOnOperation() {
auto &instanceGraph = getAnalysis<hw::InstanceGraph>();
DenseSet<Operation *> handled;

Expand Down Expand Up @@ -144,6 +143,6 @@ void InlineModulesPass::runOnOperation() {
}
}

std::unique_ptr<Pass> arc::createInlineModulesPass() {
return std::make_unique<InlineModulesPass>();
std::unique_ptr<Pass> circt::hw::createFlattenModulesPass() {
return std::make_unique<FlattenModulesPass>();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: circt-opt %s --arc-inline-modules | FileCheck %s
// RUN: circt-opt %s --hw-flatten-modules | FileCheck %s


// CHECK-LABEL: hw.module @SimpleA
Expand Down
1 change: 1 addition & 0 deletions tools/arcilator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_circt_tool(arcilator arcilator.cpp)
target_link_libraries(arcilator
PRIVATE
CIRCTArc
CIRCTHWTransforms
CIRCTArcToLLVM
CIRCTArcTransforms
CIRCTCombToArith
Expand Down
3 changes: 2 additions & 1 deletion tools/arcilator/arcilator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "circt/Dialect/Arc/ModelInfo.h"
#include "circt/Dialect/Arc/ModelInfoExport.h"
#include "circt/Dialect/Emit/EmitDialect.h"
#include "circt/Dialect/HW/HWPasses.h"
#include "circt/Dialect/Seq/SeqPasses.h"
#include "circt/InitAllDialects.h"
#include "circt/InitAllPasses.h"
Expand Down Expand Up @@ -256,7 +257,7 @@ static void populateHwModuleToArcPipeline(PassManager &pm) {
}
if (shouldDedup)
pm.addPass(arc::createDedupPass());
pm.addPass(arc::createInlineModulesPass());
pm.addPass(hw::createFlattenModulesPass());
pm.addPass(createCSEPass());
pm.addPass(arc::createArcCanonicalizerPass());

Expand Down
Loading