[Mlir-commits] [mlir] [mlir][spirv][nfc] Refactor member decorations in StructType (PR #150218)
Jakub Kuderski
llvmlistbot at llvm.org
Wed Jul 23 06:44:02 PDT 2025
================
@@ -301,30 +301,35 @@ class StructType
static constexpr StringLiteral name = "spirv.struct";
- // Type for specifying the decoration(s) on struct members
+ // Type for specifying the decoration(s) on struct members.
+ // If `decorationValue` is UnitAttr then decoration has no
+ // value.
struct MemberDecorationInfo {
- uint32_t memberIndex : 31;
- uint32_t hasValue : 1;
+ uint32_t memberIndex;
Decoration decoration;
- uint32_t decorationValue;
+ Attribute decorationValue;
- MemberDecorationInfo(uint32_t index, uint32_t hasValue,
- Decoration decoration, uint32_t decorationValue)
- : memberIndex(index), hasValue(hasValue), decoration(decoration),
+ MemberDecorationInfo(uint32_t index, Decoration decoration,
+ Attribute decorationValue)
+ : memberIndex(index), decoration(decoration),
decorationValue(decorationValue) {}
- bool operator==(const MemberDecorationInfo &other) const {
- return (this->memberIndex == other.memberIndex) &&
- (this->decoration == other.decoration) &&
- (this->decorationValue == other.decorationValue);
+ friend bool operator==(const MemberDecorationInfo &lhs,
+ const MemberDecorationInfo &rhs) {
+ return (lhs.memberIndex == rhs.memberIndex) &&
+ (lhs.decoration == rhs.decoration) &&
+ (lhs.decorationValue == rhs.decorationValue);
}
- bool operator<(const MemberDecorationInfo &other) const {
- return this->memberIndex < other.memberIndex ||
- (this->memberIndex == other.memberIndex &&
- static_cast<uint32_t>(this->decoration) <
- static_cast<uint32_t>(other.decoration));
+ friend bool operator<(const MemberDecorationInfo &lhs,
+ const MemberDecorationInfo &rhs) {
+ return lhs.memberIndex < rhs.memberIndex ||
+ (lhs.memberIndex == rhs.memberIndex &&
+ llvm::to_underlying(lhs.decoration) <
+ llvm::to_underlying(rhs.decoration));
----------------
kuhar wrote:
we can use `std::tie` here to simplify this
https://github.com/llvm/llvm-project/pull/150218
More information about the Mlir-commits
mailing list