Support "Methods" in register classes in CodgeGenRegisterClass

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15965 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-08-21 19:21:21 +00:00
parent 12585baf1a
commit 5767775505
3 changed files with 10 additions and 11 deletions

View File

@ -26,7 +26,6 @@ namespace llvm {
Record *TheDef;
const std::string &getName() const;
unsigned DeclaredSpillSize, DeclaredSpillAlignment;
CodeGenRegister(Record *R);
};
@ -36,6 +35,7 @@ namespace llvm {
std::vector<Record*> Elements;
unsigned SpillSize;
unsigned SpillAlignment;
std::string MethodDefinitions;
const std::string &getName() const;

View File

@ -135,6 +135,12 @@ CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) {
SpillSize = R->getValueAsInt("Size");
SpillAlignment = R->getValueAsInt("Alignment");
if (CodeInit *CI = dynamic_cast<CodeInit*>(R->getValueInit("Methods")))
MethodDefinitions = CI->getValue();
else
throw "Expected 'code' fragment for 'Methods' value in register class '"+
getName() + "'!";
ListInit *RegList = R->getValueAsListInit("MemberList");
for (unsigned i = 0, e = RegList->getSize(); i != e; ++i) {
DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));

View File

@ -121,16 +121,9 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
OS << " struct " << Name << "Class : public TargetRegisterClass {\n"
<< " " << Name << "Class() : TargetRegisterClass("
<< RC.SpillSize/8 << ", " << RC.SpillAlignment << ", " << Name << ", "
<< Name << " + " << RC.Elements.size() << ") {}\n";
if (CodeInit *CI =
dynamic_cast<CodeInit*>(RC.TheDef->getValueInit("Methods")))
OS << CI->getValue();
else
throw "Expected 'code' fragment for 'Methods' value in register class '"+
RC.getName() + "'!";
OS << " } " << Name << "Instance;\n\n";
<< Name << " + " << RC.Elements.size() << ") {}\n"
<< RC.MethodDefinitions
<< " } " << Name << "Instance;\n\n";
}
OS << " const TargetRegisterClass* const RegisterClasses[] = {\n";