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]

[PATCH c/middle-end] Replace vector_opaque_p with a bit in the type


I think I've already posted the patch, but it never was committed.
Since these types are never created by the user (e.g. with attributes),
it makes less sense in my opinion to use a target hook than for
TARGET_MS_BITFIELD_TYPE_P.

Ok for 4.5?

Paolo
2006-09-17  Paolo Bonzini  <bonzini@gnu.org>

	* c-common.c (vector_types_convertible_p): Use TYPE_VECTOR_OPAQUE
	instead of targetm.vector_opaque_p.
	* c-typeck.c (convert_for_assignment): Likewise, and on vectors
	rather than pointers.
	(really_start_incremental_init): Likewise.
	* target-def.h (TARGET_VECTOR_OPAQUE_P): Remove.
	(TARGET_INITIALIZER): Remove it.
	* target.h (struct target): Remove vector_opaque_p.
	* tree.c (build_opaque_vector_type): New.
	* tree.h (TYPE_VECTOR_OPAQUE): New.
	(build_opaque_vector_type): Declare.
	* doc/tm.texi (TARGET_VECTOR_OPAQUE_P): Remove.
	* config/rs6000/rs6000.c (build_opaque_vector_type,
	rs6000_is_vector_type, TARGET_VECTOR_OPAQUE_P): Remove.
	(rs6000_init_builtins): Use build_opaque_vector_type for
	opaque_V4SI_type_node.

cp:
2006-09-17  Paolo Bonzini  <bonzini@gnu.org>

	* decl.c (check_initializer): Use TYPE_VECTOR_OPAQUE
	instead of targetm.vector_opaque_p.

Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi	(branch opaque-vectors)
+++ gcc/doc/tm.texi	(working copy)
@@ -1424,14 +1424,6 @@ floating-point arithmetic.
 The default definition of this macro returns false for all sizes.
 @end defmac
 
-@deftypefn {Target Hook} bool TARGET_VECTOR_OPAQUE_P (tree @var{type})
-This target hook should return @code{true} a vector is opaque.  That
-is, if no cast is needed when copying a vector value of type
-@var{type} into another vector lvalue of the same size.  Vector opaque
-types cannot be initialized.  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: gcc/tree.c
===================================================================
--- gcc/tree.c	(branch opaque-vectors)
+++ gcc/tree.c	(working copy)
@@ -7925,6 +7925,19 @@ build_vector_type (tree innertype, int n
   return make_vector_type (innertype, nunits, VOIDmode);
 }
 
+/* Similarly, but takes the inner type and number of units, which must be
+   a power of two.  */
+
+tree
+build_opaque_vector_type (tree innertype, int nunits)
+{
+  tree t;
+  innertype = build_distinct_type_copy (innertype);
+  t = make_vector_type (innertype, nunits, VOIDmode);
+  TYPE_VECTOR_OPAQUE (t) = true;
+  return t;
+}
+
 
 /* Build RESX_EXPR with given REGION_NUMBER.  */
 tree
Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(branch opaque-vectors)
+++ gcc/tree.h	(working copy)
@@ -594,6 +594,9 @@ struct tree_common GTY(())
        STMT_IN_SSA_EDGE_WORKLIST in
            all expressions (tree-ssa-propagate.c)
 
+	TYPE_VECTOR_OPAQUE in
+	   VECTOR_TYPE
+
    visited:
 
        TREE_VISITED in
@@ -2228,6 +2231,11 @@ extern enum machine_mode vector_type_mod
 #define SET_TYPE_VECTOR_SUBPARTS(VECTOR_TYPE, X) \
   (VECTOR_TYPE_CHECK (VECTOR_TYPE)->type.precision = exact_log2 (X))
 
+/* Nonzero in an IDENTIFIER_NODE if the name is a local alias, whose
+   uses are to be substituted for uses of the TREE_CHAINed identifier.  */
+#define TYPE_VECTOR_OPAQUE(NODE) \
+  (VECTOR_TYPE_CHECK (NODE)->common.deprecated_flag)
+
 /* Indicates that objects of this type must be initialized by calling a
    function when they are created.  */
 #define TYPE_NEEDS_CONSTRUCTING(NODE) \
@@ -3996,6 +4004,7 @@ extern tree build_reference_type_for_mod
 extern tree build_reference_type (tree);
 extern tree build_vector_type_for_mode (tree, enum machine_mode);
 extern tree build_vector_type (tree innertype, int nunits);
+extern tree build_opaque_vector_type (tree innertype, int nunits);
 extern tree build_type_no_quals (tree);
 extern tree build_index_type (tree);
 extern tree build_index_2_type (tree, tree);
Index: gcc/target.h
===================================================================
--- gcc/target.h	(branch opaque-vectors)
+++ gcc/target.h	(working copy)
@@ -672,9 +672,6 @@ struct gcc_target
      for further details.  */
   bool (* vector_mode_supported_p) (enum machine_mode mode);
 
-  /* True if a vector is opaque.  */
-  bool (* vector_opaque_p) (const_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: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(branch opaque-vectors)
+++ gcc/cp/decl.c	(working copy)
@@ -5133,7 +5133,7 @@ check_initializer (tree decl, tree init,
 		       decl);
 	      init = build_tree_list (NULL_TREE, init);
 	    }
