Skip to content

Commit

Permalink
[FIRRTL] Print port names attributes if a port has an empty name (#7688)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwy7 authored Oct 9, 2024
1 parent 6b5b63c commit 5f62873
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Dialect/FIRRTL/FIRRTLOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ printModulePorts(OpAsmPrinter &p, Block *block, ArrayRef<bool> portDirections,
// If the name wasn't printable in a way that agreed with portName, make
// sure to print out an explicit portNames attribute.
auto portName = cast<StringAttr>(portNames[i]).getValue();
if (!portName.empty() && tmpStream.str().drop_front() != portName)
if (tmpStream.str().drop_front() != portName)
printedNamesDontMatch = true;
p << tmpStream.str();
} else {
Expand Down
12 changes: 6 additions & 6 deletions test/Dialect/FIRRTL/lower-layers.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ firrtl.circuit "Test" {
}
}

// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>) {
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>)
// CHECK: %w = firrtl.wire : !firrtl.uint<1>
// CHECK: firrtl.connect %w, %[[p]] : !firrtl.uint<1>
// CHECK: }
Expand All @@ -130,7 +130,7 @@ firrtl.circuit "Test" {
}
}

// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>) {
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>)
// CHECK: %0 = firrtl.ref.send %[[p]] : !firrtl.uint<1>
// CHECK: %1 = firrtl.ref.resolve %0 : !firrtl.probe<uint<1>>
// CHECK: }
Expand Down Expand Up @@ -180,7 +180,7 @@ firrtl.circuit "Test" {
}
}

// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>) {
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>)
// CHECK: %c1_ui1 = firrtl.constant 1 : !firrtl.uint<1>
// CHECK: firrtl.when %[[p]] : !firrtl.uint<1> {
// CHECK: %0 = firrtl.add %[[p]], %c1_ui1 : (!firrtl.uint<1>, !firrtl.uint<1>) -> !firrtl.uint<2>
Expand Down Expand Up @@ -248,7 +248,7 @@ firrtl.circuit "Test" {

// Src Outside Layerblock.
//
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>) {
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>)
// CHECK: %0 = firrtl.ref.send %[[p]] : !firrtl.uint<1>
// CHECK: %1 = firrtl.wire : !firrtl.probe<uint<1>>
// CHECK: firrtl.ref.define %1, %0 : !firrtl.probe<uint<1>>
Expand All @@ -269,7 +269,7 @@ firrtl.circuit "Test" {

// Dst Outside Layerblock.
//
// CHECK: firrtl.module private @[[A:.+]](out %[[p:.+]]: !firrtl.probe<uint<1>>) {
// CHECK: firrtl.module private @[[A:.+]](out %[[p:.+]]: !firrtl.probe<uint<1>>)
// CHECK: %0 = firrtl.wire : !firrtl.probe<uint<1>>
// CHECK: firrtl.ref.define %[[p]], %0 : !firrtl.probe<uint<1>>
// CHECK: }
Expand Down Expand Up @@ -575,7 +575,7 @@ firrtl.circuit "CaptureHardwareMultipleTimes" {

firrtl.extmodule @CaptureHardwareMultipleTimes ()

// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>) {
// CHECK: firrtl.module private @[[A:.+]](in %[[p:.+]]: !firrtl.uint<1>)
// CHECK: %0 = firrtl.add %[[p]], %[[p]] : (!firrtl.uint<1>, !firrtl.uint<1>) -> !firrtl.uint<2>
// CHECK: }
// CHECK: firrtl.module @CaptureSrcTwice() {
Expand Down
3 changes: 3 additions & 0 deletions test/Dialect/FIRRTL/round-trip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ firrtl.circuit "Basic" attributes {
} {
firrtl.extmodule @Basic()

// CHECK: firrtl.module @Top(in %arg0: !firrtl.uint<1>) attributes {portNames = [""]}
firrtl.module @Top(in %arg0: !firrtl.uint<1>) attributes {portNames = [""]} {}

// CHECK-LABEL: firrtl.module @Intrinsics
firrtl.module @Intrinsics(in %ui : !firrtl.uint, in %clock: !firrtl.clock, in %ui1: !firrtl.uint<1>) {
// CHECK-NEXT: firrtl.int.sizeof %ui : (!firrtl.uint) -> !firrtl.uint<32>
Expand Down

0 comments on commit 5f62873

Please sign in to comment.