[llvm-commits] [llvm] r45635 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.cpp CodeGenDAGPatterns.h DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
sabre at nondot.org
Sat Jan 5 14:54:53 PST 2008
Author: lattner
Date: Sat Jan 5 16:54:53 2008
New Revision: 45635
URL: http://llvm.org/viewvc/llvm-project?rev=45635&view=rev
Log:
move Node Transformation printing from CodeGenDAGPatterns -> DAGISelEmitter.
The only difference in output is that we now print them in alphabetical
order instead of reverse alphabetical order.
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
llvm/trunk/utils/TableGen/DAGISelEmitter.h
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=45635&r1=45634&r2=45635&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sat Jan 5 16:54:53 2008
@@ -1112,12 +1112,10 @@
//
// FIXME: REMOVE OSTREAM ARGUMENT
-CodegenDAGPatterns::CodegenDAGPatterns(RecordKeeper &R, std::ostream &OS)
- : Records(R) {
-
+CodegenDAGPatterns::CodegenDAGPatterns(RecordKeeper &R) : Records(R) {
Intrinsics = LoadIntrinsics(Records);
ParseNodeInfo();
- ParseNodeTransforms(OS);
+ ParseNodeTransforms();
ParseComplexPatterns();
ParsePatternFragments();
ParseDefaultOperands();
@@ -1161,26 +1159,13 @@
/// ParseNodeTransforms - Parse all SDNodeXForm instances into the SDNodeXForms
/// map, and emit them to the file as functions.
-void CodegenDAGPatterns::ParseNodeTransforms(std::ostream &OS) {
- OS << "\n// Node transformations.\n";
+void CodegenDAGPatterns::ParseNodeTransforms() {
std::vector<Record*> Xforms = Records.getAllDerivedDefinitions("SDNodeXForm");
while (!Xforms.empty()) {
Record *XFormNode = Xforms.back();
Record *SDNode = XFormNode->getValueAsDef("Opcode");
std::string Code = XFormNode->getValueAsCode("XFormFunction");
- SDNodeXForms.insert(std::make_pair(XFormNode,
- std::make_pair(SDNode, Code)));
-
- if (!Code.empty()) {
- std::string ClassName = getSDNodeInfo(SDNode).getSDClassName();
- const char *C2 = ClassName == "SDNode" ? "N" : "inN";
-
- OS << "inline SDOperand Transform_" << XFormNode->getName()
- << "(SDNode *" << C2 << ") {\n";
- if (ClassName != "SDNode")
- OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n";
- OS << Code << "\n}\n";
- }
+ SDNodeXForms.insert(std::make_pair(XFormNode, NodeXForm(SDNode, Code)));
Xforms.pop_back();
}
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=45635&r1=45634&r2=45635&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Sat Jan 5 16:54:53 2008
@@ -451,7 +451,7 @@
/// emit.
std::vector<PatternToMatch> PatternsToMatch;
public:
- CodegenDAGPatterns(RecordKeeper &R, std::ostream &OS);
+ CodegenDAGPatterns(RecordKeeper &R);
~CodegenDAGPatterns();
const CodeGenTarget &getTargetInfo() const { return Target; }
@@ -463,11 +463,18 @@
return SDNodes.find(R)->second;
}
- const std::pair<Record*, std::string> &getSDNodeTransform(Record *R) const {
+ // Node transformation lookups.
+ typedef std::pair<Record*, std::string> NodeXForm;
+ const NodeXForm &getSDNodeTransform(Record *R) const {
assert(SDNodeXForms.count(R) && "Invalid transform!");
return SDNodeXForms.find(R)->second;
}
+ typedef std::map<Record*, NodeXForm>::const_iterator nx_iterator;
+ nx_iterator nx_begin() const { return SDNodeXForms.begin(); }
+ nx_iterator nx_end() const { return SDNodeXForms.end(); }
+
+
const ComplexPattern &getComplexPattern(Record *R) const {
assert(ComplexPatterns.count(R) && "Unknown addressing mode!");
return ComplexPatterns.find(R)->second;
@@ -530,7 +537,7 @@
private:
void ParseNodeInfo();
- void ParseNodeTransforms(std::ostream &OS);
+ void ParseNodeTransforms();
void ParseComplexPatterns();
void ParsePatternFragments();
void ParseDefaultOperands();
Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=45635&r1=45634&r2=45635&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Sat Jan 5 16:54:53 2008
@@ -207,6 +207,39 @@
}
//===----------------------------------------------------------------------===//
+// Node Transformation emitter implementation.
+//
+void DAGISelEmitter::EmitNodeTransforms(std::ostream &OS) {
+ // Walk the pattern fragments, adding them to a map, which sorts them by
+ // name.
+ typedef std::map<std::string, CodegenDAGPatterns::NodeXForm> NXsByNameTy;
+ NXsByNameTy NXsByName;
+
+ for (CodegenDAGPatterns::nx_iterator I = CGP->nx_begin(), E = CGP->nx_end();
+ I != E; ++I)
+ NXsByName.insert(std::make_pair(I->first->getName(), I->second));
+
+ OS << "\n// Node transformations.\n";
+
+ for (NXsByNameTy::iterator I = NXsByName.begin(), E = NXsByName.end();
+ I != E; ++I) {
+ Record *SDNode = I->second.first;
+ std::string Code = I->second.second;
+
+ if (Code.empty()) continue; // Empty code? Skip it.
+
+ std::string ClassName = CGP->getSDNodeInfo(SDNode).getSDClassName();
+ const char *C2 = ClassName == "SDNode" ? "N" : "inN";
+
+ OS << "inline SDOperand Transform_" << I->first << "(SDNode *" << C2
+ << ") {\n";
+ if (ClassName != "SDNode")
+ OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n";
+ OS << Code << "\n}\n";
+ }
+}
+
+//===----------------------------------------------------------------------===//
// Predicate emitter implementation.
//
@@ -2010,10 +2043,11 @@
OS << " return Dummy.getValue();\n";
OS << "}\n";
- CodegenDAGPatterns CGP(Records, OS);
+ CodegenDAGPatterns CGP(Records);
this->CGP = &CGP;
+ EmitNodeTransforms(OS);
EmitPredicateFunctions(OS);
DOUT << "\n\nALL PATTERNS TO MATCH:\n\n";
Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.h?rev=45635&r1=45634&r2=45635&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.h Sat Jan 5 16:54:53 2008
@@ -33,6 +33,7 @@
private:
+ void EmitNodeTransforms(std::ostream &OS);
void EmitPredicateFunctions(std::ostream &OS);
void GenerateCodeForPattern(const PatternToMatch &Pattern,
More information about the llvm-commits
mailing list