Minor cleanups on tree checking macros

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Mon Jun 16 19:02:00 GMT 2003


Tested on i686-pc-linux-gnu.

2003-06-16  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* tree.h (STMT_CHECK): New macro.
	Also upper-case argument names on all checking macros and
	fix some whitespace problems; assume CODE argument does not
	have side-effects.

*** tree.h	16 Jun 2003 14:58:03 -0000	1.411
--- tree.h	16 Jun 2003 18:08:33 -0000
*************** struct tree_common GTY(())
*** 275,303 ****
  #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
  
! #define TREE_CHECK(t, code) __extension__				\
! ({  const tree __t = (t);						\
!     if (TREE_CODE(__t) != (code))					\
!       tree_check_failed (__t, code, __FILE__, __LINE__, __FUNCTION__);	\
      __t; })
! #define TREE_CLASS_CHECK(t, class) __extension__			\
! ({  const tree __t = (t);						\
!     if (TREE_CODE_CLASS(TREE_CODE(__t)) != (class))			\
!       tree_class_check_failed (__t, class, __FILE__, __LINE__,		\
  			       __FUNCTION__);				\
      __t; })
  
  /* These checks have to be special cased.  */
! #define EXPR_CHECK(t) __extension__					\
! ({  const tree __t = (t);						\
!     char const __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__,		\
  			       __FUNCTION__);				\
      __t; })
  
