aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-02-19 00:51:16 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2003-02-19 00:51:16 +0000
commit62e1dfcf2f4ba9568194e08ebccdd1b1c1db78f3 (patch)
tree80e4f09c68d9f7c5a7226ee0a859bf2f53c872a8 /gcc
parent5e93e88adf5643394ee014e06d2c8f13fafaff96 (diff)
downloadgcc-62e1dfcf2f4ba9568194e08ebccdd1b1c1db78f3.zip
gcc-62e1dfcf2f4ba9568194e08ebccdd1b1c1db78f3.tar.gz
gcc-62e1dfcf2f4ba9568194e08ebccdd1b1c1db78f3.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c9
-rw-r--r--gcc/config/rs6000/rs6000.c38
-rw-r--r--gcc/doc/tm.texi6
-rw-r--r--gcc/target-def.h5
-rw-r--r--gcc/target.h3
5 files changed, 61 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index f3b6bb9..d784d3e 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -574,6 +574,11 @@ comptypes (type1, type2)
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;
}
@@ -4064,6 +4069,10 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
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
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 240f2d5..9920534 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -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 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. */
@@ -420,6 +422,9 @@ static const char alt_reg_names[][8] =
#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
@@ -13588,4 +13593,37 @@ rs6000_memory_move_cost (mode, class, in)
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"
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 9e8c4a2..6277057 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1452,6 +1452,12 @@ floating-point arithmetic.
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
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 985d651..57d6e98 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -256,6 +256,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#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
@@ -303,6 +307,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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, \
diff --git a/gcc/target.h b/gcc/target.h
index f671321..90660d9 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -320,6 +320,9 @@ struct gcc_target
/* 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. */