diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7da1ad87ce7..75937f96959 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,27 @@ +2001-10-17 Neil Booth + + * config.gcc: Update c4x and i370 for C front end-specific + dependencies. + * config/c4x/c4x-c.c: New. + * config/c4x/c4x-protos.h (c4x_handle_pragma): Remove. + (code_tree, data_tree, pure_tree, noreturn_tree, interrupt_tree): + New declarations. + * config/c4x/c4x.c: Don't include c-lex.h or c-pragma.h. + (code_tree, data_tree, pure_tree, noreturn_tree, interrupt_tree): + Make extern. + (c4x_init_pragma): Remove. + (c4x_parse_pragma, c4x_pr_CODE_SECTION, c4x_pr_DATA_SECTION, + c4x_pr_FUNC_IS_PURE, c4x_pr_FUNC_NEVER_RETURNS, c4x_pr_INTERRUPT, + c4x_pr_ignored): Move to c4x-c.c. + * config/c4x/c4x.h (REGISTER_TARGET_PRAGMAS): Update. + * config/c4x/t-c4x: Update. + * config/i370/i370-c.c: New. + * config/i370/i370.c: Don't include c-lex.h or c-pragma.h. + (i370_pr_map): Move to i370-c.c. + * config/i370/t-i370: New. + + * doc/tm.texi: Update. + 2001-10-17 Stan Shebs * config/rs6000/rs6000.c: Make assorted mechanical formatting and diff --git a/gcc/config.gcc b/gcc/config.gcc index f6085953e2b..b1bd55d24a4 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -644,11 +644,15 @@ c4x-*-rtems*) if test x$enable_threads = xyes; then thread_file='rtems' fi + c_target_objs="c4x-c.o" + cxx_target_objs="c4x-c.o" ;; c4x-*) cpu_type=c4x float_format=c4x tmake_file=c4x/t-c4x + c_target_objs="c4x-c.o" + cxx_target_objs="c4x-c.o" ;; clipper-intergraph-clix*) tm_file="${tm_file} svr3.h clipper/clix.h" @@ -941,11 +945,17 @@ hppa*-*-mpeix*) i370-*-opened*) # IBM 360/370/390 Architecture xm_defines='POSIX FATAL_EXIT_CODE=12' tm_file=i370/oe.h + tmake_file="i370/t-i370" xmake_file=i370/x-oe + c_target_objs="i370-c.o" + cxx_target_objs="i370-c.o" ;; i370-*-mvs*) xm_defines='POSIX FATAL_EXIT_CODE=12' tm_file=i370/mvs.h + tmake_file="i370/t-i370" + c_target_objs="i370-c.o" + cxx_target_objs="i370-c.o" ;; i370-*-linux*) xmake_file=x-linux diff --git a/gcc/config/c4x/c4x-c.c b/gcc/config/c4x/c4x-c.c new file mode 100644 index 00000000000..3bbf184e174 --- /dev/null +++ b/gcc/config/c4x/c4x-c.c @@ -0,0 +1,159 @@ +/* Subroutines for the C front end on the TMS320C[34]x + Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. + + Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz) + and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl). + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include "system.h" +#include "tree.h" +#include "toplev.h" +#include "cpplib.h" +#include "c-pragma.h" +#include "c-lex.h" +#include "c4x-protos.h" + +static int c4x_parse_pragma PARAMS ((const char *, tree *, tree *)); + +/* Handle machine specific pragmas for compatibility with existing + compilers for the C3x/C4x. + + pragma attribute + ---------------------------------------------------------- + CODE_SECTION(symbol,"section") section("section") + DATA_SECTION(symbol,"section") section("section") + FUNC_CANNOT_INLINE(function) + FUNC_EXT_CALLED(function) + FUNC_IS_PURE(function) const + FUNC_IS_SYSTEM(function) + FUNC_NEVER_RETURNS(function) noreturn + FUNC_NO_GLOBAL_ASG(function) + FUNC_NO_IND_ASG(function) + INTERRUPT(function) interrupt + + */ + +/* Parse a C4x pragma, of the form ( function [, "section"] ) \n. + FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with + the STRING_CST node of the string. If SECT is null, then this + pragma doesn't take a section string. Returns 0 for a good pragma, + -1 for a malformed pragma. */ +#define BAD(msgid, arg) do { warning (msgid, arg); return -1; } while (0) + +static int +c4x_parse_pragma (name, func, sect) + const char *name; + tree *func; + tree *sect; +{ + tree f, s, x; + + if (c_lex (&x) != CPP_OPEN_PAREN) + BAD ("missing '(' after '#pragma %s' - ignored", name); + + if (c_lex (&f) != CPP_NAME) + BAD ("missing function name in '#pragma %s' - ignored", name); + + if (sect) + { + if (c_lex (&x) != CPP_COMMA) + BAD ("malformed '#pragma %s' - ignored", name); + if (c_lex (&s) != CPP_STRING) + BAD ("missing section name in '#pragma %s' - ignored", name); + *sect = s; + } + + if (c_lex (&x) != CPP_CLOSE_PAREN) + BAD ("missing ')' for '#pragma %s' - ignored", name); + + if (c_lex (&x) != CPP_EOF) + warning ("junk at end of '#pragma %s'", name); + + *func = f; + return 0; +} + +void +c4x_pr_CODE_SECTION (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree func, sect; + + if (c4x_parse_pragma ("CODE_SECTION", &func, §)) + return; + code_tree = chainon (code_tree, + build_tree_list (func, + build_tree_list (NULL_TREE, sect))); +} + +void +c4x_pr_DATA_SECTION (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree func, sect; + + if (c4x_parse_pragma ("DATA_SECTION", &func, §)) + return; + data_tree = chainon (data_tree, + build_tree_list (func, + build_tree_list (NULL_TREE, sect))); +} + +void +c4x_pr_FUNC_IS_PURE (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree func; + + if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0)) + return; + pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE)); +} + +void +c4x_pr_FUNC_NEVER_RETURNS (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree func; + + if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0)) + return; + noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE)); +} + +void +c4x_pr_INTERRUPT (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree func; + + if (c4x_parse_pragma ("INTERRUPT", &func, 0)) + return; + interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE)); +} + +/* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM, + FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */ +void +c4x_pr_ignored (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ +} diff --git a/gcc/config/c4x/c4x-protos.h b/gcc/config/c4x/c4x-protos.h index 1a3ebcfcd44..be39ca2aade 100644 --- a/gcc/config/c4x/c4x-protos.h +++ b/gcc/config/c4x/c4x-protos.h @@ -39,10 +39,6 @@ extern void c4x_expand_epilogue PARAMS ((void)); extern int c4x_null_epilogue_p PARAMS ((void)); -extern int c4x_handle_pragma PARAMS ((int (* p_getc) (void), - void (* p_ungetc) (int), - char *)); - extern void c4x_global_label (const char *); extern void c4x_external_ref (const char *); @@ -305,6 +301,7 @@ extern void c4x_pr_FUNC_NEVER_RETURNS PARAMS ((cpp_reader *)); extern void c4x_pr_INTERRUPT PARAMS ((cpp_reader *)); extern void c4x_pr_ignored PARAMS ((cpp_reader *)); extern void c4x_init_pragma PARAMS ((int (*) (tree *))); +extern tree code_tree, data_tree, pure_tree, noreturn_tree, interrupt_tree; #endif #endif /* ! GCC_C4X_PROTOS_H */ diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index b59d34475d7..3c9d1400f7e 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -45,8 +45,6 @@ Boston, MA 02111-1307, USA. */ #include "c-tree.h" #include "ggc.h" #include "cpplib.h" -#include "c-lex.h" -#include "c-pragma.h" #include "toplev.h" #include "c4x-protos.h" #include "target.h" @@ -160,11 +158,11 @@ int c4x_cpu_version = 40; /* CPU version C30/31/32/33/40/44. */ /* Pragma definitions. */ -static tree code_tree = NULL_TREE; -static tree data_tree = NULL_TREE; -static tree pure_tree = NULL_TREE; -static tree noreturn_tree = NULL_TREE; -static tree interrupt_tree = NULL_TREE; +tree code_tree = NULL_TREE; +tree data_tree = NULL_TREE; +tree pure_tree = NULL_TREE; +tree noreturn_tree = NULL_TREE; +tree interrupt_tree = NULL_TREE; /* Forward declarations */ static void c4x_add_gc_roots PARAMS ((void)); @@ -187,7 +185,6 @@ static int c4x_valid_operands PARAMS ((enum rtx_code, rtx *, static int c4x_arn_reg_operand PARAMS ((rtx, enum machine_mode, unsigned int)); static int c4x_arn_mem_operand PARAMS ((rtx, enum machine_mode, unsigned int)); static void c4x_check_attribute PARAMS ((const char *, tree, tree, tree *)); -static int c4x_parse_pragma PARAMS ((const char *, tree *, tree *)); static int c4x_r11_set_p PARAMS ((rtx)); static int c4x_rptb_valid_p PARAMS ((rtx, rtx)); static int c4x_label_ref_used_p PARAMS ((rtx, rtx)); @@ -4487,141 +4484,6 @@ c4x_operand_subword (op, i, validate_address, mode) return operand_subword (op, i, validate_address, mode); } -/* Handle machine specific pragmas for compatibility with existing - compilers for the C3x/C4x. - - pragma attribute - ---------------------------------------------------------- - CODE_SECTION(symbol,"section") section("section") - DATA_SECTION(symbol,"section") section("section") - FUNC_CANNOT_INLINE(function) - FUNC_EXT_CALLED(function) - FUNC_IS_PURE(function) const - FUNC_IS_SYSTEM(function) - FUNC_NEVER_RETURNS(function) noreturn - FUNC_NO_GLOBAL_ASG(function) - FUNC_NO_IND_ASG(function) - INTERRUPT(function) interrupt - - */ - -/* Parse a C4x pragma, of the form ( function [, "section"] ) \n. - FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with - the STRING_CST node of the string. If SECT is null, then this - pragma doesn't take a section string. Returns 0 for a good pragma, - -1 for a malformed pragma. */ -#define BAD(msgid, arg) do { warning (msgid, arg); return -1; } while (0) - -static int (*c_lex_func) (tree *); - -void -c4x_init_pragma (get_token) - int (*get_token) PARAMS ((tree *)); -{ - c_lex_func = get_token; -} - - -static int -c4x_parse_pragma (name, func, sect) - const char *name; - tree *func; - tree *sect; -{ - tree f, s, x; - - if (c_lex_func (&x) != CPP_OPEN_PAREN) - BAD ("missing '(' after '#pragma %s' - ignored", name); - - if (c_lex_func (&f) != CPP_NAME) - BAD ("missing function name in '#pragma %s' - ignored", name); - - if (sect) - { - if (c_lex_func (&x) != CPP_COMMA) - BAD ("malformed '#pragma %s' - ignored", name); - if (c_lex_func (&s) != CPP_STRING) - BAD ("missing section name in '#pragma %s' - ignored", name); - *sect = s; - } - - if (c_lex_func (&x) != CPP_CLOSE_PAREN) - BAD ("missing ')' for '#pragma %s' - ignored", name); - - if (c_lex_func (&x) != CPP_EOF) - warning ("junk at end of '#pragma %s'", name); - - *func = f; - return 0; -} - -void -c4x_pr_CODE_SECTION (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree func, sect; - - if (c4x_parse_pragma ("CODE_SECTION", &func, §)) - return; - code_tree = chainon (code_tree, - build_tree_list (func, - build_tree_list (NULL_TREE, sect))); -} - -void -c4x_pr_DATA_SECTION (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree func, sect; - - if (c4x_parse_pragma ("DATA_SECTION", &func, §)) - return; - data_tree = chainon (data_tree, - build_tree_list (func, - build_tree_list (NULL_TREE, sect))); -} - -void -c4x_pr_FUNC_IS_PURE (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree func; - - if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0)) - return; - pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE)); -} - -void -c4x_pr_FUNC_NEVER_RETURNS (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree func; - - if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0)) - return; - noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE)); -} - -void -c4x_pr_INTERRUPT (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree func; - - if (c4x_parse_pragma ("INTERRUPT", &func, 0)) - return; - interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE)); -} - -/* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM, - FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */ -void -c4x_pr_ignored (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ -} - struct name_list { struct name_list *next; diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index e8052c6b68c..202b4c065c7 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -2348,7 +2348,6 @@ do { \ cpp_register_pragma (PFILE, 0, "FUNC_NO_GLOBAL_ASG", c4x_pr_ignored); \ cpp_register_pragma (PFILE, 0, "FUNC_NO_IND_ASG", c4x_pr_ignored); \ cpp_register_pragma (PFILE, 0, "INTERRUPT", c4x_pr_INTERRUPT); \ - c4x_init_pragma (&c_lex); \ } while (0) /* Assembler Commands for Alignment. */ diff --git a/gcc/config/c4x/t-c4x b/gcc/config/c4x/t-c4x index c88eba4a1f7..394b4c95738 100644 --- a/gcc/config/c4x/t-c4x +++ b/gcc/config/c4x/t-c4x @@ -7,6 +7,10 @@ LIB1ASMFUNCS = _divsf3 _divsi3 _udivsi3 _umodsi3 _modsi3 _mulsi3 \ TARGET_LIBGCC2_CFLAGS = -Dexit=unused_exit +c4x-c.o: $(srcdir)/config/c4x/c4x-c.c $(srcdir)/config/c4x/c4x-protos.h \ + $(CONFIG_H) $(SYSTEM_H) cpplib.h $(TREE_H) c-pragma.h c-lex.h toplev.h + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< + MULTILIB_OPTIONS = m30 msmall mmemparm MULTILIB_DIRNAMES = c3x small mem MULTILIB_MATCHES = m30=mcpu?30 m30=mcpu?31 m30=mcpu?32 m30=m31 m30=m32 diff --git a/gcc/config/i370/i370-c.c b/gcc/config/i370/i370-c.c new file mode 100644 index 00000000000..d1eddb6a971 --- /dev/null +++ b/gcc/config/i370/i370-c.c @@ -0,0 +1,63 @@ +/* Subroutines for the C front end for System/370. + Copyright (C) 1989, 1993, 1995, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. + Contributed by Jan Stein (jan@cd.chalmers.se). + Modified for OS/390 LanguageEnvironment C by Dave Pitts (dpitts@cozx.com) + Hacked for Linux-ELF/390 by Linas Vepstas (linas@linas.org) + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include "system.h" +#include "tree.h" +#include "toplev.h" +#include "cpplib.h" +#include "c-pragma.h" +#include "c-lex.h" +#include "i370-protos.h" + +#ifdef TARGET_HLASM + +/* #pragma map (name, alias) - + In this implementation both name and alias are required to be + identifiers. The older code seemed to be more permissive. Can + anyone clarify? */ + +void +i370_pr_map (pfile) + cpp_reader *pfile ATTRIBUTE_UNUSED; +{ + tree name, alias, x; + + if (c_lex (&x) == CPP_OPEN_PAREN + && c_lex (&name) == CPP_NAME + && c_lex (&x) == CPP_COMMA + && c_lex (&alias) == CPP_NAME + && c_lex (&x) == CPP_CLOSE_PAREN) + { + if (c_lex (&x) != CPP_EOF) + warning ("junk at end of #pragma map"); + + mvs_add_alias (IDENTIFIER_POINTER (name), IDENTIFIER_POINTER (alias), 1); + return; + } + + warning ("malformed #pragma map, ignored"); +} + +#endif diff --git a/gcc/config/i370/i370.c b/gcc/config/i370/i370.c index ca3cafb2ab0..1547da2eacb 100644 --- a/gcc/config/i370/i370.c +++ b/gcc/config/i370/i370.c @@ -39,8 +39,6 @@ Boston, MA 02111-1307, USA. */ #include "recog.h" #include "toplev.h" #include "cpplib.h" -#include "c-pragma.h" -#include "c-lex.h" #include "tm_p.h" #include "target.h" #include "target-def.h" @@ -1031,33 +1029,6 @@ mvs_check_alias (realname, aliasname) return 0; } -/* #pragma map (name, alias) - - In this implementation both name and alias are required to be - identifiers. The older code seemed to be more permissive. Can - anyone clarify? */ - -void -i370_pr_map (pfile) - cpp_reader *pfile ATTRIBUTE_UNUSED; -{ - tree name, alias, x; - - if (c_lex (&x) == CPP_OPEN_PAREN - && c_lex (&name) == CPP_NAME - && c_lex (&x) == CPP_COMMA - && c_lex (&alias) == CPP_NAME - && c_lex (&x) == CPP_CLOSE_PAREN) - { - if (c_lex (&x) != CPP_EOF) - warning ("junk at end of #pragma map"); - - mvs_add_alias (IDENTIFIER_POINTER (name), IDENTIFIER_POINTER (alias), 1); - return; - } - - warning ("malformed #pragma map, ignored"); -} - /* defines and functions specific to the HLASM assembler */ #endif /* TARGET_HLASM */ /* ===================================================== */ diff --git a/gcc/config/i370/t-i370 b/gcc/config/i370/t-i370 new file mode 100644 index 00000000000..c92ebed33f1 --- /dev/null +++ b/gcc/config/i370/t-i370 @@ -0,0 +1,3 @@ +i370-c.o: $(srcdir)/config/i370/i370-c.c $(srcdir)/config/i370/i370-protos.h \ + $(CONFIG_H) $(SYSTEM_H) cpplib.h $(TREE_H) c-pragma.h c-lex.h toplev.h + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index c5863952802..227636f47a0 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8514,12 +8514,13 @@ pragma of the form @var{space} is the case-sensitive namespace of the pragma, or @code{NULL} to put the pragma in the global namespace. The callback routine receives @var{pfile} as its first argument, which can be passed -on to cpplib's functions if necessary. It may read any text after the -@var{name} by making calls to @code{c_lex}. Text which is not read by -the callback will be silently ignored. +on to cpplib's functions if necessary. You can lex tokens after the +@var{name} by calling @code{c_lex}. Tokens that are not read by the +callback will be silently ignored. The end of the line is indicated by +a token of type @code{CPP_EOF}. For an example use of this routine, see @file{c4x.h} and the callback -routines defined in @file{c4x.c}. +routines defined in @file{c4x-c.c}. Note that the use of @code{c_lex} is specific to the C and C++ compilers. It will not work in the Java or Fortran compilers, or any