aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@bitmover.com>1999-08-19 22:33:38 +0000
committerZack Weinberg <zack@gcc.gnu.org>1999-08-19 22:33:38 +0000
commit8f985ec4c7de63e524197f1728a2c056f9af6554 (patch)
tree7d2c04e895a06940acfa67236fcbdb23966207b9 /gcc/tree.h
parent02af3af6514c82ca3bc75aa75b2774073f0ce602 (diff)
downloadgcc-8f985ec4c7de63e524197f1728a2c056f9af6554.zip
gcc-8f985ec4c7de63e524197f1728a2c056f9af6554.tar.gz
gcc-8f985ec4c7de63e524197f1728a2c056f9af6554.tar.bz2
rtl.def (NOTE): Change format to "iuu0n".
1999-08-19 14:44 -0700 Zack Weinberg <zack@bitmover.com> * rtl.def (NOTE): Change format to "iuu0n". (ADDR_DIFF_VEC): Change format to "eEee0". (ADDRESSOF): Change format to "eit". * rtl.h (rtvec): Make "elem" an array of rtx, not rtunion. (RTVEC_ELT): Change to match. (XVECEXP): Use XVEC and RTVEC_ELT. (INSN_UID, INSN_CODE, CODE_LABEL_NUMBER, NOTE_LINE_NUMBER, ADDRESSOF_REGNO, REGNO, SUBREG_WORD): Use XINT. (PREV_INSN, NEXT_INSN, PATTERN, REG_NOTES, CALL_INSN_FUNCTION_USAGE, SUBREG_REG, SET_SRC, SET_DEST, TRAP_CONDITION, TRAP_CODE): Use XEXP. (INTVAL): Use XWINT. (ADDRESSOF_DECL): Use XTREE. (SET_ADDRESSOF_DECL): Delete. (NOTE_DECL_NAME, NOTE_DECL_CODE, NOTE_DECL_RTL, NOTE_DECL_IDENTIFIER, NOTE_DECL_TYPE): Kill. These have been ifdefed out since 2.6 at least. (gen_rtvec_vv): Delete prototype. * rtl.h (rtvec_alloc): rt->elem is now an array of rtx, not rtunion. (copy_most_rtx): Handle 't' format letter. * emit-rtl.c (gen_rtvec_v): rt_val->elem is an array of rtx. (gen_rtvec_vv): Delete function. All callers changed to use gen_rtvec_v instead. * print-rtl.c (print_rtx): Move special casing of NOTEs to the '0' format letter. * function.c (gen_mem_addressof): Don't use SET_ADDRESSOF_DECL; provide `decl' to gen_rtx_ADDRESSOF instead. * integrate.c (copy_rtx_and_substitute): Likewise. Copy 't' slots with XTREE. (subst_constants): Treat 't' slots like '[swi]' slots. * cse.c (canon_hash, exp_equiv_p): Treat 't' slots like '0' slots. * jump.c (rtx_equal_for_thread_p): Likewise. * rtlanal.c (rtx_equal_p): Likewise. * stmt.c (expand_end_case): gen_rtx_ADDR_DIFF_VEC now takes only four arguments. * gengenrtl.c (type_from_format): Provide correct types for 'b' and 't' slots. * tree.h [ENABLE_CHECKING] (TREE_CHECK, TREE_CLASS_CHECK): If a recent gcc is in use (always in stage2 and beyond), use statement expressions, so we don't make a function call unless the check fails. Evaluate arguments exactly once. (CHAIN_CHECK, DO_CHECK, DO_CHECK1, TREE_CHECK1, TREE_CLASS_CHECK1, TYPE_CHECK1, DECL_CHECK1, CST_CHECK1): Delete. (CST_OR_CONSTRUCTOR_CHECK, EXPR_CHECK): Redefine such that they evaluate their arguments exactly once, irrespective of the compiler in use. * tree.c [ENABLE_CHECKING]: Define whichever set of functions is used by the currently-enabled check macros. This is: (tree_check_failed, tree_class_check_failed): For gcc. (tree_check, tree_class_check, cst_or_constructor_check, expr_check): For other compilers. * gencheck.c: Do not define any *_CHECK1 macros. From-SVN: r28769
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h104
1 files changed, 72 insertions, 32 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index 08d4570..3777d0e 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -311,38 +311,84 @@ struct tree_common
#define TREE_SET_CODE(NODE, VALUE) ((NODE)->common.code = (int) (VALUE))
/* When checking is enabled, errors will be generated if a tree node
- is accessed incorrectly. The macros abort with a fatal error,
- except for the *1 variants, which just return 0 on failure. The
- latter variants should only be used for combination checks, which
- succeed when one of the checks succeed. The CHAIN_CHECK macro helps
- defining such checks. */
+ is accessed incorrectly. The macros abort with a fatal error. */
#ifdef ENABLE_CHECKING
-#define DO_CHECK(FUNC, t, param) FUNC (t, param, __FILE__, __LINE__, 0)
-#define DO_CHECK1(FUNC, t, param) FUNC (t, param, __FILE__, __LINE__, 1)
-#define CHAIN_CHECK(t, c1, c2) (c1 (t) ? t : c2 (t))
-#else
-#define DO_CHECK(FUNC, t, param) (t)
-#define DO_CHECK1(FUNC, t, param) (t)
-#define CHAIN_CHECK(t, c1, c2) (t)
-#endif
-#define TREE_CHECK(t, code) DO_CHECK (tree_check, t, code)
-#define TREE_CHECK1(t, code) DO_CHECK1 (tree_check, t, code)
+#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC_MINOR__ > 6)
+/* This optimization can only be done in stage2/3, because it
+ uses statement expressions. You might think that you could use
+ conditional (?:) expressions, but you would be wrong: these macros
+ need to evaluate `t' only once. */
+#define TREE_CHECK(t, code) \
+({ const tree __t = t; \
+ if (TREE_CODE(__t) != (code)) \
+ tree_check_failed (__t, code, __FILE__, \
+ __LINE__, __PRETTY_FUNCTION__); \
+ __t; })
+#define TREE_CLASS_CHECK(t, class) \
+({ const tree __t = t; \
+ if (TREE_CODE_CLASS(TREE_CODE(__t)) != (class)) \
+ tree_class_check_failed (__t, class, __FILE__, \
+ __LINE__, __PRETTY_FUNCTION__); \
+ __t; })
+
+/* These checks have to be special cased. */
+#define CST_OR_CONSTRUCTOR_CHECK(t) \
+({ const tree __t = t; \
+ enum tree_code __c = TREE_CODE(__t); \
+ if (__c != CONSTRUCTOR && TREE_CODE_CLASS(__c) != 'c') \
+ tree_check_failed (__t, CONSTRUCTOR, __FILE__, \
+ __LINE__, __PRETTY_FUNCTION__); \
+ __t; })
+#define EXPR_CHECK(t) \
+({ const tree __t = t; \
+ char __c = TREE_CODE_CLASS(TREE_CODE(__t)); \
+ if (__c != 'r' && __c != 's' && __c != '<' \
+ && __c != '1' && __c != '2' && __c != 'e') \
+ tree_class_check_failed(__t, 'e', __FILE__, \
+ __LINE__, __PRETTY_FUNCTION__); \
+ __t; })
+
+extern void tree_check_failed PROTO((const tree, enum tree_code,
+ const char *, int, const char *))
+ ATTRIBUTE_NORETURN;
+extern void tree_class_check_failed PROTO((const tree, char,
+ const char *, int, const char *))
+ ATTRIBUTE_NORETURN;
+
+#else /* not gcc or old gcc */
+
+#define TREE_CHECK(t, code) \
+ tree_check (t, code, __FILE__, __LINE__)
+#define TREE_CLASS_CHECK(t, code) \
+ tree_class_check (t, code, __FILE__, __LINE__)
+#define CST_OR_CONSTRUCTOR_CHECK(t) \
+ cst_or_constructor_check (t, __FILE__, __LINE__)
+#define EXPR_CHECK(t) \
+ expr_check (t, __FILE__, __LINE__)
+
+extern tree tree_check PROTO((const tree, enum tree_code, const char *, int));
+extern tree tree_class_check PROTO((const tree, char, const char *, int));
+extern tree cst_or_constructor_check PROTO((const tree, const char *, int));
+extern tree expr_check PROTO((const tree, enum tree_code, const char *, int));
-#include "tree-check.h"
+#endif /* not gcc or old gcc */
-#define TYPE_CHECK(tree) DO_CHECK (tree_class_check, tree, 't')
-#define TYPE_CHECK1(tree) DO_CHECK1 (tree_class_check, tree, 't')
-#define DECL_CHECK(t) DO_CHECK (tree_class_check, t, 'd')
-#define DECL_CHECK1(t) DO_CHECK1 (tree_class_check, t, 'd')
-#define CST_CHECK(t) DO_CHECK (tree_class_check, t, 'c')
-#define CST_CHECK1(t) DO_CHECK1 (tree_class_check, t, 'c')
-#define EXPR_CHECK(t) DO_CHECK (expr_check, t, 0)
+#else /* not ENABLE_CHECKING */
-/* Chained checks. The last check has to succeed, the others may fail. */
-#define CST_OR_CONSTRUCTOR_CHECK(t) \
- CHAIN_CHECK (t, CST_CHECK1, CONSTRUCTOR_CHECK)
+#define TREE_CHECK(t, code) (t)
+#define TREE_CLASS_CHECK(t, code) (t)
+#define CST_OR_CONSTRUCTOR_CHECK(t) (t)
+#define EXPR_CHECK(t) (t)
+
+#endif
+
+#include "tree-check.h"
+
+#define TYPE_CHECK(tree) TREE_CLASS_CHECK (tree, 't')
+#define DECL_CHECK(tree) TREE_CLASS_CHECK (tree, 'd')
+#define CST_CHECK(tree) TREE_CLASS_CHECK (tree, 'c')
/* In all nodes that are expressions, this is the data type of the expression.
In POINTER_TYPE nodes, this is the type that the pointer points to.
@@ -2198,12 +2244,6 @@ extern void start_identifier_warnings PROTO ((void));
extern void gcc_obstack_init PROTO ((struct obstack *));
extern void init_obstacks PROTO ((void));
extern void obfree PROTO ((char *));
-extern tree tree_check PROTO ((tree, enum tree_code,
- const char *, int, int));
-extern tree tree_class_check PROTO ((tree, char, const char *,
- int, int));
-extern tree expr_check PROTO ((tree, int, const char *,
- int, int));
/* In function.c */
extern void setjmp_protect_args PROTO ((void));