]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/33256 (internal compiler error: in print_operand_reloc, at config/mips...
authorRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 6 Sep 2007 18:04:51 +0000 (18:04 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 6 Sep 2007 18:04:51 +0000 (18:04 +0000)
gcc/
PR target/33256
* config/mips/mips.c (mips_classify_symbolic_expression): New function.
(mips_classify_address): Use it instead of mips_symbolic_constant_p.
(print_operand_reloc): Likewise.

gcc/testsuite/
200x-xx-xx  David Daney  <ddaney@avtrex.com>
    Richard Sandiford  <richard@codesourcery.com>

PR target/33256
* gcc.target/mips/mips.exp (setup_mips_tests): Set mips_forced_le.
(dg-mips-options): Skip -EB and -meb tests when $mips_forced_le.
* gcc.target/mips/pr33256.c: New test.

From-SVN: r128197

gcc/ChangeLog
gcc/config/mips/mips.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/mips.exp
gcc/testsuite/gcc.target/mips/pr33256.c [new file with mode: 0644]

index 5f7785a28e869e65dc0647af9d13835c05bf647d..94bbd3db77683cdac30df6084cf421488b909da5 100644 (file)
@@ -1,3 +1,10 @@
+2007-09-06  Richard Sandiford  <richard@codesourcery.com>
+
+       PR target/33256
+       * config/mips/mips.c (mips_classify_symbolic_expression): New function.
+       (mips_classify_address): Use it instead of mips_symbolic_constant_p.
+       (print_operand_reloc): Likewise.
+
 2007-09-03  Anatoly Sokolov <aesok@post.ru>
 
        PR target/28902
index 381082b8fb3829f3eb95aeb583569ae304ede8e3..19b732182dba9167d947d6150351f8a3ecb8da53 100644 (file)
@@ -1292,6 +1292,20 @@ mips_split_const (rtx x, rtx *base, HOST_WIDE_INT *offset)
   *base = x;
 }
 
+/* Classify symbolic expression X, given that it appears in context
+   CONTEXT.  */
+
+static enum mips_symbol_type
+mips_classify_symbolic_expression (rtx x)
+{
+  HOST_WIDE_INT offset;
+
+  mips_split_const (x, &x, &offset);
+  if (UNSPEC_ADDRESS_P (x))
+    return UNSPEC_ADDRESS_TYPE (x);
+
+  return mips_classify_symbol (x);
+}
 
 /* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points
    to the same object as SYMBOL, or to the same object_block.  */
@@ -1529,8 +1543,17 @@ mips_classify_address (struct mips_address_info *info, rtx x,
       info->type = ADDRESS_LO_SUM;
       info->reg = XEXP (x, 0);
       info->offset = XEXP (x, 1);
+      /* We have to trust the creator of the LO_SUM to do something vaguely
+        sane.  Target-independent code that creates a LO_SUM should also
+        create and verify the matching HIGH.  Target-independent code that
+        adds an offset to a LO_SUM must prove that the offset will not
+        induce a carry.  Failure to do either of these things would be
+        a bug, and we are not required to check for it here.  The MIPS
+        backend itself should only create LO_SUMs for valid symbolic
+        constants, with the high part being either a HIGH or a copy
+        of _gp. */
+      info->symbol_type = mips_classify_symbolic_expression (info->offset);
       return (mips_valid_base_register_p (info->reg, mode, strict)
-             && mips_symbolic_constant_p (info->offset, &info->symbol_type)
              && mips_symbolic_address_p (info->symbol_type, mode)
              && mips_lo_relocs[info->symbol_type] != 0);
 
@@ -5666,7 +5689,8 @@ print_operand_reloc (FILE *file, rtx op, const char **relocs)
   rtx base;
   HOST_WIDE_INT offset;
 
-  if (!mips_symbolic_constant_p (op, &symbol_type) || relocs[symbol_type] == 0)
+  symbol_type = mips_classify_symbolic_expression (op);
+  if (relocs[symbol_type] == 0)
     fatal_insn ("PRINT_OPERAND, invalid operand for relocation", op);
 
   /* If OP uses an UNSPEC address, we want to print the inner symbol.  */
index 93adf99bb5564cf5d1384097b845728a90c630e4..22977f9fb210644d990b65f1ff8f414c1167fef1 100644 (file)
@@ -1,3 +1,11 @@
+2007-09-06  David Daney  <ddaney@avtrex.com>
+           Richard Sandiford  <richard@codesourcery.com>
+
+       PR target/33256
+       * gcc.target/mips/mips.exp (setup_mips_tests): Set mips_forced_le.
+       (dg-mips-options): Skip -EB and -meb tests when $mips_forced_le.
+       * gcc.target/mips/pr33256.c: New test.
+
 2007-09-05  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/33210
index 96b2c216193d363d52da7901b27acef496bc57d9..889fac9952abc1fe3b6ccf1d70211b87d2e97a16 100644 (file)
@@ -37,6 +37,7 @@ load_lib gcc-dg.exp
 #    $mips_forced_isa:  true if the command line uses -march=* or -mips*
 #    $mips_forced_abi:  true if the command line uses -mabi=* or -mgp*
 #    $mips_forced_float: true if the command line uses -mhard/soft-float
+#    $mips_forced_le    true if the command line uses -EL or -mel
 proc setup_mips_tests {} {
     global mips_isa
     global mips_arch
@@ -47,6 +48,7 @@ proc setup_mips_tests {} {
     global mips_forced_isa
     global mips_forced_abi
     global mips_forced_float
+    global mips_forced_le
 
     global compiler_flags
     global tool
@@ -81,6 +83,7 @@ proc setup_mips_tests {} {
     set mips_forced_isa [regexp -- {(-mips|-march)} $compiler_flags]
     set mips_forced_abi [regexp -- {(-mgp|-mabi)} $compiler_flags]
     set mips_forced_float [regexp -- {-m(hard|soft)-float} $compiler_flags]
+    set mips_forced_le [regexp -- {-(EL|mel)[[:>:]]} $compiler_flags]
 }
 
 # Return true if command-line option FLAG forces 32-bit code.
@@ -116,6 +119,10 @@ proc is_gp32_flag {flag} {
 #    -mhard-float
 #      Select the given floating-point mode.  Skip the test if the
 #      multilib flags force a different selection.
+#
+#    -EB
+#      Select big-endian code.  Skip the test if the multilib flags
+#      force a little-endian target.
 proc dg-mips-options {args} {
     upvar dg-extra-tool-flags extra_tool_flags
     upvar dg-do-what do_what
@@ -129,6 +136,7 @@ proc dg-mips-options {args} {
     global mips_forced_isa
     global mips_forced_abi
     global mips_forced_float
+    global mips_forced_le
 
     set flags [lindex $args 1]
     set matches 1
@@ -170,6 +178,10 @@ proc dg-mips-options {args} {
            if {$mips_float != $float && $mips_forced_float} {
                set matches 0
            }
+       } elseif {[regexp -- {^-(EB|meb)$} $flag]} {
+           if {$mips_forced_le} {
+               set matches 0
+           }
        }
     }
     if {$matches} {
diff --git a/gcc/testsuite/gcc.target/mips/pr33256.c b/gcc/testsuite/gcc.target/mips/pr33256.c
new file mode 100644 (file)
index 0000000..d5db110
--- /dev/null
@@ -0,0 +1,11 @@
+/* GCC used to report an ICE for this test because we generated a LO_SUM
+   for an illegitimate constant.  */
+/* { dg-mips-options "-mabi=64 -mips3 -msym32 -O2 -EB -mno-abicalls" } */
+extern unsigned long a[];
+int b (int);
+
+int
+c (void)
+{
+  return b (a[0]);
+}