Skip to content

Commit

Permalink
[FIRRTL] Add OpenAgg support to getFieldName, fix diagnostic.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dtzSiFive committed Oct 6, 2023
1 parent 71a78d6 commit 8fcb732
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Dialect/FIRRTL/FIRRTLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpenBundleType>(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<FVectorType>(type)) {
auto index = vecType.getIndexForFieldID(localID);
name += nameSafe ? "_" : "[";
Expand All @@ -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<OpenVectorType>(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<FEnumType>(type)) {
auto index = enumType.getIndexForFieldID(localID);
auto &element = enumType.getElements()[index];
Expand Down

0 comments on commit 8fcb732

Please sign in to comment.