with my poor knowledge, It may be weird to say "I want to check the assembly code because I wonder if the FPU in processor is enabled with my C code."
Actually I have things like floating point operation that be done with Xilinx Zynq Ultrascale board. and I found it has Cortex-A53 processor in APU, and it also has FPU in it. so, I want to enable FPU to use for floating point operation.
First, I have to check if the FPU in Cortex-A53 is enabled, but I just found that aarch64 compiles the code with FPU with no gcc compile options, just by default.
so I just write the C code(file name is "test.c") and compile the code with the command line "gcc -S test.c" to get the assembly code(I don't know exactly what the assembly code means)
because I read that the FPU in Cortex-A53 supports VFP instructions, like VADD, VDIV, VMLS..whatever with 'V~~'
but I couldn't find the VFP instructions I just want to know what kind of code use VFP instructions in C. want to get the explicit examples like "you should just write and complie the code like float a = 1.11; a 3.14~~ then, you can see the VFP instructions in assembly code with that"
Which code in C I can use to see VFP instructions in assembly?
and just one more thing.. Is it a right way I can check the FPU is enabled? If it is wrong, how can I enable FPU in Cortex-A53 and How can I check if it is enabled? How can I run the codes with FPU?
CodePudding user response:
It's a long description, but still lack a lot of information.
Xilinx Zynq Ultrascale is ARMv8 core which could run in 32bit mode or 64bit mode. So there are two type of toolchain for each mode, there are some differents in compilation flags.
For 32b mode -mfpu=neon
should do, refer ARM options
For 64b mode 'advanced simd' is mandatory, so no command line option is needed. Still you might want to enable auto vectorization optimisations with -O3
or -O2 -ftree-vectorize
, otherwise compiler might not bother to use simd.
Is it a right way I can check the FPU is enabled? If it is wrong, how can I enable FPU in Cortex-A53 and How can I check if it is enabled? How can I run the codes with FPU?
Out of head, there is a bit in some fpu state register that indicates if it's enabled. You did not tell if you work baremetal or under OS. Access to such registers might not be available from 'user mode' when apps run under OS. Simple way is always to run some fpu command like vadd
inside asm volatile(...)
for example, if fpu not enabled/supported, you get exception.