[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Evan Cheng evan.cheng at apple.com
Thu Jan 12 11:36:07 PST 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.132 -> 1.133
---
Log message:

Allow transformation from GlobalAddress to TargetGlobalAddress and
ExternalSymbol to TargetExternalSymbol.


---
Diffs of the changes:  (+24 -13)

 DAGISelEmitter.cpp |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.132 llvm/utils/TableGen/DAGISelEmitter.cpp:1.133
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.132	Thu Jan 12 01:54:57 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Thu Jan 12 13:35:54 2006
@@ -1826,7 +1826,9 @@
   unsigned PatternNo;
   std::ostream &OS;
   // Node to name mapping
-  std::map<std::string,std::string> VariableMap;
+  std::map<std::string, std::string> VariableMap;
+  // Node to operator mapping
+  std::map<std::string, Record*> OperatorMap;
   // Names of all the folded nodes which produce chains.
   std::vector<std::pair<std::string, unsigned> > FoldedChains;
   unsigned TmpNo;
@@ -1892,6 +1894,9 @@
            << ") goto P" << PatternNo << "Fail;\n";
         return;
       }
+
+      if (!N->isLeaf())
+        OperatorMap[N->getName()] = N->getOperator();
     }
 
 
@@ -2023,20 +2028,26 @@
         OS << "      SDOperand Tmp" << utostr(ResNo)
            << " = CurDAG->getTargetConstant(Tmp"
            << ResNo << "C, MVT::" << getEnumName(N->getTypeNum(0)) << ");\n";
-      } else if (!N->isLeaf() && N->getOperator()->getName() == "globaladdr") {
-        OS << "      SDOperand Tmp" << ResNo
-           << " = CurDAG->getTargetGlobalAddress(cast<GlobalAddressSDNode>("
-           << Val << ")->getGlobal(), MVT::" << getEnumName(N->getTypeNum(0))
-           << ");\n";
-      } else if (!N->isLeaf() && N->getOperator()->getName() == "externalsym") {
-        OS << "      SDOperand Tmp" << ResNo
-           << " = CurDAG->getTargetExternalSymbol(cast<ExternalSymbolSDNode>("
-           << Val << ")->getSymbol(), MVT::" << getEnumName(N->getTypeNum(0))
-           << ");\n";
       } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
-        OS << "      SDOperand Tmp" << ResNo << " = " << Val << ";\n";
+        Record *Op = OperatorMap[N->getName()];
+        // Transform ExternalSymbol to TargetExternalSymbol
+        if (Op && Op->getName() == "externalsym") {
+          OS << "      SDOperand Tmp" << ResNo
+             << " = CurDAG->getTargetExternalSymbol(cast<ExternalSymbolSDNode>("
+             << Val << ")->getSymbol(), MVT::" << getEnumName(N->getTypeNum(0))
+             << ");\n";
+        } else
+          OS << "      SDOperand Tmp" << ResNo << " = " << Val << ";\n";
       } else if (!N->isLeaf() && N->getOperator()->getName() == "tglobaladdr") {
-        OS << "      SDOperand Tmp" << ResNo << " = " << Val << ";\n";
+        Record *Op = OperatorMap[N->getName()];
+        // Transform GlobalAddress to TargetGlobalAddress
+        if (Op && Op->getName() == "globaladdr") {
+          OS << "      SDOperand Tmp" << ResNo
+             << " = CurDAG->getTargetGlobalAddress(cast<GlobalAddressSDNode>("
+             << Val << ")->getGlobal(), MVT::" << getEnumName(N->getTypeNum(0))
+             << ");\n";
+        } else
+          OS << "      SDOperand Tmp" << ResNo << " = " << Val << ";\n";
       } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
         OS << "      SDOperand Tmp" << ResNo << " = " << Val << ";\n";
       } else if (!N->isLeaf() && N->getOperator()->getName() == "tconstpool") {






More information about the llvm-commits mailing list