[LLVMdev] double* to <2 x double>*
mats petersson
mats at planetcatfish.com
Thu Apr 16 01:46:28 PDT 2015
The result of getelementptr is a pointer to double, you want a pointer
to 2 x double, not a type of 2 x double *.
So, you need to make a pointer to a 2 x double (writing from memory,
so syntax may be off, but conceptually this should be right)
vecPtrTy = Type::getUnqualPtr(VectorType:get(Type::getDoubleTy(), 2));
--
Mats
On 16 April 2015 at 08:46, zhi chen <zchenhn at gmail.com> wrote:
> Does anyone know how to instrument double* to <2 x doulbe>*, e.g., 2.2 -->
> <2.2, 2.2>?
> For example, I want to change the following IR code
>
> %arrayidx1 = getelementptr inbounds [100 x double]* @main.B, i32 0, i32
> %i.021
> %1 = load double* %arrayidx1, align 4, !tbaa !0
>
> to:
>
> %arrayidx1 = getelementptr inbounds [100 x double]* @main.B, i32 0, i32
> %i.021
> %1 = bitcast double* %arrayidx1 to <2 x double>*
> %2 = load <2 x double>* %1, align 4
>
> what I right now doing is:
> Assume pInst is %1 = load double* %arrayidx1, align 4, !tbaa !0
>
> Value *loadValue = pInst->getOperand(0);
> Type *vecTy = VectorType::get(Type::getDoublePtrTy(currF->getContext()), 2);
> Value *emptyVec = UndefValue::get(vecTy);
> Type* u32Ty = Type::getInt32Ty(currF->getContext());
> Value *index0 = ConstantInt::get(u32Ty, 0);
> Value *index1 = ConstantInt::get(u32Ty, 1);
>
> Instruction *InsertVal = InsertElementInst::Create(emptyVec, loadValue,
> index0, "");
> InsertVal = InsertElementInst::Create(emptyVec, loadValue, index1, "");
> InsertVal->insertBefore(pInst);
>
> It turned out that the way I am doing is not right because the output is <2
> x double*>. Any help will be appreciated!
>
> BTW, can I use bitcastInst (if so, how?) or I have to use insertelementInst?
>
> Thanks,
> Zhi
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list