Skip to content

Commit 759ef12

Browse files
author
Hailong Sun
authored
[MooreToCore][NFC] Fix the visibility of hw.module. (#7396)
1 parent 756166e commit 759ef12

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/Conversion/MooreToCore/MooreToCore.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ struct SVModuleOpConversion : public OpConversionPattern<SVModuleOp> {
103103
auto outputOp = op.getOutputOp();
104104
rewriter.setInsertionPoint(op);
105105

106-
// Create the hw.module to replace svmoduleOp
106+
// Create the hw.module to replace moore.module
107107
auto hwModuleOp =
108108
rewriter.create<hw::HWModuleOp>(op.getLoc(), op.getSymNameAttr(),
109109
getModulePortInfo(*typeConverter, op));
110+
// Make hw.module have the same visibility as the moore.module.
111+
// The entry/top level module is public, otherwise is private.
112+
SymbolTable::setSymbolVisibility(hwModuleOp,
113+
SymbolTable::getSymbolVisibility(op));
110114
rewriter.eraseBlock(hwModuleOp.getBodyBlock());
111115
rewriter.inlineRegionBefore(op.getBodyRegion(), hwModuleOp.getBodyRegion(),
112116
hwModuleOp.getBodyRegion().end());

test/Conversion/MooreToCore/basic.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ moore.module @InstanceNull() {
201201
moore.output
202202
}
203203

204-
// CHECK-LABEL: hw.module @Null() {
205-
moore.module @Null() {
204+
// CHECK-LABEL: hw.module private @Null() {
205+
moore.module private @Null() {
206206

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

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

0 commit comments

Comments
 (0)