From 9a0bbb116fe743e1a6b7043a5223670f407c6241 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Thu, 4 Jan 2024 18:18:46 -0500 Subject: [PATCH] [FIRRTL] Emit Layer-associated Probes Add emitter support for layer-associated probes. Signed-off-by: Schuyler Eldridge --- lib/Dialect/FIRRTL/Export/FIREmitter.cpp | 8 ++++++++ test/Dialect/FIRRTL/emit-basic.mlir | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Dialect/FIRRTL/Export/FIREmitter.cpp b/lib/Dialect/FIRRTL/Export/FIREmitter.cpp index 82b00f6f9f18..6fb7dbed770d 100644 --- a/lib/Dialect/FIRRTL/Export/FIREmitter.cpp +++ b/lib/Dialect/FIRRTL/Export/FIREmitter.cpp @@ -1378,6 +1378,14 @@ void Emitter::emitType(Type type, bool includeConst) { ps << "RW"; ps << "Probe<"; emitType(type.getType()); + if (auto layer = type.getLayer()) { + ps << "," << PP::nbsp; + ps.addAsString(layer.getRootReference().getValue()); + for (auto nested : layer.getNestedReferences()) { + ps << "."; + ps.addAsString(nested.getValue()); + } + } ps << ">"; }) .Case([&](AnyRefType type) { ps << "AnyRef"; }) diff --git a/test/Dialect/FIRRTL/emit-basic.mlir b/test/Dialect/FIRRTL/emit-basic.mlir index 5989c26fdc9e..52311f4dc451 100644 --- a/test/Dialect/FIRRTL/emit-basic.mlir +++ b/test/Dialect/FIRRTL/emit-basic.mlir @@ -704,13 +704,18 @@ firrtl.circuit "Foo" { } } // CHECK: module ModuleWithGroups : - // CHECK-NEXT: layerblock GroupA : + // CHECK-NEXT: output a : Probe, GroupA> + // CHECK-NEXT: output b : RWProbe, GroupA.GroupB> + // CHECK: layerblock GroupA : // CHECK-NEXT: layerblock GroupB : // CHECK-NEXT: layerblock GroupC : // CHECK-NEXT: layerblock GroupD : // CHECK-NEXT: layerblock GroupE : // CHECK-NEXT: layerblock GroupF : - firrtl.module @ModuleWithGroups() { + firrtl.module @ModuleWithGroups( + out %a: !firrtl.probe, @GroupA>, + out %b: !firrtl.rwprobe, @GroupA::@GroupB> + ) { firrtl.layerblock @GroupA { firrtl.layerblock @GroupA::@GroupB { firrtl.layerblock @GroupA::@GroupB::@GroupC {