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

Nate Begeman natebegeman at mac.com
Tue Oct 18 17:07:07 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.201 -> 1.202
---
Log message:

Teach Legalize how to do something with EXTRACT_ELEMENT when the type of
the pair of elements is a legal type.


---
Diffs of the changes:  (+30 -7)

 LegalizeDAG.cpp |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.201 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.202
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.201	Mon Oct 17 19:27:41 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Tue Oct 18 19:06:56 2005
@@ -955,14 +955,37 @@
     }
     assert(0 && "Unreachable");
   }
-  case ISD::EXTRACT_ELEMENT:
-    // Get both the low and high parts.
-    ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
-    if (cast<ConstantSDNode>(Node->getOperand(1))->getValue())
-      Result = Tmp2;  // 1 -> Hi
-    else
-      Result = Tmp1;  // 0 -> Lo
+  case ISD::EXTRACT_ELEMENT: {
+    MVT::ValueType OpTy = Node->getOperand(0).getValueType();
+    switch (getTypeAction(OpTy)) {
+    default:
+      assert(0 && "EXTRACT_ELEMENT action for type unimplemented!");
+      break;
+    case Legal:
+      if (cast<ConstantSDNode>(Node->getOperand(1))->getValue()) {
+        // 1 -> Hi
+        Result = DAG.getNode(ISD::SRL, OpTy, Node->getOperand(0),
+                             DAG.getConstant(MVT::getSizeInBits(OpTy)/2, 
+                                             TLI.getShiftAmountTy()));
+        Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Result);
+      } else {
+        // 0 -> Lo
+        Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), 
+                             Node->getOperand(0));
+      }
+      Result = LegalizeOp(Result);
+      break;
+    case Expand:
+      // Get both the low and high parts.
+      ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
+      if (cast<ConstantSDNode>(Node->getOperand(1))->getValue())
+        Result = Tmp2;  // 1 -> Hi
+      else
+        Result = Tmp1;  // 0 -> Lo
+      break;
+    }
     break;
+  }
 
   case ISD::CopyToReg:
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.






More information about the llvm-commits mailing list