Using inline NEON code
Carsten Haitzler (The Rasterman)
raster at rasterman.com
Thu Dec 2 23:56:57 UTC 2010
On Fri, 3 Dec 2010 10:49:29 +1300 Michael Hope <michael.hope at linaro.org> said:
> Hi there. Currently you can't use NEON instructions in inline
> assembly if the compiler is set to -mfpu=vfp such as Ubuntu's
> -mfpu=vfpv3-d16. Trying code like this:
> int main()
> asm("veor d1, d2, d3");
> return 0;
> gives an error message like:
> test.s: Assembler messages:
> test.s:29: Error: selected processor does not support Thumb mode `veor
> The problem is that -mfpu=vfpv3-d16 has two jobs: it tells the
> compiler what instructions to use, and also tells the assembler what
> instructions are valid. We might want the compiler to use the VFP for
> compatibility or power reasons, but still be able to use NEON
> instructions in inline assembler without passing extra flags.
> Inserting ".fpu neon" to the start of the inline assembly fixes the
> problem. Is this valid? Are assembly files with multiple .fpu
> statements allowed? Passing '-Wa,-mfpu=neon' to GCC doesn't work as
> gas seems to ignore the second -mfpu.
> What's the best way to handle this? Some options are:
> * Add '.fpu neon' directives to the start of any inline assembly
> * Separate out the features, so you can specify the capabilities with
> one option and restrict the compiler to a subset with another.
> Something like '-mfpu=neon -mfpu-tune=vfpv3-d16'
> * Relax the assembler so that any instructions are accepted. We'd
> lose some checking of GCC's output though.
relax dude... relax... :) (that was a vote for relaxing the output - if i stick
some neon asm in my code.. i expect the assembler to do as commanded and punt
out that asm just as instructed and not try and tell me what versions of the
machine instruction set may or may not be valid based on the C compilers
optimisation flags. if i'm dropping to asm.. i'm doing so because "i know
better" than the C compiler)
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster at rasterman.com
More information about the linaro-toolchain