Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 9c7ba76

Browse files
authored
[MLIR][TBLGen] Added compound assignment operator for any BitEnum (#160840)
## Details: - Added missing compound assignment operators `|=`, `&=`, `^=` to `mlir-tblgen` - Replaced the arithmetic operators with added assignment operators for `BitEnum` in the transformations - Updated related documentation ## Tickets: - Closes llvm/llvm-project#158098
1 parent a7fe757 commit 9c7ba76

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

mlir/tools/mlir-tblgen/EnumsGen.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ getAllBitsUnsetCase(llvm::ArrayRef<EnumCase> cases) {
364364
// inline constexpr <enum-type> operator|(<enum-type> a, <enum-type> b);
365365
// inline constexpr <enum-type> operator&(<enum-type> a, <enum-type> b);
366366
// inline constexpr <enum-type> operator^(<enum-type> a, <enum-type> b);
367+
// inline constexpr <enum-type> &operator|=(<enum-type> &a, <enum-type> b);
368+
// inline constexpr <enum-type> &operator&=(<enum-type> &a, <enum-type> b);
369+
// inline constexpr <enum-type> &operator^=(<enum-type> &a, <enum-type> b);
367370
// inline constexpr <enum-type> operator~(<enum-type> bits);
368371
// inline constexpr bool bitEnumContainsAll(<enum-type> bits, <enum-type> bit);
369372
// inline constexpr bool bitEnumContainsAny(<enum-type> bits, <enum-type> bit);
@@ -385,6 +388,15 @@ inline constexpr {0} operator&({0} a, {0} b) {{
385388
inline constexpr {0} operator^({0} a, {0} b) {{
386389
return static_cast<{0}>(static_cast<{1}>(a) ^ static_cast<{1}>(b));
387390
}
391+
inline constexpr {0} &operator|=({0} &a, {0} b) {{
392+
return a = a | b;
393+
}
394+
inline constexpr {0} &operator&=({0} &a, {0} b) {{
395+
return a = a & b;
396+
}
397+
inline constexpr {0} &operator^=({0} &a, {0} b) {{
398+
return a = a ^ b;
399+
}
388400
inline constexpr {0} operator~({0} bits) {{
389401
// Ensure only bits that can be present in the enum are set
390402
return static_cast<{0}>(~static_cast<{1}>(bits) & static_cast<{1}>({2}u));

0 commit comments

Comments
 (0)