* rfc: auto-casted vector types
@ 2003-02-13 21:09 Aldy Hernandez
2003-02-17 19:52 ` Aldy Hernandez
2003-02-17 22:33 ` Jim Wilson
0 siblings, 2 replies; 10+ messages in thread
From: Aldy Hernandez @ 2003-02-13 21:09 UTC (permalink / raw)
To: GCC Mailinglist; +Cc: Nick Clifton, Jim Wilson
The PPC E500 API specifies that vector types of type __ev64_opaque__
(V2SImode) can interconvert with other vector types without a cast.
For example:
#define __vector __attribute__((vector_size(8)))
typedef int __vector __ev64_opaque__;
typedef float __vector __ev64_fs__;
typedef int __vector __ev64_int__;
__ev64_fs__ f;
__ev64_int__ i;
__ev64_opaque__ op;
/* Do not require a cast. */
op = f;
f = op;
op = i;
i = op;
I had originally kludged a solution in comptypes() and
convert_for_assignment() because I thought nobody would be interested
(or would agree), but Nick has since cleaned up my patches a bit, and
they don't look that bad: three lines of actual generic code.
I'd like to get input on:
(a) the feasibility of including these patches
(b) alternate solutions that would be accepted
(c) including the patch below in contrib/
As you can probably guess, I didn't design the API, so no flames please
;-).
Comments?
2003-02-13 Nick Clifton <nickc@redhat.com>
Aldy Hernandez <aldyh@redhat.com>
* doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
* c-typeck.c (comptypes): Take into account
TARGET_VECTOR_TYPES_COMPATIBLE.
(convert_for_assignment): Same.
* config/rs6000/rs6000-protos.h
(rs6000_spe_vector_types_compatible): Prototype.
* config/rs6000/rs6000.c (is_ev64_opaque_type): New.
(rs6000_spe_vector_types_compatible): New.
* config/rs6000/rs6000.h (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.198
diff -c -p -r1.198 tm.texi
*** doc/tm.texi 31 Jan 2003 23:34:17 -0000 1.198
--- doc/tm.texi 13 Feb 2003 20:50:20 -0000
*************** Define this macro to be nonzero if the p
*** 1302,1307 ****
--- 1302,1312 ----
involving vector mode @var{mode}. At the very least, it must have
move
patterns for this mode.
+ @findex TARGET_VECTOR_TYPES_COMPATIBLE
+ @item TARGET_VECTOR_TYPES_COMPATIBLE(@var{tree1}, @var{tree2})
+ Define this macro to return nonzero if no cast is needed when copying
+ a value of type @var{tree1} to a value of type @var{tree2}.
+
@findex STACK_SAVEAREA_MODE
@item STACK_SAVEAREA_MODE (@var{save_level})
If defined, an expression of type @code{enum machine_mode} that
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.218
diff -c -p -r1.218 c-typeck.c
*** c-typeck.c 1 Feb 2003 13:09:39 -0000 1.218
--- c-typeck.c 13 Feb 2003 20:50:35 -0000
*************** comptypes (type1, type2)
*** 574,579 ****
--- 574,586 ----
val = 1;
break;
+ case VECTOR_TYPE:
+ #ifdef TARGET_VECTOR_TYPES_COMPATIBLE
+ /* The target might allow certain vector types to be
compatible. */
+ val = TARGET_VECTOR_TYPES_COMPATIBLE (t1, t2);
+ #endif
+ break;
+
default:
break;
}
*************** convert_for_assignment (type, rhs, errty
*** 4061,4066 ****
--- 4068,4079 ----
rhs = build1 (NOP_EXPR, type, rhs);
return rhs;
}
+ #ifdef TARGET_VECTOR_TYPES_COMPATIBLE
+ /* Some types can interconvert without explicit casts. */
+ else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
+ && TARGET_VECTOR_TYPES_COMPATIBLE (type, rhstype))
+ return convert (type, rhs);
+ #endif
/* Arithmetic types all interconvert, and enum is treated like int.
*/
else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
|| codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.422
diff -c -p -r1.422 rs6000.c
*** config/rs6000/rs6000.c 10 Feb 2003 18:42:19 -0000 1.422
--- config/rs6000/rs6000.c 13 Feb 2003 20:51:03 -0000
*************** static void is_altivec_return_reg PARAMS
*** 265,270 ****
--- 265,271 ----
static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int));
static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT));
static int easy_vector_constant PARAMS ((rtx));
+ static int is_ev64_opaque_type PARAMS ((tree));
/* Hash table stuff for keeping track of TOC entries. */
*************** rs6000_memory_move_cost (mode, class, in
*** 13522,13527 ****
--- 13523,13556 ----
return 4 * HARD_REGNO_NREGS (FIRST_ALTIVEC_REGNO, mode);
else
return 4 + rs6000_register_move_cost (mode, class, GENERAL_REGS);
+ }
+
+ static int
+ is_ev64_opaque_type (type)
+ tree type;
+ {
+ return (TYPE_NAME (type)
+ && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type))
+ && strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
+ "__ev64_opaque__") == 0);
+ }
+
+ /* Return true iff vector type1 can be converted into vector type2.
*/
+
+ int
+ rs6000_spe_vector_types_compatible (t1, t2)
+ tree t1;
+ tree t2;
+ {
+ if (TREE_CODE (t1) != VECTOR_TYPE || TREE_CODE (t2) != VECTOR_TYPE)
+ return 0;
+
+ if (TYPE_NAME (t1) || TYPE_NAME (t2))
+ return is_ev64_opaque_type (t1) || is_ev64_opaque_type (t2);
+
+ /* The V2SI type is the basis of the ev64_opaque type. */
+ return t1 == V2SI_type_node || t2 == V2SI_type_node;
}
#include "gt-rs6000.h"
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.251
diff -c -p -r1.251 rs6000.h
*** config/rs6000/rs6000.h 8 Feb 2003 03:59:40 -0000 1.251
--- config/rs6000/rs6000.h 13 Feb 2003 20:51:11 -0000
*************** extern int rs6000_default_long_calls;
*** 892,897 ****
--- 892,901 ----
|| (MODE) == V1DImode \
|| (MODE) == V2SImode)
+ /* Allow SPE vector types to be inter-converted. */
+ #define TARGET_VECTOR_TYPES_COMPATIBLE(t1,t2) \
+ (TARGET_SPE ? rs6000_spe_vector_types_compatible (t1, t2) : 0)
+
/* Define this macro to be nonzero if the port is prepared to handle
insns involving vector mode MODE. At the very least, it must have
move patterns for this mode. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-13 21:09 rfc: auto-casted vector types Aldy Hernandez
@ 2003-02-17 19:52 ` Aldy Hernandez
2003-02-17 20:33 ` Zack Weinberg
2003-02-18 7:40 ` Mark Mitchell
2003-02-17 22:33 ` Jim Wilson
1 sibling, 2 replies; 10+ messages in thread
From: Aldy Hernandez @ 2003-02-17 19:52 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: GCC Mailinglist, Nick Clifton, Jim Wilson, Zack Weinberg
ping.
could i get some comments on this, or the patches look sensible enough
to submit for inclusion?
aldy
On Thursday, February 13, 2003, at 01:01 PM, Aldy Hernandez wrote:
> The PPC E500 API specifies that vector types of type __ev64_opaque__
> (V2SImode) can interconvert with other vector types without a cast.
>
> For example:
>
> #define __vector __attribute__((vector_size(8)))
> typedef int __vector __ev64_opaque__;
> typedef float __vector __ev64_fs__;
> typedef int __vector __ev64_int__;
>
> __ev64_fs__ f;
> __ev64_int__ i;
> __ev64_opaque__ op;
>
> /* Do not require a cast. */
> op = f;
> f = op;
> op = i;
> i = op;
>
> I had originally kludged a solution in comptypes() and
> convert_for_assignment() because I thought nobody would be interested
> (or would agree), but Nick has since cleaned up my patches a bit, and
> they don't look that bad: three lines of actual generic code.
>
> I'd like to get input on:
>
> (a) the feasibility of including these patches
> (b) alternate solutions that would be accepted
> (c) including the patch below in contrib/
>
> As you can probably guess, I didn't design the API, so no flames
> please ;-).
>
> Comments?
>
> 2003-02-13 Nick Clifton <nickc@redhat.com>
> Aldy Hernandez <aldyh@redhat.com>
>
> * doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
>
> * c-typeck.c (comptypes): Take into account
> TARGET_VECTOR_TYPES_COMPATIBLE.
> (convert_for_assignment): Same.
>
> * config/rs6000/rs6000-protos.h
> (rs6000_spe_vector_types_compatible): Prototype.
>
> * config/rs6000/rs6000.c (is_ev64_opaque_type): New.
> (rs6000_spe_vector_types_compatible): New.
>
> * config/rs6000/rs6000.h (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
>
> Index: doc/tm.texi
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
> retrieving revision 1.198
> diff -c -p -r1.198 tm.texi
> *** doc/tm.texi 31 Jan 2003 23:34:17 -0000 1.198
> --- doc/tm.texi 13 Feb 2003 20:50:20 -0000
> *************** Define this macro to be nonzero if the p
> *** 1302,1307 ****
> --- 1302,1312 ----
> involving vector mode @var{mode}. At the very least, it must have
> move
> patterns for this mode.
>
> + @findex TARGET_VECTOR_TYPES_COMPATIBLE
> + @item TARGET_VECTOR_TYPES_COMPATIBLE(@var{tree1}, @var{tree2})
> + Define this macro to return nonzero if no cast is needed when copying
> + a value of type @var{tree1} to a value of type @var{tree2}.
> +
> @findex STACK_SAVEAREA_MODE
> @item STACK_SAVEAREA_MODE (@var{save_level})
> If defined, an expression of type @code{enum machine_mode} that
> Index: c-typeck.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
> retrieving revision 1.218
> diff -c -p -r1.218 c-typeck.c
> *** c-typeck.c 1 Feb 2003 13:09:39 -0000 1.218
> --- c-typeck.c 13 Feb 2003 20:50:35 -0000
> *************** comptypes (type1, type2)
> *** 574,579 ****
> --- 574,586 ----
> val = 1;
> break;
>
> + case VECTOR_TYPE:
> + #ifdef TARGET_VECTOR_TYPES_COMPATIBLE
> + /* The target might allow certain vector types to be
> compatible. */
> + val = TARGET_VECTOR_TYPES_COMPATIBLE (t1, t2);
> + #endif
> + break;
> +
> default:
> break;
> }
> *************** convert_for_assignment (type, rhs, errty
> *** 4061,4066 ****
> --- 4068,4079 ----
> rhs = build1 (NOP_EXPR, type, rhs);
> return rhs;
> }
> + #ifdef TARGET_VECTOR_TYPES_COMPATIBLE
> + /* Some types can interconvert without explicit casts. */
> + else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
> + && TARGET_VECTOR_TYPES_COMPATIBLE (type, rhstype))
> + return convert (type, rhs);
> + #endif
> /* Arithmetic types all interconvert, and enum is treated like
> int. */
> else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
> || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
> Index: config/rs6000/rs6000.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
> retrieving revision 1.422
> diff -c -p -r1.422 rs6000.c
> *** config/rs6000/rs6000.c 10 Feb 2003 18:42:19 -0000 1.422
> --- config/rs6000/rs6000.c 13 Feb 2003 20:51:03 -0000
> *************** static void is_altivec_return_reg PARAMS
> *** 265,270 ****
> --- 265,271 ----
> static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int));
> static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT));
> static int easy_vector_constant PARAMS ((rtx));
> + static int is_ev64_opaque_type PARAMS ((tree));
>
> /* Hash table stuff for keeping track of TOC entries. */
>
> *************** rs6000_memory_move_cost (mode, class, in
> *** 13522,13527 ****
> --- 13523,13556 ----
> return 4 * HARD_REGNO_NREGS (FIRST_ALTIVEC_REGNO, mode);
> else
> return 4 + rs6000_register_move_cost (mode, class, GENERAL_REGS);
> + }
> +
> + static int
> + is_ev64_opaque_type (type)
> + tree type;
> + {
> + return (TYPE_NAME (type)
> + && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
> + && DECL_NAME (TYPE_NAME (type))
> + && strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
> + "__ev64_opaque__") == 0);
> + }
> +
> + /* Return true iff vector type1 can be converted into vector type2.
> */
> +
> + int
> + rs6000_spe_vector_types_compatible (t1, t2)
> + tree t1;
> + tree t2;
> + {
> + if (TREE_CODE (t1) != VECTOR_TYPE || TREE_CODE (t2) != VECTOR_TYPE)
> + return 0;
> +
> + if (TYPE_NAME (t1) || TYPE_NAME (t2))
> + return is_ev64_opaque_type (t1) || is_ev64_opaque_type (t2);
> +
> + /* The V2SI type is the basis of the ev64_opaque type. */
> + return t1 == V2SI_type_node || t2 == V2SI_type_node;
> }
>
> #include "gt-rs6000.h"
> Index: config/rs6000/rs6000.h
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
> retrieving revision 1.251
> diff -c -p -r1.251 rs6000.h
> *** config/rs6000/rs6000.h 8 Feb 2003 03:59:40 -0000 1.251
> --- config/rs6000/rs6000.h 13 Feb 2003 20:51:11 -0000
> *************** extern int rs6000_default_long_calls;
> *** 892,897 ****
> --- 892,901 ----
> || (MODE) == V1DImode \
> || (MODE) == V2SImode)
>
> + /* Allow SPE vector types to be inter-converted. */
> + #define TARGET_VECTOR_TYPES_COMPATIBLE(t1,t2) \
> + (TARGET_SPE ? rs6000_spe_vector_types_compatible (t1, t2) : 0)
> +
> /* Define this macro to be nonzero if the port is prepared to handle
> insns involving vector mode MODE. At the very least, it must have
> move patterns for this mode. */
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-17 19:52 ` Aldy Hernandez
@ 2003-02-17 20:33 ` Zack Weinberg
2003-02-18 7:40 ` Mark Mitchell
1 sibling, 0 replies; 10+ messages in thread
From: Zack Weinberg @ 2003-02-17 20:33 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: Aldy Hernandez, GCC Mailinglist, Nick Clifton, Jim Wilson
Aldy Hernandez <aldy@andrews.edu> writes:
> ping.
>
> could i get some comments on this, or the patches look sensible enough
> to submit for inclusion?
It looks decent to me. I would suggest that here
>> + @findex TARGET_VECTOR_TYPES_COMPATIBLE
>> + @item TARGET_VECTOR_TYPES_COMPATIBLE(@var{tree1}, @var{tree2})
>> + Define this macro to return nonzero if no cast is needed when copying
>> + a value of type @var{tree1} to a value of type @var{tree2}.
you say that this works only for vector types (I realize this is
implied by the name, but it should be said explicitly anyway); and
rather than putting #ifdefs in c-typeck.c, make this a target hook
whose default is 'always return 0'.
zw
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-13 21:09 rfc: auto-casted vector types Aldy Hernandez
2003-02-17 19:52 ` Aldy Hernandez
@ 2003-02-17 22:33 ` Jim Wilson
2003-02-17 23:35 ` Kumar Gala
` (3 more replies)
1 sibling, 4 replies; 10+ messages in thread
From: Jim Wilson @ 2003-02-17 22:33 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: GCC Mailinglist, Nick Clifton
Aldy Hernandez <aldyh@redhat.com> writes:
> The PPC E500 API specifies that vector types of type __ev64_opaque__
> (V2SImode) can interconvert with other vector types without a cast.
Is there any publicly available documentation? My copy of the draft docs
say they are Motorola confidential. If there is documentation available,
it would be useful to point to it somewhere.
I tried searching the Motorola web site. I found Altivec PIM documentation,
but no SPE PIM documentation.
> * doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
> * c-typeck.c (comptypes): Take into account
> TARGET_VECTOR_TYPES_COMPATIBLE.
> (convert_for_assignment): Same.
> ...
The patch looks pretty reasonable to me also. I agree with Zack's suggestions.
It might be useful to note in the comments in the rs6000 file that the
current implementation has a known flaw. It pretends that V2SI is the opaque
vector type. This means that it accidentally allows conversions to/from the
V2SI vector type without explicit casts. In order to fix this, we need to
use a different otherwise unused vector type for the opaque vector type.
Nick started on a patch to do this, but didn't have enough time to finish it.
Jim
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-17 22:33 ` Jim Wilson
@ 2003-02-17 23:35 ` Kumar Gala
2003-02-17 23:53 ` Kumar Gala
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Kumar Gala @ 2003-02-17 23:35 UTC (permalink / raw)
To: Jim Wilson; +Cc: Aldy Hernandez, GCC Mailinglist, Nick Clifton
The SPE PIM docs are not currently publicly available.
- kumar
On Monday, February 17, 2003, at 04:25 PM, Jim Wilson wrote:
> Aldy Hernandez <aldyh@redhat.com> writes:
>
>> The PPC E500 API specifies that vector types of type __ev64_opaque__
>> (V2SImode) can interconvert with other vector types without a cast.
>
> Is there any publicly available documentation? My copy of the draft
> docs
> say they are Motorola confidential. If there is documentation
> available,
> it would be useful to point to it somewhere.
>
> I tried searching the Motorola web site. I found Altivec PIM
> documentation,
> but no SPE PIM documentation.
>
>> * doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
>> * c-typeck.c (comptypes): Take into account
>> TARGET_VECTOR_TYPES_COMPATIBLE.
>> (convert_for_assignment): Same.
>> ...
>
> The patch looks pretty reasonable to me also. I agree with Zack's
> suggestions.
>
> It might be useful to note in the comments in the rs6000 file that the
> current implementation has a known flaw. It pretends that V2SI is the
> opaque
> vector type. This means that it accidentally allows conversions
> to/from the
> V2SI vector type without explicit casts. In order to fix this, we
> need to
> use a different otherwise unused vector type for the opaque vector
> type.
> Nick started on a patch to do this, but didn't have enough time to
> finish it.
>
> Jim
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-17 22:33 ` Jim Wilson
2003-02-17 23:35 ` Kumar Gala
@ 2003-02-17 23:53 ` Kumar Gala
2003-02-18 3:50 ` Geoff Keating
2003-02-18 4:38 ` patch: " Aldy Hernandez
3 siblings, 0 replies; 10+ messages in thread
From: Kumar Gala @ 2003-02-17 23:53 UTC (permalink / raw)
To: Jim Wilson; +Cc: Aldy Hernandez, GCC Mailinglist, Nick Clifton
> The patch looks pretty reasonable to me also. I agree with Zack's
> suggestions.
>
> It might be useful to note in the comments in the rs6000 file that the
> current implementation has a known flaw. It pretends that V2SI is the
> opaque
> vector type. This means that it accidentally allows conversions
> to/from the
> V2SI vector type without explicit casts. In order to fix this, we
> need to
> use a different otherwise unused vector type for the opaque vector
> type.
> Nick started on a patch to do this, but didn't have enough time to
> finish it.
If this is not successful can we make the opaque type map to a 64-bit
data type(V1SI?) instead of the V2SI. I think this would be more
natural if we have to provide something for opaque.
eg
__ev64_opaque__ x = { 0, 3 }; // should fail
__ev64_opaque__ y = { 3 }; // should be ok
- kumar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-17 22:33 ` Jim Wilson
2003-02-17 23:35 ` Kumar Gala
2003-02-17 23:53 ` Kumar Gala
@ 2003-02-18 3:50 ` Geoff Keating
2003-02-18 20:21 ` Aldy Hernandez
2003-02-18 4:38 ` patch: " Aldy Hernandez
3 siblings, 1 reply; 10+ messages in thread
From: Geoff Keating @ 2003-02-18 3:50 UTC (permalink / raw)
To: Jim Wilson; +Cc: GCC Mailinglist, Nick Clifton
Jim Wilson <wilson@redhat.com> writes:
> It might be useful to note in the comments in the rs6000 file that the
> current implementation has a known flaw. It pretends that V2SI is the opaque
> vector type. This means that it accidentally allows conversions to/from the
> V2SI vector type without explicit casts. In order to fix this, we need to
> use a different otherwise unused vector type for the opaque vector type.
> Nick started on a patch to do this, but didn't have enough time to finish it.
This shouldn't be done at the RTL level at all; the right thing to do
is to create a special '__ev64_opaque__' type which is different from
'vector int' and just happens to also have V2SImode (or DImode or
whatever is convenient---I'd vote for DImode since that's what GCC
uses for all-purpose "blob of data" types).
--
- Geoffrey Keating <geoffk@geoffk.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* patch: Re: rfc: auto-casted vector types
2003-02-17 22:33 ` Jim Wilson
` (2 preceding siblings ...)
2003-02-18 3:50 ` Geoff Keating
@ 2003-02-18 4:38 ` Aldy Hernandez
3 siblings, 0 replies; 10+ messages in thread
From: Aldy Hernandez @ 2003-02-18 4:38 UTC (permalink / raw)
To: Jim Wilson; +Cc: GCC Mailinglist, Nick Clifton, gcc-patches, Kumar Gala
> Is there any publicly available documentation? My copy of the draft
> docs
> say they are Motorola confidential. If there is documentation
> available,
> it would be useful to point to it somewhere.
According to Kumar, no.
> The patch looks pretty reasonable to me also. I agree with Zack's
> suggestions.
Done.
> It might be useful to note in the comments in the rs6000 file that the
> current implementation has a known flaw. It pretends that V2SI is the
> opaque
> vector type. This means that it accidentally allows conversions
> to/from the
> V2SI vector type without explicit casts. In order to fix this, we
> need to
I added a comment.
> use a different otherwise unused vector type for the opaque vector
> type.
> Nick started on a patch to do this, but didn't have enough time to
> finish it.
As I recall he used V8QI, but that had other problems. V1DI, as Kumar
suggests,
is probably a better approach, but will require heavily massaging
spe.h/spe.md. I'll try that later, since that will probably break
other things I don't have time to fix right now ;-).
OK, I'm formally submitting the patch now. I've built an spe toolchain
with this, and a generic powerpc-linux bootstrap/regtest is in progress.
OK to install when tests finish?
Aldy
2003-02-17 Nick Clifton <nickc@redhat.com>
Aldy Hernandez <aldyh@redhat.com>
* defaults.h (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
* doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
* c-typeck.c (comptypes): Take into account
TARGET_VECTOR_TYPES_COMPATIBLE.
(convert_for_assignment): Same.
(really_start_incremental_init): Disallow initialization of
ev64_opaque types.
* config/rs6000/rs6000-protos.h
(rs6000_spe_vector_types_compatible): Prototype.
* config/rs6000/rs6000.c (is_ev64_opaque_type): New.
(rs6000_spe_vector_types_compatible): New.
* config/rs6000/rs6000.h (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.101
diff -c -p -r1.101 defaults.h
*** defaults.h 24 Jan 2003 22:07:00 -0000 1.101
--- defaults.h 18 Feb 2003 00:09:35 -0000
*************** You Lose! You must define PREFERRED_DEB
*** 595,600 ****
--- 595,607 ----
#define VECTOR_MODE_SUPPORTED_P(MODE) 0
#endif
+ /* Define this macro to return nonzero if no cast is needed when
+ copying a vector value of type TYPE1 to a vector value of
+ type TYPE2. */
+ #ifndef TARGET_VECTOR_TYPES_COMPATIBLE
+ #define TARGET_VECTOR_TYPES_COMPATIBLE(TYPE1, TYPE2) 0
+ #endif
+
/* Determine whether __cxa_atexit, rather than atexit, is used to
register C++ destructors for local statics and global objects. */
#ifndef DEFAULT_USE_CXA_ATEXIT
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.218
diff -c -p -r1.218 c-typeck.c
*** c-typeck.c 1 Feb 2003 13:09:39 -0000 1.218
--- c-typeck.c 18 Feb 2003 00:09:41 -0000
*************** comptypes (type1, type2)
*** 574,579 ****
--- 574,584 ----
val = 1;
break;
+ case VECTOR_TYPE:
+ /* The target might allow certain vector types to be
compatible. */
+ val = TARGET_VECTOR_TYPES_COMPATIBLE (t1, t2);
+ break;
+
default:
break;
}
*************** convert_for_assignment (type, rhs, errty
*** 4061,4066 ****
--- 4066,4075 ----
rhs = build1 (NOP_EXPR, type, rhs);
return rhs;
}
+ /* Some types can interconvert without explicit casts. */
+ else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
+ && TARGET_VECTOR_TYPES_COMPATIBLE (type, rhstype))
+ return convert (type, rhs);
/* Arithmetic types all interconvert, and enum is treated like int.
*/
else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
|| codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.198
diff -c -p -r1.198 tm.texi
*** doc/tm.texi 31 Jan 2003 23:34:17 -0000 1.198
--- doc/tm.texi 18 Feb 2003 00:10:20 -0000
*************** Define this macro to be nonzero if the p
*** 1302,1307 ****
--- 1302,1313 ----
involving vector mode @var{mode}. At the very least, it must have
move
patterns for this mode.
+ @findex TARGET_VECTOR_TYPES_COMPATIBLE
+ @item TARGET_VECTOR_TYPES_COMPATIBLE(@var{tree1}, @var{tree2})
+ Define this macro to return nonzero if no cast is needed when copying
+ a vector value of type @var{tree1} to a vector value of type
+ @var{tree2}.
+
@findex STACK_SAVEAREA_MODE
@item STACK_SAVEAREA_MODE (@var{save_level})
If defined, an expression of type @code{enum machine_mode} that
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.422
diff -c -p -r1.422 rs6000.c
*** config/rs6000/rs6000.c 10 Feb 2003 18:42:19 -0000 1.422
--- config/rs6000/rs6000.c 18 Feb 2003 00:10:29 -0000
*************** static void is_altivec_return_reg PARAMS
*** 265,270 ****
--- 265,271 ----
static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int));
static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT));
static int easy_vector_constant PARAMS ((rtx));
+ static int is_ev64_opaque_type PARAMS ((tree));
/* Hash table stuff for keeping track of TOC entries. */
*************** rs6000_memory_move_cost (mode, class, in
*** 13522,13527 ****
--- 13523,13558 ----
return 4 * HARD_REGNO_NREGS (FIRST_ALTIVEC_REGNO, mode);
else
return 4 + rs6000_register_move_cost (mode, class, GENERAL_REGS);
+ }
+
+ static int
+ is_ev64_opaque_type (type)
+ tree type;
+ {
+ return (TYPE_NAME (type)
+ && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type))
+ && strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
+ "__ev64_opaque__") == 0);
+ }
+
+ /* Return true iff vector type1 can be converted into vector type2.
*/
+
+ int
+ rs6000_spe_vector_types_compatible (t1, t2)
+ tree t1;
+ tree t2;
+ {
+ if (TREE_CODE (t1) != VECTOR_TYPE || TREE_CODE (t2) != VECTOR_TYPE)
+ return 0;
+
+ if (TYPE_NAME (t1) || TYPE_NAME (t2))
+ return is_ev64_opaque_type (t1) || is_ev64_opaque_type (t2);
+
+ /* FIXME: We assume V2SI is the opaque type, so we accidentally
+ allow inter conversion to and from V2SI modes. We could use
+ V1D1, and rewrite <spe.h> accordingly. */
+ return t1 == V2SI_type_node || t2 == V2SI_type_node;
}
#include "gt-rs6000.h"
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.251
diff -c -p -r1.251 rs6000.h
*** config/rs6000/rs6000.h 8 Feb 2003 03:59:40 -0000 1.251
--- config/rs6000/rs6000.h 18 Feb 2003 00:10:41 -0000
*************** extern int rs6000_default_long_calls;
*** 892,897 ****
--- 892,901 ----
|| (MODE) == V1DImode \
|| (MODE) == V2SImode)
+ /* Allow SPE vector types to be inter-converted. */
+ #define TARGET_VECTOR_TYPES_COMPATIBLE(t1,t2) \
+ (TARGET_SPE ? rs6000_spe_vector_types_compatible (t1, t2) : 0)
+
/* Define this macro to be nonzero if the port is prepared to handle
insns involving vector mode MODE. At the very least, it must have
move patterns for this mode. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-17 19:52 ` Aldy Hernandez
2003-02-17 20:33 ` Zack Weinberg
@ 2003-02-18 7:40 ` Mark Mitchell
1 sibling, 0 replies; 10+ messages in thread
From: Mark Mitchell @ 2003-02-18 7:40 UTC (permalink / raw)
To: Aldy Hernandez, Aldy Hernandez
Cc: GCC Mailinglist, Nick Clifton, Jim Wilson, Zack Weinberg
--On Monday, February 17, 2003 11:16:34 AM -0800 Aldy Hernandez
<aldy@andrews.edu> wrote:
> ping.
>
> could i get some comments on this, or the patches look sensible enough to
> submit for inclusion?
To me, this approach looks plausible. I'd rather we use #if than #ifdef;
can't that TARGET_* stuff go in the target hooks bits? Also, you need some
comments for the new functions.
I don't object to the patch in principle, though.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rfc: auto-casted vector types
2003-02-18 3:50 ` Geoff Keating
@ 2003-02-18 20:21 ` Aldy Hernandez
0 siblings, 0 replies; 10+ messages in thread
From: Aldy Hernandez @ 2003-02-18 20:21 UTC (permalink / raw)
To: Geoff Keating; +Cc: Jim Wilson, GCC Mailinglist, Nick Clifton
>>>>> "Geoff" == Geoff Keating <geoffk@geoffk.org> writes:
> Jim Wilson <wilson@redhat.com> writes:
>> It might be useful to note in the comments in the rs6000 file that the
>> current implementation has a known flaw. It pretends that V2SI is the opaque
>> vector type. This means that it accidentally allows conversions to/from the
>> V2SI vector type without explicit casts. In order to fix this, we need to
>> use a different otherwise unused vector type for the opaque vector type.
>> Nick started on a patch to do this, but didn't have enough time to finish it.
> This shouldn't be done at the RTL level at all; the right thing to do
> is to create a special '__ev64_opaque__' type which is different from
> 'vector int' and just happens to also have V2SImode (or DImode or
> whatever is convenient---I'd vote for DImode since that's what GCC
> uses for all-purpose "blob of data" types).
Actually, I agree with this because I just ran into a similar problem
this morning with an upcoming patch that I solved by looking at the
type instead.
I'll put it on my TODO list.
Aldy
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-02-18 19:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-13 21:09 rfc: auto-casted vector types Aldy Hernandez
2003-02-17 19:52 ` Aldy Hernandez
2003-02-17 20:33 ` Zack Weinberg
2003-02-18 7:40 ` Mark Mitchell
2003-02-17 22:33 ` Jim Wilson
2003-02-17 23:35 ` Kumar Gala
2003-02-17 23:53 ` Kumar Gala
2003-02-18 3:50 ` Geoff Keating
2003-02-18 20:21 ` Aldy Hernandez
2003-02-18 4:38 ` patch: " Aldy Hernandez
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).