This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [DOC Patch] Add sample for @cc constraint


On 4/25/2016 2:51 AM, Bernd Schmidt wrote:
On 04/16/2016 01:12 AM, David Wohlferd wrote:
There were  basically 3 changes I was trying for in that doc patch. Are
any of them worth keeping?  Or are we done?

1) "Do not clobber flags if they are being used as outputs."
2) Output flags sample (with #if removed).
3) "On the x86 platform, flags are always treated as clobbered by
extended asm whether @code{"cc"} is specified or not."

I'm prepared to send an updated patch if there's anything here that
might get approved.

I think the updated flags sample would be nice to have.

Attached.

dw
Index: extend.texi
===================================================================
--- extend.texi	(revision 235054)
+++ extend.texi	(working copy)
@@ -8135,6 +8135,26 @@
 ``not'' @var{flag}, or inverted versions of those above
 @end table
 
+This example uses the @code{bt} instruction (which sets the carry flag) to
+see if bit 0 of an integer is set.  To see the improvement in the generated
+output, make sure optimizations are enabled.
+
+@example
+void TestEven (int value)
+@{
+  char CarryIsSet;
+
+  asm ("bt $0, %[value]"
+    : "=@@ccc" (CarryIsSet)
+    : [value] "rm" (value));
+
+  if (CarryIsSet)
+    printf ("odd\n");
+  else
+    printf ("even\n");
+@}
+@end example
+
 @end table
 
 @anchor{InputOperands}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]