Closed abrodkin closed 1 year ago
For some reason combination of -mcpu=hs58
and -mno-ll64
doesn't work as expected. Adding -mno-ll64
has no effect and compiler continue to put ldd/std instructions. Does compiler handle option -mno-ll64
?
At the same time combination of -mcpu=hs5x
and -mll64
works as expected.
For some reason combination of
-mcpu=hs58
and-mno-ll64
doesn't work as expected. Adding-mno-ll64
has no effect and compiler continue to put ldd/std instructions. Does compiler handle option-mno-ll64
? At the same time combination of-mcpu=hs5x
and-mll64
works as expected.
How do you tell if -mno-ll64
works or not? Just grepping the vmlinux
disassembly? I guess some ldd
/std
come from assembly code, thus the compiler option doesn't affect that part. But if you count a number of ldd
/std
instructions with -mcpu=hs58
vs -mcpu=hs58 -mno-ll64
I expect that you'll see the difference.
Yes, I see ldd/std
instructions in the vmlinux
disassembly (C functions like start_kernel
, mount_root
and others), even without option CONFIG_ARC_HAS_LL64. I talk about situation after my change in Makefile from current -mcpu=hs5x to -mcpu=hs58.
I've also checked combination of -mcpu=hs58 -mno-ll64
on simple C program:
#include <stdio.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
uint64_t value = 0x100000001ull;
printf("64-bit value %llx", value);
return 0;
}
arc32-linux-gcc -mcpu=hs58 -mno-ll64 ldd_test.c -o ldd_test
And I see than -mno-ll64
option has no effect. With option -mcpu=hs58
compiler puts ldd/std
instructions with and without -mno-ll64
.
Compiler for archs with -mcpu=hs38
doesn't have this issue and option -mno-ll64
works as expected.
I've been using latest ARC 2022.09 toolchain for arc32.
@claziss, can you please also look?
So, if this issue be confirmed, I want offer to use combination of -mcpu=hs5x
and -mll64
in Makefile for ARCv3 32 Linux kernel to workaround it.
For hs58
cpu the ll64 is enabled by default and cannot be turned off, as the compiler will use the ll64 optimized libraries. If you don't want ll64 option on, please use the default hs5x
.
@claziss, thank you for your comment.
Is there another difference between use of -mcpu=hs5x
and -mcpu=hs58
or just ll64? What is preferable?
I'm going to use -mcpu=hs5x
+ -mll64
to enable ll64.
@pavelvkozlov not yet, but we may choose to grow this difference. More info here: https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/blob/arc-dev/doc/baremetal/gcc-mcpu.rst And I think your solution is the right one.
Thanks to all for comments. I've created PR #106. To provides correct logic for HS5x, I had to add extra conditions. Now ldd/std instructions appear as expected. @abrodkin please take a look. Is it ok?
Merged. Commit: c8444e0
GCC for 32-bit ARCv3 processors supports 2
mcpu
values:hs5x
&hs58
. With the only difference ofhs58
supporting dual loads/stores (AKAldd
,std
,llockd
&scondd
instructions) whilehs5x
doesn't. See https://foss-for-synopsys-dwc-arc-processors.github.io/toolchain/baremetal/gcc-mcpu.html#arcv3-toolchain. I.e.-mcpu=hs58
is exactly the same as-mcpu=hs5x -mll64
, or in reverse-mcpu=hs5x
is exactky the same as-mcpu=hs58 -mno-ll64
.Now in our current Linxu port for ARCv3 we have by default
-mcpu=hs5x
and...I.e. if in the kernel configuration we unset
CONFIG_ARC_HAS_LL64
then-mno-ll64
is used, while n case of enabledCONFIG_ARC_HAS_LL64
nothing really happens. Which means effectively dual loads/stores are not used now at all.But given reverse logic of
CONFIG_ARC_HAS_LL64
processing is still used for ARCv2, we don't want to change that. Thus leaves us just one option - switching-mcpu
to the one which enables dual loads/stores by default. So, let's finally do it.