+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
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,
{
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;
}
case REG:
case SCRATCH:
case CLOBBER:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
case CALL:
/* case TRAP_IF: This isn't clear yet. */
return 1;
+ case ASM_INPUT:
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
case REG:
case SCRATCH:
case CLOBBER:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
return 0;
return 1;
case MEM:
+ case ASM_INPUT:
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
case PC:
case REG:
case SCRATCH:
- case ASM_INPUT:
case ADDR_VEC:
case ADDR_DIFF_VEC:
return 0;
return 1;
case MEM:
+ case ASM_INPUT:
case ASM_OPERANDS:
if (MEM_VOLATILE_P (x))
return 1;
}
\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 (gen_rtx_ASM_INPUT (VOIDmode,
- TREE_STRING_POINTER (body)));
+ emit_insn (body);
+
clear_last_expr ();
}
+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.
--- /dev/null
+/* 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" } } */
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));