Skip to content

Commit

Permalink
Make logger annotations unserializable
Browse files Browse the repository at this point in the history
Change logger annotations to mix-in the Unserializable trait so that they
will not emitted by a stage.  These annotations are not intended to be
seen by CIRCT and these should be stripped from the output FIRRTL text.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
seldridge committed Mar 2, 2024
1 parent 61df8bb commit f1b5eff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions firrtl/src/main/scala/logger/LoggerAnnotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package logger

import firrtl.annotations.{Annotation, NoTargetAnnotation}
import firrtl.options.{HasShellOptions, ShellOption}
import firrtl.options.{HasShellOptions, ShellOption, Unserializable}

/** An annotation associated with a Logger command line option */
sealed trait LoggerOption { this: Annotation => }
Expand All @@ -16,6 +16,7 @@ sealed trait LoggerOption { this: Annotation => }
case class LogLevelAnnotation(globalLogLevel: LogLevel.Value = LogLevel.None)
extends NoTargetAnnotation
with LoggerOption
with Unserializable

object LogLevelAnnotation extends HasShellOptions {

Expand All @@ -39,6 +40,7 @@ object LogLevelAnnotation extends HasShellOptions {
case class ClassLogLevelAnnotation(className: String, level: LogLevel.Value)
extends NoTargetAnnotation
with LoggerOption
with Unserializable

object ClassLogLevelAnnotation extends HasShellOptions {

Expand All @@ -63,7 +65,7 @@ object ClassLogLevelAnnotation extends HasShellOptions {
* - maps to [[LoggerOptions.logFileName]]
* - enabled with `--log-file`
*/
case class LogFileAnnotation(file: Option[String]) extends NoTargetAnnotation with LoggerOption
case class LogFileAnnotation(file: Option[String]) extends NoTargetAnnotation with LoggerOption with Unserializable

object LogFileAnnotation extends HasShellOptions {

Expand All @@ -81,7 +83,11 @@ object LogFileAnnotation extends HasShellOptions {
/** Enables class names in log output
* - enabled with `-lcn/--log-class-names`
*/
case object LogClassNamesAnnotation extends NoTargetAnnotation with LoggerOption with HasShellOptions {
case object LogClassNamesAnnotation
extends NoTargetAnnotation
with LoggerOption
with HasShellOptions
with Unserializable {

val options = Seq(
new ShellOption[Unit](
Expand Down
6 changes: 6 additions & 0 deletions src/test/scala/circtTests/stage/ChiselStageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,12 @@ class ChiselStageSpec extends AnyFunSpec with Matchers with chiselTests.Utils {
}
log2 shouldNot include("Done elaborating.")
}

it("should not emit logger annotations") {
import chisel3.RawModule
(ChiselStage.emitCHIRRTL(new RawModule {}) should not).include("LogLevelAnnotation")
(ChiselStage.emitCHIRRTL(new RawModule {}, Array("-ll", "info")) should not).include("LogLevelAnnotation")
}
}

describe("ChiselStage$ exception handling") {
Expand Down

0 comments on commit f1b5eff

Please sign in to comment.