summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/c-semantics.c2
-rw-r--r--gcc/c-typeck.c6
-rw-r--r--gcc/rtlanal.c6
-rw-r--r--gcc/stmt.c24
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/old-style-asm-1.c19
-rw-r--r--gcc/tree.h2
8 files changed, 60 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4055fa12832..96ca06396ff 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
+
Thu Jan 9 12:00:36 CET 2003 Jan Hubicka <jh@suse.cz>
* i386.md (*mul*): FIx constraints; remove confused comment; fix
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index 77d7384f9a2..769c1165d4a 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -749,7 +749,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,
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index c5b4ecbf9d3..87703a73079 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -6853,9 +6853,9 @@ simple_asm_stmt (expr)
{
tree stmt;
- 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;
}
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 63d7feb6035..030682e43f9 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -2237,7 +2237,6 @@ volatile_insn_p (x)
case REG:
case SCRATCH:
case CLOBBER:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
case CALL:
@@ -2248,6 +2247,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;
@@ -2304,7 +2304,6 @@ volatile_refs_p (x)
case REG:
case SCRATCH:
case CLOBBER:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
return 0;
@@ -2313,6 +2312,7 @@ volatile_refs_p (x)
return 1;
case MEM:
+ case ASM_INPUT:
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
@@ -2368,7 +2368,6 @@ side_effects_p (x)
case PC:
case REG:
case SCRATCH:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
return 0;
@@ -2391,6 +2390,7 @@ side_effects_p (x)
return 1;
case MEM:
+ case ASM_INPUT:
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
diff --git a/gcc/stmt.c b/gcc/stmt.c
index fbdf463ee57..ac0aa15bef2 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1098,18 +1098,26 @@ n_occurrences (c, s)
}
/* 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 (gen_rtx_ASM_INPUT (VOIDmode,
- TREE_STRING_POINTER (body)));
+ emit_insn (body);
+
clear_last_expr ();
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f5d0134f2a1..8063cf3a40d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-01-09 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ gcc.dg/old-style-asm-1.c: New test.
+
2003-01-09 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/compile/20030109-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/old-style-asm-1.c b/gcc/testsuite/gcc.dg/old-style-asm-1.c
new file mode 100644
index 00000000000..006cf0949b0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/old-style-asm-1.c
@@ -0,0 +1,19 @@
+/* PR inline-asm/8832 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Verify that GCC doesn't optimize
+ old style asm instructions. */
+
+void foo(int v)
+{
+ if (v)
+ asm ("dummy1");
+
+ asm ("dummy2");
+
+ if (v)
+ asm ("dummy3");
+}
+
+/* { dg-final { scan-assembler "L2" } } */
diff --git a/gcc/tree.h b/gcc/tree.h
index 93a237f73f2..6075d83b87f 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2835,7 +2835,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));