restore some 'magic' code that I removed: it is needed. Add comments explaining

why.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-11-14 22:17:10 +00:00
parent 717a611f79
commit 33a400477b

View File

@ -3602,10 +3602,15 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
// Print function. // Print function.
std::string OpVTStr; std::string OpVTStr;
if (OpVT == MVT::iPTR) if (OpVT == MVT::iPTR) {
OpVTStr = "iPTR"; OpVTStr = "_iPTR";
else } else if (OpVT == MVT::isVoid) {
OpVTStr = getEnumName(OpVT).substr(5); // Skip 'MVT::' // Nodes with a void result actually have a first result type of either
// Other (a chain) or Flag. Since there is no one-to-one mapping from
// void to this case, we handle it specially here.
} else {
OpVTStr = "_" + getEnumName(OpVT).substr(5); // Skip 'MVT::'
}
std::map<std::string, std::vector<std::string> >::iterator OpVTI = std::map<std::string, std::vector<std::string> >::iterator OpVTI =
OpcodeVTMap.find(OpName); OpcodeVTMap.find(OpName);
if (OpVTI == OpcodeVTMap.end()) { if (OpVTI == OpcodeVTMap.end()) {
@ -3616,7 +3621,7 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
OpVTI->second.push_back(OpVTStr); OpVTI->second.push_back(OpVTStr);
OS << "SDNode *Select_" << getLegalCName(OpName) OS << "SDNode *Select_" << getLegalCName(OpName)
<< "_" << OpVTStr << "(const SDOperand &N) {\n"; << OpVTStr << "(const SDOperand &N) {\n";
// Loop through and reverse all of the CodeList vectors, as we will be // Loop through and reverse all of the CodeList vectors, as we will be
// accessing them from their logical front, but accessing the end of a // accessing them from their logical front, but accessing the end of a
@ -3723,25 +3728,29 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
if (OpVTs.size() == 1) { if (OpVTs.size() == 1) {
std::string &VTStr = OpVTs[0]; std::string &VTStr = OpVTs[0];
OS << " return Select_" << getLegalCName(OpName) OS << " return Select_" << getLegalCName(OpName)
<< (VTStr != "" ? "_" : "") << VTStr << "(N);\n"; << VTStr << "(N);\n";
} else { } else {
// Keep track of whether we see a pattern that has an iPtr result. // Keep track of whether we see a pattern that has an iPtr result.
bool HasPtrPattern = false; bool HasPtrPattern = false;
bool HasDefaultPattern = false;
OS << " switch (NVT) {\n"; OS << " switch (NVT) {\n";
for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) { for (unsigned i = 0, e = OpVTs.size(); i < e; ++i) {
std::string &VTStr = OpVTs[i]; std::string &VTStr = OpVTs[i];
assert(!VTStr.empty() && "Unset vtstr?"); if (VTStr.empty()) {
HasDefaultPattern = true;
continue;
}
// If this is a match on iPTR: don't emit it directly, we need special // If this is a match on iPTR: don't emit it directly, we need special
// code. // code.
if (VTStr == "iPTR") { if (VTStr == "_iPTR") {
HasPtrPattern = true; HasPtrPattern = true;
continue; continue;
} }
OS << " case MVT::" << VTStr << ":\n" OS << " case MVT::" << VTStr.substr(1) << ":\n"
<< " return Select_" << getLegalCName(OpName) << " return Select_" << getLegalCName(OpName)
<< "_" << VTStr << "(N);\n"; << VTStr << "(N);\n";
} }
OS << " default:\n"; OS << " default:\n";
@ -3750,6 +3759,9 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
OS << " if (NVT == TLI.getPointerTy())\n"; OS << " if (NVT == TLI.getPointerTy())\n";
OS << " return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n"; OS << " return Select_" << getLegalCName(OpName) <<"_iPTR(N);\n";
} }
if (HasDefaultPattern) {
OS << " return Select_" << getLegalCName(OpName) << "(N);\n";
}
OS << " break;\n"; OS << " break;\n";
OS << " }\n"; OS << " }\n";
OS << " break;\n"; OS << " break;\n";