! #define TREE_VEC_ELT_CHECK(t, i) __extension__				\
! (*({const tree __t = t;							\
!     const int __i = (i);						\
      if (TREE_CODE (__t) != TREE_VEC)					\
        tree_check_failed (__t, TREE_VEC,					\
--- 275,303 ----
  #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
  
! #define TREE_CHECK(T, CODE) __extension__				\
! ({  const tree __t = (T);						\
!     if (TREE_CODE (__t) != (CODE))					\
!       tree_check_failed (__t, (CODE), __FILE__, __LINE__, __FUNCTION__); \
      __t; })
! 
! #define TREE_CLASS_CHECK(T, CLASS) __extension__			\
! ({  const tree __t = (T);						\
!     if (TREE_CODE_CLASS (TREE_CODE(__t)) != (CLASS))			\
!       tree_class_check_failed (__t, (CLASS), __FILE__, __LINE__,	\
  			       __FUNCTION__);				\
      __t; })
  
  /* These checks have to be special cased.  */
! #define EXPR_CHECK(T) __extension__					\
! ({  const tree __t = (T);						\
!     char const __c = TREE_CODE_CLASS (TREE_CODE (__t));			\
!     if (!IS_EXPR_CODE_CLASS (__c) && __c != 'r' && __c != 's')		\
        tree_class_check_failed (__t, 'e', __FILE__, __LINE__,		\
  			       __FUNCTION__);				\
      __t; })
  
! #define TREE_VEC_ELT_CHECK(T, I) __extension__				\
! (*({const tree __t = (T);						\
!     const int __i = (I);						\
      if (TREE_CODE (__t) != TREE_VEC)					\
        tree_check_failed (__t, TREE_VEC,					\
*************** struct tree_common GTY(())
*** 309,315 ****
  
  /* Special checks for TREE_OPERANDs.  */
! #define TREE_OPERAND_CHECK(t, i) __extension__				\
! (*({const tree __t = EXPR_CHECK(t);					\
!     const int __i = (i);						\
      if (__i < 0 || __i >= TREE_CODE_LENGTH (TREE_CODE (__t)))		\
        tree_operand_check_failed (__i, TREE_CODE (__t),			\
--- 309,315 ----
  
  /* Special checks for TREE_OPERANDs.  */
! #define TREE_OPERAND_CHECK(T, I) __extension__				\
! (*({const tree __t = EXPR_CHECK(T);					\
!     const int __i = (I);						\
      if (__i < 0 || __i >= TREE_CODE_LENGTH (TREE_CODE (__t)))		\
        tree_operand_check_failed (__i, TREE_CODE (__t),			\
*************** struct tree_common GTY(())
*** 317,342 ****
      &__t->exp.operands[__i]; }))
  
! #define TREE_OPERAND_CHECK_CODE(t, code, i) __extension__		\
! (*({const tree __t = t;							\
!     const int __i = (i);						\
!     const enum tree_code __code = code;					\
!     if (TREE_CODE (__t) != __code)					\
!       tree_check_failed (__t, __code,					\
! 			 __FILE__, __LINE__, __FUNCTION__);		\
!     if (__i < 0 || __i >= TREE_CODE_LENGTH (__code))			\
!       tree_operand_check_failed (__i, __code,				\
  				 __FILE__, __LINE__, __FUNCTION__);	\
      &__t->exp.operands[__i]; }))
  
! #define TREE_RTL_OPERAND_CHECK(t, code, i) __extension__		\
  (*(rtx *)								\
!  ({const tree __t = t;							\
!     const int __i = (i);						\
!     const enum tree_code __code = code;					\
!     if (TREE_CODE (__t) != __code)					\
!       tree_check_failed (__t, __code,					\
! 			 __FILE__, __LINE__, __FUNCTION__);		\
!     if (__i < 0 || __i >= TREE_CODE_LENGTH (__code))			\
!       tree_operand_check_failed (__i, __code,				\
  				 __FILE__, __LINE__, __FUNCTION__);	\
      &__t->exp.operands[__i]; }))
--- 317,338 ----
      &__t->exp.operands[__i]; }))
  
! #define TREE_OPERAND_CHECK_CODE(T, CODE, I) __extension__		\
! (*({const tree __t = (T);						\
!     const int __i = (I);						\
!     if (TREE_CODE (__t) != CODE)					\
!       tree_check_failed (__t, CODE, __FILE__, __LINE__, __FUNCTION__);	\
!     if (__i < 0 || __i >= TREE_CODE_LENGTH (CODE))			\
!       tree_operand_check_failed (__i, (CODE),				\
  				 __FILE__, __LINE__, __FUNCTION__);	\
      &__t->exp.operands[__i]; }))
  
! #define TREE_RTL_OPERAND_CHECK(T, CODE, I) __extension__		\
  (*(rtx *)								\
!  ({const tree __t = (T);						\
!     const int __i = (I);						\
!     if (TREE_CODE (__t) != (CODE))					\
!       tree_check_failed (__t, (CODE), __FILE__, __LINE__, __FUNCTION__); \
!     if (__i < 0 || __i >= TREE_CODE_LENGTH ((CODE)))			\
!       tree_operand_check_failed (__i, (CODE),				\
  				 __FILE__, __LINE__, __FUNCTION__);	\
      &__t->exp.operands[__i]; }))
*************** extern void tree_operand_check_failed PA
*** 358,368 ****
  #else /* not ENABLE_TREE_CHECKING, or not gcc */
  
! #define TREE_CHECK(t, code)		(t)
! #define TREE_CLASS_CHECK(t, code)	(t)
! #define EXPR_CHECK(t)			(t)
! #define TREE_VEC_ELT_CHECK(t, i)	((t)->vec.a[i])
! #define TREE_OPERAND_CHECK(t, i)	((t)->exp.operands[i])
! #define TREE_OPERAND_CHECK_CODE(t, code, i) ((t)->exp.operands[i])
! #define TREE_RTL_OPERAND_CHECK(t, code, i)  (*(rtx *) &((t)->exp.operands[i]))
  
  #endif
--- 354,364 ----
  #else /* not ENABLE_TREE_CHECKING, or not gcc */
  
! #define TREE_CHECK(T, CODE)		(T)
! #define TREE_CLASS_CHECK(T, CODE)	(T)
! #define EXPR_CHECK(T)			(T)
! #define TREE_VEC_ELT_CHECK(T, I)	((T)->vec.a[I])
! #define TREE_OPERAND_CHECK(T, I)	((T)->exp.operands[I])
! #define TREE_OPERAND_CHECK_CODE(T, CODE, I) ((T)->exp.operands[I])
! #define TREE_RTL_OPERAND_CHECK(T, CODE, I)  (*(rtx *) &((T)->exp.operands[I]))
  
  #endif
*************** extern void tree_operand_check_failed PA
*** 370,376 ****
  #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.
--- 366,373 ----
  #include "tree-check.h"
  
! #define TYPE_CHECK(T)		TREE_CLASS_CHECK (T, 't')
! #define DECL_CHECK(T)		TREE_CLASS_CHECK (T, 'd')
! #define CST_CHECK(T)		TREE_CLASS_CHECK (T, 'c')
! #define STMT_CHECK(T)		TREE_CLASS_CHECK (T, 's')
  
  /* In all nodes that are expressions, this is the data type of the expression.



More information about the Gcc-patches mailing list