Alex wrote:

> Here's an incremental change, also by Olivier Hainque, that enables
> biarch -m32-defaulting x86_64-linux-gnum32.
>
...

> +#define TARGET_BI_ARCH 3
>
...

I was actually not so happy with the introduction of another hardcoded value
for TARGET_BI_ARCH and the accompanying assumptions and tried an alternative
approach.

Independently from the m32 discussion which started this thread, would the
attached patch be ok to install first?

This is a proposal to replace the processing of harcoded
values for TARGET_BI_ARCH in the i386 port by tests on the ABI bit
within TARGET_64BIT_DEFAULT that each of the TARGET_BI_ARCH value
was meant to convey.

The patch also removes a config.gcc #define TARGET_BI_ARCH 0 for
a couple of darwin variants that need to go 64-bit only per the
accompanying comment.  There was a mismatch between the previous
definition and the implicit assumption in ix86_option_override_internal,
that TARGET_BI_ARCH defined and != 1 implies == 2, per:

  #ifdef TARGET_BI_ARCH
   else
     {
  #if TARGET_BI_ARCH == 1
  ...
  #else
      /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
         on and OPTION_MASK_ABI_64 is off.
  ...

Moreover, ISTM the absence of definition better matches the intent of
the TARGET_64BIT definition logic in i386.h, with the #ifndef guard in:

  #ifdef IN_LIBGCC2
  ...
  #else
  #ifndef TARGET_BI_ARCH  <== here
  #undef TARGET_64BIT
  #undef TARGET_64BIT_P
  #if TARGET_64BIT_DEFAULT
  #define TARGET_64BIT 1
  #define TARGET_64BIT_P(x) 1
  #else
  #define TARGET_64BIT 0
  #define TARGET_64BIT_P(x) 0
  #endif
  #endif
  #endif

...

This also preserves the outcome of:

  #if defined (TARGET_BI_ARCH) || TARGET_64BIT_DEFAULT
  #define MAX_BITS_PER_WORD 64
  #else
  #define MAX_BITS_PER_WORD 32
  #endif

As TARGET_64BIT_DEFAULT is defined to non zero.

I believe the change also preserves the effect of definitions of
TARGET_BI_ARCH
to 1 for i.86-linux (for enable-targets=all) or solaris, in particular the
influence on
MAX_BITS_PER_WORD quoted above.

This bootstraps and regtests fine on x86_64-linux. I might be able to
perform
other tests if deemed necessary.

Olivier

--

2025-11-01  Olivier Hainque  <[email protected]>

        * config/i386/i386-options.cc (ix86_option_override_internal):
        Replace tests on TARGET_BI_ARCH by tests on ABI bits within
        TARGET_64BIT_DEFAULT.
        * config/i386/gnu-user64.h: Likewise.
        * config/i386/biarchx32.h (TARGET_BI_ARCH): Now a regular
        #define to standard Boolean value 1.
        * config.gcc (x86_64-*-darwin1* and 2*): Remove definition
        of TARGET_BI_ARCH to 0.

Attachment: 0001-Turn-tests-on-TARGET_BI_ARCH-into-tests-on-TARGET_64.patch
Description: Binary data

Reply via email to