* config/tc-tic80.c (tic80_relax): New static variable.

(md_longopts): Add new OPTION_RELAX and OPTION_NO_RELAX options.
	(md_parse_option): Handle new relax options.
	(md_show_usage): Document new relax options.
	(find_opcode): Don't use short forms of PC relative branches if
	tic80_relax is set.
PR 12927
This commit is contained in:
Fred Fish 1997-12-16 20:03:53 +00:00
parent 47d1c515b0
commit 37f82cb4dc
2 changed files with 48 additions and 6 deletions

View file

@ -1,3 +1,14 @@
start-sanitize-tic80
Tue Dec 16 16:55:45 1997 Fred Fish <fnf@cygnus.com>
* config/tc-tic80.c (tic80_relax): New static variable.
(md_longopts): Add new OPTION_RELAX and OPTION_NO_RELAX options.
(md_parse_option): Handle new relax options.
(md_show_usage): Document new relax options.
(find_opcode): Don't use short forms of PC relative branches if
tic80_relax is set.
end-sanitize-tic80
start-sanitize-d30v
Tue Dec 16 15:26:03 1997 Michael Meissner <meissner@cygnus.com>

View file

@ -75,6 +75,12 @@ static void build_insn PARAMS ((struct tic80_opcode *, expressionS *));
static int get_operands PARAMS ((expressionS exp[]));
static int const_overflow PARAMS ((unsigned long num, int bits, int flags));
/* Replace short PC relative instructions with long form when necessary. Currently
this is off by default or when given the -no-relax option. Turning it on by using
the -relax option forces all PC relative instructions to use the long form, which
is why it is currently not the default. */
static int tic80_relax = 0;
int
md_estimate_size_before_relax (fragP, segment_type)
@ -393,16 +399,19 @@ find_opcode (opcode, myops)
}
break;
case O_symbol:
if ((bits < 32) && (flags & TIC80_OPERAND_PCREL))
if ((bits < 32) && (flags & TIC80_OPERAND_PCREL) && !tic80_relax)
{
/* For now we only allow PC relative relocations in the
short immediate fields, like the TI assembler.
/* The default is to prefer the short form of PC relative relocations.
This is the only form that the TI assembler supports.
If the -relax option is given, we never use the short forms.
FIXME: Should be able to choose "best-fit". */
}
else if ((bits == 32) /* && (flags & TIC80_OPERAND_BASEREL) */)
{
/* For now we only allow base relative relocations in
the long immediate fields, like the TI assembler.
/* The default is to prefer the long form of base relative relocations.
This is the only form that the TI assembler supports.
If the -no-relax option is given, we always use the long form of
PC relative relocations.
FIXME: Should be able to choose "best-fit". */
}
else
@ -896,6 +905,13 @@ CONST char *md_shortopts = "";
that are passed to getopt. */
struct option md_longopts[] = {
#define OPTION_RELAX (OPTION_MD_BASE)
{"relax", no_argument, NULL, OPTION_RELAX},
#define OPTION_NO_RELAX (OPTION_RELAX + 1)
{"no-relax", no_argument, NULL, OPTION_NO_RELAX},
{NULL, no_argument, NULL, 0}
};
@ -910,7 +926,18 @@ md_parse_option (c, arg)
int c;
char *arg;
{
return (0);
switch (c)
{
case OPTION_RELAX:
tic80_relax = 1;
break;
case OPTION_NO_RELAX:
tic80_relax = 0;
break;
default:
return (0);
}
return (1);
}
/* The md_show_usage function will be called whenever a usage message is
@ -921,6 +948,10 @@ void
md_show_usage (stream)
FILE *stream;
{
fprintf (stream, "\
TIc80 options:\n\
-relax alter PC relative branch instructions to use long form when needed\n\
-no-relax always use short PC relative branch instructions, error on overflow\n");
}