aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/transforms/OptimizationAnnotations.scala')
-rw-r--r--src/main/scala/firrtl/transforms/OptimizationAnnotations.scala33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala b/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala
index 2336710a..42b45813 100644
--- a/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala
+++ b/src/main/scala/firrtl/transforms/OptimizationAnnotations.scala
@@ -6,29 +6,17 @@ import firrtl.annotations._
import firrtl.passes.PassException
/** Indicate that DCE should not be run */
-object NoDCEAnnotation {
- val marker = "noDCE!"
- val transform = classOf[DeadCodeElimination]
- def apply(): Annotation = Annotation(CircuitTopName, transform, marker)
- def unapply(a: Annotation): Boolean = a match {
- case Annotation(_, targetXform, value) if targetXform == transform && value == marker => true
- case _ => false
- }
-}
+case object NoDCEAnnotation extends NoTargetAnnotation
/** A component that should be preserved
*
* DCE treats the component as a top-level sink of the circuit
*/
-object DontTouchAnnotation {
- private val marker = "DONTtouch!"
- def apply(target: ComponentName): Annotation = Annotation(target, classOf[Transform], marker)
-
- def unapply(a: Annotation): Option[ComponentName] = a match {
- case Annotation(component: ComponentName, _, value) if value == marker => Some(component)
- case _ => None
- }
+case class DontTouchAnnotation(target: ComponentName) extends SingleTargetAnnotation[ComponentName] {
+ def duplicate(n: ComponentName) = this.copy(n)
+}
+object DontTouchAnnotation {
class DontTouchNotFoundException(module: String, component: String) extends PassException(
s"Component marked DONT Touch ($module.$component) not found!\n" +
"Perhaps it is an aggregate type? Currently only leaf components are supported.\n" +
@@ -48,12 +36,7 @@ object DontTouchAnnotation {
*
* @note Unlike [[DontTouchAnnotation]], we don't care if the annotation is deleted
*/
-object OptimizableExtModuleAnnotation {
- private val marker = "optimizableExtModule!"
- def apply(target: ModuleName): Annotation = Annotation(target, classOf[Transform], marker)
-
- def unapply(a: Annotation): Option[ModuleName] = a match {
- case Annotation(component: ModuleName, _, value) if value == marker => Some(component)
- case _ => None
- }
+case class OptimizableExtModuleAnnotation(target: ModuleName) extends
+ SingleTargetAnnotation[ModuleName] {
+ def duplicate(n: ModuleName) = this.copy(n)
}