[llvm-dev] Beginner question: Calling intrinsic

John Ky via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 9 01:38:32 PST 2018


Nice!

Thanks so much!

On Tue, 9 Jan 2018 at 07:20 Craig Topper <craig.topper at gmail.com> wrote:

> If you are using x86, you probably need to pass something like
> -mcpu=haswell or -mattr=bmi2 to enable support for the intrinsic. It seems
> to -mcpu=native doesn't work for lli so it can't just autodetect your CPU.
>
> ~Craig
>
> On Sun, Jan 7, 2018 at 7:54 AM, Nemanja Ivanovic via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> 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
>>>
>>
>> _______________________________________________
>> 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/20180109/8462711f/attachment.html>


More information about the llvm-dev mailing list