armclang:error: couldn't allocate output register for constraint 'w', but pass with GCC

498 Views Asked by At

I have an inline assembler code, and passed with arm-none-eabi-gcc, compiled error with armclang. Here is the sample code:

//wrong-reg.c

#include <stdio.h>
#include <stdint.h>

#define __asm__ asm volatile
float __vabs(const float a) {
    //VABS{cond}.F32 Sd, Sm 
    float result;
    __asm volatile("vabs.f32 %0, %1" : "=w"(result) : "w"(a):);
    return result;
}

int __vcvta_s32(float a) {
    int result;
    __asm volatile("vcvta.s32.f32 %0, %1" : "=w"(result) : "w"(a):);
    return result;
}

int main(int argc, char *argv[])
{
    const uint8_t n4 = __vcvta_s32(__vabs(1 - 32.f / 100.0) * 100.0);

    printf("now n4 is %d", n4);
    return 0;
}

compiled with:

armclang --target=arm-arm-none-eabi -mcpu=cortex-m55 -O2 -g -c -mfpu=fp-armv8-fullfp16-sp-d16 wrong-regs.c -o wrong-regs.o

error:

wrong-regs.c:17:17: error: couldn't allocate output register for constraint 'w'
        __asm volatile("vcvta.s32.f32 %0, %1" : "=w"(result) : "w"(a):);

with gcc:

arm-none-eabi-gcc -mcpu=cortex-m55 -march=armv8.1-m.main+mve.fp+fp.dp -mfloat-abi=hard --specs=rdimon.specs -mfpu=auto -g -O2 wrong-regs.c -o wrong-regs-gcc

the result is okay.

armclang --version

Product: Arm Compiler for Embedded 6.17 Professional
Component: Arm Compiler for Embedded 6.17

arm-none-eabi-gcc --version

arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release)
0

There are 0 best solutions below