mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45635 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dc32f9802a
commit
443e3f9dd6
@ -1112,12 +1112,10 @@ void TreePattern::dump() const { print(*cerr.stream()); }
|
||||
//
|
||||
|
||||
// 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 @@ void CodegenDAGPatterns::ParseNodeInfo() {
|
||||
|
||||
/// 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();
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ class CodegenDAGPatterns {
|
||||
/// 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 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
private:
|
||||
void ParseNodeInfo();
|
||||
void ParseNodeTransforms(std::ostream &OS);
|
||||
void ParseNodeTransforms();
|
||||
void ParseComplexPatterns();
|
||||
void ParsePatternFragments();
|
||||
void ParseDefaultOperands();
|
||||
|
@ -206,6 +206,39 @@ static bool PatternHasProperty(TreePatternNode *N, SDNP Property,
|
||||
return false;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// 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 << " unsigned NumKilled = ISelKilled.size();\n";
|
||||
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";
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
void EmitNodeTransforms(std::ostream &OS);
|
||||
void EmitPredicateFunctions(std::ostream &OS);
|
||||
|
||||
void GenerateCodeForPattern(const PatternToMatch &Pattern,
|
||||
|
Loading…
Reference in New Issue
Block a user