problem compiling x86 intrinsic function

I am trying to compile this little C-program:

We used to support this, but there are problems with it. I actually just went to go implement this again, which illustrated why this is a bad idea. If you apply this patch to clang, it will do what you want:

p.patch (1.02 KB)

Thanks for your advice.

I am not sure that I understood your comment "If you need something, there should be a __builtin that corresponds to the intrinsic." Is that a better way to define an intrinsic function in C? How do you do it?

I am actually trying to add several intrinsic functions for my target machine so I am looking for a simple and workable way of doing it.

Thanks again.

-- Fima

Ah ok. The 'right' way to do this is to add a builtin that correponds to the intrinsic. In the case of the one you listed, the builtin is __builtin_ia32_cmpsd. Depending on what frontend you're using, there are different ways to add the intrinsic. In clang, you can grep for __builtin_ia32_cmpsd in lib/codegen for an example. Another simpler way is to make the builtin correspond directly to the intrinsic with the 'GCCBuiltin' annotation in the intrinsic .td file.

-Chris