]> git.ipfire.org Git - thirdparty/gcc.git/commit
inline-asm: Add support for cc operand modifier
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Dec 2024 10:49:11 +0000 (11:49 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 Dec 2024 10:49:11 +0000 (11:49 +0100)
commit74d6a676034b3ab20c387f12f19f5597e4f1c9fa
tree1b48bb12b2b38783b208a432d6c132b055578e22
parentc7f725cd8d8e418818a8283fd5ef393a977753d5
inline-asm: Add support for cc operand modifier

As mentioned in the "inline asm: Add new constraint for symbol definitions"
patch description, while the c operand modifier is documented to:
Require a constant operand and print the constant expression with no punctuation.
it actually doesn't do that with -fpic at least on some targets and
has been behaving that way for at least 3 decades.
It prints the operand using output_addr_const if CONSTANT_ADDRESS_P is true,
but CONSTANT_ADDRESS_P can do all sorts of target specific checks.
And if it is false, it falls back to output_operand (operands[opnum], 'c');
which will on various targets just result in an error that it is invalid
modifier letter (weird because it is documented), on others like x86 or
alpha will handle the operand in some weird way if it is a comparison
and otherwise complain the argument isn't a comparison, on others like
arm perhaps do what the user wanted.

As I wrote, we are pretty much out of modifier letters because some targets
use a lot of them, and almost out of % punctuation chars (I think ` is left)
but right now punctuation chars aren't normally followed by operand number
anyway.

So, the following patch takes one of the generic letters (c) and adds an
extra modifier char after it, I chose cc, which behaves like c but just
always uses output_addr_const instead of falling back to the machine
dependent code.

2024-12-18  Jakub Jelinek  <jakub@redhat.com>

* final.cc (output_asm_insn): Add support for cc operand modifier.
* doc/extend.texi (Generic Operand Modifiers): Document cc operand
modifier.
* doc/md.texi (@samp{:} in constraint): Mention the cc operand
modifier and add small example.

* c-c++-common/toplevel-asm-4.c: Don't use -fno-pie option.
Use cc modifier instead of c.
(v, w): Add extern keyword.
* c-c++-common/toplevel-asm-6.c: New test.
gcc/doc/extend.texi
gcc/doc/md.texi
gcc/final.cc
gcc/testsuite/c-c++-common/toplevel-asm-4.c
gcc/testsuite/c-c++-common/toplevel-asm-6.c [new file with mode: 0644]