]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR inline-asm/39058 (ICE with double in inline-asm)
authorUros Bizjak <ubizjak@gmail.com>
Thu, 26 Feb 2009 07:06:48 +0000 (08:06 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 26 Feb 2009 07:06:48 +0000 (08:06 +0100)
Backport from mainline:
2009-02-02  Jakub Jelinek  <jakub@redhat.com>

PR inline-asm/39058
* recog.h (asm_operand_ok): Add constraints argument.
* recog.c (asm_operand_ok): Likewise.  If it is set, for digits
recurse on matching constraint.
(check_asm_operands): Pass constraints as 3rd argument to
asm_operand_ok.  Don't look up matching constraint here.
* stmt.c (expand_asm_operands): Pass NULL as 3rd argument
to asm_operand_ok.

testsuite/ChangeLog:

Backport from mainline:
2009-02-02  Jakub Jelinek  <jakub@redhat.com>

PR inline-asm/39058
* gcc.target/i386/pr39058.c: New test.

From-SVN: r144445

gcc/ChangeLog
gcc/recog.c
gcc/recog.h
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr39058.c [new file with mode: 0644]

index 0f5e583b6b198daef8678a57de896dd7bdfd9392..9a0a119505ffa83ebd12819e519e5906cd148150 100644 (file)
@@ -1,3 +1,17 @@
+2009-02-26  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline:
+       2009-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR inline-asm/39058
+       * recog.h (asm_operand_ok): Add constraints argument.
+       * recog.c (asm_operand_ok): Likewise.  If it is set, for digits
+       recurse on matching constraint.
+       (check_asm_operands): Pass constraints as 3rd argument to
+       asm_operand_ok.  Don't look up matching constraint here.
+       * stmt.c (expand_asm_operands): Pass NULL as 3rd argument
+       to asm_operand_ok.
+
 2009-02-25  Janis Johnson  <janis187@us.ibm.com>
 
        Backport from mainline:
index b0f125e8aa646e80015b6c2c2cf18563b9ff1d9c..34ce6b7431b2de24fc30c4215123dc247140fd11 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used by or related to instruction recognition.
    Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -147,10 +147,7 @@ check_asm_operands (rtx x)
       const char *c = constraints[i];
       if (c[0] == '%')
        c++;
-      if (ISDIGIT ((unsigned char) c[0]) && c[1] == '\0')
-       c = constraints[c[0] - '0'];
-
-      if (! asm_operand_ok (operands[i], c))
+      if (! asm_operand_ok (operands[i], c, constraints))
        return 0;
     }
 
@@ -1506,7 +1503,7 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
    Return > 0 if ok, = 0 if bad, < 0 if inconclusive.  */
 
 int
-asm_operand_ok (rtx op, const char *constraint)
+asm_operand_ok (rtx op, const char *constraint, const char **constraints)
 {
   int result = 0;
 
@@ -1534,15 +1531,29 @@ asm_operand_ok (rtx op, const char *constraint)
 
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
-         /* For best results, our caller should have given us the
-            proper matching constraint, but we can't actually fail
-            the check if they didn't.  Indicate that results are
-            inconclusive.  */
-         do
-           constraint++;
-         while (ISDIGIT (*constraint));
-         if (! result)
-           result = -1;
+         /* If caller provided constraints pointer, look up
+            the maching constraint.  Otherwise, our caller should have
+            given us the proper matching constraint, but we can't
+            actually fail the check if they didn't.  Indicate that
+            results are inconclusive.  */
+         if (constraints)
+           {
+             char *end;
+             unsigned long match;
+
+             match = strtoul (constraint, &end, 10);
+             if (!result)
+               result = asm_operand_ok (op, constraints[match], NULL);
+             constraint = (const char *) end;
+           }
+         else
+           {
+             do
+               constraint++;
+             while (ISDIGIT (*constraint));
+             if (! result)
+               result = -1;
+           }
          continue;
 
        case 'p':
index cdc438c88929126eef58864f67a385b9526adfd4..cdd6875acf37d79b9034e53b3fea55913e120d30 100644 (file)
@@ -1,6 +1,6 @@
 /* Declarations for interface to insn recognizer and insn-output.c.
    Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
-   2005, 2006, 2007 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -71,7 +71,7 @@ struct operand_alternative
 extern void init_recog (void);
 extern void init_recog_no_volatile (void);
 extern int check_asm_operands (rtx);
-extern int asm_operand_ok (rtx, const char *);
+extern int asm_operand_ok (rtx, const char *, const char **);
 extern bool validate_change (rtx, rtx *, rtx, bool);
 extern bool validate_unshare_change (rtx, rtx *, rtx, bool);
 extern bool canonicalize_change_group (rtx insn, rtx x);
index e0b167006bd975cc3690fff6bab6079d1c24cb68..2b7c0170c0abbf301fa95b61ab890945aebe2243 100644 (file)
@@ -1,6 +1,6 @@
 /* Expands front end tree to back end RTL for GCC
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -895,7 +895,7 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
       else if (MEM_P (op))
        op = validize_mem (op);
 
-      if (asm_operand_ok (op, constraint) <= 0)
+      if (asm_operand_ok (op, constraint, NULL) <= 0)
        {
          if (allows_reg && TYPE_MODE (type) != BLKmode)
            op = force_reg (TYPE_MODE (type), op);
index 68a7e295ec17445eed137a30e75c64456b1f460b..ba0e60699ea1488c7f3c2db7a8b683b8ae2649f8 100644 (file)
@@ -1,3 +1,11 @@
+2009-02-26  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline:
+       2009-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR inline-asm/39058
+       * gcc.target/i386/pr39058.c: New test.
+
 2009-02-25  Janis Johnson  <janis187@us.ibm.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gcc.target/i386/pr39058.c b/gcc/testsuite/gcc.target/i386/pr39058.c
new file mode 100644 (file)
index 0000000..2982e8d
--- /dev/null
@@ -0,0 +1,34 @@
+/* PR inline-asm/39058 */
+/* { dg-options "-O2" } */
+
+double
+f1 ()
+{
+  double x;
+  asm ("" : "=r,r" (x) : "0,0" (x));
+  return x;
+}
+
+double
+f2 ()
+{
+  double x;
+  asm ("" : "=r" (x) : "0" (x));
+  return x;
+}
+
+double
+f3 ()
+{
+  double x, y;
+  asm ("" : "=r,r" (x), "=r,r" (y) : "%0,0" (x), "r,r" (0));
+  return x;
+}
+
+double
+f4 ()
+{
+  double x, y;
+  asm ("" : "=r" (x), "=r" (y) : "0" (x), "r" (0));
+  return x;
+}