diff mbox

VEC re-write [patch 20/25]

Message ID 20121115215418.586ADC0916@torture.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo Nov. 15, 2012, 9:54 p.m. UTC
2012-11-15  Diego Novillo  <dnovillo@google.com>

	Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)

	* config/rs6000/rs6000-c.c: Use new vec API in vec.h.
	* config/rs6000/rs6000.c: Likewise.

Comments

David Edelsohn Nov. 17, 2012, 3:24 p.m. UTC | #1
On Thu, Nov 15, 2012 at 4:54 PM, Diego Novillo <dnovillo@google.com> wrote:
> 2012-11-15  Diego Novillo  <dnovillo@google.com>
>
>         Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
>
>         * config/rs6000/rs6000-c.c: Use new vec API in vec.h.
>         * config/rs6000/rs6000.c: Likewise.

Okay.

Thanks, David
diff mbox

Patch

diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 295015f..79da7a6 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -3505,8 +3505,8 @@  tree
 altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 				    void *passed_arglist)
 {
-  VEC(tree,gc) *arglist = (VEC(tree,gc) *) passed_arglist;
-  unsigned int nargs = VEC_length (tree, arglist);
+  vec<tree, va_gc> *arglist = static_cast<vec<tree, va_gc> *> (passed_arglist);
+  unsigned int nargs = vec_safe_length (arglist);
   enum rs6000_builtins fcode
     = (enum rs6000_builtins)DECL_FUNCTION_CODE (fndecl);
   tree fnargs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
@@ -3529,7 +3529,7 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
       int size;
       int i;
       bool unsigned_p;
-      VEC(constructor_elt,gc) *vec;
+      vec<constructor_elt, va_gc> *vec;
       const char *name = fcode == ALTIVEC_BUILTIN_VEC_SPLATS ? "vec_splats": "vec_promote";
 
       if (nargs == 0)
@@ -3549,10 +3549,10 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 	}
       /* Ignore promote's element argument.  */
       if (fcode == ALTIVEC_BUILTIN_VEC_PROMOTE
-	  && !INTEGRAL_TYPE_P (TREE_TYPE (VEC_index (tree, arglist, 1))))
+	  && !INTEGRAL_TYPE_P (TREE_TYPE ((*arglist)[1])))
 	goto bad;
 
-      arg = VEC_index (tree, arglist, 0);
+      arg = (*arglist)[0];
       type = TREE_TYPE (arg);
       if (!SCALAR_FLOAT_TYPE_P (type)
 	  && !INTEGRAL_TYPE_P (type))
@@ -3582,11 +3582,11 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 	    goto bad;
 	}
       arg = save_expr (fold_convert (TREE_TYPE (type), arg));
-      vec = VEC_alloc (constructor_elt, gc, size);
+      vec_alloc (vec, size);
       for(i = 0; i < size; i++)
 	{
 	  constructor_elt elt = {NULL_TREE, arg};
-	  VEC_quick_push (constructor_elt, vec, elt);
+	  vec->quick_push (elt);
 	}
 	return build_constructor (type, vec);
     }
@@ -3610,8 +3610,8 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 	  return error_mark_node;
 	}
 
-      arg2 = VEC_index (tree, arglist, 1);
-      arg1 = VEC_index (tree, arglist, 0);
+      arg2 = (*arglist)[1];
+      arg1 = (*arglist)[0];
       arg1_type = TREE_TYPE (arg1);
 
       if (TREE_CODE (arg1_type) != VECTOR_TYPE)
@@ -3686,10 +3686,10 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 	  return error_mark_node;
 	}
 
-      arg0 = VEC_index (tree, arglist, 0);
-      arg1 = VEC_index (tree, arglist, 1);
+      arg0 = (*arglist)[0];
+      arg1 = (*arglist)[1];
       arg1_type = TREE_TYPE (arg1);
-      arg2 = VEC_index (tree, arglist, 2);
+      arg2 = (*arglist)[2];
 
       if (TREE_CODE (arg1_type) != VECTOR_TYPE)
 	goto bad; 
@@ -3752,7 +3752,7 @@  altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
        fnargs = TREE_CHAIN (fnargs), n++)
     {
       tree decl_type = TREE_VALUE (fnargs);
-      tree arg = VEC_index (tree, arglist, n);
+      tree arg = (*arglist)[n];
       tree type;
 
       if (arg == error_mark_node)
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b37bca9..4bde320 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -24928,10 +24928,8 @@  typedef struct branch_island_d {
   int line_number;
 } branch_island;
 
-DEF_VEC_O(branch_island);
-DEF_VEC_ALLOC_O(branch_island,gc);
 
-static VEC(branch_island,gc) *branch_islands;
+static vec<branch_island, va_gc> *branch_islands;
 
 /* Remember to generate a branch island for far calls to the given
    function.  */
@@ -24941,7 +24939,7 @@  add_compiler_branch_island (tree label_name, tree function_name,
 			    int line_number)
 {
   branch_island bi = {function_name, label_name, line_number};
-  VEC_safe_push (branch_island, gc, branch_islands, bi);
+  vec_safe_push (branch_islands, bi);
 }
 
 /* Generate far-jump branch islands for everything recorded in
@@ -24955,9 +24953,9 @@  macho_branch_islands (void)
 {
   char tmp_buf[512];
 
-  while (!VEC_empty (branch_island, branch_islands))
+  while (!vec_safe_is_empty (branch_islands))
     {
-      branch_island *bi = &VEC_last (branch_island, branch_islands);
+      branch_island *bi = &branch_islands->last ();
       const char *label = IDENTIFIER_POINTER (bi->label_name);
       const char *name = IDENTIFIER_POINTER (bi->function_name);
       char name_buf[512];
@@ -25025,7 +25023,7 @@  macho_branch_islands (void)
       if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
 	dbxout_stabd (N_SLINE, bi->line_number);
 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
-      VEC_pop (branch_island, branch_islands);
+      branch_islands->pop ();
     }
 }
 
@@ -25038,7 +25036,7 @@  no_previous_def (tree function_name)
   branch_island *bi;
   unsigned ix;
 
-  FOR_EACH_VEC_ELT (branch_island, branch_islands, ix, bi)
+  FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi)
     if (function_name == bi->function_name)
       return 0;
   return 1;
@@ -25053,7 +25051,7 @@  get_prev_label (tree function_name)
   branch_island *bi;
   unsigned ix;
 
-  FOR_EACH_VEC_ELT (branch_island, branch_islands, ix, bi)
+  FOR_EACH_VEC_SAFE_ELT (branch_islands, ix, bi)
     if (function_name == bi->function_name)
       return bi->label_name;
   return NULL_TREE;