I would need a way to use GS segment register instead of FS for x86-64 for target RDOS since RDOS cannot use FS for TLS. It seems like the code related to this is concentrated to two different places:

The gcc/config/i386/i386.c:
11677:                seg = TARGET_64BIT ? SEG_FS : SEG_GS;
13526:  if (ix86_decompose_address (x, &addr) == 0
     || addr.seg != (TARGET_64BIT ? SEG_FS : SEG_GS)
     || addr.disp == NULL_RTX
     || GET_CODE (addr.disp) != CONST)

Especially the second reference would become hard-to-read if more conditionals are added to it.

Perhaps the code could be changed to something like this:

#ifdef TARGET_RDOS
#define GET_TLS_SEG_REG  SEG_GS
#else
#define GET_TLS_SEG_REG TARGET_64BIT ? SEG_FS : SEG_GS
#endif

Then the above could be patched to:
11677:                seg = GET_TLS_SEG_REG;
13526:  if (ix86_decompose_address (x, &addr) == 0
     || addr.seg != (GET_TLS_SEG_REG)
     || addr.disp == NULL_RTX
     || GET_CODE (addr.disp) != CONST)

Thoughts?

Regards,
Leif Ekblad

Reply via email to