diff --git a/include/circt/Dialect/FIRRTL/FIRParser.h b/include/circt/Dialect/FIRRTL/FIRParser.h index 1177b4ca51ec..3250a39ffbbf 100644 --- a/include/circt/Dialect/FIRRTL/FIRParser.h +++ b/include/circt/Dialect/FIRRTL/FIRParser.h @@ -46,7 +46,7 @@ struct FIRParserOptions { /// This, along with numOMIRFiles provides structure to the buffers in the /// source manager. unsigned numAnnotationFiles; - bool scalarizeTopModule = false; + bool scalarizePublicModules = false; bool scalarizeExtModules = false; }; diff --git a/lib/Dialect/FIRRTL/Import/FIRParser.cpp b/lib/Dialect/FIRRTL/Import/FIRParser.cpp index a41f8384b5a0..af9ed4e340ac 100644 --- a/lib/Dialect/FIRRTL/Import/FIRParser.cpp +++ b/lib/Dialect/FIRRTL/Import/FIRParser.cpp @@ -4573,7 +4573,7 @@ ParseResult FIRCircuitParser::parseExtModule(CircuitOp circuit, auto builder = circuit.getBodyBuilder(); auto isMainModule = (name == circuit.getName()); auto convention = - (isMainModule && getConstants().options.scalarizeTopModule) || + (isMainModule && getConstants().options.scalarizePublicModules) || getConstants().options.scalarizeExtModules ? Convention::Scalarized : Convention::Internal; @@ -4638,19 +4638,20 @@ ParseResult FIRCircuitParser::parseModule(CircuitOp circuit, bool isPublic, info.parseOptionalInfo() || parsePortList(portList, portLocs, indent)) return failure(); - auto circuitName = circuit.getName(); - auto isMainModule = (name == circuitName); + // The main module is implicitly public. + isPublic |= name == circuit.getName(); + ArrayAttr annotations = getConstants().emptyArrayAttr; auto convention = Convention::Internal; - if (isMainModule && getConstants().options.scalarizeTopModule) + if (isPublic && getConstants().options.scalarizePublicModules) convention = Convention::Scalarized; auto conventionAttr = ConventionAttr::get(getContext(), convention); auto builder = circuit.getBodyBuilder(); auto moduleOp = builder.create(info.getLoc(), name, conventionAttr, portList, annotations); - auto visibility = isMainModule || isPublic ? SymbolTable::Visibility::Public - : SymbolTable::Visibility::Private; + auto visibility = isPublic ? SymbolTable::Visibility::Public + : SymbolTable::Visibility::Private; SymbolTable::setSymbolVisibility(moduleOp, visibility); // Parse the body of this module after all prototypes have been parsed. This diff --git a/test/firtool/convention.fir b/test/firtool/convention.fir index e035c542ca86..6e767cd379da 100644 --- a/test/firtool/convention.fir +++ b/test/firtool/convention.fir @@ -1,29 +1,29 @@ -; RUN: firtool %s --format=fir --parse-only --scalarize-top-module=false --scalarize-ext-modules=false --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_NONE %s -; RUN: firtool %s --format=fir --parse-only --scalarize-top-module=true --scalarize-ext-modules=false --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_TOP %s -; RUN: firtool %s --format=fir --parse-only --scalarize-top-module=false --scalarize-ext-modules=true --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_EXT %s -; RUN: firtool %s --format=fir --parse-only --scalarize-top-module=true --scalarize-ext-modules=true --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_BOTH %s +; RUN: firtool %s --format=fir --parse-only --scalarize-public-modules=false --scalarize-ext-modules=false --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_NONE %s +; RUN: firtool %s --format=fir --parse-only --scalarize-public-modules=true --scalarize-ext-modules=false --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_PUB %s +; RUN: firtool %s --format=fir --parse-only --scalarize-public-modules=false --scalarize-ext-modules=true --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_EXT %s +; RUN: firtool %s --format=fir --parse-only --scalarize-public-modules=true --scalarize-ext-modules=true --preserve-aggregate=all | FileCheck --check-prefix=SCALARIZE_BOTH %s ; Ensure that top module and ext modules are marked scalarized. circuit Top : ; SCALARIZE_NONE-NOT: attributes {convention = #firrtl} - ; SCALARIZE_TOP: attributes {convention = #firrtl} + ; SCALARIZE_PUB: attributes {convention = #firrtl} ; SCALARIZE_EXT-NOT: attributes {convention = #firrtl} ; SCALARIZE_BOTH: attributes {convention = #firrtl} module Top : output port: UInt<8>[2] port[0] <= UInt<8>(0) port[1] <= UInt<8>(0) - + ; SCALARIZE_NONE-NOT: attributes {convention = #firrtl} - ; SCALARIZE_TOP-NOT: attributes {convention = #firrtl} + ; SCALARIZE_PUB-NOT: attributes {convention = #firrtl} ; SCALARIZE_EXT: attributes {convention = #firrtl} ; SCALARIZE_BOTH: attributes {convention = #firrtl} extmodule External : output port: UInt<8>[2] ; SCALARIZE_NONE-NOT: attributes {convention = #firrtl} - ; SCALARIZE_TOP-NOT: attributes {convention = #firrtl} + ; SCALARIZE_PUB-NOT: attributes {convention = #firrtl} ; SCALARIZE_EXT-NOT: attributes {convention = #firrtl} ; SCALARIZE_BOTH-NOT: attributes {convention = #firrtl} module Internal : diff --git a/test/firtool/refs-in-aggs.fir b/test/firtool/refs-in-aggs.fir index 15ce6bc17020..361f7cb6ae61 100644 --- a/test/firtool/refs-in-aggs.fir +++ b/test/firtool/refs-in-aggs.fir @@ -1,6 +1,6 @@ ; Check this design makes it through firtool. ; RUN: firtool %s --no-dedup -; RUN: firtool %s --no-dedup --preserve-aggregate=all --scalarize-top-module=false +; RUN: firtool %s --no-dedup --preserve-aggregate=all --scalarize-public-modules=false ; Check parsing into open aggregates. ; RUN: circt-translate -import-firrtl -verify-diagnostics -split-input-file %s | circt-opt | FileCheck %s diff --git a/test/firtool/spec/refs/define-flip-to-passive.fir b/test/firtool/spec/refs/define-flip-to-passive.fir index ea808c112a58..8490369185e3 100644 --- a/test/firtool/spec/refs/define-flip-to-passive.fir +++ b/test/firtool/spec/refs/define-flip-to-passive.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Foo : ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/define-subelement.fir b/test/firtool/spec/refs/define-subelement.fir index 594af2e8257a..52db24ef6e6d 100644 --- a/test/firtool/spec/refs/define-subelement.fir +++ b/test/firtool/spec/refs/define-subelement.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Foo: ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/define.fir b/test/firtool/spec/refs/define.fir index e4547e9e3ff5..642aee87bb90 100644 --- a/test/firtool/spec/refs/define.fir +++ b/test/firtool/spec/refs/define.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Refs: ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/endpoints.fir b/test/firtool/spec/refs/endpoints.fir index c1b2f3dc3f44..af3b3daefd46 100644 --- a/test/firtool/spec/refs/endpoints.fir +++ b/test/firtool/spec/refs/endpoints.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Top : %[[ { "class": "firrtl.transforms.DontTouchAnnotation", "target": "~Top|Top>producer_debug"}, diff --git a/test/firtool/spec/refs/ext.fir b/test/firtool/spec/refs/ext.fir index c5d16f94aed4..acaef18b8576 100644 --- a/test/firtool/spec/refs/ext.fir +++ b/test/firtool/spec/refs/ext.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false circuit MyExternalModuleWithRefs : ; SPEC EXAMPLE BEGIN extmodule MyExternalModuleWithRefs : diff --git a/test/firtool/spec/refs/force_and_release.fir b/test/firtool/spec/refs/force_and_release.fir index af4dae829832..574ac2a1e9aa 100644 --- a/test/firtool/spec/refs/force_and_release.fir +++ b/test/firtool/spec/refs/force_and_release.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit ForceAndRelease: ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/force_initial.fir b/test/firtool/spec/refs/force_initial.fir index 6481e3fc1d32..e24cdc48d07d 100644 --- a/test/firtool/spec/refs/force_initial.fir +++ b/test/firtool/spec/refs/force_initial.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit ForceAndRelease: diff --git a/test/firtool/spec/refs/force_nonpassive.fir b/test/firtool/spec/refs/force_nonpassive.fir index cd99a77a945d..f459371a6d43 100644 --- a/test/firtool/spec/refs/force_nonpassive.fir +++ b/test/firtool/spec/refs/force_nonpassive.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false -verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false -verify-diagnostics FIRRTL version 3.0.0 circuit Top : diff --git a/test/firtool/spec/refs/forwarding_refs_upwards.fir b/test/firtool/spec/refs/forwarding_refs_upwards.fir index 28f1d53c5d33..0912e68cb2e9 100644 --- a/test/firtool/spec/refs/forwarding_refs_upwards.fir +++ b/test/firtool/spec/refs/forwarding_refs_upwards.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false circuit Forward: ; SPEC EXAMPLE BEGIN extmodule Foo : ; XXX: module -> extmodule diff --git a/test/firtool/spec/refs/forwarding_refs_upwards_narrow.fir b/test/firtool/spec/refs/forwarding_refs_upwards_narrow.fir index 3b058eb8893b..1862d039fb4b 100644 --- a/test/firtool/spec/refs/forwarding_refs_upwards_narrow.fir +++ b/test/firtool/spec/refs/forwarding_refs_upwards_narrow.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false circuit Forward : ; SPEC EXAMPLE BEGIN extmodule Foo : diff --git a/test/firtool/spec/refs/in_ref_context.fir b/test/firtool/spec/refs/in_ref_context.fir index 0b4d383350fa..59fa1e22c38c 100644 --- a/test/firtool/spec/refs/in_ref_context.fir +++ b/test/firtool/spec/refs/in_ref_context.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false -verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false -verify-diagnostics FIRRTL version 3.0.0 ; expected-error @+27 {{input probes cannot be used}} ; expected-note @+19 {{input probe here}} diff --git a/test/firtool/spec/refs/inference_reset_bad.fir b/test/firtool/spec/refs/inference_reset_bad.fir index 8888b9fc8faa..16459565a90f 100644 --- a/test/firtool/spec/refs/inference_reset_bad.fir +++ b/test/firtool/spec/refs/inference_reset_bad.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false -verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false -verify-diagnostics ; XFAIL: * ; https://github.com/llvm/circt/issues/4813 FIRRTL version 3.0.0 diff --git a/test/firtool/spec/refs/inference_reset_good.fir b/test/firtool/spec/refs/inference_reset_good.fir index 7a9f608afccf..47f9e14e4e70 100644 --- a/test/firtool/spec/refs/inference_reset_good.fir +++ b/test/firtool/spec/refs/inference_reset_good.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit ResetInferGood : ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/inference_works.fir b/test/firtool/spec/refs/inference_works.fir index a9bef8468266..b86d2ec8572e 100644 --- a/test/firtool/spec/refs/inference_works.fir +++ b/test/firtool/spec/refs/inference_works.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false ; NOT SPEC EXAMPLE FIRRTL version 3.0.0 @@ -16,4 +16,3 @@ circuit MinimumWidth : inst u of Uninferred connect u.x, x connect y, read(u.r) - diff --git a/test/firtool/spec/refs/invalid_in.fir b/test/firtool/spec/refs/invalid_in.fir index de58093bf7aa..9837c9bbdfa0 100644 --- a/test/firtool/spec/refs/invalid_in.fir +++ b/test/firtool/spec/refs/invalid_in.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s --verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false --verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false --verify-diagnostics FIRRTL version 3.0.0 circuit FooUser: ; Invalid, per spec diff --git a/test/firtool/spec/refs/nested_refproducer.fir b/test/firtool/spec/refs/nested_refproducer.fir index ed0c67ae7521..38adfbe910e2 100644 --- a/test/firtool/spec/refs/nested_refproducer.fir +++ b/test/firtool/spec/refs/nested_refproducer.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit RefProducer : ; SPEC EXAMPLE BEGIN diff --git a/test/firtool/spec/refs/nosubaccess.fir b/test/firtool/spec/refs/nosubaccess.fir index f2edb0362e15..c4b90b09421e 100644 --- a/test/firtool/spec/refs/nosubaccess.fir +++ b/test/firtool/spec/refs/nosubaccess.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false circuit NoSubAccessesWithProbes : extmodule Ext : output x : {a : Probe[2]>, b : UInt<2>}[3] diff --git a/test/firtool/spec/refs/probe_export_simple.fir b/test/firtool/spec/refs/probe_export_simple.fir index b7836c5822fe..3dbf21fafe20 100644 --- a/test/firtool/spec/refs/probe_export_simple.fir +++ b/test/firtool/spec/refs/probe_export_simple.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false circuit MyModule : ; SPEC EXAMPLE BEGIN module MyModule : @@ -8,4 +8,3 @@ circuit MyModule : define r = probe(in) ; SPEC EXAMPLE END - diff --git a/test/firtool/spec/refs/read.fir b/test/firtool/spec/refs/read.fir index d802db4622af..e3339ba508a9 100644 --- a/test/firtool/spec/refs/read.fir +++ b/test/firtool/spec/refs/read.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Foo : diff --git a/test/firtool/spec/refs/read_subelement.fir b/test/firtool/spec/refs/read_subelement.fir index b63a19bdf8b0..3a45d4b2494c 100644 --- a/test/firtool/spec/refs/read_subelement.fir +++ b/test/firtool/spec/refs/read_subelement.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Foo : @@ -17,4 +17,3 @@ circuit Foo : inst f of Foo connect x, read(f.p.b) ; indirectly access the probed data ; SPEC EXAMPLE END - diff --git a/test/firtool/spec/refs/read_subelement_add.fir b/test/firtool/spec/refs/read_subelement_add.fir index 5e3cac14f8ac..ecccc4c0e057 100644 --- a/test/firtool/spec/refs/read_subelement_add.fir +++ b/test/firtool/spec/refs/read_subelement_add.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit Foo : diff --git a/test/firtool/spec/refs/unused_in.fir b/test/firtool/spec/refs/unused_in.fir index b2a87678c5d0..9ab171ad4280 100644 --- a/test/firtool/spec/refs/unused_in.fir +++ b/test/firtool/spec/refs/unused_in.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false -verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false -verify-diagnostics FIRRTL version 3.0.0 circuit ForwardDownwardsTH : module ForwardDownwardsTH : diff --git a/test/firtool/spec/refs/uturn.fir b/test/firtool/spec/refs/uturn.fir index 77b207102c9f..f7353ac8dfa6 100644 --- a/test/firtool/spec/refs/uturn.fir +++ b/test/firtool/spec/refs/uturn.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -verify-diagnostics -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false -verify-diagnostics +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false -verify-diagnostics FIRRTL version 3.0.0 circuit UTurnTH: module UTurnTH: diff --git a/test/firtool/spec/refs/when_c_force_initial.fir b/test/firtool/spec/refs/when_c_force_initial.fir index 1096b7a7bc72..e2cdd19cfa5c 100644 --- a/test/firtool/spec/refs/when_c_force_initial.fir +++ b/test/firtool/spec/refs/when_c_force_initial.fir @@ -1,5 +1,5 @@ ; RUN: firtool %s -; RUN: firtool %s -preserve-aggregate=all -scalarize-top-module=false +; RUN: firtool %s -preserve-aggregate=all -scalarize-public-modules=false FIRRTL version 3.0.0 circuit WhenCForce : diff --git a/tools/firtool/firtool.cpp b/tools/firtool/firtool.cpp index 85273cb2dd95..878b1c5fa470 100644 --- a/tools/firtool/firtool.cpp +++ b/tools/firtool/firtool.cpp @@ -121,9 +121,9 @@ static cl::opt infoLocHandling( cl::init(InfoLocHandling::PreferInfo), cl::cat(mainCategory)); static cl::opt - scalarizeTopModule("scalarize-top-module", - cl::desc("Scalarize the ports of the top module"), - cl::init(true), cl::cat(mainCategory)); + scalarizePublicModules("scalarize-public-modules", + cl::desc("Scalarize all public modules"), + cl::init(true), cl::cat(mainCategory)); static cl::opt scalarizeExtModules("scalarize-ext-modules", @@ -339,7 +339,7 @@ static LogicalResult processBuffer( firrtl::FIRParserOptions options; options.infoLocatorHandling = infoLocHandling; options.numAnnotationFiles = numAnnotationFiles; - options.scalarizeTopModule = scalarizeTopModule; + options.scalarizePublicModules = scalarizePublicModules; options.scalarizeExtModules = scalarizeExtModules; module = importFIRFile(sourceMgr, &context, parserTimer, options); } else {