CIRCT 22.0.0git
Loading...
Searching...
No Matches
LayerSet.h
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
9#ifndef CIRCT_DIALECT_FIRRTL_LAYERSET_H
10#define CIRCT_DIALECT_FIRRTL_LAYERSET_H
11
12#include "mlir/IR/BuiltinAttributes.h"
13
14namespace circt {
15namespace firrtl {
16
17/// Compares two `SymbolRefAttr` lexicographically, returning true if LHS should
18/// be ordered before RHS.
20 bool operator()(SymbolRefAttr lhs, SymbolRefAttr rhs) const {
21 auto cmp = lhs.getRootReference().compare(rhs.getRootReference());
22 if (cmp == -1)
23 return true;
24 if (cmp == 1)
25 return false;
26 auto lhsNested = lhs.getNestedReferences();
27 auto rhsNested = rhs.getNestedReferences();
28 auto lhsNestedSize = lhsNested.size();
29 auto rhsNestedSize = rhsNested.size();
30 auto e = std::min(lhsNestedSize, rhsNestedSize);
31 for (unsigned i = 0; i < e; ++i) {
32 auto cmp = lhsNested[i].getAttr().compare(rhsNested[i].getAttr());
33 if (cmp == -1)
34 return true;
35 if (cmp == 1)
36 return false;
37 }
38 return lhsNestedSize < rhsNestedSize;
39 }
40};
41
43
44} // namespace firrtl
45} // namespace circt
46
47#endif // CIRCT_DIALECT_FIRRTL_LAYERSET_H
SmallSet< SymbolRefAttr, 4, LayerSetCompare > LayerSet
Definition LayerSet.h:42
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Compares two SymbolRefAttr lexicographically, returning true if LHS should be ordered before RHS.
Definition LayerSet.h:19
bool operator()(SymbolRefAttr lhs, SymbolRefAttr rhs) const
Definition LayerSet.h:20