Skip to content

Commit

Permalink
[MooreToCore][NFC] Fix the visibility of hw.module. (#7396)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailongSun2000 authored Jul 29, 2024
1 parent 756166e commit 759ef12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ struct SVModuleOpConversion : public OpConversionPattern<SVModuleOp> {
auto outputOp = op.getOutputOp();
rewriter.setInsertionPoint(op);

// Create the hw.module to replace svmoduleOp
// Create the hw.module to replace moore.module
auto hwModuleOp =
rewriter.create<hw::HWModuleOp>(op.getLoc(), op.getSymNameAttr(),
getModulePortInfo(*typeConverter, op));
// Make hw.module have the same visibility as the moore.module.
// The entry/top level module is public, otherwise is private.
SymbolTable::setSymbolVisibility(hwModuleOp,
SymbolTable::getSymbolVisibility(op));
rewriter.eraseBlock(hwModuleOp.getBodyBlock());
rewriter.inlineRegionBefore(op.getBodyRegion(), hwModuleOp.getBodyRegion(),
hwModuleOp.getBodyRegion().end());
Expand Down
8 changes: 4 additions & 4 deletions test/Conversion/MooreToCore/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ moore.module @InstanceNull() {
moore.output
}

// CHECK-LABEL: hw.module @Null() {
moore.module @Null() {
// CHECK-LABEL: hw.module private @Null() {
moore.module private @Null() {

// CHECK-NEXT: hw.output
moore.output
Expand All @@ -222,10 +222,10 @@ moore.module @Top(in %arg0 : !moore.l1, in %arg1 : !moore.l1, out out0 : !moore.
moore.output %inst_1.c : !moore.l1
}

// CHECK-LABEL: hw.module @SubModule_0(in
// CHECK-LABEL: hw.module private @SubModule_0(in
// CHECK-SAME: %[[V0:.*]] : i1, in
// CHECK-SAME: %[[V1:.*]] : i1, out c : i1) {
moore.module @SubModule_0(in %a : !moore.l1, in %b : !moore.l1, out c : !moore.l1) {
moore.module private @SubModule_0(in %a : !moore.l1, in %b : !moore.l1, out c : !moore.l1) {
// CHECK-NEXT: %[[V2:.*]] = comb.and %[[V0]], %[[V1]] : i1
%0 = moore.and %a, %b : !moore.l1

Expand Down

0 comments on commit 759ef12

Please sign in to comment.