aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/options/phases/AddDefaults.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/options/phases/AddDefaults.scala')
-rw-r--r--src/main/scala/firrtl/options/phases/AddDefaults.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/options/phases/AddDefaults.scala b/src/main/scala/firrtl/options/phases/AddDefaults.scala
new file mode 100644
index 00000000..f0749b22
--- /dev/null
+++ b/src/main/scala/firrtl/options/phases/AddDefaults.scala
@@ -0,0 +1,26 @@
+// See LICENSE for license details.
+
+package firrtl.options.phases
+
+import firrtl.AnnotationSeq
+import firrtl.options.{Phase, StageOption, TargetDirAnnotation}
+
+/** Add default annotations for a [[Stage]]
+ *
+ * This currently only adds a [[TargetDirAnnotation]]. This isn't necessary for a [[StageOptionsView]], but downstream
+ * tools may expect a [[TargetDirAnnotation]] to exist.
+ */
+object AddDefaults extends Phase {
+
+ def transform(annotations: AnnotationSeq): AnnotationSeq = {
+ var td = true
+ annotations.collect { case a: StageOption => a }.map {
+ case _: TargetDirAnnotation => td = false
+ case _ =>
+ }
+
+ (if (td) Seq(TargetDirAnnotation()) else Seq()) ++
+ annotations
+ }
+
+}