This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Clean up three more tree flags
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 5 Apr 04 08:36:00 EDT
- Subject: Clean up three more tree flags
Again, self-explanatory. Tested on x86_64-linux.
I suspect the rest will be harder.
2004-04-02 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* c-decl.c (build_compound_literal): Use TYPE_READONLY.
* emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise.
* objc/objc-act.c (adorn_decl, gen_declspecs): Likewise.
* c-typeck.c (decl_constant_value): Don't access DECL_INITIAL of a
PARM_DECL.
* calls.c (flags_from_decl_or_type): Use TYPE_READONLY and do so only
for a type.
* print-tree.c (print_node): Properly handle side-effects, readonly,
and constant flags.
* tree.c (build1_stat, build_expr_wfl): Only look at TREE_SIDE_EFFECTS
and TREE_CONSTANT if not a type.
* tree.h (IS_NON_TYPE_CODE_CLASS): New macro.
(IS_EXPR_CODE_CLASS): Write 'E', not 'e'.
(NON_TYPE_CHECK): New macro.
(TREE_SIDE_EFFECT, TREE_READONLY, TREE_CONSTANT: Add check.
* cp/init.c (decl_constant_value): Don't look at DECL_INITIAL
of PARM_DECL.
* cp/tree.c (bot_manip, build_min): Don't look at TREE_CONSTANT
or TREE_SIDE_EFFECTS of a type.
* ada/decl.c (gnat_to_gnu_entity): Use TYPE_READONLY.
* ada/utils.c (create_field_decl): Likewise.
* ada/utils2.c (build_unary_op, gnat_build_constructor): Likewise.
*** c-decl.c 1 Apr 2004 03:50:26 -0000 1.493
--- c-decl.c 2 Apr 2004 22:07:07 -0000
*************** build_compound_literal (tree type, tree
*** 3090,3094 ****
TREE_USED (decl) = 1;
TREE_TYPE (decl) = type;
! TREE_READONLY (decl) = TREE_READONLY (type);
store_init_value (decl, init);
--- 3090,3094 ----
TREE_USED (decl) = 1;
TREE_TYPE (decl) = type;
! TREE_READONLY (decl) = TYPE_READONLY (type);
store_init_value (decl, init);
*** c-typeck.c 1 Apr 2004 03:50:27 -0000 1.299
--- c-typeck.c 2 Apr 2004 22:07:12 -0000
*************** decl_constant_value (tree decl)
*** 1004,1009 ****
{
if (/* Don't change a variable array bound or initial value to a constant
! in a place where a variable is invalid. */
current_function_decl != 0
&& ! TREE_THIS_VOLATILE (decl)
&& TREE_READONLY (decl)
--- 1004,1011 ----
{
if (/* Don't change a variable array bound or initial value to a constant
! in a place where a variable is invalid. Note that DECL_INITIAL
! isn't valid for a PARM_DECL. */
current_function_decl != 0
+ && TREE_CODE (decl) != PARM_DECL
&& ! TREE_THIS_VOLATILE (decl)
&& TREE_READONLY (decl)
*** calls.c 1 Apr 2004 03:50:28 -0000 1.328
--- calls.c 2 Apr 2004 22:07:15 -0000
*************** flags_from_decl_or_type (tree exp)
*** 727,734 ****
if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
! flags |= ECF_LIBCALL_BLOCK;
}
!
! if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
flags |= ECF_CONST;
--- 727,733 ----
if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
! flags |= ECF_LIBCALL_BLOCK | ECF_CONST;
}
! else if (TYPE_P (exp) && TYPE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
flags |= ECF_CONST;
*** emit-rtl.c 30 Mar 2004 19:18:50 -0000 1.387
--- emit-rtl.c 2 Apr 2004 22:07:22 -0000
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1505,1509 ****
RTX_UNCHANGING_P (ref)
|= ((lang_hooks.honor_readonly
! && (TYPE_READONLY (type) || TREE_READONLY (t)))
|| (! TYPE_P (t) && TREE_CONSTANT (t)));
MEM_POINTER (ref) = POINTER_TYPE_P (type);
--- 1505,1509 ----
RTX_UNCHANGING_P (ref)
|= ((lang_hooks.honor_readonly
! && (TYPE_READONLY (type) || (t != type && TREE_READONLY (t))))
|| (! TYPE_P (t) && TREE_CONSTANT (t)));
MEM_POINTER (ref) = POINTER_TYPE_P (type);
*** print-tree.c 1 Apr 2004 13:41:29 -0000 1.83
--- print-tree.c 2 Apr 2004 22:07:23 -0000
*************** print_node (FILE *file, const char *pref
*** 246,254 ****
}
! if (TREE_SIDE_EFFECTS (node))
fputs (" side-effects", file);
! if (TREE_READONLY (node))
fputs (" readonly", file);
! if (TREE_CONSTANT (node))
fputs (" constant", file);
if (TREE_ADDRESSABLE (node))
--- 246,255 ----
}
! if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
fputs (" side-effects", file);
!
! if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
fputs (" readonly", file);
! if (!TYPE_P (node) && TREE_CONSTANT (node))
fputs (" constant", file);
if (TREE_ADDRESSABLE (node))
*** tree.c 1 Apr 2004 13:41:27 -0000 1.364
--- tree.c 2 Apr 2004 22:07:26 -0000
*************** build1_stat (enum tree_code code, tree t
*** 2403,2407 ****
TREE_COMPLEXITY (t) = 0;
TREE_OPERAND (t, 0) = node;
! if (node && first_rtl_op (code) != 0)
{
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
--- 2403,2407 ----
TREE_COMPLEXITY (t) = 0;
TREE_OPERAND (t, 0) = node;
! if (node && !TYPE_P (node) && first_rtl_op (code) != 0)
{
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
*************** build1_stat (enum tree_code code, tree t
*** 2457,2461 ****
default:
! if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node))
TREE_CONSTANT (t) = 1;
break;
--- 2457,2462 ----
default:
! if (TREE_CODE_CLASS (code) == '1' && node && !TYPE_P (node)
! && TREE_CONSTANT (node))
TREE_CONSTANT (t) = 1;
break;
*************** build1_stat (enum tree_code code, tree t
*** 2468,2472 ****
do { \
TREE_OPERAND (t, N) = arg##N; \
! if (arg##N && fro > N) \
{ \
if (TREE_SIDE_EFFECTS (arg##N)) \
--- 2469,2473 ----
do { \
TREE_OPERAND (t, N) = arg##N; \
! if (arg##N &&!TYPE_P (arg##N) && fro > N) \
{ \
if (TREE_SIDE_EFFECTS (arg##N)) \
*************** build_expr_wfl (tree node, const char *f
*** 2743,2747 ****
EXPR_WFL_FILENAME_NODE (wfl) = last_filenode;
! if (node)
{
TREE_SIDE_EFFECTS (wfl) = TREE_SIDE_EFFECTS (node);
--- 2744,2749 ----
EXPR_WFL_FILENAME_NODE (wfl) = last_filenode;
!
! if (node && !TYPE_P (node))
{
TREE_SIDE_EFFECTS (wfl) = TREE_SIDE_EFFECTS (node);
*** tree.h 1 Apr 2004 13:41:30 -0000 1.486
--- tree.h 2 Apr 2004 22:07:32 -0000
*************** extern const char tree_code_type[];
*** 55,58 ****
--- 55,62 ----
#define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)]
+ /* Returns nonzero iff CLASS is not the tree code of a type. */
+
+ #define IS_NON_TYPE_CODE_CLASS(CLASS) (strchr ("xbcdr<12se", (CLASS)) != 0)
+
/* Returns nonzero iff CLASS is the tree-code class of an
expression. */
*************** struct tree_common GTY(())
*** 160,166 ****
unsigned unsigned_flag : 1;
unsigned asm_written_flag: 1;
- unsigned unused_0 : 1;
-
unsigned used_flag : 1;
unsigned nothrow_flag : 1;
unsigned static_flag : 1;
--- 164,169 ----
unsigned unsigned_flag : 1;
unsigned asm_written_flag: 1;
unsigned used_flag : 1;
+
unsigned nothrow_flag : 1;
unsigned static_flag : 1;
*************** struct tree_common GTY(())
*** 169,172 ****
--- 172,177 ----
unsigned protected_flag : 1;
unsigned deprecated_flag : 1;
+
+ unsigned unused_0 : 1;
unsigned unused_1 : 1;
*************** struct tree_common GTY(())
*** 241,244 ****
--- 246,251 ----
TREE_SIDE_EFFECTS in
all expressions
+ all decls
+ all constants
volatile_flag:
*************** struct tree_common GTY(())
*** 260,263 ****
--- 267,272 ----
TREE_CONSTANT in
all expressions
+ all decls
+ all constants
unsigned_flag:
*************** struct tree_common GTY(())
*** 366,370 ****
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
if (!IS_EXPR_CODE_CLASS (__c)) \
! tree_class_check_failed (__t, 'e', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
--- 375,388 ----
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
if (!IS_EXPR_CODE_CLASS (__c)) \
! tree_class_check_failed (__t, 'E', __FILE__, __LINE__, \
! __FUNCTION__); \
! __t; })
!
! /* These checks have to be special cased. */
! #define NON_TYPE_CHECK(T) __extension__ \
! ({ const tree __t = (T); \
! char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
! if (!IS_NON_TYPE_CODE_CLASS (__c)) \
! tree_class_check_failed (__t, 'T', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
*************** extern void tree_operand_check_failed (i
*** 449,452 ****
--- 467,471 ----
#define TREE_CLASS_CHECK(T, CODE) (T)
#define EXPR_CHECK(T) (T)
+ #define NON_TYPE_CHECK(T) (T)
#define TREE_VEC_ELT_CHECK(T, I) ((T)->vec.a[I])
#define TREE_OPERAND_CHECK(T, I) ((T)->exp.operands[I])
*************** extern void tree_operand_check_failed (i
*** 678,687 ****
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
! /* In any expression, nonzero means it has side effects or reevaluation
! of the whole expression could produce a different value.
! This is set if any subexpression is a function call, a side effect
! or a reference to a volatile variable.
! In a ..._DECL, this is set only if the declaration said `volatile'. */
! #define TREE_SIDE_EFFECTS(NODE) ((NODE)->common.side_effects_flag)
/* Nonzero means this expression is volatile in the C sense:
--- 697,707 ----
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
! /* In any expression, decl, or constant, nonzero means it has side effects or
! reevaluation of the whole expression could produce a different value.
! This is set if any subexpression is a function call, a side effect or a
! reference to a volatile variable. In a ..._DECL, this is set only if the
! declaration said `volatile'. This will never be set for a constant. */
! #define TREE_SIDE_EFFECTS(NODE) \
! (NON_TYPE_CHECK (NODE)->common.side_effects_flag)
/* Nonzero means this expression is volatile in the C sense:
*************** extern void tree_operand_check_failed (i
*** 698,715 ****
/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
! nonzero means it may not be the lhs of an assignment.
! In a ..._TYPE node, means this type is const-qualified
! (but the macro TYPE_READONLY should be used instead of this macro
! when the node is a type). */
! #define TREE_READONLY(NODE) ((NODE)->common.readonly_flag)
/* Nonzero if NODE is a _DECL with TREE_READONLY set. */
! #define TREE_READONLY_DECL_P(NODE) (TREE_READONLY (NODE) && DECL_P (NODE))
! /* Value of expression is constant.
! Always appears in all ..._CST nodes.
! May also appear in an arithmetic expression, an ADDR_EXPR or a CONSTRUCTOR
! if the value is constant. */
! #define TREE_CONSTANT(NODE) ((NODE)->common.constant_flag)
/* In a decl (most significantly a FIELD_DECL), means an unsigned field. */
--- 718,730 ----
/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
! nonzero means it may not be the lhs of an assignment. */
! #define TREE_READONLY(NODE) (NON_TYPE_CHECK (NODE)->common.readonly_flag)
/* Nonzero if NODE is a _DECL with TREE_READONLY set. */
! #define TREE_READONLY_DECL_P(NODE) (DECL_P (NODE) && TREE_READONLY (NODE))
! /* Value of expression is constant. Always on in all ..._CST nodes. May
! also appear in an expression or decl where the value is constant. */
! #define TREE_CONSTANT(NODE) (NON_TYPE_CHECK (NODE)->common.constant_flag)
/* In a decl (most significantly a FIELD_DECL), means an unsigned field. */
*************** struct tree_type GTY(())
*** 1447,1451 ****
For a PARM_DECL, not used--default
values for parameters are encoded in the type of the function,
! not in the PARM_DECL slot. */
#define DECL_INITIAL(NODE) (DECL_CHECK (NODE)->decl.initial)
/* For a PARM_DECL, records the data type used to pass the argument,
--- 1462,1468 ----
For a PARM_DECL, not used--default
values for parameters are encoded in the type of the function,
! not in the PARM_DECL slot.
!
! ??? Need to figure out some way to check this isn't a PARM_DECL. */
#define DECL_INITIAL(NODE) (DECL_CHECK (NODE)->decl.initial)
/* For a PARM_DECL, records the data type used to pass the argument,
*** cp/init.c 9 Mar 2004 10:00:12 -0000 1.365
--- cp/init.c 2 Apr 2004 22:08:00 -0000
*************** decl_constant_value (tree decl)
*** 1624,1627 ****
--- 1624,1628 ----
are also 'volatile'. */
|| CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)))
+ && TREE_CODE (decl) != PARM_DECL
&& DECL_INITIAL (decl)
&& DECL_INITIAL (decl) != error_mark_node
*** cp/tree.c 2 Apr 2004 11:48:53 -0000 1.371
--- cp/tree.c 2 Apr 2004 22:08:03 -0000
*************** bot_manip (tree* tp, int* walk_subtrees,
*** 1187,1191 ****
tree t = *tp;
! if (TREE_CONSTANT (t))
{
/* There can't be any TARGET_EXPRs or their slot variables below
--- 1187,1191 ----
tree t = *tp;
! if (!TYPE_P (t) && TREE_CONSTANT (t))
{
/* There can't be any TARGET_EXPRs or their slot variables below
*************** build_min (enum tree_code code, tree tt,
*** 1328,1332 ****
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
! if (x && TREE_SIDE_EFFECTS (x))
TREE_SIDE_EFFECTS (t) = 1;
}
--- 1328,1332 ----
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
! if (x && !TYPE_P (x) && TREE_SIDE_EFFECTS (x))
TREE_SIDE_EFFECTS (t) = 1;
}
*** objc/objc-act.c 1 Apr 2004 03:50:36 -0000 1.211
--- objc/objc-act.c 3 Apr 2004 00:07:00 -0000
*************** adorn_decl (tree decl, char *str)
*** 8100,8106 ****
{
strcpy (tmpbuf, "*");
! if (TREE_READONLY (decl) || TYPE_VOLATILE (decl))
{
! if (TREE_READONLY (decl))
strcat (tmpbuf, " const");
if (TYPE_VOLATILE (decl))
--- 8100,8106 ----
{
strcpy (tmpbuf, "*");
! if (TYPE_READONLY (decl) || TYPE_VOLATILE (decl))
{
! if (TYPE_READONLY (decl))
strcat (tmpbuf, " const");
if (TYPE_VOLATILE (decl))
*************** gen_declspecs (tree declspecs, char *buf
*** 8306,8310 ****
{
/* Type qualifiers. */
! if (TREE_READONLY (declspecs))
strcat (buf, "const ");
if (TYPE_VOLATILE (declspecs))
--- 8306,8310 ----
{
/* Type qualifiers. */
! if (TYPE_READONLY (declspecs))
strcat (buf, "const ");
if (TYPE_VOLATILE (declspecs))
*** ada/decl.c 1 Apr 2004 10:12:30 -0000 1.63.2.47
--- ada/decl.c 2 Apr 2004 22:19:59 -0000
*************** gnat_to_gnu_entity (Entity_Id gnat_entit
*** 1444,1448 ****
TYPE_NAME (gnu_fat_type) = create_concat_name (gnat_entity, "XUP");
TYPE_IS_FAT_POINTER_P (gnu_fat_type) = 1;
! TREE_READONLY (gnu_template_type) = 1;
/* Make a node for the array. If we are not defining the array
--- 1444,1448 ----
TYPE_NAME (gnu_fat_type) = create_concat_name (gnat_entity, "XUP");
TYPE_IS_FAT_POINTER_P (gnu_fat_type) = 1;
! TYPE_READONLY (gnu_template_type) = 1;
/* Make a node for the array. If we are not defining the array
*************** gnat_to_gnu_entity (Entity_Id gnat_entit
*** 1554,1558 ****
/* Install all the fields into the template. */
finish_record_type (gnu_template_type, gnu_template_fields, 0, 0);
! TREE_READONLY (gnu_template_type) = 1;
/* Now make the array of arrays and update the pointer to the array
--- 1554,1558 ----
/* Install all the fields into the template. */
finish_record_type (gnu_template_type, gnu_template_fields, 0, 0);
! TYPE_READONLY (gnu_template_type) = 1;
/* Now make the array of arrays and update the pointer to the array
*** ada/utils.c 1 Apr 2004 10:13:17 -0000 1.48.2.35
--- ada/utils.c 2 Apr 2004 22:20:14 -0000
*************** create_field_decl (tree field_name,
*** 1403,1407 ****
DECL_CONTEXT (field_decl) = record_type;
! TREE_READONLY (field_decl) = TREE_READONLY (field_type);
/* If FIELD_TYPE is BLKmode, we must ensure this is aligned to at least a
--- 1403,1407 ----
DECL_CONTEXT (field_decl) = record_type;
! TREE_READONLY (field_decl) = TYPE_READONLY (field_type);
/* If FIELD_TYPE is BLKmode, we must ensure this is aligned to at least a
*** ada/utils2.c 1 Apr 2004 10:13:37 -0000 1.21.4.15
--- ada/utils2.c 2 Apr 2004 22:20:17 -0000
*************** build_unary_op (enum tree_code op_code,
*** 1235,1239 ****
{
result = fold (build1 (op_code, TREE_TYPE (type), operand));
! TREE_READONLY (result) = TREE_READONLY (TREE_TYPE (type));
}
--- 1235,1239 ----
{
result = fold (build1 (op_code, TREE_TYPE (type), operand));
! TREE_READONLY (result) = TYPE_READONLY (TREE_TYPE (type));
}
*************** gnat_build_constructor (tree type, tree
*** 1522,1526 ****
TREE_STATIC (result) = allconstant;
TREE_SIDE_EFFECTS (result) = side_effects;
! TREE_READONLY (result) = TREE_READONLY (type);
return result;
--- 1522,1526 ----
TREE_STATIC (result) = allconstant;
TREE_SIDE_EFFECTS (result) = side_effects;
! TREE_READONLY (result) = TYPE_READONLY (type);
return result;