[LLVMdev] ARM NEON intrinsics in clang

Renato Golin renato.golin at linaro.org
Thu Sep 26 08:01:58 PDT 2013

On 26 September 2013 12:22, Stanislav Manilov <S.Z.Manilov at sms.ed.ac.uk>wrote:

> In the process I found out that clang doesn't support NEON (as per
> http://blog.llvm.org/2010/04/arm-advanced-simd-neon-intrinsics-and.html),
> but there has been at least some effort in adding it (
> https://www.codeaurora.org/patches/quic/llvm/32040/clang-Initial-Neon-support.patch
> ).

Hi Stanislav,

LLVM does support NEON on ARM32 for a very long time. The commit you're
referring is about AArch64, and yes, support for ARM64 NEON is patchy at
the moment, but it's progressing quite quickly. What back-end are you
trying to use? 32-bits or 64-bits?

I also tried compiling LLVM 2.9 + llvm-gcc but that failed too many times
> and I gave up. After some discussions with colleagues (notably Alberto
> Magni, who added OpenCL support to clang some time ago
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-November/012293.html) my
> current plan is to implement the ARM NEON intrinsics as a shared library,
> using attributes as in:

LLVM 2.9 is really old, and llvm-gcc is discontinued, so I wouldn't even
try that. If you don't want to use trunk, I recommend you to use LLVM with
Clang 3.3 and see what you get.

typedef float float4 __attribute__((ext_vector_type(4)));
> or if that doesn't work, I will try to implement the intrinsics in clang
> itself (not sure this is the best way of doing it).
> Ideally, I want to be able to compile C code that includes ARM NEON
> intrinsics to other targets (TI processors, e.g.).

So, if I get it right, you have a file with ARM NEON intrinsics (the ones
defined in arm_neon.h) and passed it through LLVM 2.9 with LLVM-GCC
front-end and failed.

As of 2010, LLVM can compile every single NEON instruction, but you should
use LLVM's own version of arm_neon.h, since the type definitions do vary
between toolchains. In the end, they amount to the same thing on each
toolchain, but their representation can be different.

I suggest you try with Clang 3.3 and if that fails, we'll start from there.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130926/f2608d17/attachment.html>

More information about the llvm-dev mailing list