Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-04-08 Thread Iain Sandoe

Hi H.J.

On 31 Mar 2012, at 20:24, Jack Howarth wrote:


  The latest gcc-pr52784-2.patch patch also allows current gcc trunk  
to

bootstrap on i386-apple-darwin10.


Despite the fact that bootstrap is restored, there remain problems  
with this patch and some more work is needed.


(a) [trivial] the option 'mx32' is in i386.opt, which means it is  
exposed to all sub-targets, even if they don't support it.


$ ./gcc/xgcc -Bgcc ../tests/hello.c -mx32 -o hc
/var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:10:bad  
register name `%rbp'
/var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:14:bad  
register name `%rsi'

etc. etc.

(b) [serious] the m64 ObjC multi-lib is broken on i?86-darwin* (and  
likely there are other more subtle effects).


This is because the code in config/darwin.c that Joseph pointed out  
(earlier in this thread) is called for SUBSUBTARGET_OVERRIDE_OPTIONS.


That code sets defaults for, and checks errors for, flags that apply  
to *-*-darwin* (and are needed for LTO as well as c-family).


In the case of the ObjC ABI (fobjc-abi-version=) we need to default it  
to 2 @ m64 (and default it to 0 or 1 depending on the darwin version  
@ m32).


I accept that some of this could possibly be done in driver-self- 
specs; however, we allow m32/m64 to be unspecified on the c/l and to  
default for the target.  I'm also not yet sure whether %:version- 
compare() would be applicable to fobjc-abi-version.


Thus, the current trunk implementation is broken by your patch and we  
need to address that pending other solutions (I'm also very short of  
free time for Darwin right now - to experiment with the specs solution).


=--=

It is possible that there is an options handling issue, (although I  
might also have misunderstood) viz:


=
(current) i386.opt:

;; ISA support

m32
Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT)  
Var(ix86_isa_flags) Save

Generate 32bit i386 code

m64
Target RejectNegative Negative(mx32) Report Mask(ABI_64)  
Var(ix86_isa_flags) Save

Generate 64bit x86-64 code

mx32
Target RejectNegative Negative(m32) Report Mask(ABI_X32)  
Var(ix86_isa_flags) Save

Generate 32bit x86-64 code

===
from gccint.pdf (section 8.2):

Negative(othername )
The option will turn off another option othername, which is the option  
name
with the leading “-” removed. This chain action will propagate  
through the

Negative property of the option to be turned off.
As a consequence, if you have a group of mutually-exclusive options,  
their
Negative properties should form a circular chain. For example, if  
options
‘-a ’, ‘-b ’ and ‘-c ’ are mutually exclusive, their  
respective Negative properties

should be ‘Negative(b )’, ‘Negative(c )’ and ‘Negative(a )’.

==

I read this as if the User specifies -a on the command line the  
inverse of -b *and* the inverse of -c will be applied.


so that when -m64 is issued, the *inverse* of Mask(ABI_X32) should be  
applied and then the *inverse* of InverseMask(ISA_64BIT) - which would  
(correctly, for the case we're considering) set MASK_ISA_64BIT.


However, in the example above this does NOT happen - if I set a  
breakpoint at the entry of x86_internal_override_options - ISA_64BIT  
ends up as 0 when -m64 is specified on the c/l for i?86-darwin*.


The x86_isa_explicit stuff doesn't appear to get set either, although  
global_options_set.x_x86_isa... does, which I've used in the attached  
patch.


so is this an options bug or misunderstanding on my part?

=

An interim solution to the current scenario (tested by the chaps  
across the darwin range) is attached.


Is that OK for trunk?

NOTE: I can't apply any patch at present, unless it's considered to be  
trivial, since my personal FSF (c) assignment is in the process of  
being transferred to my new employer.


cheers
Iain

Index: gcc/config/i386/darwin.h
===
--- gcc/config/i386/darwin.h(revision 186156)
+++ gcc/config/i386/darwin.h(working copy)
@@ -231,11 +231,26 @@ extern int darwin_emit_branch_islands;
 SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;   \
   } while (0)
 
+/* This macros gets the first opportunity to check/modify flags.
+   In this case we need to sort out the ABI/ISA mask flags here because
+   we want to act on them in SUBSUBTARGET_OVERRIDE_OPTIONS.  */
+
 #undef SUBTARGET_OVERRIDE_OPTIONS
 #define SUBTARGET_OVERRIDE_OPTIONS \
 do {   \
+  /* As of darwin 11/OSX 10.7, mx32 has no implementation for darwin. */\
+  if (TARGET_X32)  \
+error_at (UNKNOWN_LOCATION,
\
+ %-mx32% is not valid for Darwin/Mac OS X);\
+  /*  Furthermore, explicit LP64 implies ISA_64BIT.  */
\
+  if (TARGET_LP64  

Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-04-08 Thread H.J. Lu
On Sun, Apr 8, 2012 at 4:38 AM, Iain Sandoe idsan...@googlemail.com wrote:
 Hi H.J.


 On 31 Mar 2012, at 20:24, Jack Howarth wrote:


  The latest gcc-pr52784-2.patch patch also allows current gcc trunk to
 bootstrap on i386-apple-darwin10.


 Despite the fact that bootstrap is restored, there remain problems with this
 patch and some more work is needed.

 (a) [trivial] the option 'mx32' is in i386.opt, which means it is exposed to
 all sub-targets, even if they don't support it.

 $ ./gcc/xgcc -Bgcc ../tests/hello.c -mx32 -o hc
 /var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:10:bad
 register name `%rbp'
 /var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:14:bad
 register name `%rsi'
 etc. etc.

It is useful for bootstrap and allows you check out what
X32 code looks like even if your OS doesn't support it.

 (b) [serious] the m64 ObjC multi-lib is broken on i?86-darwin* (and likely
 there are other more subtle effects).

 This is because the code in config/darwin.c that Joseph pointed out (earlier
 in this thread) is called for SUBSUBTARGET_OVERRIDE_OPTIONS.

 That code sets defaults for, and checks errors for, flags that apply to
 *-*-darwin* (and are needed for LTO as well as c-family).

 In the case of the ObjC ABI (fobjc-abi-version=) we need to default it to
 2 @ m64 (and default it to 0 or 1 depending on the darwin version @ m32).

 I accept that some of this could possibly be done in driver-self-specs;
 however, we allow m32/m64 to be unspecified on the c/l and to default for
 the target.  I'm also not yet sure whether %:version-compare() would be
 applicable to fobjc-abi-version.

 Thus, the current trunk implementation is broken by your patch and we need
 to address that pending other solutions (I'm also very short of free time
 for Darwin right now - to experiment with the specs solution).

Please try this

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index c959113..69893ab 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3109,14 +3109,6 @@ ix86_option_override_internal (bool main_args_p)
   sw = attribute;
 }

-#ifdef SUBTARGET_OVERRIDE_OPTIONS
-  SUBTARGET_OVERRIDE_OPTIONS;
-#endif
-
-#ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
-  SUBSUBTARGET_OVERRIDE_OPTIONS;
-#endif
-
   /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
  TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false.  */
   if (TARGET_64BIT_DEFAULT  !TARGET_64BIT)
@@ -3157,6 +3149,14 @@ ix86_option_override_internal (bool main_args_p)
   ix86_isa_flags = ~OPTION_MASK_ABI_X32;
 }

+#ifdef SUBTARGET_OVERRIDE_OPTIONS
+  SUBTARGET_OVERRIDE_OPTIONS;
+#endif
+
+#ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
+  SUBSUBTARGET_OVERRIDE_OPTIONS;
+#endif
+
   /* -fPIC is the default for x86_64.  */
   if (TARGET_MACHO  TARGET_64BIT)
 flag_pic = 2;


 =--=

 It is possible that there is an options handling issue, (although I might
 also have misunderstood) viz:

 =
 (current) i386.opt:

 ;; ISA support


 m32
 Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT)
 Var(ix86_isa_flags) Save
 Generate 32bit i386 code

 m64
 Target RejectNegative Negative(mx32) Report Mask(ABI_64) Var(ix86_isa_flags)
 Save

 Generate 64bit x86-64 code

 mx32
 Target RejectNegative Negative(m32) Report Mask(ABI_X32) Var(ix86_isa_flags)
 Save
 Generate 32bit x86-64 code

 ===
 from gccint.pdf (section 8.2):

 Negative(othername )
 The option will turn off another option othername, which is the option name
 with the leading “-” removed. This chain action will propagate through the
 Negative property of the option to be turned off.
 As a consequence, if you have a group of mutually-exclusive options, their
 Negative properties should form a circular chain. For example, if options
 ‘-a ’, ‘-b ’ and ‘-c ’ are mutually exclusive, their respective Negative
 properties
 should be ‘Negative(b )’, ‘Negative(c )’ and ‘Negative(a )’.

 ==

 I read this as if the User specifies -a on the command line the inverse of
 -b *and* the inverse of -c will be applied.

 so that when -m64 is issued, the *inverse* of Mask(ABI_X32) should be
 applied and then the *inverse* of InverseMask(ISA_64BIT) - which would
 (correctly, for the case we're considering) set MASK_ISA_64BIT.

 However, in the example above this does NOT happen - if I set a breakpoint
 at the entry of x86_internal_override_options - ISA_64BIT ends up as 0 when
 -m64 is specified on the c/l for i?86-darwin*.

 The x86_isa_explicit stuff doesn't appear to get set either, although
 global_options_set.x_x86_isa... does, which I've used in the attached patch.

 so is this an options bug or misunderstanding on my part?


There is no problem here.  ISA_64BIT is turned on by ABI_64:

  else if (TARGET_LP64)
{
  /* Always turn on OPTION_MASK_ISA_64BIT and turn off
 OPTION_MASK_ABI_X32 for TARGET_LP64.  */
  ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
  ix86_isa_flags = ~OPTION_MASK_ABI_X32;
}



-- 

Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-04-08 Thread Iain Sandoe


On 8 Apr 2012, at 15:54, H.J. Lu wrote:
Despite the fact that bootstrap is restored, there remain problems  
with this

patch and some more work is needed.

(a) [trivial] the option 'mx32' is in i386.opt, which means it is  
exposed to

all sub-targets, even if they don't support it.

$ ./gcc/xgcc -Bgcc ../tests/hello.c -mx32 -o hc
/var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:10:bad
register name `%rbp'
/var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:14:bad
register name `%rsi'
etc. etc.


It is useful for bootstrap and allows you check out what
X32 code looks like even if your OS doesn't support it.


well, OK, but I'd have thought that to be something for developers to  
experiment with, rather than an 'end user' flag.
However, it is, as stated 'trivial' I'm not going to lose sleep over  
it ;-).


(b) [serious] the m64 ObjC multi-lib is broken on i?86-darwin* (and  
likely

there are other more subtle effects).

This is because the code in config/darwin.c that Joseph pointed out  
(earlier

in this thread) is called for SUBSUBTARGET_OVERRIDE_OPTIONS.

That code sets defaults for, and checks errors for, flags that  
apply to

*-*-darwin* (and are needed for LTO as well as c-family).

In the case of the ObjC ABI (fobjc-abi-version=) we need to default  
it to
2 @ m64 (and default it to 0 or 1 depending on the darwin version  
@ m32).


I accept that some of this could possibly be done in driver-self- 
specs;
however, we allow m32/m64 to be unspecified on the c/l and to  
default for
the target.  I'm also not yet sure whether %:version-compare()  
would be

applicable to fobjc-abi-version.

Thus, the current trunk implementation is broken by your patch and  
we need
to address that pending other solutions (I'm also very short of  
free time

for Darwin right now - to experiment with the specs solution).


Please try this


snip

This is not enough to solve the problem, because there are decisions  
made earlier (e.g. in c-family/c-opts.c re. exceptions) that depend on  
flag states.


It would be possible to move/repeat some of those (which I did in the  
proposed fix attached to my last post).


=--=


It is possible that there is an options handling issue, (although I  
might

also have misunderstood) viz:

=
(current) i386.opt:

;; ISA support


m32
Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT)
Var(ix86_isa_flags) Save
Generate 32bit i386 code

m64
Target RejectNegative Negative(mx32) Report Mask(ABI_64)  
Var(ix86_isa_flags)

Save

Generate 64bit x86-64 code

mx32
Target RejectNegative Negative(m32) Report Mask(ABI_X32)  
Var(ix86_isa_flags)

Save
Generate 32bit x86-64 code

===
from gccint.pdf (section 8.2):

Negative(othername )
The option will turn off another option othername, which is the  
option name
with the leading “-” removed. This chain action will propagate  
through the

Negative property of the option to be turned off.
As a consequence, if you have a group of mutually-exclusive  
options, their
Negative properties should form a circular chain. For example, if  
options
‘-a ’, ‘-b ’ and ‘-c ’ are mutually exclusive, their  
respective Negative

properties
should be ‘Negative(b )’, ‘Negative(c )’ and  
‘Negative(a )’.


==

I read this as if the User specifies -a on the command line the  
inverse of

-b *and* the inverse of -c will be applied.

so that when -m64 is issued, the *inverse* of Mask(ABI_X32) should be
applied and then the *inverse* of InverseMask(ISA_64BIT) - which  
would

(correctly, for the case we're considering) set MASK_ISA_64BIT.

However, in the example above this does NOT happen - if I set a  
breakpoint
at the entry of x86_internal_override_options - ISA_64BIT ends up  
as 0 when

-m64 is specified on the c/l for i?86-darwin*.

The x86_isa_explicit stuff doesn't appear to get set either, although
global_options_set.x_x86_isa... does, which I've used in the  
attached patch.


so is this an options bug or misunderstanding on my part?



There is no problem here.  ISA_64BIT is turned on by ABI_64:


Well, I accept that your code in i386.c enforces the assumption above  
- my point is that the documentation implies (at least to me) that the  
enforcement should be done in options processing.


The i386.c enforcement happens *after* some points in the code that  
(currently) assume the behavior as I describe above (or as per the  
code before your patch).


I am sure that a hybrid of the two patches can be made to work - my  
concern is to be clear about what is *supposed* to happen at options  
parsing time.


thanks
Iain



Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-31 Thread H.J. Lu
On Fri, Mar 30, 2012 at 1:36 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Fri, Mar 30, 2012 at 1:23 PM, Jack Howarth howa...@bromo.med.uc.edu 
 wrote:
 On Fri, Mar 30, 2012 at 11:32:37AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 11:05 AM, Jack Howarth howa...@bromo.med.uc.edu 
 wrote:
  On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
  On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
  r...@cebitec.uni-bielefeld.de wrote:
   Mike Stump mikest...@comcast.net writes:
  
   Here is the new patch.  OK for trunk if there are no regressions on
   Linux/ia32 and Linux/x86-64?
  
   Too bad you didn't test 32-bit darwin, causes:
  
     http://gcc.gnu.org/PR52784
  
   Could you please revert or fix, thanks.
  
   Same problem on Solaris 10 and 11/x86.
  
          Rainer
  
 
  When i[34567]86-*-* targets are configured with --enable-targets=all,
  TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
  isn't defined.  It leads to
 
     if (!TARGET_64BIT)
       ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 
  Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
  correctly.  This patch changes TARGET_BI_ARCH to 3 for
  i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
  Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
  --disable-bootstrap.  Please try on other OSes.
 
  H.J.,
    This patch solves the bootstrap of current gcc trunk on
  i386-apple-darwin10. Thanks.
           Jack
 

 Here is a smaller patch.

 H.J.,
  The smaller patch also solves the bootstrap failure on i386-apple-darwin10.
           Jack


 Please ignore the smaller patch since preprocessor may handle
 TARGET_64BIT_DEFAULT properly.


Please try this even smaller patch.  If it works for you, I will
check it in as an obvious fix.

Thanks.


-- 
H.J.


gcc-pr52784-2.patch
Description: Binary data


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-31 Thread Jack Howarth
On Sat, Mar 31, 2012 at 11:20:27AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 1:36 PM, H.J. Lu hjl.to...@gmail.com wrote:
  On Fri, Mar 30, 2012 at 1:23 PM, Jack Howarth howa...@bromo.med.uc.edu 
  wrote:
  On Fri, Mar 30, 2012 at 11:32:37AM -0700, H.J. Lu wrote:
  On Fri, Mar 30, 2012 at 11:05 AM, Jack Howarth howa...@bromo.med.uc.edu 
  wrote:
   On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
   On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
   r...@cebitec.uni-bielefeld.de wrote:
Mike Stump mikest...@comcast.net writes:
   
Here is the new patch.  OK for trunk if there are no regressions on
Linux/ia32 and Linux/x86-64?
   
Too bad you didn't test 32-bit darwin, causes:
   
  http://gcc.gnu.org/PR52784
   
Could you please revert or fix, thanks.
   
Same problem on Solaris 10 and 11/x86.
   
       Rainer
   
  
   When i[34567]86-*-* targets are configured with --enable-targets=all,
   TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
   isn't defined.  It leads to
  
      if (!TARGET_64BIT)
        ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
  
   Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
   correctly.  This patch changes TARGET_BI_ARCH to 3 for
   i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
   Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
   --disable-bootstrap.  Please try on other OSes.
  
   H.J.,
     This patch solves the bootstrap of current gcc trunk on
   i386-apple-darwin10. Thanks.
            Jack
  
 
  Here is a smaller patch.
 
  H.J.,
   The smaller patch also solves the bootstrap failure on 
  i386-apple-darwin10.
            Jack
 
 
  Please ignore the smaller patch since preprocessor may handle
  TARGET_64BIT_DEFAULT properly.
 
 
 Please try this even smaller patch.  If it works for you, I will
 check it in as an obvious fix.

H.J.,
   The latest gcc-pr52784-2.patch patch also allows current gcc trunk to
bootstrap on i386-apple-darwin10.
 Jack

 
 Thanks.
 
 
 -- 
 H.J.




Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread Rainer Orth
Mike Stump mikest...@comcast.net writes:

 Here is the new patch.  OK for trunk if there are no regressions on
 Linux/ia32 and Linux/x86-64?

 Too bad you didn't test 32-bit darwin, causes:

   http://gcc.gnu.org/PR52784

 Could you please revert or fix, thanks.

Same problem on Solaris 10 and 11/x86.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread H.J. Lu
On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
r...@cebitec.uni-bielefeld.de wrote:
 Mike Stump mikest...@comcast.net writes:

 Here is the new patch.  OK for trunk if there are no regressions on
 Linux/ia32 and Linux/x86-64?

 Too bad you didn't test 32-bit darwin, causes:

   http://gcc.gnu.org/PR52784

 Could you please revert or fix, thanks.

 Same problem on Solaris 10 and 11/x86.

        Rainer


When i[34567]86-*-* targets are configured with --enable-targets=all,
TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
isn't defined.  It leads to

   if (!TARGET_64BIT)
 ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);

Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
correctly.  This patch changes TARGET_BI_ARCH to 3 for
i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
--disable-bootstrap.  Please try on other OSes.

Thanks.


-- 
H.J.
---
2012-03-30  H.J. Lu  hongjiu...@intel.com

PR bootstrap/52784
* config.gcc (tm_defines): Replace TARGET_BI_ARCH=1 with
TARGET_BI_ARCH=3 for i[34567]86-*-* targets.

* config/i386/i386.c (ix86_option_override_internal): Don't
check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3.
2012-03-30  H.J. Lu  hongjiu...@intel.com

	PR bootstrap/52784
	* config.gcc (tm_defines): Replace TARGET_BI_ARCH=1 with
	TARGET_BI_ARCH=3 for i[34567]86-*-* targets.

	* config/i386/i386.c (ix86_option_override_internal): Don't
	check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
	TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index c30bb24..d1e0480 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1208,7 +1208,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 		default_gnu_indirect_function=yes
 		if test x$enable_targets = xall; then
 			tm_file=${tm_file} i386/x86-64.h i386/gnu-user64.h i386/linux64.h
-			tm_defines=${tm_defines} TARGET_BI_ARCH=1
+			tm_defines=${tm_defines} TARGET_BI_ARCH=3
 			tmake_file=${tmake_file} i386/t-linux64
 			x86_multilibs=${with_multilib_list}
 			if test $x86_multilibs = default; then
@@ -1338,7 +1338,7 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
 	case ${target} in
 	*-*-solaris2.1[0-9]*)
 		tm_file=${tm_file} i386/x86-64.h i386/sol2-bi.h sol2-bi.h
-		tm_defines=${tm_defines} TARGET_BI_ARCH=1
+		tm_defines=${tm_defines} TARGET_BI_ARCH=3
 		tmake_file=$tmake_file i386/t-sol2-64
 		need_64bit_isa=yes
 		case X${with_cpu} in
@@ -1406,7 +1406,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 			user_headers_inc_next_pre=${user_headers_inc_next_pre} stddef.h stdarg.h
 			tm_file=${tm_file} i386/mingw-w64.h
 			if test x$enable_targets = xall; then
-tm_defines=${tm_defines} TARGET_BI_ARCH=1
+tm_defines=${tm_defines} TARGET_BI_ARCH=3
 case X${with_cpu} in
 Xgeneric|Xatom|Xcore2|Xcorei7|Xcorei7-avx|Xnocona|Xx86-64|Xbdver2|Xbdver1|Xbtver1|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx|Xathlon64-sse3|Xk8-sse3|Xopteron-sse3)
 	;;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 42746e4..62ed2c0 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3117,11 +3117,14 @@ ix86_option_override_internal (bool main_args_p)
   SUBSUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
-  /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
- TARGET_64BIT is false.  */
+#if defined TARGET_BI_ARCH  TARGET_BI_ARCH != 3
+  /* When TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3,
+ TARGET_64BIT is false by default and there is no need to check
+ OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32.  Turn off both
+ OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if TARGET_64BIT is
+ false.  */
   if (!TARGET_64BIT)
 ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
-#ifdef TARGET_BI_ARCH
   else
 {
 #if TARGET_BI_ARCH == 1


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread Jack Howarth
On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
  Mike Stump mikest...@comcast.net writes:
 
  Here is the new patch.  OK for trunk if there are no regressions on
  Linux/ia32 and Linux/x86-64?
 
  Too bad you didn't test 32-bit darwin, causes:
 
    http://gcc.gnu.org/PR52784
 
  Could you please revert or fix, thanks.
 
  Same problem on Solaris 10 and 11/x86.
 
         Rainer
 
 
 When i[34567]86-*-* targets are configured with --enable-targets=all,
 TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
 isn't defined.  It leads to
 
if (!TARGET_64BIT)
  ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 
 Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
 correctly.  This patch changes TARGET_BI_ARCH to 3 for
 i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
 Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
 --disable-bootstrap.  Please try on other OSes.

H.J.,
   This patch solves the bootstrap of current gcc trunk on
i386-apple-darwin10. Thanks.
  Jack

 
 Thanks.
 
 
 -- 
 H.J.
 ---
 2012-03-30  H.J. Lu  hongjiu...@intel.com
 
   PR bootstrap/52784
   * config.gcc (tm_defines): Replace TARGET_BI_ARCH=1 with
   TARGET_BI_ARCH=3 for i[34567]86-*-* targets.
 
   * config/i386/i386.c (ix86_option_override_internal): Don't
   check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
   TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3.

 2012-03-30  H.J. Lu  hongjiu...@intel.com
 
   PR bootstrap/52784
   * config.gcc (tm_defines): Replace TARGET_BI_ARCH=1 with
   TARGET_BI_ARCH=3 for i[34567]86-*-* targets.
 
   * config/i386/i386.c (ix86_option_override_internal): Don't
   check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
   TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3.
 
 diff --git a/gcc/config.gcc b/gcc/config.gcc
 index c30bb24..d1e0480 100644
 --- a/gcc/config.gcc
 +++ b/gcc/config.gcc
 @@ -1208,7 +1208,7 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
 i[34567]86-*-knetbsd*-gnu | i
   default_gnu_indirect_function=yes
   if test x$enable_targets = xall; then
   tm_file=${tm_file} i386/x86-64.h i386/gnu-user64.h 
 i386/linux64.h
 - tm_defines=${tm_defines} TARGET_BI_ARCH=1
 + tm_defines=${tm_defines} TARGET_BI_ARCH=3
   tmake_file=${tmake_file} i386/t-linux64
   x86_multilibs=${with_multilib_list}
   if test $x86_multilibs = default; then
 @@ -1338,7 +1338,7 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
   case ${target} in
   *-*-solaris2.1[0-9]*)
   tm_file=${tm_file} i386/x86-64.h i386/sol2-bi.h sol2-bi.h
 - tm_defines=${tm_defines} TARGET_BI_ARCH=1
 + tm_defines=${tm_defines} TARGET_BI_ARCH=3
   tmake_file=$tmake_file i386/t-sol2-64
   need_64bit_isa=yes
   case X${with_cpu} in
 @@ -1406,7 +1406,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
   user_headers_inc_next_pre=${user_headers_inc_next_pre} 
 stddef.h stdarg.h
   tm_file=${tm_file} i386/mingw-w64.h
   if test x$enable_targets = xall; then
 - tm_defines=${tm_defines} TARGET_BI_ARCH=1
 + tm_defines=${tm_defines} TARGET_BI_ARCH=3
   case X${with_cpu} in
   
 Xgeneric|Xatom|Xcore2|Xcorei7|Xcorei7-avx|Xnocona|Xx86-64|Xbdver2|Xbdver1|Xbtver1|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx|Xathlon64-sse3|Xk8-sse3|Xopteron-sse3)
   ;;
 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index 42746e4..62ed2c0 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -3117,11 +3117,14 @@ ix86_option_override_internal (bool main_args_p)
SUBSUBTARGET_OVERRIDE_OPTIONS;
  #endif
  
 -  /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
 - TARGET_64BIT is false.  */
 +#if defined TARGET_BI_ARCH  TARGET_BI_ARCH != 3
 +  /* When TARGET_BI_ARCH isn't defined or TARGET_BI_ARCH == 3,
 + TARGET_64BIT is false by default and there is no need to check
 + OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32.  Turn off both
 + OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if TARGET_64BIT is
 + false.  */
if (!TARGET_64BIT)
  ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 -#ifdef TARGET_BI_ARCH
else
  {
  #if TARGET_BI_ARCH == 1



Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread H.J. Lu
On Fri, Mar 30, 2012 at 11:05 AM, Jack Howarth howa...@bromo.med.uc.edu wrote:
 On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
 r...@cebitec.uni-bielefeld.de wrote:
  Mike Stump mikest...@comcast.net writes:
 
  Here is the new patch.  OK for trunk if there are no regressions on
  Linux/ia32 and Linux/x86-64?
 
  Too bad you didn't test 32-bit darwin, causes:
 
    http://gcc.gnu.org/PR52784
 
  Could you please revert or fix, thanks.
 
  Same problem on Solaris 10 and 11/x86.
 
         Rainer
 

 When i[34567]86-*-* targets are configured with --enable-targets=all,
 TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
 isn't defined.  It leads to

    if (!TARGET_64BIT)
      ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);

 Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
 correctly.  This patch changes TARGET_BI_ARCH to 3 for
 i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
 Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
 --disable-bootstrap.  Please try on other OSes.

 H.J.,
   This patch solves the bootstrap of current gcc trunk on
 i386-apple-darwin10. Thanks.
          Jack


Here is a smaller patch.


-- 
H.J.
2012-03-30  H.J. Lu  hongjiu...@intel.com

	PR bootstrap/52784
	* config/i386/i386.c (ix86_option_override_internal): Don't
	check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
	TARGET_BI_ARCH isn't defined or TARGET_64BIT_DEFAULT is 0.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 42746e4..3905287 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3117,11 +3117,13 @@ ix86_option_override_internal (bool main_args_p)
   SUBSUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
-  /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
- TARGET_64BIT is false.  */
+#if defined TARGET_BI_ARCH  TARGET_64BIT_DEFAULT
+  /* When TARGET_64BIT_DEFAULT isn't defined, TARGET_64BIT is false by
+ default and there is no need to check OPTION_MASK_ABI_64 nor
+ OPTION_MASK_ABI_X32.  Turn off both OPTION_MASK_ABI_64 and
+ OPTION_MASK_ABI_X32 if TARGET_64BIT is false.  */
   if (!TARGET_64BIT)
 ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
-#ifdef TARGET_BI_ARCH
   else
 {
 #if TARGET_BI_ARCH == 1


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread Jack Howarth
On Fri, Mar 30, 2012 at 11:32:37AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 11:05 AM, Jack Howarth howa...@bromo.med.uc.edu 
 wrote:
  On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
  On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
  r...@cebitec.uni-bielefeld.de wrote:
   Mike Stump mikest...@comcast.net writes:
  
   Here is the new patch.  OK for trunk if there are no regressions on
   Linux/ia32 and Linux/x86-64?
  
   Too bad you didn't test 32-bit darwin, causes:
  
     http://gcc.gnu.org/PR52784
  
   Could you please revert or fix, thanks.
  
   Same problem on Solaris 10 and 11/x86.
  
          Rainer
  
 
  When i[34567]86-*-* targets are configured with --enable-targets=all,
  TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
  isn't defined.  It leads to
 
     if (!TARGET_64BIT)
       ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 
  Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
  correctly.  This patch changes TARGET_BI_ARCH to 3 for
  i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
  Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
  --disable-bootstrap.  Please try on other OSes.
 
  H.J.,
    This patch solves the bootstrap of current gcc trunk on
  i386-apple-darwin10. Thanks.
           Jack
 
 
 Here is a smaller patch.

H.J.,
  The smaller patch also solves the bootstrap failure on i386-apple-darwin10.
   Jack

 
 
 -- 
 H.J.

 2012-03-30  H.J. Lu  hongjiu...@intel.com
 
   PR bootstrap/52784
   * config/i386/i386.c (ix86_option_override_internal): Don't
   check OPTION_MASK_ABI_64 nor OPTION_MASK_ABI_X32 if
   TARGET_BI_ARCH isn't defined or TARGET_64BIT_DEFAULT is 0.
 
 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
 index 42746e4..3905287 100644
 --- a/gcc/config/i386/i386.c
 +++ b/gcc/config/i386/i386.c
 @@ -3117,11 +3117,13 @@ ix86_option_override_internal (bool main_args_p)
SUBSUBTARGET_OVERRIDE_OPTIONS;
  #endif
  
 -  /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
 - TARGET_64BIT is false.  */
 +#if defined TARGET_BI_ARCH  TARGET_64BIT_DEFAULT
 +  /* When TARGET_64BIT_DEFAULT isn't defined, TARGET_64BIT is false by
 + default and there is no need to check OPTION_MASK_ABI_64 nor
 + OPTION_MASK_ABI_X32.  Turn off both OPTION_MASK_ABI_64 and
 + OPTION_MASK_ABI_X32 if TARGET_64BIT is false.  */
if (!TARGET_64BIT)
  ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 -#ifdef TARGET_BI_ARCH
else
  {
  #if TARGET_BI_ARCH == 1



Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-30 Thread H.J. Lu
On Fri, Mar 30, 2012 at 1:23 PM, Jack Howarth howa...@bromo.med.uc.edu wrote:
 On Fri, Mar 30, 2012 at 11:32:37AM -0700, H.J. Lu wrote:
 On Fri, Mar 30, 2012 at 11:05 AM, Jack Howarth howa...@bromo.med.uc.edu 
 wrote:
  On Fri, Mar 30, 2012 at 09:18:13AM -0700, H.J. Lu wrote:
  On Fri, Mar 30, 2012 at 8:11 AM, Rainer Orth
  r...@cebitec.uni-bielefeld.de wrote:
   Mike Stump mikest...@comcast.net writes:
  
   Here is the new patch.  OK for trunk if there are no regressions on
   Linux/ia32 and Linux/x86-64?
  
   Too bad you didn't test 32-bit darwin, causes:
  
     http://gcc.gnu.org/PR52784
  
   Could you please revert or fix, thanks.
  
   Same problem on Solaris 10 and 11/x86.
  
          Rainer
  
 
  When i[34567]86-*-* targets are configured with --enable-targets=all,
  TARGET_BI_ARCH is defined as 1, but TARGET_64BIT_DEFAULT
  isn't defined.  It leads to
 
     if (!TARGET_64BIT)
       ix86_isa_flags = ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
 
  Since TARGET_64BIT is false by default, -m64 and -mx32 don't work
  correctly.  This patch changes TARGET_BI_ARCH to 3 for
  i[34567]86-*-* targets configured with --enable-targets=all.  Tested on
  Linux/ia32 with bootstrap and Linux/ia32 with --enable-targets=all
  --disable-bootstrap.  Please try on other OSes.
 
  H.J.,
    This patch solves the bootstrap of current gcc trunk on
  i386-apple-darwin10. Thanks.
           Jack
 

 Here is a smaller patch.

 H.J.,
  The smaller patch also solves the bootstrap failure on i386-apple-darwin10.
           Jack


Please ignore the smaller patch since preprocessor may handle
TARGET_64BIT_DEFAULT properly.

-- 
H.J.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-29 Thread Jack Howarth
On Wed, Mar 28, 2012 at 03:40:28PM -0700, H.J. Lu wrote:
 On Wed, Mar 28, 2012 at 3:07 PM, Joseph S. Myers
 jos...@codesourcery.com wrote:
  On Wed, 28 Mar 2012, H.J. Lu wrote:
 
  Here is the updated patch.  I will wait for OK from Joseph.
 
  I have no comments on this patch.
 
 
 Given that my patch doesn't change any command line options,
 I am checking it in.  Please let me know if there are any issues.
 
 Thanks.
 
 
 -- 
 H.J.

H.J.,
   This patch caused PR52784 where the multilib bootstrap on i386-apple-darwin10
is broken. The multilib bootstrap for x86_64-apple-darwin10 is uneffected. 
Reverting
r185937 eliminates the bootstrap failure on i386-apple-darwin10.
   Jack


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread Uros Bizjak
On Tue, Mar 27, 2012 at 7:48 PM, H.J. Lu hongjiu...@intel.com wrote:

 OPTION_MASK_ISA_64BIT                 32bit x86-64 code or 64bit x86-64 code
 OPTION_MASK_ISA_X86_64                64bit x86-64 code
 OPTION_MASK_ISA_X32           32bit x86-64 code

How annoying, the first one doesn't mean what it says.
OPTION_MASK_ISA_64BIT should be renamed to OPTION_MASK_ARCH_X86_64,
then it makes sense. For consistency, I'd say:

OPTION_MASK_ISA_64BIT - OPTION_MASK_ARCH_X86_64
OPTION_MASK_ISA_X86_64 - OPTION_MASK_ISA_64
OPTION_MASK_ISA_X32 - stays the same.

 and i386.opt becomes

 -m64: Turn on OPTION_MASK_ISA_X86_64
 -mx32: Turn on OPTION_MASK_ISA_X32
 -m32: Turn off OPTION_MASK_ISA_64BIT

 Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply
 OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64
 and vice versa.

With a renamed macros, the above make sense.

 -#define TARGET_LP64    (TARGET_64BIT  !TARGET_X32)
 +#define TARGET_LP64    TARGET_X86_64

You don't need new define, just use OPTION_MASK_ISA_64.

Uros.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread H.J. Lu
On Wed, Mar 28, 2012 at 3:17 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Tue, Mar 27, 2012 at 7:48 PM, H.J. Lu hongjiu...@intel.com wrote:

 OPTION_MASK_ISA_64BIT                 32bit x86-64 code or 64bit x86-64 code
 OPTION_MASK_ISA_X86_64                64bit x86-64 code
 OPTION_MASK_ISA_X32           32bit x86-64 code

 How annoying, the first one doesn't mean what it says.
 OPTION_MASK_ISA_64BIT should be renamed to OPTION_MASK_ARCH_X86_64,
 then it makes sense. For consistency, I'd say:

 OPTION_MASK_ISA_64BIT - OPTION_MASK_ARCH_X86_64
 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ISA_64
 OPTION_MASK_ISA_X32 - stays the same.

 and i386.opt becomes

 -m64: Turn on OPTION_MASK_ISA_X86_64
 -mx32: Turn on OPTION_MASK_ISA_X32
 -m32: Turn off OPTION_MASK_ISA_64BIT

 Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply
 OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64
 and vice versa.

 With a renamed macros, the above make sense.

 -#define TARGET_LP64    (TARGET_64BIT  !TARGET_X32)
 +#define TARGET_LP64    TARGET_X86_64

 You don't need new define, just use OPTION_MASK_ISA_64.


What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT?  They
are used to indicate 64bit ISA like:

collect2.c:/* TARGET_64BIT may be defined to use driver specific
functionality. */
collect2.c:#undef TARGET_64BIT
collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
reg-stack.c:  if ((flag_pic  !TARGET_64BIT)
tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. */
tlink.c:#undef TARGET_64BIT
tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
xcoffout.c:   if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX))   
   \
config/darwin.c:TARGET_64BIT
config/darwin.c:TARGET_64BIT
config/darwin.c:: (TARGET_64BIT ? 2
config/darwin.c:  if (TARGET_64BIT  global_options.x_flag_objc_abi  2)
config/darwin.c:  if (!TARGET_64BIT  global_options.x_flag_objc_abi = 2)
config/darwin.c:   !TARGET_64BIT)
config/darwin.c:  if (!TARGET_64BIT)\
config/darwin.c:  if (!TARGET_64BIT 
  \
config/darwin.h:flag_next_runtime  
!TARGET_64BIT; \
config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

Should we keep them? Right now I have

#define TARGET_64BITOPTION_ARCH_X86_64

and

#define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64)

Should we go with

OPTION_MASK_ISA_64BIT - stays the same
OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64
OPTION_MASK_ISA_X32 -  OPTION_MASK_ABI_X32

instead?

-- 
H.J.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread Joseph S. Myers
On Wed, 28 Mar 2012, H.J. Lu wrote:

 collect2.c:/* TARGET_64BIT may be defined to use driver specific
 functionality. */
 collect2.c:#undef TARGET_64BIT
 collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT

As previously discussed, this use is a bug; TARGET_64BIT should be 
considered private to back ends and collect2.c should use better-defined 
target macros or hooks that aren't private to the back end.  (I don't know 
what target macro is being used in collect2 that may be using 
TARGET_64BIT_DEFAULT indirectly.)

 reg-stack.c:  if ((flag_pic  !TARGET_64BIT)

Logically part of the x86 back end.  We should set things up so that 
architecture-specific passes can actually go in gcc/config/.

 tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. 
 */
 tlink.c:#undef TARGET_64BIT
 tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT

Part of collect2.

 xcoffout.c: if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX))   
\

Logically part of the rs6000 back end (specifically, for AIX).  You can 
ignore it.

 config/darwin.c:  TARGET_64BIT
 config/darwin.c:  TARGET_64BIT
 config/darwin.c:  : (TARGET_64BIT ? 2
 config/darwin.c:  if (TARGET_64BIT  global_options.x_flag_objc_abi  2)
 config/darwin.c:  if (!TARGET_64BIT  global_options.x_flag_objc_abi = 
 2)
 config/darwin.c:   !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT)  \
 config/darwin.c:  if (!TARGET_64BIT   
   \
 config/darwin.h:  flag_next_runtime  
 !TARGET_64BIT; \
 config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
 config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

I don't know exactly what TARGET_64BIT is intended to mean, 
architecture-independently, for Darwin and Solaris.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread Uros Bizjak
On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote:

 What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT?  They
 are used to indicate 64bit ISA like:

 collect2.c:/* TARGET_64BIT may be defined to use driver specific
 functionality. */
 collect2.c:#undef TARGET_64BIT
 collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 reg-stack.c:  if ((flag_pic  !TARGET_64BIT)
 tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. 
 */
 tlink.c:#undef TARGET_64BIT
 tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 xcoffout.c:       if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX))     
      \
 config/darwin.c:                TARGET_64BIT
 config/darwin.c:            TARGET_64BIT
 config/darwin.c:                : (TARGET_64BIT ? 2
 config/darwin.c:      if (TARGET_64BIT  global_options.x_flag_objc_abi  2)
 config/darwin.c:      if (!TARGET_64BIT  global_options.x_flag_objc_abi = 
 2)
 config/darwin.c:       !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT)                            \
 config/darwin.c:  if (!TARGET_64BIT                                           
     \
 config/darwin.h:                                flag_next_runtime  
 !TARGET_64BIT;     \
 config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
 config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

 Should we keep them? Right now I have

 #define TARGET_64BIT    OPTION_ARCH_X86_64

 and

 #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64)

 Should we go with

 OPTION_MASK_ISA_64BIT - stays the same
 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64
 OPTION_MASK_ISA_X32 -  OPTION_MASK_ABI_X32

Yes, the above is IMO much better. We have to separate ABI and ISA
defines in some meaningful way.

Uros.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread H.J. Lu
On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote:

 What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT?  They
 are used to indicate 64bit ISA like:

 collect2.c:/* TARGET_64BIT may be defined to use driver specific
 functionality. */
 collect2.c:#undef TARGET_64BIT
 collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 reg-stack.c:  if ((flag_pic  !TARGET_64BIT)
 tlink.c:/* TARGET_64BIT may be defined to use driver specific functionality. 
 */
 tlink.c:#undef TARGET_64BIT
 tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 xcoffout.c:       if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX))    
       \
 config/darwin.c:                TARGET_64BIT
 config/darwin.c:            TARGET_64BIT
 config/darwin.c:                : (TARGET_64BIT ? 2
 config/darwin.c:      if (TARGET_64BIT  global_options.x_flag_objc_abi  2)
 config/darwin.c:      if (!TARGET_64BIT  global_options.x_flag_objc_abi = 
 2)
 config/darwin.c:       !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT)                            \
 config/darwin.c:  if (!TARGET_64BIT                                          
      \
 config/darwin.h:                                flag_next_runtime  
 !TARGET_64BIT;     \
 config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
 config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

 Should we keep them? Right now I have

 #define TARGET_64BIT    OPTION_ARCH_X86_64

 and

 #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64)

 Should we go with

 OPTION_MASK_ISA_64BIT - stays the same
 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64
 OPTION_MASK_ISA_X32 -  OPTION_MASK_ABI_X32

 Yes, the above is IMO much better. We have to separate ABI and ISA
 defines in some meaningful way.

 Uros.

Here is the new patch.  OK for trunk if there are no regressions on
Linux/ia32 and Linux/x86-64?

Thanks.


-- 
H.J.
--
2012-03-28  H.J. Lu  hongjiu...@intel.com

* config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
OPTION_MASK_ABI_64.

* config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
(SPEC_X32): Likewise.
(MULTILIB_DEFAULTS): Likewise.

* config/i386/i386.c (isa_opts): Replace OPTION_MASK_ISA_64BIT
with OPTION_MASK_ABI_64 for -m64.
(ix86_option_override_internal): Properly
set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as
handle -m32, -m64 and -mx32.

* config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32
with OPTION_ABI_X32.
(TARGET_LP64): Changed to OPTION_ABI_64.

* config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64.
(mx32): Replace ISA_X32 with ABI_X32.
2012-03-28  H.J. Lu  hongjiu...@intel.com

	* config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
	OPTION_MASK_ABI_64.

	* config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
	(SPEC_X32): Likewise.
	(MULTILIB_DEFAULTS): Likewise.

	* config/i386/i386.c (isa_opts): Replace OPTION_MASK_ISA_64BIT
	with OPTION_MASK_ABI_64 for -m64.
	(ix86_option_override_internal): Properly
	set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as
	handle -m32, -m64 and -mx32.

	* config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32
	with OPTION_ABI_X32.
	(TARGET_LP64): Changed to OPTION_ABI_64.

	* config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64.
	(mx32): Replace ISA_X32 with ABI_X32.

diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h
index 629ec98..0c3811e 100644
--- a/gcc/config/i386/biarch64.h
+++ b/gcc/config/i386/biarch64.h
@@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 http://www.gnu.org/licenses/.  */
 
-#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64)
 #define TARGET_BI_ARCH 1
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 954f3b2..6f7b5de 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -58,8 +58,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #if TARGET_64BIT_DEFAULT
 #define SPEC_32 m32
+#if TARGET_BI_ARCH == 2
+#define SPEC_64 m64
+#define SPEC_X32 m32|m64:;
+#else
 #define SPEC_64 m32|mx32:;
 #define SPEC_X32 mx32
+#endif
 #else
 #define SPEC_32 m64|mx32:;
 #define SPEC_64 m64
@@ -95,7 +100,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s
 
 #if TARGET_64BIT_DEFAULT
+#if TARGET_BI_ARCH == 2
+#define MULTILIB_DEFAULTS { mx32 }
+#else
 #define MULTILIB_DEFAULTS { m64 }
+#endif
 #else
 #define MULTILIB_DEFAULTS { m32 }
 #endif
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 18172a1..b11602b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2657,7 

Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread Mike Stump
On Mar 28, 2012, at 12:44 PM, Joseph S. Myers wrote:
 config/darwin.c: TARGET_64BIT
 config/darwin.c: TARGET_64BIT
 config/darwin.c: : (TARGET_64BIT ? 2
 config/darwin.c:  if (TARGET_64BIT  global_options.x_flag_objc_abi  2)
 config/darwin.c:  if (!TARGET_64BIT  global_options.x_flag_objc_abi = 
 2)
 config/darwin.c:   !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT) \
 config/darwin.c:  if (!TARGET_64BIT  
   \
 config/darwin.h: flag_next_runtime  
 !TARGET_64BIT; \

 I don't know exactly what TARGET_64BIT is intended to mean, 
 architecture-independently, for Darwin and Solaris.

For darwin, it means:

#define TARGET_64BITOPTION_ISA_64BIT

from i386.h for darwin on x86, and on ppc, it means the same thing that 
TARGET_64BIT means in rs6000.h.  The rough idea, we are going to generate code 
for a 64-bit target.  (-m64 for example, on x86, that would be x86_64 and on 
ppc that would be powerpc64).


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread H.J. Lu
On Wed, Mar 28, 2012 at 2:10 PM, Uros Bizjak ubiz...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 10:13 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote:

 What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT?  They
 are used to indicate 64bit ISA like:

 collect2.c:/* TARGET_64BIT may be defined to use driver specific
 functionality. */
 collect2.c:#undef TARGET_64BIT
 collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 reg-stack.c:  if ((flag_pic  !TARGET_64BIT)
 tlink.c:/* TARGET_64BIT may be defined to use driver specific 
 functionality. */
 tlink.c:#undef TARGET_64BIT
 tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 xcoffout.c:       if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX))  
         \
 config/darwin.c:                TARGET_64BIT
 config/darwin.c:            TARGET_64BIT
 config/darwin.c:                : (TARGET_64BIT ? 2
 config/darwin.c:      if (TARGET_64BIT  global_options.x_flag_objc_abi  
 2)
 config/darwin.c:      if (!TARGET_64BIT  global_options.x_flag_objc_abi 
 = 2)
 config/darwin.c:       !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT)                            \
 config/darwin.c:  if (!TARGET_64BIT                                        
        \
 config/darwin.h:                                flag_next_runtime  
 !TARGET_64BIT;     \
 config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
 config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

 Should we keep them? Right now I have

 #define TARGET_64BIT    OPTION_ARCH_X86_64

 and

 #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | OPTION_MASK_ISA_64)

 Should we go with

 OPTION_MASK_ISA_64BIT - stays the same
 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64
 OPTION_MASK_ISA_X32 -  OPTION_MASK_ABI_X32

 Yes, the above is IMO much better. We have to separate ABI and ISA
 defines in some meaningful way.

 Uros.

 Here is the new patch.  OK for trunk if there are no regressions on
 Linux/ia32 and Linux/x86-64?

 @@ -2657,7 +2657,7 @@ ix86_target_string (HOST_WIDE_INT isa, int
 flags, const char *arch,
      preceding options while match those first.  */
   static struct ix86_target_opts isa_opts[] =
   {
 -    { -m64,          OPTION_MASK_ISA_64BIT },
 +    { -m64,          OPTION_MASK_ABI_64 },
     { -mfma4,                OPTION_MASK_ISA_FMA4 },

 Please add -mx32 here. Probably also -m32.

I will add -mx32.  Adding -m32 is hard since clearing the
OPTION_MASK_ISA_64BIT bit isn't supported here.  Can I
try

{ !-m32,  OPTION_MASK_ISA_64BIT },

  #define TARGET_64BIT   OPTION_ISA_64BIT
 -#define TARGET_X32     OPTION_ISA_X32
 +#define TARGET_X32     OPTION_ABI_X32
  #define TARGET_MMX     OPTION_ISA_MMX
  #define TARGET_3DNOW   OPTION_ISA_3DNOW
  #define TARGET_3DNOW_A OPTION_ISA_3DNOW_A
 @@ -77,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME
 respectively.  If not, see
  #define TARGET_F16C    OPTION_ISA_F16C
  #define TARGET_RTM      OPTION_ISA_RTM

 -#define TARGET_LP64    (TARGET_64BIT  !TARGET_X32)
 +#define TARGET_LP64    OPTION_ABI_64

 Please group new OPTION_ABI_xxx defines together, after ISA defines.

Will do.

 The patch is OK, but please also get approval from Joseph (options 
 maintainer).


Thanks.

-- 
H.J.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread H.J. Lu
On Wed, Mar 28, 2012 at 2:17 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 2:10 PM, Uros Bizjak ubiz...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 10:13 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 12:51 PM, Uros Bizjak ubiz...@gmail.com wrote:
 On Wed, Mar 28, 2012 at 9:33 PM, H.J. Lu hjl.to...@gmail.com wrote:

 What do we do with TARGET_64BIT and TARGET_64BIT_DEFAULT?  They
 are used to indicate 64bit ISA like:

 collect2.c:/* TARGET_64BIT may be defined to use driver specific
 functionality. */
 collect2.c:#undef TARGET_64BIT
 collect2.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 reg-stack.c:  if ((flag_pic  !TARGET_64BIT)
 tlink.c:/* TARGET_64BIT may be defined to use driver specific 
 functionality. */
 tlink.c:#undef TARGET_64BIT
 tlink.c:#define TARGET_64BIT TARGET_64BIT_DEFAULT
 xcoffout.c:       if (lno  0  (TARGET_64BIT || lno = (int)USHRT_MAX)) 
          \
 config/darwin.c:                TARGET_64BIT
 config/darwin.c:            TARGET_64BIT
 config/darwin.c:                : (TARGET_64BIT ? 2
 config/darwin.c:      if (TARGET_64BIT  global_options.x_flag_objc_abi 
  2)
 config/darwin.c:      if (!TARGET_64BIT  global_options.x_flag_objc_abi 
 = 2)
 config/darwin.c:       !TARGET_64BIT)
 config/darwin.c:  if (!TARGET_64BIT)                            \
 config/darwin.c:  if (!TARGET_64BIT                                       
         \
 config/darwin.h:                                flag_next_runtime  
 !TARGET_64BIT;     \
 config/sol2-bi.h:#define WCHAR_TYPE (TARGET_64BIT ? int : long int)
 config/sol2-bi.h:#define WINT_TYPE (TARGET_64BIT ? int : long int)

 Should we keep them? Right now I have

 #define TARGET_64BIT    OPTION_ARCH_X86_64

 and

 #define TARGET_64BIT_DEFAULT (OPTION_MASK_ARCH_X86_64 | 
 OPTION_MASK_ISA_64)

 Should we go with

 OPTION_MASK_ISA_64BIT - stays the same
 OPTION_MASK_ISA_X86_64 - OPTION_MASK_ABI_64
 OPTION_MASK_ISA_X32 -  OPTION_MASK_ABI_X32

 Yes, the above is IMO much better. We have to separate ABI and ISA
 defines in some meaningful way.

 Uros.

 Here is the new patch.  OK for trunk if there are no regressions on
 Linux/ia32 and Linux/x86-64?

 @@ -2657,7 +2657,7 @@ ix86_target_string (HOST_WIDE_INT isa, int
 flags, const char *arch,
      preceding options while match those first.  */
   static struct ix86_target_opts isa_opts[] =
   {
 -    { -m64,          OPTION_MASK_ISA_64BIT },
 +    { -m64,          OPTION_MASK_ABI_64 },
     { -mfma4,                OPTION_MASK_ISA_FMA4 },

 Please add -mx32 here. Probably also -m32.

 I will add -mx32.  Adding -m32 is hard since clearing the
 OPTION_MASK_ISA_64BIT bit isn't supported here.  Can I
 try

 { !-m32,          OPTION_MASK_ISA_64BIT },

It turns out I can just remove -m64 and handle -m32/-m64/-mx32
together.

  #define TARGET_64BIT   OPTION_ISA_64BIT
 -#define TARGET_X32     OPTION_ISA_X32
 +#define TARGET_X32     OPTION_ABI_X32
  #define TARGET_MMX     OPTION_ISA_MMX
  #define TARGET_3DNOW   OPTION_ISA_3DNOW
  #define TARGET_3DNOW_A OPTION_ISA_3DNOW_A
 @@ -77,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME
 respectively.  If not, see
  #define TARGET_F16C    OPTION_ISA_F16C
  #define TARGET_RTM      OPTION_ISA_RTM

 -#define TARGET_LP64    (TARGET_64BIT  !TARGET_X32)
 +#define TARGET_LP64    OPTION_ABI_64

 Please group new OPTION_ABI_xxx defines together, after ISA defines.

 Will do.

 The patch is OK, but please also get approval from Joseph (options 
 maintainer).



Here is the updated patch.  I will wait for OK from Joseph.

Thanks,

-- 
H.J.
2012-03-28  H.J. Lu  hongjiu...@intel.com

	* config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
	OPTION_MASK_ABI_64.

	* config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
	(SPEC_X32): Likewise.
	(MULTILIB_DEFAULTS): Likewise.

	* config/i386/i386.c (isa_opts): Remove -m64.
	(ix86_target_string): Properly handle -m32/-m64/-mx32.
	(ix86_option_override_internal): Properly
	set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as
	handle -m32, -m64 and -mx32.

	* config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32
	with OPTION_ABI_X32.  Moved after TARGET_LP64.
	(TARGET_LP64): Changed to OPTION_ABI_64.

	* config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64.
	(mx32): Replace ISA_X32 with ABI_X32.

diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h
index 629ec98..0c3811e 100644
--- a/gcc/config/i386/biarch64.h
+++ b/gcc/config/i386/biarch64.h
@@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 http://www.gnu.org/licenses/.  */
 
-#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64)
 #define TARGET_BI_ARCH 1
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 954f3b2..6f7b5de 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -58,8 +58,13 

Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread Joseph S. Myers
On Wed, 28 Mar 2012, H.J. Lu wrote:

 Here is the updated patch.  I will wait for OK from Joseph.

I have no comments on this patch.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-28 Thread H.J. Lu
On Wed, Mar 28, 2012 at 3:07 PM, Joseph S. Myers
jos...@codesourcery.com wrote:
 On Wed, 28 Mar 2012, H.J. Lu wrote:

 Here is the updated patch.  I will wait for OK from Joseph.

 I have no comments on this patch.


Given that my patch doesn't change any command line options,
I am checking it in.  Please let me know if there are any issues.

Thanks.


-- 
H.J.


Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-27 Thread H.J. Lu
On Sat, Mar 24, 2012 at 03:42:29PM -0700, H.J. Lu wrote:
 Hi,
 
 In i386 option mask, there is OPTION_MASK_ISA_64BIT for -m64 or -mx32
 code generations and OPTION_MASK_ISA_X32 for -mx32 code generation. We
 support
 
 -m64: OPTION_MASK_ISA_64BIT  !OPTION_MASK_ISA_X32
 -mx32: OPTION_MASK_ISA_64BIT  OPTION_MASK_ISA_X32
 -m32: !OPTION_MASK_ISA_64BIT
 
 i386.opt has
 
 -m64: Turn on OPTION_MASK_ISA_64BIT
 -mx32: Turn on OPTION_MASK_ISA_X32
 -m32: Turn off OPTION_MASK_ISA_64BIT
 
 So it isn't possible to make -mx32 as default -m64 just turns on
 OPTION_MASK_ISA_64BIT and doesn't change anything.  This option adds
 OPTION_MASK_ISA_X86_64 so that we can have
 
 OPTION_MASK_ISA_64BIT 32bit x86-64 code or 64bit x86-64 code
 OPTION_MASK_ISA_X86_6464bit x86-64 code
 OPTION_MASK_ISA_X32   32bit x86-64 code
 
 and i386.opt becomes
 
 -m64: Turn on OPTION_MASK_ISA_X86_64 
 -mx32: Turn on OPTION_MASK_ISA_X32
 -m32: Turn off OPTION_MASK_ISA_64BIT
 
 Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply
 OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64
 and vice versa.
 
 I added a dummy command line option, -mx86-64, since we don't support
 ISA_64BIT in
 
 m32
 Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) 
 Var(ix86_isa_flags) Save
 Generate 32bit i386 code
 
 without a place holder for Mask(ISA_64BIT).
 
 Currectly when TARGET_BI_ARCH is defined, i386 backend will set the
 OPTION_MASK_ISA_64BIT bit by default to make -m64 as the default.  This
 patch extends TARGET_BI_ARCH to support:
 
 1. TARGET_BI_ARCH == 1: -m64 is the default by setting the
 OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X86_64 bits.
 2. TARGET_BI_ARCH == 2: -mx32 is the default by setting the
 OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 bits.
 
 I will send a sparate patch to define TARGET_BI_ARCH to 2.  Tested on
 Linux/x86-64.  OK to install?
 

Here is the updated patch without the undocumented -mx86-64 option.
Tested on Linux/x86-64.  OK to install?

Thanks.

H.J.
---
2012-03-27  H.J. Lu  hongjiu...@intel.com

* config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
OPTION_MASK_ISA_X86_64.

* config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
(SPEC_X32): Likewise.
(MULTILIB_DEFAULTS): Likewise.

* config/i386/i386.c (ix86_option_override_internal): Properly
set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as
handle -m32, -m64 and -mx32.

* config/i386/i386.h (TARGET_X86_64): New.
(TARGET_LP64): Changed to TARGET_X86_64.

* config/i386/i386.opt (m64): Replace ISA_64BIT with ISA_X86_64.

diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h
index 629ec98..3dc9889 100644
--- a/gcc/config/i386/biarch64.h
+++ b/gcc/config/i386/biarch64.h
@@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this 
program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 http://www.gnu.org/licenses/.  */
 
-#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ISA_X86_64)
 #define TARGET_BI_ARCH 1
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 954f3b2..6f7b5de 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -58,8 +58,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 #if TARGET_64BIT_DEFAULT
 #define SPEC_32 m32
+#if TARGET_BI_ARCH == 2
+#define SPEC_64 m64
+#define SPEC_X32 m32|m64:;
+#else
 #define SPEC_64 m32|mx32:;
 #define SPEC_X32 mx32
+#endif
 #else
 #define SPEC_32 m64|mx32:;
 #define SPEC_64 m64
@@ -95,7 +100,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s
 
 #if TARGET_64BIT_DEFAULT
+#if TARGET_BI_ARCH == 2
+#define MULTILIB_DEFAULTS { mx32 }
+#else
 #define MULTILIB_DEFAULTS { m64 }
+#endif
 #else
 #define MULTILIB_DEFAULTS { m32 }
 #endif
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 18172a1..4e29b06 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3102,8 +3102,45 @@ ix86_option_override_internal (bool main_args_p)
   SUBSUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
+  /* Turn off both OPTION_MASK_ISA_X86_64 and OPTION_MASK_ISA_X32 if
+ TARGET_64BIT is false.  */
+  if (!TARGET_64BIT)
+ix86_isa_flags = ~(OPTION_MASK_ISA_X86_64 | OPTION_MASK_ISA_X32);
+#ifdef TARGET_BI_ARCH
+  else
+{
+#if TARGET_BI_ARCH == 1
+  /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ISA_X86_64
+is on and OPTION_MASK_ISA_X32 is off.  We turn off
+OPTION_MASK_ISA_X86_64 if OPTION_MASK_ISA_X32 is turned on by
+-mx32.  */
+  if (TARGET_X32)
+   ix86_isa_flags = ~OPTION_MASK_ISA_X86_64;
+#else
+  /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ISA_X32 is
+on and OPTION_MASK_ISA_X86_64 is off.  We turn 

PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2

2012-03-24 Thread H.J. Lu
Hi,

In i386 option mask, there is OPTION_MASK_ISA_64BIT for -m64 or -mx32
code generations and OPTION_MASK_ISA_X32 for -mx32 code generation. We
support

-m64: OPTION_MASK_ISA_64BIT  !OPTION_MASK_ISA_X32
-mx32: OPTION_MASK_ISA_64BIT  OPTION_MASK_ISA_X32
-m32: !OPTION_MASK_ISA_64BIT

i386.opt has

-m64: Turn on OPTION_MASK_ISA_64BIT
-mx32: Turn on OPTION_MASK_ISA_X32
-m32: Turn off OPTION_MASK_ISA_64BIT

So it isn't possible to make -mx32 as default -m64 just turns on
OPTION_MASK_ISA_64BIT and doesn't change anything.  This option adds
OPTION_MASK_ISA_X86_64 so that we can have

OPTION_MASK_ISA_64BIT   32bit x86-64 code or 64bit x86-64 code
OPTION_MASK_ISA_X86_64  64bit x86-64 code
OPTION_MASK_ISA_X32 32bit x86-64 code

and i386.opt becomes

-m64: Turn on OPTION_MASK_ISA_X86_64 
-mx32: Turn on OPTION_MASK_ISA_X32
-m32: Turn off OPTION_MASK_ISA_64BIT

Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply
OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64
and vice versa.

I added a dummy command line option, -mx86-64, since we don't support
ISA_64BIT in

m32
Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) 
Var(ix86_isa_flags) Save
Generate 32bit i386 code

without a place holder for Mask(ISA_64BIT).

Currectly when TARGET_BI_ARCH is defined, i386 backend will set the
OPTION_MASK_ISA_64BIT bit by default to make -m64 as the default.  This
patch extends TARGET_BI_ARCH to support:

1. TARGET_BI_ARCH == 1: -m64 is the default by setting the
OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X86_64 bits.
2. TARGET_BI_ARCH == 2: -mx32 is the default by setting the
OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 bits.

I will send a sparate patch to define TARGET_BI_ARCH to 2.  Tested on
Linux/x86-64.  OK to install?

Thanks.
 

H.J.
---
2012-03-24  H.J. Lu  hongjiu...@intel.com

* config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
OPTION_MASK_ISA_X86_64.

* config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
(SPEC_X32): Likewise.
(MULTILIB_DEFAULTS): Likewise.

* config/i386/i386.c (ix86_option_override_internal): Properly
set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as
handle -m32, -m64 and -mx32.

* config/i386/i386.h (TARGET_X86_64): New.
(TARGET_LP64): Changed to TARGET_X86_64.

* config/i386/i386.opt (m64): Replace ISA_64BIT with ISA_X86_64.
(mx86-64): New.

diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h
index 629ec98..3dc9889 100644
--- a/gcc/config/i386/biarch64.h
+++ b/gcc/config/i386/biarch64.h
@@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this 
program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 http://www.gnu.org/licenses/.  */
 
-#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ISA_X86_64)
 #define TARGET_BI_ARCH 1
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 954f3b2..6f7b5de 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -58,8 +58,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 #if TARGET_64BIT_DEFAULT
 #define SPEC_32 m32
+#if TARGET_BI_ARCH == 2
+#define SPEC_64 m64
+#define SPEC_X32 m32|m64:;
+#else
 #define SPEC_64 m32|mx32:;
 #define SPEC_X32 mx32
+#endif
 #else
 #define SPEC_32 m64|mx32:;
 #define SPEC_64 m64
@@ -95,7 +100,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s
 
 #if TARGET_64BIT_DEFAULT
+#if TARGET_BI_ARCH == 2
+#define MULTILIB_DEFAULTS { mx32 }
+#else
 #define MULTILIB_DEFAULTS { m64 }
+#endif
 #else
 #define MULTILIB_DEFAULTS { m32 }
 #endif
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index f93583f..4b6ceab 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3097,8 +3097,45 @@ ix86_option_override_internal (bool main_args_p)
   SUBSUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
+  /* Turn off both OPTION_MASK_ISA_X86_64 and OPTION_MASK_ISA_X32 if
+ TARGET_64BIT is false.  */
+  if (!TARGET_64BIT)
+ix86_isa_flags = ~(OPTION_MASK_ISA_X86_64 | OPTION_MASK_ISA_X32);
+#ifdef TARGET_BI_ARCH
+  else
+{
+#if TARGET_BI_ARCH == 1
+  /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ISA_X86_64
+is on and OPTION_MASK_ISA_X32 is off.  We turn off
+OPTION_MASK_ISA_X86_64 if OPTION_MASK_ISA_X32 is turned on by
+-mx32.  */
+  if (TARGET_X32)
+   ix86_isa_flags = ~OPTION_MASK_ISA_X86_64;
+#else
+  /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ISA_X32 is
+on and OPTION_MASK_ISA_X86_64 is off.  We turn off
+OPTION_MASK_ISA_X32 if OPTION_MASK_ISA_X86_64 is turned on by
+-m64.  */
+  if (TARGET_X86_64)
+   ix86_isa_flags = ~OPTION_MASK_ISA_X32;
+#endif
+}
+#endif
+
   if