]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
spu.opt (mfixed-range): New option.
authorSa Liu <saliu@de.ibm.com>
Tue, 12 Dec 2006 04:55:50 +0000 (04:55 +0000)
committerBen Elliston <bje@gcc.gnu.org>
Tue, 12 Dec 2006 04:55:50 +0000 (15:55 +1100)
* config/spu/spu.opt (mfixed-range): New option.
* config/spu/spu.h (spu_fixed_range_string): Declare.
* config/spu/spu.c (spu_override_options): Handle -mfixed-range.
(fix_range): New function.
* doc/invoke.texi (SPU Options): Document -mfixed-range.
* testsuite/gcc.target/spu/fixed-range.c: New.
* testsuite/gcc.target/spu/fixed-range-bad.c: Ditto.

Co-Authored-By: Ben Elliston <bje@au.ibm.com>
From-SVN: r119768

gcc/ChangeLog
gcc/config/spu/spu.c
gcc/config/spu/spu.h
gcc/config/spu/spu.opt
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/spu/fixed-range-bad.c [new file with mode: 0644]
gcc/testsuite/gcc.target/spu/fixed-range.c [new file with mode: 0644]

index a39ec7eaf1094c3df5e941dede3a8330349149c7..4c150cc4c3476740338a7133d974071c0b1770f4 100644 (file)
@@ -1,3 +1,14 @@
+2006-12-12  Sa Liu  <saliu@de.ibm.com>
+           Ben Elliston  <bje@au.ibm.com>
+
+       * config/spu/spu.opt (mfixed-range): New option.
+       * config/spu/spu.h (spu_fixed_range_string): Declare.
+       * config/spu/spu.c (spu_override_options): Handle -mfixed-range.
+       (fix_range): New function.
+       * doc/invoke.texi (SPU Options): Document -mfixed-range.
+       * testsuite/gcc.target/spu/fixed-range.c: New.
+       * testsuite/gcc.target/spu/fixed-range-bad.c: Ditto.
+
 2006-12-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/17982
index 70f09c5d918725f7c6405181f6fb8802bb198760..52c8e9ce9cb03d69c610eda55925949dd204ad03 100644 (file)
@@ -128,6 +128,7 @@ static unsigned char spu_rtx_costs (rtx x, int code, int outer_code,
 static unsigned char spu_function_ok_for_sibcall (tree decl, tree exp);
 static void spu_init_libfuncs (void);
 static bool spu_return_in_memory (tree type, tree fntype);
+static void fix_range (const char *);
 
 extern const char *reg_names[];
 rtx spu_compare_op0, spu_compare_op1;
@@ -264,6 +265,9 @@ spu_override_options (void)
 
   if (align_functions < 8)
     align_functions = 8;
+
+  if (spu_fixed_range_string)
+    fix_range (spu_fixed_range_string);
 }
 \f
 /* Handle an attribute requiring a FUNCTION_DECL; arguments as in
@@ -3574,6 +3578,68 @@ mem_is_padded_component_ref (rtx x)
   return 0;
 }
 
+/* Parse the -mfixed-range= option string.  */
+static void
+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;
+    }
+}
+
 int
 spu_valid_move (rtx * ops)
 {
index b56ff1486e6c660d7a1ac01624a6fa8fbf535767..923ca75ac7410db3280b5ddc28bd975e53353f8a 100644 (file)
@@ -24,6 +24,7 @@
 #define OVERRIDE_OPTIONS spu_override_options()
 
 extern int target_flags;
+extern const char *spu_fixed_range_string;
 
 /* Default target_flags if no switches specified.  */
 #ifndef TARGET_DEFAULT
index 5df242ebe9e6ebe4c32ca73431e127c701168865..6c3ab59b63d38fd494cd8a4150ebf43afbf62d8e 100644 (file)
@@ -52,3 +52,6 @@ mlarge-mem
 Target Report RejectNegative Mask(LARGE_MEM)
 Generate code for 32 bit addressing
 
+mfixed-range=
+Target RejectNegative Joined Var(spu_fixed_range_string)
+Specify range of registers to make fixed
index b7eab9e964f6d634f0a8725e137505fb0ce6d542..2d28e8509e1e3644b7f122fd99e6cd17856b89ad 100644 (file)
@@ -733,7 +733,8 @@ See RS/6000 and PowerPC Options.
 @gccoptlist{-mwarn-reloc -merror-reloc @gol
 -msafe-dma -munsafe-dma @gol
 -mbranch-hints @gol
--msmall-mem -mlarge-mem -mstdmain}
+-msmall-mem -mlarge-mem -mstdmain @gol
+-mfixed-range=@var{register-range}}
 
 @emph{System V Options}
 @gccoptlist{-Qy  -Qn  -YP,@var{paths}  -Ym,@var{dir}}
@@ -12909,6 +12910,14 @@ With @option{-mstdmain}, GCC will link your program against startup
 code that assumes a C99-style interface to @code{main}, including a
 local copy of @code{argv} strings.
 
+@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.
+
 @end table
 
 @node System V Options
diff --git a/gcc/testsuite/gcc.target/spu/fixed-range-bad.c b/gcc/testsuite/gcc.target/spu/fixed-range-bad.c
new file mode 100644 (file)
index 0000000..eeef122
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-mfixed-range=1-x" } */
+/* { dg-error "unknown register name" "" { target spu-*-* } 0 } */
+
+int i;
diff --git a/gcc/testsuite/gcc.target/spu/fixed-range.c b/gcc/testsuite/gcc.target/spu/fixed-range.c
new file mode 100644 (file)
index 0000000..8dcb7fe
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mfixed-range=1-20" } */
+/* { dg-final { scan-assembler "lqd.*21" } } */
+
+int foo (int i)
+{
+  return i;
+}