From d129e0d61af27ef27f2ce9a6258df73d2a258c68 Mon Sep 17 00:00:00 2001 From: bebbo Date: Thu, 28 Apr 2022 20:56:04 +0200 Subject: [PATCH] add __near to move some stuff into the data segment --- gcc/c-family/c-common.c | 4 +++- gcc/c-family/c-format.c | 31 ++++++++++++++++++++++++++- gcc/c-family/c-pch.c | 4 +++- gcc/cp/decl.c | 3 +++ gcc/cp/error.c | 3 +++ gcc/cp/rtti.c | 3 +++ gcc/gengtype.c | 46 +++++++++++++++++++++++++++++++++++++++-- gcc/ggc-common.c | 2 ++ gcc/ggc.h | 9 ++++++++ gcc/params.c | 3 +++ gcc/sel-sched-ir.c | 19 ++++++++++------- gcc/tree-vect-stmts.c | 13 ++++++------ libgcc/unwind-dw2-fde.c | 6 ++++++ libiberty/cp-demangle.c | 3 +++ libiberty/cp-demangle.h | 3 +++ 15 files changed, 133 insertions(+), 19 deletions(-) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 0c353b88fc9..f0dfed44d5c 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -284,7 +284,9 @@ struct fname_var_t }; /* The three ways of getting then name of the current function. */ - +#ifdef __amiga__ +__near +#endif const struct fname_var_t fname_vars[] = { /* C99 compliant __func__, must be first. */ diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index c19c411d61a..fceff72f757 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -669,7 +669,9 @@ static const format_flag_pair strfmon_flag_pairs[] = { 0, 0, 0, 0 } }; - +#ifdef __amiga__ +__near +#endif static const format_char_info print_char_table[] = { /* C89 conversion specifiers. */ @@ -693,6 +695,9 @@ static const format_char_info print_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info asm_fprintf_char_table[] = { /* C89 conversion specifiers. */ @@ -713,6 +718,9 @@ static const format_char_info asm_fprintf_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info gcc_diag_char_table[] = { /* C89 conversion specifiers. */ @@ -734,6 +742,9 @@ static const format_char_info gcc_diag_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info gcc_tdiag_char_table[] = { /* C89 conversion specifiers. */ @@ -757,6 +768,9 @@ static const format_char_info gcc_tdiag_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info gcc_cdiag_char_table[] = { /* C89 conversion specifiers. */ @@ -780,6 +794,9 @@ static const format_char_info gcc_cdiag_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info gcc_cxxdiag_char_table[] = { /* C89 conversion specifiers. */ @@ -806,6 +823,9 @@ static const format_char_info gcc_cxxdiag_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info gcc_gfc_char_table[] = { /* C89 conversion specifiers. */ @@ -826,6 +846,9 @@ static const format_char_info gcc_gfc_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info scan_char_table[] = { /* C89 conversion specifiers. */ @@ -874,6 +897,9 @@ static const format_char_info time_char_table[] = { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } }; +#ifdef __amiga__ +__near +#endif static const format_char_info monetary_char_table[] = { { "in", 0, STD_C89, { T89_D, BADLEN, BADLEN, BADLEN, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "=^+(!-w#p", "", NULL }, @@ -881,6 +907,9 @@ static const format_char_info monetary_char_table[] = }; /* This must be in the same order as enum format_type. */ +#ifdef __amiga__ +__near +#endif static const format_kind_info format_types_orig[] = { { "gnu_printf", printf_length_specs, print_char_table, " +#0-'I", NULL, diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c index 9147c62be54..2261ea26209 100644 --- a/gcc/c-family/c-pch.c +++ b/gcc/c-family/c-pch.c @@ -32,7 +32,9 @@ along with GCC; see the file COPYING3. If not see /* This is a list of flag variables that must match exactly, and their names for the error message. The possible values for *flag_var must fit in a 'signed char'. */ - +#ifdef __amiga__ +__near +#endif static const struct c_pch_matching { int *flag_var; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 975dea75833..736e55b9f9e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3956,6 +3956,9 @@ initialize_predefined_identifiers (void) const predefined_identifier *pid; /* A table of identifiers to create at startup. */ +#ifdef __amiga__ +__near +#endif static const predefined_identifier predefined_identifiers[] = { { "C++", &lang_name_cplusplus, 0 }, { "C", &lang_name_c, 0 }, diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7a324981424..d970fa06397 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -40,6 +40,9 @@ along with GCC; see the file COPYING3. If not see debugger or by the front-end for things like __PRETTY_FUNCTION__. */ static cxx_pretty_printer actual_pretty_printer; +#ifdef __amiga__ +__near +#endif static cxx_pretty_printer * const cxx_pp = &actual_pretty_printer; /* Translate if being used for diagnostics, but not for dump files or diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 244c34d0580..e68cdd467f7 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1511,6 +1511,9 @@ emit_support_tinfos (void) { /* Dummy static variable so we can put nullptr in the array; it will be set before we actually start to walk the array. */ +#ifdef __amiga__ +__near +#endif static tree *const fundamentals[] = { &void_type_node, diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 987069ae7f7..27c6b71a262 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -4106,6 +4106,17 @@ finish_root_table (struct flist *flp, const char *pfx, const char *lastname, for (fnum = 0; bitmap != 0; fnum++, bitmap >>= 1) if (bitmap & 1) { + char const * mf = get_output_file_name (CONST_CAST (input_file*, fli2->file)); + if (0 == strcmp(mf, "gt-c-c-decl.h") || + 0 == strcmp(mf, "gt-c-family-c-common.h") || + 0 == strcmp(mf, "gt-c-c-parser.h") || 1 + ) + { + oprintf (base_files[fnum], "\n#ifdef __amiga__\n"); + oprintf (base_files[fnum], "__attribute((section(\".data\")))\n"); + oprintf (base_files[fnum], "#endif\n"); + } + oprintf (base_files[fnum], "extern const struct %s gt_%s_", tname, pfx); put_mangled_filename (base_files[fnum], fli2->file); @@ -4116,8 +4127,19 @@ finish_root_table (struct flist *flp, const char *pfx, const char *lastname, { size_t fnum; for (fnum = 0; base_files && fnum < num_lang_dirs; fnum++) - oprintf (base_files[fnum], - "EXPORTED_CONST struct %s * const %s[] = {\n", tname, name); + { + if (0 == strcmp(name, "gt_ggc_rtab") || + 0 == strcmp(name, "gt_pch_scalar_rtab") || + 0 == strcmp(name, "gt_ggc_r_gt_c_c_decl_h") + || 1) + { + oprintf (base_files[fnum], "#ifdef __amiga__\n"); + oprintf (base_files[fnum], "__attribute((section(\".data\")))\n"); + oprintf (base_files[fnum], "#endif\n"); + } + oprintf (base_files[fnum], + "EXPORTED_CONST struct %s * const %s[] = {\n", tname, name); + } } @@ -4552,6 +4574,15 @@ write_roots (pair_p variables, bool emit_pch) if (!fli->started_p) { fli->started_p = 1; + char const * mf = get_output_file_name (CONST_CAST (input_file*, v->line.file)); + if (0 == strcmp(mf, "gt-c-c-decl.h") || + 0 == strcmp(mf, "gt-c-c-parser.h") || 1 + ) + { + oprintf (f, "\n#ifdef __amiga__\n"); + oprintf (f, "__attribute((section(\".data\")))\n"); + oprintf (f, "#endif\n"); + } oprintf (f, "EXPORTED_CONST struct ggc_root_tab gt_ggc_r_"); put_mangled_filename (f, v->line.file); @@ -4586,6 +4617,9 @@ write_roots (pair_p variables, bool emit_pch) { fli->started_p = 1; + oprintf (f, "#ifdef __amiga__\n"); + oprintf (f, "__attribute((section(\".data\")))\n"); + oprintf (f, "#endif\n"); oprintf (f, "EXPORTED_CONST struct ggc_root_tab gt_ggc_rd_"); put_mangled_filename (f, v->line.file); oprintf (f, "[] = {\n"); @@ -4660,6 +4694,14 @@ write_roots (pair_p variables, bool emit_pch) { fli->started_p = 1; + char const * mf = get_output_file_name (CONST_CAST (input_file*, v->line.file)); + if (0 == strcmp(mf, "gt-c-c-decl.h") || 1) + { + oprintf (f, "\n#ifdef __amiga__\n"); + oprintf (f, "__attribute((section(\".data\")))\n"); + oprintf (f, "#endif\n"); + } + oprintf (f, "EXPORTED_CONST struct ggc_root_tab gt_pch_rs_"); put_mangled_filename (f, v->line.file); oprintf (f, "[] = {\n"); diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 9b291aa3387..d4006dc552b 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "hosthooks.h" #include "plugin.h" +#include /* When set, ggc_collect will do collection. */ bool ggc_force_collect; @@ -729,6 +730,7 @@ static double ggc_rlimit_bound (double limit) { #if defined(HAVE_GETRLIMIT) +// && !defined __amiga__ struct rlimit rlim; # if defined (RLIMIT_AS) /* RLIMIT_AS is what POSIX says is the limit on mmap. Presumably diff --git a/gcc/ggc.h b/gcc/ggc.h index 1ee2bbf3d33..0fda05dd83e 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -71,8 +71,17 @@ struct ggc_root_tab { #define LAST_GGC_ROOT_TAB { NULL, 0, 0, NULL, NULL } /* Pointers to arrays of ggc_root_tab, terminated by NULL. */ #ifndef __MAKE_MSYS2__ +#ifdef __amiga__ +__near +#endif extern const struct ggc_root_tab * const gt_ggc_rtab[]; +#ifdef __amiga__ +__near +#endif extern const struct ggc_root_tab * const gt_ggc_deletable_rtab[]; +#ifdef __amiga__ +__near +#endif extern const struct ggc_root_tab * const gt_pch_scalar_rtab[]; #endif diff --git a/gcc/params.c b/gcc/params.c index 41660b47393..5aa2b8f9e1f 100644 --- a/gcc/params.c +++ b/gcc/params.c @@ -45,6 +45,9 @@ static bool params_finished; #undef DEFPARAMENUM5 #undef DEFPARAM +#ifdef __amiga__ +__near +#endif static const param_info lang_independent_params[] = { #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \ { OPTION, DEFAULT, MIN, MAX, HELP, NULL }, diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 83f813aa571..701307c8b03 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -3086,6 +3086,17 @@ finish_global_and_expr_insn (insn_t insn) } } +#ifdef __amiga__ +__near +#endif +const static struct sched_scan_info_def ssi0 = + { + NULL, /* extend_bb */ + finish_global_and_expr_for_bb, /* init_bb */ + NULL, /* extend_insn */ + finish_global_and_expr_insn /* init_insn */ + }; + /* Finalize per instruction data for the whole region. */ void sel_finish_global_and_expr (void) @@ -3101,13 +3112,7 @@ sel_finish_global_and_expr (void) /* Clear AV_SETs and INSN_EXPRs. */ { - const struct sched_scan_info_def ssi = - { - NULL, /* extend_bb */ - finish_global_and_expr_for_bb, /* init_bb */ - NULL, /* extend_insn */ - finish_global_and_expr_insn /* init_insn */ - }; + struct sched_scan_info_def ssi = ssi0; sched_scan (&ssi, bbs); } diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index dae3766dce6..7b93eb51b4a 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3603,7 +3603,6 @@ vect_create_vectorized_promotion_stmts (vec *vec_oprnds0, If VEC_STMT is also passed, vectorize the STMT: create a vectorized stmt to replace it, put it in VEC_STMT, and insert it at GSI. Return FALSE if not a vectorizable STMT, TRUE otherwise. */ - static bool vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, slp_tree slp_node) @@ -3619,7 +3618,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, tree decl1 = NULL_TREE, decl2 = NULL_TREE; tree new_temp; gimple *def_stmt; - enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dt[2]; dt[0] = vect_unknown_def_type; dt[1] = vect_unknown_def_type; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -4209,7 +4208,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi, loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); tree new_temp; gimple *def_stmt; - enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dt[2]; dt[0] = vect_unknown_def_type; dt[1] = vect_unknown_def_type; int ncopies; int i, j; vec vec_oprnds = vNULL; @@ -4420,7 +4419,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi, int icode; machine_mode optab_op2_mode; gimple *def_stmt; - enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dt[2]; dt[0] = vect_unknown_def_type; dt[1] = vect_unknown_def_type; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -4793,8 +4792,8 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi, optab optab; bool target_support_p; gimple *def_stmt; - enum vect_def_type dt[3] - = {vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dt[3]; + dt[0] = vect_unknown_def_type; dt[1] = vect_unknown_def_type; dt[2] = vect_unknown_def_type; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -7827,7 +7826,7 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, tree vec_rhs1 = NULL_TREE, vec_rhs2 = NULL_TREE; tree new_temp; loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); - enum vect_def_type dts[2] = {vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dts[2]; dts[0] = vect_unknown_def_type; dts[1] = vect_unknown_def_type; unsigned nunits; int ncopies; enum tree_code code; diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c index 5b16a1f87e2..943ad45ef90 100644 --- a/libgcc/unwind-dw2-fde.c +++ b/libgcc/unwind-dw2-fde.c @@ -440,6 +440,9 @@ static inline void fde_split (struct object *ob, fde_compare_t fde_compare, struct fde_vector *linear, struct fde_vector *erratic) { +#ifdef __amiga__ +__near +#endif static const fde *marker; size_t count = linear->count; const fde *const *chain_end = ▮ @@ -749,6 +752,9 @@ init_object (struct object* ob) count = classify_object_over_fdes (ob, ob->u.single); if (count == (size_t) -1) { +#ifdef __amiga__ +__near +#endif static const fde terminator; unhandled_fdes: ob->s.i = 0; diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 78e59788478..29933f518eb 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -2250,6 +2250,9 @@ d_ctor_dtor_name (struct d_info *di) ::= u */ +#ifdef __amiga__ +__near +#endif CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h index 197883e2560..31c74d880f8 100644 --- a/libiberty/cp-demangle.h +++ b/libiberty/cp-demangle.h @@ -180,6 +180,9 @@ extern const struct demangle_operator_info cplus_demangle_operators[]; #define D_BUILTIN_TYPE_COUNT (33) +#ifdef __amiga__ +__near +#endif CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT];