This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Aarch64 llvm unrecognized instruction mnemonic

I am trying to use ARM inline assembly in a C code. I am compiling using aarch64-linux-android-clang version 3.8.243773, the 64 bit llvm toolchain from Android NDK R11.

The inline assembly code is as follows:

__asm__("ssat %w0, #24, %w1\n\t" : "=r" (val) : "r" (val) : );

The syntax of inline assembly code is correct and it compiles the syntax code as such but the assembler spits out a error saying

error: unrecognized instruction mnemonic ssat

What is the problem here? Doesn't llvm from the ndk toolchain support this assembly instruction?

How can I fix or workaround this issue?

thanks.

  • Hi ajitsdeshpande

    I have moved your question to ARM Processors where I think you'll get your answer.

  • Hello,

    You're assembling AArch64 code, but SSAT is an AArch32 instruction. You'll need to rewrite this to be using AArch64 instructions.

    Hope that helps,

    Ash

  • Hello Ash,

    When i see the ARM DUI 0802A, which is armasm reference guide for all general instructions available for A64, and there is strangely no Saturation instruction, there is a saturation instruction for Advanced SIMD Vector (Neon) but thats not what i am looking to do?

    Any pointers, workarounds?

  • They dropped all the DSP type instructions operating on the general registers when going to the 64 bit instruction set. There's equivalent type instructions for SIMD or else you have to just code using a few register general register instructions - or just use C. If going the SIMD route it may well be worthwhile trying out the NEON intrinsics instead which will work on both.

  • daith

    Dropping DSP type instructions in an advanced architecture as Aarch64 is a bit strange, and inefficient in my opinion.

    I am trying to write a small macro which saturates input to 24 bits , using inline assembly on ARM. This is accessed from non-Neon code as well,

    Secondly,  I have a feeling that writing Neon for that would have its own overhead of data transfer from ARM to Neon and back, and that might negate out the benefit if any of Neon operation.

    Can i ask you for some inputs on what ARM general code/instructions could do the job of saturating a 32 bit int to 24 bits?

    The C macro i use is:

    (((x) < (int32_t)0xff800000L)? (int32_t)0xff800000L : ((x) \

                         > (int32_t)0x007fffffL) ? (int32_t)0x007fffffL : (x))

    thank you.

  • NEON is not like AVX or MMX, you do not need to "move" to NEON. Just use NEON instructions.
    Anyway AFAICS NEON does not provide saturation either.
    I think the ASM code does not look to bad:
    mov w1, 8388607
    mov w2, -8388608
    cmp w0, w1
    csel w0, w0, w1, le
    cmp w0, w2
    csel w0, w0, w2, ge

    Of course, nothing compared to a single instruction. :-)