start parsing SDNode info records

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23279 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-09-08 21:03:01 +00:00
parent 223df2269d
commit ca559d0654
2 changed files with 39 additions and 0 deletions

View File

@ -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 @@ void TreePattern::dump() const { print(std::cerr); }
// 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 @@ void DAGISelEmitter::run(std::ostream &OS) {
EmitSourceFileHeader("DAG Instruction Selector for the " + Target.getName() +
" target", OS);
ParseNodeInfo();
ParseAndResolvePatternFragments(OS);
ParseAndResolveInstructions();

View File

@ -23,6 +23,21 @@ namespace llvm {
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 @@ class DAGISelEmitter : public TableGenBackend {
RecordKeeper &Records;
CodeGenTarget Target;
std::map<Record*, SDNodeInfo> SDNodes;
std::map<Record*, TreePattern*> PatternFragments;
std::vector<TreePattern*> Instructions;
public:
@ -188,6 +204,11 @@ public:
// 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 @@ public:
}
private:
void ParseNodeInfo();
void ParseAndResolvePatternFragments(std::ostream &OS);
void ParseAndResolveInstructions();
void EmitInstructionSelector(std::ostream &OS);