diff mbox

[v2,12/13] Document the x86 address spaces

Message ID 56294634.1060205@redhat.com
State New
Headers show

Commit Message

Richard Henderson Oct. 22, 2015, 8:25 p.m. UTC
I believe I've addressed all of your comments like so.


r~

Comments

Sandra Loosemore Oct. 23, 2015, 5:07 p.m. UTC | #1
On 10/22/2015 02:25 PM, Richard Henderson wrote:
> I believe I've addressed all of your comments like so.

This looks much better, except for this hunk:

> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index e54fe67..5793868 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -1240,8 +1240,8 @@ As an extension, GNU C supports named address spaces as
>  defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
>  address spaces in GCC will evolve as the draft technical report
>  changes.  Calling conventions for any target might also change.  At
> -present, only the AVR, SPU, M32C, and RL78 targets support address
> -spaces other than the generic address space.
> +present, only the AVR, SPU, M32C, RL78, and i386/x86_64 targets support

Please use "x86" here, too.

> +address spaces other than the generic address space.
>
>  Address space identifiers may be used exactly like any other C type
>  qualifier (e.g., @code{const} or @code{volatile}).  See the N1275

-Sandra
diff mbox

Patch

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e54fe67..5793868 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1240,8 +1240,8 @@  As an extension, GNU C supports named address spaces as
 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
 address spaces in GCC will evolve as the draft technical report
 changes.  Calling conventions for any target might also change.  At
-present, only the AVR, SPU, M32C, and RL78 targets support address
-spaces other than the generic address space.
+present, only the AVR, SPU, M32C, RL78, and i386/x86_64 targets support
+address spaces other than the generic address space.
 
 Address space identifiers may be used exactly like any other C type
 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
@@ -1430,6 +1430,49 @@  It may use runtime library
 support, or generate special machine instructions to access that address
 space.
 
+@subsection x86 Named Address Spaces
+@cindex x86 named address spaces
+
+On the x86 target, variables may be declared as being relative
+to the @code{%fs} or @code{%gs} segments.
+
+@table @code
+@item __seg_fs
+@itemx __seg_gs
+@cindex @code{__seg_fs} x86 named address space
+@cindex @code{__seg_gs} x86 named address space
+The object is accessed with the respective segment override prefix.
+
+The respective segment base must be set via some method specific to
+the operating system.  Rather than require an expensive system call
+to retrieve the segment base, these address spaces are not considered
+to be subspaces of the generic (flat) address space.  This means that
+explicit casts are required to convert pointers between these address
+spaces and the generic address space.  In practice the application
+should cast to @code{uintptr_t} and apply the segment base offset
+that it installed previously.
+
+The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
+defined when these address spaces are supported.
+
+@item __seg_tls
+@cindex @code{__seg_tls} x86 named address space
+Some operating systems define either the @code{%fs} or @code{%gs}
+segment as the thread-local storage base for each thread.  Objects
+within this address space are accessed with the appropriate
+segment override prefix.
+
+The pointer located at address 0 within the segment contains the
+offset of the segment within the generic address space.  Thus this
+address space is considered a subspace of the generic address space,
+and the known segment offset is applied when converting addresses
+to and from the generic address space.
+
+The preprocessor symbol @code{__SEG_TLS} is defined when this
+address space is supported.
+
+@end table
+
 @node Zero Length
 @section Arrays of Length Zero
 @cindex arrays of length zero