From 8fcb732efa718e1c2522812882815cef549c2cce Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 5 Oct 2023 20:20:30 -0500 Subject: [PATCH] [FIRRTL] Add OpenAgg support to getFieldName, fix diagnostic. These disappear early but some diagnostics, such as flow checking, use this method so implement it. This shouldn't be "unreachable", but that's a different fix. --- lib/Dialect/FIRRTL/FIRRTLUtils.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/Dialect/FIRRTL/FIRRTLUtils.cpp b/lib/Dialect/FIRRTL/FIRRTLUtils.cpp index e6777776a8d1..02985be25432 100644 --- a/lib/Dialect/FIRRTL/FIRRTLUtils.cpp +++ b/lib/Dialect/FIRRTL/FIRRTLUtils.cpp @@ -593,6 +593,16 @@ circt::firrtl::getFieldName(const FieldRef &fieldRef, bool nameSafe) { // Recurse in to the element type. type = element.type; localID = localID - bundleType.getFieldID(index); + } else if (auto bundleType = type_dyn_cast(type)) { + auto index = bundleType.getIndexForFieldID(localID); + // Add the current field string, and recurse into a subfield. + auto &element = bundleType.getElements()[index]; + if (!name.empty()) + name += nameSafe ? "_" : "."; + name += element.name.getValue(); + // Recurse in to the element type. + type = element.type; + localID = localID - bundleType.getFieldID(index); } else if (auto vecType = type_dyn_cast(type)) { auto index = vecType.getIndexForFieldID(localID); name += nameSafe ? "_" : "["; @@ -602,6 +612,15 @@ circt::firrtl::getFieldName(const FieldRef &fieldRef, bool nameSafe) { // Recurse in to the element type. type = vecType.getElementType(); localID = localID - vecType.getFieldID(index); + } else if (auto vecType = type_dyn_cast(type)) { + auto index = vecType.getIndexForFieldID(localID); + name += nameSafe ? "_" : "["; + name += std::to_string(index); + if (!nameSafe) + name += "]"; + // Recurse in to the element type. + type = vecType.getElementType(); + localID = localID - vecType.getFieldID(index); } else if (auto enumType = type_dyn_cast(type)) { auto index = enumType.getIndexForFieldID(localID); auto &element = enumType.getElements()[index];