altivec c++ obvious fixes

Aldy Hernandez aldyh@redhat.com
Mon Feb 4 21:10:00 GMT 2002


i've found a few buglets while testing the c++ version of altivec.
fixed.

i also noticed the C++ front end expects void_list_node instead
of my tree_cons()ed void node (for builtins accepting no arugments).
fixed.

vec_ld*() for c++ were missing a few cases.  fixed.

vec_step() was not implemented in the c++ version.  fixed.

all of which were pretty obvious fixes.  

committed as obvious.

Cheers.
Aldy

2002-02-05  Aldy Hernandez  <aldyh@redhat.com>

        * config/rs6000/rs6000.c (altivec_init_builtins): Fix typo
        building void typed builtins.

        * config/rs6000/altivec.h (vec_ld*): Fix typos.
        (vec_step): Implement for C++.

Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.280
diff -c -p -r1.280 rs6000.c
*** rs6000.c	2002/02/04 22:50:55	1.280
--- rs6000.c	2002/02/05 02:16:22
*************** rs6000_legitimize_reload_address (x, mod
*** 1802,1807 ****
--- 1802,1808 ----
        *win = 1;
        return x;
      }
+ 
  #if TARGET_MACHO
    if (DEFAULT_ABI == ABI_DARWIN && flag_pic
        && GET_CODE (x) == LO_SUM
*************** altivec_init_builtins (void)
*** 4161,4175 ****
  
    /* void foo (void).  */
    tree void_ftype_void
!     = build_function_type (void_type_node,
! 			   tree_cons (NULL_TREE, void_type_node,
! 				      endlink));
  
    /* vshort foo (void).  */
    tree v8hi_ftype_void
!     = build_function_type (V8HI_type_node,
! 			   tree_cons (NULL_TREE, void_type_node,
! 				      endlink));
  
    tree v4si_ftype_v4si_v4si
      = build_function_type (V4SI_type_node,
--- 4162,4172 ----
  
    /* void foo (void).  */
    tree void_ftype_void
!     = build_function_type (void_type_node, void_list_node);
  
    /* vshort foo (void).  */
    tree v8hi_ftype_void
!     = build_function_type (V8HI_type_node, void_list_node);
  
    tree v4si_ftype_v4si_v4si
      = build_function_type (V4SI_type_node,
Index: config/rs6000/altivec.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/rs6000/altivec.h,v
retrieving revision 1.5
diff -c -p -r1.5 altivec.h
*** altivec.h	2002/02/04 22:50:54	1.5
--- altivec.h	2002/02/05 02:16:25
*************** vec_ld (int a1, vector float *a2)
*** 720,801 ****
    return (vector float) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector signed int
  vec_ld (int a1, vector signed int *a2)
  {
    return (vector signed int) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector unsigned int
  vec_ld (int a1, vector unsigned int *a2)
  {
    return (vector unsigned int) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector signed short
  vec_ld (int a1, vector signed short *a2)
  {
    return (vector signed short) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector unsigned short
  vec_ld (int a1, vector unsigned short *a2)
  {
    return (vector unsigned short) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector signed char
  vec_ld (int a1, vector signed char *a2)
  {
    return (vector signed char) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  inline vector unsigned char
  vec_ld (int a1, vector unsigned char *a2)
  {
    return (vector unsigned char) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
  /* vec_lde */
  
  inline vector signed char
! vec_lde (int a1, vector signed char *a2)
  {
    return (vector signed char) __builtin_altivec_lvebx (a1, (void *) a2);
  }
  
  inline vector unsigned char
! vec_lde (int a1, vector unsigned char *a2)
  {
    return (vector unsigned char) __builtin_altivec_lvebx (a1, (void *) a2);
  }
  
  inline vector signed short
! vec_lde (int a1, vector signed short *a2)
  {
    return (vector signed short) __builtin_altivec_lvehx (a1, (void *) a2);
  }
  
  inline vector unsigned short
! vec_lde (int a1, vector unsigned short *a2)
  {
    return (vector unsigned short) __builtin_altivec_lvehx (a1, (void *) a2);
  }
  
  inline vector float
! vec_lde (int a1, vector float *a2)
  {
    return (vector float) __builtin_altivec_lvewx (a1, (void *) a2);
  }
  
  inline vector signed int
! vec_lde (int a1, vector signed int *a2)
  {
    return (vector signed int) __builtin_altivec_lvewx (a1, (void *) a2);
  }
  
  inline vector unsigned int
! vec_lde (int a1, vector unsigned int *a2)
  {
    return (vector unsigned int) __builtin_altivec_lvewx (a1, (void *) a2);
  }
--- 720,843 ----
    return (vector float) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector float
+ vec_ld (int a1, float *a2)
+ {
+   return (vector float) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector signed int
  vec_ld (int a1, vector signed int *a2)
  {
    return (vector signed int) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector signed int
+ vec_ld (int a1, signed int *a2)
+ {
+   return (vector signed int) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector unsigned int
  vec_ld (int a1, vector unsigned int *a2)
  {
    return (vector unsigned int) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector unsigned int
+ vec_ld (int a1, unsigned int *a2)
+ {
+   return (vector unsigned int) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector signed short
  vec_ld (int a1, vector signed short *a2)
  {
    return (vector signed short) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector signed short
+ vec_ld (int a1, signed short *a2)
+ {
+   return (vector signed short) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector unsigned short
  vec_ld (int a1, vector unsigned short *a2)
  {
    return (vector unsigned short) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector unsigned short
+ vec_ld (int a1, unsigned short *a2)
+ {
+   return (vector unsigned short) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector signed char
  vec_ld (int a1, vector signed char *a2)
  {
    return (vector signed char) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector signed char
+ vec_ld (int a1, signed char *a2)
+ {
+   return (vector signed char) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  inline vector unsigned char
  vec_ld (int a1, vector unsigned char *a2)
  {
    return (vector unsigned char) __builtin_altivec_lvx (a1, (void *) a2);
  }
  
+ inline vector unsigned char
+ vec_ld (int a1, unsigned char *a2)
+ {
+   return (vector unsigned char) __builtin_altivec_lvx (a1, (void *) a2);
+ }
+ 
  /* vec_lde */
  
  inline vector signed char
! vec_lde (int a1, signed char *a2)
  {
    return (vector signed char) __builtin_altivec_lvebx (a1, (void *) a2);
  }
  
  inline vector unsigned char
! vec_lde (int a1, unsigned char *a2)
  {
    return (vector unsigned char) __builtin_altivec_lvebx (a1, (void *) a2);
  }
  
  inline vector signed short
! vec_lde (int a1, signed short *a2)
  {
    return (vector signed short) __builtin_altivec_lvehx (a1, (void *) a2);
  }
  
  inline vector unsigned short
! vec_lde (int a1, unsigned short *a2)
  {
    return (vector unsigned short) __builtin_altivec_lvehx (a1, (void *) a2);
  }
  
  inline vector float
! vec_lde (int a1, float *a2)
  {
    return (vector float) __builtin_altivec_lvewx (a1, (void *) a2);
  }
  
  inline vector signed int
! vec_lde (int a1, signed int *a2)
  {
    return (vector signed int) __builtin_altivec_lvewx (a1, (void *) a2);
  }
  
  inline vector unsigned int
! vec_lde (int a1, unsigned int *a2)
  {
    return (vector unsigned int) __builtin_altivec_lvewx (a1, (void *) a2);
  }
*************** vec_ldl (int a1, vector float *a2)
*** 808,849 ****
--- 850,933 ----
    return (vector float) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector float
+ vec_ldl (int a1, float *a2)
+ {
+   return (vector float) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector signed int
  vec_ldl (int a1, vector signed int *a2)
  {
    return (vector signed int) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector signed int
+ vec_ldl (int a1, signed int *a2)
+ {
+   return (vector signed int) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector unsigned int
  vec_ldl (int a1, vector unsigned int *a2)
  {
    return (vector unsigned int) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector unsigned int
+ vec_ldl (int a1, unsigned int *a2)
+ {
+   return (vector unsigned int) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector signed short
  vec_ldl (int a1, vector signed short *a2)
  {
    return (vector signed short) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector signed short
+ vec_ldl (int a1, signed short *a2)
+ {
+   return (vector signed short) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector unsigned short
  vec_ldl (int a1, vector unsigned short *a2)
  {
    return (vector unsigned short) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector unsigned short
+ vec_ldl (int a1, unsigned short *a2)
+ {
+   return (vector unsigned short) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector signed char
  vec_ldl (int a1, vector signed char *a2)
  {
    return (vector signed char) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector signed char
+ vec_ldl (int a1, signed char *a2)
+ {
+   return (vector signed char) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  inline vector unsigned char
  vec_ldl (int a1, vector unsigned char *a2)
  {
    return (vector unsigned char) __builtin_altivec_lvxl (a1, (void *) a2);
  }
  
+ inline vector unsigned char
+ vec_ldl (int a1, unsigned char *a2)
+ {
+   return (vector unsigned char) __builtin_altivec_lvxl (a1, (void *) a2);
+ }
+ 
  /* vec_loge */
  
  inline vector float
*************** vec_any_out (vector float a1, vector flo
*** 3897,3902 ****
--- 3981,4039 ----
  {
    return __builtin_altivec_vcmpbfp_p (__CR6_EQ_REV, a1, a2);
  }
+ 
+ /* vec_step */
+ 
+ template<typename _Tp>
+ struct vec_step_help
+ {
+   // All proper vector types will specialize elem.
+ };
+ 
+ template<>
+ struct vec_step_help<vector signed short>
+ {
+   static const int elem = 8;
+ };
+ 
+ template<>
+ struct vec_step_help<vector unsigned short>
+ {
+   static const int elem = 8;
+ };
+ 
+ template<>
+ struct vec_step_help<vector signed int>
+ {
+   static const int elem = 4;
+ };
+ 
+ template<>
+ struct vec_step_help<vector unsigned int>
+ {
+   static const int elem = 4;
+ };
+ 
+ template<>
+ struct vec_step_help<vector unsigned char>
+ {
+   static const int elem = 16;
+ };
+ 
+ template<>
+ struct vec_step_help<vector signed char>
+ {
+   static const int elem = 16;
+ };
+ 
+ template<>
+ struct vec_step_help<vector float>
+ {
+   static const int elem = 4;
+ };
+ 
+ #define vec_step(t)  vec_step_help<t>::elem
+ 
  #else /* not C++ */
  
  /* "... and so I think no man in a century will suffer as greatly as



More information about the Gcc-patches mailing list