public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64
@ 2015-01-15  1:19 Segher Boessenkool
  2015-01-15  1:47 ` [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4 Segher Boessenkool
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-15  1:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

UNITS_PER_WORD is 8 with -m32 -mpowerpc64.  Promoting items smaller
than 8 bytes to 4 bytes doesn't make sense.

I tried to fix it the other way around first, promoting everything
smaller than UNITS_PER_WORD to word_mode; this fails all over the
place, because word_mode is bigger than Pmode.  So let's not do that ;-)

Okay for mainline?


Segher


2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* config/rs6000/rs6000.h (PROMOTE_MODE): Correct test for when -m32
	-mpowerpc64 is active.

---
 gcc/config/rs6000/rs6000.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index c55d7ed..ef6bb2f 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -733,7 +733,7 @@ extern unsigned char rs6000_recip_bits[];
 
 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)	\
   if (GET_MODE_CLASS (MODE) == MODE_INT		\
-      && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
+      && GET_MODE_SIZE (MODE) < (TARGET_32BIT ? 4 : 8)) \
     (MODE) = TARGET_32BIT ? SImode : DImode;
 
 /* Define this if most significant bit is lowest numbered
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4
  2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
@ 2015-01-15  1:47 ` Segher Boessenkool
  2015-01-15  4:53   ` David Edelsohn
  2015-01-15  3:51 ` [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE Segher Boessenkool
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-15  1:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

This fixes 88 testsuite FAILs.

-mpowerpc64 does not change the ABI, but it does change the value of
UNITS_PER_WORD.  This code is for 32-bit only so we can use
MIN_UNITS_PER_WORD instead.

Bootstrapped and tested as usual.  Okay for mainline?


Segher


2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* config/rs6000/rs6000.c (rs6000_va_start): Use MIN_UNITS_PER_WORD
	instead of UNITS_PER_WORD to describe the size of stack slots.

---
 gcc/config/rs6000/rs6000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index ca5ce28..afced72 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -11232,7 +11232,7 @@ rs6000_va_start (tree valist, rtx nextarg)
   /* Find the overflow area.  */
   t = make_tree (TREE_TYPE (ovf), virtual_incoming_args_rtx);
   if (words != 0)
-    t = fold_build_pointer_plus_hwi (t, words * UNITS_PER_WORD);
+    t = fold_build_pointer_plus_hwi (t, words * MIN_UNITS_PER_WORD);
   t = build2 (MODIFY_EXPR, TREE_TYPE (ovf), ovf, t);
   TREE_SIDE_EFFECTS (t) = 1;
   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE
  2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
  2015-01-15  1:47 ` [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4 Segher Boessenkool
@ 2015-01-15  3:51 ` Segher Boessenkool
  2015-01-15  4:43   ` David Edelsohn
  2015-01-15  4:36 ` [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode Segher Boessenkool
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-15  3:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

As the existing comment explains, we should always promote function
arguments and return values.  However, notwithstanding its name,
default_promote_function_mode_always_promote does not always promote.
Importantly, it does not for libcalls.  This makes ftrapv-[12].c fail
with 64-bit ABIs.

This patch introduces an rs6000_promote_function_mode that _does_
always promote, fixing this.

Tested as usual (c,c++,fortran,ada; -m32,-m32/-mpowerpc64,-m64,-m64/-mlra).
Is this okay for mainline?


Segher


2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* config/rs6000/rs6000.c (TARGET_PROMOTE_FUNCTION_MODE): Implement
	as rs6000_promote_function_mode.  Move comment to there.
	(rs6000_promote_function_mode): New function.

---
 gcc/config/rs6000/rs6000.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4f8803d..ca5ce28 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1504,10 +1504,8 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #undef TARGET_MEMBER_TYPE_FORCES_BLK
 #define TARGET_MEMBER_TYPE_FORCES_BLK rs6000_member_type_forces_blk
 
-/* On rs6000, function arguments are promoted, as are function return
-   values.  */
 #undef TARGET_PROMOTE_FUNCTION_MODE
-#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
+#define TARGET_PROMOTE_FUNCTION_MODE rs6000_promote_function_mode
 
 #undef TARGET_RETURN_IN_MEMORY
 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
@@ -9301,6 +9299,20 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
     }
 }
 \f
+/* On rs6000, function arguments are promoted, as are function return
+   values.  */
+
+static machine_mode
+rs6000_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
+			      machine_mode mode,
+			      int *punsignedp ATTRIBUTE_UNUSED,
+			      const_tree, int)
+{
+  PROMOTE_MODE (mode, *punsignedp, type);
+
+  return mode;
+}
+
 /* Return true if TYPE must be passed on the stack and not in registers.  */
 
 static bool
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode
  2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
  2015-01-15  1:47 ` [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4 Segher Boessenkool
  2015-01-15  3:51 ` [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE Segher Boessenkool
@ 2015-01-15  4:36 ` Segher Boessenkool
  2015-01-15  5:00   ` David Edelsohn
  2015-01-15  4:37 ` [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64 Segher Boessenkool
  2015-01-15  4:39 ` [PATCH 1/5] rs6000: Fix PROMOTE_MODE for " David Edelsohn
  4 siblings, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-15  4:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

Some hooks return word_mode by default, which is incorrect for -m32
-mpowerpc64.  This patch creates a new function rs6000_abi_word_mode
to implement these hooks, and does so.

This fixes 163 testuite FAILs.

[ David already OKed this fixed version, but sending it again is easier
  for me.  Lazy, etc. ]


2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* config/rs6000/rs6000.c (TARGET_LIBGCC_CMP_RETURN_MODE,
	TARGET_LIBGCC_SHIFT_COUNT_MODE, TARGET_UNWIND_WORD_MODE): Implement
	as ...
	(rs6000_abi_word_mode): New function.

---
 gcc/config/rs6000/rs6000.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index afced72..6c91f3c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1669,6 +1669,13 @@ static const struct attribute_spec rs6000_attribute_table[] =
 
 #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV
 #define TARGET_ATOMIC_ASSIGN_EXPAND_FENV rs6000_atomic_assign_expand_fenv
+
+#undef TARGET_LIBGCC_CMP_RETURN_MODE
+#define TARGET_LIBGCC_CMP_RETURN_MODE rs6000_abi_word_mode
+#undef TARGET_LIBGCC_SHIFT_COUNT_MODE
+#define TARGET_LIBGCC_SHIFT_COUNT_MODE rs6000_abi_word_mode
+#undef TARGET_UNWIND_WORD_MODE
+#define TARGET_UNWIND_WORD_MODE rs6000_abi_word_mode
 \f
 
 /* Processor table.  */
@@ -9299,6 +9306,15 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
     }
 }
 \f
+/* The mode the ABI uses for a word.  This is not the same as word_mode
+   for -m32 -mpowerpc64.  This is used to implement various target hooks.  */
+
+static machine_mode
+rs6000_abi_word_mode (void)
+{
+  return TARGET_32BIT ? SImode : DImode;
+}
+
 /* On rs6000, function arguments are promoted, as are function return
    values.  */
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64
  2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
                   ` (2 preceding siblings ...)
  2015-01-15  4:36 ` [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode Segher Boessenkool
@ 2015-01-15  4:37 ` Segher Boessenkool
  2015-01-15 16:18   ` David Edelsohn
  2015-01-15  4:39 ` [PATCH 1/5] rs6000: Fix PROMOTE_MODE for " David Edelsohn
  4 siblings, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-15  4:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

This fixes 141 FAILs.

-mpowerpc64 does not change the ABI, but default_scalar_mode_supported_p
does not know that, and allows TImode for -m32 -mpowerpc64.

This fixes it.  Okay for mainline?


2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* config/rs6000/rs6000.c (rs6000_scalar_mode_supported_p): Disallow
	TImode for TARGET_32BIT.

---
 gcc/config/rs6000/rs6000.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 6c91f3c..8fa9a22 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -31960,6 +31960,10 @@ rs6000_eh_return_filter_mode (void)
 static bool
 rs6000_scalar_mode_supported_p (machine_mode mode)
 {
+  /* For -m32 -mpowerpc64 we want the same ABI as for -m32.  */
+  if (TARGET_32BIT && mode == TImode)
+    return false;
+
   if (DECIMAL_FLOAT_MODE_P (mode))
     return default_decimal_float_supported_p ();
   else
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64
  2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
                   ` (3 preceding siblings ...)
  2015-01-15  4:37 ` [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64 Segher Boessenkool
@ 2015-01-15  4:39 ` David Edelsohn
  4 siblings, 0 replies; 11+ messages in thread
From: David Edelsohn @ 2015-01-15  4:39 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> UNITS_PER_WORD is 8 with -m32 -mpowerpc64.  Promoting items smaller
> than 8 bytes to 4 bytes doesn't make sense.
>
> I tried to fix it the other way around first, promoting everything
> smaller than UNITS_PER_WORD to word_mode; this fails all over the
> place, because word_mode is bigger than Pmode.  So let's not do that ;-)
>
> Okay for mainline?
>
>
> Segher
>
>
> 2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * config/rs6000/rs6000.h (PROMOTE_MODE): Correct test for when -m32
>         -mpowerpc64 is active.

Okay.

Thanks, David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE
  2015-01-15  3:51 ` [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE Segher Boessenkool
@ 2015-01-15  4:43   ` David Edelsohn
  0 siblings, 0 replies; 11+ messages in thread
From: David Edelsohn @ 2015-01-15  4:43 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> As the existing comment explains, we should always promote function
> arguments and return values.  However, notwithstanding its name,
> default_promote_function_mode_always_promote does not always promote.
> Importantly, it does not for libcalls.  This makes ftrapv-[12].c fail
> with 64-bit ABIs.
>
> This patch introduces an rs6000_promote_function_mode that _does_
> always promote, fixing this.
>
> Tested as usual (c,c++,fortran,ada; -m32,-m32/-mpowerpc64,-m64,-m64/-mlra).
> Is this okay for mainline?
>
>
> Segher
>
>
> 2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * config/rs6000/rs6000.c (TARGET_PROMOTE_FUNCTION_MODE): Implement
>         as rs6000_promote_function_mode.  Move comment to there.
>         (rs6000_promote_function_mode): New function.

Okay.

Thanks, David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4
  2015-01-15  1:47 ` [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4 Segher Boessenkool
@ 2015-01-15  4:53   ` David Edelsohn
  0 siblings, 0 replies; 11+ messages in thread
From: David Edelsohn @ 2015-01-15  4:53 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> This fixes 88 testsuite FAILs.
>
> -mpowerpc64 does not change the ABI, but it does change the value of
> UNITS_PER_WORD.  This code is for 32-bit only so we can use
> MIN_UNITS_PER_WORD instead.
>
> Bootstrapped and tested as usual.  Okay for mainline?
>
>
> Segher
>
>
> 2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * config/rs6000/rs6000.c (rs6000_va_start): Use MIN_UNITS_PER_WORD
>         instead of UNITS_PER_WORD to describe the size of stack slots.

Okay.

Thanks, David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode
  2015-01-15  4:36 ` [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode Segher Boessenkool
@ 2015-01-15  5:00   ` David Edelsohn
  0 siblings, 0 replies; 11+ messages in thread
From: David Edelsohn @ 2015-01-15  5:00 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> Some hooks return word_mode by default, which is incorrect for -m32
> -mpowerpc64.  This patch creates a new function rs6000_abi_word_mode
> to implement these hooks, and does so.
>
> This fixes 163 testuite FAILs.
>
> [ David already OKed this fixed version, but sending it again is easier
>   for me.  Lazy, etc. ]
>
>
> 2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * config/rs6000/rs6000.c (TARGET_LIBGCC_CMP_RETURN_MODE,
>         TARGET_LIBGCC_SHIFT_COUNT_MODE, TARGET_UNWIND_WORD_MODE): Implement
>         as ...
>         (rs6000_abi_word_mode): New function.

Okay.

Thanks, David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64
  2015-01-15  4:37 ` [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64 Segher Boessenkool
@ 2015-01-15 16:18   ` David Edelsohn
  2015-01-16 16:58     ` Segher Boessenkool
  0 siblings, 1 reply; 11+ messages in thread
From: David Edelsohn @ 2015-01-15 16:18 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches

On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> This fixes 141 FAILs.
>
> -mpowerpc64 does not change the ABI, but default_scalar_mode_supported_p
> does not know that, and allows TImode for -m32 -mpowerpc64.
>
> This fixes it.  Okay for mainline?
>
>
> 2015-01-14  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * config/rs6000/rs6000.c (rs6000_scalar_mode_supported_p): Disallow
>         TImode for TARGET_32BIT.

Okay.

Would you please add a comment that efficient TImode arithmetic
requires carry to explain the TARGET_32BIT relationship?

We can think about providing TImode logical operations in 32 bit, in
the long run.

Thanks, David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64
  2015-01-15 16:18   ` David Edelsohn
@ 2015-01-16 16:58     ` Segher Boessenkool
  0 siblings, 0 replies; 11+ messages in thread
From: Segher Boessenkool @ 2015-01-16 16:58 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GCC Patches

On Thu, Jan 15, 2015 at 11:06:38AM -0500, David Edelsohn wrote:
> On Wed, Jan 14, 2015 at 8:14 PM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > This fixes 141 FAILs.
> >
> > -mpowerpc64 does not change the ABI, but default_scalar_mode_supported_p
> > does not know that, and allows TImode for -m32 -mpowerpc64.

> Would you please add a comment that efficient TImode arithmetic
> requires carry to explain the TARGET_32BIT relationship?

I expanded the comment to:

  /* -m32 does not support TImode.  This is the default, from
     default_scalar_mode_supported_p.  For -m32 -mpowerpc64 we want the
     same ABI as for -m32.  But default_scalar_mode_supported_p allows
     integer modes of precision 2 * BITS_PER_WORD, which matches TImode
     for -mpowerpc64.  */

because the reasons why we do or do not suppoort TImode with -m32 are
pretty much irrelevant here.  Hope that's okay.

> We can think about providing TImode logical operations in 32 bit, in
> the long run.

Generic code would handle that just fine already, AFAICS.  We just do
not allow TImode at all (like most (all?) other 32-bit targets).


Segher

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-01-16 16:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15  1:19 [PATCH 1/5] rs6000: Fix PROMOTE_MODE for -m32 -mpowerpc64 Segher Boessenkool
2015-01-15  1:47 ` [PATCH 3/5] rs6000: Fix va_start handling for -m32 -mpowerpc64 ABI_V4 Segher Boessenkool
2015-01-15  4:53   ` David Edelsohn
2015-01-15  3:51 ` [PATCH 2/5] rs6000: Fix TARGET_PROMOTE_FUNCTION_MODE Segher Boessenkool
2015-01-15  4:43   ` David Edelsohn
2015-01-15  4:36 ` [PATCH 4/5] rs6000: Introducing rs6000_abi_word_mode Segher Boessenkool
2015-01-15  5:00   ` David Edelsohn
2015-01-15  4:37 ` [PATCH 5/5] rs6000: Do not allow TImode with -m32 -mpowerpc64 Segher Boessenkool
2015-01-15 16:18   ` David Edelsohn
2015-01-16 16:58     ` Segher Boessenkool
2015-01-15  4:39 ` [PATCH 1/5] rs6000: Fix PROMOTE_MODE for " David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).