On Tue, Nov 1, 2011 at 3:00 PM, Peter Bergner <berg...@vnet.ibm.com> wrote:
> +/* Fills in the label name that should be used for a 476 link stack thunk. > */ > + > +void > +get_ppc476_thunk_name (char name[32]) > +{ > + gcc_assert (TARGET_LINK_STACK); > + > + if (HAVE_GAS_HIDDEN) > + sprintf (name, "__ppc476.get_thunk"); > + else > + ASM_GENERATE_INTERNAL_LABEL (name, "LPPC476_", 0); > +} > + > +/* This function emits the simple thunk routine that is used to preserve > + the link stack on the 476 cpu. */ > + > +static void > +rs6000_code_end (void) > +{ > + char name[32]; > + tree decl; > + > + if (!TARGET_LINK_STACK) > + return; > + > + get_ppc476_thunk_name (name); > + > + decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name), > + build_function_type_list (void_type_node, NULL_TREE)); > + DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL, > + NULL_TREE, void_type_node); > + TREE_PUBLIC (decl) = 1; > + TREE_STATIC (decl) = 1; > + > + if (HAVE_GAS_HIDDEN) > + { > + DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl); > + targetm.asm_out.unique_section (decl, 0); > + switch_to_section (get_named_section (decl, NULL, 0)); > + DECL_WEAK (decl) = 1; > + ASM_WEAKEN_DECL (asm_out_file, decl, name, 0); > + targetm.asm_out.globalize_label (asm_out_file, name); > + targetm.asm_out.assemble_visibility (decl, VISIBILITY_HIDDEN); > + ASM_DECLARE_FUNCTION_NAME (asm_out_file, name, decl); > + } > + else > + { > + switch_to_section (text_section); > + ASM_OUTPUT_LABEL (asm_out_file, name); > + } > + > + DECL_INITIAL (decl) = make_node (BLOCK); > + current_function_decl = decl; > + init_function_start (decl); > + first_function_block_is_cold = false; > + /* Make sure unwind info is emitted for the thunk if needed. */ > + final_start_function (emit_barrier (), asm_out_file, 1); > + > + fputs ("\tblr\n", asm_out_file); > + > + final_end_function (); > + init_insn_lengths (); > + free_after_compilation (cfun); > + set_cfun (NULL); > + current_function_decl = NULL; The two new functions have mistakes because I did not realize the semantics of HAVE_GAS_HIDDEN. HAVE_GAS_HIDDEN is not a macro to be tested at runtime, but a macro tested at compile time. if (HAVE_GAS_HIDDEN) should be #ifdef HAVE_GAS_HIDDEN Please correct. Thanks, David