diff options
Diffstat (limited to 'gcc/config/pa')
-rw-r--r-- | gcc/config/pa/pa-hpux10.h | 7 | ||||
-rw-r--r-- | gcc/config/pa/pa-protos.h | 8 | ||||
-rw-r--r-- | gcc/config/pa/pa.c | 91 | ||||
-rw-r--r-- | gcc/config/pa/pa.h | 6 | ||||
-rw-r--r-- | gcc/config/pa/som.h | 95 |
5 files changed, 172 insertions, 35 deletions
diff --git a/gcc/config/pa/pa-hpux10.h b/gcc/config/pa/pa-hpux10.h index d3b5d858474..6c4dbf596d5 100644 --- a/gcc/config/pa/pa-hpux10.h +++ b/gcc/config/pa/pa-hpux10.h @@ -136,3 +136,10 @@ Boston, MA 02111-1307, USA. */ better than the assembler shipped with older versions of hpux. */ #undef NEW_HP_ASSEMBLER #define NEW_HP_ASSEMBLER 1 + +/* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa + directive. This provides one only linkage semantics even though we + don't have weak support. */ +#undef SUPPORTS_ONE_ONLY +#define SUPPORTS_ONE_ONLY (TARGET_GAS) +#undef MAKE_DECL_ONE_ONLY diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index 0e0dc74d5b4..7c9350ce000 100644 --- a/gcc/config/pa/pa-protos.h +++ b/gcc/config/pa/pa-protos.h @@ -135,6 +135,7 @@ extern int zdepi_cint_p (unsigned HOST_WIDE_INT); extern void override_options (void); extern void output_ascii (FILE *, const char *, int); +extern const char * som_text_section_asm_op (void); extern HOST_WIDE_INT compute_frame_size (HOST_WIDE_INT, int *); extern int and_mask_p (unsigned HOST_WIDE_INT); extern int cint_ok_for_move (HOST_WIDE_INT); @@ -151,7 +152,6 @@ extern int cmpib_comparison_operator (rtx, enum machine_mode); #endif - #ifdef TREE_CODE extern int reloc_needed (tree); #ifdef RTX_CODE @@ -164,3 +164,9 @@ extern int function_arg_partial_nregs (CUMULATIVE_ARGS *, tree, int); extern bool pa_return_in_memory (tree, tree); #endif /* TREE_CODE */ + +/* Functions in varasm.c used by pa.c. */ +extern void readonly_data (void); +extern void one_only_readonly_data_section (void); +extern void one_only_data_section (void); +extern void forget_section (void); diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index bd8b0a40c8c..20c0b8305de 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -143,6 +143,7 @@ static void pa_hpux_init_libfuncs (void); static rtx pa_struct_value_rtx (tree, int); static bool pa_pass_by_reference (CUMULATIVE_ARGS *ca, enum machine_mode, tree, bool); +static struct machine_function * pa_init_machine_status (void); /* Save the operands last given to a compare for use when we @@ -464,6 +465,8 @@ override_options (void) targetm.asm_out.unaligned_op.si = NULL; targetm.asm_out.unaligned_op.di = NULL; } + + init_machine_status = pa_init_machine_status; } static void @@ -475,6 +478,16 @@ pa_init_builtins (void) #endif } +/* Function to init struct machine_function. + This will be called, via a pointer variable, + from push_function_context. */ + +static struct machine_function * +pa_init_machine_status (void) +{ + return ggc_alloc_cleared (sizeof (machine_function)); +} + /* If FROM is a probable pointer register, mark TO as a probable pointer register with the same pointer alignment as FROM. */ @@ -4210,6 +4223,14 @@ pa_output_function_epilogue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED) fputs ("\t.EXIT\n\t.PROCEND\n", file); + if (TARGET_SOM && TARGET_GAS) + { + /* We done with this subspace except possibly for some additional + debug information. Forget that we are in this subspace to ensure + that the next function is output in its own subspace. */ + forget_section (); + } + if (INSN_ADDRESSES_SET_P ()) { insn = get_last_nonnote_insn (); @@ -7995,8 +8016,9 @@ pa_asm_output_mi_thunk (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta, fprintf (file, "\t.align 4\n"); ASM_OUTPUT_LABEL (file, label); fprintf (file, "\t.word P'%s\n", fname); - function_section (thunk_fndecl); } + else if (TARGET_SOM && TARGET_GAS) + forget_section (); current_thunk_number++; nbytes = ((nbytes + FUNCTION_BOUNDARY / BITS_PER_UNIT - 1) @@ -9144,6 +9166,58 @@ cmpib_comparison_operator (rtx op, enum machine_mode mode) || GET_CODE (op) == LEU)); } +#ifndef ONE_ONLY_TEXT_SECTION_ASM_OP +#define ONE_ONLY_TEXT_SECTION_ASM_OP "" +#endif + +#ifndef NEW_TEXT_SECTION_ASM_OP +#define NEW_TEXT_SECTION_ASM_OP "" +#endif + +#ifndef DEFAULT_TEXT_SECTION_ASM_OP +#define DEFAULT_TEXT_SECTION_ASM_OP "" +#endif + +/* Select and return a TEXT_SECTION_ASM_OP for the current function. + + This function is only used with SOM. Because we don't support + named subspaces, we can only create a new subspace or switch back + into the default text subspace. */ +const char * +som_text_section_asm_op (void) +{ + if (TARGET_SOM && TARGET_GAS) + { + if (cfun && !cfun->machine->in_nsubspa) + { + /* We only want to emit a .nsubspa directive once at the + start of the function. */ + cfun->machine->in_nsubspa = 1; + + /* Create a new subspace for the text. This provides + better stub placement and one-only functions. */ + if (cfun->decl + && DECL_ONE_ONLY (cfun->decl) + && !DECL_WEAK (cfun->decl)) + return ONE_ONLY_TEXT_SECTION_ASM_OP; + + return NEW_TEXT_SECTION_ASM_OP; + } + else + { + /* There isn't a current function or the body of the current + function has been completed. So, we are changing to the + text section to output debugging information. Do this in + the default text section. We need to forget that we are + in the text section so that text_section will call us the + next time around. */ + forget_section (); + } + } + + return DEFAULT_TEXT_SECTION_ASM_OP; +} + /* On hpux10, the linker will give an error if we have a reference in the read-only data section to a symbol defined in a shared library. Therefore, expressions that might require a reloc can @@ -9160,10 +9234,23 @@ pa_select_section (tree exp, int reloc, && (DECL_INITIAL (exp) == error_mark_node || TREE_CONSTANT (DECL_INITIAL (exp))) && !reloc) - readonly_data_section (); + { + if (TARGET_SOM + && DECL_ONE_ONLY (exp) + && !DECL_WEAK (exp)) + one_only_readonly_data_section (); + else + readonly_data_section (); + } else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c' && !reloc) readonly_data_section (); + else if (TARGET_SOM + && TREE_CODE (exp) == VAR_DECL + && DECL_ONE_ONLY (exp) + && !DECL_WEAK (exp) + && DECL_INITIAL (exp)) + one_only_data_section (); else data_section (); } diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 9e259f308b9..80f70ded500 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -430,6 +430,12 @@ do { \ #define CAN_DEBUG_WITHOUT_FP /* target machine storage layout */ +typedef struct machine_function GTY(()) +{ + /* Flag indicating that a .NSUBSPA directive has been output for + this function. */ + int in_nsubspa; +} machine_function; /* Define this macro if it is advisable to hold scalars in registers in a wider mode than that declared by the program. In such cases, diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h index ae52cd0a30e..d8082d82b9e 100644 --- a/gcc/config/pa/som.h +++ b/gcc/config/pa/som.h @@ -1,5 +1,5 @@ /* Definitions for SOM assembler support. - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GCC. @@ -129,19 +129,6 @@ do { \ #endif -/* NAME refers to the function's name. If we are placing each function into - its own section, we need to switch to the section for this function. Note - that the section name will have a "." prefix. */ -#define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \ - { \ - const char *name = (*targetm.strip_name_encoding) (NAME); \ - if (TARGET_GAS && in_section == in_text) \ - fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \ - else if (TARGET_GAS) \ - fprintf (FILE, \ - "\t.SUBSPA .%s\n", name); \ - } - #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \ tree tree_type = TREE_TYPE (DECL); \ @@ -219,30 +206,84 @@ do { \ #define TARGET_ASM_FILE_START pa_som_file_start -/* Output before code. */ +/* Select and return a TEXT_SECTION_ASM_OP string. */ +#define TEXT_SECTION_ASM_OP som_text_section_asm_op () -/* Supposedly the assembler rejects the command if there is no tab! */ -#define TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$\n" +/* Output before code in the default text section. */ +#define DEFAULT_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$" -/* Output before read-only data. */ +/* Output before text in a new subspace. This allows the linker to + place stubs between functions. */ +#define NEW_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$" + +/* Output before text in a new one-only subspace. */ +#define ONE_ONLY_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\ +\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,SORT=24,COMDAT" -/* Supposedly the assembler rejects the command if there is no tab! */ +/* Output before read-only data. */ #define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n" -#define EXTRA_SECTIONS in_readonly_data +/* Output before one-only readonly data. We make readonly data one only + by creating a new $LIT$ subspace in $TEXT$ with the comdat flag. */ +#define ONE_ONLY_READONLY_DATA_SECTION_ASM_OP "\t.SPACE $TEXT$\n\ +\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=16,COMDAT\n" + +/* Output before writable data. */ +#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n" + +/* Output before one-only data. We make data one only by creating + a new $DATA$ subspace in $PRIVATE$ with the comdat flag. */ +#define ONE_ONLY_DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\ +\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=24,COMDAT\n" + +/* Output before uninitialized data. */ +#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n" + +#define EXTRA_SECTIONS \ + in_readonly_data, \ + in_one_only_readonly_data, \ + in_one_only_data #define EXTRA_SECTION_FUNCTIONS \ -extern void readonly_data (void); \ + READONLY_DATA_FUNCTION \ + ONE_ONLY_READONLY_DATA_SECTION_FUNCTION \ + ONE_ONLY_DATA_SECTION_FUNCTION \ + FORGET_SECTION_FUNCTION + +#define READONLY_DATA_FUNCTION \ void \ readonly_data (void) \ { \ if (in_section != in_readonly_data) \ { \ in_section = in_readonly_data; \ - fprintf (asm_out_file, "%s\n", READONLY_DATA_ASM_OP); \ + fputs (READONLY_DATA_ASM_OP, asm_out_file); \ } \ +} \ + +#define ONE_ONLY_READONLY_DATA_SECTION_FUNCTION \ +void \ +one_only_readonly_data_section (void) \ +{ \ + in_section = in_one_only_readonly_data; \ + fputs (ONE_ONLY_READONLY_DATA_SECTION_ASM_OP, asm_out_file); \ +} \ + +#define ONE_ONLY_DATA_SECTION_FUNCTION \ +void \ +one_only_data_section (void) \ +{ \ + in_section = in_one_only_data; \ + fputs (ONE_ONLY_DATA_SECTION_ASM_OP, asm_out_file); \ } +#define FORGET_SECTION_FUNCTION \ +void \ +forget_section (void) \ +{ \ + in_section = no_section; \ +} \ + /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups which reference data within the $TEXT$ space (for example constant strings in the $LIT$ subspace). @@ -255,18 +296,8 @@ readonly_data (void) \ $TEXT$ space during PIC generation. Instead place all constant data into the $PRIVATE$ subspace (this reduces sharing, but it works correctly). */ - #define READONLY_DATA_SECTION (flag_pic ? data_section : readonly_data) -/* Output before writable data. */ - -/* Supposedly the assembler rejects the command if there is no tab! */ -#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n" - -/* Output before uninitialized data. */ - -#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n" - /* We must not have a reference to an external symbol defined in a shared library in a readonly section, else the SOM linker will complain. |