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

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 7 13:57:10 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.6 -> 1.7
SelectionDAGISel.cpp updated: 1.2 -> 1.3
---
Log message:

Implement support for long GEP indices on 32-bit archs and support for
int GEP indices on 64-bit archs.


---
Diffs of the changes:  (+15 -3)

Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.6 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.7
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.6	Fri Jan  7 15:45:56 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Fri Jan  7 15:56:57 2005
@@ -529,6 +529,7 @@
     break;
   case ISD::ZERO_EXTEND:
   case ISD::SIGN_EXTEND:
+  case ISD::TRUNCATE:
   case ISD::FP_EXTEND:
   case ISD::FP_ROUND:
     switch (getTypeAction(Node->getOperand(0).getValueType())) {


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.2 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.3
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.2	Fri Jan  7 15:34:19 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Fri Jan  7 15:56:57 2005
@@ -477,9 +477,20 @@
       if (!isa<Constant>(Idx) || !cast<Constant>(Idx)->isNullValue()) {
         // N = N + Idx * ElementSize;
         uint64_t ElementSize = TD.getTypeSize(Ty);
-        SDOperand IdxN = getValue(Idx);
-        IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN,
-			   getIntPtrConstant(ElementSize));
+        SDOperand IdxN = getValue(Idx), Scale = getIntPtrConstant(ElementSize);
+
+        // If the index is smaller or larger than intptr_t, truncate or extend
+        // it.
+        if (IdxN.getValueType() < Scale.getValueType()) {
+          if (Idx->getType()->isSigned())
+            IdxN = DAG.getNode(ISD::SIGN_EXTEND, Scale.getValueType(), IdxN);
+          else
+            IdxN = DAG.getNode(ISD::ZERO_EXTEND, Scale.getValueType(), IdxN);
+        } else if (IdxN.getValueType() > Scale.getValueType())
+          IdxN = DAG.getNode(ISD::TRUNCATE, Scale.getValueType(), IdxN);
+
+        IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
+			   
         N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
       }
     }






More information about the llvm-commits mailing list