Skip to content

Commit

Permalink
[FIRRTL][ResolvePaths] Fix detection of agg target if alias. (#7257)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtzSiFive authored Jul 1, 2024
1 parent 624a3d9 commit 461f893
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Dialect/FIRRTL/Transforms/ResolvePaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ struct PathResolver {
// we are targeting a module, the type will be null.
if (Type targetType = path->ref.getType()) {
auto fieldId = path->fieldIdx;
auto baseType = dyn_cast<FIRRTLBaseType>(targetType);
auto baseType = type_dyn_cast<FIRRTLBaseType>(targetType);
if (!baseType)
return emitError(loc, "unable to target non-hardware type ")
<< targetType;
targetType = hw::FieldIdImpl::getFinalTypeByFieldID(baseType, fieldId);
if (isa<BundleType, FVectorType>(targetType))
if (type_isa<BundleType, FVectorType>(targetType))
return emitError(loc, "unable to target aggregate type ") << targetType;
}

Expand Down
9 changes: 9 additions & 0 deletions test/Dialect/FIRRTL/resolve-paths-errors.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ firrtl.module @BundleTarget(in %a : !firrtl.bundle<>) {

// -----

firrtl.circuit "AliasBundleTarget" {
firrtl.module @AliasBundleTarget(in %a : !firrtl.alias<t, bundle<>>) {
// expected-error @below {{unable to target aggregate type '!firrtl.alias<t, bundle<>>'}}
%0 = firrtl.unresolved_path "OMReferenceTarget:~AliasBundleTarget|AliasBundleTarget>a"
}
}

// -----

firrtl.circuit "VectorTarget" {
firrtl.module @VectorTarget(in %a : !firrtl.vector<uint<1>, 1>) {
// expected-error @below {{unable to target aggregate type '!firrtl.vector<uint<1>, 1>'}}
Expand Down

0 comments on commit 461f893

Please sign in to comment.