-	  else if ((*targetm.vector_opaque_p) (type))
+	  else if (TYPE_VECTOR_OPAQUE (type))
 	    {
 	      error ("opaque vector types cannot be initialized");
 	      init = error_mark_node;
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c	(branch opaque-vectors)
+++ gcc/c-typeck.c	(working copy)
@@ -5287,7 +5287,7 @@ really_start_incremental_init (tree type
   if (type == 0)
     type = TREE_TYPE (constructor_decl);
 
-  if (targetm.vector_opaque_p (type))
+  if (TYPE_VECTOR_OPAQUE (type))
     error ("opaque vector types cannot be initialized");
 
   p->type = constructor_type;
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h	(branch opaque-vectors)
+++ gcc/target-def.h	(working copy)
@@ -473,10 +473,6 @@
 #define TARGET_VECTOR_MODE_SUPPORTED_P hook_bool_mode_false
 #endif
 
-#ifndef TARGET_VECTOR_OPAQUE_P
-#define TARGET_VECTOR_OPAQUE_P hook_bool_const_tree_false
-#endif
-
 /* In hooks.c.  */
 #define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
 #define TARGET_BRANCH_TARGET_REGISTER_CLASS hook_int_void_no_regs
@@ -881,7 +877,6 @@
   TARGET_VALID_POINTER_MODE,                    \
   TARGET_SCALAR_MODE_SUPPORTED_P,		\
   TARGET_VECTOR_MODE_SUPPORTED_P,               \
-  TARGET_VECTOR_OPAQUE_P,			\
   TARGET_RTX_COSTS,				\
   TARGET_ADDRESS_COST,				\
   TARGET_ALLOCATE_INITIAL_VALUE,		\
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(branch opaque-vectors)
+++ gcc/c-common.c	(working copy)
@@ -1352,7 +1352,7 @@ bool
 vector_targets_convertible_p (const_tree t1, const_tree t2)
 {
   if (TREE_CODE (t1) == VECTOR_TYPE && TREE_CODE (t2) == VECTOR_TYPE
-      && (targetm.vector_opaque_p (t1) || targetm.vector_opaque_p (t2))
+      && (TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
       && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
     return true;
 
@@ -1370,7 +1370,7 @@ vector_types_convertible_p (const_tree t
   static bool emitted_lax_note = false;
   bool convertible_lax;
 
-  if ((targetm.vector_opaque_p (t1) || targetm.vector_opaque_p (t2))
+  if ((TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
       && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
     return true;
 
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(branch opaque-vectors)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -885,7 +885,6 @@ static rtx paired_expand_predicate_built
 static void enable_mask_for_builtins (struct builtin_description *, int,
 				      enum rs6000_builtins,
 				      enum rs6000_builtins);
-static tree build_opaque_vector_type (tree, int);
 static void spe_init_builtins (void);
 static rtx spe_expand_builtin (tree, rtx, bool *);
 static rtx spe_expand_stv_builtin (enum insn_code, tree);
@@ -916,7 +915,6 @@ static void compute_save_world_info (rs6
 static void is_altivec_return_reg (rtx, void *);
 static rtx generate_set_vrsave (rtx, rs6000_stack_t *, int);
 int easy_vector_constant (rtx, enum machine_mode);
-static bool rs6000_is_opaque_type (const_tree);
 static rtx rs6000_dwarf_register_span (rtx);
 static void rs6000_init_dwarf_reg_sizes_extra (tree);
 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
@@ -1191,9 +1189,6 @@ static const char alt_reg_names[][8] =
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
 
-#undef TARGET_VECTOR_OPAQUE_P
-#define TARGET_VECTOR_OPAQUE_P rs6000_is_opaque_type
-
 #undef TARGET_DWARF_REGISTER_SPAN
 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
 
@@ -9358,15 +9353,6 @@ rs6000_expand_builtin (tree exp, rtx tar
   gcc_unreachable ();
 }
 
-static tree
-build_opaque_vector_type (tree node, int nunits)
-{
-  node = copy_node (node);
-  TYPE_MAIN_VARIANT (node) = node;
-  TYPE_CANONICAL (node) = node;
-  return build_vector_type (node, nunits);
-}
-
 static void
 rs6000_init_builtins (void)
 {
@@ -9385,7 +9371,7 @@ rs6000_init_builtins (void)
   opaque_V2SF_type_node = build_opaque_vector_type (float_type_node, 2);
   opaque_V2SI_type_node = build_opaque_vector_type (intSI_type_node, 2);
   opaque_p_V2SI_type_node = build_pointer_type (opaque_V2SI_type_node);
-  opaque_V4SI_type_node = copy_node (V4SI_type_node);
+  opaque_V4SI_type_node = build_opaque_vector_type (intSI_type_node, 4);
 
   /* The 'vector bool ...' types must be kept distinct from 'vector unsigned ...'
      types, especially in C++ land.  Similarly, 'vector pixel' is distinct from
@@ -22673,16 +22659,6 @@ rs6000_initial_elimination_offset (int f
   return offset;
 }
 
-/* Return true if TYPE is a SPE or AltiVec opaque type.  */
-
-static bool
-rs6000_is_opaque_type (const_tree type)
-{
-  return (type == opaque_V2SI_type_node
-	      || type == opaque_V2SF_type_node
-	      || type == opaque_V4SI_type_node);
-}
-
 static rtx
 rs6000_dwarf_register_span (rtx reg)
 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]