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]

[commit, spu] Unbreak SPU build (Re: Allow gc roots to be structures with array fields)


Richard Sandiford wrote:

> The patch also errors for array fields in an array of structures,
> which are in general too complex to handle with a single count and
> stride.

This breaks spu builds as the new error catches the spu_builtin_description
data type in spu.h.  The patch below fixes this by breaking out the FNDECL
element of struct spu_builtin_description into an array of its own, mirroring
the rs6000 way of storing builtin descriptions.

Tested on spu-elf, committed to mainline.

Bye,
Ulrich


ChangeLog:

	* config/spu/spu.h (struct spu_builtin_description): Remove FNDECL
	member.  Do not mark as GTY(()).
	* config/spu/spu.c (spu_builtins): Remove FNDECL initializer elements.
	(spu_builtin_decls): New static variable.
	(spu_builtin_decl): Use it instead of spu_builtins[].fndecl.
	(spu_init_builtins): Likewise.
	(spu_builtin_mul_widen_even): Likewise.
	(spu_builtin_mul_widen_odd): Likewise.
	(spu_builtin_mask_for_load): Likewise.
	(spu_builtin_vec_perm): Likewise.
	* config/spu/spu-c.c: Include "target.h".
	(spu_resolve_overloaded_builtin): Call targetm.builtin_decl instead
	of using spu_builtins[].fndecl.


Index: gcc/config/spu/spu-c.c
===================================================================
*** gcc/config/spu/spu-c.c	(revision 162075)
--- gcc/config/spu/spu-c.c	(working copy)
***************
*** 24,29 ****
--- 24,30 ----
  #include "c-family/c-pragma.h"
  #include "tm_p.h"
  #include "langhooks.h"
+ #include "target.h"
  
  
  /* Keep the vector keywords handy for fast comparisons.  */
*************** spu_resolve_overloaded_builtin (location
*** 111,117 ****
    for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL;
         new_fcode++)
      {
!       tree decl = spu_builtins[new_fcode].fndecl;
        tree params = TYPE_ARG_TYPES (TREE_TYPE (decl));
        tree param;
        bool all_scalar;
--- 112,118 ----
    for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL;
         new_fcode++)
      {
!       tree decl = targetm.builtin_decl (new_fcode, true);
        tree params = TYPE_ARG_TYPES (TREE_TYPE (decl));
        tree param;
        bool all_scalar;
Index: gcc/config/spu/spu.c
===================================================================
*** gcc/config/spu/spu.c	(revision 162075)
--- gcc/config/spu/spu.c	(working copy)
*************** extern GTY(()) struct spu_builtin_descri
*** 5618,5629 ****
  
  struct spu_builtin_description spu_builtins[] = {
  #define DEF_BUILTIN(fcode, icode, name, type, params) \
!   {fcode, icode, name, type, params, NULL_TREE},
  #include "spu-builtins.def"
  #undef DEF_BUILTIN
  };
  
! /* Returns the rs6000 builtin decl for CODE.  */
  
  static tree
  spu_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
--- 5618,5631 ----
  
  struct spu_builtin_description spu_builtins[] = {
  #define DEF_BUILTIN(fcode, icode, name, type, params) \
!   {fcode, icode, name, type, params},
  #include "spu-builtins.def"
  #undef DEF_BUILTIN
  };
  
! static GTY(()) tree spu_builtin_decls[NUM_SPU_BUILTINS];
! 
! /* Returns the spu builtin decl for CODE.  */
  
  static tree
  spu_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
*************** spu_builtin_decl (unsigned code, bool in
*** 5631,5637 ****
    if (code >= NUM_SPU_BUILTINS)
      return error_mark_node;
            
!   return spu_builtins[code].fndecl;
  }
  
  
--- 5633,5639 ----
    if (code >= NUM_SPU_BUILTINS)
      return error_mark_node;
            
!   return spu_builtin_decls[code];
  }
  
  
*************** spu_init_builtins (void)
*** 5709,5722 ****
        p = build_function_type (spu_builtin_types[d->parm[0]], p);
  
        sprintf (name, "__builtin_%s", d->name);
!       d->fndecl =
  	add_builtin_function (name, p, END_BUILTINS + i, BUILT_IN_MD,
  			      NULL, NULL_TREE);
        if (d->fcode == SPU_MASK_FOR_LOAD)
! 	TREE_READONLY (d->fndecl) = 1;	
  
        /* These builtins don't throw.  */
!       TREE_NOTHROW (d->fndecl) = 1;
      }
  }
  
--- 5711,5724 ----
        p = build_function_type (spu_builtin_types[d->parm[0]], p);
  
        sprintf (name, "__builtin_%s", d->name);
!       spu_builtin_decls[i] =
  	add_builtin_function (name, p, END_BUILTINS + i, BUILT_IN_MD,
  			      NULL, NULL_TREE);
        if (d->fcode == SPU_MASK_FOR_LOAD)
! 	TREE_READONLY (spu_builtin_decls[i]) = 1;	
  
        /* These builtins don't throw.  */
!       TREE_NOTHROW (spu_builtin_decls[i]) = 1;
      }
  }
  
