1
- // ===- HierPathBuilder .h - HierPathOp Builder Utility ---------------------===//
1
+ // ===- HierPathCache .h - HierPathOp Caching Utility -- ---------------------===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
//
9
- // The HierPathBuilder is a utility for creating hierarchical paths at some
10
- // location in a circuit. This exists to help with a common pattern where you
11
- // are running a transform and you need to build HierPathOps, but you don't know
12
- // when you are going to do it. You also don't want to create the same
13
- // HierPathOp multiple times. This utility will maintain a cache of existing
14
- // ops and only create new ones when necessary. Additionally, this creates the
15
- // ops in nice, predictable order. I.e., all the ops are inserted into the IR
16
- // in the order they are created, not in reverse order.
9
+ // The HierPathCache is a utility for creating hierarchical paths at a
10
+ // pre-defined location in a circuit. This exists to help with a common pattern
11
+ // where you are running a transform and you need to build HierPathOps, but you
12
+ // don't know when you are going to do it. You also don't want to create the
13
+ // same HierPathOp multiple times. This utility will maintain a cache of
14
+ // existing ops and only create new ones when necessary. Additionally, this
15
+ // creates the ops in nice, predictable order. I.e., all the ops are inserted
16
+ // into the IR in the order they are created, not in reverse order.
17
17
//
18
18
// ===----------------------------------------------------------------------===//
19
19
20
- #ifndef CIRCT_DIALECT_HW_HIERPATHBUILDER_H
21
- #define CIRCT_DIALECT_HW_HIERPATHBUILDER_H
20
+ #ifndef CIRCT_DIALECT_HW_HIERPATHCACHE_H
21
+ #define CIRCT_DIALECT_HW_HIERPATHCACHE_H
22
22
23
23
#include " circt/Dialect/HW/HWOps.h"
24
24
#include " circt/Support/Namespace.h"
27
27
namespace circt {
28
28
namespace hw {
29
29
30
- class HierPathBuilder {
30
+ class HierPathCache {
31
31
public:
32
- HierPathBuilder (Namespace *ns, OpBuilder::InsertPoint insertionPoint)
32
+ HierPathCache (Namespace *ns, OpBuilder::InsertPoint insertionPoint)
33
33
: ns(ns), pathInsertPoint(insertionPoint) {}
34
34
35
+ // / Get an existing `hw::HierPathOp` at the default location in the circuit.
35
36
HierPathOp getOrCreatePath (ArrayAttr pathArray, Location loc,
36
37
StringRef nameHint = " xmrPath" );
37
38
39
+ // / Get an existing `hw::HierPathOp` at a specific location in the circuit.
40
+ // / The insertion point will be updated to allow for this method to be used
41
+ // / repeatedly to create the ops predictably, one after the other.
38
42
HierPathOp getOrCreatePath (ArrayAttr pathArray, Location loc,
39
43
OpBuilder::InsertPoint &insertPoint,
40
44
StringRef nameHint = " xmrPath" );
@@ -54,4 +58,4 @@ class HierPathBuilder {
54
58
} // namespace hw
55
59
} // namespace circt
56
60
57
- #endif // CIRCT_DIALECT_HW_HIERPATHBUILDER_H
61
+ #endif // CIRCT_DIALECT_HW_HIERPATHCACHE_H
0 commit comments