From 791b0dc5ba32ace51fb8214cdb0cf769b91a024c Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Wed, 29 Jul 2015 16:14:23 +0100 Subject: [PATCH] Add new hooks asm_out.function_start and asm_out.function_end. They are used by the implementation of __attribute__ ((target(...))) on S390. --- gcc/doc/tm.texi | 10 ++++++++++ gcc/doc/tm.texi.in | 4 ++++ gcc/hooks.c | 7 +++++++ gcc/hooks.h | 1 + gcc/target.def | 16 ++++++++++++++++ gcc/varasm.c | 2 ++ 6 files changed, 40 insertions(+) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index d548d96..62d83db 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -7348,6 +7348,16 @@ Output to @code{asm_out_file} any text which the assembler expects to find at the end of a file. The default is to output nothing. @end deftypefn +@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_START (FILE *@var{}, @var{tree}) +Output to @code{asm_out_file} any text which is necessary at the start of +a function. The default is to output nothing. +@end deftypefn + +@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_END (FILE *@var{}, @var{tree}) +Output to @code{asm_out_file} any text which is necessary at the end of a +function. The default is to output nothing. +@end deftypefn + @deftypefun void file_end_indicate_exec_stack () Some systems use a common convention, the @samp{.note.GNU-stack} special section, to indicate whether or not an object file relies on diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 9bef4a5..b1c4b96 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -5122,6 +5122,10 @@ This describes the overall framework of an assembly file. @hook TARGET_ASM_FILE_END +@hook TARGET_ASM_FUNCTION_START + +@hook TARGET_ASM_FUNCTION_END + @deftypefun void file_end_indicate_exec_stack () Some systems use a common convention, the @samp{.note.GNU-stack} special section, to indicate whether or not an object file relies on diff --git a/gcc/hooks.c b/gcc/hooks.c index 0fb9add..3440e06 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -146,6 +146,13 @@ hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree) { } +/* Generic hook that takes (FILE *, tree) and does + nothing. */ +void +hook_void_FILEptr_tree (FILE *, tree) +{ +} + /* Generic hook that takes (FILE *, rtx) and returns false. */ bool hook_bool_FILEptr_rtx_false (FILE *a ATTRIBUTE_UNUSED, diff --git a/gcc/hooks.h b/gcc/hooks.h index c3d4bd3..bbd26cb 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -70,6 +70,7 @@ extern void hook_void_rtx_insn_int (rtx_insn *, int); extern void hook_void_FILEptr_constcharptr (FILE *, const char *); extern void hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree); +extern void hook_void_FILEptr_tree (FILE *, tree); extern bool hook_bool_FILEptr_rtx_false (FILE *, rtx); extern void hook_void_rtx_tree (rtx, tree); extern void hook_void_tree (tree); diff --git a/gcc/target.def b/gcc/target.def index aa5a1f1..4a18be5 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -672,6 +672,22 @@ to find at the end of a file. The default is to output nothing.", void, (void), hook_void_void) +/* Output additional text at the start of a function. */ +DEFHOOK +(function_start, + "Output to @code{asm_out_file} any text which is necessary at the start of\n\ +a function. The default is to output nothing.", + void, (FILE *, tree), + hook_void_FILEptr_tree) + +/* Output additional text at the end of a function. */ +DEFHOOK +(function_end, + "Output to @code{asm_out_file} any text which is necessary at the end of a\n\ +function. The default is to output nothing.", + void, (FILE *, tree), + hook_void_FILEptr_tree) + /* Output any boilerplate text needed at the beginning of an LTO output stream. */ DEFHOOK diff --git a/gcc/varasm.c b/gcc/varasm.c index 706e652..1b6f7b7 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1701,6 +1701,7 @@ assemble_start_function (tree decl, const char *fnname) char tmp_label[100]; bool hot_label_written = false; + targetm.asm_out.function_start (asm_out_file, current_function_decl); if (flag_reorder_blocks_and_partition) { ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno); @@ -1864,6 +1865,7 @@ assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED) ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_end_label); switch_to_section (save_text_section); } + targetm.asm_out.function_end (asm_out_file, current_function_decl); } /* Assemble code to leave SIZE bytes of zeros. */ -- 2.3.0