CIRCT
24.0.0git
Loading...
Searching...
No Matches
include
circt
Dialect
FIRRTL
Namespace.h
Go to the documentation of this file.
1
//===- Namespace.h - A symbol table for FIRRTL ops --------------*- 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
//
9
// This file implements the FIRRTL CircuitNamespace, a symbol table for
10
// `firrtl.circuit` operations that allows for name collision resolution.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef CIRCT_DIALECT_FIRRTL_NAMESPACE_H
15
#define CIRCT_DIALECT_FIRRTL_NAMESPACE_H
16
17
#include "
circt/Dialect/FIRRTL/FIRRTLOps.h
"
18
#include "
circt/Support/Namespace.h
"
19
20
namespace
circt
{
21
namespace
firrtl
{
22
23
/// The namespace of a `CircuitOp`, generally inhabited by modules.
24
struct
CircuitNamespace
:
public
Namespace
{
25
CircuitNamespace
() {}
26
CircuitNamespace
(CircuitOp circuit) {
add
(circuit); }
27
28
/// Populate the namespace from a circuit operation. This namespace will be
29
/// composed of any operation in the first level of the circuit that contains
30
/// a symbol.
31
void
add
(CircuitOp circuit) {
32
for
(
auto
&op : *circuit.getBodyBlock())
33
if
(
auto
symbol = mlir::dyn_cast<mlir::SymbolOpInterface>(&op))
34
nextIndex
.insert({symbol.getName(), 0});
35
}
36
};
37
38
}
// namespace firrtl
39
}
// namespace circt
40
41
#endif
// CIRCT_DIALECT_FIRRTL_NAMESPACE_H
FIRRTLOps.h
Namespace.h
circt::Namespace::nextIndex
llvm::StringMap< size_t > nextIndex
Definition
Namespace.h:160
circt::Namespace::Namespace
Namespace()
Definition
Namespace.h:32
circt::firrtl
Definition
FIRRTLInstanceInfo.h:24
circt
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition
DebugAnalysis.h:21
circt::firrtl::CircuitNamespace::add
void add(CircuitOp circuit)
Populate the namespace from a circuit operation.
Definition
Namespace.h:31
circt::firrtl::CircuitNamespace::CircuitNamespace
CircuitNamespace(CircuitOp circuit)
Definition
Namespace.h:26
circt::firrtl::CircuitNamespace::CircuitNamespace
CircuitNamespace()
Definition
Namespace.h:25
Generated on
for CIRCT by
1.15.0