[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Sep 8 14:03:12 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.2 -> 1.3
DAGISelEmitter.h updated: 1.2 -> 1.3
---
Log message:
start parsing SDNode info records
---
Diffs of the changes: (+39 -0)
DAGISelEmitter.cpp | 17 +++++++++++++++++
DAGISelEmitter.h | 22 ++++++++++++++++++++++
2 files changed, 39 insertions(+)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.2 llvm/utils/TableGen/DAGISelEmitter.cpp:1.3
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.2 Thu Sep 8 12:45:12 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 8 16:03:01 2005
@@ -18,6 +18,13 @@
#include <set>
using namespace llvm;
+//===----------------------------------------------------------------------===//
+// SDNodeInfo implementation
+//
+SDNodeInfo::SDNodeInfo(Record *R) : Def(R) {
+ EnumName = R->getValueAsString("Opcode");
+ SDClassName = R->getValueAsString("SDClass");
+}
//===----------------------------------------------------------------------===//
// TreePatternNode implementation
@@ -349,6 +356,15 @@
// DAGISelEmitter implementation
//
+// Parse all of the SDNode definitions for the target, populating SDNodes.
+void DAGISelEmitter::ParseNodeInfo() {
+ std::vector<Record*> Nodes = Records.getAllDerivedDefinitions("SDNode");
+ while (!Nodes.empty()) {
+ SDNodes.insert(std::make_pair(Nodes.back(), Nodes.back()));
+ Nodes.pop_back();
+ }
+}
+
/// ParseAndResolvePatternFragments - Parse all of the PatFrag definitions in
/// the .td file, building up the PatternFragments map. After we've collected
/// them all, inline fragments together as necessary, so that there are no
@@ -458,6 +474,7 @@
EmitSourceFileHeader("DAG Instruction Selector for the " + Target.getName() +
" target", OS);
+ ParseNodeInfo();
ParseAndResolvePatternFragments(OS);
ParseAndResolveInstructions();
Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.2 llvm/utils/TableGen/DAGISelEmitter.h:1.3
--- llvm/utils/TableGen/DAGISelEmitter.h:1.2 Wed Sep 7 18:44:43 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h Thu Sep 8 16:03:01 2005
@@ -23,6 +23,21 @@
class DagInit;
class TreePattern;
class DAGISelEmitter;
+
+ /// SDNodeInfo - One of these records is created for each SDNode instance in
+ /// the target .td file. This represents the various dag nodes we will be
+ /// processing.
+ class SDNodeInfo {
+ Record *Def;
+ std::string EnumName;
+ std::string SDClassName;
+ public:
+ SDNodeInfo(Record *R); // Parse the specified record.
+
+ Record *getRecord() const { return Def; }
+ const std::string &getEnumName() const { return EnumName; }
+ const std::string &getSDClassName() const { return SDClassName; }
+ };
/// FIXME: TreePatternNode's can be shared in some cases (due to dag-shaped
/// patterns), and as such should be ref counted. We currently just leak all
@@ -181,6 +196,7 @@
RecordKeeper &Records;
CodeGenTarget Target;
+ std::map<Record*, SDNodeInfo> SDNodes;
std::map<Record*, TreePattern*> PatternFragments;
std::vector<TreePattern*> Instructions;
public:
@@ -188,6 +204,11 @@
// run - Output the isel, returning true on failure.
void run(std::ostream &OS);
+
+ const SDNodeInfo &getSDNodeInfo(Record *R) const {
+ assert(SDNodes.count(R) && "Unknown node!");
+ return SDNodes.find(R)->second;
+ }
TreePattern *getPatternFragment(Record *R) const {
assert(PatternFragments.count(R) && "Invalid pattern fragment request!");
@@ -195,6 +216,7 @@
}
private:
+ void ParseNodeInfo();
void ParseAndResolvePatternFragments(std::ostream &OS);
void ParseAndResolveInstructions();
void EmitInstructionSelector(std::ostream &OS);
More information about the llvm-commits
mailing list