Skip to content

Commit

Permalink
merge some code.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96896 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Feb 23, 2010
1 parent be5ad7d commit 25b6f91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
36 changes: 20 additions & 16 deletions utils/TableGen/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2077,19 +2077,26 @@ void CodeGenDAGPatterns::ParseInstructions() {
SrcPattern = Pattern;
}

std::string Reason;
if (!SrcPattern->canPatternMatch(Reason, *this))
I->error("Instruction can never match: " + Reason);

Record *Instr = II->first;
TreePatternNode *DstPattern = TheInst.getResultPattern();
PatternsToMatch.
push_back(PatternToMatch(Instr->getValueAsListInit("Predicates"),
SrcPattern, DstPattern, TheInst.getImpResults(),
Instr->getValueAsInt("AddedComplexity")));
AddPatternToMatch(I,
PatternToMatch(Instr->getValueAsListInit("Predicates"),
SrcPattern, DstPattern,
TheInst.getImpResults(),
Instr->getValueAsInt("AddedComplexity")));
}
}

void CodeGenDAGPatterns::AddPatternToMatch(const TreePattern *Pattern,
const PatternToMatch &PTM) {
std::string Reason;
if (!PTM.getSrcPattern()->canPatternMatch(Reason, *this))
Pattern->error("Instruction can never match: " + Reason);

PatternsToMatch.push_back(PTM);
}



void CodeGenDAGPatterns::InferInstructionFlags() {
std::map<std::string, CodeGenInstruction> &InstrDescs =
Expand Down Expand Up @@ -2218,15 +2225,12 @@ void CodeGenDAGPatterns::ParsePatterns() {
TreePattern Temp(Result->getRecord(), DstPattern, false, *this);
Temp.InferAllTypes();

std::string Reason;
if (!Pattern->getTree(0)->canPatternMatch(Reason, *this))
Pattern->error("Pattern can never match: " + Reason);

PatternsToMatch.
push_back(PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"),
Pattern->getTree(0),
Temp.getOnlyTree(), InstImpResults,
Patterns[i]->getValueAsInt("AddedComplexity")));
AddPatternToMatch(Pattern,
PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"),
Pattern->getTree(0),
Temp.getOnlyTree(), InstImpResults,
Patterns[i]->getValueAsInt("AddedComplexity")));
}
}

Expand Down
1 change: 1 addition & 0 deletions utils/TableGen/CodeGenDAGPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class CodeGenDAGPatterns {
void InferInstructionFlags();
void GenerateVariants();

void AddPatternToMatch(const TreePattern *Pattern, const PatternToMatch &PTM);
void FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
std::map<std::string,
TreePatternNode*> &InstInputs,
Expand Down

0 comments on commit 25b6f91

Please sign in to comment.