From 88b2da3c175d34d65415f69961420f35ac1a1c56 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 13 Nov 2024 19:46:19 -0500 Subject: [PATCH] Switch from clear_builtin_types to TARGET_CLEANUP_BUILTINS --- gcc/config/i386/i386-builtins.cc | 6 ++---- gcc/config/i386/i386-builtins.h | 1 + gcc/config/i386/i386.cc | 2 ++ gcc/doc/tm.texi | 7 +++++++ gcc/doc/tm.texi.in | 2 ++ gcc/jit/dummy-frontend.cc | 9 +++++++++ gcc/target.def | 10 ++++++++++ 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc index 7a5f2e738ac86..3bd9796610b82 100644 --- a/gcc/config/i386/i386-builtins.cc +++ b/gcc/config/i386/i386-builtins.cc @@ -227,8 +227,8 @@ static GTY(()) tree ix86_builtins[(int) IX86_BUILTIN_MAX + 1]; struct builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX]; -static void -clear_builtin_types (void) +void +ix86_cleanup_builtins (void) { for (int i = 0 ; i < IX86_BT_LAST_CPTR + 1 ; i++) ix86_builtin_type_tab[i] = NULL; @@ -1490,8 +1490,6 @@ ix86_init_builtins (void) { tree ftype, decl; - clear_builtin_types (); - ix86_init_builtin_types (); /* Builtins to get CPU type and features. */ diff --git a/gcc/config/i386/i386-builtins.h b/gcc/config/i386/i386-builtins.h index cd51e234972e8..6d9b293388002 100644 --- a/gcc/config/i386/i386-builtins.h +++ b/gcc/config/i386/i386-builtins.h @@ -318,6 +318,7 @@ extern builtin_isa ix86_builtins_isa[(int) IX86_BUILTIN_MAX]; tree ix86_builtin_vectorized_function (unsigned int fn, tree type_out, tree type_in); void ix86_init_builtins (void); +void ix86_cleanup_builtins (void); tree ix86_vectorize_builtin_gather (const_tree mem_vectype, const_tree index_type, int scale); tree ix86_builtin_decl (unsigned code, bool); diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index ad2e7b447ffae..988756be088dc 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -26538,6 +26538,8 @@ static const scoped_attribute_specs *const ix86_attribute_table[] = #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS ix86_init_builtins +#undef TARGET_CLEANUP_BUILTINS +#define TARGET_CLEANUP_BUILTINS ix86_cleanup_builtins #undef TARGET_BUILTIN_DECL #define TARGET_BUILTIN_DECL ix86_builtin_decl #undef TARGET_EXPAND_BUILTIN diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 70acde767ece7..baddef2b5a2b4 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -12112,6 +12112,13 @@ only language front ends that use those two functions will call @samp{TARGET_INIT_BUILTINS}. @end deftypefn +@deftypefn {Target Hook} void TARGET_CLEANUP_BUILTINS (void) +Define this hook if you have any machine-specific built-in functions +that need to be cleaned up. It should be a function that performs the +necessary cleanup so that a second compilation in the same process via +the jit frontend will not fail. +@end deftypefn + @deftypefn {Target Hook} tree TARGET_BUILTIN_DECL (unsigned @var{code}, bool @var{initialize_p}) Define this hook if you have any machine-specific built-in functions that need to be defined. It should be a function that returns the diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 5d24844799c79..392e29676bb28 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7868,6 +7868,8 @@ to by @var{ce_info}. @hook TARGET_INIT_BUILTINS +@hook TARGET_CLEANUP_BUILTINS + @hook TARGET_BUILTIN_DECL @hook TARGET_EXPAND_BUILTIN diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc index a9cc8859b7968..fe372dd97bf44 100644 --- a/gcc/jit/dummy-frontend.cc +++ b/gcc/jit/dummy-frontend.cc @@ -1088,6 +1088,12 @@ jit_langhook_init (void) return true; } +void +jit_langhook_finish (void) +{ + //targetm.cleanup_builtins (); +} + static void jit_langhook_parse_file (void) { @@ -1455,6 +1461,9 @@ jit_langhook_eh_personality (void) #undef LANG_HOOKS_INIT #define LANG_HOOKS_INIT jit_langhook_init +#undef LANG_HOOKS_FINISH +#define LANG_HOOKS_FINISH jit_langhook_finish + #undef LANG_HOOKS_PARSE_FILE #define LANG_HOOKS_PARSE_FILE jit_langhook_parse_file diff --git a/gcc/target.def b/gcc/target.def index b31550108883c..264a3e6e543e1 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2450,6 +2450,16 @@ only language front ends that use those two functions will call\n\ void, (void), hook_void_void) +/* Clean up target-specific built-in functions. */ +DEFHOOK +(cleanup_builtins, + "Define this hook if you have any machine-specific built-in functions\n\ +that need to be cleaned up. It should be a function that performs the\n\ +necessary cleanup so that a second compilation in the same process via\n\ +the jit frontend will not fail.", + void, (void), + hook_void_void) + /* Initialize (if INITIALIZE_P is true) and return the target-specific built-in function decl for CODE. Return NULL if that is not possible. Return error_mark_node if CODE