diff options
Diffstat (limited to 'utils/TableGen/RegisterInfoEmitter.cpp')
-rw-r--r-- | utils/TableGen/RegisterInfoEmitter.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 3c7b44a..bf0721e 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -66,6 +66,7 @@ void RegisterInfoEmitter::runHeader(raw_ostream &OS) { << " virtual bool needsStackRealignment(const MachineFunction &) const\n" << " { return false; }\n" << " unsigned getSubReg(unsigned RegNo, unsigned Index) const;\n" + << " unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;\n" << "};\n\n"; const std::vector<CodeGenRegisterClass> &RegisterClasses = @@ -831,6 +832,23 @@ void RegisterInfoEmitter::run(raw_ostream &OS) { OS << " };\n"; OS << " return 0;\n"; OS << "}\n\n"; + + OS << "unsigned " << ClassName + << "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n" + << " switch (RegNo) {\n" + << " default:\n return 0;\n"; + for (std::map<Record*, std::vector<std::pair<int, Record*> > >::iterator + I = SubRegVectors.begin(), E = SubRegVectors.end(); I != E; ++I) { + OS << " case " << getQualifiedName(I->first) << ":\n"; + for (unsigned i = 0, e = I->second.size(); i != e; ++i) + OS << " if (SubRegNo == " + << getQualifiedName((I->second)[i].second) + << ") return " << (I->second)[i].first << ";\n"; + OS << " return 0;\n"; + } + OS << " };\n"; + OS << " return 0;\n"; + OS << "}\n\n"; // Emit the constructor of the class... OS << ClassName << "::" << ClassName |