Skip to content

Commit

Permalink
i386: Add address spaces for fs/gs segments and tls
Browse files Browse the repository at this point in the history
        * config/i386/i386-c.c (ix86_target_macros): Define __SEG_FS,
        __SEG_GS, __SEG_TLS.
        (ix86_register_pragmas): Register address spaces __seg_fs,
        __seg_gs, __seg_tls.
        * config/i386/i386-protos.h (enum ix86_address_seg): Remove.
        (ADDR_SPACE_SEG_FS, ADDR_SPACE_SEG_GS, ADDR_SPACE_SEG_TLS): New.
        (struct ix86_address): Use addr_space_t instead of ix86_address_seg.
        * config/i386/i386.c (ix86_decompose_address): Likewise.
        (ix86_legitimate_address_p): Likewise.
        (memory_address_length): Likewise.  Check mem address space too.
        (ix86_print_operand): Use ix86_print_operand_address_as.
        (ix86_print_operand_address_as): Rename from
        ix86_print_operand_address, add new addr_space_t parameter.
        Validate that either the parameter or the ix86_address segment
        is default address space.  Handle ADDR_SPACE_SEG_TLS.
        (ix86_print_operand_address): New.
        (ix86_addr_space_subset_p, TARGET_ADDR_SPACE_SUBSET_P): New.
        (ix86_addr_space_convert, TARGET_ADDR_SPACE_CONVERT): New.
        (ix86_addr_space_debug, TARGET_ADDR_SPACE_DEBUG): New.
        (ix86_addr_space_zero_address_valid): New.
        (TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): New.
        * config/i386/i386.h (DEFAULT_TLS_SEG_REG): Use addr_space_t constants.
        * config/i386/rdos.h (DEFAULT_TLS_SEG_REG): Likewise.
        * config/i386/predicates.md (address_no_seg_operand): Likewise.
        (vsib_address_operand): Likewise.
        (address_mpx_no_base_operand): Likewise.
        (address_mpx_no_index_operand): Likewise.
        * doc/extend.texi (x86 Named Address Spaces): New section.

        * gcc.target/i386/addr-space-1.c: New test.
        * gcc.target/i386/addr-space-2.c: New test.
        * gcc.target/i386/addr-space-3.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230003 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
rth committed Nov 9, 2015
1 parent a48b812 commit 716c563
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 81 deletions.
29 changes: 29 additions & 0 deletions gcc/ChangeLog
@@ -1,5 +1,34 @@
2015-11-09 Richard Henderson <rth@redhat.com>

* config/i386/i386-c.c (ix86_target_macros): Define __SEG_FS,
__SEG_GS, __SEG_TLS.
(ix86_register_pragmas): Register address spaces __seg_fs,
__seg_gs, __seg_tls.
* config/i386/i386-protos.h (enum ix86_address_seg): Remove.
(ADDR_SPACE_SEG_FS, ADDR_SPACE_SEG_GS, ADDR_SPACE_SEG_TLS): New.
(struct ix86_address): Use addr_space_t instead of ix86_address_seg.
* config/i386/i386.c (ix86_decompose_address): Likewise.
(ix86_legitimate_address_p): Likewise.
(memory_address_length): Likewise. Check mem address space too.
(ix86_print_operand): Use ix86_print_operand_address_as.
(ix86_print_operand_address_as): Rename from
ix86_print_operand_address, add new addr_space_t parameter.
Validate that either the parameter or the ix86_address segment
is default address space. Handle ADDR_SPACE_SEG_TLS.
(ix86_print_operand_address): New.
(ix86_addr_space_subset_p, TARGET_ADDR_SPACE_SUBSET_P): New.
(ix86_addr_space_convert, TARGET_ADDR_SPACE_CONVERT): New.
(ix86_addr_space_debug, TARGET_ADDR_SPACE_DEBUG): New.
(ix86_addr_space_zero_address_valid): New.
(TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID): New.
* config/i386/i386.h (DEFAULT_TLS_SEG_REG): Use addr_space_t constants.
* config/i386/rdos.h (DEFAULT_TLS_SEG_REG): Likewise.
* config/i386/predicates.md (address_no_seg_operand): Likewise.
(vsib_address_operand): Likewise.
(address_mpx_no_base_operand): Likewise.
(address_mpx_no_index_operand): Likewise.
* doc/extend.texi (x86 Named Address Spaces): New section.

* config/i386/i386.c (ix86_check_no_addr_space): New.
(decide_alg): Add have_as parameter.
(alg_usable_p): Likewise; disable rep algorithms if set.
Expand Down
8 changes: 8 additions & 0 deletions gcc/config/i386/i386-c.c
Expand Up @@ -586,6 +586,10 @@ ix86_target_macros (void)
ix86_tune,
ix86_fpmath,
cpp_define);

cpp_define (parse_in, "__SEG_FS");
cpp_define (parse_in, "__SEG_GS");
cpp_define (parse_in, "__SEG_TLS");
}


Expand All @@ -600,6 +604,10 @@ ix86_register_pragmas (void)
/* Update pragma hook to allow parsing #pragma GCC target. */
targetm.target_option.pragma_parse = ix86_pragma_target_parse;

c_register_addr_space ("__seg_fs", ADDR_SPACE_SEG_FS);
c_register_addr_space ("__seg_gs", ADDR_SPACE_SEG_GS);
c_register_addr_space ("__seg_tls", ADDR_SPACE_SEG_TLS);

#ifdef REGISTER_SUBTARGET_PRAGMAS
REGISTER_SUBTARGET_PRAGMAS ();
#endif
Expand Down
7 changes: 5 additions & 2 deletions gcc/config/i386/i386-protos.h
Expand Up @@ -279,12 +279,11 @@ extern rtx maybe_get_pool_constant (rtx);
extern char internal_label_prefix[16];
extern int internal_label_prefix_len;

enum ix86_address_seg { SEG_DEFAULT, SEG_FS, SEG_GS };
struct ix86_address
{
rtx base, index, disp;
HOST_WIDE_INT scale;
enum ix86_address_seg seg;
addr_space_t seg;
};

extern int ix86_decompose_address (rtx, struct ix86_address *);
Expand Down Expand Up @@ -326,3 +325,7 @@ struct ix86_first_cycle_multipass_data_
# define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T \
struct ix86_first_cycle_multipass_data_
#endif /* RTX_CODE */

const addr_space_t ADDR_SPACE_SEG_FS = 1;
const addr_space_t ADDR_SPACE_SEG_GS = 2;
const addr_space_t ADDR_SPACE_SEG_TLS = 3;

0 comments on commit 716c563

Please sign in to comment.