diff --git a/lib/Target/TargetSelectionDAG.td b/lib/Target/TargetSelectionDAG.td
index 2d6f4e344c2..e19a5a375a6 100644
--- a/lib/Target/TargetSelectionDAG.td
+++ b/lib/Target/TargetSelectionDAG.td
@@ -190,20 +190,23 @@ def vt         : SDNode<"ISD::VALUETYPE" , SDTOther   , [], "VTSDNode">;
 def bb         : SDNode<"ISD::BasicBlock", SDTOther   , [], "BasicBlockSDNode">;
 def cond       : SDNode<"ISD::CONDCODE"  , SDTOther   , [], "CondCodeSDNode">;
 def undef      : SDNode<"ISD::UNDEF"     , SDTUNDEF   , []>;
-def globaladdr : SDNode<"ISD::GlobalAddress",       SDTPtrLeaf, [],
+def globaladdr : SDNode<"ISD::GlobalAddress",         SDTPtrLeaf, [],
                         "GlobalAddressSDNode">;
-def tglobaladdr: SDNode<"ISD::TargetGlobalAddress", SDTPtrLeaf, [],
-                        "GlobalAddressSDNode">;
-def constpool  : SDNode<"ISD::ConstantPool",        SDTPtrLeaf, [],
-                        "ConstantPoolSDNode">;
-def tconstpool : SDNode<"ISD::TargetConstantPool",  SDTPtrLeaf, [],
-                        "ConstantPoolSDNode">;
-def frameindex : SDNode<"ISD::FrameIndex",          SDTPtrLeaf, [],
-                        "FrameIndexSDNode">;
-def tframeindex: SDNode<"ISD::TargetFrameIndex",    SDTPtrLeaf, [],
-                        "FrameIndexSDNode">;
-def externalsym: SDNode<"ISD::ExternalSymbol",      SDTPtrLeaf, [],
-                        "ExternalSymbolSDNode">;
+def tglobaladdr : SDNode<"ISD::TargetGlobalAddress",  SDTPtrLeaf, [],
+                         "GlobalAddressSDNode">;
+def constpool   : SDNode<"ISD::ConstantPool",         SDTPtrLeaf, [],
+                         "ConstantPoolSDNode">;
+def tconstpool  : SDNode<"ISD::TargetConstantPool",   SDTPtrLeaf, [],
+                         "ConstantPoolSDNode">;
+def frameindex  : SDNode<"ISD::FrameIndex",           SDTPtrLeaf, [],
+                         "FrameIndexSDNode">;
+def tframeindex : SDNode<"ISD::TargetFrameIndex",     SDTPtrLeaf, [],
+                         "FrameIndexSDNode">;
+def externalsym : SDNode<"ISD::ExternalSymbol",       SDTPtrLeaf, [],
+                         "ExternalSymbolSDNode">;
+def texternalsym: SDNode<"ISD::TargetExternalSymbol", SDTPtrLeaf, [],
+                         "ExternalSymbolSDNode">;
+
 def add        : SDNode<"ISD::ADD"       , SDTIntBinOp   ,
                         [SDNPCommutative, SDNPAssociative]>;
 def sub        : SDNode<"ISD::SUB"       , SDTIntBinOp>;
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 05b96290a97..8754097d904 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -1983,6 +1983,10 @@ public:
         OS << "      ";
         DeclareSDOperand("Tmp"+utostr(ResNo));
         OS << " = " << Val << ";\n";
+      } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym") {
+        OS << "      ";
+        DeclareSDOperand("Tmp"+utostr(ResNo));
+        OS << " = " << Val << ";\n";
       } else if (N->isLeaf() && (CP = NodeGetComplexPattern(N, ISE))) {
         std::string Fn = CP->getSelectFunc();
         NumRes = CP->getNumOperands();