public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/43112] New: 'A' constraint's behavior not compliant with doc under x86-64
@ 2010-02-18 5:59 zuxy dot meng at gmail dot com
2010-02-18 8:56 ` [Bug inline-asm/43112] " jakub at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: zuxy dot meng at gmail dot com @ 2010-02-18 5:59 UTC (permalink / raw)
To: gcc-bugs
According to "info gcc", the 'A' constraint denotes the `a' and `d'
registers, as a pair (for instructions that return half the result in
one and half in the other). However, in reality 'A' is treated simply as
a 64-bit long integer in %rax under x86-64. For example, the following
code piece:
#include <stdint.h>
uint64_t rdtsc(void)
{
uint64_t ret;
asm ("rdtsc":"=A"(ret));
return ret;
}
produces:
[zuxy@Rainbow31 bin]$ objdump -d a.o
a.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <rdtsc>:
0: 0f 31 rdtsc
2: c3 retq
--
Summary: 'A' constraint's behavior not compliant with doc under
x86-64
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zuxy dot meng at gmail dot com
GCC build triplet: x86_64-redhat-linux
GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43112
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug inline-asm/43112] 'A' constraint's behavior not compliant with doc under x86-64
2010-02-18 5:59 [Bug inline-asm/43112] New: 'A' constraint's behavior not compliant with doc under x86-64 zuxy dot meng at gmail dot com
@ 2010-02-18 8:56 ` jakub at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-02-18 8:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jakub at gcc dot gnu dot org 2010-02-18 08:56 -------
You just misunderstand it. You'd need a 128-bit int __attribute__((mode (TI)))
value if you want it to mean a pair, because for -m64 registers are 64-bit.
If you use smaller precision type, "A" constraint acts just as a constraint
allowing both ax and dx registers and it is up to the compiler which one it
chooses.
rdtsc returns result in %eax and %edx, even for 64-bit code, so you need to use
unsigned int low, high;
"=a" (low), "=d" (high)
and then combine that into a 64-bit value.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43112
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-18 8:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-18 5:59 [Bug inline-asm/43112] New: 'A' constraint's behavior not compliant with doc under x86-64 zuxy dot meng at gmail dot com
2010-02-18 8:56 ` [Bug inline-asm/43112] " jakub at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).