[llvm-dev] Beginner question: Calling intrinsic

Nemanja Ivanovic via llvm-dev llvm-dev at lists.llvm.org
Sun Jan 7 07:54:38 PST 2018


Hi John,
What targer are you trying to compile this for? I imagine this is just a
case of using an X86 intrinsic on a non-X86 back end. Or is this an
intrinsic you added and didn't provide a selection pattern for?

In any case, this intrinsic makes it into the selection DAG and the
instruction selector tries to select a sequence of instructions for it.
However, it fails to find a pattern that it can match in your back end, so
you get this error.

As far as learning LLVM, The documentation at llvm.org is the best place to
start. However, it is a huge project so you probably want to be a bit more
specific in terms of what it is you want to learn. Based on your question,
I imagine you want to learn how code generation works, so you might want to
check out http://llvm.org/docs/CodeGenerator.html

Hope this helps.

On Sun, Jan 7, 2018 at 4:21 PM John Ky via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Hello,
>
> I’m not sure if this is the right place to ask beginner questions.
>
> If not, please direct me to the appropriate place.
>
> I’m writing my first llvm program and I’m trying to call an intrinsic,
> but failing.
>
> So far this is what I have:
>
> declare ccc i32 @llvm.x86.bmi.pdep.32(i32, i32)
>
> @.str2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
>
> declare i32 @printf(i8*, ...) nounwind
>
> ; Definition of main function
> define i32 @main() {
>   %res = call ccc i32 (i32, i32) @llvm.x86.bmi.pdep.32( i32 1, i32 1 )
>
>   %a = alloca i32, align 8
>   %1 = load i32, i32* %a, align 8
>   %ss = getelementptr inbounds [4 x i8], [4 x i8]*  @.str2, i32 0, i32 0
>   call i32 (i8*, ...) @printf( i8* %ss, i32 %res)
>
>   ret i32 0
> }
>
> When I run this code, I get the following error:
>
> $ lli helloWorld.ll
> LLVM ERROR: Cannot select: intrinsic %llvm.x86.bmi.pdep.32
>
> Where am I going wrong?
>
> Also, what’s the best resource for learning llvm?
>
> Cheers,
>
> -John
>>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180107/7343d2e6/attachment.html>


More information about the llvm-dev mailing list