diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-22 23:04:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-22 23:04:37 +0000 |
commit | eccb73d57fc2cb321d02152a4e257c35ff0b2761 (patch) | |
tree | ff31d49de337d97fc0520bd1b49368c08853fc45 /llvm/lib | |
parent | 12b25a12a6c3e117eda5ca1dc5cf353fa7fbe46c (diff) | |
download | bcm5719-llvm-eccb73d57fc2cb321d02152a4e257c35ff0b2761.tar.gz bcm5719-llvm-eccb73d57fc2cb321d02152a4e257c35ff0b2761.zip |
Get this to work for 64-bit systems.
llvm-svn: 19763
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3439249446e..20d731332b8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -566,11 +566,13 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { unsigned Align = TLI.getTargetData().getTypeAlignment(Ty); SDOperand AllocSize = getValue(I.getArraySize()); + MVT::ValueType IntPtr = TLI.getPointerTy(); + if (IntPtr < AllocSize.getValueType()) + AllocSize = DAG.getNode(ISD::TRUNCATE, IntPtr, AllocSize); + else if (IntPtr > AllocSize.getValueType()) + AllocSize = DAG.getNode(ISD::ZERO_EXTEND, IntPtr, AllocSize); - assert(AllocSize.getValueType() == TLI.getPointerTy() && - "FIXME: should extend or truncate to pointer size!"); - - AllocSize = DAG.getNode(ISD::MUL, TLI.getPointerTy(), AllocSize, + AllocSize = DAG.getNode(ISD::MUL, IntPtr, AllocSize, getIntPtrConstant(TySize)); // Handle alignment. If the requested alignment is less than or equal to the @@ -679,8 +681,11 @@ void SelectionDAGLowering::visitMalloc(MallocInst &I) { SDOperand Src = getValue(I.getOperand(0)); MVT::ValueType IntPtr = TLI.getPointerTy(); - // FIXME: Extend or truncate to the intptr size. - assert(Src.getValueType() == IntPtr && "Need to adjust the amount!"); + + if (IntPtr < Src.getValueType()) + Src = DAG.getNode(ISD::TRUNCATE, IntPtr, Src); + else if (IntPtr > Src.getValueType()) + Src = DAG.getNode(ISD::ZERO_EXTEND, IntPtr, Src); // Scale the source by the type size. uint64_t ElementSize = TD.getTypeSize(I.getType()->getElementType()); |