Skip to content

Commit

Permalink
Switch from clear_builtin_types to TARGET_CLEANUP_BUILTINS
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Nov 14, 2024
1 parent e0dcdd4 commit 4787e39
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gcc/config/i386/i386-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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. */
Expand Down
1 change: 1 addition & 0 deletions gcc/config/i386/i386-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions gcc/config/i386/i386.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions gcc/doc/tm.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gcc/doc/tm.texi.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions gcc/jit/dummy-frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions gcc/target.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4787e39

Please sign in to comment.