aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-06-15 20:00:14 +0000
committerDuncan Sands <baldrick@free.fr>2008-06-15 20:00:14 +0000
commit7d0d8460646d1a06ff561775d40123a4cf65bf4d (patch)
tree5808f02d1bfc436c66c36f4397f4c28869c9a94c /lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
parent8a08769bad43a22fae2845bb0ba0fd1266cd55c8 (diff)
LegalizeTypes support for INSERT_VECTOR_ELT with
a non-constant index. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52292 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeTypes.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 16c86936a6..5b37c75f1f 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -577,6 +577,23 @@ SDOperand DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
return CallInfo.first;
}
+SDOperand DAGTypeLegalizer::GetVectorElementPointer(SDOperand VecPtr, MVT EltVT,
+ SDOperand Index) {
+ // Make sure the index type is big enough to compute in.
+ if (Index.getValueType().bitsGT(TLI.getPointerTy()))
+ Index = DAG.getNode(ISD::TRUNCATE, TLI.getPointerTy(), Index);
+ else
+ Index = DAG.getNode(ISD::ZERO_EXTEND, TLI.getPointerTy(), Index);
+
+ // Calculate the element offset and add it to the pointer.
+ unsigned EltSize = EltVT.getSizeInBits() / 8; // FIXME: should be ABI size.
+
+ Index = DAG.getNode(ISD::MUL, Index.getValueType(), Index,
+ DAG.getConstant(EltSize, Index.getValueType()));
+ return DAG.getNode(ISD::ADD, Index.getValueType(), Index, VecPtr);
+}
+
+
//===----------------------------------------------------------------------===//
// Entry Point
//===----------------------------------------------------------------------===//