[Bug c++/56715] Explicit Reg Vars are being ignored for consts when using g++
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 25 08:50:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56715
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-25 08:50:15 UTC ---
Simply don't use const on the register asm vars for C++. The thing is that
already the C++ frontend is replacing all the r4 const var uses with just
0x1000 (i.e. the initializer), that isn't really an optimization, but part of
C++ semantics. r4 is an integral constant expression that evaluates to 0x1000.
See
ISO C++ 98, [expr.const]/1. So in foo what you are doing is actually
void foo() {
register const int r4 asm("r4") = 0x1000;
asm volatile("swi #1" : : "r"(0x1000));
}
and that of course can use any available register.
More information about the Gcc-bugs
mailing list