CIRCT 20.0.0git
Loading...
Searching...
No Matches
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
15#include "mlir/Pass/Pass.h"
16
17namespace circt {
18namespace hw {
19#define GEN_PASS_DEF_FOOWIRES
20#include "circt/Dialect/HW/Passes.h.inc"
21} // namespace hw
22} // namespace circt
23
24using namespace circt;
25using namespace hw;
26
27namespace {
28// A test pass that simply replaces all wire names with foo_<n>
29struct FooWiresPass : circt::hw::impl::FooWiresBase<FooWiresPass> {
30 void runOnOperation() override;
31};
32} // namespace
33
34void 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
42std::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 hw.py:1