From 3217af3e616fde3ebfc47747327885439ffc8724 Mon Sep 17 00:00:00 2001 From: Kaz Kojima Date: Thu, 22 May 2008 22:23:54 +0000 Subject: [PATCH] sh.opt (mfixed-range): New option. * config/sh/sh.opt (mfixed-range): New option. * config/sh/sh-protos.h (sh_fix_range): Declare. * config/sh/sh.c (sh_fix_range): New function. * config/sh/sh.h (sh_fixed_range_str): Declare. (OVERRIDE_OPTIONS): Call sh_fix_range if sh_fixed_range_str is not empty. * doc/invoke.texi (SH Options): Document -mfixed-range. From-SVN: r135779 --- gcc/ChangeLog | 10 +++++++ gcc/config/sh/sh-protos.h | 1 + gcc/config/sh/sh.c | 62 +++++++++++++++++++++++++++++++++++++++ gcc/config/sh/sh.h | 5 ++++ gcc/config/sh/sh.opt | 4 +++ gcc/doc/invoke.texi | 10 ++++++- 6 files changed, 91 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68a04067cac..116fb969109 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2008-05-22 Kaz Kojima + + * config/sh/sh.opt (mfixed-range): New option. + * config/sh/sh-protos.h (sh_fix_range): Declare. + * config/sh/sh.c (sh_fix_range): New function. + * config/sh/sh.h (sh_fixed_range_str): Declare. + (OVERRIDE_OPTIONS): Call sh_fix_range if sh_fixed_range_str + is not empty. + * doc/invoke.texi (SH Options): Document -mfixed-range. + 2008-05-22 Kai Tietz * config/i386/sol2-10.h (SUBTARGET_RETURN_IN_MEMORY): Undefine diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 9e1a4882354..a03c624d660 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -173,6 +173,7 @@ extern enum reg_class sh_secondary_reload (bool, rtx, enum reg_class, struct secondary_reload_info *); extern int sh2a_get_function_vector_number (rtx); extern int sh2a_is_function_vector_call (rtx); +extern void sh_fix_range (const char *); #endif /* ! GCC_SH_PROTOS_H */ diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index a41783de91b..3af0ee8cff1 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -7973,6 +7973,68 @@ initial_elimination_offset (int from, int to) else return total_auto_space; } + +/* Parse the -mfixed-range= option string. */ +void +sh_fix_range (const char *const_str) +{ + int i, first, last; + char *str, *dash, *comma; + + /* str must be of the form REG1'-'REG2{,REG1'-'REG} where REG1 and + REG2 are either register names or register numbers. The effect + of this option is to mark the registers in the range from REG1 to + REG2 as ``fixed'' so they won't be used by the compiler. */ + + i = strlen (const_str); + str = (char *) alloca (i + 1); + memcpy (str, const_str, i + 1); + + while (1) + { + dash = strchr (str, '-'); + if (!dash) + { + warning (0, "value of -mfixed-range must have form REG1-REG2"); + return; + } + *dash = '\0'; + comma = strchr (dash + 1, ','); + if (comma) + *comma = '\0'; + + first = decode_reg_name (str); + if (first < 0) + { + warning (0, "unknown register name: %s", str); + return; + } + + last = decode_reg_name (dash + 1); + if (last < 0) + { + warning (0, "unknown register name: %s", dash + 1); + return; + } + + *dash = '-'; + + if (first > last) + { + warning (0, "%s-%s is an empty range", str, dash + 1); + return; + } + + for (i = first; i <= last; ++i) + fixed_regs[i] = call_used_regs[i] = 1; + + if (!comma) + break; + + *comma = ','; + str = comma + 1; + } +} /* Insert any deferred function attributes from earlier pragmas. */ static void diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 67a6e3923fb..2ff4a81f9b6 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -533,6 +533,8 @@ extern enum sh_divide_strategy_e sh_div_strategy; #define SUBTARGET_OVERRIDE_OPTIONS (void) 0 +extern const char *sh_fixed_range_str; + #define OVERRIDE_OPTIONS \ do { \ int regno; \ @@ -754,6 +756,9 @@ do { \ if (align_functions < min_align) \ align_functions = min_align; \ } \ + \ + if (sh_fixed_range_str) \ + sh_fix_range (sh_fixed_range_str); \ } while (0) /* Target machine storage layout. */ diff --git a/gcc/config/sh/sh.opt b/gcc/config/sh/sh.opt index b62530f6100..145e2d504c3 100644 --- a/gcc/config/sh/sh.opt +++ b/gcc/config/sh/sh.opt @@ -248,6 +248,10 @@ mdivsi3_libfunc= Target RejectNegative Joined Var(sh_divsi3_libfunc) Init("") Specify name for 32 bit signed division function +mfixed-range= +Target RejectNegative Joined Var(sh_fixed_range_str) +Specify range of registers to make fixed + mfmovd Target RejectNegative Mask(FMOVD) Undocumented diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 842755d1a24..061311fb260 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -748,7 +748,7 @@ See RS/6000 and PowerPC Options. -mbigtable -mfmovd -mhitachi -mrenesas -mno-renesas -mnomacsave @gol -mieee -mbitops -misize -minline-ic_invalidate -mpadstruct -mspace @gol -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol --mdivsi3_libfunc=@var{name} @gol +-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol -madjust-unroll -mindexed-addressing -mgettrcost=@var{number} -mpt-fixed @gol -minvalid-symbols} @@ -14090,6 +14090,14 @@ Set the name of the library function used for 32 bit signed division to division strategies, and the compiler will still expect the same sets of input/output/clobbered registers as if this option was not present. +@item -mfixed-range=@var{register-range} +@opindex mfixed-range +Generate code treating the given register range as fixed registers. +A fixed register is one that the register allocator can not use. This is +useful when compiling kernel code. A register range is specified as +two registers separated by a dash. Multiple register ranges can be +specified separated by a comma. + @item -madjust-unroll @opindex madjust-unroll Throttle unrolling to avoid thrashing target registers. -- 2.30.2