diff options
Diffstat (limited to 'src/main/scala/firrtl/transforms/OptimizationAnnotations.scala')
| -rw-r--r-- | src/main/scala/firrtl/transforms/OptimizationAnnotations.scala | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala b/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala index b0cf2f02..ff44afec 100644 --- a/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala +++ b/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala @@ -8,11 +8,33 @@ import firrtl.passes.PassException /** Indicate that DCE should not be run */ case object NoDCEAnnotation extends NoTargetAnnotation +/** Lets an annotation mark its ReferenceTarget members as DontTouch + * + * This permits a transform to run and remove its associated annotations, + * thus making their ReferenceTargets new candidates for optimization. This + * removes the need for the pass writer to reason about pre-existing + * DontTouchAnnotations that may touch the same node. + */ +trait HasDontTouches { self: Annotation => + def dontTouches: Iterable[ReferenceTarget] +} + +/** + * A globalized form of HasDontTouches which applies to all ReferenceTargets + * provided with the annotation + */ +trait DontTouchAllTargets extends HasDontTouches { self: Annotation => + def dontTouches: Iterable[ReferenceTarget] = getTargets.collect { + case rT: ReferenceTarget => rT + } +} + /** A component that should be preserved * * DCE treats the component as a top-level sink of the circuit */ -case class DontTouchAnnotation(target: ReferenceTarget) extends SingleTargetAnnotation[ReferenceTarget] { +case class DontTouchAnnotation(target: ReferenceTarget) + extends SingleTargetAnnotation[ReferenceTarget] with DontTouchAllTargets { def targets = Seq(target) def duplicate(n: ReferenceTarget) = this.copy(n) } |
