================ @@ -1720,21 +1720,29 @@ void SVEEmitter::createBuiltinZAState(raw_ostream &OS) { for (auto *R : RV) createIntrinsic(R, Defs); - std::map<bool, std::set<std::string>> DefsZAState; - - uint64_t IsSharedZAFlag = getEnumValueForFlag("IsSharedZA"); + std::map<std::string, std::set<std::string>> IntrinsicsPerState; for (auto &Def : Defs) { - bool HasZAState = Def->isFlagSet(IsSharedZAFlag); - DefsZAState[HasZAState].insert(Def->getMangledName()); + std::string Key; + auto AddToKey = [&Key](std::string S) -> void { + Key = Key.empty() ? S : (Key + " | " + S); + }; + + if (Def->isFlagSet(getEnumValueForFlag("IsInZA"))) + AddToKey("ArmInZA"); + else if (Def->isFlagSet(getEnumValueForFlag("IsOutZA"))) + AddToKey("ArmOutZA"); + else if (Def->isFlagSet(getEnumValueForFlag("IsInOutZA"))) + AddToKey("ArmInOutZA"); + + if (!Key.empty()) + IntrinsicsPerState[Key].insert(Def->getMangledName()); ---------------- MDevereau wrote:
Am I reading this correctly? `std::string Key;` will create an empty string `Key` at the start of each for loop iteration. The only way to add to this string is via 3 `else if`'s which means the `Key.empty()` check in the lambda will always be true and the else case will never fire. Therefore you can just replace everything in this for loop with ```c++ if (Def->isFlagSet(getEnumValueForFlag("IsInZA"))) IntrinsicsPerState["ArmInZA"].insert(Def->getMangledName()); else if (Def->isFlagSet(getEnumValueForFlag("IsOutZA"))) IntrinsicsPerState["ArmOutZA"].insert(Def->getMangledName()); else if (Def->isFlagSet(getEnumValueForFlag("IsInOutZA"))) IntrinsicsPerState["ArmInOutZA"].insert(Def->getMangledName()); ``` I'm assuming this is meant to be used to output or checks in `clang/include/clang/Basic/arm_sme_builtins_za_state.inc` like `return ArmInZA | ArmOutZA`? These aren't being emitted for me when I build this so I don't think this is doing what it was made for correctly. https://github.com/llvm/llvm-project/pull/78258 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits