diff options
| author | Albert Magyar | 2019-12-18 16:21:06 -0500 |
|---|---|---|
| committer | Schuyler Eldridge | 2020-02-19 19:47:17 -0500 |
| commit | 68d9fc84ce510c4ff5eb1907419925d4ea548e04 (patch) | |
| tree | 1c0703f49f09200661820d13d981b34ce548b6aa /src/main/scala/firrtl/options/phases | |
| parent | 235ec6cbdce6866c8fcd49c0000a7abeeaa4ef80 (diff) | |
Support Singleton Dependencies (#1275)
This makes a change to the Dependency API that breaks chisel3. This
needs to [skip chisel tests], but is fixed with
https://github.com/freechipsproject/chisel3/pull/1270.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/main/scala/firrtl/options/phases')
6 files changed, 43 insertions, 12 deletions
diff --git a/src/main/scala/firrtl/options/phases/AddDefaults.scala b/src/main/scala/firrtl/options/phases/AddDefaults.scala index 8f7fe401..a327d930 100644 --- a/src/main/scala/firrtl/options/phases/AddDefaults.scala +++ b/src/main/scala/firrtl/options/phases/AddDefaults.scala @@ -3,14 +3,18 @@ package firrtl.options.phases import firrtl.AnnotationSeq -import firrtl.options.{Phase, TargetDirAnnotation} +import firrtl.options.{Dependency, Phase, PreservesAll, 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. */ -class AddDefaults extends Phase { +class AddDefaults extends Phase with PreservesAll[Phase] { + + override val prerequisites = Seq(Dependency[GetIncludes], Dependency[ConvertLegacyAnnotations]) + + override val dependents = Seq.empty def transform(annotations: AnnotationSeq): AnnotationSeq = { val td = annotations.collectFirst{ case a: TargetDirAnnotation => a}.isEmpty diff --git a/src/main/scala/firrtl/options/phases/Checks.scala b/src/main/scala/firrtl/options/phases/Checks.scala index 0691e9b0..659247c9 100644 --- a/src/main/scala/firrtl/options/phases/Checks.scala +++ b/src/main/scala/firrtl/options/phases/Checks.scala @@ -4,12 +4,17 @@ package firrtl.options.phases import firrtl.AnnotationSeq import firrtl.annotations.Annotation -import firrtl.options.{OptionsException, OutputAnnotationFileAnnotation, Phase, TargetDirAnnotation} +import firrtl.options.{OptionsException, OutputAnnotationFileAnnotation, Phase, PreservesAll, TargetDirAnnotation} +import firrtl.options.Dependency /** [[firrtl.options.Phase Phase]] that validates an [[AnnotationSeq]]. If successful, views of this [[AnnotationSeq]] * as [[StageOptions]] are guaranteed to succeed. */ -class Checks extends Phase { +class Checks extends Phase with PreservesAll[Phase] { + + override val prerequisites = Seq(Dependency[GetIncludes], Dependency[ConvertLegacyAnnotations], Dependency[AddDefaults]) + + override val dependents = Seq.empty /** Validate an [[AnnotationSeq]] for [[StageOptions]] * @throws OptionsException if annotations are invalid diff --git a/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala b/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala index 39f59572..a8e86a77 100644 --- a/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala +++ b/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala @@ -4,10 +4,14 @@ package firrtl.options.phases import firrtl.AnnotationSeq import firrtl.annotations.LegacyAnnotation -import firrtl.options.Phase +import firrtl.options.{Dependency, Phase, PreservesAll} /** Convert any [[firrtl.annotations.LegacyAnnotation LegacyAnnotation]]s to non-legacy variants */ -class ConvertLegacyAnnotations extends Phase { +class ConvertLegacyAnnotations extends Phase with PreservesAll[Phase] { + + override val prerequisites = Seq(Dependency[GetIncludes]) + + override val dependents = Seq.empty def transform(annotations: AnnotationSeq): AnnotationSeq = LegacyAnnotation.convertLegacyAnnos(annotations) diff --git a/src/main/scala/firrtl/options/phases/DeletedWrapper.scala b/src/main/scala/firrtl/options/phases/DeletedWrapper.scala index 0a959f32..5374aa66 100644 --- a/src/main/scala/firrtl/options/phases/DeletedWrapper.scala +++ b/src/main/scala/firrtl/options/phases/DeletedWrapper.scala @@ -4,7 +4,7 @@ package firrtl.options.phases import firrtl.AnnotationSeq import firrtl.annotations.DeletedAnnotation -import firrtl.options.{Phase, Translator} +import firrtl.options.{Phase, PreservesAll, Translator} import scala.collection.mutable @@ -12,7 +12,12 @@ import scala.collection.mutable * wrapped [[firrtl.options.Phase Phase]] will be added as [[firrtl.annotations.DeletedAnnotation DeletedAnnotation]]s. * @param p a [[firrtl.options.Phase Phase]] to wrap */ -class DeletedWrapper(p: Phase) extends Phase with Translator[AnnotationSeq, (AnnotationSeq, AnnotationSeq)] { +class DeletedWrapper(p: Phase) extends Phase with Translator[AnnotationSeq, (AnnotationSeq, AnnotationSeq)] + with PreservesAll[Phase] { + + override val prerequisites = Seq.empty + + override val dependents = Seq.empty override lazy val name: String = p.name diff --git a/src/main/scala/firrtl/options/phases/GetIncludes.scala b/src/main/scala/firrtl/options/phases/GetIncludes.scala index cb9bb840..f6c02543 100644 --- a/src/main/scala/firrtl/options/phases/GetIncludes.scala +++ b/src/main/scala/firrtl/options/phases/GetIncludes.scala @@ -7,7 +7,7 @@ import net.jcazevedo.moultingyaml._ import firrtl.AnnotationSeq import firrtl.annotations.{AnnotationFileNotFoundException, JsonProtocol, LegacyAnnotation} import firrtl.annotations.AnnotationYamlProtocol._ -import firrtl.options.{InputAnnotationFileAnnotation, Phase, StageUtils} +import firrtl.options.{InputAnnotationFileAnnotation, Phase, PreservesAll, StageUtils} import firrtl.FileUtils import java.io.File @@ -16,7 +16,11 @@ import scala.collection.mutable import scala.util.{Try, Failure} /** Recursively expand all [[InputAnnotationFileAnnotation]]s in an [[AnnotationSeq]] */ -class GetIncludes extends Phase { +class GetIncludes extends Phase with PreservesAll[Phase] { + + override val prerequisites = Seq.empty + + override val dependents = Seq.empty /** Read all [[annotations.Annotation]] from a file in JSON or YAML format * @param filename a JSON or YAML file of [[annotations.Annotation]] diff --git a/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala b/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala index bb2a8cd6..4a638393 100644 --- a/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala +++ b/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala @@ -4,14 +4,23 @@ package firrtl.options.phases import firrtl.AnnotationSeq import firrtl.annotations.{DeletedAnnotation, JsonProtocol} -import firrtl.options.{Phase, StageOptions, Unserializable, Viewer} +import firrtl.options.{Phase, PreservesAll, StageOptions, Unserializable, Viewer} +import firrtl.options.Dependency import java.io.PrintWriter /** [[firrtl.options.Phase Phase]] that writes an [[AnnotationSeq]] to a file. A file is written if and only if a * [[StageOptions]] view has a non-empty [[StageOptions.annotationFileOut annotationFileOut]]. */ -class WriteOutputAnnotations extends Phase { +class WriteOutputAnnotations extends Phase with PreservesAll[Phase] { + + override val prerequisites = + Seq( Dependency[GetIncludes], + Dependency[ConvertLegacyAnnotations], + Dependency[AddDefaults], + Dependency[Checks] ) + + override val dependents = Seq.empty /** Write the input [[AnnotationSeq]] to a fie. */ def transform(annotations: AnnotationSeq): AnnotationSeq = { |
