diff options
| author | Schuyler Eldridge | 2021-02-01 15:53:39 -0500 |
|---|---|---|
| committer | GitHub | 2021-02-01 20:53:39 +0000 |
| commit | 81ff0fe30f7dd63cffd0c4cd93b72ebee9c8bec9 (patch) | |
| tree | 2ca4e99a1c1600c7c9e84b2e4cbfb952db5bab45 /src | |
| parent | fd5d4422df395064c87ec415a27a03d5a052088b (diff) | |
Suport ir.SubAccess in Utils.splitRef (#2021)
* Add SubAccess case to Utils.splitRef
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
* Update Utils.splitRef to use IR types
Change Utils.splitRef to use the actual IR types instead of their
WIR aliases. Update the Scaladoc note to reflect this.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index 886ee986..d187ea5f 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -659,19 +659,24 @@ object Utils extends LazyLogging { * Given: SubField(SubIndex(Ref("b"), 2), "c") * Returns: (Ref("b"), SubField(SubIndex(EmptyExpression, 2), "c")) * b[2].c -> (b, EMPTY[2].c) - * @note This function only supports WRef, WSubField, and WSubIndex + * @note This function only supports [[firrtl.ir.RefLikeExpression RefLikeExpression]]s: [[firrtl.ir.Reference + * Reference]], [[firrtl.ir.SubField SubField]], [[firrtl.ir.SubIndex SubIndex]], and [[firrtl.ir.SubAccess + * SubAccess]] */ def splitRef(e: Expression): (WRef, Expression) = e match { - case e: WRef => (e, EmptyExpression) - case e: WSubIndex => + case e: Reference => (e, EmptyExpression) + case e: SubIndex => val (root, tail) = splitRef(e.expr) - (root, WSubIndex(tail, e.value, e.tpe, e.flow)) - case e: WSubField => + (root, SubIndex(tail, e.value, e.tpe, e.flow)) + case e: SubField => val (root, tail) = splitRef(e.expr) tail match { - case EmptyExpression => (root, WRef(e.name, e.tpe, root.kind, e.flow)) - case exp => (root, WSubField(tail, e.name, e.tpe, e.flow)) + case EmptyExpression => (root, Reference(e.name, e.tpe, root.kind, e.flow)) + case exp => (root, SubField(tail, e.name, e.tpe, e.flow)) } + case e: SubAccess => + val (root, tail) = splitRef(e.expr) + (root, SubAccess(tail, e.index, e.tpe, e.flow)) } /** Adds a root reference to some SubField/SubIndex chain */ |
