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: unsigned vectors


yet another patch from the "is everything vector related broken?"
department. :)

vector int should not be the same as vector unsigned int, and currently
they are.

i ran into this while coding the overloaded vector functions for
altivec.

i also cleaned up some code in type_for_mode() that called TYPE_MODE on
a node, when we already knew the mode.

tested on ppc linux.  no regressions.

ok?

-- 
Aldy Hernandez			E-mail: aldyh@redhat.com
Professional Gypsy
Red Hat, Inc.

2001-12-10  Aldy Hernandez  <aldyh@redhat.com>

	* c-common.c (type_for_mode): Handle unsigned vectors.
	(type_for_mode): Remove redundant calls to TYPE_MODE.

	* tree.c (make_vector): New.
	(build_common_tree_nodes_2): Use make_vector for vector types.
	Add unsigned vector types.

	* tree.h (tree_index): Add unsigned types for vectors.
	(unsigned_V16QI_type_node): New.
	(unsigned_V4SI_type_node): New.
	(unsigned_V8QI_type_node): New.
	(unsigned_V8HI_type_node): New.
	(unsigned_V4HI_type_node): New.
	(unsigned_V2SI_type_node): New.

Index: c-common.c
===================================================================
RCS file: /cvs/uberbaum/gcc/c-common.c,v
retrieving revision 1.279
diff -c -p -r1.279 c-common.c
*** c-common.c	2001/12/05 23:19:54	1.279
--- c-common.c	2001/12/11 00:27:40
*************** type_for_mode (mode, unsignedp)
*** 1315,1330 ****
      return unsignedp ? widest_unsigned_literal_type_node
                       : widest_integer_literal_type_node;
  
!   if (mode == TYPE_MODE (intQI_type_node))
      return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
  
!   if (mode == TYPE_MODE (intHI_type_node))
      return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
  
!   if (mode == TYPE_MODE (intSI_type_node))
      return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
  
!   if (mode == TYPE_MODE (intDI_type_node))
      return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
  
  #if HOST_BITS_PER_WIDE_INT >= 64
--- 1315,1330 ----
      return unsignedp ? widest_unsigned_literal_type_node
                       : widest_integer_literal_type_node;
  
!   if (mode == QImode)
      return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
  
!   if (mode == HImode)
      return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
  
!   if (mode == SImode)
      return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
  
!   if (mode == DImode)
      return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
  
  #if HOST_BITS_PER_WIDE_INT >= 64
*************** type_for_mode (mode, unsignedp)
*** 1348,1369 ****
      return build_pointer_type (integer_type_node);
  
  #ifdef VECTOR_MODE_SUPPORTED_P
