Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpaqueType support to Records #2662

Merged
merged 19 commits into from
Aug 13, 2022

Conversation

adkian-sifive
Copy link
Contributor

@adkian-sifive adkian-sifive commented Aug 5, 2022

OpaqueType allows simplifying Record references when the Record subtypes have single map elements

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • new feature/API

API Impact

New override for Records for single element types

Backend Code Generation Impact

If Record.opaqueType is overridden to true, the generated CHIRRTL will substitute name of the Record for that of the subfield, and substitute type of the subfield for type of the Record

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference.

Release Notes

Add new override in Record to support opaque types

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (Bug fix: 3.4.x, [small] API extension: 3.5.x, API modification or big change: 3.6.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good! Some suggested improvements.

core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
core/src/main/scala/chisel3/Aggregate.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/RecordSpec.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/RecordSpec.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/RecordSpec.scala Outdated Show resolved Hide resolved
@jackkoenig jackkoenig added this to the 3.5.x milestone Aug 12, 2022
Copy link
Contributor

@jackkoenig jackkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except one minor tweak

src/test/scala/chiselTests/RecordSpec.scala Outdated Show resolved Hide resolved
src/test/scala/chiselTests/RecordSpec.scala Show resolved Hide resolved
src/test/scala/chiselTests/RecordSpec.scala Show resolved Hide resolved
@jackkoenig jackkoenig enabled auto-merge (squash) August 13, 2022 16:55
@jackkoenig jackkoenig added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Aug 13, 2022
@jackkoenig jackkoenig merged commit df5afee into chipsalliance:master Aug 13, 2022
mergify bot pushed a commit that referenced this pull request Aug 13, 2022
OpaqueTypes are essentially type aliases that hide the underlying type.
They are implemented in Chisel as Records of a single, unnamed element
where the wrapping Record does not exist in the emitted FIRRTL.

Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit df5afee)
@mergify mergify bot added the Backported This PR has been backported label Aug 13, 2022
@jackkoenig
Copy link
Contributor

Github automerged this even though CI failed.... that's weird. I'll push a fix

mergify bot added a commit that referenced this pull request Aug 16, 2022
* Add OpaqueType support to Records (#2662)

OpaqueTypes are essentially type aliases that hide the underlying type.
They are implemented in Chisel as Records of a single, unnamed element
where the wrapping Record does not exist in the emitted FIRRTL.

Co-authored-by: Jack Koenig <koenig@sifive.com>
(cherry picked from commit df5afee)

* Fix test compilation

* Fix OpaqueType tests in RecordSpec

Need to implement cloneType correctly and to warn instead of error when
accessing .toTarget of non-hardware types because that is a warning (not
error) in 3.5.

* Waive MiMa false positives

Co-authored-by: Aditya Naik <91489422+adkian-sifive@users.noreply.github.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants