From 47907859fdd0b39ecb2a78c068872470f823329f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 6 Aug 2001 17:13:35 -0700 Subject: [PATCH] varasm.c (assemble_constructor): Take a symbol_ref and a priority instead of a bare string. * varasm.c (assemble_constructor): Take a symbol_ref and a priority instead of a bare string. Move priority handling here from cp/decl2.c. * output.h: Update decls. * c-decl.c (c_expand_body): Update calls to assemble_constructor and assemble_destructor. * profile.c (output_func_start_profiler): Likewise. * objc/objc-act.c (finish_objc): Likewise. (build_module_descriptor): Return the symbol not the symbol name. * ch/grant.c (chill_finish_compile): Pass a symbol_ref and priority to assemble_constructor. * cp/decl2.c (finish_objects): Pass a symbol_ref and priority to assemble_{constructor,destructor}. Remove priority handling. * java/class.c (emit_register_classes): Pass a symbol_ref and priority to assemble_constructor. From-SVN: r44678 --- gcc/ChangeLog | 13 ++++++++++ gcc/c-decl.c | 8 ++++--- gcc/ch/ChangeLog | 5 ++++ gcc/ch/grant.c | 3 ++- gcc/cp/ChangeLog | 5 ++++ gcc/cp/decl2.c | 32 +++++-------------------- gcc/java/ChangeLog | 5 ++++ gcc/java/class.c | 2 +- gcc/objc/objc-act.c | 20 +++++++--------- gcc/output.h | 14 +++++------ gcc/profile.c | 2 +- gcc/varasm.c | 58 +++++++++++++++++++++++++++++++++++++-------- 12 files changed, 106 insertions(+), 61 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 25731979142..1e18e1e5156 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2001-08-06 Richard Henderson + + * varasm.c (assemble_constructor): Take a symbol_ref and a + priority instead of a bare string. Move priority handling + here from cp/decl2.c. + * output.h: Update decls. + + * c-decl.c (c_expand_body): Update calls to assemble_constructor + and assemble_destructor. + * profile.c (output_func_start_profiler): Likewise. + * objc/objc-act.c (finish_objc): Likewise. + (build_module_descriptor): Return the symbol not the symbol name. + 2001-08-06 David Edelsohn * config/rs6000/darwin.h (DOUBLE_INT_ASM_OP): Add whitespace. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index b57e6d4f18c..6c5056f875e 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6781,9 +6781,10 @@ c_expand_body (fndecl, nested_p) static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors); else #endif - assemble_constructor (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))); - + assemble_constructor (XEXP (DECL_RTL (fndecl), 0), + DEFAULT_INIT_PRIORITY); } + if (DECL_STATIC_DESTRUCTOR (fndecl)) { #ifndef ASM_OUTPUT_DESTRUCTOR @@ -6791,7 +6792,8 @@ c_expand_body (fndecl, nested_p) static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors); else #endif - assemble_destructor (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))); + assemble_destructor (XEXP (DECL_RTL (fndecl), 0), + DEFAULT_INIT_PRIORITY); } if (nested_p) diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index d2421059f41..b1c048b64ea 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,8 @@ +2001-08-06 Richard Henderson + + * grant.c (chill_finish_compile): Pass a symbol_ref and priority + to assemble_constructor. + 2001-07-19 Neil Booth * Makefile.in (lex.o): No dependence on dwarfout.h. diff --git a/gcc/ch/grant.c b/gcc/ch/grant.c index 29e7ddc1bb5..c10eb99dc20 100644 --- a/gcc/ch/grant.c +++ b/gcc/ch/grant.c @@ -3048,7 +3048,8 @@ chill_finish_compile () if (pass == 2) { - assemble_constructor (IDENTIFIER_POINTER (chill_init_name)); + assemble_constructor (XEXP (DECL_RTL (chill_init_function), 0), + DEFAULT_INIT_PRIORITY); globalize_decl (chill_init_function); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 470fd821188..1b3cceb3015 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-08-06 Richard Henderson + + * decl2.c (finish_objects): Pass a symbol_ref and priority to + assemble_{constructor,destructor}. Remove priority handling. + 2001-08-05 Gabriel Dos Reis Don't allow template-id in using-declaration. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d35ab7195d2..be02224557f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2839,8 +2839,8 @@ finish_objects (method_type, initp, body) int method_type, initp; tree body; { - const char *fnname; tree fn; + rtx fnsym; /* Finish up. */ finish_compound_stmt (/*has_no_scope=*/0, body); @@ -2853,31 +2853,11 @@ finish_objects (method_type, initp, body) if (flag_syntax_only) return; - fnname = XSTR (XEXP (DECL_RTL (fn), 0), 0); - if (initp == DEFAULT_INIT_PRIORITY) - { - if (method_type == 'I') - assemble_constructor (fnname); - else - assemble_destructor (fnname); - } -#if defined (ASM_OUTPUT_CONSTRUCTOR) - /* If we're using init priority we can't use assemble_*tor, but on ELF - targets we can stick the references into named sections for GNU ld - to collect. */ - else if (targetm.have_named_sections) - { - char buf[15]; - sprintf (buf, ".%ctors.%.5u", method_type == 'I' ? 'c' : 'd', - /* invert the numbering so the linker puts us in the proper - order; constructors are run from right to left, and the - linker sorts in increasing order. */ - MAX_INIT_PRIORITY - initp); - named_section (NULL_TREE, buf, 0); - assemble_integer (XEXP (DECL_RTL (fn), 0), - POINTER_SIZE / BITS_PER_UNIT, 1); - } -#endif + fnsym = XEXP (DECL_RTL (fn), 0); + if (method_type == 'I') + assemble_constructor (fnsym, initp); + else + assemble_destructor (fnsym, initp); } /* The names of the parameters to the function created to handle diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 31c9785ac3d..5273aaf5cfa 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2001-08-06 Richard Henderson + + * class.c (emit_register_classes): Pass a symbol_ref and priority + to assemble_constructor. + 2001-08-02 Alexandre Petit-Bianco * java-tree.h (all_class_filename): New macro. diff --git a/gcc/java/class.c b/gcc/java/class.c index 3b56f53ff51..3cb8aa4e398 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1903,7 +1903,7 @@ emit_register_classes () flag_inline_functions = saved_flag; } current_function_decl = NULL_TREE; - assemble_constructor (IDENTIFIER_POINTER (init_name)); + assemble_constructor (XEXP (DECL_RTL (init_decl), 0), DEFAULT_INIT_PRIORITY); } void diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 03c3ae4f262..67e4000252b 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -165,7 +165,7 @@ static void objc_post_options PARAMS ((void)); static void synth_module_prologue PARAMS ((void)); static tree build_constructor PARAMS ((tree, tree)); -static const char *build_module_descriptor PARAMS ((void)); +static rtx build_module_descriptor PARAMS ((void)); static tree init_module_descriptor PARAMS ((tree)); static tree build_objc_method_call PARAMS ((int, tree, tree, tree, tree, tree)); @@ -1836,13 +1836,12 @@ init_module_descriptor (type) /* Write out the data structures to describe Objective C classes defined. If appropriate, compile and output a setup function to initialize them. - Return a string which is the name of a function to call to initialize - the Objective C data structures for this file (and perhaps for other files - also). + Return a symbol_ref to the function to call to initialize the Objective C + data structures for this file (and perhaps for other files also). struct objc_module { ... } _OBJC_MODULE = { ... }; */ -static const char * +static rtx build_module_descriptor () { tree decl_specs, field_decl, field_decl_chain; @@ -1911,7 +1910,7 @@ build_module_descriptor () way of generating the requisite code. */ if (flag_next_runtime) - return 0; + return NULL_RTX; { tree parms, function_decl, decelerator, void_list_node_1; @@ -1967,8 +1966,7 @@ build_module_descriptor () function_decl = current_function_decl; finish_function (0); - /* Return the name of the constructor function. */ - return XSTR (XEXP (DECL_RTL (function_decl), 0), 0); + return XEXP (DECL_RTL (function_decl), 0); } } @@ -8361,9 +8359,9 @@ finish_objc () || meth_var_names_chain || meth_var_types_chain || sel_ref_chain) { /* Arrange for Objc data structures to be initialized at run time. */ - const char *init_name = build_module_descriptor (); - if (init_name) - assemble_constructor (init_name); + rtx init_sym = build_module_descriptor (); + if (init_sym) + assemble_constructor (init_sym, DEFAULT_INIT_PRIORITY); } /* Dump the class references. This forces the appropriate classes diff --git a/gcc/output.h b/gcc/output.h index f28c7afe2a6..574d6f654b2 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -257,16 +257,14 @@ extern void assemble_variable PARAMS ((tree, int, int, int)); extern void assemble_external PARAMS ((tree)); #endif /* TREE_CODE */ -/* Record an element in the table of global destructors. - How this is done depends on what sort of assembler and linker - are in use. - - NAME should be the name of a global function to be called - at exit time. This name is output using assemble_name. */ -extern void assemble_destructor PARAMS ((const char *)); +#ifdef RTX_CODE +/* Record an element in the table of global destructors. The argument + should be a SYMBOL_REF of the function to be called. */ +extern void assemble_destructor PARAMS ((rtx, int)); /* Likewise for global constructors. */ -extern void assemble_constructor PARAMS ((const char *)); +extern void assemble_constructor PARAMS ((rtx, int)); +#endif /* Likewise for entries we want to record for garbage collection. Garbage collection is still under development. */ diff --git a/gcc/profile.c b/gcc/profile.c index b3ecf4c4429..a872ab850c6 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -1147,5 +1147,5 @@ output_func_start_profiler () fflush (asm_out_file); current_function_decl = NULL_TREE; - assemble_constructor (IDENTIFIER_POINTER (DECL_NAME (fndecl))); + assemble_constructor (XEXP (DECL_RTL (fndecl), 0), DEFAULT_INIT_PRIORITY); } diff --git a/gcc/varasm.c b/gcc/varasm.c index d574a802539..b7335d3b045 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -813,17 +813,34 @@ assemble_asm (string) fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string)); } -/* Record an element in the table of global destructors. - How this is done depends on what sort of assembler and linker - are in use. - - NAME should be the name of a global function to be called - at exit time. This name is output using assemble_name. */ +/* Record an element in the table of global destructors. The argument + should be a SYMBOL_REF of the function to be called. */ void -assemble_destructor (name) - const char *name; +assemble_destructor (symbol, priority) + rtx symbol; + int priority; { + const char *name; + + if (GET_CODE (symbol) != SYMBOL_REF) + abort (); + name = XSTR (symbol, 0); + + if (priority != DEFAULT_INIT_PRIORITY + && targetm.have_named_sections) + { + char buf[15]; + sprintf (buf, ".dtors.%.5u", + /* Invert the numbering so the linker puts us in the proper + order; constructors are run from right to left, and the + linker sorts in increasing order. */ + MAX_INIT_PRIORITY - priority); + named_section_flags (buf, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT); + assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1); + return; + } + #ifdef ASM_OUTPUT_DESTRUCTOR ASM_OUTPUT_DESTRUCTOR (asm_out_file, name); #else @@ -841,9 +858,30 @@ assemble_destructor (name) /* Likewise for global constructors. */ void -assemble_constructor (name) - const char *name; +assemble_constructor (symbol, priority) + rtx symbol; + int priority; { + const char *name; + + if (GET_CODE (symbol) != SYMBOL_REF) + abort (); + name = XSTR (symbol, 0); + + if (priority != DEFAULT_INIT_PRIORITY + && targetm.have_named_sections) + { + char buf[15]; + sprintf (buf, ".ctors.%.5u", + /* Invert the numbering so the linker puts us in the proper + order; constructors are run from right to left, and the + linker sorts in increasing order. */ + MAX_INIT_PRIORITY - priority); + named_section_flags (buf, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT); + assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1); + return; + } + #ifdef ASM_OUTPUT_CONSTRUCTOR ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name); #else -- 2.30.2