!   if (mode == TYPE_MODE (V16QI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V16QI_type_node;
!   if (mode == TYPE_MODE (V8HI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V8HI_type_node;
!   if (mode == TYPE_MODE (V4SF_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V4SF_type_node;
!   if (mode == TYPE_MODE (V4SI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V4SI_type_node;
!   if (mode == TYPE_MODE (V2SI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V2SI_type_node;
!   if (mode == TYPE_MODE (V4HI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V4HI_type_node;
!   if (mode == TYPE_MODE (V8QI_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V8QI_type_node;
!   if (mode == TYPE_MODE (V2SF_type_node) && VECTOR_MODE_SUPPORTED_P (mode))
!     return V2SF_type_node;
  #endif
  
    return 0;
--- 1348,1377 ----
      return build_pointer_type (integer_type_node);
  
  #ifdef VECTOR_MODE_SUPPORTED_P
!   if (VECTOR_MODE_SUPPORTED_P (mode))
!     {
!       switch (mode)
! 	{
! 	case V16QImode:
! 	  return unsignedp ? unsigned_V16QI_type_node : V16QI_type_node;
! 	case V8HImode:
! 	  return unsignedp ? unsigned_V8HI_type_node : V8HI_type_node;
! 	case V4SImode:
! 	  return unsignedp ? unsigned_V4SI_type_node : V4SI_type_node;
! 	case V2SImode:
! 	  return unsignedp ? unsigned_V2SI_type_node : V2SI_type_node;
! 	case V4HImode:
! 	  return unsignedp ? unsigned_V4HI_type_node : V4HI_type_node;
! 	case V8QImode:
! 	  return unsignedp ? unsigned_V8QI_type_node : V8QI_type_node;
! 	case V4SFmode:
! 	  return V4SF_type_node;
! 	case V2SFmode:
! 	  return V2SF_type_node;
! 	default:
! 	  return 0;
! 	}
!     }
  #endif
  
    return 0;
Index: tree.c
===================================================================
RCS file: /cvs/uberbaum/gcc/tree.c,v
retrieving revision 1.228
diff -c -p -r1.228 tree.c
*** tree.c	2001/12/10 01:28:03	1.228
--- tree.c	2001/12/11 00:27:52
*************** static int type_hash_eq PARAMS ((const v
*** 162,167 ****
--- 162,168 ----
  static unsigned int type_hash_hash PARAMS ((const void*));
  static void print_type_hash_statistics PARAMS((void));
  static void finish_vector_type PARAMS((tree));
+ static tree make_vector PARAMS ((enum machine_mode, tree, int));
  static int type_hash_marked_p PARAMS ((const void *));
  static void type_hash_mark PARAMS ((const void *));
  static int mark_tree_hashtable_entry PARAMS((void **, void *));
*************** build_common_tree_nodes_2 (short_double)
*** 4874,4916 ****
      va_list_type_node = t;
    }
  
!   V4SF_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V4SF_type_node) = float_type_node;
!   TYPE_MODE (V4SF_type_node) = V4SFmode;
!   finish_vector_type (V4SF_type_node);
! 
!   V4SI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V4SI_type_node) = intSI_type_node;
!   TYPE_MODE (V4SI_type_node) = V4SImode;
!   finish_vector_type (V4SI_type_node);
! 
!   V2SI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V2SI_type_node) = intSI_type_node;
!   TYPE_MODE (V2SI_type_node) = V2SImode;
!   finish_vector_type (V2SI_type_node);
! 
!   V4HI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V4HI_type_node) = intHI_type_node;
!   TYPE_MODE (V4HI_type_node) = V4HImode;
!   finish_vector_type (V4HI_type_node);
! 
!   V8QI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V8QI_type_node) = intQI_type_node;
!   TYPE_MODE (V8QI_type_node) = V8QImode;
!   finish_vector_type (V8QI_type_node);
! 
!   V8HI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V8HI_type_node) = intHI_type_node;
!   TYPE_MODE (V8HI_type_node) = V8HImode;
!   finish_vector_type (V8HI_type_node);
! 
!   V2SF_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V2SF_type_node) = float_type_node;
!   TYPE_MODE (V2SF_type_node) = V2SFmode;
!   finish_vector_type (V2SF_type_node);
! 
!   V16QI_type_node = make_node (VECTOR_TYPE);
!   TREE_TYPE (V16QI_type_node) = intQI_type_node;
!   TYPE_MODE (V16QI_type_node) = V16QImode;
!   finish_vector_type (V16QI_type_node);
  }
--- 4875,4919 ----
      va_list_type_node = t;
    }
  
!   unsigned_V4SI_type_node
!     = make_vector (V4SImode, unsigned_intSI_type_node, 1);
!   unsigned_V2SI_type_node
!     = make_vector (V2SImode, unsigned_intSI_type_node, 1);
!   unsigned_V4HI_type_node
!     = make_vector (V4HImode, unsigned_intHI_type_node, 1);
!   unsigned_V8QI_type_node
!     = make_vector (V8QImode, unsigned_intQI_type_node, 1);
!   unsigned_V8HI_type_node
!     = make_vector (V8HImode, unsigned_intHI_type_node, 1);
!   unsigned_V16QI_type_node
!     = make_vector (V16QImode, unsigned_intQI_type_node, 1);
! 
!   V4SF_type_node = make_vector (V4SFmode, float_type_node, 0);
!   V4SI_type_node = make_vector (V4SImode, intSI_type_node, 0);
!   V2SI_type_node = make_vector (V2SImode, intSI_type_node, 0);
!   V4HI_type_node = make_vector (V4HImode, intHI_type_node, 0);
!   V8QI_type_node = make_vector (V8QImode, intQI_type_node, 0);
!   V8HI_type_node = make_vector (V8HImode, intHI_type_node, 0);
!   V2SF_type_node = make_vector (V2SFmode, float_type_node, 0);
!   V16QI_type_node = make_vector (V16QImode, intQI_type_node, 0);
! }
! 
! /* Returns a vector tree node given a vector mode, the inner type, and
!    the signness.  */
! 
! static tree
! make_vector (mode, innertype, unsignedp)
!      enum machine_mode mode;
!      tree innertype;
!      int unsignedp;
! {
!   tree t;
! 
!   t = make_node (VECTOR_TYPE);
!   TREE_TYPE (t) = innertype;
!   TYPE_MODE (t) = mode;
!   TREE_UNSIGNED (TREE_TYPE (t)) = unsignedp;
!   finish_vector_type (t);
! 
!   return t;
  }
Index: tree.h
===================================================================
RCS file: /cvs/uberbaum/gcc/tree.h,v
retrieving revision 1.293
diff -c -p -r1.293 tree.h
*** tree.h	2001/12/05 22:37:30	1.293
--- tree.h	2001/12/11 00:28:03
*************** enum tree_index
*** 1888,1893 ****
--- 1888,1902 ----
  
    TI_VOID_LIST_NODE,
  
+   TI_UV4SF_TYPE,
+   TI_UV4SI_TYPE,
+   TI_UV8HI_TYPE,
+   TI_UV8QI_TYPE,
+   TI_UV4HI_TYPE,
+   TI_UV2SI_TYPE,
+   TI_UV2SF_TYPE,
+   TI_UV16QI_TYPE,
+ 
    TI_V4SF_TYPE,
    TI_V4SI_TYPE,
    TI_V8HI_TYPE,
*************** extern tree global_trees[TI_MAX];
*** 1955,1960 ****
--- 1964,1976 ----
  
  #define main_identifier_node		global_trees[TI_MAIN_IDENTIFIER]
  #define MAIN_NAME_P(NODE) (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node)
+ 
+ #define unsigned_V16QI_type_node	global_trees[TI_UV16QI_TYPE]
+ #define unsigned_V4SI_type_node		global_trees[TI_UV4SI_TYPE]
+ #define unsigned_V8QI_type_node		global_trees[TI_UV8QI_TYPE]
+ #define unsigned_V8HI_type_node		global_trees[TI_UV8HI_TYPE]
+ #define unsigned_V4HI_type_node		global_trees[TI_UV4HI_TYPE]
+ #define unsigned_V2SI_type_node		global_trees[TI_UV2SI_TYPE]
  
  #define V16QI_type_node			global_trees[TI_V16QI_TYPE]
  #define V4SF_type_node			global_trees[TI_V4SF_TYPE]


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