md.texi (386 constraints): Clarify A constraint documentation.
authorRichard Guenther <rguenther@suse.de>
Tue, 23 Nov 2010 15:15:50 +0000 (15:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 23 Nov 2010 15:15:50 +0000 (15:15 +0000)
2010-11-23  Richard Guenther  <rguenther@suse.de>

* doc/md.texi (386 constraints): Clarify A constraint documentation.

From-SVN: r167081

gcc/ChangeLog
gcc/doc/md.texi

index 09053c37400299611b093bfd38b89578b199d9a8..9fcd937962810f7bc5b924983e368ace16703964 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-23  Richard Guenther  <rguenther@suse.de>
+
+       * doc/md.texi (386 constraints): Clarify A constraint documentation.
+
 2010-11-23  Basile Starynkevitch  <basile@starynkevitch.net>
            Jeremie Salvucci  <jeremie.salvucci@free.fr>
 
index bdf42f17986f3ba699543965a42224e72e4d4da4..677ea02b6e59bb74bc3dababa4077787536353a9 100644 (file)
@@ -2101,8 +2101,32 @@ The @code{si} register.
 The @code{di} register.
 
 @item A
-The @code{a} and @code{d} registers, as a pair (for instructions that
-return half the result in one and half in the other).
+The @code{a} and @code{d} registers.  This class is used for instructions
+that return double word results in the @code{ax:dx} register pair.  Single
+word values will be allocated either in @code{ax} or @code{dx}.
+For example on i386 the following implements @code{rdtsc}:
+
+@smallexample
+unsigned long long rdtsc (void)
+@{
+  unsigned long long tick;
+  __asm__ __volatile__("rdtsc":"=A"(tick));
+  return tick;
+@}
+@end smallexample
+
+This is not correct on x86_64 as it would allocate tick in either @code{ax}
+or @code{dx}.  You have to use the following variant instead:
+
+@smallexample
+unsigned long long rdtsc (void)
+@{
+  unsigned int tickl, tickh;
+  __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh));
+  return ((unsigned long long)tickh << 32)|tickl;
+@}
+@end smallexample
+
 
 @item f
 Any 80387 floating-point (stack) register.