patch: Re: rfc: auto-casted vector types
Aldy Hernandez
aldyh@redhat.com
Tue Feb 18 04:38:00 GMT 2003
> 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. */
More information about the Gcc
mailing list