diff options
| author | Schuyler Eldridge | 2020-08-28 12:09:43 -0400 |
|---|---|---|
| committer | GitHub | 2020-08-28 16:09:43 +0000 |
| commit | a8d7b9a2a118ac3763935664309c031b91d48ca0 (patch) | |
| tree | d161d5889c8a871a0292d472c6ececf7e5d3edd5 /src/test/scala/firrtl | |
| parent | 4ac3f314173732002daf26b6bfdaf95fd42213f5 (diff) | |
Deprecate CompilerAnnotation (#1870)
* CompilerAnnotation$ emits RunFirrtlTransform
Change the CompilerAnnotation object to emit
RunFirrtlTransformAnnotations containing the associated emitter.
This requires a fix in the Driver compatibility layer to know how to
enable one-file-per module emission if either a CompilerAnnotation or
a RunFirrtlTransformAnnotation(_: Emitter) is present.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Add ConvertCompilerAnnotation phase
Add a phase, ConvertCompilerAnnotation, that converts a
CompilerAnnotation to a RunFirrtlTransformAnnotation. This provides a
warning to the user if this path is taken.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Add test of ConvertCompilerAnnotation
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Deprecate CompilerAnnotation$, move helper methods
Deprecate the CompilerAnnotation companion object and move it's
private utility inside the RunFirrtlTransformAnnotation companion
object.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Make ConvertCompilerAnnotations private[firrtl]
Make this phase private to avoid adding a deprecation warning. Also,
remove an unused string value.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Fix incorrect string in test
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
* Add test that '-X verilog', no emitter yields file
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/test/scala/firrtl')
| -rw-r--r-- | src/test/scala/firrtl/stage/phases/tests/ConvertCompilerAnnotationsSpec.scala | 40 | ||||
| -rw-r--r-- | src/test/scala/firrtl/testutils/FirrtlSpec.scala | 2 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/test/scala/firrtl/stage/phases/tests/ConvertCompilerAnnotationsSpec.scala b/src/test/scala/firrtl/stage/phases/tests/ConvertCompilerAnnotationsSpec.scala new file mode 100644 index 00000000..acd37bf5 --- /dev/null +++ b/src/test/scala/firrtl/stage/phases/tests/ConvertCompilerAnnotationsSpec.scala @@ -0,0 +1,40 @@ +// See LICENSE for license details. + +package firrtl.stage.phases.tests + +import firrtl.{HighFirrtlCompiler, HighFirrtlEmitter, LowFirrtlCompiler} +import firrtl.options.{Dependency, OptionsException} +import firrtl.stage.{CompilerAnnotation, RunFirrtlTransformAnnotation} +import firrtl.stage.phases.ConvertCompilerAnnotations + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class ConvertCompilerAnnotationsSpec extends AnyFlatSpec with Matchers { + + class Fixture { + val phase = new ConvertCompilerAnnotations + } + + behavior.of(classOf[ConvertCompilerAnnotations].getName) + + it should "convert a deprecated CompilerAnnotation to a RunFirrtlTransformAnnotation" in new Fixture { + val annotations = Seq(CompilerAnnotation(new HighFirrtlCompiler)) + phase + .transform(annotations) + .map { + case RunFirrtlTransformAnnotation(a) => Dependency.fromTransform(a) + } + .toSeq should be(Seq(Dependency[HighFirrtlEmitter])) + } + + it should "throw an exception if multiple CompilerAnnotations are specified" in new Fixture { + val annotations = Seq( + CompilerAnnotation(new HighFirrtlCompiler), + CompilerAnnotation(new LowFirrtlCompiler) + ) + intercept[OptionsException] { + phase.transform(annotations) + }.getMessage should include("Zero or one CompilerAnnotation may be specified") + } +} diff --git a/src/test/scala/firrtl/testutils/FirrtlSpec.scala b/src/test/scala/firrtl/testutils/FirrtlSpec.scala index a0c41085..9ee5fdaf 100644 --- a/src/test/scala/firrtl/testutils/FirrtlSpec.scala +++ b/src/test/scala/firrtl/testutils/FirrtlSpec.scala @@ -101,7 +101,7 @@ trait FirrtlRunners extends BackendCompilationUtilities { InfoModeAnnotation("ignore") +: RenameTopAnnotation(topName) +: stage.FirrtlCircuitAnnotation(circuit) +: - stage.CompilerAnnotation("mverilog") +: + stage.RunFirrtlTransformAnnotation.stringToEmitter("mverilog") +: stage.OutputFileAnnotation(topName) +: toAnnos(baseTransforms) } |
