Skip to content

Commit 990d37a

Browse files
authored
Deprecate everything in package firrtl (#4878)
Previously, we tried to avoid this by deprecating any imports from the firrtl package, but this missed things. Instead, we deprecate every public class, object, and trait. Also delete the previous attempt using the DeprecateSFCComponent in the compiler plugin. It is now redundant.
1 parent 17c9e97 commit 990d37a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+315
-84
lines changed

build.mill

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ object v extends Module {
7777

7878
val scala2WarnConf = Seq(
7979
"msg=APIs in chisel3.internal:s",
80-
"msg=Importing from firrtl:s",
80+
"msg=All APIs in package firrtl:s",
8181
"msg=migration to the MLIR:s",
8282
"msg=method hasDefiniteSize in trait IterableOnceOps is deprecated:s", // replacement `knownSize` is not in 2.12
8383
"msg=object JavaConverters in package collection is deprecated:s",

firrtl/src/main/scala/firrtl/AttributeAnnotation.scala

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import firrtl.annotations.{Named, SingleTargetAnnotation}
77
* @param target target component to tag with attribute
88
* @param description Attribute string to add to target
99
*/
10+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1011
case class AttributeAnnotation(target: Named, description: String) extends SingleTargetAnnotation[Named] {
1112
def duplicate(n: Named): AttributeAnnotation = this.copy(target = n, description = description)
1213
}

firrtl/src/main/scala/firrtl/Compiler.scala

+2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ package firrtl
55
import firrtl.annotations._
66

77
/** Container of all annotations for a Firrtl compiler */
8+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
89
class AnnotationSeq private (underlying: Seq[Annotation]) {
910
def toSeq: Seq[Annotation] = underlying
1011
}
12+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1113
object AnnotationSeq {
1214
def apply(xs: Seq[Annotation]): AnnotationSeq = new AnnotationSeq(xs)
1315
}

firrtl/src/main/scala/firrtl/Emitter.scala

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import firrtl.stage.FirrtlOptions
99
import firrtl.stage.FirrtlOptionsView
1010

1111
// ***** Annotations for results of emission *****
12+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1213
sealed abstract class EmittedComponent {
1314
def name: String
1415

@@ -17,9 +18,11 @@ sealed abstract class EmittedComponent {
1718
def outputSuffix: String
1819
}
1920

21+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2022
sealed abstract class EmittedCircuit extends EmittedComponent
2123

2224
/** Traits for Annotations containing emitted components */
25+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2326
trait EmittedAnnotation[T <: EmittedComponent] extends NoTargetAnnotation with CustomFileEmission {
2427
val value: T
2528

@@ -30,20 +33,27 @@ trait EmittedAnnotation[T <: EmittedComponent] extends NoTargetAnnotation with C
3033
override protected val suffix: Option[String] = Some(value.outputSuffix)
3134
}
3235

36+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3337
sealed trait EmittedCircuitAnnotation[T <: EmittedCircuit] extends EmittedAnnotation[T] {
3438
override def getBytes = value.value.getBytes
3539
}
3640

41+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3742
case class EmittedFirrtlCircuitAnnotation(value: EmittedFirrtlCircuit)
3843
extends EmittedCircuitAnnotation[EmittedFirrtlCircuit]
3944

45+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4046
final case class EmittedFirrtlCircuit(name: String, value: String, outputSuffix: String) extends EmittedCircuit
4147

48+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4249
final case class EmittedBtor2Circuit(name: String, value: String, outputSuffix: String) extends EmittedCircuit
4350

51+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4452
case class EmittedBtor2CircuitAnnotation(value: EmittedBtor2Circuit)
4553
extends EmittedCircuitAnnotation[EmittedBtor2Circuit]
4654

55+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4756
final case class EmittedVerilogCircuit(name: String, value: String, outputSuffix: String) extends EmittedCircuit
57+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4858
case class EmittedVerilogCircuitAnnotation(value: EmittedVerilogCircuit)
4959
extends EmittedCircuitAnnotation[EmittedVerilogCircuit]

firrtl/src/main/scala/firrtl/FirrtlException.scala

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import scala.util.control.NoStackTrace
99
* These exceptions indicate a problem due to bad input and thus do not include a stack trace.
1010
* This can be extended by custom transform writers.
1111
*/
12+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1213
class FirrtlUserException(message: String, cause: Throwable = null)
1314
extends RuntimeException(message, cause)
1415
with NoStackTrace

firrtl/src/main/scala/firrtl/Parser.scala

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package firrtl
44

5+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
56
object Parser {
67

78
sealed abstract class InfoMode

firrtl/src/main/scala/firrtl/PrimOps.scala

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import logger.LazyLogging
66
import firrtl.ir._
77

88
/** Definitions and Utility functions for [[ir.PrimOp]]s */
9+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
910
object PrimOps extends LazyLogging {
1011

1112
/** Addition */

firrtl/src/main/scala/firrtl/RenameMap.scala

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import firrtl.renamemap._
99

1010
import scala.collection.mutable
1111

12+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1213
object RenameMap {
1314
def apply(map: collection.Map[Named, Seq[Named]], circuitName: String): RenameMap =
1415
MutableRenameMap.fromNamed(map, circuitName)
@@ -31,6 +32,7 @@ object RenameMap {
3132
* @define noteDistinct @note Rename to/tos will be made distinct
3233
*/
3334
// TODO This should probably be refactored into immutable and mutable versions
35+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3436
sealed trait RenameMap {
3537

3638
// Records the name of the circuit to which this rename map applies. This is
@@ -521,6 +523,7 @@ sealed trait RenameMap {
521523

522524
// This must be in same file as RenameMap because RenameMap is sealed
523525
package object renamemap {
526+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
524527
object MutableRenameMap {
525528
def fromNamed(map: collection.Map[Named, Seq[Named]], circuitName: String): MutableRenameMap = {
526529
val rm = new MutableRenameMap(circuitName)
@@ -538,6 +541,7 @@ package object renamemap {
538541
def apply(circuitName: String): MutableRenameMap = new MutableRenameMap(circuitName)
539542
}
540543

544+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
541545
final class MutableRenameMap private[firrtl] (
542546
override protected val circuitName: String,
543547
protected val _underlying: mutable.HashMap[CompleteTarget, Seq[CompleteTarget]] =

firrtl/src/main/scala/firrtl/Utils.scala

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import firrtl.ir._
66

77
import _root_.logger.LazyLogging
88

9+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
910
object Utils extends LazyLogging {
1011

1112
/** Unwind the causal chain until we hit the initial exception (which may be the first).

firrtl/src/main/scala/firrtl/WIR.scala

+7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ package firrtl
44

55
import firrtl.ir._
66

7+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
78
abstract class MPortDir extends FirrtlNode
9+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
810
case object MInfer extends MPortDir {
911
def serialize: String = "infer"
1012
}
13+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1114
case object MRead extends MPortDir {
1215
def serialize: String = "read"
1316
}
17+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1418
case object MWrite extends MPortDir {
1519
def serialize: String = "write"
1620
}
21+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1722
case object MReadWrite extends MPortDir {
1823
def serialize: String = "rdwr"
1924
}
2025

26+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2127
case class CDefMemory(
2228
info: Info,
2329
name: String,
@@ -39,6 +45,7 @@ case class CDefMemory(
3945
def foreachString(f: String => Unit): Unit = f(name)
4046
def foreachInfo(f: Info => Unit): Unit = f(info)
4147
}
48+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
4249
case class CDefMPort(info: Info, name: String, tpe: Type, mem: String, exps: Seq[Expression], direction: MPortDir)
4350
extends Statement
4451
with HasInfo

firrtl/src/main/scala/firrtl/annotations/Annotation.scala

+6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ package annotations
55

66
import org.json4s.JValue
77

8+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
89
case class AnnotationException(message: String) extends Exception(message)
910

1011
/** Base type of auxiliary information */
12+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1113
trait Annotation extends Product {
1214

1315
/** Update the target based on how signals are renamed */
@@ -24,11 +26,13 @@ trait Annotation extends Product {
2426
/** If an Annotation does not target any [[Named]] thing in the circuit, then all updates just
2527
* return the Annotation itself
2628
*/
29+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2730
trait NoTargetAnnotation extends Annotation {
2831
def update(renames: RenameMap): Seq[NoTargetAnnotation] = Seq(this)
2932
}
3033

3134
/** An Annotation that targets a single [[Named]] thing */
35+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3236
trait SingleTargetAnnotation[T <: Named] extends Annotation {
3337
val target: T
3438

@@ -71,6 +75,8 @@ trait SingleTargetAnnotation[T <: Named] extends Annotation {
7175
}
7276
}
7377

78+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
7479
object Annotation
7580

81+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
7682
case class UnrecognizedAnnotation(underlying: JValue) extends NoTargetAnnotation

firrtl/src/main/scala/firrtl/annotations/AnnotationUtils.scala

+8
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@ import java.io.File
77

88
import firrtl.ir._
99

10+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1011
case class InvalidAnnotationFileException(file: File, cause: FirrtlUserException = null)
1112
extends FirrtlUserException(s"$file", cause)
13+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1214
case class UnrecogizedAnnotationsException(msg: String) extends FirrtlUserException(s"Unrecognized annotations $msg")
15+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1316
case class InvalidAnnotationJSONException(msg: String) extends FirrtlUserException(msg)
17+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1418
case class AnnotationFileNotFoundException(file: File)
1519
extends FirrtlUserException(
1620
s"Annotation file $file not found!"
1721
)
22+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1823
case class AnnotationClassNotFoundException(className: String)
1924
extends FirrtlUserException(
2025
s"Annotation class $className not found! Please check spelling and classpath"
2126
)
27+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2228
class UnserializableAnnotationException private (msg: String) extends FirrtlUserException(msg)
29+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2330
object UnserializableAnnotationException {
2431
private def toMessage(pair: (Annotation, Throwable)): String =
2532
s"Failed to serialiaze annotation of type ${pair._1.getClass.getName} because '${pair._2.getMessage}'"
@@ -30,6 +37,7 @@ object UnserializableAnnotationException {
3037
}
3138
}
3239

40+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3341
object AnnotationUtils {
3442

3543
/** Returns true if a valid Module name */

firrtl/src/main/scala/firrtl/annotations/JsonProtocol.scala

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.json4s.native.Serialization.{read, write, writePretty}
1717
import scala.collection.mutable
1818
import java.io.{StringWriter, Writer}
1919

20+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2021
trait HasSerializationHints {
2122
// For serialization of complicated constructor arguments, let the annotation
2223
// writer specify additional type hints for relevant classes that might be
@@ -25,8 +26,10 @@ trait HasSerializationHints {
2526
}
2627

2728
/** Wrapper [[Annotation]] for Annotations that cannot be serialized */
29+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2830
case class UnserializeableAnnotation(error: String, content: String) extends NoTargetAnnotation
2931

32+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3033
object JsonProtocol extends LazyLogging {
3134
private val GetClassPattern = "[^']*'([^']+)'.*".r
3235

firrtl/src/main/scala/firrtl/annotations/LoadMemoryAnnotation.scala

+3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import firrtl.FirrtlUserException
88

99
/** Representation of the two types of `readmem` statements available in Verilog.
1010
*/
11+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1112
sealed abstract class MemoryLoadFileType(val value: String) {
1213
def serialize: String = value
1314
}
1415

16+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1517
object MemoryLoadFileType {
1618
// purely for backwards compatibility with chisel3's ChiselLoadMemoryAnnotation
1719
type FileType = MemoryLoadFileType
@@ -30,6 +32,7 @@ object MemoryLoadFileType {
3032
* @param fileName name of input file
3133
* @param hexOrBinary use `\$readmemh` or `\$readmemb`
3234
*/
35+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
3336
case class LoadMemoryAnnotation(
3437
target: ComponentName,
3538
fileName: String,

firrtl/src/main/scala/firrtl/annotations/MemoryInitAnnotation.scala

+2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ package firrtl.annotations
77
* While not supported on normal ASIC flows, it can be useful for simulation and FPGA flows.
88
* This annotation is consumed by the verilog emitter.
99
*/
10+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1011
sealed trait MemoryInitAnnotation extends SingleTargetAnnotation[ReferenceTarget] {
1112
def isRandomInit: Boolean
1213
}
1314

1415
/** Initialize the `target` memory with inline readmem[hb] statement. */
16+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
1517
case class MemoryFileInlineAnnotation(
1618
target: ReferenceTarget,
1719
filename: String,

firrtl/src/main/scala/firrtl/annotations/Target.scala

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import scala.collection.mutable
1717
* - Complete: moduleOpt is non-empty, and all Instance(_) are followed by OfModule(_)
1818
* - Local: tokens does not refer to things through an instance hierarchy (no Instance(_) or OfModule(_) tokens)
1919
*/
20+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
2021
sealed trait Target extends Named {
2122

2223
/** @return Module name, if it exists */
@@ -79,6 +80,7 @@ sealed trait Target extends Named {
7980
def path: Seq[(Instance, OfModule)]
8081
}
8182

83+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
8284
object Target {
8385
def asTarget(m: ModuleTarget)(e: Expression): ReferenceTarget = e match {
8486
case r: ir.Reference => m.ref(r.name)
@@ -193,6 +195,7 @@ object Target {
193195
* @param moduleOpt Optional module name
194196
* @param tokens [[TargetToken]]s to represent the target in a module
195197
*/
198+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
196199
case class GenericTarget(moduleOpt: Option[String], tokens: Vector[TargetToken]) extends Target {
197200

198201
override def toGenericTarget: GenericTarget = this
@@ -342,6 +345,7 @@ case class GenericTarget(moduleOpt: Option[String], tokens: Vector[TargetToken])
342345
/** Concretely points to a FIRRTL target, no generic selectors
343346
* IsLegal
344347
*/
348+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
345349
trait CompleteTarget extends Target {
346350

347351
def getComplete: Option[CompleteTarget] = Some(this)
@@ -363,6 +367,7 @@ trait CompleteTarget extends Target {
363367
/** A member of a FIRRTL Circuit
364368
* Concrete Subclasses are: [[ModuleTarget]], [[InstanceTarget]], and [[ReferenceTarget]]
365369
*/
370+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
366371
trait IsMember extends CompleteTarget {
367372

368373
/** @return Root module, e.g. top-level module of this target */
@@ -414,6 +419,7 @@ trait IsMember extends CompleteTarget {
414419

415420
/** References a module-like target (e.g. a [[ModuleTarget]] or an [[InstanceTarget]])
416421
*/
422+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
417423
trait IsModule extends IsMember {
418424

419425
/** @return Creates a new Target, appending a ref */
@@ -427,6 +433,7 @@ trait IsModule extends IsMember {
427433

428434
/** A component of a FIRRTL Module (e.g. cannot point to a ModuleTarget)
429435
*/
436+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
430437
trait IsComponent extends IsMember {
431438

432439
/** Removes n levels of instance hierarchy
@@ -477,6 +484,7 @@ trait IsComponent extends IsMember {
477484
/** Target pointing to a FIRRTL [[firrtl.ir.DefModule]]
478485
* @param module Name of the module
479486
*/
487+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
480488
case class ModuleTarget(module: String) extends IsModule {
481489

482490
override def moduleOpt: Option[String] = Some(module)
@@ -520,6 +528,7 @@ case class ModuleTarget(module: String) extends IsModule {
520528
* @param ref Name of component
521529
* @param component Subcomponent of this reference, e.g. field or index
522530
*/
531+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
523532
case class ReferenceTarget(
524533
module: String,
525534
override val path: Seq[(Instance, OfModule)],
@@ -613,6 +622,7 @@ case class ReferenceTarget(
613622
* @param instance Name of the instance
614623
* @param ofModule Name of the instance's module
615624
*/
625+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
616626
case class InstanceTarget(
617627
module: String,
618628
override val path: Seq[(Instance, OfModule)],
@@ -677,15 +687,18 @@ case class InstanceTarget(
677687
}
678688

679689
/** Named classes associate an annotation with a component in a Firrtl circuit */
690+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
680691
sealed trait Named {
681692
def toTarget: CompleteTarget
682693
}
683694

695+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
684696
final case class ModuleName(name: String) extends Named {
685697
if (!validModuleName(name)) throw AnnotationException(s"Illegal module name: $name")
686698
def toTarget: ModuleTarget = ModuleTarget(name)
687699
}
688700

701+
@deprecated("All APIs in package firrtl are deprecated.", "Chisel 7.0.0")
689702
final case class ComponentName(name: String, module: ModuleName) extends Named {
690703
if (!validComponentName(name)) throw AnnotationException(s"Illegal component name: $name")
691704
def expr: Expression = toExp(name)

0 commit comments

Comments
 (0)