Commit 62e1dfcf by Nick Clifton Committed by Aldy Hernandez

20030218-1.c: New.

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.

        * config/rs6000/rs6000.c (is_ev64_opaque_type): New.
        (rs6000_spe_vector_types_compatible): New.
        (TARGET_VECTOR_TYPES_COMPATIBLE): Define.

From-SVN: r63080
parent 5e93e88a
...@@ -574,6 +574,11 @@ comptypes (type1, type2) ...@@ -574,6 +574,11 @@ comptypes (type1, type2)
val = 1; val = 1;
break; break;
case VECTOR_TYPE:
/* The target might allow certain vector types to be compatible. */
val = (*targetm.vector_types_compatible) (t1, t2);
break;
default: default:
break; break;
} }
...@@ -4064,6 +4069,10 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) ...@@ -4064,6 +4069,10 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
rhs = build1 (NOP_EXPR, type, rhs); rhs = build1 (NOP_EXPR, type, rhs);
return 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. */ /* Arithmetic types all interconvert, and enum is treated like int. */
else if ((codel == INTEGER_TYPE || codel == REAL_TYPE else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
|| codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
......
...@@ -268,6 +268,8 @@ static void is_altivec_return_reg PARAMS ((rtx, void *)); ...@@ -268,6 +268,8 @@ static void is_altivec_return_reg PARAMS ((rtx, void *));
static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int)); static rtx generate_set_vrsave PARAMS ((rtx, rs6000_stack_t *, int));
static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT)); static void altivec_frame_fixup PARAMS ((rtx, rtx, HOST_WIDE_INT));
static int easy_vector_constant PARAMS ((rtx)); 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. */ /* Hash table stuff for keeping track of TOC entries. */
...@@ -420,6 +422,9 @@ static const char alt_reg_names[][8] = ...@@ -420,6 +422,9 @@ static const char alt_reg_names[][8] =
#undef TARGET_ADDRESS_COST #undef TARGET_ADDRESS_COST
#define TARGET_ADDRESS_COST hook_int_rtx_0 #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; struct gcc_target targetm = TARGET_INITIALIZER;
/* Override command line options. Mostly we process the processor /* Override command line options. Mostly we process the processor
...@@ -13588,4 +13593,37 @@ rs6000_memory_move_cost (mode, class, in) ...@@ -13588,4 +13593,37 @@ rs6000_memory_move_cost (mode, class, in)
return 4 + rs6000_register_move_cost (mode, class, GENERAL_REGS); 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" #include "gt-rs6000.h"
...@@ -1452,6 +1452,12 @@ floating-point arithmetic. ...@@ -1452,6 +1452,12 @@ floating-point arithmetic.
The default definition of this macro returns false for all sizes. The default definition of this macro returns false for all sizes.
@end table @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}) @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 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 @var{record_type} are to be laid out following the rules of Microsoft
......
...@@ -256,6 +256,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -256,6 +256,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_VALID_POINTER_MODE default_valid_pointer_mode #define TARGET_VALID_POINTER_MODE default_valid_pointer_mode
#endif #endif
#ifndef TARGET_VECTOR_TYPES_COMPATIBLE
#define TARGET_VECTOR_TYPES_COMPATIBLE hook_bool_tree_tree_false
#endif
/* In hook.c. */ /* In hook.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false #define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false #define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false
...@@ -303,6 +307,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -303,6 +307,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_ENCODE_SECTION_INFO, \ TARGET_ENCODE_SECTION_INFO, \
TARGET_STRIP_NAME_ENCODING, \ TARGET_STRIP_NAME_ENCODING, \
TARGET_VALID_POINTER_MODE, \ TARGET_VALID_POINTER_MODE, \
TARGET_VECTOR_TYPES_COMPATIBLE, \
TARGET_RTX_COSTS, \ TARGET_RTX_COSTS, \
TARGET_ADDRESS_COST, \ TARGET_ADDRESS_COST, \
TARGET_HAVE_NAMED_SECTIONS, \ TARGET_HAVE_NAMED_SECTIONS, \
......
...@@ -320,6 +320,9 @@ struct gcc_target ...@@ -320,6 +320,9 @@ struct gcc_target
/* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */ /* True if MODE is valid for a pointer in __attribute__((mode("MODE"))). */
bool (* valid_pointer_mode) PARAMS ((enum machine_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 /* Compute a (partial) cost for rtx X. Return true if the complete
cost has been computed, and false if subexpressions should be cost has been computed, and false if subexpressions should be
scanned. In either case, *TOTAL contains the cost result. */ scanned. In either case, *TOTAL contains the cost result. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment