This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [DOC Patch] Add sample for @cc constraint
- From: David Wohlferd <dw at LimeGreenSocks dot com>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>, Sandra Loosemore <sandra at codesourcery dot com>, David Wohlferd <dw at LimeGreenSocks dot com>
- Date: Mon, 25 Apr 2016 17:16:33 -0700
- Subject: Re: [DOC Patch] Add sample for @cc constraint
- Authentication-results: sourceware.org; auth=none
- References: <56E4E5D6 dot 4030500 at LimeGreenSocks dot com> <56F40103 dot 8080600 at redhat dot com> <56F85899 dot 4010201 at LimeGreenSocks dot com> <56FA6B82 dot 9080308 at redhat dot com> <56FF06A7 dot 8040900 at LimeGreenSocks dot com> <570C29F9 dot 5080305 at LimeGreenSocks dot com> <570CF2C2 dot 1000108 at redhat dot com> <5711756E dot 4000603 at LimeGreenSocks dot com> <571DE898 dot 4020905 at redhat dot com>
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}