https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90181
Segher Boessenkool <segher at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Last reconfirmed| |2019-04-20 CC| |segher at gcc dot gnu.org Resolution|WONTFIX |--- Ever confirmed|0 |1 --- Comment #4 from Segher Boessenkool <segher at gcc dot gnu.org> --- (In reply to nfxjfg from comment #0) > Currently, inline assembler constraints have no way to select an explicitly > named register. Apparently you're supposed to use register variables. There > is even text that register variables exist only for this use case. That is not what it says. Originally a local register variable lived in the specified register always. This quickly was found out to not really work. After many years it was finally documented as just not supported for anything but assembler operands. Hopefully it will actually do *only* this in the not too far future. We should be able to make (almost) all gotchas here magically disappear. > For example, suppose you want to pass something through the register a7 on > the RISC-V platform. You need to do: > > void call_ecall(size_t num) > { > register size_t r_a7 __asm("a7") = num; > __asm volatile("ecall" : : "r" (r_a7) : "memory"); > } > > This gets awkward fast. It adds a lot of extra noise if you have many > registers to pass (the ecall instruction provides an example where this may > be needed). Does the riscv port not have a builtin for this? > The semantics are also not entirely clear: will r_a7 occupy the a7 register > for the entire function It does not matter: you are only allowed to pass it to the asm, and nothing else is defined behaviour. > void call_ecall(size_t num) > { > __asm volatile("ecall" : : "a7" (num) : "memory"); > } Because a7 is not a constraint. It also cannot *be* one, in general; for example, many archs have a register "r0" but the constraint "r0" already means something else. So we need some new syntax for this. I suggested "*a7" before. Confirmed. It's a reasonable request, and it is a feature that would make GCC better, and isn't too hard to define or implement. Reopening.