- if (!SubRegIndices.empty()) {
- // Emit getMatchingSuperRegClass.
- // We need to find the largest sub-class of A such that every register has
- // an Idx sub-register in B. Map (B, Idx) to a bit-vector of
- // super-register classes that map into B. Then compute the largest common
- // sub-class with A by taking advantage of the register class ordering,
- // like getCommonSubClass().
- OS << "const TargetRegisterClass *" << ClassName
- << "::getMatchingSuperRegClass(const TargetRegisterClass *A,"
- << " const TargetRegisterClass *B, unsigned Idx) const {\n"
- << " assert(A && B && \"Missing regclass\");\n"
- << " assert(Idx && Idx <= " << SubRegIndices.size()
- << " && \"Bad subreg\");\n"
- << " const uint16_t *SRI = B->getSuperRegIndices();\n"
- << " unsigned Offset = 0;\n"
- << " while (SRI[Offset] != Idx) {\n"
- << " if (!SRI[Offset])\n return 0;\n"
- << " ++Offset;\n }\n"
- << " const uint32_t *TV = B->getSubClassMask() + (Offset+1)*"
- << RCMaskWords << ";\n"
- << " const uint32_t *SC = A->getSubClassMask();\n"
- << " for (unsigned i = 0; i != " << RCMaskWords << "; ++i)\n"
- << " if (unsigned Common = TV[i] & SC[i])\n"
- << " return getRegClass(32*i + CountTrailingZeros_32(Common));\n"
- << " return 0;\n}\n\n";
- }
-