CIRCT  20.0.0git
FooWires.cpp
Go to the documentation of this file.
1 //===- FooWires.cpp - Replace all wire names with foo ------*- C++ -*-===//
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 // Replace all wire names with foo.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #include "circt/Dialect/HW/HWOps.h"
15 #include "mlir/Pass/Pass.h"
16 
17 namespace circt {
18 namespace hw {
19 #define GEN_PASS_DEF_FOOWIRES
20 #include "circt/Dialect/HW/Passes.h.inc"
21 } // namespace hw
22 } // namespace circt
23 
24 using namespace circt;
25 using namespace hw;
26 
27 namespace {
28 // A test pass that simply replaces all wire names with foo_<n>
29 struct FooWiresPass : circt::hw::impl::FooWiresBase<FooWiresPass> {
30  void runOnOperation() override;
31 };
32 } // namespace
33 
34 void FooWiresPass::runOnOperation() {
35  size_t nWires = 0; // Counts the number of wires modified
36  getOperation().walk(
37  [&](hw::WireOp wire) { // Walk over every wire in the module
38  wire.setName("foo_" + std::to_string(nWires++)); // Rename said wire
39  });
40 }
41 
42 std::unique_ptr<mlir::Pass> circt::hw::createFooWiresPass() {
43  return std::make_unique<FooWiresPass>();
44 }
std::unique_ptr< mlir::Pass > createFooWiresPass()
Definition: FooWires.cpp:42
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: hw.py:1