arc: Do not pass -mcode-density to the assembler with -mno-code-density#271
Open
luismgsilva wants to merge 2 commits into
Open
arc: Do not pass -mcode-density to the assembler with -mno-code-density#271luismgsilva wants to merge 2 commits into
luismgsilva wants to merge 2 commits into
Conversation
luismgsilva
commented
Jun 16, 2026
Member
Member
Author
|
This patch fixes the original issue reported in #253 |
66b4214 to
cc0cdec
Compare
This reverts commit 20158a7.
cc0cdec to
9f30dfa
Compare
9f30dfa to
ad4017e
Compare
For ARC EM CPUs that enable code density by default, cpu_to_as adds
-mcode-density to the assembler command line. When the user passes
-mno-code-density, the compiler disables the extension, but cpu_to_as
still requested -mcode-density for those CPUs. The GNU assembler only
has a positive -mcode-density option and no way to disable the
extension from the command line, so the driver must omit -mcode-density
instead of forwarding the user's -mno-code-density flag.
Pass a no-cd marker from ASM_SPEC when -mno-code-density is given, and
have cpu_to_as parse it from the spec function arguments and suppress
the default -mcode-density request. Explicit -mcode-density continues
to be forwarded by %{mcode-density}. The assembler now uses the
instruction encoding that matches whether code density is enabled or
disabled.
For example, with -mcpu=em4_dmips the driver invokes the assembler as:
gcc ... -mcpu=em4_dmips -c test.c
-> as ... -mcpu=arcem -mcode-density ...
With -mno-code-density, it used to make no difference:
gcc ... -mcpu=em4_dmips -mno-code-density -c test.c
-> as ... -mcpu=arcem -mcode-density ...
and now correctly omits -mcode-density:
gcc ... -mcpu=em4_dmips -mno-code-density -c test.c
-> as ... -mcpu=arcem ...
Assembling the same test program shows different instruction encodings
in the object file, for example:
$ gcc -c test.c -mcpu=em4_dmips
$ objdump -d test.o
4: 4104 ld_s r1,[r0,0]
10: 4004 ld_s r0,[r0,0]
versus:
$ gcc -c test.c -mcpu=em4_dmips -mno-code-density
$ objdump -d test.o
4: 8020 ld_s r1,[r0,0]
10: 8000 ld_s r0,[r0,0]
gcc/ChangeLog:
* config/arc/arc.h (ASM_SPEC): Pass a no-cd marker to cpu_to_as
when -mno-code-density is given.
* config/arc/driver-arc.cc (arc_cpu_to_as): Parse the marker and
the optional -mcpu name from the spec arguments; do not request
-mcode-density from the assembler when the marker is present.
Signed-off-by: Luis Silva <luis.silva@globalfoundries.com>
61c48ef to
2fc37c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.