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 | 68cd65ea689907fb8a4aa80d72d182921e94607f (patch) | |
tree | 622db2f053e13608f1c9112fbd68bcb825069ece /lib | |
parent | ae6ec8e6c48a792c9e2384034674f0c134f70afe (diff) | |
download | external_llvm-68cd65ea689907fb8a4aa80d72d182921e94607f.zip external_llvm-68cd65ea689907fb8a4aa80d72d182921e94607f.tar.gz external_llvm-68cd65ea689907fb8a4aa80d72d182921e94607f.tar.bz2 |
Get this to work for 64-bit systems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19763 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3439249..20d7313 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/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()); |