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 
13 #include "PassDetails.h"
16 #include "circt/Dialect/SV/SVOps.h"
17 
18 using namespace circt;
19 
20 namespace {
21 struct FinalizeIRPass : public firrtl::FinalizeIRBase<FinalizeIRPass> {
22  void runOnOperation() override;
23 };
24 } // namespace
25 
26 /// Finalize the IR after ExportVerilog and before the final IR is emitted.
27 void FinalizeIRPass::runOnOperation() {
28  // Erase any sv.verbatim ops for sideband files.
29  for (auto verbatim : llvm::make_early_inc_range(
30  getOperation().getBodyRegion().getOps<sv::VerbatimOp>()))
31  if (auto outputFile = verbatim->getAttrOfType<hw::OutputFileAttr>(
32  hw::OutputFileAttr::getMnemonic()))
33  if (!outputFile.isDirectory() &&
34  outputFile.getExcludeFromFilelist().getValue())
35  verbatim.erase();
36 }
37 
38 std::unique_ptr<mlir::Pass> circt::firrtl::createFinalizeIRPass() {
39  return std::make_unique<FinalizeIRPass>();
40 }
std::unique_ptr< mlir::Pass > createFinalizeIRPass()
Definition: FinalizeIR.cpp:38
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21