+2006-02-09 J"orn Rennecke <joern.rennecke@st.com>
+
+ PR inline-asm/16194
+ * tree.h (decl_overlaps_hard_reg_set_p) Don't declare.
+ (tree_overlaps_hard_reg_set): Declare.
+ * stmt.c (decl_overlaps_hard_reg_set_p): Now static. Change return
+ type and signature to match function type expected by walk_tree.
+ (tree_overlaps_hard_reg_set): New function.
+ (decl_conflicts_with_clobbers_p): Rename to:
+ (tree_conflicts_with_clobbers_p). Take HARD_REG_SET * argument.
+ Use tree_overlaps_hard_reg_set. Changed caller.
+ * doc/tm.texi (TARGET_MD_ASM_CLOBBERS): Replace
+ decl_overlaps_hard_reg_set_p with tree_overlaps_hard_reg_set.
+ * cris.c (cris_md_asm_clobbers): Likewise.
+
2006-02-09 Bernd Schmidt <bernd.schmidt@analog.com>
* reload1.c (emit_input_reload_insns): Delete code that tries to
#define COST_TABLE(I) cost_table_[(unsigned HOST_WIDE_INT) ((I) + 1)]
\f
static int n_occurrences (int, const char *);
-static bool decl_conflicts_with_clobbers_p (tree, const HARD_REG_SET);
+static bool tree_conflicts_with_clobbers_p (tree, HARD_REG_SET *);
static void expand_nl_goto_receiver (void);
static bool check_operand_nalternatives (tree, tree);
static bool check_unique_operand_names (tree, tree);
return true;
}
-/* Return true iff there's an overlap between REGS and DECL, where DECL
- can be an asm-declared register. */
+/* Return DECL iff there's an overlap between *REGS and DECL, where DECL
+ can be an asm-declared register. Called via walk_tree. */
-bool
-decl_overlaps_hard_reg_set_p (tree decl, const HARD_REG_SET regs)
+static tree
+decl_overlaps_hard_reg_set_p (tree *declp, int *walk_subtrees ATTRIBUTE_UNUSED,
+ void *data)
{
- if ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
- && DECL_REGISTER (decl)
- && REG_P (DECL_RTL (decl))
- && REGNO (DECL_RTL (decl)) < FIRST_PSEUDO_REGISTER)
+ tree decl = *declp;
+ const HARD_REG_SET *regs = data;
+
+ if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
{
- rtx reg = DECL_RTL (decl);
- unsigned int regno;
-
- for (regno = REGNO (reg);
- regno < (REGNO (reg)
- + hard_regno_nregs[REGNO (reg)][GET_MODE (reg)]);
- regno++)
- if (TEST_HARD_REG_BIT (regs, regno))
- return true;
+ if (DECL_REGISTER (decl)
+ && REG_P (DECL_RTL (decl))
+ && REGNO (DECL_RTL (decl)) < FIRST_PSEUDO_REGISTER)
+ {
+ rtx reg = DECL_RTL (decl);
+ unsigned int regno;
+
+ for (regno = REGNO (reg);
+ regno < (REGNO (reg)
+ + hard_regno_nregs[REGNO (reg)][GET_MODE (reg)]);
+ regno++)
+ if (TEST_HARD_REG_BIT (*regs, regno))
+ return decl;
+ }
+ walk_subtrees = 0;
}
-
- return false;
+ else if (TYPE_P (decl))
+ walk_subtrees = 0;
+ return NULL_TREE;
}
+/* If there is an overlap between *REGS and DECL, return the first overlap
+ found. */
+tree
+tree_overlaps_hard_reg_set (tree decl, HARD_REG_SET *regs)
+{
+ return walk_tree (&decl, decl_overlaps_hard_reg_set_p, regs, NULL);
+}
/* Check for overlap between registers marked in CLOBBERED_REGS and
- anything inappropriate in DECL. Emit error and return TRUE for error,
- FALSE for ok. */
+ anything inappropriate in T. Emit error and return the register
+ variable definition for error, NULL_TREE for ok. */
static bool
-decl_conflicts_with_clobbers_p (tree decl, const HARD_REG_SET clobbered_regs)
+tree_conflicts_with_clobbers_p (tree t, HARD_REG_SET *clobbered_regs)
{
/* Conflicts between asm-declared register variables and the clobber
list are not allowed. */
- if (decl_overlaps_hard_reg_set_p (decl, clobbered_regs))
+ tree overlap = tree_overlaps_hard_reg_set (t, clobbered_regs);
+
+ if (overlap)
{
error ("asm-specifier for variable %qs conflicts with asm clobber list",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
+ IDENTIFIER_POINTER (DECL_NAME (overlap)));
/* Reset registerness to stop multiple errors emitted for a single
variable. */
- DECL_REGISTER (decl) = 0;
+ DECL_REGISTER (overlap) = 0;
return true;
}
inout_opnum[ninout++] = i;
}
- if (decl_conflicts_with_clobbers_p (val, clobbered_regs))
+ if (tree_conflicts_with_clobbers_p (val, &clobbered_regs))
clobber_conflict_found = 1;
}
= gen_rtx_ASM_INPUT (TYPE_MODE (type),
ggc_strdup (constraints[i + noutputs]));
- if (decl_conflicts_with_clobbers_p (val, clobbered_regs))
+ if (tree_conflicts_with_clobbers_p (val, &clobbered_regs))
clobber_conflict_found = 1;
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-bogus "internal compiler error" "ICE" { target *-*-* } 0 } */
+
+#define ASMDECL __asm (REG);
+#define CLOBBER_LIST : REG
+#define INP_CLOBBER_LIST : CLOBBER_LIST
+#if defined (__alpha__)
+# define REG "$1"
+#elif defined (__CRIS__) || defined (__sh__)
+# define REG "r10"
+#elif defined (__i386__)
+# define REG "%eax"
+#elif defined (__MMIX__)
+# define REG "$8"
+#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
+ || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
+# define REG "6"
+#elif defined (__x86_64__)
+# define REG "rax"
+#else
+ /* Make this test harmless for any target not recognized above. */
+# undef ASMDECL
+# define ASMDECL
+# define REG "conflict"
+# undef CLOBBER_LIST
+# define CLOBBER_LIST
+# undef INP_CLOBBER_LIST
+# define INP_CLOBBER_LIST
+#endif
+
+struct A
+{
+ int a;
+};
+
+struct B
+{
+ struct A b[3];
+};
+
+struct C
+{
+ struct B c;
+};
+
+void bug (void)
+{
+ register char* dst ASMDECL;
+ __asm__ ("":"=g"(*dst): : REG); /* { dg-error "conflict" } */
+}
+
+/* The tree optimizers currently prevent us from finding an overlap -
+ we end up using a copy of dst rather than dst.
+ But at least make sure we don't get an ICE. */
+void bug2 (void)
+{
+ register char* dst ASMDECL;
+ __asm__ ("": :"g"(*dst) CLOBBER_LIST);
+}
+
+void
+foo (void)
+{
+ register struct C *dst ASMDECL;
+ __asm__ ("" : "=g"(dst->c.b[1].a) INP_CLOBBER_LIST);
+}