aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2020-08-12 21:17:14 -0700
committerGitHub2020-08-13 04:17:14 +0000
commit39f510a9081d09d94d56eb89ceb97a678993fda1 (patch)
tree02dcadb37c768d5763f6eae87b84b5aeeead6df1 /src
parente1d3a0c64a48b4c9999ad59f15922db7c155c361 (diff)
Remove LegacyAnnotation and [most] MoultingYaml (#1833)
* Remove LegacyAnnotation and MoultingYaml It has been deprecated since 1.1 * Remove all uses of ConvertLegacyAnnotations Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/Compiler.scala12
-rw-r--r--src/main/scala/firrtl/Driver.scala29
-rw-r--r--src/main/scala/firrtl/annotations/Annotation.scala125
-rw-r--r--src/main/scala/firrtl/annotations/AnnotationUtils.scala6
-rw-r--r--src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala45
-rw-r--r--src/main/scala/firrtl/options/Stage.scala3
-rw-r--r--src/main/scala/firrtl/options/phases/AddDefaults.scala2
-rw-r--r--src/main/scala/firrtl/options/phases/Checks.scala2
-rw-r--r--src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala6
-rw-r--r--src/main/scala/firrtl/options/phases/GetIncludes.scala18
-rw-r--r--src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala1
-rw-r--r--src/main/scala/firrtl/passes/memlib/ReplaceMemMacros.scala2
-rw-r--r--src/test/resources/annotations/InvalidLegacyAnnotations.anno26
-rw-r--r--src/test/resources/annotations/LegacyAnnotations.anno50
-rw-r--r--src/test/resources/annotations/SampleAnnotations.anno30
-rw-r--r--src/test/scala/firrtlTests/AnnotationTests.scala46
-rw-r--r--src/test/scala/firrtlTests/DriverSpec.scala125
-rw-r--r--src/test/scala/firrtlTests/FileUtilsSpec.scala2
-rw-r--r--src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala63
19 files changed, 16 insertions, 577 deletions
diff --git a/src/main/scala/firrtl/Compiler.scala b/src/main/scala/firrtl/Compiler.scala
index 359e83bc..db4853a2 100644
--- a/src/main/scala/firrtl/Compiler.scala
+++ b/src/main/scala/firrtl/Compiler.scala
@@ -356,18 +356,6 @@ trait Transform extends TransformLike[CircuitState] with DependencyAPI[Transform
}
}
- /** Convenience method to get annotations relevant to this Transform
- *
- * @param state The [[CircuitState]] form which to extract annotations
- * @return A collection of annotations
- */
- @deprecated("Just collect the actual Annotation types the transform wants", "1.1")
- final def getMyAnnotations(state: CircuitState): Seq[Annotation] = {
- val msg = "getMyAnnotations is deprecated, use collect and match on concrete types"
- StageUtils.dramaticWarning(msg)
- state.annotations.collect { case a: LegacyAnnotation if a.transform == this.getClass => a }
- }
-
/** Executes before any transform's execute method
* @param state
* @return
diff --git a/src/main/scala/firrtl/Driver.scala b/src/main/scala/firrtl/Driver.scala
index c6842f52..2050b235 100644
--- a/src/main/scala/firrtl/Driver.scala
+++ b/src/main/scala/firrtl/Driver.scala
@@ -5,9 +5,7 @@ package firrtl
import scala.collection._
import scala.util.{Failure, Try}
import java.io.{File, FileNotFoundException}
-import net.jcazevedo.moultingyaml._
import annotations._
-import firrtl.annotations.AnnotationYamlProtocol._
import firrtl.transforms._
import firrtl.Utils.throwInternalError
import firrtl.stage.{FirrtlExecutionResultView, FirrtlStage}
@@ -93,33 +91,20 @@ object Driver {
// Warnings to get people to change to drop old API
if (firrtlConfig.annotationFileNameOverride.nonEmpty) {
- val msg = "annotationFileNameOverride is deprecated! " +
+ val msg = "annotationFileNameOverride has been removed, file will be ignored! " +
"Use annotationFileNames"
- dramaticWarning(msg)
+ dramaticError(msg)
} else if (usingImplicitAnnoFile) {
- val msg = "Implicit .anno file from top-name is deprecated!\n" +
+ val msg = "Implicit .anno file from top-name has been removed, file will be ignored!\n" +
(" "*9) + "Use explicit -faf option or annotationFileNames"
- Driver.dramaticWarning(msg)
+ dramaticError(msg)
}
val loadedAnnos = annoFiles.flatMap { file =>
if (!file.exists) {
throw new AnnotationFileNotFoundException(file)
}
- // Try new protocol first
- JsonProtocol.deserializeTry(file).recoverWith { case jsonException =>
- // Try old protocol if new one fails
- Try {
- val yaml = FileUtils.getText(file).parseYaml
- val result = yaml.convertTo[List[LegacyAnnotation]]
- val msg = s"$file is a YAML file!\n" +
- (" "*9) + "YAML Annotation files are deprecated! Use JSON"
- Driver.dramaticWarning(msg)
- result
- }.orElse { // Propagate original JsonProtocol exception if YAML also fails
- Failure(jsonException)
- }
- }.get
+ JsonProtocol.deserialize(file)
}
val targetDirAnno = List(BlackBoxTargetDirAnno(optionsManager.targetDirName))
@@ -131,9 +116,7 @@ object Driver {
(if (firrtlConfig.dontCheckCombLoops) Seq(DontCheckCombLoopsAnnotation) else Seq()) ++
(if (firrtlConfig.noDCE) Seq(NoDCEAnnotation) else Seq())
- val annos = targetDirAnno ++ outputAnnos ++ globalAnnos ++
- firrtlConfig.annotations ++ loadedAnnos
- LegacyAnnotation.convertLegacyAnnos(annos)
+ targetDirAnno ++ outputAnnos ++ globalAnnos ++ firrtlConfig.annotations ++ loadedAnnos
}
private sealed trait FileExtension
diff --git a/src/main/scala/firrtl/annotations/Annotation.scala b/src/main/scala/firrtl/annotations/Annotation.scala
index 3e58a0d7..a382f685 100644
--- a/src/main/scala/firrtl/annotations/Annotation.scala
+++ b/src/main/scala/firrtl/annotations/Annotation.scala
@@ -127,130 +127,7 @@ trait MultiTargetAnnotation extends Annotation {
def flat(): AnnotationSeq = crossJoin(targets).map(r => duplicate(r.map(Seq(_))))
}
-@deprecated("Just extend NoTargetAnnotation", "1.1")
-trait SingleStringAnnotation extends NoTargetAnnotation {
- def value: String
-}
-
-object Annotation {
- @deprecated("This returns a LegacyAnnotation, use an explicit Annotation type", "1.1")
- def apply(target: Named, transform: Class[_ <: Transform], value: String): LegacyAnnotation =
- new LegacyAnnotation(target, transform, value)
- @deprecated("This uses LegacyAnnotation, use an explicit Annotation type", "1.1")
- def unapply(a: LegacyAnnotation): Option[(Named, Class[_ <: Transform], String)] =
- Some((a.target, a.transform, a.value))
-}
-
-// Constructor is private so that we can still construct these internally without deprecation
-// warnings
-final case class LegacyAnnotation private[firrtl] (
- target: Named,
- transform: Class[_ <: Transform],
- value: String) extends SingleTargetAnnotation[Named] {
- val targetString: String = target.serialize
- val transformClass: String = transform.getName
-
- def targets(named: Named): Boolean = named == target
- def targets(transform: Class[_ <: Transform]): Boolean = transform == this.transform
-
- /**
- * This serialize is basically a pretty printer, actual serialization is handled by
- * AnnotationYamlProtocol
- * @return a nicer string than the raw case class default
- */
- override def serialize: String = {
- s"Annotation(${target.serialize},${transform.getCanonicalName},$value)"
- }
-
- def update(tos: Seq[Named]): Seq[Annotation] = {
- check(target, tos, this)
- propagate(target, tos, duplicate)
- }
- def propagate(from: Named, tos: Seq[Named], dup: Named=>Annotation): Seq[Annotation] = tos.map(dup(_))
- def check(from: Named, tos: Seq[Named], which: Annotation): Unit = {}
- def duplicate(n: Named): LegacyAnnotation = new LegacyAnnotation(n, transform, value)
-}
-
-// Private so that LegacyAnnotation can only be constructed via deprecated Annotation.apply
-private[firrtl] object LegacyAnnotation {
- // ***** Everything below here is to help people migrate off of old annotations *****
- def errorIllegalAnno(name: String): Annotation =
- throw new Exception(s"Old-style annotations that look like $name are no longer supported")
-
- private val OldDeletedRegex = """(?s)DELETED by ([^\n]*)\n(.*)""".r
- private val PinsRegex = "pins:(.*)".r
- private val SourceRegex = "source (.+)".r
- private val SinkRegex = "sink (.+)".r
-
- import firrtl.transforms._
- import firrtl.passes._
- import firrtl.passes.memlib._
- import firrtl.passes.wiring._
- import firrtl.passes.clocklist._
-
- // Attempt to convert common Annotations and error on the rest of old-style build-in annotations
- def convertLegacyAnno(anno: LegacyAnnotation): Annotation = anno match {
- // All old-style Emitter annotations are illegal
- case LegacyAnnotation(_,_,"emitCircuit") => errorIllegalAnno("EmitCircuitAnnotation")
- case LegacyAnnotation(_,_,"emitAllModules") => errorIllegalAnno("EmitAllModulesAnnotation")
- case LegacyAnnotation(_,_,value) if value.startsWith("emittedFirrtlCircuit") =>
- errorIllegalAnno("EmittedFirrtlCircuitAnnotation")
- case LegacyAnnotation(_,_,value) if value.startsWith("emittedFirrtlModule") =>
- errorIllegalAnno("EmittedFirrtlModuleAnnotation")
- case LegacyAnnotation(_,_,value) if value.startsWith("emittedVerilogCircuit") =>
- errorIllegalAnno("EmittedVerilogCircuitAnnotation")
- case LegacyAnnotation(_,_,value) if value.startsWith("emittedVerilogModule") =>
- errorIllegalAnno("EmittedVerilogModuleAnnotation")
- // People shouldn't be trying to pass deleted annotations to Firrtl
- case LegacyAnnotation(_,_,OldDeletedRegex(_,_)) => errorIllegalAnno("DeletedAnnotation")
- // Some annotations we'll try to support
- case LegacyAnnotation(named, t, _) if t == classOf[InlineInstances] => InlineAnnotation(named)
- case LegacyAnnotation(n: ModuleName, t, outputConfig) if t == classOf[ClockListTransform] =>
- ClockListAnnotation(n, outputConfig)
- case LegacyAnnotation(CircuitName(_), transform, "") if transform == classOf[InferReadWrite] =>
- InferReadWriteAnnotation
- case LegacyAnnotation(_,_,PinsRegex(pins)) => PinAnnotation(pins.split(" "))
- case LegacyAnnotation(_, t, value) if t == classOf[ReplSeqMem] =>
- val args = value.split(" ")
- require(args.size == 2, "Something went wrong, stop using legacy ReplSeqMemAnnotation")
- ReplSeqMemAnnotation(args(0), args(1))
- case LegacyAnnotation(c: ComponentName, transform, "nodedupmem!")
- if transform == classOf[ResolveMemoryReference] => NoDedupMemAnnotation(c)
- case LegacyAnnotation(m: ModuleName, transform, "nodedup!")
- if transform == classOf[DedupModules] => NoDedupAnnotation(m)
- case LegacyAnnotation(c: ComponentName, _, SourceRegex(pin)) => SourceAnnotation(c, pin)
- case LegacyAnnotation(n, _, SinkRegex(pin)) => SinkAnnotation(n, pin)
- case LegacyAnnotation(m: ModuleName, t, text) if t == classOf[BlackBoxSourceHelper] =>
- val nArgs = 3
- text.split("\n", nArgs).toList match {
- case "resource" :: id :: _ => BlackBoxResourceAnno(m, id)
- case "inline" :: name :: text :: _ => BlackBoxInlineAnno(m, name, text)
- case "targetDir" :: targetDir :: _ => BlackBoxTargetDirAnno(targetDir)
- case _ => errorIllegalAnno("BlackBoxSourceAnnotation")
- }
- case LegacyAnnotation(_, transform, "noDCE!") if transform == classOf[DeadCodeElimination] =>
- NoDCEAnnotation
- case LegacyAnnotation(c: ComponentName, _, "DONTtouch!") => DontTouchAnnotation(c.toTarget)
- case LegacyAnnotation(c: ModuleName, _, "optimizableExtModule!") =>
- OptimizableExtModuleAnnotation(c)
- case other => other
- }
- def convertLegacyAnnos(annos: AnnotationSeq): AnnotationSeq = {
- var warned: Boolean = false
- annos.map {
- case legacy: LegacyAnnotation =>
- val annox = convertLegacyAnno(legacy)
- if (!warned && (annox ne legacy)) {
- val msg = s"A LegacyAnnotation was automatically converted.\n" + (" "*9) +
- "This functionality will soon be removed. Please migrate to new annotations."
- StageUtils.dramaticWarning(msg)
- warned = true
- }
- annox
- case other => other
- }
- }
-}
+object Annotation
case class DeletedAnnotation(xFormName: String, anno: Annotation) extends NoTargetAnnotation {
override def serialize: String = s"""DELETED by $xFormName\n${anno.serialize}"""
diff --git a/src/main/scala/firrtl/annotations/AnnotationUtils.scala b/src/main/scala/firrtl/annotations/AnnotationUtils.scala
index 52b18400..58cc0097 100644
--- a/src/main/scala/firrtl/annotations/AnnotationUtils.scala
+++ b/src/main/scala/firrtl/annotations/AnnotationUtils.scala
@@ -5,10 +5,6 @@ package annotations
import java.io.File
-
-import net.jcazevedo.moultingyaml._
-import firrtl.annotations.AnnotationYamlProtocol._
-
import firrtl.ir._
case class InvalidAnnotationFileException(file: File, cause: FirrtlUserException = null)
@@ -22,8 +18,6 @@ case class AnnotationClassNotFoundException(className: String) extends FirrtlUse
)
object AnnotationUtils {
- def toYaml(a: LegacyAnnotation): String = a.toYaml.prettyPrint
- def fromYaml(s: String): LegacyAnnotation = s.parseYaml.convertTo[LegacyAnnotation]
/** Returns true if a valid Module name */
val SerializedModuleName = """([a-zA-Z_][a-zA-Z_0-9~!@#$%^*\-+=?/]*)""".r
diff --git a/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala b/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala
deleted file mode 100644
index 4bb643b3..00000000
--- a/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-// See LICENSE for license details.
-
-package firrtl
-package annotations
-
-import net.jcazevedo.moultingyaml._
-
-object AnnotationYamlProtocol extends DefaultYamlProtocol {
- // bottom depends on top
- implicit object AnnotationYamlFormat extends YamlFormat[LegacyAnnotation] {
- def write(a: LegacyAnnotation) = YamlObject(
- YamlString("targetString") -> YamlString(a.targetString),
- YamlString("transformClass") -> YamlString(a.transformClass),
- YamlString("value") -> YamlString(a.value)
- )
-
- def read(yamlValue: YamlValue): LegacyAnnotation = {
- try {
- yamlValue.asYamlObject.getFields(
- YamlString("targetString"),
- YamlString("transformClass"),
- YamlString("value")) match {
- case Seq(YamlString(targetString), YamlString(transformClass), YamlString(value)) =>
- LegacyAnnotation(toTarget(targetString),
- Class.forName(transformClass).asInstanceOf[Class[_ <: Transform]],
- value)
- case _ => deserializationError("LegacyAnnotation expected")
- }
- }
- catch {
- case annotationException: AnnotationException =>
- Utils.error(
- s"Error: ${annotationException.getMessage} while parsing annotation from yaml\n${yamlValue.prettyPrint}")
- }
- }
- def toTarget(string: String): Named = string.split("""\.""", -1).toSeq match {
- case Seq(c) => CircuitName(c)
- case Seq(c, m) => ModuleName(m, CircuitName(c))
- case Nil => Utils.error("BAD")
- case s =>
- val componentString = s.drop(2).mkString(".")
- ComponentName(componentString, ModuleName(s.tail.head, CircuitName(s.head)))
- }
- }
-}
diff --git a/src/main/scala/firrtl/options/Stage.scala b/src/main/scala/firrtl/options/Stage.scala
index 2b7bb9d6..aa4809dd 100644
--- a/src/main/scala/firrtl/options/Stage.scala
+++ b/src/main/scala/firrtl/options/Stage.scala
@@ -32,8 +32,7 @@ abstract class Stage extends Phase {
*/
final def transform(annotations: AnnotationSeq): AnnotationSeq = {
val annotationsx =
- Seq( new phases.GetIncludes,
- new phases.ConvertLegacyAnnotations )
+ Seq(new phases.GetIncludes)
.map(phases.DeletedWrapper(_))
.foldLeft(annotations)((a, p) => p.transform(a))
diff --git a/src/main/scala/firrtl/options/phases/AddDefaults.scala b/src/main/scala/firrtl/options/phases/AddDefaults.scala
index 9777aff0..ab342b1e 100644
--- a/src/main/scala/firrtl/options/phases/AddDefaults.scala
+++ b/src/main/scala/firrtl/options/phases/AddDefaults.scala
@@ -12,7 +12,7 @@ import firrtl.options.{Dependency, Phase, TargetDirAnnotation}
*/
class AddDefaults extends Phase {
- override def prerequisites = Seq(Dependency[GetIncludes], Dependency[ConvertLegacyAnnotations])
+ override def prerequisites = Seq(Dependency[GetIncludes])
override def optionalPrerequisiteOf = Seq.empty
diff --git a/src/main/scala/firrtl/options/phases/Checks.scala b/src/main/scala/firrtl/options/phases/Checks.scala
index 7dce7bbe..9e671aa5 100644
--- a/src/main/scala/firrtl/options/phases/Checks.scala
+++ b/src/main/scala/firrtl/options/phases/Checks.scala
@@ -12,7 +12,7 @@ import firrtl.options.Dependency
*/
class Checks extends Phase {
- override def prerequisites = Seq(Dependency[GetIncludes], Dependency[ConvertLegacyAnnotations], Dependency[AddDefaults])
+ override def prerequisites = Seq(Dependency[GetIncludes], Dependency[AddDefaults])
override def optionalPrerequisiteOf = Seq.empty
diff --git a/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala b/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala
index 559b5d28..d75acbb2 100644
--- a/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala
+++ b/src/main/scala/firrtl/options/phases/ConvertLegacyAnnotations.scala
@@ -3,10 +3,9 @@
package firrtl.options.phases
import firrtl.AnnotationSeq
-import firrtl.annotations.LegacyAnnotation
import firrtl.options.{Dependency, Phase}
-/** Convert any [[firrtl.annotations.LegacyAnnotation LegacyAnnotation]]s to non-legacy variants */
+@deprecated("LegacyAnnotation has been removed, this is a no-op", "FIRRTL 1.4")
class ConvertLegacyAnnotations extends Phase {
override def prerequisites = Seq(Dependency[GetIncludes])
@@ -15,6 +14,5 @@ class ConvertLegacyAnnotations extends Phase {
override def invalidates(a: Phase) = false
- def transform(annotations: AnnotationSeq): AnnotationSeq = LegacyAnnotation.convertLegacyAnnos(annotations)
-
+ def transform(annotations: AnnotationSeq): AnnotationSeq = annotations
}
diff --git a/src/main/scala/firrtl/options/phases/GetIncludes.scala b/src/main/scala/firrtl/options/phases/GetIncludes.scala
index a0b15173..b9320585 100644
--- a/src/main/scala/firrtl/options/phases/GetIncludes.scala
+++ b/src/main/scala/firrtl/options/phases/GetIncludes.scala
@@ -2,11 +2,8 @@
package firrtl.options.phases
-import net.jcazevedo.moultingyaml._
-
import firrtl.AnnotationSeq
-import firrtl.annotations.{AnnotationFileNotFoundException, JsonProtocol, LegacyAnnotation}
-import firrtl.annotations.AnnotationYamlProtocol._
+import firrtl.annotations.{AnnotationFileNotFoundException, JsonProtocol}
import firrtl.options.{InputAnnotationFileAnnotation, Phase, StageUtils}
import firrtl.FileUtils
@@ -31,18 +28,7 @@ class GetIncludes extends Phase {
private def readAnnotationsFromFile(filename: String): AnnotationSeq = {
val file = new File(filename).getCanonicalFile
if (!file.exists) { throw new AnnotationFileNotFoundException(file) }
- JsonProtocol.deserializeTry(file).recoverWith { case jsonException =>
- // Try old protocol if new one fails
- Try {
- val yaml = FileUtils.getText(file).parseYaml
- val result = yaml.convertTo[List[LegacyAnnotation]]
- val msg = s"$file is a YAML file!\n" + (" "*9) + "YAML Annotation files are deprecated! Use JSON"
- StageUtils.dramaticWarning(msg)
- result
- }.orElse { // Propagate original JsonProtocol exception if YAML also fails
- Failure(jsonException)
- }
- }.get
+ JsonProtocol.deserialize(file)
}
/** Recursively read all [[Annotation]]s from any [[InputAnnotationFileAnnotation]]s while making sure that each file is
diff --git a/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala b/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala
index ccd08fa4..7ee385b1 100644
--- a/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala
+++ b/src/main/scala/firrtl/options/phases/WriteOutputAnnotations.scala
@@ -17,7 +17,6 @@ class WriteOutputAnnotations extends Phase {
override def prerequisites =
Seq( Dependency[GetIncludes],
- Dependency[ConvertLegacyAnnotations],
Dependency[AddDefaults],
Dependency[Checks] )
diff --git a/src/main/scala/firrtl/passes/memlib/ReplaceMemMacros.scala b/src/main/scala/firrtl/passes/memlib/ReplaceMemMacros.scala
index d432a360..bfbc163a 100644
--- a/src/main/scala/firrtl/passes/memlib/ReplaceMemMacros.scala
+++ b/src/main/scala/firrtl/passes/memlib/ReplaceMemMacros.scala
@@ -260,7 +260,7 @@ class ReplaceMemMacros(writer: ConfWriter) extends Transform with DependencyAPIM
val pins = pannos match {
case Seq() => Nil
case Seq(PinAnnotation(pins)) => pins
- case _ => throwInternalError(s"execute: getMyAnnotations - ${getMyAnnotations(state)}")
+ case _ => throwInternalError("Something went wrong")
}
val annos = pins.foldLeft(Seq[Annotation]()) { (seq, pin) =>
seq ++ memMods.collect {
diff --git a/src/test/resources/annotations/InvalidLegacyAnnotations.anno b/src/test/resources/annotations/InvalidLegacyAnnotations.anno
deleted file mode 100644
index 75bb3b96..00000000
--- a/src/test/resources/annotations/InvalidLegacyAnnotations.anno
+++ /dev/null
@@ -1,26 +0,0 @@
-- targetString: CircuitTop
- transformClass: firrtl.VerilogEmitter
- value: emitCircuit
-- targetString: CircuitTop
- transformClass: firrtl.VerilogEmitter
- value: emitAllModules
-- targetString: CircuitTop
- transformClass: firrtl.Transform
- value: emittedFirrtlCircuit:0
-- targetString: CircuitTop
- transformClass: firrtl.Transform
- value: emittedVerilogCircuit:0
-- targetString: CircuitTop
- transformClass: firrtl.Transform
- value: emittedFirrtlModule:0
-- targetString: CircuitTop
- transformClass: firrtl.Transform
- value: emittedVerilogModule:0
-- targetString: foo
- transformClass: firrtl.Transform
- value: |
- DELETED by DeadCodeElimination
- targetString: foo
- transformClass: firrtl.passes.InlineInstances
- value: ''
-
diff --git a/src/test/resources/annotations/LegacyAnnotations.anno b/src/test/resources/annotations/LegacyAnnotations.anno
deleted file mode 100644
index 395fa56d..00000000
--- a/src/test/resources/annotations/LegacyAnnotations.anno
+++ /dev/null
@@ -1,50 +0,0 @@
-- targetString: foo
- transformClass: firrtl.passes.InlineInstances
- value: ''
-- targetString: foo.bar
- transformClass: firrtl.passes.clocklist.ClockListTransform
- value: output
-- targetString: foo
- transformClass: firrtl.passes.memlib.InferReadWrite
- value: ''
-- targetString: foo
- transformClass: firrtl.passes.memlib.ReplSeqMem
- value: input output
-- targetString: foo.bar.x
- transformClass: firrtl.passes.memlib.ResolveMemoryReference
- value: nodedupmem!
-- targetString: foo.bar
- transformClass: firrtl.transforms.DedupModules
- value: nodedup!
-- targetString: foo.bar.x
- transformClass: firrtl.passes.wiring.WiringTransform
- value: source pin
-- targetString: foo.bar.x
- transformClass: firrtl.passes.wiring.WiringTransform
- value: sink pin
-- targetString: foo.bar
- transformClass: firrtl.transforms.BlackBoxSourceHelper
- value: |-
- resource
- resource
-- targetString: foo.bar
- transformClass: firrtl.transforms.BlackBoxSourceHelper
- value: |-
- inline
- name
- text
-- targetString: foo.bar
- transformClass: firrtl.transforms.BlackBoxSourceHelper
- value: |-
- targetDir
- targetdir
-- targetString: CircuitTop
- transformClass: firrtl.transforms.DeadCodeElimination
- value: noDCE!
-- targetString: foo.bar.x
- transformClass: firrtl.Transform
- value: DONTtouch!
-- targetString: foo.bar
- transformClass: firrtl.Transform
- value: optimizableExtModule!
-
diff --git a/src/test/resources/annotations/SampleAnnotations.anno b/src/test/resources/annotations/SampleAnnotations.anno
deleted file mode 100644
index 8fa9f44f..00000000
--- a/src/test/resources/annotations/SampleAnnotations.anno
+++ /dev/null
@@ -1,30 +0,0 @@
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModC
- value: ModC.this params 16 32
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModC.io.out
- value: ModuleC(16,32) width < 32
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModA
- value: ModA.this
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModA.io.out
- value: inside ModA.io.out params 64,64
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModC_1
- value: ModC.this params 42 77
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModC_1.io.out
- value: ModuleC(42,77) width < 77
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModB.io.out
- value: inside ModB.io.out params 32,48
-- transformClass: firrtl.passes.InlineInstances
- targetString: TopOfDiamond
- value: |-
- TopOfDiamond
- With
- Some new lines
-- transformClass: firrtl.passes.InlineInstances
- targetString: ModB.io.in
- value: TopOfDiamond.moduleB.io.in
diff --git a/src/test/scala/firrtlTests/AnnotationTests.scala b/src/test/scala/firrtlTests/AnnotationTests.scala
index 2b347034..03131165 100644
--- a/src/test/scala/firrtlTests/AnnotationTests.scala
+++ b/src/test/scala/firrtlTests/AnnotationTests.scala
@@ -4,7 +4,6 @@ package firrtlTests
import java.io.{File, FileWriter}
-import firrtl.annotations.AnnotationYamlProtocol._
import firrtl.annotations._
import firrtl._
import firrtl.FileUtils
@@ -13,7 +12,6 @@ import firrtl.passes.InlineAnnotation
import firrtl.passes.memlib.PinAnnotation
import firrtl.util.BackendCompilationUtilities
import firrtl.testutils._
-import net.jcazevedo.moultingyaml._
import org.scalatest.matchers.should.Matchers
/**
@@ -472,50 +470,6 @@ abstract class AnnotationTests extends AnnotationSpec with Matchers {
}
}
-class LegacyAnnotationTests extends AnnotationTests {
- def anno(s: String, value: String ="this is a value", mod: String = "Top"): Annotation =
- Annotation(ComponentName(s, ModuleName(mod, CircuitName("Top"))), classOf[Transform], value)
- def manno(mod: String): Annotation =
- Annotation(ModuleName(mod, CircuitName("Top")), classOf[Transform], "some value")
-
- "LegacyAnnotations" should "be readable from file" in {
- val annotationsYaml = FileUtils.getTextResource("/annotations/SampleAnnotations.anno").parseYaml
- val annotationArray = annotationsYaml.convertTo[Array[LegacyAnnotation]]
- annotationArray.length should be (9)
- annotationArray(0).targetString should be ("ModC")
- annotationArray(7).transformClass should be ("firrtl.passes.InlineInstances")
- val expectedValue = "TopOfDiamond\nWith\nSome new lines"
- annotationArray(7).value should be (expectedValue)
- }
-
- "Badly formatted LegacyAnnotation serializations" should "return reasonable error messages" in {
- var badYaml =
- """
- |- transformClass: firrtl.passes.InlineInstances
- | targetString: circuit.module..
- | value: ModC.this params 16 32
- """.stripMargin.parseYaml
-
- var thrown = intercept[Exception] {
- badYaml.convertTo[Array[LegacyAnnotation]]
- }
- thrown.getMessage should include ("Illegal component name")
-
- badYaml =
- """
- |- transformClass: firrtl.passes.InlineInstances
- | targetString: .circuit.module.component
- | value: ModC.this params 16 32
- """.stripMargin.parseYaml
-
- thrown = intercept[Exception] {
- badYaml.convertTo[Array[LegacyAnnotation]]
- }
- thrown.getMessage should include ("Illegal circuit name")
- }
-
-}
-
class JsonAnnotationTests extends AnnotationTests with BackendCompilationUtilities {
// Helper annotations
case class SimpleAnno(target: ComponentName, value: String) extends
diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala
index 92381e8c..400bf314 100644
--- a/src/test/scala/firrtlTests/DriverSpec.scala
+++ b/src/test/scala/firrtlTests/DriverSpec.scala
@@ -209,131 +209,6 @@ class DriverSpec extends AnyFreeSpec with Matchers with BackendCompilationUtilit
}
}
- // Deprecated
- "Annotations can be read implicitly from the name of the circuit" - {
- val input = """|circuit foo :
- | module foo :
- | input x : UInt<8>
- | output y : UInt<8>
- | y <= x""".stripMargin
- val top = "foo"
- val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
- commonOptions = commonOptions.copy(topName = top)
- firrtlOptions = firrtlOptions.copy(firrtlSource = Some(input))
- }
- val annoFile = new File(optionsManager.commonOptions.targetDirName, top + ".anno")
- val vFile = new File(optionsManager.commonOptions.targetDirName, top + ".v")
- "Using Driver.getAnnotations" in {
- copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile)
- optionsManager.firrtlOptions.annotations.length should be(0)
- val annos = Driver.getAnnotations(optionsManager)
- annos.length should be(12) // 9 from circuit plus 3 general purpose
- annos.count(_.isInstanceOf[InlineAnnotation]) should be(9)
- annoFile.delete()
- vFile.delete()
- }
- "Using Driver.execute" in {
- copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile)
- Driver.execute(optionsManager) match {
- case r: FirrtlExecutionSuccess =>
- val annos = r.circuitState.annotations
- annos.count(_.isInstanceOf[InlineAnnotation]) should be(9)
- }
- annoFile.delete()
- vFile.delete()
- }
- }
-
- // Deprecated
- "Annotations can be read using annotationFileNameOverride" in {
- val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
- commonOptions = commonOptions.copy(topName = "a.fir")
- firrtlOptions = firrtlOptions.copy(
- annotationFileNameOverride = "SampleAnnotations"
- )
- }
- val annotationsTestFile = new File(optionsManager.commonOptions.targetDirName, optionsManager.firrtlOptions.annotationFileNameOverride + ".anno")
- copyResourceToFile("/annotations/SampleAnnotations.anno", annotationsTestFile)
- optionsManager.firrtlOptions.annotations.length should be(0)
- val annos = Driver.getAnnotations(optionsManager)
- annos.length should be(12) // 9 from circuit plus 3 general purpose
- annos.count(_.isInstanceOf[InlineAnnotation]) should be(9)
- annotationsTestFile.delete()
- }
-
- // Deprecated
- "Supported LegacyAnnotations will be converted automagically" in {
- val testDir = createTestDirectory("test")
- val annoFilename = "LegacyAnnotations.anno"
- val annotationsTestFile = new File(testDir, annoFilename)
- val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
- commonOptions = commonOptions.copy(topName = "test", targetDirName = testDir.toString)
- firrtlOptions = firrtlOptions.copy(
- annotationFileNames = List(annotationsTestFile.toString)
- )
- }
- copyResourceToFile(s"/annotations/$annoFilename", annotationsTestFile)
- val annos = Driver.getAnnotations(optionsManager)
-
- val cname = CircuitName("foo")
- val mname = ModuleName("bar", cname)
- val compname = ComponentName("x", mname)
- import firrtl.passes.clocklist._
- import firrtl.passes.memlib._
- import firrtl.passes.wiring._
- import firrtl.transforms._
- val expected = List(
- InlineAnnotation(cname),
- ClockListAnnotation(mname, "output"),
- InferReadWriteAnnotation,
- ReplSeqMemAnnotation("input", "output"),
- NoDedupMemAnnotation(compname),
- NoDedupAnnotation(mname),
- SourceAnnotation(compname, "pin"),
- SinkAnnotation(compname, "pin"),
- BlackBoxResourceAnno(mname, "resource"),
- BlackBoxInlineAnno(mname, "name", "text"),
- BlackBoxTargetDirAnno("targetdir"),
- NoDCEAnnotation,
- DontTouchAnnotation(compname),
- OptimizableExtModuleAnnotation(mname)
- )
- for (e <- expected) {
- annos should contain(e)
- }
- }
-
- // Deprecated
- "UNsupported LegacyAnnotations should throw errors" in {
- val testDir = createTestDirectory("test")
- val annoFilename = "InvalidLegacyAnnotations.anno"
- val annotationsTestFile = new File(testDir, annoFilename)
- copyResourceToFile(s"/annotations/$annoFilename", annotationsTestFile)
-
- import net.jcazevedo.moultingyaml._
- val text = FileUtils.getText(annotationsTestFile)
- val yamlAnnos = text.parseYaml match {
- case YamlArray(xs) => xs
- }
-
- // Since each one should error, emit each one to an anno file and try to read it
- for ((anno, i) <- yamlAnnos.zipWithIndex) {
- val annoFile = new File(testDir, s"anno_$i.anno")
- val fw = new FileWriter(annoFile)
- fw.write(YamlArray(anno).prettyPrint)
- fw.close()
- val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
- commonOptions = commonOptions.copy(topName = "test", targetDirName = testDir.toString)
- firrtlOptions = firrtlOptions.copy(
- annotationFileNames = List(annoFile.toString)
- )
- }
- (the[Exception] thrownBy {
- Driver.getAnnotations(optionsManager)
- }).getMessage should include("Old-style annotations")
- }
- }
-
"Annotations can be read from multiple files" in {
val filename = "SampleAnnotations.anno.json"
val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions {
diff --git a/src/test/scala/firrtlTests/FileUtilsSpec.scala b/src/test/scala/firrtlTests/FileUtilsSpec.scala
index 7b643e84..43d35048 100644
--- a/src/test/scala/firrtlTests/FileUtilsSpec.scala
+++ b/src/test/scala/firrtlTests/FileUtilsSpec.scala
@@ -9,7 +9,7 @@ import org.scalatest.matchers.should.Matchers
class FileUtilsSpec extends AnyFlatSpec with Matchers {
- private val sampleAnnotations: String = "annotations/SampleAnnotations.anno"
+ private val sampleAnnotations: String = "annotations/SampleAnnotations.anno.json"
private val sampleAnnotationsFileName: String = s"src/test/resources/$sampleAnnotations"
behavior of "FileUtils.getLines"
diff --git a/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala b/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala
index 5c8f1129..1b4a1375 100644
--- a/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala
+++ b/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala
@@ -304,69 +304,6 @@ class FirrtlMainSpec extends AnyFeatureSpec with GivenWhenThen with Matchers wit
* behavior.
*/
- Scenario("User tries to use an implicit annotation file") {
- val f = new FirrtlMainFixture
- val td = new TargetDirectoryFixture("implict-annotation-file")
- val circuit = new SimpleFirrtlCircuitFixture
-
- And("implicit legacy and extant annotation files")
- val annoFiles = Array( (new File(td.dir + "/Top.anno"), "/annotations/SampleAnnotations.anno"),
- (new File(td.dir + "/Top.anno.json"), "/annotations/SampleAnnotations.anno.json") )
- annoFiles.foreach{ case (file, source) => copyResourceToFile(source, file) }
-
- When("the user implies an annotation file (an annotation file has the same base name as an input file)")
- val in = new File(td.dir + "/Top.fir")
- val pw = new PrintWriter(in)
- pw.write(circuit.input)
- pw.close()
- val (out, _, result) = grabStdOutErr{ catchStatus { f.stage.main(Array("-td", td.dir.toString,
- "-i", in.toString,
- "-foaf", "Top.out",
- "-X", "high",
- "-E", "high")) } }
-
- Then("the implicit annotation file should NOT be read")
- val annoFileOut = new File(td.dir + "/Top.out.anno.json")
- val annotationJson = FileUtils.getText(annoFileOut)
- annotationJson should not include ("InlineInstances")
-
- And("no warning should be printed")
- out should not include ("Warning:")
-
- And("no error should be printed")
- out should not include ("Error:")
-
- And("the exit code should be 0")
- result shouldBe a [Right[_,_]]
- }
-
- Scenario("User provides unsupported legacy annotations") {
- val f = new FirrtlMainFixture
- val td = new TargetDirectoryFixture("legacy-annotation-file")
- val circuit = new SimpleFirrtlCircuitFixture
-
- And("a legacy annotation file")
- val annoFile = new File(td.dir + "/legacy.anno")
- copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile)
-
- When("the user provides legacy annotations")
- val in = new File(td.dir + "/Top.fir")
- val pw = new PrintWriter(in)
- pw.write(circuit.input)
- pw.close()
- val (out, _, result) = grabStdOutErr{ catchStatus { f.stage.main(Array("-td", td.dir.toString,
- "-i", in.toString,
- "-faf", annoFile.toString,
- "-foaf", "Top",
- "-X", "high")) } }
-
- Then("a warning should be printed")
- out should include ("YAML Annotation files are deprecated")
-
- And("the exit code should be 0")
- result shouldBe a [Right[_,_]]
- }
-
Seq(
/* Erroneous inputs */
FirrtlMainTest(args = Array("--thisIsNotASupportedOption"),