Teach TableGen to automatically generate missing SubRegIndex instances.

The RegisterInfo.td file should only specify the indexes that sources need to
refer to. The rest is inferred.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2011-05-07 21:22:39 +00:00
parent aec038fa84
commit 123cab9480
3 changed files with 47 additions and 22 deletions
+10 -3
View File
@@ -98,14 +98,14 @@ std::string llvm::getEnumName(MVT::SimpleValueType T) {
/// namespace qualifier if the record contains one.
///
std::string llvm::getQualifiedName(const Record *R) {
std::string Namespace = R->getValueAsString("Namespace");
std::string Namespace;
if (R->getValue("Namespace"))
Namespace = R->getValueAsString("Namespace");
if (Namespace.empty()) return R->getName();
return Namespace + "::" + R->getName();
}
/// getTarget - Return the current instance of the Target class.
///
CodeGenTarget::CodeGenTarget(RecordKeeper &records) : Records(records) {
@@ -182,6 +182,13 @@ void CodeGenTarget::ReadSubRegIndices() const {
std::sort(SubRegIndices.begin(), SubRegIndices.end(), LessRecord());
}
Record *CodeGenTarget::createSubRegIndex(const std::string &Name) {
Record *R = new Record(Name, SMLoc(), Records);
Records.addDef(R);
SubRegIndices.push_back(R);
return R;
}
void CodeGenTarget::ReadRegisterClasses() const {
std::vector<Record*> RegClasses =
Records.getAllDerivedDefinitions("RegisterClass");