[LLVMdev] How to call the llvm.prefetch intrinsic ?

Jimborean Alexandra xinfinity_a at yahoo.com
Wed Apr 10 11:00:14 PDT 2013


Thank you, this is what I was looking for.

Alexandra




________________________________
 From: Hal Finkel <hfinkel at anl.gov>
To: Jimborean Alexandra <xinfinity_a at yahoo.com> 
Cc: llvmdev at cs.uiuc.edu 
Sent: Wednesday, April 10, 2013 7:52 PM
Subject: Re: [LLVMdev] How to call the llvm.prefetch intrinsic ?
 
Alexandra,

I'm not sure what you mean by "replace", but I have code that does this to insert prefetches:

      Type *I8Ptr = Type::getInt8PtrTy((*I)->getContext(), PtrAddrSpace);
      Value *PrefPtrValue = ...

      IRBuilder<> Builder(MemI);
      Module *M = (*I)->getParent()->getParent();
      Type *I32 = Type::getInt32Ty((*I)->getContext());
      Value *PrefetchFunc = Intrinsic::getDeclaration(M, Intrinsic::prefetch);
      Builder.CreateCall4(PrefetchFunc, PrefPtrValue,
        ConstantInt::get(I32, MemI->mayReadFromMemory() ? 0 : 1),
        ConstantInt::get(I32, 3), ConstantInt::get(I32, 1));

-Hal

----- Original Message -----
> From: "Jimborean Alexandra" <xinfinity_a at yahoo.com>
> To: llvmdev at cs.uiuc.edu
> Sent: Wednesday, April 10, 2013 12:43:23 PM
> Subject: [LLVMdev] How to call the llvm.prefetch intrinsic ?
> 
> 
> 
> 
> Hello,
> 
> 
> Can anyone please guide me how can I replace a load instruction with
> a prefetch. I was looking at the intrinsic creation methods of the
> IRBuilder, but I can only find functions corresponding to memset,
> memcpy and memmove intrinsics, not for prefetching.
> 
> 
> Also, I target x86-64 architectures. Is it sufficient to insert a
> call to the intrinsic in the LLVM IR to have the corresponding
> prefetch instruction generated for this target?
> 
> 
> 
> Thank you for your help,
> Alexandra
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu        http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130410/fc7d2bb3/attachment.html>


More information about the llvm-dev mailing list