Make the subregister hashtable output more readable by wrapping the lines,

and mark it const along with the associated changes to TargetRegisterInfo.

llvm-svn: 52966
This commit is contained in:
Owen Anderson 2008-07-01 17:34:38 +00:00
parent ab54e51b38
commit 3684013910
3 changed files with 25 additions and 17 deletions

View File

@ -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:

View File

@ -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!");

View File

@ -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