This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/2] xtensa: add --tramp-limit option to gas
- From: Max Filippov <jcmvbkbc at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Sterling Augustine <augustine dot sterling at gmail dot com>, David Weatherford <weath at cadence dot com>, Marc Gauthier <marc at cadence dot com>, linux-xtensa at linux-xtensa dot org, Max Filippov <jcmvbkbc at gmail dot com>
- Date: Wed, 12 Aug 2015 03:54:26 +0300
- Subject: [PATCH 1/2] xtensa: add --tramp-limit option to gas
- Authentication-results: sourceware.org; auth=none
- References: <1439340867-980-1-git-send-email-jcmvbkbc at gmail dot com>
Hardcoded frag count limit for trampoline frag emission may not work for
all configurations. Make that limit configurable.
2015-08-12 David Weatherford <weath@cadence.com>
gas/
* config/tc-xtensa.c (trampoline_frag_limit): New static
variable.
(option_trampoline_limit): New option enum identifier.
(md_longopts): New entry for tramp-limit option.
(md_parse_option): Handle option_trampoline_limit.
(md_show_usage): Help text for --tramp-limit option.
(xtensa_check_frag_count): Fix comment, replace hard-coded limit
with trampoline_frag_limit variable.
---
gas/config/tc-xtensa.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 18307c1..f818ae5 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -469,6 +469,7 @@ static void finish_vinsn (vliw_insn *);
static bfd_boolean emit_single_op (TInsn *);
static int total_frag_text_expansion (fragS *);
static bfd_boolean use_trampolines = TRUE;
+static int trampoline_frag_limit = 8000;
static void xtensa_check_frag_count (void);
static void xtensa_create_trampoline_frag (bfd_boolean);
static void xtensa_maybe_create_trampoline_frag (void);
@@ -698,6 +699,7 @@ enum
option_trampolines,
option_no_trampolines,
+ option_trampoline_limit,
};
const char *md_shortopts = "";
@@ -772,6 +774,7 @@ struct option md_longopts[] =
{ "trampolines", no_argument, NULL, option_trampolines },
{ "no-trampolines", no_argument, NULL, option_no_trampolines },
+ { "tramp-limit", required_argument, NULL, option_trampoline_limit },
{ NULL, no_argument, NULL, 0 }
};
@@ -961,6 +964,21 @@ md_parse_option (int c, char *arg)
use_trampolines = FALSE;
return 1;
+ case option_trampoline_limit:
+ {
+ int value = 0;
+ if (*arg == 0 || *arg == '-')
+ as_fatal (_("invalid tramp-limit argument"));
+ value = strtol (arg, &arg, 10);
+ if (*arg != 0)
+ as_fatal (_("invalid tramp-limit argument"));
+ if (value < 100 || value > 10000)
+ as_fatal (_("invalid tramp-limit argument (range is 100-10000)"));
+ trampoline_frag_limit = value;
+ use_trampolines = TRUE;
+ return 1;
+ }
+
default:
return 0;
}
@@ -986,7 +1004,10 @@ Xtensa options:\n\
flix bundles\n\
--rename-section old=new Rename section 'old' to 'new'\n\
--[no-]trampolines [Do not] generate trampolines (jumps to jumps)\n\
- when jumps do not reach their targets\n", stream);
+ when jumps do not reach their targets\n\
+ --tramp-limit=<value> (default 8000, range 100-10000) Maximum number of\n\
+ blocks of instructions to emit between trampoline\n\
+ locations; implies --trampolines flag\n", stream);
}
@@ -7303,12 +7324,10 @@ xtensa_check_frag_count (void)
if (!use_trampolines || frag_now->tc_frag_data.is_no_transform)
return;
- /* We create an area for possible trampolines every 8000 frags or so. This
- is an estimate based on the max range of a "j" insn (+/-128K) divided
- by a typical frag byte count (16), minus a few for safety. This function
- is called after each source line is processed. */
+ /* We create an area for possible trampolines every 8000 frags or so.
+ This function is called after each source line is processed. */
- if (get_frag_count () > 8000)
+ if (get_frag_count () > trampoline_frag_limit)
{
xtensa_create_trampoline_frag (TRUE);
clear_frag_count ();
--
1.8.1.4