[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Apr 10 15:54:41 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.79 -> 1.80
---
Log message:

Teach legalize to deal with targets that don't support some SEXTLOAD/ZEXTLOADs


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

 LegalizeDAG.cpp |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.79 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.80
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.79	Sun Apr 10 12:40:35 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sun Apr 10 17:54:25 2005
@@ -442,22 +442,47 @@
 
   case ISD::EXTLOAD:
   case ISD::SEXTLOAD:
-  case ISD::ZEXTLOAD:
+  case ISD::ZEXTLOAD: {
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
     Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the pointer.
-    if (Tmp1 != Node->getOperand(0) ||
-        Tmp2 != Node->getOperand(1))
-      Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1, Tmp2,
-                           cast<MVTSDNode>(Node)->getExtraValueType());
-    else
-      Result = SDOperand(Node, 0);
-    
-    // Since loads produce two values, make sure to remember that we legalized
-    // both of them.
-    AddLegalizedOperand(SDOperand(Node, 0), Result);
-    AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
-    return Result.getValue(Op.ResNo);
 
+    MVT::ValueType SrcVT = cast<MVTSDNode>(Node)->getExtraValueType();
+    switch (TLI.getOperationAction(Node->getOpcode(), SrcVT)) {
+    case TargetLowering::Promote:
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Legal:
+      if (Tmp1 != Node->getOperand(0) ||
+          Tmp2 != Node->getOperand(1))
+        Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0),
+                             Tmp1, Tmp2, SrcVT);
+      else
+        Result = SDOperand(Node, 0);
+
+      // Since loads produce two values, make sure to remember that we legalized
+      // both of them.
+      AddLegalizedOperand(SDOperand(Node, 0), Result);
+      AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
+      return Result.getValue(Op.ResNo);
+      break;
+    case TargetLowering::Expand:
+      assert(Node->getOpcode() != ISD::EXTLOAD &&
+             "EXTLOAD should always be supported!");
+      // Turn the unsupported load into an EXTLOAD followed by an explicit
+      // zero/sign extend inreg.
+      Result = DAG.getNode(ISD::EXTLOAD, Node->getValueType(0),
+                           Tmp1, Tmp2, SrcVT);
+      unsigned ExtOp = Node->getOpcode() == ISD::SEXTLOAD ?
+                            ISD::SIGN_EXTEND_INREG : ISD::ZERO_EXTEND_INREG;
+      SDOperand ValRes = DAG.getNode(ExtOp, Result.getValueType(),
+                                     Result, SrcVT);
+      AddLegalizedOperand(SDOperand(Node, 0), ValRes);
+      AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
+      if (Op.ResNo)
+        return Result.getValue(1);
+      return ValRes;
+    }
+    assert(0 && "Unreachable");
+  }
   case ISD::EXTRACT_ELEMENT:
     // Get both the low and high parts.
     ExpandOp(Node->getOperand(0), Tmp1, Tmp2);






More information about the llvm-commits mailing list