diff options
author | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-05 21:57:13 +0000 |
---|---|---|
committer | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-05 21:57:13 +0000 |
commit | 549aab72b1897b579be5f894a4fdc26083590cf7 (patch) | |
tree | 908fc4e9290a416e1c851c8683a076b5d6982f1b | |
parent | 07932ea7c4fd4a2fb44e8ddabd0eef35b121ba61 (diff) | |
download | gcc-549aab72b1897b579be5f894a4fdc26083590cf7.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184960 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/mep/mep.c | 38 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 109 | ||||
-rw-r--r-- | gcc/langhooks.c | 10 | ||||
-rw-r--r-- | gcc/langhooks.h | 4 |
5 files changed, 61 insertions, 107 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7d7dfacbf6..bf33eb4c263 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-03-05 Steven Bosscher <steven@gcc.gnu.org> + + * 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. + 2012-03-05 Jakub Jelinek <jakub@redhat.com> PR debug/51902 diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index 39d9cf95d30..4351702fa4b 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -6059,33 +6059,17 @@ mep_init_builtins (void) 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)); + 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 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 3ffc48c7e31..04ea22b70dd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -11567,25 +11567,17 @@ rs6000_init_builtins (void) builtin_mode_to_type[V16QImode][0] = V16QI_type_node; builtin_mode_to_type[V16QImode][1] = unsigned_V16QI_type_node; - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__bool char"), - bool_char_type_node); + tdecl = add_builtin_type ("__bool char", bool_char_type_node); TYPE_NAME (bool_char_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__bool short"), - bool_short_type_node); + + tdecl = add_builtin_type ("__bool short", bool_short_type_node); TYPE_NAME (bool_short_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__bool int"), - bool_int_type_node); + + tdecl = add_builtin_type ("__bool int", bool_int_type_node); TYPE_NAME (bool_int_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, get_identifier ("__pixel"), - pixel_type_node); + + tdecl = add_builtin_type ("__pixel", pixel_type_node); TYPE_NAME (pixel_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); bool_V16QI_type_node = build_vector_type (bool_char_type_node, 16); bool_V8HI_type_node = build_vector_type (bool_short_type_node, 8); @@ -11593,88 +11585,50 @@ rs6000_init_builtins (void) bool_V2DI_type_node = build_vector_type (bool_long_type_node, 2); pixel_V8HI_type_node = build_vector_type (pixel_type_node, 8); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__vector unsigned char"), - unsigned_V16QI_type_node); + tdecl = add_builtin_type ("__vector unsigned char", unsigned_V16QI_type_node); TYPE_NAME (unsigned_V16QI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector signed char"), - V16QI_type_node); + + tdecl = add_builtin_type ("__vector signed char", V16QI_type_node); TYPE_NAME (V16QI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector __bool char"), - bool_V16QI_type_node); + + tdecl = add_builtin_type ("__vector __bool char", bool_V16QI_type_node); TYPE_NAME ( bool_V16QI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector unsigned short"), - unsigned_V8HI_type_node); + tdecl = add_builtin_type ("__vector unsigned short", unsigned_V8HI_type_node); TYPE_NAME (unsigned_V8HI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector signed short"), - V8HI_type_node); + + tdecl = add_builtin_type ("__vector signed short", V8HI_type_node); TYPE_NAME (V8HI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__vector __bool short"), - bool_V8HI_type_node); + + tdecl = add_builtin_type ("__vector __bool short", bool_V8HI_type_node); TYPE_NAME (bool_V8HI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__vector unsigned int"), - unsigned_V4SI_type_node); + tdecl = add_builtin_type ("__vector unsigned int", unsigned_V4SI_type_node); TYPE_NAME (unsigned_V4SI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector signed int"), - V4SI_type_node); + + tdecl = add_builtin_type ("__vector signed int", V4SI_type_node); TYPE_NAME (V4SI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector __bool int"), - bool_V4SI_type_node); + + tdecl = add_builtin_type ("__vector __bool int", bool_V4SI_type_node); TYPE_NAME (bool_V4SI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector float"), - V4SF_type_node); + tdecl = add_builtin_type ("__vector float", V4SF_type_node); TYPE_NAME (V4SF_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector __pixel"), - pixel_V8HI_type_node); + + tdecl = add_builtin_type ("__vector __pixel", pixel_V8HI_type_node); TYPE_NAME (pixel_V8HI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector double"), - V2DF_type_node); + tdecl = add_builtin_type ("__vector double", V2DF_type_node); TYPE_NAME (V2DF_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector long"), - V2DI_type_node); + tdecl = add_builtin_type ("__vector long", V2DI_type_node); TYPE_NAME (V2DI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector unsigned long"), - unsigned_V2DI_type_node); + tdecl = add_builtin_type ("__vector unsigned long", unsigned_V2DI_type_node); TYPE_NAME (unsigned_V2DI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); - tdecl = build_decl (BUILTINS_LOCATION, - TYPE_DECL, get_identifier ("__vector __bool long"), - bool_V2DI_type_node); + tdecl = add_builtin_type ("__vector __bool long", bool_V2DI_type_node); TYPE_NAME (bool_V2DI_type_node) = tdecl; - (*lang_hooks.decls.pushdecl) (tdecl); /* Paired and SPE builtins are only available if you build a compiler with the appropriate options, so only create those builtins with the @@ -11843,10 +11797,7 @@ spe_init_builtins (void) signed_char_type_node, NULL_TREE); - (*lang_hooks.decls.pushdecl) - (build_decl (BUILTINS_LOCATION, TYPE_DECL, - get_identifier ("__ev64_opaque__"), - opaque_V2SI_type_node)); + add_builtin_type ("__ev64_opaque__", opaque_V2SI_type_node); /* Initialize irregular SPE builtins. */ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 80efd32580d..017e024e248 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -605,6 +605,16 @@ lhd_builtin_function (tree decl) 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. */ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 89e74f93681..15497225cbd 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -479,6 +479,7 @@ struct lang_hooks /* 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, @@ -489,5 +490,6 @@ extern tree add_builtin_function_ext_scope (const char *name, tree type, 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 */ |