This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch: Re: rfc: auto-casted vector types


+ @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}.
Kill this chunk entirely.
Doh!  Thought I had deleted that.

And incorporate its wording here:

  This target hook should return @code{true} if no cast is
  needed when copying a vector value of type @var{type1} into a
  vector lvalue of type @var{type2}.  The default is that there are no
  such types.
Done.

+ extern bool rs6000_spe_vector_types_compatible PARAMS ((tree, tree));
This function can and should now be made static.
Done.

+ /* Allow SPE vector types to be inter-converted.  */
+ #define TARGET_VECTOR_TYPES_COMPATIBLE
rs6000_spe_vector_types_compatible
Make this definition with the other target-hook defines, in rs6000.c.
Ah, I see. Done.

One last change. I changed the test to only run for powerpc-eabi* since linux has TARGET_SPE set to 0 by default.

How does this look?

2003-02-18 Nick Clifton <nickc@redhat.com>
Aldy Hernandez <aldyh@redhat.com>

* testsuite/gcc.dg/20030218-1.c: New.

* doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.

* target-def.h (TARGET_INITIALIZER): Add
TARGET_VECTOR_TYPES_COMPATIBLE.
(TARGET_VECTOR_TYPES_COMPATIBLE): New macro.

* target.h (struct gcc_target): Add field 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.c (is_ev64_opaque_type): New.
(rs6000_spe_vector_types_compatible): New.
(TARGET_VECTOR_TYPES_COMPATIBLE): Define.

Index: testsuite/gcc.dg/20030218-1.c
===================================================================
RCS file: testsuite/gcc.dg/20030218-1.c
diff -N testsuite/gcc.dg/20030218-1.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/20030218-1.c 18 Feb 2003 23:15:07 -0000
***************
*** 0 ****
--- 1,16 ----
+ /* { dg-do compile { target powerpc-*-eabi* } } */
+ /* { dg-options "-mcpu=8540" } */
+
+ /* Test vectors that can interconvert without a cast. */
+
+ int vint __attribute__((mode(V2SI)));
+ int vshort __attribute__((mode(V4HI)));
+ int vfloat __attribute__((mode(V2SF)));
+
+ int
+ main (void)
+ {
+ vint = vfloat;
+ vshort = vint;
+ vfloat = vshort; /* { dg-error "incompatible types in assignment" } */
+ }
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 23:15:19 -0000
*************** floating-point arithmetic.
*** 1452,1457 ****
--- 1452,1463 ----
The default definition of this macro returns false for all sizes.
@end table

+ @deftypefn {Target Hook} bool TARGET_VECTOR_TYPES_COMPATIBLE (tree @var{type1}, tree @var{type2})
+ This target hook should return @code{true} if no cast is needed when
+ copying a vector value of type @var{type1} into a vector lvalue of
+ type @var{type2}. The default is that there are no such types.
+ @end deftypefn
+
@deftypefn {Target Hook} bool TARGET_MS_BITFIELD_LAYOUT_P (tree @var{record_type})
This target hook returns @code{true} if bit-fields in the given
@var{record_type} are to be laid out following the rules of Microsoft
Index: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.42
diff -c -p -r1.42 target-def.h
*** target-def.h 28 Jan 2003 18:08:48 -0000 1.42
--- target-def.h 18 Feb 2003 23:15:21 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 256,261 ****
--- 256,265 ----
#define TARGET_VALID_POINTER_MODE default_valid_pointer_mode
#endif

+ #ifndef TARGET_VECTOR_TYPES_COMPATIBLE
+ #define TARGET_VECTOR_TYPES_COMPATIBLE hook_bool_tree_tree_false
+ #endif
+
/* In hook.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false
*************** Foundation, 59 Temple Place - Suite 330,
*** 299,304 ****
--- 303,309 ----
TARGET_ENCODE_SECTION_INFO, \
TARGET_STRIP_NAME_ENCODING, \
TARGET_VALID_POINTER_MODE, \
+ TARGET_VECTOR_TYPES_COMPATIBLE, \
TARGET_RTX_COSTS, \
TARGET_ADDRESS_COST, \
TARGET_HAVE_NAMED_SECTIONS, \
Index: target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.48
diff -c -p -r1.48 target.h
*** target.h 28 Jan 2003 18:08:48 -0000 1.48
--- target.h 18 Feb 2003 23:15:21 -0000
*************** struct gcc_target
*** 314,319 ****
--- 314,322 ----
/* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */
bool (* valid_pointer_mode) PARAMS ((enum machine_mode mode));

+ /* True if two vector types can be copied without an explicit cast. */
+ bool (* vector_types_compatible) PARAMS ((tree, tree));
+
/* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */
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 23:15:30 -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 = (*targetm.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
+ && (*targetm.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: 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 23:15:41 -0000
*************** static void is_altivec_return_reg PARAMS
*** 265,270 ****
--- 265,272 ----
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));
+ static bool rs6000_spe_vector_types_compatible PARAMS ((tree, tree));

/* Hash table stuff for keeping track of TOC entries. */

*************** static const char alt_reg_names[][8] =
*** 410,415 ****
--- 412,420 ----
#undef TARGET_ADDRESS_COST
#define TARGET_ADDRESS_COST hook_int_rtx_0

+ #undef TARGET_VECTOR_TYPES_COMPATIBLE
+ #define TARGET_VECTOR_TYPES_COMPATIBLE rs6000_spe_vector_types_compatible
+
struct gcc_target targetm = TARGET_INITIALIZER;

/* Override command line options. Mostly we process the processor
*************** rs6000_memory_move_cost (mode, class, in
*** 13522,13527 ****
--- 13527,13565 ----
return 4 * HARD_REGNO_NREGS (FIRST_ALTIVEC_REGNO, mode);
else
return 4 + rs6000_register_move_cost (mode, class, GENERAL_REGS);
+ }
+
+ /* Return true if TYPE is of type __ev64_opaque__. */
+
+ 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 if vector type1 can be converted into vector type2. */
+
+ static bool
+ rs6000_spe_vector_types_compatible (t1, t2)
+ tree t1;
+ tree t2;
+ {
+ if (!TARGET_SPE
+ || 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]