diff --git a/lib/Dialect/FIRRTL/Transforms/ModuleInliner.cpp b/lib/Dialect/FIRRTL/Transforms/ModuleInliner.cpp index 59524ff784d3..b2aeaea28a3f 100644 --- a/lib/Dialect/FIRRTL/Transforms/ModuleInliner.cpp +++ b/lib/Dialect/FIRRTL/Transforms/ModuleInliner.cpp @@ -677,12 +677,9 @@ bool Inliner::rename(StringRef prefix, Operation *op, InliningLevel &il) { // Add a prefix to things that has a "name" attribute. We don't prefix // memories since it will affect the name of the generated module. - // TODO: We should find a way to prefix the instance of a memory module. - if (!isa(op)) { - if (auto nameAttr = op->getAttrOfType("name")) - op->setAttr("name", StringAttr::get(op->getContext(), - (prefix + nameAttr.getValue()))); - } + if (auto nameAttr = op->getAttrOfType("name")) + op->setAttr("name", StringAttr::get(op->getContext(), + (prefix + nameAttr.getValue()))); // If the operation has an inner symbol, ensure that it is unique. Record // renames for any NLAs that this participates in if the symbol was renamed. diff --git a/test/Dialect/FIRRTL/inliner.mlir b/test/Dialect/FIRRTL/inliner.mlir index fa37e949e4c6..e263cf6d02c8 100644 --- a/test/Dialect/FIRRTL/inliner.mlir +++ b/test/Dialect/FIRRTL/inliner.mlir @@ -256,11 +256,11 @@ firrtl.module @renaming() { } firrtl.module @declarations(in %clock : !firrtl.clock, in %u8 : !firrtl.uint<8>, in %reset : !firrtl.asyncreset) attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} { %c0_ui8 = firrtl.constant 0 : !firrtl.uint<8> - // CHECK: %cmem = chirrtl.combmem : !chirrtl.cmemory, 8> + // CHECK: %myinst_cmem = chirrtl.combmem : !chirrtl.cmemory, 8> %cmem = chirrtl.combmem : !chirrtl.cmemory, 8> - // CHECK: %mem_read = firrtl.mem Undefined {depth = 1 : i64, name = "mem", portNames = ["read"], readLatency = 0 : i32, writeLatency = 1 : i32} : !firrtl.bundle, en: uint<1>, clk: clock, data flip: sint<42>> + // CHECK: %myinst_mem_read = firrtl.mem Undefined {depth = 1 : i64, name = "myinst_mem", portNames = ["read"], readLatency = 0 : i32, writeLatency = 1 : i32} : !firrtl.bundle, en: uint<1>, clk: clock, data flip: sint<42>> %mem_read = firrtl.mem Undefined {depth = 1 : i64, name = "mem", portNames = ["read"], readLatency = 0 : i32, writeLatency = 1 : i32} : !firrtl.bundle, en: uint<1>, clk: clock, data flip: sint<42>> - // CHECK: %memoryport_data, %memoryport_port = chirrtl.memoryport Read %cmem {name = "memoryport"} : (!chirrtl.cmemory, 8>) -> (!firrtl.uint<8>, !chirrtl.cmemoryport) + // CHECK: %myinst_memoryport_data, %myinst_memoryport_port = chirrtl.memoryport Read %myinst_cmem {name = "myinst_memoryport"} : (!chirrtl.cmemory, 8>) -> (!firrtl.uint<8>, !chirrtl.cmemoryport) %memoryport_data, %memoryport_port = chirrtl.memoryport Read %cmem {name = "memoryport"} : (!chirrtl.cmemory, 8>) -> (!firrtl.uint<8>, !chirrtl.cmemoryport) chirrtl.memoryport.access %memoryport_port[%u8], %clock : !chirrtl.cmemoryport, !firrtl.uint<8>, !firrtl.clock // CHECK: %myinst_node = firrtl.node %myinst_u8 : !firrtl.uint<8> @@ -269,7 +269,7 @@ firrtl.module @declarations(in %clock : !firrtl.clock, in %u8 : !firrtl.uint<8>, %reg = firrtl.reg %clock {name = "reg"} : !firrtl.clock, !firrtl.uint<8> // CHECK: %myinst_regreset = firrtl.regreset %myinst_clock, %myinst_reset, %c0_ui8 : !firrtl.clock, !firrtl.asyncreset, !firrtl.uint<8>, !firrtl.uint<8> %regreset = firrtl.regreset %clock, %reset, %c0_ui8 : !firrtl.clock, !firrtl.asyncreset, !firrtl.uint<8>, !firrtl.uint<8> - // CHECK: %smem = chirrtl.seqmem Undefined : !chirrtl.cmemory, 8> + // CHECK: %myinst_smem = chirrtl.seqmem Undefined : !chirrtl.cmemory, 8> %smem = chirrtl.seqmem Undefined : !chirrtl.cmemory, 8> // CHECK: %myinst_wire = firrtl.wire : !firrtl.uint<1> %wire = firrtl.wire : !firrtl.uint<1>