Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UniqueValidateOpsPass.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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
12
13namespace circt {
14namespace rtg {
15#define GEN_PASS_DEF_UNIQUEVALIDATEOPSPASS
16#include "circt/Dialect/RTG/Transforms/RTGPasses.h.inc"
17} // namespace rtg
18} // namespace circt
19
20using namespace mlir;
21using namespace circt;
22using namespace circt::rtg;
23
24//===----------------------------------------------------------------------===//
25// Unique Validate Ops Pass
26//===----------------------------------------------------------------------===//
27
28namespace {
29struct UniqueValidateOpsPass
30 : public rtg::impl::UniqueValidateOpsPassBase<UniqueValidateOpsPass> {
31 using Base::Base;
32
33 void runOnOperation() override;
34};
35} // namespace
36
37void UniqueValidateOpsPass::runOnOperation() {
38 Namespace names;
39 SmallVector<ValidateOp> validateOps;
40
41 // Collect all the already fixed names in a first iteration.
42 getOperation()->walk([&](ValidateOp op) {
43 if (op.getId().has_value())
44 names.add(op.getId().value());
45 else
46 validateOps.push_back(op);
47 });
48
49 for (auto op : validateOps) {
50 auto newName = names.newName("validation_id");
51 op.setId(newName);
52 }
53}
A namespace that is used to store existing names and generate new names in some scope within the IR.
Definition Namespace.h:30
void add(mlir::ModuleOp module)
Definition Namespace.h:48
StringRef newName(const Twine &name)
Return a unique name, derived from the input name, and add the new name to the internal namespace.
Definition Namespace.h:87
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition rtg.py:1