diff --git a/integration_test/EmitVerilog/exampleCodeGen.fir b/integration_test/EmitVerilog/exampleCodeGen.fir index 07ecabfa9f..3f785f57da 100644 --- a/integration_test/EmitVerilog/exampleCodeGen.fir +++ b/integration_test/EmitVerilog/exampleCodeGen.fir @@ -1,5 +1,5 @@ ; REQUIRES: verilator -; RUN: firtool -verilog -lower-to-hw %s > %t.sv +; RUN: firtool -verilog %s > %t.sv ; RUN: circt-rtl-sim.py %t.sv 2>&1 | tee %t.out ; RUN: grep PASS %t.out diff --git a/integration_test/EmitVerilog/standards-verilator.mlir b/integration_test/EmitVerilog/standards-verilator.mlir index fbcd687a79..48516d1aee 100644 --- a/integration_test/EmitVerilog/standards-verilator.mlir +++ b/integration_test/EmitVerilog/standards-verilator.mlir @@ -1,12 +1,12 @@ // REQUIRES: verilator -// RUN: firtool --lower-to-hw --verilog %s > %t1.1995.v -// RUN: firtool --lower-to-hw --verilog %s > %t1.2001.v -// RUN: firtool --lower-to-hw --verilog %s > %t1.2005.v -// RUN: firtool --lower-to-hw --verilog %s > %t1.2005.sv -// RUN: firtool --lower-to-hw --verilog %s > %t1.2009.sv -// RUN: firtool --lower-to-hw --verilog %s > %t1.2012.sv -// RUN: firtool --lower-to-hw --verilog %s> %t1.2017.sv +// RUN: firtool --verilog %s > %t1.1995.v +// RUN: firtool --verilog %s > %t1.2001.v +// RUN: firtool --verilog %s > %t1.2005.v +// RUN: firtool --verilog %s > %t1.2005.sv +// RUN: firtool --verilog %s > %t1.2009.sv +// RUN: firtool --verilog %s > %t1.2012.sv +// RUN: firtool --verilog %s> %t1.2017.sv // RUN: verilator --lint-only +1364-1995ext+v %t1.1995.v || true // RUN: verilator --lint-only +1364-2001ext+v %t1.2001.v || true diff --git a/integration_test/EmitVerilog/verilog_equiv.fir b/integration_test/EmitVerilog/verilog_equiv.fir index 04e1fe3368..4c357b65c1 100644 --- a/integration_test/EmitVerilog/verilog_equiv.fir +++ b/integration_test/EmitVerilog/verilog_equiv.fir @@ -1,8 +1,8 @@ ; REQUIRES: yosys ; RUN: split-file %s %t -; RUN: firtool %t/test_mod.fir --format=fir --lower-to-hw -verilog -o %t/test_mod.fir.v -; RUN: firtool %t/test_unary.fir --format=fir --lower-to-hw -verilog -o %t/test_unary.fir.v -; RUN: firtool %t/test_prim.fir --format=fir --lower-to-hw -verilog -o %t/test_prim.fir.v +; RUN: firtool %t/test_mod.fir --format=fir -verilog -o %t/test_mod.fir.v +; RUN: firtool %t/test_unary.fir --format=fir -verilog -o %t/test_unary.fir.v +; RUN: firtool %t/test_prim.fir --format=fir -verilog -o %t/test_prim.fir.v ; RUN: equiv-rtl.sh %t/test_mod.fir.v %t/test_mod.v test_mod ; RUN: equiv-rtl.sh %t/test_unary.fir.v %t/test_unary.v test_unary ; RUN: equiv-rtl.sh %t/test_prim.fir.v %t/test_prim.v test_prim diff --git a/test/Dialect/FIRRTL/SFCTests/async-reset-errors.mlir b/test/Dialect/FIRRTL/SFCTests/async-reset-errors.mlir index 9fc3978fb4..60d20bebbc 100644 --- a/test/Dialect/FIRRTL/SFCTests/async-reset-errors.mlir +++ b/test/Dialect/FIRRTL/SFCTests/async-reset-errors.mlir @@ -1,4 +1,4 @@ -// RUN: firtool --lower-to-hw --split-input-file --verify-diagnostics %s +// RUN: firtool --hw --split-input-file --verify-diagnostics %s // These will be picked up by https://github.com/llvm/circt/pull/1444 // Tests extracted from: diff --git a/test/Dialect/FIRRTL/SFCTests/async-reset.fir b/test/Dialect/FIRRTL/SFCTests/async-reset.fir index 5e27e10f8e..2c80d7c34e 100644 --- a/test/Dialect/FIRRTL/SFCTests/async-reset.fir +++ b/test/Dialect/FIRRTL/SFCTests/async-reset.fir @@ -1,4 +1,4 @@ -; RUN: firtool --split-input-file %s | FileCheck %s +; RUN: firtool --split-input-file %s --ir-fir | FileCheck %s ; Tests extracted from: ; - test/scala/firrtlTests/AsyncResetSpec.scala diff --git a/test/Dialect/FIRRTL/SFCTests/async-reset.mlir b/test/Dialect/FIRRTL/SFCTests/async-reset.mlir index a5aa74592d..7480dc0e83 100644 --- a/test/Dialect/FIRRTL/SFCTests/async-reset.mlir +++ b/test/Dialect/FIRRTL/SFCTests/async-reset.mlir @@ -1,4 +1,4 @@ -// RUN: firtool %s | FileCheck %s +// RUN: firtool --ir-fir %s | FileCheck %s // Tests extracted from: // - test/scala/firrtlTests/AsyncResetSpec.scala diff --git a/test/Dialect/FIRRTL/SFCTests/remove-reset.fir b/test/Dialect/FIRRTL/SFCTests/remove-reset.fir index 7a46cf1c93..5b00edc8c9 100644 --- a/test/Dialect/FIRRTL/SFCTests/remove-reset.fir +++ b/test/Dialect/FIRRTL/SFCTests/remove-reset.fir @@ -1,4 +1,4 @@ -; RUN: firtool --split-input-file %s | FileCheck %s +; RUN: firtool --split-input-file %s --ir-fir | FileCheck %s ; Tests extracted from: ; - test/scala/firrtlTests/transforms/RemoveResetSpec.scala diff --git a/test/Dialect/FIRRTL/SFCTests/width-spec.fir b/test/Dialect/FIRRTL/SFCTests/width-spec.fir index 76b2c5aa10..31f9245e48 100644 --- a/test/Dialect/FIRRTL/SFCTests/width-spec.fir +++ b/test/Dialect/FIRRTL/SFCTests/width-spec.fir @@ -1,4 +1,4 @@ -; RUN: firtool --split-input-file %s | FileCheck %s +; RUN: firtool --split-input-file %s --ir-fir | FileCheck %s ; Tests extracted from: ; - test/scala/firrtlTests/WidthSpec.scala diff --git a/test/firtool/blackbox.mlir b/test/firtool/blackbox.mlir index 3707fe9379..05ba4a88a5 100644 --- a/test/firtool/blackbox.mlir +++ b/test/firtool/blackbox.mlir @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: firtool %s --blackbox-resource-path=%S/.. | firtool --format=mlir --split-verilog -o=%t --blackbox-path=%S --blackbox-resource-path=%S/.. +// RUN: firtool %s --ir-fir --blackbox-resource-path=%S/.. | firtool --format=mlir --split-verilog -o=%t --blackbox-path=%S --blackbox-resource-path=%S/.. // RUN: FileCheck %s --check-prefix=VERILOG-TOP < %t/test_mod.sv // RUN: FileCheck %s --check-prefix=VERILOG-FOO < %t/magic/blackbox-inline.v // RUN: FileCheck %s --check-prefix=VERILOG-HDR < %t/magic/blackbox-inline.svh diff --git a/test/firtool/firtool.fir b/test/firtool/firtool.fir index 131c0183e0..93b980288f 100644 --- a/test/firtool/firtool.fir +++ b/test/firtool/firtool.fir @@ -1,12 +1,12 @@ -; RUN: firtool %s --format=fir -mlir | circt-opt | FileCheck %s --check-prefix=MLIR -; RUN: firtool %s --format=fir -mlir --annotation-file %s.anno.json,%s.anno.1.json | circt-opt | FileCheck %s --check-prefix=ANNOTATIONS -; RUN: firtool %s --format=fir -mlir --annotation-file %s.anno.json --annotation-file %s.anno.1.json | circt-opt | FileCheck %s --check-prefix=ANNOTATIONS -; RUN: firtool %s --format=fir -mlir -lower-to-hw | circt-opt | FileCheck %s --check-prefix=MLIRLOWER +; RUN: firtool %s --format=fir --ir-fir | circt-opt | FileCheck %s --check-prefix=MLIR +; RUN: firtool %s --format=fir --ir-fir --annotation-file %s.anno.json,%s.anno.1.json | circt-opt | FileCheck %s --check-prefix=ANNOTATIONS +; RUN: firtool %s --format=fir --ir-fir --annotation-file %s.anno.json --annotation-file %s.anno.1.json | circt-opt | FileCheck %s --check-prefix=ANNOTATIONS +; RUN: firtool %s --format=fir --ir-hw | circt-opt | FileCheck %s --check-prefix=MLIRLOWER ; RUN: firtool %s --format=fir -verilog | FileCheck %s --check-prefix=VERILOG -; RUN: firtool %s --annotation-file %s.anno.json,%s.anno.1.json --mlir --parse-only | FileCheck %s --check-prefix=ANNOTATIONS +; RUN: firtool %s --annotation-file %s.anno.json,%s.anno.1.json --parse-only | FileCheck %s --check-prefix=ANNOTATIONS ; RUN: firtool %s --omir-file %s.omir.anno.json --parse-only | FileCheck %s --check-prefix=OMIR ; RUN: firtool %s --omir-file %s.omir.anno.json --output-omir meta.omir.json --verilog | FileCheck %s --check-prefix=OMIROUT -; RUN: firtool %s --format=fir -verilog-ir | circt-opt | FileCheck %s --check-prefix=VERILOG-IR +; RUN: firtool %s --format=fir --ir-verilog | circt-opt | FileCheck %s --check-prefix=VERILOG-IR circuit test_mod : %[[{"a": "a"}]] diff --git a/test/firtool/firtool.mlir b/test/firtool/firtool.mlir index ba6ddf8fac..20a8b71556 100644 --- a/test/firtool/firtool.mlir +++ b/test/firtool/firtool.mlir @@ -1,4 +1,4 @@ -// RUN: firtool %s --format=mlir -mlir | circt-opt | FileCheck %s --check-prefix=MLIR +// RUN: firtool %s --format=mlir --ir-fir | circt-opt | FileCheck %s --check-prefix=MLIR // RUN: firtool %s --format=mlir -verilog | FileCheck %s --check-prefix=VERILOG firrtl.circuit "Top" { diff --git a/test/firtool/memory.fir b/test/firtool/memory.fir index 45f4e9325b..d28bba7837 100644 --- a/test/firtool/memory.fir +++ b/test/firtool/memory.fir @@ -1,5 +1,5 @@ -; RUN: firtool %s --format=fir --lower-to-hw | FileCheck %s -; RUN: firtool %s --format=fir --lower-to-hw --ignore-read-enable-mem | FileCheck --check-prefix=READ %s +; RUN: firtool %s --format=fir --ir-hw | FileCheck %s +; RUN: firtool %s --format=fir --ir-hw --ignore-read-enable-mem | FileCheck --check-prefix=READ %s circuit Qux: module Qux: diff --git a/test/firtool/optimizations.fir b/test/firtool/optimizations.fir index f558fcb065..23c1839a29 100644 --- a/test/firtool/optimizations.fir +++ b/test/firtool/optimizations.fir @@ -1,5 +1,5 @@ -; RUN: firtool %s --format=fir | circt-opt | FileCheck %s --check-prefix=OPT -; RUN: firtool %s --format=fir -disable-opt | circt-opt | FileCheck %s --check-prefix=NOOPT +; RUN: firtool %s --format=fir --ir-fir | circt-opt | FileCheck %s --check-prefix=OPT +; RUN: firtool %s --format=fir --ir-fir -disable-opt | circt-opt | FileCheck %s --check-prefix=NOOPT circuit test_cse : module test_cse : diff --git a/test/firtool/phase-ordering.fir b/test/firtool/phase-ordering.fir index 89668682cd..ab49b61fff 100644 --- a/test/firtool/phase-ordering.fir +++ b/test/firtool/phase-ordering.fir @@ -1,4 +1,4 @@ -; RUN: firtool %s --format=fir | FileCheck %s +; RUN: firtool %s --format=fir --ir-fir | FileCheck %s ; Temporary wires should not be introduced by type lowering, and if they are, ; they should be cleaned up by canonicalize. diff --git a/test/firtool/style.fir b/test/firtool/style.fir index 502d1a5b25..4eef67b27b 100644 --- a/test/firtool/style.fir +++ b/test/firtool/style.fir @@ -1,6 +1,6 @@ -; RUN: firtool %s | FileCheck %s --check-prefix=DEFAULT -; RUN: not firtool --lowering-options=bad-option %s 2>&1 | FileCheck %s --check-prefix=BADOPTION -; RUN: firtool --lowering-options=noAlwaysComb %s | FileCheck %s --check-prefix=OPTIONS +; RUN: firtool %s --ir-fir| FileCheck %s --check-prefix=DEFAULT +; RUN: not firtool --ir-fir --lowering-options=bad-option %s 2>&1 | FileCheck %s --check-prefix=BADOPTION +; RUN: firtool --ir-fir --lowering-options=noAlwaysComb %s | FileCheck %s --check-prefix=OPTIONS circuit test : module test : diff --git a/tools/firtool/firtool.cpp b/tools/firtool/firtool.cpp index 2da15605b8..572963b928 100644 --- a/tools/firtool/firtool.cpp +++ b/tools/firtool/firtool.cpp @@ -67,10 +67,6 @@ static cl::opt cl::desc("Output filename, or directory for split output"), cl::value_desc("filename"), cl::init("-")); -static cl::opt - parseOnly("parse-only", - cl::desc("Stop after parsing inputs and annotations")); - static cl::opt splitInputFile("split-input-file", cl::desc("Split the input file into pieces and process each " @@ -90,9 +86,6 @@ static cl::opt inliner("inline", cl::desc("Run the FIRRTL module inliner"), cl::init(true)); -static cl::opt lowerToHW("lower-to-hw", - cl::desc("run the lower-to-hw pass")); - static cl::opt enableAnnotationWarning( "warn-on-unprocessed-annotations", cl::desc("Warn about annotations that were not removed by lower-to-hw"), @@ -205,25 +198,30 @@ static cl::opt newAnno("new-anno", cl::init(false)); enum OutputFormatKind { - OutputMLIR, + OutputParseOnly, + OutputIRFir, + OutputIRHW, + OutputIRVerilog, OutputVerilog, OutputSplitVerilog, - OutputVerilogIR, OutputDisabled }; static cl::opt outputFormat( cl::desc("Specify output format:"), - cl::values(clEnumValN(OutputMLIR, "mlir", "Emit MLIR dialect"), - clEnumValN(OutputVerilog, "verilog", "Emit Verilog"), - clEnumValN(OutputSplitVerilog, "split-verilog", - "Emit Verilog (one file per module; specify " - "directory with -o=)"), - clEnumValN(OutputVerilogIR, "verilog-ir", - "Emit IR after Verilog lowering"), - clEnumValN(OutputDisabled, "disable-output", - "Do not output anything")), - cl::init(OutputMLIR)); + cl::values( + clEnumValN(OutputParseOnly, "parse-only", + "Emit FIR dialect after parsing"), + clEnumValN(OutputIRFir, "ir-fir", "Emit FIR dialect after pipeline"), + clEnumValN(OutputIRHW, "ir-hw", "Emit HW dialect"), + clEnumValN(OutputIRVerilog, "ir-verilog", + "Emit IR after Verilog lowering"), + clEnumValN(OutputVerilog, "verilog", "Emit Verilog"), + clEnumValN(OutputSplitVerilog, "split-verilog", + "Emit Verilog (one file per module; specify " + "directory with -o=)"), + clEnumValN(OutputDisabled, "disable-output", "Do not output anything")), + cl::init(OutputVerilog)); static cl::opt verifyPasses("verify-each", @@ -308,23 +306,11 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, return failure(); // If the user asked for just a parse, stop here. - if (parseOnly) { + if (outputFormat == OutputParseOnly) { mlir::ModuleOp theModule = module.release(); - switch (outputFormat) { - case OutputMLIR: { - auto outputTimer = ts.nest("Print .mlir output"); - theModule->print(outputFile.getValue()->os()); - return success(); - } - case OutputDisabled: - return success(); - case OutputVerilog: - case OutputSplitVerilog: - case OutputVerilogIR: - llvm::errs() - << "verilog emission is not supported in -parse-only mode.\n"; - return failure(); - } + auto outputTimer = ts.nest("Print .mlir output"); + theModule->print(outputFile.getValue()->os()); + return success(); } // Apply any pass manager command line options. @@ -423,8 +409,7 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, firrtl::createEmitOMIRPass(omirOutFile)); // Lower if we are going to verilog or if lowering was specifically requested. - if (lowerToHW || outputFormat == OutputVerilog || - outputFormat == OutputSplitVerilog || outputFormat == OutputVerilogIR) { + if (outputFormat != OutputIRFir) { pm.addPass(createLowerFIRRTLToHWPass(enableAnnotationWarning.getValue(), nonConstAsyncResetValueIsError)); pm.addPass(sv::createHWMemSimImplPass(replSeqMem, ignoreReadEnableMem)); @@ -443,7 +428,7 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, // Add passes specific to Verilog emission if we're going there. if (outputFormat == OutputVerilog || outputFormat == OutputSplitVerilog || - outputFormat == OutputVerilogIR) { + outputFormat == OutputIRVerilog) { // Legalize unsupported operations within the modules. pm.nest().addPass(sv::createHWLegalizeModulesPass()); @@ -455,8 +440,7 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, // Emit a single file or multiple files depending on the output format. switch (outputFormat) { - case OutputMLIR: - case OutputDisabled: + default: llvm_unreachable("can't reach this"); case OutputVerilog: pm.addPass(createExportVerilogPass(outputFile.getValue()->os())); @@ -464,7 +448,7 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, case OutputSplitVerilog: pm.addPass(createExportSplitVerilogPass(outputFilename)); break; - case OutputVerilogIR: + case OutputIRVerilog: // Run the ExportVerilog pass to get its lowering, but discard the output. pm.addPass(createExportVerilogPass(llvm::nulls())); break; @@ -483,7 +467,8 @@ processBuffer(MLIRContext &context, TimingScope &ts, llvm::SourceMgr &sourceMgr, if (failed(pm.run(module.get()))) return failure(); - if (outputFormat == OutputMLIR || outputFormat == OutputVerilogIR) { + if (outputFormat == OutputIRFir || outputFormat == OutputIRHW || + outputFormat == OutputIRVerilog) { auto outputTimer = ts.nest("Print .mlir output"); module->print(outputFile.getValue()->os()); }