[Libclc-dev] Adding fabs to libclc

Gabriel Rodríguez grodriguez at udc.es
Thu Mar 1 02:43:32 PST 2012

Dear all, 

I have been trying to add support for fabs() to libclc and later to the LLVM-PTX backend. 
This looked simple enough, but I am having trouble starting with the libclc part. I have added 
the following files: 

generic/include/clc/math/fabs.h --------------------------- 

#undef fabs 
#define fabs __clc_fabs 

#define FUNCTION __clc_fabs 
#define INTRINSIC "llvm.fabs" 
#include <clc/math/unary_intrin.inc> 


#define native_fabs abs 

And I have added those files to generic/include/clc/clc.h. I expected this to generate 
@llvm.fabs.[f32/f64] functions as happens for sqrt, for instance. However, I find that the 
definition is already different in LLVM IR: 

declare ptx_device double @llvm.fabs.f64(double) 
declare double @llvm.sqrt.f64(double) nounwind readonly 

Since I am unable to get LLVM to lower calls to llvm.fabs as "abs" instructions rather than 
"call.uni", I suspect the declaration differences to be (at least in part) the culprit. Could someone 
point me out in the right direction? 

Thanks in advance, 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20120301/9ca052bb/attachment-0002.html>

More information about the Libclc-dev mailing list