Commit d2bfc447 by Martin Sebor Committed by Martin Sebor

extend.texi (optimize): Clarify/expand attribute documentation.

gcc/ChangeLog:

	* doc/extend.texi (optimize): Clarify/expand attribute documentation.
	(target, pragma GCC optimize, pragma GCC target): Ditto.

From-SVN: r265631
parent a2e0398a
2018-10-30 Martin Sebor <msebor@redhat.com>
* doc/extend.texi (optimize): Clarify/expand attribute documentation.
(target, pragma GCC optimize, pragma GCC target): Ditto.
2018-10-30 Jonathan Wakely <jwakely@redhat.com> 2018-10-30 Jonathan Wakely <jwakely@redhat.com>
* doc/extend.texi: Fix prototype and description of * doc/extend.texi: Fix prototype and description of
...@@ -3193,21 +3193,32 @@ the standard C library can be guaranteed not to throw an exception ...@@ -3193,21 +3193,32 @@ the standard C library can be guaranteed not to throw an exception
with the notable exceptions of @code{qsort} and @code{bsearch} that with the notable exceptions of @code{qsort} and @code{bsearch} that
take function pointer arguments. take function pointer arguments.
@item optimize @item optimize (@var{level}, @dots{})
@item optimize (@var{string}, @dots{})
@cindex @code{optimize} function attribute @cindex @code{optimize} function attribute
The @code{optimize} attribute is used to specify that a function is to The @code{optimize} attribute is used to specify that a function is to
be compiled with different optimization options than specified on the be compiled with different optimization options than specified on the
command line. Arguments can either be numbers or strings. Numbers command line. Valid arguments are constant non-negative integers and
are assumed to be an optimization level. Strings that begin with strings. Each numeric argument specifies an optimization @var{level}.
@code{O} are assumed to be an optimization option, while other options Each @var{string} argument consists of one or more comma-separated
are assumed to be used with a @code{-f} prefix. You can also use the substrings. Each substring that begins with the letter @code{O} refers
@samp{#pragma GCC optimize} pragma to set the optimization options to an optimization option such as @option{-O0} or @option{-Os}. Other
that affect more than one function. substrings are taken as suffixes to the @code{-f} prefix jointly
@xref{Function Specific Option Pragmas}, for details about the forming the name of an optimization option. @xref{Optimize Options}.
@samp{#pragma GCC optimize} pragma.
@samp{#pragma GCC optimize} can be used to set optimization options
This attribute should be used for debugging purposes only. It is not for more than one function. @xref{Function Specific Option Pragmas},
suitable in production code. for details about the pragma.
Providing multiple strings as arguments separated by commas to specify
multiple options is equivalent to separating the option suffixes with
a comma (@samp{,}) within a single string. Spaces are not permitted
within the strings.
Not every optimization option that starts with the @var{-f} prefix
specified by the attribute necessarily has an effect on the function.
The @code{optimize} attribute should be used for debugging purposes only.
It is not suitable in production code.
@item patchable_function_entry @item patchable_function_entry
@cindex @code{patchable_function_entry} function attribute @cindex @code{patchable_function_entry} function attribute
...@@ -3361,17 +3372,21 @@ This attribute adds stack protection code to the function if ...@@ -3361,17 +3372,21 @@ This attribute adds stack protection code to the function if
flags @option{-fstack-protector}, @option{-fstack-protector-strong} flags @option{-fstack-protector}, @option{-fstack-protector-strong}
or @option{-fstack-protector-explicit} are set. or @option{-fstack-protector-explicit} are set.
@item target (@var{options}) @item target (@var{string}, @dots{})
@cindex @code{target} function attribute @cindex @code{target} function attribute
Multiple target back ends implement the @code{target} attribute Multiple target back ends implement the @code{target} attribute
to specify that a function is to to specify that a function is to
be compiled with different target options than specified on the be compiled with different target options than specified on the
command line. This can be used for instance to have functions command line. One or more strings can be provided as arguments.
Each string consists of one or more comma-separated suffixes to
the @code{-m} prefix jointly forming the name of a machine-dependent
option. @xref{Submodel Options,,Machine-Dependent Options}.
The @code{target} attribute can be used for instance to have a function
compiled with a different ISA (instruction set architecture) than the compiled with a different ISA (instruction set architecture) than the
default. You can also use the @samp{#pragma GCC target} pragma to set default. @samp{#pragma GCC target} can be used to specify target-specific
more than one function to be compiled with specific target options. options for more than one function. @xref{Function Specific Option Pragmas},
@xref{Function Specific Option Pragmas}, for details about the for details about the pragma.
@samp{#pragma GCC target} pragma.
For instance, on an x86, you could declare one function with the For instance, on an x86, you could declare one function with the
@code{target("sse4.1,arch=core2")} attribute and another with @code{target("sse4.1,arch=core2")} attribute and another with
...@@ -3389,9 +3404,10 @@ int core2_func (void) __attribute__ ((__target__ ("arch=core2"))); ...@@ -3389,9 +3404,10 @@ int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
int sse3_func (void) __attribute__ ((__target__ ("sse3"))); int sse3_func (void) __attribute__ ((__target__ ("sse3")));
@end smallexample @end smallexample
You can either use multiple Providing multiple strings as arguments separated by commas to specify
strings separated by commas to specify multiple options, multiple options is equivalent to separating the option suffixes with
or separate the options with a comma (@samp{,}) within a single string. a comma (@samp{,}) within a single string. Spaces are not permitted
within the strings.
The options supported are specific to each target; refer to @ref{x86 The options supported are specific to each target; refer to @ref{x86
Function Attributes}, @ref{PowerPC Function Attributes}, Function Attributes}, @ref{PowerPC Function Attributes},
...@@ -22404,30 +22420,32 @@ push_macro} and restored by @code{#pragma pop_macro}. ...@@ -22404,30 +22420,32 @@ push_macro} and restored by @code{#pragma pop_macro}.
@subsection Function Specific Option Pragmas @subsection Function Specific Option Pragmas
@table @code @table @code
@item #pragma GCC target (@var{"string"}...) @item #pragma GCC target (@var{string}, @dots{})
@cindex pragma GCC target @cindex pragma GCC target
This pragma allows you to set target specific options for functions This pragma allows you to set target-specific options for functions
defined later in the source file. One or more strings can be defined later in the source file. One or more strings can be
specified. Each function that is defined after this point is as specified. Each function that is defined after this point is treated
if @code{attribute((target("STRING")))} was specified for that as if it had been declared with one @code{target(}@var{string}@code{)}
function. The parenthesis around the options is optional. attribute for each @var{string} argument. The parentheses around
@xref{Function Attributes}, for more information about the the strings in the pragma are optional. @xref{Function Attributes},
@code{target} attribute and the attribute syntax. for more information about the @code{target} attribute and the attribute
syntax.
The @code{#pragma GCC target} pragma is presently implemented for The @code{#pragma GCC target} pragma is presently implemented for
x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only. x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
@item #pragma GCC optimize (@var{"string"}...) @item #pragma GCC optimize (@var{string}, @dots{})
@cindex pragma GCC optimize @cindex pragma GCC optimize
This pragma allows you to set global optimization options for functions This pragma allows you to set global optimization options for functions
defined later in the source file. One or more strings can be defined later in the source file. One or more strings can be
specified. Each function that is defined after this point is as specified. Each function that is defined after this point is treated
if @code{attribute((optimize("STRING")))} was specified for that as if it had been declared with one @code{optimize(}@var{string}@code{)}
function. The parenthesis around the options is optional. attribute for each @var{string} argument. The parentheses around
@xref{Function Attributes}, for more information about the the strings in the pragma are optional. @xref{Function Attributes},
@code{optimize} attribute and the attribute syntax. for more information about the @code{optimize} attribute and the attribute
syntax.
@item #pragma GCC push_options @item #pragma GCC push_options
@itemx #pragma GCC pop_options @itemx #pragma GCC pop_options
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment