diff options
author | Janis Johnson <janis@gcc.gnu.org> | 2001-12-04 00:50:35 +0000 |
---|---|---|
committer | Janis Johnson <janis@gcc.gnu.org> | 2001-12-04 00:50:35 +0000 |
commit | a9ccbb60d4bfa7b7637a9157e10e58f4c60102a5 (patch) | |
tree | 40c85f3d7a5f7892b65417f4aa96b825f4936046 /gcc/doc | |
parent | 21b8482ae8289fccb3ddaaa74532995aa3f27c56 (diff) | |
download | gcc-a9ccbb60d4bfa7b7637a9157e10e58f4c60102a5.zip gcc-a9ccbb60d4bfa7b7637a9157e10e58f4c60102a5.tar.gz gcc-a9ccbb60d4bfa7b7637a9157e10e58f4c60102a5.tar.bz2 |
builtin-types.def (BT_FN_VOID_PTR_INT_INT): New.
* builtin-types.def (BT_FN_VOID_PTR_INT_INT): New.
* builtins.def (BUILT_IN_PREFETCH): New.
* builtins.c (expand_builtin_expect): New.
(expand_builtin): Call it.
* doc/extend.texi: Document __builtin_expect.
From-SVN: r47582
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index d0fdae6..781fa99 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -4474,6 +4474,45 @@ if (__builtin_expect (ptr != NULL, 1)) when testing pointer or floating-point values. @end deftypefn +@deftypefn {Built-in Function} void __builtin_prefetch (void *@var{addr}, int @var{rw}, int @var{locality}) +This function is used to minimize cache-miss latency by moving data into +a cache before it is accessed. +You can insert calls to @code{__builtin_prefetch} into code for which +you know addresses of data in memory that is likely to be accessed soon. +If the target supports them, data prefetch instructions will be generated. +If the prefetch is done early enough before the access then the data will +be in the cache by the time it is accessed. + +The value of @var{addr} is the address of the memory to prefetch. +The value of @var{rw} is a compile-time constant one or zero; one +means that the prefetch is preparing for a write to the memory address. +The value @var{locality} must be a compile-time constant integer between +zero and three. A value of zero means that the data has no temporal +locality, so it need not be left in the cache after the access. A value +of three means that the data has a high degree of temporal locality and +should be left in all levels of cache possible. Values of one and two +mean, respectively, a low or moderate degree of temporal locality. + +@smallexample +for (i = 0; i < n; i++) + @{ + a[i] = a[i] + b[i]; + __builtin_prefetch (&a[i+j], 1, 1); + __builtin_prefetch (&b[i+j], 0, 1); + /* ... */ + @} +@end smallexample + +Data prefetch does not generate faults if @var{addr} is invalid, but +the address expression itself must be valid. For example, a prefetch +of @code{p->next} will not fault if @code{p->next} is not a valid +address, but evaluation will fault if @code{p} is not a valid address. + +If the target does not support data prefetch, the address expression +is evaluated if it includes side effects but no other code is generated +and GCC does not issue a warning. +@end deftypefn + @node Pragmas @section Pragmas Accepted by GCC @cindex pragmas |