diff --git a/llvm/include/llvm/Target/TargetRegisterInfo.h b/llvm/include/llvm/Target/TargetRegisterInfo.h index 7e1320f87a44..6b460547e419 100644 --- a/llvm/include/llvm/Target/TargetRegisterInfo.h +++ b/llvm/include/llvm/Target/TargetRegisterInfo.h @@ -275,8 +275,8 @@ public: /// class TargetRegisterInfo { protected: - unsigned* SubregHash; - unsigned SubregHashSize; + const unsigned* SubregHash; + const unsigned SubregHashSize; public: typedef const TargetRegisterClass * const * regclass_iterator; private: @@ -291,7 +291,9 @@ protected: regclass_iterator RegClassBegin, regclass_iterator RegClassEnd, int CallFrameSetupOpcode = -1, - int CallFrameDestroyOpcode = -1); + int CallFrameDestroyOpcode = -1, + const unsigned* subregs = 0, + const unsigned subregsize = 0); virtual ~TargetRegisterInfo(); public: diff --git a/llvm/lib/Target/TargetRegisterInfo.cpp b/llvm/lib/Target/TargetRegisterInfo.cpp index 3f44a0cb5a31..37745ec95d40 100644 --- a/llvm/lib/Target/TargetRegisterInfo.cpp +++ b/llvm/lib/Target/TargetRegisterInfo.cpp @@ -22,8 +22,10 @@ using namespace llvm; TargetRegisterInfo::TargetRegisterInfo(const TargetRegisterDesc *D, unsigned NR, regclass_iterator RCB, regclass_iterator RCE, - int CFSO, int CFDO) - : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) { + int CFSO, int CFDO, + const unsigned* subregs, const unsigned subregsize) + : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE), + SubregHash(subregs), SubregHashSize(subregsize) { assert(NumRegs < FirstVirtualRegister && "Target has too many physical registers!"); diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp index 366447403242..0c5e8442c2aa 100644 --- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp +++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp @@ -501,29 +501,34 @@ void RegisterInfoEmitter::run(std::ostream &OS) { if (SubregHashTableSize) { std::string Namespace = Regs[0].TheDef->getValueAsString("Namespace"); - OS << "\n\n unsigned SubregHashTable[] = {"; + OS << "\n\n const unsigned SubregHashTable[] = { "; for (unsigned i = 0; i < SubregHashTableSize - 1; ++i) { + if (i != 0) + // Insert spaces for nice formatting. + OS << " "; + if (SubregHashTable[2*i] != ~0U) { OS << getQualifiedName(Regs[SubregHashTable[2*i]].TheDef) << ", " - << getQualifiedName(Regs[SubregHashTable[2*i+1]].TheDef) << ", "; + << getQualifiedName(Regs[SubregHashTable[2*i+1]].TheDef) << ", \n"; } else { - OS << Namespace << "::NoRegister, " << Namespace << "::NoRegister, "; + OS << Namespace << "::NoRegister, " << Namespace << "::NoRegister, \n"; } } unsigned Idx = SubregHashTableSize*2-2; if (SubregHashTable[Idx] != ~0U) { - OS << getQualifiedName(Regs[SubregHashTable[Idx]].TheDef) << ", " - << getQualifiedName(Regs[SubregHashTable[Idx+1]].TheDef) << "};\n"; + OS << " " + << getQualifiedName(Regs[SubregHashTable[Idx]].TheDef) << ", " + << getQualifiedName(Regs[SubregHashTable[Idx+1]].TheDef) << " };\n"; } else { - OS << Namespace << "::NoRegister, " << Namespace << "::NoRegister};\n"; + OS << Namespace << "::NoRegister, " << Namespace << "::NoRegister };\n"; } - OS << " unsigned SubregHashTableSize = " + OS << " const unsigned SubregHashTableSize = " << SubregHashTableSize << ";\n"; } else { - OS << "\n\n unsigned SubregHashTable[] = { ~0U, ~0U };\n" - << " unsigned SubregHashTableSize = 1;\n"; + OS << "\n\n const unsigned SubregHashTable[] = { ~0U, ~0U };\n" + << " const unsigned SubregHashTableSize = 1;\n"; } delete [] SubregHashTable; @@ -672,9 +677,8 @@ void RegisterInfoEmitter::run(std::ostream &OS) { << "(int CallFrameSetupOpcode, int CallFrameDestroyOpcode)\n" << " : TargetRegisterInfo(RegisterDescriptors, " << Registers.size()+1 << ", RegisterClasses, RegisterClasses+" << RegisterClasses.size() <<",\n " - << " CallFrameSetupOpcode, CallFrameDestroyOpcode) {\n" - << " this->SubregHash = SubregHashTable;\n" - << " this->SubregHashSize = SubregHashTableSize;\n" + << " CallFrameSetupOpcode, CallFrameDestroyOpcode,\n" + << " SubregHashTable, SubregHashTableSize) {\n" << "}\n\n"; // Collect all information about dwarf register numbers