diff options
| author | Schuyler Eldridge | 2018-11-22 23:40:38 -0500 |
|---|---|---|
| committer | GitHub | 2018-11-22 23:40:38 -0500 |
| commit | 27afc3d8defd9e2a85d5e3d2f9d2b35310b9b775 (patch) | |
| tree | 8435ab570e88b60ca6af127e607794c64565bb9c /src/main/scala/firrtl/options/phases/AddDefaults.scala | |
| parent | 4a2211c1602b37a65b4e44c3b7ebe82e8bfeedc0 (diff) | |
| parent | 696bc256a90cc80bcb094aaeada8eea51a643ae0 (diff) | |
Merge pull request #945 from seldridge/add-phase
- Change firrtl.options API, add Phase
Diffstat (limited to 'src/main/scala/firrtl/options/phases/AddDefaults.scala')
| -rw-r--r-- | src/main/scala/firrtl/options/phases/AddDefaults.scala | 26 |
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 + } + +} |
