mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +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
|
// FIXME: REMOVE OSTREAM ARGUMENT
|
||||||
CodegenDAGPatterns::CodegenDAGPatterns(RecordKeeper &R, std::ostream &OS)
|
CodegenDAGPatterns::CodegenDAGPatterns(RecordKeeper &R) : Records(R) {
|
||||||
: Records(R) {
|
|
||||||
|
|
||||||
Intrinsics = LoadIntrinsics(Records);
|
Intrinsics = LoadIntrinsics(Records);
|
||||||
ParseNodeInfo();
|
ParseNodeInfo();
|
||||||
ParseNodeTransforms(OS);
|
ParseNodeTransforms();
|
||||||
ParseComplexPatterns();
|
ParseComplexPatterns();
|
||||||
ParsePatternFragments();
|
ParsePatternFragments();
|
||||||
ParseDefaultOperands();
|
ParseDefaultOperands();
|
||||||
@ -1161,26 +1159,13 @@ void CodegenDAGPatterns::ParseNodeInfo() {
|
|||||||
|
|
||||||
/// ParseNodeTransforms - Parse all SDNodeXForm instances into the SDNodeXForms
|
/// ParseNodeTransforms - Parse all SDNodeXForm instances into the SDNodeXForms
|
||||||
/// map, and emit them to the file as functions.
|
/// map, and emit them to the file as functions.
|
||||||
void CodegenDAGPatterns::ParseNodeTransforms(std::ostream &OS) {
|
void CodegenDAGPatterns::ParseNodeTransforms() {
|
||||||
OS << "\n// Node transformations.\n";
|
|
||||||
std::vector<Record*> Xforms = Records.getAllDerivedDefinitions("SDNodeXForm");
|
std::vector<Record*> Xforms = Records.getAllDerivedDefinitions("SDNodeXForm");
|
||||||
while (!Xforms.empty()) {
|
while (!Xforms.empty()) {
|
||||||
Record *XFormNode = Xforms.back();
|
Record *XFormNode = Xforms.back();
|
||||||
Record *SDNode = XFormNode->getValueAsDef("Opcode");
|
Record *SDNode = XFormNode->getValueAsDef("Opcode");
|
||||||
std::string Code = XFormNode->getValueAsCode("XFormFunction");
|
std::string Code = XFormNode->getValueAsCode("XFormFunction");
|
||||||
SDNodeXForms.insert(std::make_pair(XFormNode,
|
SDNodeXForms.insert(std::make_pair(XFormNode, NodeXForm(SDNode, Code)));
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
Xforms.pop_back();
|
Xforms.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ class CodegenDAGPatterns {
|
|||||||
/// emit.
|
/// emit.
|
||||||
std::vector<PatternToMatch> PatternsToMatch;
|
std::vector<PatternToMatch> PatternsToMatch;
|
||||||
public:
|
public:
|
||||||
CodegenDAGPatterns(RecordKeeper &R, std::ostream &OS);
|
CodegenDAGPatterns(RecordKeeper &R);
|
||||||
~CodegenDAGPatterns();
|
~CodegenDAGPatterns();
|
||||||
|
|
||||||
const CodeGenTarget &getTargetInfo() const { return Target; }
|
const CodeGenTarget &getTargetInfo() const { return Target; }
|
||||||
@ -463,11 +463,18 @@ public:
|
|||||||
return SDNodes.find(R)->second;
|
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!");
|
assert(SDNodeXForms.count(R) && "Invalid transform!");
|
||||||
return SDNodeXForms.find(R)->second;
|
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 {
|
const ComplexPattern &getComplexPattern(Record *R) const {
|
||||||
assert(ComplexPatterns.count(R) && "Unknown addressing mode!");
|
assert(ComplexPatterns.count(R) && "Unknown addressing mode!");
|
||||||
return ComplexPatterns.find(R)->second;
|
return ComplexPatterns.find(R)->second;
|
||||||
@ -530,7 +537,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseNodeInfo();
|
void ParseNodeInfo();
|
||||||
void ParseNodeTransforms(std::ostream &OS);
|
void ParseNodeTransforms();
|
||||||
void ParseComplexPatterns();
|
void ParseComplexPatterns();
|
||||||
void ParsePatternFragments();
|
void ParsePatternFragments();
|
||||||
void ParseDefaultOperands();
|
void ParseDefaultOperands();
|
||||||
|
@ -206,6 +206,39 @@ static bool PatternHasProperty(TreePatternNode *N, SDNP Property,
|
|||||||
return false;
|
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.
|
// Predicate emitter implementation.
|
||||||
//
|
//
|
||||||
@ -2010,10 +2043,11 @@ OS << " unsigned NumKilled = ISelKilled.size();\n";
|
|||||||
OS << " return Dummy.getValue();\n";
|
OS << " return Dummy.getValue();\n";
|
||||||
OS << "}\n";
|
OS << "}\n";
|
||||||
|
|
||||||
CodegenDAGPatterns CGP(Records, OS);
|
CodegenDAGPatterns CGP(Records);
|
||||||
|
|
||||||
this->CGP = &CGP;
|
this->CGP = &CGP;
|
||||||
|
|
||||||
|
EmitNodeTransforms(OS);
|
||||||
EmitPredicateFunctions(OS);
|
EmitPredicateFunctions(OS);
|
||||||
|
|
||||||
DOUT << "\n\nALL PATTERNS TO MATCH:\n\n";
|
DOUT << "\n\nALL PATTERNS TO MATCH:\n\n";
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void EmitNodeTransforms(std::ostream &OS);
|
||||||
void EmitPredicateFunctions(std::ostream &OS);
|
void EmitPredicateFunctions(std::ostream &OS);
|
||||||
|
|
||||||
void GenerateCodeForPattern(const PatternToMatch &Pattern,
|
void GenerateCodeForPattern(const PatternToMatch &Pattern,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user