diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-24 22:05:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-24 22:05:23 +0000 |
commit | c382bc3c0f476bf94303d9892af4e2cee173bfe5 (patch) | |
tree | 177ed972f2efd65c0f0296b1899e97042128a4cb /lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | |
parent | 46ca5efdd5b748ba8aa62168f7753cb46b683bc5 (diff) | |
download | external_llvm-c382bc3c0f476bf94303d9892af4e2cee173bfe5.tar.gz external_llvm-c382bc3c0f476bf94303d9892af4e2cee173bfe5.tar.bz2 external_llvm-c382bc3c0f476bf94303d9892af4e2cee173bfe5.zip |
Make getTypeSizeInBits work correctly for array types; it should return
the number of value bits, not the number of bits of allocation for in-memory
storage.
Make getTypeStoreSize and getTypeAllocSize work consistently for arrays and
vectors.
Fix several places in CodeGen which compute offsets into in-memory vectors
to use TargetData information.
This fixes PR1784.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index e9321dad8c..87dc0ac935 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -660,7 +660,8 @@ PerformInsertVectorEltInMemory(SDValue Vec, SDValue Val, SDValue Idx, unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND; Tmp3 = DAG.getNode(CastOpc, dl, PtrVT, Tmp3); // Add the offset to the index. - unsigned EltSize = EltVT.getSizeInBits()/8; + unsigned EltSize = TLI.getTargetData()-> + getTypeAllocSize(EltVT.getTypeForEVT(*DAG.getContext())); Tmp3 = DAG.getNode(ISD::MUL, dl, IdxVT, Tmp3,DAG.getConstant(EltSize, IdxVT)); SDValue StackPtr2 = DAG.getNode(ISD::ADD, dl, IdxVT, Tmp3, StackPtr); // Store the scalar value. @@ -1512,8 +1513,9 @@ SDValue SelectionDAGLegalize::ExpandExtractFromVectorThroughStack(SDValue Op) { false, false, 0); // Add the offset to the index. - unsigned EltSize = - Vec.getValueType().getVectorElementType().getSizeInBits()/8; + unsigned EltSize = TLI.getTargetData()->getTypeAllocSize( + Vec.getValueType().getVectorElementType().getTypeForEVT(*DAG.getContext())); + Idx = DAG.getNode(ISD::MUL, dl, Idx.getValueType(), Idx, DAG.getConstant(EltSize, Idx.getValueType())); @@ -1548,7 +1550,8 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) { // Emit a store of each element to the stack slot. SmallVector<SDValue, 8> Stores; - unsigned TypeByteSize = EltVT.getSizeInBits() / 8; + unsigned TypeByteSize = TLI.getTargetData()-> + getTypeAllocSize(EltVT.getTypeForEVT(*DAG.getContext())); // Store (in the right endianness) the elements to memory. for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { // Ignore undef elements. |