Emit a redundant check for immediates at root context, e.g. (imm 0).

This allows formation of OpcodeSwitch for top level patterns, in
particular on X86.  This saves about 1K of data space in the x86
table and makes the dispatch much more efficient.

llvm-svn: 97440
This commit is contained in:
Chris Lattner 2010-03-01 07:27:07 +00:00
parent 053a28a397
commit a44697c394
2 changed files with 10 additions and 2 deletions

View File

@ -55,7 +55,6 @@ public:
CheckPredicate, // Fail if node predicate fails.
CheckOpcode, // Fail if not opcode.
SwitchOpcode, // Dispatch based on opcode.
CheckMultiOpcode, // Fail if not in opcode list.
CheckType, // Fail if not correct type.
CheckChildType, // Fail if child has wrong type.
CheckInteger, // Fail if wrong val.

View File

@ -205,8 +205,17 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
AddMatcher(new CheckPredicateMatcher(N->getPredicateFns()[i]));
// Direct match against an integer constant.
if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue()))
if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue())) {
// If this is the root of the dag we're matching, we emit a redundant opcode
// check to ensure that this gets folded into the normal top-level
// OpcodeSwitch.
if (N == Pattern.getSrcPattern()) {
const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed("imm"));
AddMatcher(new CheckOpcodeMatcher(NI));
}
return AddMatcher(new CheckIntegerMatcher(II->getValue()));
}
DefInit *DI = dynamic_cast<DefInit*>(N->getLeafValue());
if (DI == 0) {