[llvm] [TableGen] Complete the support for artificial registers (PR #183371)
Ivan Kosarev via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 08:53:55 PDT 2026
================
@@ -844,7 +844,30 @@ unsigned CodeGenRegisterClass::getWeight(const CodeGenRegBank &RegBank) const {
bool CodeGenRegisterClass::Key::operator<(
const CodeGenRegisterClass::Key &B) const {
assert(Members && B.Members);
- return std::tie(*Members, RSI) < std::tie(*B.Members, B.RSI);
+ if (!IgnoreArtificialMembers)
+ return std::tie(*Members, RSI) < std::tie(*B.Members, B.RSI);
+
+ // Do the same lexicographical comparison, but ignoring
+ // artificial registers.
+ auto IA = Members->begin(), EA = Members->end();
+ auto IB = B.Members->begin(), EB = B.Members->end();
+ while (IA != EA && IB != EB) {
+ if ((*IA)->Artificial) {
+ ++IA;
+ continue;
+ }
+ if ((*IB)->Artificial) {
+ ++IB;
+ continue;
+ }
+ if (*IA != *IB)
+ return *IA < *IB;
+ ++IA;
+ ++IB;
+ }
+ if (IA == EA && IB == EB)
----------------
kosarev wrote:
Oh of course, let me fix this. Sigh, I did try to use `std::lexicographical_compare()` originally, but it doesn't seem to work with our filter ranges.
https://github.com/llvm/llvm-project/pull/183371
More information about the llvm-commits
mailing list