Xcode Arm vector assembly error

Every time a (valid) vector instruction is added to the .s file, xcode report an error (without vector instruction the .s file compile correctly) By example

 vand q8, q8, q10

found in https://developer.apple.com/forums/thread/104424 give an error

What I am missing to tell xcode to accept vector instruction ?

Answered by Alain_B in 818683022

(At least, that is the intention.)

Not sure is the best way...

I think most user want a regular immediate...

I really appreciate you help. Thank you very much.

give an error

What's the error?

..../sources/qs_arm.s Command CompileC failed with a nonzero exit code

..../sources/qs_arm.s Command CompileC failed with a nonzero exit code

Other way to get more explicit detail ?

Surely there is more than that in the build log!

"Compile qs_arm.s (arm64)328"CompileC /Users/alain/Library/Developer/Xcode/DerivedData/QS-cibiavwrwfecqvgtkmfwdqiatgoh/Build/Intermediates.noindex/QS.build/Debug/QS.build/Objects-normal/arm64/qs_arm.o /Users/alain/Desktop/QS_univ/sources/qs_arm.s normal arm64 assembler-with-cpp com.apple.compilers.llvm.clang.1_0.compiler (in target 'QS' from project 'QS')c45c92378389c641^755897378389c641^-190"/Users/alain/Desktop/QS_univ/sources/qs_arm.s:159:2:

error: unrecognized instruction mnemonic, did you mean: and, ands?

vand q8, q8, q10 ^

Command CompileC failed with a nonzero exit code 1(21%IDEActivityLogMessage5@48"Command CompileC failed with a nonzero exit code-

Ugh, I started to reply but it disappeared...

I think vand is the wrong syntax. Maybe it's a 32- vs. 64-bit thing? I think that the correct, current, syntax is just AND with the vector width indicated by the register names. See e.g. https://developer.arm.com/documentation/ddi0596/2021-03/SIMD-FP-Instructions/AND--vector---Bitwise-AND--vector--?lang=en

Yes! The correct syntax is:

and v8.8b, v8.8b, v10.8b

On other hand do you know (I am just curious) why ARM does "and immediate" so restricted ? By example the assembler accept

add x2,x1,#32

but reject

and x2,x1,#22

Thank you very much.

do you know (I am just curious) why ARM does "and immediate" so restricted ?

ADD takes a regular 12-bit immediate.

AND also has 12 (or 13?) bits in the instruction for the immediate value, but they are not a regular binary value; they encode a 32- or 64-bit value using a scheme that makes them better at representing the sort of bit patterns you more often need with logical instructions. (At least, that is the intention.) In the earliest ARM instruction sets the format was a a few literal bits and a shift; the current scheme seems more complicated. But 22 (10110) is not one of the patterns that can be represented.

Here's a random page with a description:

https://dinfuehr.github.io/blog/encoding-of-immediate-values-on-aarch64/

Scroll down to "logical immediates".

The same guy has enumerated all the supported values, which is quite interesting and a bit hypnotic to scroll through: https://gist.github.com/dinfuehr/51a01ac58c0b23e4de9aac313ed6a06a

Accepted Answer

(At least, that is the intention.)

Not sure is the best way...

I think most user want a regular immediate...

I really appreciate you help. Thank you very much.

Xcode Arm vector assembly error
 
 
Q