Skip to content

Conversation

jackkoenig
Copy link
Contributor

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 request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Feature (or new API)

Desired Merge Strategy

  • Squash

Release Notes

Annotations can now mixin OverrideSerializationClass to customize the "class" field in annotation serialization. This allows annotation classes to reside in a different package than firtool is expecting for the class field. Note that this breaks automatic deserialization which does not matter to firtool but would matter for annotations communicating information between Chisel generator invocations.

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.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) and clean up the commit message.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@jackkoenig jackkoenig added this to the 7.0 milestone Jun 13, 2025
@jackkoenig jackkoenig requested a review from seldridge June 13, 2025 19:35
@jackkoenig jackkoenig added the Feature New feature, will be included in release notes label Jun 13, 2025
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +180 to +187
val tags = mutable.ListBuffer.empty[Class[_]]
val seenTags = mutable.Set.empty[Class[_]]
def addTag(clazz: Class[_]): Unit = {
if (!seenTags(clazz)) {
tags += clazz
seenTags += clazz
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize that ListBuffer has constant time prepend and append. This looked like a performance issue, but it isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, and .toList is constant time (copy-on-write to original ListBuffer object). It's how Scala makes List relatively fast all things considered.

Comment on lines +121 to +123
res should include(""""class":"firrtl.annotations.UnserializeableAnnotation",""")
res should include(""""error":"Classes defined in method bodies are not supported.",""")
res should include(""""content":"MyAnno(3)"""")
Copy link
Member

Choose a reason for hiding this comment

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

FileCheck would be better. 😉 However, I don't think FileCheck is available in this compilation unit.

jackkoenig and others added 2 commits June 13, 2025 12:59
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@jackkoenig jackkoenig enabled auto-merge (squash) June 13, 2025 20:04
@jackkoenig jackkoenig merged commit 13728ec into main Jun 13, 2025
15 checks passed
@jackkoenig jackkoenig deleted the jackkoenig/annotation-custom-class-serialization branch June 13, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants