Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-23 Thread Eric Botcazou
> Ok, I committed your suggestion to trunk for now.

Thanks!

-- 
Eric Botcazou


Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-23 Thread David Miller
From: David Miller 
Date: Sun, 23 Oct 2011 16:32:36 -0400 (EDT)

> From: Eric Botcazou 
> Date: Sun, 23 Oct 2011 11:58:57 +0200
> 
>>> I'll try to brainstorm on this, thanks for letting me know about the
>>> Solaris target problem.
>> 
>> Let's fix the regression quickly though.
> 
> I'll fix it by the end of tonight.

Ok, I committed your suggestion to trunk for now.

--
[PATCH] Fix sol2 sparc -mv8 regression.

* config/sparc/sparc.c (sparc_option_override): Remove -mv8plus
cpu adjustment.
* config/sparc/linux64.h (CC1_SPEC): When defaulting to 64-bit,
append -mcpu=v9 when -mv8plus is given.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180362 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  |5 +
 gcc/config/sparc/linux64.h |2 ++
 gcc/config/sparc/sparc.c   |4 
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1842402..54e1a4f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
 2011-10-23  David S. Miller  
 
+   * config/sparc/sparc.c (sparc_option_override): Remove -mv8plus
+   cpu adjustment.
+   * config/sparc/linux64.h (CC1_SPEC): When defaulting to 64-bit,
+   append -mcpu=v9 when -mv8plus is given.
+
* config/sparc/sparc.h (SECONDARY_MEMORY_NEEDED): We can move
between float and non-float regs when VIS3.
* config/sparc/sparc.c (eligible_for_restore_insn): We can't
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index a51a2f0..7604fa0 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -166,6 +166,8 @@ extern const char *host_detect_local_cpu (int argc, const 
char **argv);
 %{m32:%{m64:%emay not use both -m32 and -m64}} \
 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
   %{!mcpu*:-mcpu=cypress}} \
+%{mv8plus:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
+  %{!mcpu*:-mcpu=v9}} \
 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
 "
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 79bb821..29d2922 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -1029,10 +1029,6 @@ sparc_option_override (void)
   sparc_cpu_and_features = def->processor;
 }
 
-  if ((target_flags & MASK_V8PLUS)
-  && sparc_cpu_and_features < PROCESSOR_V9)
-sparc_cpu_and_features = PROCESSOR_V9;
-
   if (!global_options_set.x_sparc_cpu)
 sparc_cpu = sparc_cpu_and_features;
 
-- 
1.7.6.401.g6a319



Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-23 Thread David Miller
From: Eric Botcazou 
Date: Sun, 23 Oct 2011 11:58:57 +0200

>> I'll try to brainstorm on this, thanks for letting me know about the
>> Solaris target problem.
> 
> Let's fix the regression quickly though.

I'll fix it by the end of tonight.


Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-23 Thread Eric Botcazou
> This is precisely what I tried initially, and my posting was
> explicitly trying to explain that this kind of approach cannot
> work. :-)

It will work for Richard's case though and that's clearly the most glaring 
problem.  Moreover, it will bring Linux on par with Solaris, which is also a 
good thing.  And of course it will unbreak Solaris.

> Personally, I tend to build a 32-bit compiler and test 64-bit things by
> giving -m64.  Richard has been building 64-bit compilers and using -m32
> to test 32-bit stuff.
>
> Furthermore, consider that we need to solve this issue for things
> other than MASK_V8PLUS.  For example VIS2, VIS3, and FMAF all need
> similar treatment.
>
> Given that, I don't think we want to keep banging the specs for every
> new MASK we add, even if it could work.  I think the specs are quite
> convoluted as-is.

The specs is the only mechanism that discriminates between user input and the 
rest.  I don't think that rejecting them upfront is a good approach.

> I'll try to brainstorm on this, thanks for letting me know about the
> Solaris target problem.

Let's fix the regression quickly though.

-- 
Eric Botcazou


Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-22 Thread David Miller
From: Eric Botcazou 
Date: Sun, 23 Oct 2011 00:22:14 +0200

> This breaks -mcpu on Solaris though because TARGET_DEFAULT has MASK_V8PLUS.
> So any setting below or equal to -mcpu=v8 triggers an architecture mismatch 
> between assembler and compiler.
> 
> I think we need to go the specs route.  I'd just add a mv8plus rule to 
> CC1_SPEC 
> in config/sparc/linux64.h similar to the one present in config/sparc/sol2.h.
> This works as OPTION_DEFAULT_SPECS shouldn't prepend anything if you pass 
> -m32.

This is precisely what I tried initially, and my posting was
explicitly trying to explain that this kind of approach cannot
work. :-)

> But I presume this still leaves us with the problem for the 32-bit compiler.

I tried these kinds of things.  No matter what you do the OPTION_DEFAULT_SPECS
either get in the way of the native bitness or the non-native bitness of
compiler's default target.

Personally, I tend to build a 32-bit compiler and test 64-bit things by
giving -m64.  Richard has been building 64-bit compilers and using -m32
to test 32-bit stuff.

Furthermore, consider that we need to solve this issue for things
other than MASK_V8PLUS.  For example VIS2, VIS3, and FMAF all need
similar treatment.

Given that, I don't think we want to keep banging the specs for every
new MASK we add, even if it could work.  I think the specs are quite
convoluted as-is.

I'll try to brainstorm on this, thanks for letting me know about the
Solaris target problem.


Re: [PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-22 Thread Eric Botcazou
> You can't just fix this -mv8plus problem universally using spec
> tricks.  Spec rules such as "{!-mcpu*:-mcpu=v9}" never trigger for the
> default bitness, because OPTION_DEFAULT_SPECS appends "-mcpu=v7" or
> similar to the command line first.
>
> Therefore, I put the cpu bump to v9 into sparc_override_options()
> itself, this handles all possible cases.

This breaks -mcpu on Solaris though because TARGET_DEFAULT has MASK_V8PLUS.
So any setting below or equal to -mcpu=v8 triggers an architecture mismatch 
between assembler and compiler.

I think we need to go the specs route.  I'd just add a mv8plus rule to CC1_SPEC 
in config/sparc/linux64.h similar to the one present in config/sparc/sol2.h.
This works as OPTION_DEFAULT_SPECS shouldn't prepend anything if you pass -m32.

But I presume this still leaves us with the problem for the 32-bit compiler.

-- 
Eric Botcazou


[PATCH] Fix mv8plus, allow targetting Linux or Solaris from other sparc host.

2011-10-14 Thread David Miller

Richard reported to me that we wouldn't have a mulsi3 pattern with
"-m32 -mv8plus", which left me dumbfounded. It seemed impossible.

Clarifying further, the case is when gcc is built for a target of
sparc64-linux.  And indeed I was able to reproduce this, a 32-bit
mutliply results in a libcall.

The problem is that the default cpu when 32-bit is v7, and applying
the cpu disable bits in sparc_override_options() clears MASK_ISA
which includes MASK_V8PLUS.

While diagnosing this I added all kinds of debugging helpers to
sparc_override_options() so that the next guy can figure this kind of
thing out more quickly.  "-mdebug=x,y,z" is added, and currently
recognizes "options" and "all".  More can be added later, as needed,
to ease sparc backend maintainence.

You can't just fix this -mv8plus problem universally using spec
tricks.  Spec rules such as "{!-mcpu*:-mcpu=v9}" never trigger for the
default bitness, because OPTION_DEFAULT_SPECS appends "-mcpu=v7" or
similar to the command line first.

Therefore, I put the cpu bump to v9 into sparc_override_options()
itself, this handles all possible cases.

sparc64-sun-solaris2* by wouldn't hit this problem, because the
default cpu there is v9.

While testing to see what happens on Solaris, I noticed that it has
become impossible to cross from one sparc target to Linux/Sparc or
Solaris/Sparc.  This is because the ifdef guard for EXTRA_SPEC_FUNCTIONS
is not identical to the test used to decide if driver-sparc.o should
be included in the build, so we get a link failure in such cross
situations.

That issue is fixed here too.

Commited to trunk.

gcc/

* config/sparc/sol2.h: Protect -m{cpu,tune}=native handling
with a more complete cpp test.
* config/sparc/linux64.h: Likewise.
* config/sparc/linux.h: Likewise.
* config/sparc/sparc.opt (sparc_debug): New target variable.
(mdebug): New target option.
* config/sparc/sparc.h (MASK_DEBUG_OPTIONS, MASK_DEBUG_ALL,
TARGET_DEBUG_OPTIONS): New defines.
* config/sparc/sparc.c (debug_target_flag_bits,
debug_target_flags): New functions.
(sparc_option_override): Add name strings back to cpu_table[].
Parse -mdebug string.  When TARGET_DEBUG_OPTIONS is true, print
out the target flags before and after override processing as well
as the selected cpu.  If MASK_V8PLUS, make sure that the selected
cpu is at least v9.
---
 gcc/ChangeLog  |   18 +
 gcc/config/sparc/linux.h   |2 +-
 gcc/config/sparc/linux64.h |2 +-
 gcc/config/sparc/sol2.h|2 +-
 gcc/config/sparc/sparc.c   |  161 ++--
 gcc/config/sparc/sparc.h   |6 ++
 gcc/config/sparc/sparc.opt |8 ++
 7 files changed, 174 insertions(+), 25 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8eac26e..2bc40b0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2011-10-14  David S. Miller  
+
+   * config/sparc/sol2.h: Protect -m{cpu,tune}=native handling
+   with a more complete cpp test.
+   * config/sparc/linux64.h: Likewise.
+   * config/sparc/linux.h: Likewise.
+   * config/sparc/sparc.opt (sparc_debug): New target variable.
+   (mdebug): New target option.
+   * config/sparc/sparc.h (MASK_DEBUG_OPTIONS, MASK_DEBUG_ALL,
+   TARGET_DEBUG_OPTIONS): New defines.
+   * config/sparc/sparc.c (debug_target_flag_bits,
+   debug_target_flags): New functions.
+   (sparc_option_override): Add name strings back to cpu_table[].
+   Parse -mdebug string.  When TARGET_DEBUG_OPTIONS is true, print
+   out the target flags before and after override processing as well
+   as the selected cpu.  If MASK_V8PLUS, make sure that the selected
+   cpu is at least v9.
+
 2011-10-15  Oleg Endo  
 
PR target/49263
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 0ad4b34..443c796 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -41,7 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* -mcpu=native handling only makes sense with compiler running on
a SPARC chip.  */
-#if defined(__sparc__)
+#if defined(__sparc__) && defined(__linux__)
 extern const char *host_detect_local_cpu (int argc, const char **argv);
 # define EXTRA_SPEC_FUNCTIONS  \
   { "local_cpu_detect", host_detect_local_cpu },
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index b87116a..a51a2f0 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -139,7 +139,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* -mcpu=native handling only makes sense with compiler running on
a SPARC chip.  */
-#if defined(__sparc__)
+#if defined(__sparc__) && defined(__linux__)
 extern const char *host_detect_local_cpu (int argc, const char **argv);
 # define EXTRA_SPEC_FUNCTIONS  \
   { "loc