diff --git a/llvm/include/llvm/Target/TargetRegisterInfo.h b/llvm/include/llvm/Target/TargetRegisterInfo.h index 7eb506c22696..77705449a2fb 100644 --- a/llvm/include/llvm/Target/TargetRegisterInfo.h +++ b/llvm/include/llvm/Target/TargetRegisterInfo.h @@ -70,6 +70,9 @@ public: const uint8_t AllocationPriority; /// Whether the class supports two (or more) disjunct subregister indices. const bool HasDisjunctSubRegs; + /// Whether a combination of subregisters can cover every register in the + /// class. See also the CoveredBySubRegs description in Target.td. + const bool CoveredBySubRegs; const sc_iterator SuperClasses; ArrayRef (*OrderFunc)(const MachineFunction&); diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp index 114ee18a5f3a..626144fbe855 100644 --- a/llvm/utils/TableGen/CodeGenRegisters.cpp +++ b/llvm/utils/TableGen/CodeGenRegisters.cpp @@ -1829,11 +1829,14 @@ void CodeGenRegBank::computeDerivedInfo() { computeRegUnitLaneMasks(); - // Compute register class HasDisjunctSubRegs flag. + // Compute register class HasDisjunctSubRegs/CoveredBySubRegs flag. for (CodeGenRegisterClass &RC : RegClasses) { RC.HasDisjunctSubRegs = false; - for (const CodeGenRegister *Reg : RC.getMembers()) + RC.CoveredBySubRegs = true; + for (const CodeGenRegister *Reg : RC.getMembers()) { RC.HasDisjunctSubRegs |= Reg->HasDisjunctSubRegs; + RC.CoveredBySubRegs &= Reg->CoveredBySubRegs; + } } // Get the weight of each set. diff --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h index 83b5996b45b5..b8d47aa4ff82 100644 --- a/llvm/utils/TableGen/CodeGenRegisters.h +++ b/llvm/utils/TableGen/CodeGenRegisters.h @@ -310,6 +310,7 @@ namespace llvm { unsigned LaneMask; /// True if there are at least 2 subregisters which do not interfere. bool HasDisjunctSubRegs; + bool CoveredBySubRegs; // Return the Record that defined this class, or NULL if the class was // created by TableGen. diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp index 4ec3e7de0f72..3316da6185cf 100644 --- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp +++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp @@ -1311,7 +1311,9 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target, << format("0x%08x,\n ", RC.LaneMask) << (unsigned)RC.AllocationPriority << ",\n " << (RC.HasDisjunctSubRegs?"true":"false") - << ", /* HasDisjunctSubRegs */\n "; + << ", /* HasDisjunctSubRegs */\n " + << (RC.CoveredBySubRegs?"true":"false") + << ", /* CoveredBySubRegs */\n "; if (RC.getSuperClasses().empty()) OS << "NullRegClasses,\n "; else