CIRCT 20.0.0git
Loading...
Searching...
No Matches
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 "mlir/Pass/Pass.h"
17
18namespace circt {
19namespace firrtl {
20#define GEN_PASS_DEF_FINALIZEIR
21#include "circt/Dialect/FIRRTL/Passes.h.inc"
22} // namespace firrtl
23} // namespace circt
24
25using namespace circt;
26namespace {
27struct FinalizeIRPass
28 : public circt::firrtl::impl::FinalizeIRBase<FinalizeIRPass> {
29 void runOnOperation() override;
30};
31} // namespace
32
33/// Finalize the IR after ExportVerilog and before the final IR is emitted.
34void FinalizeIRPass::runOnOperation() {
35 // Erase any sv.verbatim ops for sideband files.
36 for (auto verbatim : llvm::make_early_inc_range(
37 getOperation().getBodyRegion().getOps<sv::VerbatimOp>()))
38 if (auto outputFile = verbatim->getAttrOfType<hw::OutputFileAttr>(
39 hw::OutputFileAttr::getMnemonic()))
40 if (!outputFile.isDirectory() &&
41 outputFile.getExcludeFromFilelist().getValue())
42 verbatim.erase();
43}
44
45std::unique_ptr<mlir::Pass> circt::firrtl::createFinalizeIRPass() {
46 return std::make_unique<FinalizeIRPass>();
47}
std::unique_ptr< mlir::Pass > createFinalizeIRPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1
Definition sv.py:1