[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Wed Sep 14 15:55:37 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.24 -> 1.25
DAGISelEmitter.h updated: 1.15 -> 1.16
---
Log message:
start building the instruction dest pattern correctly. Change the xform
functions to preserve the Record for the xform instead of making it into a
function name.
---
Diffs of the changes: (+27 -15)
DAGISelEmitter.cpp | 23 +++++++++++++++--------
DAGISelEmitter.h | 19 ++++++++++++-------
2 files changed, 27 insertions(+), 15 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.24 llvm/utils/TableGen/DAGISelEmitter.cpp:1.25
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.24 Wed Sep 14 17:06:36 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed Sep 14 17:55:26 2005
@@ -203,8 +203,8 @@
if (!PredicateFn.empty())
OS << "<<P:" << PredicateFn << ">>";
- if (!TransformFn.empty())
- OS << "<<X:" << TransformFn << ">>";
+ if (TransformFn)
+ OS << "<<X:" << TransformFn->getName() << ">>";
if (!getName().empty())
OS << ":$" << getName();
@@ -598,7 +598,7 @@
// it.
Record *Transform = Fragments[i]->getValueAsDef("OperandTransform");
if (!getSDNodeTransform(Transform).second.empty()) // not noop xform?
- P->getOnlyTree()->setTransformFn("Transform_"+Transform->getName());
+ P->getOnlyTree()->setTransformFn(Transform);
}
OS << "\n\n";
@@ -814,7 +814,8 @@
// Loop over the inputs next. Make a copy of InstInputs so we can destroy
// the copy while we're checking the inputs.
std::map<std::string, TreePatternNode*> InstInputsCheck(InstInputs);
-
+
+ std::vector<TreePatternNode*> ResultNodeOperands;
for (unsigned i = NumResults, e = CGI.OperandList.size(); i != e; ++i) {
const std::string &OpName = CGI.OperandList[i].Name;
if (OpName.empty())
@@ -824,20 +825,26 @@
I->error("Operand $" + OpName +
" does not appear in the instruction pattern");
TreePatternNode *InVal = InstInputsCheck[OpName];
- InstInputsCheck.erase(OpName);
+ InstInputsCheck.erase(OpName); // It occurred, remove from map.
if (CGI.OperandList[i].Ty != InVal->getType())
I->error("Operand $" + OpName +
"'s type disagrees between the operand and pattern");
+
+ ResultNodeOperands.push_back(InVal->clone());
}
if (!InstInputsCheck.empty())
I->error("Input operand $" + InstInputsCheck.begin()->first +
" occurs in pattern but not in operands list!");
-
+
+ TreePatternNode *ResultPattern =
+ new TreePatternNode(I->getRecord(), ResultNodeOperands);
+
unsigned NumOperands = CGI.OperandList.size()-NumResults;
DEBUG(I->dump());
- Instructions.push_back(DAGInstruction(I, NumResults, NumOperands));
+ Instructions.push_back(DAGInstruction(I, NumResults, NumOperands,
+ ResultPattern));
}
// If we can, convert the instructions to be patterns that are matched!
@@ -856,7 +863,7 @@
continue; // Not a set of a single value (not handled so far)
TreePatternNode *SrcPattern = Pattern->getChild(1)->clone();
- TreePatternNode *DstPattern = SrcPattern->clone(); // FIXME: WRONG
+ TreePatternNode *DstPattern = Instructions[i].getResultPattern();
PatternsToMatch.push_back(std::make_pair(SrcPattern, DstPattern));
DEBUG(std::cerr << "PATTERN TO MATCH: "; SrcPattern->dump();
std::cerr << "\nRESULT DAG : ";
Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.15 llvm/utils/TableGen/DAGISelEmitter.h:1.16
--- llvm/utils/TableGen/DAGISelEmitter.h:1.15 Wed Sep 14 15:53:42 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h Wed Sep 14 17:55:26 2005
@@ -122,14 +122,15 @@
/// TransformFn - The transformation function to execute on this node before
/// it can be substituted into the resulting instruction on a pattern match.
- std::string TransformFn;
+ Record *TransformFn;
std::vector<TreePatternNode*> Children;
public:
TreePatternNode(Record *Op, const std::vector<TreePatternNode*> &Ch)
- : Ty(MVT::LAST_VALUETYPE), Operator(Op), Val(0), Children(Ch) {}
+ : Ty(MVT::LAST_VALUETYPE), Operator(Op), Val(0), TransformFn(0),
+ Children(Ch) {}
TreePatternNode(Init *val) // leaf ctor
- : Ty(MVT::LAST_VALUETYPE), Operator(0), Val(val) {}
+ : Ty(MVT::LAST_VALUETYPE), Operator(0), Val(val), TransformFn(0) {}
~TreePatternNode();
const std::string &getName() const { return Name; }
@@ -152,8 +153,8 @@
const std::string &getPredicateFn() const { return PredicateFn; }
void setPredicateFn(const std::string &Fn) { PredicateFn = Fn; }
- const std::string &getTransformFn() const { return TransformFn; }
- void setTransformFn(const std::string &Fn) { TransformFn = Fn; }
+ Record *getTransformFn() const { return TransformFn; }
+ void setTransformFn(Record *Fn) { TransformFn = Fn; }
void print(std::ostream &OS) const;
void dump() const;
@@ -278,13 +279,17 @@
TreePattern *Pattern;
unsigned NumResults;
unsigned NumOperands;
+ TreePatternNode *ResultPattern;
public:
- DAGInstruction(TreePattern *TP, unsigned results, unsigned ops)
- : Pattern(TP), NumResults(results), NumOperands(ops) {}
+ DAGInstruction(TreePattern *TP, unsigned results, unsigned ops,
+ TreePatternNode *resultPattern)
+ : Pattern(TP), NumResults(results), NumOperands(ops),
+ ResultPattern(resultPattern) {}
TreePattern *getPattern() const { return Pattern; }
unsigned getNumResults() const { return NumResults; }
unsigned getNumOperands() const { return NumOperands; }
+ TreePatternNode *getResultPattern() const { return ResultPattern; }
};
More information about the llvm-commits
mailing list