Using an Inline Library. STMicroelectronics PGI
Reklamë
Reklamë
Invoking Function Inlining except: func
Inlines all eligible functions except func
, a function in the source text. you can use a comma-separated list to specify multiple functions.
[name:] func
Inlines all functions in the source text whose name matches func
. you can use a comma-separated list to specify multiple functions.
[size:] n
Inlines functions with a statement count less than or equal to n
, the specified size.
Note
The size n
may not exactly equal the number of statements in a selected function; the size parameter is merely a rough gauge.
levels: n
Inlines n
level of function calling levels. The default number is one (1). Using a level greater than one indicates that function calls within inlined functions may be replaced with inlined code. This approach allows the function inliner to automatically perform a sequence of inline and extract processes.
[lib:] file.ext
Instructs the inliner to inline the functions within the library file file.ext
. If no inline library is specified, functions are extracted from a temporary library created during an extract prepass.
Tip
Create the library file using the
-Mextract
option.
If you specify both a function name and a size n, the compiler inlines functions that match the function name
or
have n or fewer statements.
If a name is used without a keyword, then a name with a period is assumed to be an inline library and a name without a period is assumed to be a function name. If a number is used without a keyword, the number is assumed to be a size.
In the following example, the compiler inlines functions with fewer than approximately 100 statements in the source file myprog.f
and writes the executable code in the default output file a.out
.
$ pgf95 -Minline=size:100 myprog.f
Refer to “–M Options by Category,” on page 258
for more information on the
-Minline
options.
Using an Inline Library
If you specify one or more inline libraries on the command line with the
-Minline
option, the compiler does not perform an initial extract pass. The compiler selects functions to inline from the specified inline library.
If you also specify a size or function name, all functions in the inline library meeting the selection criteria are selected for inline expansion at points in the source text where they are called.
If you do not specify a function name or a size limitation for the
-Minline option, the compiler inlines every function in the inline library that matches a function in the source text.
50
Chapter 4. Using Function Inlining
In the following example, the compiler inlines the function proc
from the inline library lib.il
and writes the executable code in the default output file a.out
.
$ pgf95 -Minline=name:proc,lib:lib.il myprog.f
The following command line is equivalent to the preceding line, with the exception that in the following example does not use the keywords name:
and lib:
. You typically use keywords to avoid name conflicts when you use an inline library name that does not contain a period. Otherwise, without the keywords, a period informs the compiler that the file on the command line is an inline library.
$ pgf95 -Minline=proc,lib.il myprog.f
Creating an Inline Library
You can create or update an inline library using the
-Mextract
command-line option. If you do not specify selection criteria with the
-Mextract
option, the compiler attempts to extract all subprograms.
Several
-Mextract
options let you determine the selection criteria for creating or updating an inline library.
These selection criteria include: func
Extracts the function func
. you can use a comma-separated list to specify multiple functions.
[name:] func
Extracts the functions whose name matches func
, a function in the source text.
[size:] n
Limits the size of the extracted functions to functions with a statement count less than or equal to n
, the specified size.
Note
The size n may not exactly equal the number of statements in a selected function; the size parameter is merely a rough gauge.
[lib:] ext.lib
Stores the extracted information in the library directory ext.lib
.
If no inline library is specified, functions are extracted to a temporary library created during an extract prepass for use during the compilation stage.
When you use the
-Mextract
option, only the extract phase is performed; the compile and link phases are not performed. The output of an extract pass is a library of functions available for inlining. This output is placed in the inline library file specified on the command line with the
–o
filename specification. If the library file exists, new information is appended to it. If the file does not exist, it is created. You can use a command similar to the following:
$ pgf95 -Mextract=lib:lib.il myfunc.f
You can use the
-Minline
option with the
-Mextract
option. In this case, the extracted library of functions can have other functions inlined into the library. Using both options enables you to obtain more than one level of inlining. In this situation, if you do not specify a library with the
–Minline
option, the inline process
51
Shkarko
Reklamë