From d26296cf0edae25bc236860b55df459c9fe0c92f Mon Sep 17 00:00:00 2001 From: "m.hayes" Date: Fri, 11 Feb 2000 04:55:07 +0000 Subject: [PATCH] * config/c4x/c4x.h (ASM_GLOBALIZE_LABEL): Use c4x_global_label. (ASM_OUTPUT_EXTERNAL): Use c4x_external_ref. (ASM_OUTPUT_EXTERNAL_LIBCALL): Likewise. (ASM_FILE_END): Use c4x_file_end. * config/c4x/c4x.c (c4x_global_label): New function. (c4x_external_ref, c4x_file_end): Likewise. * config/c4x/c4x-protos.h (c4x_global_label): Add prototype. (c4x_external_ref, c4x_end_file): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31909 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 +++++ gcc/config/c4x/c4x-protos.h | 6 +++ gcc/config/c4x/c4x.c | 109 ++++++++++++++++++++++++++++++++++++++++++-- gcc/config/c4x/c4x.h | 22 ++++----- 4 files changed, 132 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 255ab22..cfbed1d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2000-02-11 Michael Hayes + + * config/c4x/c4x.h (ASM_GLOBALIZE_LABEL): Use c4x_global_label. + (ASM_OUTPUT_EXTERNAL): Use c4x_external_ref. + (ASM_OUTPUT_EXTERNAL_LIBCALL): Likewise. + (ASM_FILE_END): Use c4x_file_end. + * config/c4x/c4x.c (c4x_global_label): New function. + (c4x_external_ref, c4x_file_end): Likewise. + * config/c4x/c4x-protos.h (c4x_global_label): Add prototype. + (c4x_external_ref, c4x_end_file): Likewise. + + 2000-02-10 Zack Weinberg * cppexp.c: Don't include cpphash.h. diff --git a/gcc/config/c4x/c4x-protos.h b/gcc/config/c4x/c4x-protos.h index 3e4439b..8c5806b 100644 --- a/gcc/config/c4x/c4x-protos.h +++ b/gcc/config/c4x/c4x-protos.h @@ -37,6 +37,12 @@ extern int c4x_handle_pragma PARAMS ((int (* p_getc) (void), void (* p_ungetc) (int), char *)); +extern void c4x_global_label (char *); + +extern void c4x_external_ref (char *); + +extern void c4x_file_end (FILE *); + #ifdef TREE_CODE extern void c4x_set_default_attributes PARAMS ((tree, tree *)); diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index e0051ea..07b8b51 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -4396,19 +4396,122 @@ c4x_handle_pragma (p_getc, p_ungetc, pname) } +struct name_list +{ + struct name_list *next; + char *name; +}; + +static struct name_list *global_head; +static struct name_list *extern_head; + + +/* Add NAME to list of global symbols and remove from external list if + present on external list. */ + +void +c4x_global_label (name) + char *name; +{ + struct name_list *p, *last; + + /* Do not insert duplicate names, so linearly search through list of + existing names. */ + p = global_head; + while (p) + { + if (strcmp (p->name, name) == 0) + return; + p = p->next; + } + p = (struct name_list *) permalloc (sizeof *p); + p->next = global_head; + p->name = name; + global_head = p; + + /* Remove this name from ref list if present. */ + last = NULL; + p = extern_head; + while (p) + { + if (strcmp (p->name, name) == 0) + { + if (last) + last->next = p->next; + else + extern_head = p->next; + break; + } + last = p; + p = p->next; + } +} + + +/* Add NAME to list of external symbols. */ + +void +c4x_external_ref (name) + char *name; +{ + struct name_list *p; + + /* Do not insert duplicate names. */ + p = extern_head; + while (p) + { + if (strcmp (p->name, name) == 0) + return; + p = p->next; + } + + /* Do not insert ref if global found. */ + p = global_head; + while (p) + { + if (strcmp (p->name, name) == 0) + return; + p = p->next; + } + p = (struct name_list *) permalloc (sizeof *p); + p->next = extern_head; + p->name = name; + extern_head = p; +} + + +void +c4x_file_end (fp) + FILE *fp; +{ + struct name_list *p; + + /* Output all external names that are not global. */ + p = extern_head; + while (p) + { + fprintf (fp, "\t.ref\t"); + assemble_name (fp, p->name); + fprintf (fp, "\n"); + p = p->next; + } + fprintf (fp, "\t.end\n"); +} + + static void -c4x_check_attribute(attrib, list, decl, attributes) +c4x_check_attribute (attrib, list, decl, attributes) char *attrib; tree list, decl, *attributes; { while (list != NULL_TREE && IDENTIFIER_POINTER (TREE_PURPOSE (list)) != IDENTIFIER_POINTER (DECL_NAME (decl))) - list = TREE_CHAIN(list); + list = TREE_CHAIN (list); if (list) *attributes = chainon (*attributes, build_tree_list (get_identifier (attrib), - TREE_VALUE(list))); + TREE_VALUE (list))); } diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index 9de9735..27abc4b 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -2127,8 +2127,6 @@ dtors_section () \ fprintf (FILE, "\n"); \ } -#define ASM_FILE_END(FILE) fprintf (FILE, "\t.end\n") - /* We need to have a data section we can identify so that we can set the DP register back to a data pointer in the small memory model. This is only required for ISRs if we are paranoid that someone @@ -2211,25 +2209,21 @@ do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0); fprintf (FILE, "\t.global\t"); \ assemble_name (FILE, NAME); \ fputs ("\n", FILE); \ + c4x_global_label (NAME); \ } while (0); -#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ - do { \ - fprintf (FILE, "\t.ref\t"); \ - assemble_name (FILE, NAME); \ - fputc ('\n', FILE); \ - } while (0); +#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ +c4x_external_ref (NAME) /* A C statement to output on FILE an assembler pseudo-op to declare a library function named external. (Only needed to keep asm30 happy for ___divqf3 etc.) */ -#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ - do { \ - fprintf (FILE, "\t.ref\t"); \ - assemble_name (FILE, XSTR (FUN, 0)); \ - fprintf (FILE, "\n"); \ - } while (0); +#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ +c4x_external_ref (XSTR (FUN, 0)) + +#define ASM_FILE_END(FILE) \ +c4x_file_end (FILE) /* The prefix to add to user-visible assembler symbols. */ -- 2.7.4