[LLVMdev] GCCBuiltin and Intrinsic Mapping

David Greene dag at cray.com
Sun Sep 12 15:25:15 PDT 2010


I've run into an issue specifying intrinsics for AVX.

Right now one can use GCCBuiltin to get automatic CBE (and other)
support for emitting intrinsics as gcc builtins.  It looks like
this:

  def int_x86_sse3_hadd_pd : GCCBuiltin<"__builtin_ia32_haddpd">,
              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
                         llvm_v2f64_ty], [IntrNoMem]>;

AVX has 128-bit instructions that work exactly like SSE instructions
except they have non-destructive operands.  gcc defines intrinsics for
256-bit operations but does not define special intrinsics for 128-bit
AVX instructions.  So one has to use the SSE intrinsics:

   def int_x86_avx_vhadd_pd_xmm : GCCBuiltin<"__builtin_ia32_haddpd">,
              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty],
                        [IntrNoMem]>;

Unfortunately, this doesn't work:

/ptmp/dag/universal_build/merge/developer/DEFAULT/llvm/tblgen: Intrinsic 'int_x86_sse3_hadd_pd': duplicate GCC builtin name!

Apparently it's not possible to define two different LLVM intrinsics
that map to the same GCCBuiltin.  Is this a known limitation?  How
complicated would it be to lift this restriction?

                          -Dave



More information about the llvm-dev mailing list