(add_c_tree_codes): Register it.
* c-common.h: Declare it.
* tree.c (lang_unsafe_for_reeval): New hook.
(unsafe_for_reeval): Call it.
* tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37623
138bc75d-0d04-0410-961f-
82ee72b054a4
2000-11-21 Richard Henderson <rth@redhat.com>
+ * c-common.c (c_unsafe_for_reeval): New function.
+ (add_c_tree_codes): Register it.
+ * c-common.h: Declare it.
+ * tree.c (lang_unsafe_for_reeval): New hook.
+ (unsafe_for_reeval): Call it.
+ * tree.h: Declare it.
+
+2000-11-21 Richard Henderson <rth@redhat.com>
+
* config/i386/i386.c (i386_simplify_dwarf_addr): Simplify @GOT
references as well.
return 1;
}
+/* Hook used by unsafe_for_reeval to handle language-specific tree codes. */
+
+int
+c_unsafe_for_reeval (exp)
+ tree exp;
+{
+ /* Statement expressions may not be reevaluated. */
+ if (TREE_CODE (exp) == STMT_EXPR)
+ return 2;
+
+ /* Walk all other expressions. */
+ return -1;
+}
+
/* Tree code classes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
c_tree_code_name,
(LAST_C_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
+ lang_unsafe_for_reeval = c_unsafe_for_reeval;
}
#define CALLED_AS_BUILT_IN(NODE) \
enum expand_modifier));
extern int c_safe_from_p PARAMS ((rtx, tree));
-
#endif
+extern int c_unsafe_for_reeval PARAMS ((tree));
+
/* In dump.c */
typedef struct dump_info *dump_info_p;
void (*lang_unsave) PARAMS ((tree *));
void (*lang_unsave_expr_now) PARAMS ((tree));
+/* If non-null, these are language-specific helper functions for
+ unsafe_for_reeval. Return negative to not handle some tree. */
+int (*lang_unsafe_for_reeval) PARAMS ((tree));
\f
tree global_trees[TI_MAX];
tree integer_types[itk_none];
break;
default:
- /* ??? Add a lang hook if it becomes necessary. */
+ if (lang_unsafe_for_reeval != 0)
+ {
+ tmp = (*lang_unsafe_for_reeval) (expr);
+ if (tmp >= 0)
+ return tmp;
+ }
break;
}
/* Return 0 if it is safe to evaluate EXPR multiple times,
return 1 if it is safe if EXPR is unsaved afterward, or
return 2 if it is completely unsafe. */
-extern int unsafe_for_reeval PARAMS ((tree));
+extern int unsafe_for_reeval PARAMS ((tree));
+
+/* If non-null, these are language-specific helper functions for
+ unsafe_for_reeval. Return negative to not handle some tree. */
+extern int (*lang_unsafe_for_reeval) PARAMS ((tree));
/* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size
or offset that depends on a field within a record.