I started with Armin Rigo's patch, from back in July, https://gcc.gnu.org/ml/gcc/2015-07/msg00125.html
but then wound up changing all of it. To wit: (1) If we use more sensible defaults for address spaces, we no longer require 8 backend functions and 1 new hook. Indeed, basic support for x86 segmentation via address spaces then requires no overriding of any hooks. (2) In order to do anything useful with x86 segmentation, we need to acknowledge that the most common usage puts a valid object at %seg:0. Which means that we do need a new hook to disable several optimizations. (3) I found that usage within glibc really requires a more structured address space, one with a known mapping to the generic address space. Thus I introduce __seg_tls, which knows that the segment base is also stored at %seg:0. (4) I attempted to convert the entire tls implementation to use __seg_tls. I believe this is ultimately the best long-term solution, but I ran into a number of problems both generically and in the backend that prevented this from being simple. I've dropped these patches for now. (5) However, in the process of attempting (4), I found two problems in the backend that could affect any use of address spaces: the movabs patterns and string expansions. r~ Richard Henderson (9): Change default of non-overlapping address space conversion Relax ADDR_SPACE_GENERIC_P checks for default address space hooks i386: Handle address spaces in movabs patterns i386: Disallow address spaces with string insns i386: Add address spaces for fs/gs segments i386: Replace ix86_address_seg with addr_space_t i386: Add address space for tls Add TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID Fix PR 66768 gcc/config/i386/i386-c.c | 8 + gcc/config/i386/i386-protos.h | 8 +- gcc/config/i386/i386.c | 296 +++++++++++++++++++-------- gcc/config/i386/i386.h | 3 +- gcc/config/i386/i386.md | 91 +++++--- gcc/config/i386/predicates.md | 8 +- gcc/config/i386/rdos.h | 2 +- gcc/doc/tm.texi | 5 + gcc/doc/tm.texi.in | 2 + gcc/expr.c | 30 +-- gcc/fold-const.c | 6 +- gcc/gimple.c | 12 +- gcc/target.def | 9 + gcc/targhooks.c | 48 ++--- gcc/targhooks.h | 1 + gcc/testsuite/gcc.target/i386/addr-space-1.c | 11 + gcc/tree-ssa-address.c | 2 +- 17 files changed, 385 insertions(+), 157 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/addr-space-1.c -- 2.4.3