[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Sep 15 14:57:47 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.30 -> 1.31
DAGISelEmitter.h updated: 1.18 -> 1.19
---
Log message:
put instructions into a map instead of a vector for quick lookup
---
Diffs of the changes: (+18 -7)
DAGISelEmitter.cpp | 18 ++++++++++++------
DAGISelEmitter.h | 7 ++++++-
2 files changed, 18 insertions(+), 7 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.30 llvm/utils/TableGen/DAGISelEmitter.cpp:1.31
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.30 Thu Sep 15 16:51:12 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 15 16:57:35 2005
@@ -326,6 +326,10 @@
return MadeChange;
} else {
assert(getOperator()->isSubClassOf("Instruction") && "Unknown node type!");
+
+ const DAGInstruction &Inst =
+ TP.getDAGISelEmitter().getInstruction(getOperator());
+
// TODO: type inference for instructions.
return false;
}
@@ -874,13 +878,15 @@
new TreePatternNode(I->getRecord(), ResultNodeOperands);
DEBUG(I->dump());
- Instructions.push_back(DAGInstruction(I, ResultTypes, OperandTypes,
- ResultPattern));
+ Instructions.insert(std::make_pair(I->getRecord(),
+ DAGInstruction(I, ResultTypes,
+ OperandTypes, ResultPattern)));
}
// If we can, convert the instructions to be patterns that are matched!
- for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
- TreePattern *I = Instructions[i].getPattern();
+ for (std::map<Record*, DAGInstruction>::iterator II = Instructions.begin(),
+ E = Instructions.end(); II != E; ++II) {
+ TreePattern *I = II->second.getPattern();
if (I->getNumTrees() != 1) {
std::cerr << "CANNOT HANDLE: " << I->getRecord()->getName() << " yet!";
@@ -894,7 +900,7 @@
continue; // Not a set of a single value (not handled so far)
TreePatternNode *SrcPattern = Pattern->getChild(1)->clone();
- TreePatternNode *DstPattern = Instructions[i].getResultPattern();
+ TreePatternNode *DstPattern = II->second.getResultPattern();
PatternsToMatch.push_back(std::make_pair(SrcPattern, DstPattern));
}
}
@@ -931,7 +937,7 @@
// never do anything with this pattern: report it to the user.
#if 0 // FIXME: ENABLE when we can infer though instructions!
if (!Result->InferAllTypes())
- Result->error("Could not infer all types in pattern!");
+ Result->error("Could not infer all types in pattern result!");
#endif
if (Result->getNumTrees() != 1)
Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.18 llvm/utils/TableGen/DAGISelEmitter.h:1.19
--- llvm/utils/TableGen/DAGISelEmitter.h:1.18 Thu Sep 15 16:51:12 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h Thu Sep 15 16:57:35 2005
@@ -317,7 +317,7 @@
std::map<Record*, SDNodeInfo> SDNodes;
std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
std::map<Record*, TreePattern*> PatternFragments;
- std::vector<DAGInstruction> Instructions;
+ std::map<Record*, DAGInstruction> Instructions;
/// PatternsToMatch - All of the things we are matching on the DAG. The first
/// value is the pattern to match, the second pattern is the result to
@@ -344,6 +344,11 @@
return SDNodeXForms.find(R)->second;
}
+ const DAGInstruction &getInstruction(Record *R) const {
+ assert(Instructions.count(R) && "Unknown instruction!");
+ return Instructions.find(R)->second;
+ }
+
private:
void ParseNodeInfo();
void ParseNodeTransforms(std::ostream &OS);
More information about the llvm-commits
mailing list