[patch] Clean up some lang_hooks pushdecl uses in the back ends

2012-03-05 Thread Steven Bosscher
Hello,

This is a simple cleanup that introduces a new function
add_builtin_type and uses it in the mep and rs6000 back ends.

Bootstrapped and tested on powerpc64-unknown-linux-gnu (gcc110) and
verified that a cross to mep builds.
OK for trunk?

Ciao!
Steven

* langhooks.c (add_builtin_type): New function.
* langhooks.h (add_builtin_type): Export it.
* config/mep/mep.c (mep_init_builtins): Use it.
* config/rs6000/rs6000.c (rs6000_init_builtins): Use it.
* langhooks.c (add_builtin_type): New function.
* langhooks.h (add_builtin_type): Export it.
* config/mep/mep.c (mep_init_builtins): Use it.
* config/rs6000/rs6000.c (rs6000_init_builtins): Use it.

Index: langhooks.c
===
*** langhooks.c (revision 184954)
--- langhooks.c (working copy)
*** lhd_builtin_function (tree decl)
*** 605,610 
--- 605,620 
return decl;
  }
  
+ /* Create a builtin type.  */
+ 
+ tree
+ add_builtin_type (const char *name, tree type)
+ {
+   tree   id = get_identifier (name);
+   tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
+   return lang_hooks.decls.pushdecl (decl);
+ }
+ 
  /* LTO hooks.  */
  
  /* Used to save and restore any previously active section.  */
Index: langhooks.h
===
*** langhooks.h (revision 184954)
--- langhooks.h (working copy)
*** struct lang_hooks
*** 479,484 
--- 479,485 
  
  /* Each front end provides its own.  */
  extern struct lang_hooks lang_hooks;
+ 
  extern tree add_builtin_function (const char *name, tree type,
  int function_code, enum built_in_class cl,
  const char *library_name,
*** extern tree add_builtin_function_ext_sco
*** 489,493 
enum built_in_class cl,
const char *library_name,
tree attrs);
! 
  #endif /* GCC_LANG_HOOKS_H */
--- 490,495 
enum built_in_class cl,
const char *library_name,
tree attrs);
! extern tree add_builtin_type (const char *name, tree type);
!  
  #endif /* GCC_LANG_HOOKS_H */
Index: config/mep/mep.c
===
*** config/mep/mep.c(revision 184954)
--- config/mep/mep.c(working copy)
*** mep_init_builtins (void)
*** 6059,6091 
v4uhi_type_node = build_vector_type (unsigned_intHI_type_node, 4);
v2usi_type_node = build_vector_type (unsigned_intSI_type_node, 2);
  
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier 
(cp_data_bus_int),
!cp_data_bus_int_type_node));
! 
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_vector),
!opaque_vector_type_node));
! 
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v8qi),
!v8qi_type_node));
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v4hi),
!v4hi_type_node));
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v2si),
!v2si_type_node));
! 
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v8uqi),
!v8uqi_type_node));
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v4uhi),
!v4uhi_type_node));
!   (*lang_hooks.decls.pushdecl)
! (build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier (cp_v2usi),
!v2usi_type_node));
  
/* Intrinsics like mep_cadd3 are implemented with two groups of
   instructions, one which uses UNSPECs and one which uses a specific
--- 6059,6075 
v4uhi_type_node = build_vector_type (unsigned_intHI_type_node, 4);
v2usi_type_node = build_vector_type (unsigned_intSI_type_node, 2);
  
!   add_builtin_type (cp_data_bus_int, cp_data_bus_int_type_node);
! 
!   add_builtin_type (cp_vector, opaque_vector_type_node);
! 
!   add_builtin_type (cp_v8qi, v8qi_type_node);
!   add_builtin_type (cp_v4hi, v4hi_type_node);
!   add_builtin_type (cp_v2si, v2si_type_node);
! 
!   add_builtin_type (cp_v8uqi, v8uqi_type_node);
!   add_builtin_type (cp_v4uhi, v4uhi_type_node);
!   add_builtin_type (cp_v2usi, v2usi_type_node);
  
/* Intrinsics like mep_cadd3 are implemented with two groups of
   instructions, one which uses UNSPECs and one which uses a specific
Index: config/rs6000/rs6000.c
===

Re: [patch] Clean up some lang_hooks pushdecl uses in the back ends

2012-03-05 Thread Richard Henderson
On 03/05/2012 01:43 PM, Steven Bosscher wrote:
 * langhooks.c (add_builtin_type): New function.
 * langhooks.h (add_builtin_type): Export it.
 * config/mep/mep.c (mep_init_builtins): Use it.
 * config/rs6000/rs6000.c (rs6000_init_builtins): Use it.

Ok.


r~