*************** spu_builtin_mul_widen_even (tree type)
*** 6659,6667 ****
      {
      case V8HImode:
        if (TYPE_UNSIGNED (type))
! 	return spu_builtins[SPU_MULE_0].fndecl;
        else
! 	return spu_builtins[SPU_MULE_1].fndecl;
        break;
      default:
        return NULL_TREE;
--- 6661,6669 ----
      {
      case V8HImode:
        if (TYPE_UNSIGNED (type))
! 	return spu_builtin_decls[SPU_MULE_0];
        else
! 	return spu_builtin_decls[SPU_MULE_1];
        break;
      default:
        return NULL_TREE;
*************** spu_builtin_mul_widen_odd (tree type)
*** 6676,6684 ****
      {
      case V8HImode:
        if (TYPE_UNSIGNED (type))
! 	return spu_builtins[SPU_MULO_1].fndecl;
        else
! 	return spu_builtins[SPU_MULO_0].fndecl; 
        break;
      default:
        return NULL_TREE;
--- 6678,6686 ----
      {
      case V8HImode:
        if (TYPE_UNSIGNED (type))
! 	return spu_builtin_decls[SPU_MULO_1];
        else
! 	return spu_builtin_decls[SPU_MULO_0]; 
        break;
      default:
        return NULL_TREE;
*************** spu_builtin_mul_widen_odd (tree type)
*** 6689,6697 ****
  static tree
  spu_builtin_mask_for_load (void)
  {
!   struct spu_builtin_description *d = &spu_builtins[SPU_MASK_FOR_LOAD];
!   gcc_assert (d);
!   return d->fndecl;
  }
  
  /* Implement targetm.vectorize.builtin_vectorization_cost.  */
--- 6691,6697 ----
  static tree
  spu_builtin_mask_for_load (void)
  {
!   return spu_builtin_decls[SPU_MASK_FOR_LOAD];
  }
  
  /* Implement targetm.vectorize.builtin_vectorization_cost.  */
*************** spu_vector_alignment_reachable (const_tr
*** 6748,6801 ****
  tree
  spu_builtin_vec_perm (tree type, tree *mask_element_type)
  {
-   struct spu_builtin_description *d;
- 
    *mask_element_type = unsigned_char_type_node;
  
    switch (TYPE_MODE (type))
      {
      case V16QImode:
        if (TYPE_UNSIGNED (type))
!         d = &spu_builtins[SPU_SHUFFLE_0];
        else
!         d = &spu_builtins[SPU_SHUFFLE_1];
!       break;
  
      case V8HImode:
        if (TYPE_UNSIGNED (type))
!         d = &spu_builtins[SPU_SHUFFLE_2];
        else
!         d = &spu_builtins[SPU_SHUFFLE_3];
!       break;
  
      case V4SImode:
        if (TYPE_UNSIGNED (type))
!         d = &spu_builtins[SPU_SHUFFLE_4];
        else
!         d = &spu_builtins[SPU_SHUFFLE_5];
!       break;
  
      case V2DImode:
        if (TYPE_UNSIGNED (type))
!         d = &spu_builtins[SPU_SHUFFLE_6];
        else
!         d = &spu_builtins[SPU_SHUFFLE_7];
!       break;
  
      case V4SFmode:
!       d = &spu_builtins[SPU_SHUFFLE_8];
!       break;
  
      case V2DFmode:
!       d = &spu_builtins[SPU_SHUFFLE_9];
!       break;
  
      default:
        return NULL_TREE;
      }
- 
-   gcc_assert (d);
-   return d->fndecl;
  }
  
  /* Return the appropriate mode for a named address pointer.  */
--- 6748,6790 ----
  tree
  spu_builtin_vec_perm (tree type, tree *mask_element_type)
  {
    *mask_element_type = unsigned_char_type_node;
  
    switch (TYPE_MODE (type))
      {
      case V16QImode:
        if (TYPE_UNSIGNED (type))
!         return spu_builtin_decls[SPU_SHUFFLE_0];
        else
!         return spu_builtin_decls[SPU_SHUFFLE_1];
  
      case V8HImode:
        if (TYPE_UNSIGNED (type))
!         return spu_builtin_decls[SPU_SHUFFLE_2];
        else
!         return spu_builtin_decls[SPU_SHUFFLE_3];
  
      case V4SImode:
        if (TYPE_UNSIGNED (type))
!         return spu_builtin_decls[SPU_SHUFFLE_4];
        else
!         return spu_builtin_decls[SPU_SHUFFLE_5];
  
      case V2DImode:
        if (TYPE_UNSIGNED (type))
!         return spu_builtin_decls[SPU_SHUFFLE_6];
        else
!         return spu_builtin_decls[SPU_SHUFFLE_7];
  
      case V4SFmode:
!       return spu_builtin_decls[SPU_SHUFFLE_8];
  
      case V2DFmode:
!       return spu_builtin_decls[SPU_SHUFFLE_9];
  
      default:
        return NULL_TREE;
      }
  }
  
  /* Return the appropriate mode for a named address pointer.  */
Index: gcc/config/spu/spu.h
===================================================================
*** gcc/config/spu/spu.h	(revision 162075)
--- gcc/config/spu/spu.h	(working copy)
*************** enum spu_builtin_type
*** 570,576 ****
    B_INTERNAL
  };
  
! struct GTY(()) spu_builtin_description
  {
    int fcode;
    int icode;
--- 570,576 ----
    B_INTERNAL
  };
  
! struct spu_builtin_description
  {
    int fcode;
    int icode;
*************** struct GTY(()) spu_builtin_description
*** 580,587 ****
    /* The first element of parm is always the return type.  The rest
       are a zero terminated list of parameters.  */
    int parm[5];
- 
-   tree fndecl;
  };
  
  extern struct spu_builtin_description spu_builtins[];
--- 580,585 ----

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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