diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-26 22:15:07 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-26 22:15:07 +0000 |
commit | 484f24d4a4dd89634067c93ad3efbd13cf634c23 (patch) | |
tree | 802464920e7014566904b6f45f2d451e5689ada8 | |
parent | 89b515b1412d0e7b1492aeebcd89a0845e01e382 (diff) | |
download | external_llvm-484f24d4a4dd89634067c93ad3efbd13cf634c23.zip external_llvm-484f24d4a4dd89634067c93ad3efbd13cf634c23.tar.gz external_llvm-484f24d4a4dd89634067c93ad3efbd13cf634c23.tar.bz2 |
Check that inherited subregisters all have a direct SubRegIndex.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104755 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/RegisterInfoEmitter.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 67f91ef..c99bbd9 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -186,7 +186,7 @@ static SubRegMap &inferSubRegIndices(Record *Reg, AllSubRegMap &ASRM) { if (SubRegs.size() != Indices.size()) throw "Register " + Reg->getName() + " SubRegIndices doesn't match SubRegs"; - // First insert the direct subregs. + // First insert the direct subregs and make sure they are fully indexed. for (unsigned i = 0, e = SubRegs.size(); i != e; ++i) { if (!SRM.insert(std::make_pair(Indices[i], SubRegs[i])).second) throw "SubRegIndex " + Indices[i]->getName() @@ -194,11 +194,18 @@ static SubRegMap &inferSubRegIndices(Record *Reg, AllSubRegMap &ASRM) { inferSubRegIndices(SubRegs[i], ASRM); } + // Keep track of inherited subregs and how they can be reached. + // Register -> (SubRegIndex, SubRegIndex) + typedef std::map<Record*, std::pair<Record*,Record*>, LessRecord> OrphanMap; + OrphanMap Orphans; + // Clone inherited subregs. Here the order is important - earlier subregs take // precedence. for (unsigned i = 0, e = SubRegs.size(); i != e; ++i) { SubRegMap &M = ASRM[SubRegs[i]]; - SRM.insert(M.begin(), M.end()); + for (SubRegMap::iterator si = M.begin(), se = M.end(); si != se; ++si) + if (!SRM.insert(*si).second) + Orphans[si->second] = std::make_pair(Indices[i], si->first); } // Finally process the composites. @@ -228,6 +235,22 @@ static SubRegMap &inferSubRegIndices(Record *Reg, AllSubRegMap &ASRM) { // Insert composite index. Allow overriding inherited indices etc. SRM[BaseIdxInit->getDef()] = R2; + + // R2 is now directly addressable, no longer an orphan. + Orphans.erase(R2); + } + + // Now, Orphans contains the inherited subregisters without a direct index. + if (!Orphans.empty()) { + errs() << "Error: Register " << getQualifiedName(Reg) + << " inherited subregisters without an index:\n"; + for (OrphanMap::iterator i = Orphans.begin(), e = Orphans.end(); i != e; + ++i) { + errs() << " " << getQualifiedName(i->first) + << " = " << i->second.first->getName() + << ", " << i->second.second->getName() << "\n"; + } + abort(); } return SRM; } |