21

I'm trying to build ios project for $(ARCHS_STANDARD_32_BIT) architecture - armv7 for the latest iOS (iOS 7.0) and I've got the following error:

Unknown register name 'q0' in asm

in function

static void neon_asm_mat4_vec4_mul(const float* __restrict m, const int* __restrict v, int* __restrict output)
      {
        asm volatile
        (
         // Store m & v - avoiding q4-q7 which need to be preserved - q0 = result
         "vldmia %1, { q8-q11 } \n\t"   // q8-q11 = m
         "vldmia %2, { q1 }     \n\t"   // q1     = v

         // Convert v to floats
         "vcvt.f32.s32 q1, q1 \n\t"

         // result = first column of A x V.x
         "vmul.f32 q0, q8, d2[0] \n\t"

         // result += second column of A x V.y
         "vmla.f32 q0, q9, d2[1] \n\t"

         // result += third column of A x V.z
         "vmla.f32 q0, q10, d3[0] \n\t"

         // result += last column of A x V.w
         "vmla.f32 q0, q11, d3[1] \n\t"

         // convert to integer
         "vcvt.s32.f32 q0, q0 \n\t"

         // output = result registers
         "vstmia %0, { q0 }  \n\t"

         : // no output
         : "r" (output), "r" (m), "r" (v)      // input - note *value* of pointer doesn't change
         : "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11" //clobber
         );
      }

Could you please help me to either update my code so it can be built for the latest hardware or simply configure build settings differently. I'm new to iOS development, so I'm kind of lost...

Pavel Podlipensky
  • 8,201
  • 5
  • 42
  • 53
  • possible duplicate of [Unknown register name "q0" in asm (arm64)](http://stackoverflow.com/questions/19984307/unknown-register-name-q0-in-asm-arm64) – Paul R Feb 02 '14 at 11:52
  • @PaulR I saw another question related to this topic, but the answer state "you need to re-write this code". Smart, but I still have no idea how to fix it! – Pavel Podlipensky Feb 02 '14 at 19:39
  • Also I'm building for 32bit hardware... at least `$(ARCHS_STANDARD_32_BIT)` this is how I see it. – Pavel Podlipensky Feb 02 '14 at 19:40
  • Also see [Error: invalid use of vector register at operand 1](http://stackoverflow.com/q/38551637). It works though some of the GCC Extended ASM issues you are experiencing. And take a look at [ARM machine constraints](http://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html) because you might need a "t" or "w" instead of "r". – jww Jul 27 '16 at 20:53

2 Answers2

47

try changing in neon_matrix_impl.c and mat4.c
#if defined(ARM_NEON)
to
#if defined(_ARM_ARCH_7)

caraie
  • 1,094
  • 7
  • 18
  • 7
    I found I had to change this is two files: neon_matrix_impl.c and mat4.c . – elprl Mar 22 '14 at 15:49
  • What changes you have made? – Jag Apr 01 '14 at 01:32
  • You seem to be mixing and matching... NEON is nearly ubiquitous with ARMv7 and ARMv8. Changing `__ARM_NEON__` to `_ARM_ARCH_7` seems wrong. ***If*** you have an ARM device with NEON available, then you should add `-march=armv7-a -mfpu=neon` to your `CFLAGS` and `CXXFLAGS`. Depending on the flags present in `/proc/cpuinfo`, you might be able to use `-march=armv7-a -mfpu=neon-vfpv4`, which should indicate VFPv4 and 32 D-registers overlapping 16 Q-registers. – jww Jul 27 '16 at 21:22
20

Those who are using Cocos2d 2.1 , modification(#if defined(ARM_NEON) ->#if defined(_ARM_ARCH_7)) is needed in two macros

  1. neon_matrix_impl.c and
  2. mat4.c at line number 218

enter image description here

Actually ARM NEON was used as multimedia rendering engine in iOS devices but now with iOS 7.0 and onwards new rendering engines(ARM ARCH 64 bit) are used.

More details can be obtained from here.

But it was really confusing for me that my Xcode project was perfectly compiled and successfully executed on my iPod Touch (5th generation) with out these modifications.Modification was needed only when i tried to archive my project to submit it on AppStore.

Sauvik Dolui
  • 5,520
  • 3
  • 34
  • 44
  • You seem to be mixing and matching... NEON is nearly ubiquitous with ARMv7 and ARMv8. Changing `__ARM_NEON__` to `_ARM_ARCH_7` seems wrong. ***If*** you have an ARM device with NEON available, then you should add `-march=armv7-a -mfpu=neon` to your `CFLAGS` and `CXXFLAGS`. Depending on the flags present in `/proc/cpuinfo`, you might be able to use `-march=armv7-a -mfpu=neon-vfpv4`, which should indicate VFPv4 and 32 D-registers overlapping 16 Q-registers. – jww Jul 27 '16 at 21:20