1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Defer checking for registers in the MC AsmMatcher until the after user-defined match classes have been checked. This allows the creation of MatchClass's that are supersets of a register class.

llvm-svn: 160327
This commit is contained in:
Owen Anderson 2012-07-16 23:20:09 +00:00
parent 97c381ea93
commit cdcce931f2

View File

@ -1829,22 +1829,6 @@ static void emitValidateOperandClass(AsmMatcherInfo &Info,
<< " MCTargetAsmParser::Match_Success :\n"
<< " MCTargetAsmParser::Match_InvalidOperand;\n\n";
// Check for register operands, including sub-classes.
OS << " if (Operand.isReg()) {\n";
OS << " MatchClassKind OpKind;\n";
OS << " switch (Operand.getReg()) {\n";
OS << " default: OpKind = InvalidMatchClass; break;\n";
for (std::map<Record*, ClassInfo*>::iterator
it = Info.RegisterClasses.begin(), ie = Info.RegisterClasses.end();
it != ie; ++it)
OS << " case " << Info.Target.getName() << "::"
<< it->first->getName() << ": OpKind = " << it->second->Name
<< "; break;\n";
OS << " }\n";
OS << " return isSubclass(OpKind, Kind) ? "
<< "MCTargetAsmParser::Match_Success :\n "
<< " MCTargetAsmParser::Match_InvalidOperand;\n }\n\n";
// Check the user classes. We don't care what order since we're only
// actually matching against one of them.
for (std::vector<ClassInfo*>::iterator it = Info.Classes.begin(),
@ -1864,6 +1848,22 @@ static void emitValidateOperandClass(AsmMatcherInfo &Info,
OS << " }\n\n";
}
// Check for register operands, including sub-classes.
OS << " if (Operand.isReg()) {\n";
OS << " MatchClassKind OpKind;\n";
OS << " switch (Operand.getReg()) {\n";
OS << " default: OpKind = InvalidMatchClass; break;\n";
for (std::map<Record*, ClassInfo*>::iterator
it = Info.RegisterClasses.begin(), ie = Info.RegisterClasses.end();
it != ie; ++it)
OS << " case " << Info.Target.getName() << "::"
<< it->first->getName() << ": OpKind = " << it->second->Name
<< "; break;\n";
OS << " }\n";
OS << " return isSubclass(OpKind, Kind) ? "
<< "MCTargetAsmParser::Match_Success :\n "
<< " MCTargetAsmParser::Match_InvalidOperand;\n }\n\n";
// Generic fallthrough match failure case for operands that don't have
// specialized diagnostic types.
OS << " return MCTargetAsmParser::Match_InvalidOperand;\n";