[llvm-dev] Beginner question: Calling intrinsic

John Ky via llvm-dev
Sun, 07 Jan 2018 07:44:57 -0000

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
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20180107/31fe4a8e/attachment.html>