This is the mail archive of the gcc@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: Using the asm suffix


Thank you for the review and comments.

On 8/17/2015 3:41 AM, Segher Boessenkool wrote:
On Sun, Aug 16, 2015 at 06:33:40PM -0700, David Wohlferd wrote:
  On systems where an underscore is normally prepended to the name of a C
-function or variable, this feature allows you to define names for the
+variable, this feature allows you to define names for the
  linker that do not start with an underscore.
Why remove this?

This doc section (Controlling Names Used in Assembler Code) describes how the asm suffix affects both data and functions. However, it jumbles the two descriptions together.

My intent here is to break this clearly into two @subsubheadings: 'Assembler names for data' and 'Assembler names for functions'. Since data is the first section, I removed the word 'function' here.

  It does not make sense to use this feature with a non-static local
  variable since such variables do not have assembler names.  If you are
  trying to put the variable in a particular register, see @ref{Explicit
-Reg Vars}.  GCC presently accepts such code with a warning, but will
-probably be changed to issue an error, rather than a warning, in the
-future.
+Reg Vars}.
And this?

Vague statements about possible changes that may or not ever be written are not helpful in docs. In this case the statement is particularly unhelpful since even the warning appears to be gone.

+To specify the assember name for functions, write a declaration for the
                         ^ typo

Some typos are more embarrassing than others.

+function before its definition and put @code{asm} there, like this:
+
  @smallexample
-extern func () asm ("FUNC");
-
-func (x, y)
-     int x, y;
-/* @r{@dots{}} */
+extern int func (int x, int y) asm ("MYFUNC");
+
+int func (int x, int y)
+@{
+   /* @r{@dots{}} */
  @end smallexample
If you want to modernise the code, drop "extern" as well?  :-)

Ok.

-Also, you must not use a
-register name; that would produce completely invalid assembler code.  GCC
-does not as yet have the ability to store static variables in registers.
-Perhaps that will be added.
And why remove these?

Again with the vague statements about possible future changes. Also, whether or not static variables can be stored in registers has nothing to do with Asm Labels. If this is still true, it belongs in Explicit Reg Vars.

Update attached.

dw
Index: extend.texi
===================================================================
--- extend.texi	(revision 226751)
+++ extend.texi	(working copy)
@@ -8367,8 +8367,14 @@
 
 You can specify the name to be used in the assembler code for a C
 function or variable by writing the @code{asm} (or @code{__asm__})
-keyword after the declarator as follows:
+keyword after the declarator.
+It is up to you to make sure that the assembler names you choose do not
+conflict with any other assembler symbols.
 
+@subsubheading Assembler names for data:
+
+This sample shows how to specify the assembler name for data:
+
 @smallexample
 int foo asm ("myfoo") = 2;
 @end smallexample
@@ -8379,33 +8385,30 @@
 @samp{_foo}.
 
 On systems where an underscore is normally prepended to the name of a C
-function or variable, this feature allows you to define names for the
+variable, this feature allows you to define names for the
 linker that do not start with an underscore.
 
 It does not make sense to use this feature with a non-static local
 variable since such variables do not have assembler names.  If you are
 trying to put the variable in a particular register, see @ref{Explicit
-Reg Vars}.  GCC presently accepts such code with a warning, but will
-probably be changed to issue an error, rather than a warning, in the
-future.
+Reg Vars}.
 
-You cannot use @code{asm} in this way in a function @emph{definition}; but
-you can get the same effect by writing a declaration for the function
-before its definition and putting @code{asm} there, like this:
+@subsubheading Assembler names for functions:
 
+To specify the assembler name for functions, write a declaration for the 
+function before its definition and put @code{asm} there, like this:
+
 @smallexample
-extern func () asm ("FUNC");
-
-func (x, y)
-     int x, y;
-/* @r{@dots{}} */
+int func (int x, int y) asm ("MYFUNC");
+     
+int func (int x, int y)
+@{
+   /* @r{@dots{}} */
 @end smallexample
 
-It is up to you to make sure that the assembler names you choose do not
-conflict with any other assembler symbols.  Also, you must not use a
-register name; that would produce completely invalid assembler code.  GCC
-does not as yet have the ability to store static variables in registers.
-Perhaps that will be added.
+@noindent
+This specifies that the name to be used for the function @code{func} in
+the assembler code should be @code{MYFUNC}.
 
 @node Explicit Reg Vars
 @subsection Variables in Specified Registers

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