]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR inline-asm/8832 (traditional "asm volatile" code is illegally optimized)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Thu, 9 Jan 2003 13:18:46 +0000 (14:18 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 9 Jan 2003 13:18:46 +0000 (13:18 +0000)
PR inline-asm/8832
* tree.h (expand_asm): New prototype.
* stmt.c (expand_asm): Set the MEM_VOLATILE_P flag if instructed
to do so.
* c-semantics (genrtl_asm_stmt): Pass the RID_VOLATILE qualifier
down to expand_asm.
* c-typeck.c (simple_asm_stmt): Set the RID_VOLATILE qualifier.
* rtlanal.c (volatile_insn_p) [ASM_INPUT]: Test the MEM_VOLATILE_P flag.
(volatile_refs_p) [ASM_INPUT]: Likewise.
(side_effects_p) [ASM_INPUT]: Likewise.

From-SVN: r61108

gcc/ChangeLog
gcc/c-semantics.c
gcc/c-typeck.c
gcc/rtlanal.c
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/tree.h

index 3986de367df569e28300f5fe3ba4fbe7f76f8481..9a864f55bade3abc49424054185e94dcb78c1a16 100644 (file)
@@ -1,3 +1,16 @@
+2003-01-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR inline-asm/8832
+       * tree.h (expand_asm): New prototype.
+       * stmt.c (expand_asm): Set the MEM_VOLATILE_P flag if instructed
+       to do so.
+       * c-semantics (genrtl_asm_stmt): Pass the RID_VOLATILE qualifier
+       down to expand_asm.
+       * c-typeck.c (simple_asm_stmt): Set the RID_VOLATILE qualifier.
+       * rtlanal.c (volatile_insn_p) [ASM_INPUT]: Test the MEM_VOLATILE_P flag.
+       (volatile_refs_p) [ASM_INPUT]: Likewise.
+       (side_effects_p) [ASM_INPUT]: Likewise.
+
 2003-01-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR c/8032
index 35f7df39a826bf943febb66f479640067bbf0c21..eaa4452bb09954459516d88590f40abc517f30a4 100644 (file)
@@ -728,7 +728,7 @@ genrtl_asm_stmt (cv_qualifier, string, output_operands,
 
   emit_line_note (input_filename, lineno);
   if (asm_input_p)
-    expand_asm (string);
+    expand_asm (string, cv_qualifier != NULL_TREE);
   else
     c_expand_asm_operands (string, output_operands, input_operands, 
                           clobbers, cv_qualifier != NULL_TREE,
index fda2710acd4903e1f506d3744166d0bea81dcf8f..17e314489ea7b02c373428caa40314d7b5ed84e2 100644 (file)
@@ -6891,9 +6891,10 @@ simple_asm_stmt (expr)
 
       if (TREE_CHAIN (expr))
        expr = combine_strings (expr);
-      stmt = add_stmt (build_stmt (ASM_STMT, NULL_TREE, expr,
-                                  NULL_TREE, NULL_TREE,
-                                  NULL_TREE));
+
+      /* Simple asm statements are treated as volatile.  */
+      stmt = add_stmt (build_stmt (ASM_STMT, ridpointers[(int) RID_VOLATILE],
+                                  expr, NULL_TREE, NULL_TREE, NULL_TREE));
       ASM_INPUT_P (stmt) = 1;
       return stmt;
     }
index d6efc744ece081af241a01c167395592874550ed..23805999da34a1bae4255dba0971e7d964a2fece 100644 (file)
@@ -2054,7 +2054,6 @@ volatile_insn_p (x)
     case REG:
     case SCRATCH:
     case CLOBBER:
-    case ASM_INPUT:
     case ADDR_VEC:
     case ADDR_DIFF_VEC:
     case CALL:
@@ -2065,6 +2064,7 @@ volatile_insn_p (x)
  /* case TRAP_IF: This isn't clear yet.  */
       return 1;
 
+    case ASM_INPUT:
     case ASM_OPERANDS:
       if (MEM_VOLATILE_P (x))
        return 1;
@@ -2121,7 +2121,6 @@ volatile_refs_p (x)
     case REG:
     case SCRATCH:
     case CLOBBER:
-    case ASM_INPUT:
     case ADDR_VEC:
     case ADDR_DIFF_VEC:
       return 0;
@@ -2132,6 +2131,7 @@ volatile_refs_p (x)
       return 1;
 
     case MEM:
+    case ASM_INPUT:
     case ASM_OPERANDS:
       if (MEM_VOLATILE_P (x))
        return 1;
@@ -2187,7 +2187,6 @@ side_effects_p (x)
     case PC:
     case REG:
     case SCRATCH:
-    case ASM_INPUT:
     case ADDR_VEC:
     case ADDR_DIFF_VEC:
       return 0;
@@ -2210,6 +2209,7 @@ side_effects_p (x)
       return 1;
 
     case MEM:
+    case ASM_INPUT:
     case ASM_OPERANDS:
       if (MEM_VOLATILE_P (x))
        return 1;
index 4ba30217e9c47e5eacdde55079a30b3c6369ff2b..05705e7e6315186e5891c92eae27917c8eb744e2 100644 (file)
@@ -1281,18 +1281,25 @@ n_occurrences (c, s)
 }
 \f
 /* Generate RTL for an asm statement (explicit assembler code).
-   BODY is a STRING_CST node containing the assembler code text,
-   or an ADDR_EXPR containing a STRING_CST.  */
-
+   STRING is a STRING_CST node containing the assembler code text,
+   or an ADDR_EXPR containing a STRING_CST.  VOL nonzero means the
+   insn is volatile; don't optimize it.  */
 void
-expand_asm (body)
-     tree body;
+expand_asm (string, vol)
+     tree string;
+     int vol;
 {
-  if (TREE_CODE (body) == ADDR_EXPR)
-    body = TREE_OPERAND (body, 0);
+  rtx body;
+
+  if (TREE_CODE (string) == ADDR_EXPR)
+    string = TREE_OPERAND (string, 0);
+
+  body = gen_rtx_ASM_INPUT (VOIDmode, TREE_STRING_POINTER (string));
+
+  MEM_VOLATILE_P (body) = vol;
+
+  emit_insn (body);
 
-  emit_insn (gen_rtx_ASM_INPUT (VOIDmode,
-                               TREE_STRING_POINTER (body)));
   last_expr_type = 0;
 }
 
index 8eaec5b9e98942a652afd01248244f0ed1f235c6..75e056fa8ec3915000a090ecd1cbaaa8981fcff1 100644 (file)
@@ -1,3 +1,7 @@
+2003-01-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/old-style-asm-1.c: New test.
+
 2003-01-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.c-torture/execute/20030109-1.c: New test.
index c59c53e75fe549f24b55579e432cded9b793fe29..4a05eff216bbae658e39e0b5f20201d49b03af7d 100644 (file)
@@ -2793,7 +2793,7 @@ extern void expand_decl_init                      PARAMS ((tree));
 extern void clear_last_expr                    PARAMS ((void));
 extern void expand_label                       PARAMS ((tree));
 extern void expand_goto                                PARAMS ((tree));
-extern void expand_asm                         PARAMS ((tree));
+extern void expand_asm                         PARAMS ((tree, int));
 extern void expand_start_cond                  PARAMS ((tree, int));
 extern void expand_end_cond                    PARAMS ((void));
 extern void expand_start_else                  PARAMS ((void));