CIRCT  19.0.0git
FinalizeIR.cpp
Go to the documentation of this file.
1 //===- FinalizeIR.cpp - Finalize IR after ExportVerilog -------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the FinalizeIR pass.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 #include "circt/Dialect/SV/SVOps.h"
17 #include "mlir/Pass/Pass.h"
18 
19 namespace circt {
20 namespace firrtl {
21 #define GEN_PASS_DEF_FINALIZEIR
22 #include "circt/Dialect/FIRRTL/Passes.h.inc"
23 } // namespace firrtl
24 } // namespace circt
25 
26 using namespace circt;
27 namespace {
28 struct FinalizeIRPass
29  : public circt::firrtl::impl::FinalizeIRBase<FinalizeIRPass> {
30  void runOnOperation() override;
31 };
32 } // namespace
33 
34 /// Finalize the IR after ExportVerilog and before the final IR is emitted.
35 void FinalizeIRPass::runOnOperation() {
36  // Erase any sv.verbatim ops for sideband files.
37  for (auto verbatim : llvm::make_early_inc_range(
38  getOperation().getBodyRegion().getOps<sv::VerbatimOp>()))
39  if (auto outputFile = verbatim->getAttrOfType<hw::OutputFileAttr>(
40  hw::OutputFileAttr::getMnemonic()))
41  if (!outputFile.isDirectory() &&
42  outputFile.getExcludeFromFilelist().getValue())
43  verbatim.erase();
44 }
45 
46 std::unique_ptr<mlir::Pass> circt::firrtl::createFinalizeIRPass() {
47  return std::make_unique<FinalizeIRPass>();
48 }
std::unique_ptr< mlir::Pass > createFinalizeIRPass()
Definition: FinalizeIR.cpp:46
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21