Skip to content

Commit 4b8733c

Browse files
committed
move datastucts out of namespace scope
1 parent ce1e6a2 commit 4b8733c

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

mlir/lib/Dialect/QCO/Transforms/QuaternionMergeRotationGates.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020

2121
namespace mlir::qco {
2222

23-
struct Quaternion {
24-
mlir::Value w;
25-
mlir::Value x;
26-
mlir::Value y;
27-
mlir::Value z;
28-
};
29-
30-
static const std::unordered_set<std::string> MERGEABLE_GATES = {"u", "rx", "ry",
31-
"rz"};
3223

3324
/**
3425
* @brief This pattern attempts to merge consecutive rotation gates.
@@ -38,6 +29,20 @@ struct MergeRotationGatesPattern final
3829
explicit MergeRotationGatesPattern(mlir::MLIRContext* context)
3930
: OpInterfaceRewritePattern(context) {}
4031

32+
struct Quaternion {
33+
mlir::Value w;
34+
mlir::Value x;
35+
mlir::Value y;
36+
mlir::Value z;
37+
};
38+
39+
static constexpr std::array<std::string_view, 4> MERGEABLE_GATES = {
40+
"u", "rx", "ry", "rz"};
41+
42+
static bool isMergeable(std::string_view name) {
43+
return std::ranges::find(MERGEABLE_GATES, name) != MERGEABLE_GATES.end();
44+
}
45+
4146
/**
4247
* @brief Checks if two gates can and should be merged with quaternions.
4348
*
@@ -54,7 +59,7 @@ struct MergeRotationGatesPattern final
5459
const auto aName = a.getName().stripDialect().str();
5560
const auto bName = b.getName().stripDialect().str();
5661

57-
if (!(MERGEABLE_GATES.contains(aName) && MERGEABLE_GATES.contains(bName))) {
62+
if (!(isMergeable(aName) && isMergeable(bName))) {
5863
return false;
5964
}
6065
return (aName != bName) || (aName == "u" && bName == "u");

0 commit comments

Comments
 (0)