final.c (output_asm_insn): Make sure assembly dialects are terminated, not nested.
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Oct 2001 10:51:17 +0000 (12:51 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Oct 2001 10:51:17 +0000 (12:51 +0200)
* final.c (output_asm_insn): Make sure assembly dialects are
terminated, not nested.  Output `|' and `}' characters if they
don't appear inside assembly dialect selection.
* config/i386/i386.md (rep_movdi_rex64, rep_movsi, rep_movsi_rex64,
rep_movqi, rep_movqi_rex64, rep_stosdi_rex64, rep_stossi,
rep_stossi_rex64, rep_stosqi, rep_stosqi_rex64, strsetsi_1,
strsetsi_rex_1): Add {} braces.

* testsuite/gcc.dg/20011009-1.c: New test.

From-SVN: r46227

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/final.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20011009-1.c [new file with mode: 0644]

index 7d0706022f8cad8018e0e87e93d220dcc08f67af..82d84f68b86d02204a2c61b758bff0ea941609a0 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+       * final.c (output_asm_insn): Make sure assembly dialects are
+       terminated, not nested.  Output `|' and `}' characters if they
+       don't appear inside assembly dialect selection.
+       * config/i386/i386.md (rep_movdi_rex64, rep_movsi, rep_movsi_rex64,
+       rep_movqi, rep_movqi_rex64, rep_stosdi_rex64, rep_stossi,
+       rep_stossi_rex64, rep_stosqi, rep_stosqi_rex64, strsetsi_1,
+       strsetsi_rex_1): Add {} braces.
+
 2001-10-11  Zack Weinberg  <zack@codesourcery.com>
 
        * toplev.c (compile_file): Ignore return value from yyparse.
index 01a9be026e70ed6289e5ad0963810f3cb8528dd4..db143969dc6274c0dfc2babd8698a0f060873079 100644 (file)
    (use (match_dup 5))
    (use (reg:SI 19))]
   "TARGET_64BIT"
-  "rep\;movsq|rep movsq"
+  "{rep\;movsq|rep movsq}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "both")
    (use (match_dup 5))
    (use (reg:SI 19))]
   "!TARGET_64BIT"
-  "rep\;movsl|rep movsd"
+  "{rep\;movsl|rep movsd}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "both")
    (use (match_dup 5))
    (use (reg:SI 19))]
   "TARGET_64BIT"
-  "rep\;movsl|rep movsd"
+  "{rep\;movsl|rep movsd}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "both")
    (use (match_dup 5))
    (use (reg:SI 19))]
   "!TARGET_64BIT"
-  "rep\;movsb|rep movsb"
+  "{rep\;movsb|rep movsb}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "both")
    (use (match_dup 5))
    (use (reg:SI 19))]
   "TARGET_64BIT"
-  "rep\;movsb|rep movsb"
+  "{rep\;movsb|rep movsb}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "both")
                 (const_int 4)))
    (use (reg:SI 19))]
   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
-  "stosl|stosd"
+  "{stosl|stosd}"
   [(set_attr "type" "str")
    (set_attr "memory" "store")
    (set_attr "mode" "SI")])
                 (const_int 4)))
    (use (reg:SI 19))]
   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
-  "stosl|stosd"
+  "{stosl|stosd}"
   [(set_attr "type" "str")
    (set_attr "memory" "store")
    (set_attr "mode" "SI")])
    (use (match_dup 4))
    (use (reg:SI 19))]
   "TARGET_64BIT"
-  "rep\;stosq|rep stosq"
+  "{rep\;stosq|rep stosq}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "store")
    (use (match_dup 4))
    (use (reg:SI 19))]
   "!TARGET_64BIT"
-  "rep\;stosl|rep stosd"
+  "{rep\;stosl|rep stosd}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "store")
    (use (match_dup 4))
    (use (reg:SI 19))]
   "TARGET_64BIT"
-  "rep\;stosl|rep stosd"
+  "{rep\;stosl|rep stosd}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "store")
    (use (match_dup 4))
    (use (reg:SI 19))]
   "!TARGET_64BIT"
-  "rep\;stosb|rep stosb"
+  "{rep\;stosb|rep stosb}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "store")
    (use (match_dup 4))
    (use (reg:DI 19))]
   "TARGET_64BIT"
-  "rep\;stosb|rep stosb"
+  "{rep\;stosb|rep stosb}"
   [(set_attr "type" "str")
    (set_attr "prefix_rep" "1")
    (set_attr "memory" "store")
index 5884382b239172cd231960d6ce6e9e2cf7b18ea3..5d2d8d9ae69efa434c886ff2356f6299dc7c528b 100644 (file)
@@ -3313,6 +3313,9 @@ output_asm_insn (template, operands)
 {
   const char *p;
   int c;
+#ifdef ASSEMBLER_DIALECT
+  int dialect = 0;
+#endif
 
   /* An insn may return a null string template
      in a case where no assembler code is needed.  */
@@ -3347,6 +3350,11 @@ output_asm_insn (template, operands)
        {
          int i;
 
+         if (dialect)
+           output_operand_lossage ("nested assembly dialect alternatives");
+         else
+           dialect = 1;
+
          /* If we want the first dialect, do nothing.  Otherwise, skip
             DIALECT_NUMBER of strings ending with '|'.  */
          for (i = 0; i < dialect_number; i++)
@@ -3358,16 +3366,35 @@ output_asm_insn (template, operands)
              if (*p == '|')
                p++;
            }
+
+         if (*p == '\0')
+           output_operand_lossage ("unterminated assembly dialect alternative");
        }
        break;
 
       case '|':
-       /* Skip to close brace.  */
-       while (*p && *p++ != '}')
-         ;
+       if (dialect)
+         {
+           /* Skip to close brace.  */
+           do
+             {
+               if (*p == '\0')
+                 {
+                   output_operand_lossage ("unterminated assembly dialect alternative");
+                   break;
+                 }
+             }   
+           while (*p++ != '}');
+           dialect = 0;
+         }
+       else
+         putc (c, asm_out_file);
        break;
 
       case '}':
+       if (! dialect)
+         putc (c, asm_out_file);
+       dialect = 0;
        break;
 #endif
 
index 2a50b83736d857749498da7602d4ebf0b7276bc4..35f40e591793629dd8778a7268bcf3fe839eed76 100644 (file)
@@ -1,3 +1,7 @@
+2001-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+       * testsuite/gcc.dg/20011009-1.c: New test.
+
 2001-10-12  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR g++/4476
diff --git a/gcc/testsuite/gcc.dg/20011009-1.c b/gcc/testsuite/gcc.dg/20011009-1.c
new file mode 100644 (file)
index 0000000..dbf32e6
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run { target i?86-*-* } } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+extern void exit (int);
+
+int main ()
+{
+  int x;
+
+  asm ("movl $26, %0 # 26 |-> reg \n\t"
+       "movl $28, %0" : "=r" (x));
+  if (x != 28)
+    abort ();
+  exit (0);
+}