This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53354] New: %z# asm specifier could be extended to support immediate constraints
- From: "svfuerst at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 May 2012 01:19:12 +0000
- Subject: [Bug c/53354] New: %z# asm specifier could be extended to support immediate constraints
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53354
Bug #: 53354
Summary: %z# asm specifier could be extended to support
immediate constraints
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: svfuerst@gmail.com
It would be nice if %z# would work with immediate asm constraints:
void foo(void)
{
#if 1
int x = 1;
asm("mov%z0 %0, bar":: "r" (x));
#else
asm("mov%z0 %0, bar":: "i" (1));
#endif
}
The first option isn't optimal as an extra register is needed. If the second
is tried, gcc exits with "error: invalid 'asm': invalid operand type used with
operand code 'z'"
Typically, to work around this, people use a switch statement based on the size
of the immediate, and manually copy the code for sizes of 1, 2, 4, 8 byte
registers. It would be simpler if the bulky switch statements weren't
necessary.