This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Share int_cst nodes
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 19 Aug 2004 11:28:18 +0100
- Subject: Re: [PATCH] Share int_cst nodes
- Organization: Codesourcery LLC
- References: <412320DE.7020004@codesourcery.com> <41238CC8.60407@codesourcery.com>
Mark Mitchell wrote:
I think you should make TYPE_CACHED_LENGTH a --param thingy.
OK with that change.
Here's what I've installed. Having a param allowed me to quickly
determine that 256 was the best - saving a whopping 20% of ggc'd memory!
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-08-19 Nathan Sidwell <nathan@codesourcery.com>
* tree.h (TYPE_CACHED_VALUES_P): New.
(TYPE_CACHED_VALUES): New.
(TYPE_ORIG_SIZE_TYPE): Adjust.
* tree.def (INTEGER_CST): Update documentation.
* tree.c: Inlcude params.h.
(build_int_cst): Cache small values.
(build_type_copy): Do not copy the value cache.
* c-common.c (c_common_nodes_and_builtins): Add comment, remove
unneeded zeroing.
* c-typeck.c (build_c_cast): Add comment about OVERFLOW setting.
* expmed.c (const_mult_add_overflow_p): Clear type copy's value
cache.
* fold-const.c (force_fit_type): Copy value when setting
overflows.
(int_const_binop): Likewise.
* stor-layout.c: Include params.h
(set_sizetype): Create values cache.
(fixup_unsigned_type): Set UNSIGNED_P before caching any values.
* params.def (PARAM_INTEGER_SHARE_LIMIT): New.
* params.h (INTEGER_SHARE_LIMIT): New.
* Makefile.in (tree.o, stor-layout.o): Depend on PARAMS_H.
* cp/decl.c (finish_enum): Do not copy value node early, copy
later.
* cp/lex.c (cxx_init): Force null_node to be unique.
* java/parse.h (JAVA_RADIX10_FLAG): Rename to ...
(JAVA_NOT_RADIX10_FLAG): ... here. Invert meaning.
* java/lex.c (do_java_lex): Adjust.
(error_if_numeric_overflow): Likewise.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1348
diff -c -3 -p -r1.1348 Makefile.in
*** Makefile.in 16 Aug 2004 23:05:03 -0000 1.1348
--- Makefile.in 19 Aug 2004 08:27:04 -0000
*************** convert.o: convert.c $(CONFIG_H) $(SYSTE
*** 1558,1564 ****
langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) toplev.h \
tree-inline.h $(RTL_H) insn-config.h $(INTEGRATE_H) langhooks.h \
$(LANGHOOKS_DEF_H) $(FLAGS_H) $(GGC_H) diagnostic.h
! tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(FLAGS_H) function.h \
toplev.h $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \
real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_H)
tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
--- 1558,1565 ----
langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) toplev.h \
tree-inline.h $(RTL_H) insn-config.h $(INTEGRATE_H) langhooks.h \
$(LANGHOOKS_DEF_H) $(FLAGS_H) $(GGC_H) diagnostic.h
! tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
! $(FLAGS_H) function.h $(PARAMS_H) \
toplev.h $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \
real.h gt-tree.h tree-iterator.h $(BASIC_BLOCK_H) $(TREE_FLOW_H)
tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
*************** tree-inline.o : tree-inline.c $(CONFIG_H
*** 1571,1578 ****
$(TREE_GIMPLE_H)
print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(GGC_H) langhooks.h real.h
! stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
! $(FLAGS_H) function.h $(EXPR_H) $(RTL_H) toplev.h $(GGC_H) $(TM_P_H) $(TARGET_H) \
langhooks.h $(REGS_H)
tree-alias-type.o: tree-alias-type.c tree-alias-type.h $(SYSTEM_H) $(CONFIG_H) \
$(GGC_H) $(TM_H) coretypes.h $(VARRAY_H)
--- 1572,1580 ----
$(TREE_GIMPLE_H)
print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(GGC_H) langhooks.h real.h
! stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
! $(TREE_H) $(PARAMS_H) $(FLAGS_H) function.h $(EXPR_H) $(RTL_H) toplev.h \
! $(GGC_H) $(TM_P_H) $(TARGET_H) \
langhooks.h $(REGS_H)
tree-alias-type.o: tree-alias-type.c tree-alias-type.h $(SYSTEM_H) $(CONFIG_H) \
$(GGC_H) $(TM_H) coretypes.h $(VARRAY_H)
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.554
diff -c -3 -p -r1.554 c-common.c
*** c-common.c 16 Aug 2004 20:54:36 -0000 1.554
--- c-common.c 19 Aug 2004 08:27:18 -0000
*************** c_common_nodes_and_builtins (void)
*** 3001,3009 ****
record_builtin_type (RID_VOID, NULL, void_type_node);
void_zero_node = make_node (INTEGER_CST);
- TREE_INT_CST_LOW (void_zero_node) = 0;
- TREE_INT_CST_HIGH (void_zero_node) = 0;
TREE_TYPE (void_zero_node) = void_type_node;
void_list_node = build_void_list_node ();
--- 3001,3008 ----
record_builtin_type (RID_VOID, NULL, void_type_node);
+ /* This node must not be shared. */
void_zero_node = make_node (INTEGER_CST);
TREE_TYPE (void_zero_node) = void_type_node;
void_list_node = build_void_list_node ();
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.358
diff -c -3 -p -r1.358 c-typeck.c
*** c-typeck.c 17 Aug 2004 00:00:18 -0000 1.358
--- c-typeck.c 19 Aug 2004 08:27:32 -0000
*************** build_c_cast (tree type, tree expr)
*** 3109,3119 ****
--- 3109,3123 ----
if (TREE_CODE (value) == INTEGER_CST)
{
if (EXPR_P (ovalue))
+ /* If OVALUE had overflow set, then so will VALUE, so it
+ is safe to overwrite. */
TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
else
TREE_OVERFLOW (value) = 0;
if (TREE_CODE_CLASS (TREE_CODE (ovalue)) == 'c')
+ /* Similarly, constant_overflow cannot have become
+ cleared. */
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
}
}
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.190
diff -c -3 -p -r1.190 expmed.c
*** expmed.c 17 Aug 2004 07:27:08 -0000 1.190
--- expmed.c 19 Aug 2004 08:27:43 -0000
*************** make_tree (tree type, rtx x)
*** 4550,4556 ****
UNSIGNEDP is nonzero to do unsigned multiplication. */
bool
! const_mult_add_overflow_p (rtx x, rtx mult, rtx add, enum machine_mode mode, int unsignedp)
{
tree type, mult_type, add_type, result;
--- 4550,4557 ----
UNSIGNEDP is nonzero to do unsigned multiplication. */
bool
! const_mult_add_overflow_p (rtx x, rtx mult, rtx add,
! enum machine_mode mode, int unsignedp)
{
tree type, mult_type, add_type, result;
*************** const_mult_add_overflow_p (rtx x, rtx mu
*** 4561,4567 ****
--- 4562,4576 ----
mult_type = type;
if (unsignedp)
{
+ /* FIXME:It would be nice if we could step directly from this
+ type to its sizetype equivalent. */
mult_type = copy_node (type);
+ if (TYPE_CACHED_VALUES_P (mult_type))
+ {
+ /* Clear any set of cached values it has. */
+ TYPE_CACHED_VALUES_P (mult_type) = 0;
+ TYPE_CACHED_VALUES (mult_type) = NULL_TREE;
+ }
TYPE_IS_SIZETYPE (mult_type) = 1;
}
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.437
diff -c -3 -p -r1.437 fold-const.c
*** fold-const.c 17 Aug 2004 07:40:13 -0000 1.437
--- fold-const.c 19 Aug 2004 08:28:06 -0000
*************** force_fit_type (tree t, int overflowable
*** 268,285 ****
if (overflowed || overflowed_const
|| low != TREE_INT_CST_LOW (t) || high != TREE_INT_CST_HIGH (t))
{
if (overflowed
|| overflowable < 0
|| (overflowable > 0 && sign_extended_type))
{
TREE_OVERFLOW (t) = 1;
TREE_CONSTANT_OVERFLOW (t) = 1;
}
else if (overflowed_const)
! TREE_CONSTANT_OVERFLOW (t) = 1;
!
! TREE_INT_CST_LOW (t) = low;
! TREE_INT_CST_HIGH (t) = high;
}
return t;
--- 268,288 ----
if (overflowed || overflowed_const
|| low != TREE_INT_CST_LOW (t) || high != TREE_INT_CST_HIGH (t))
{
+ t = build_int_cst (TREE_TYPE (t), low, high);
+
if (overflowed
|| overflowable < 0
|| (overflowable > 0 && sign_extended_type))
{
+ t = copy_node (t);
TREE_OVERFLOW (t) = 1;
TREE_CONSTANT_OVERFLOW (t) = 1;
}
else if (overflowed_const)
! {
! t = copy_node (t);
! TREE_CONSTANT_OVERFLOW (t) = 1;
! }
}
return t;
*************** int_const_binop (enum tree_code code, tr
*** 1425,1435 ****
/* Propagate overflow flags ourselves. */
if (((!uns || is_sizetype) && overflow)
| TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2))
! TREE_OVERFLOW (t) = 1;
!
! if (TREE_OVERFLOW (t) | TREE_CONSTANT_OVERFLOW (arg1)
! | TREE_CONSTANT_OVERFLOW (arg2))
! TREE_CONSTANT_OVERFLOW (t) = 1;
}
else
t = force_fit_type (t, 1,
--- 1428,1443 ----
/* Propagate overflow flags ourselves. */
if (((!uns || is_sizetype) && overflow)
| TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2))
! {
! t = copy_node (t);
! TREE_OVERFLOW (t) = 1;
! TREE_CONSTANT_OVERFLOW (t) = 1;
! }
! else if (TREE_CONSTANT_OVERFLOW (arg1) | TREE_CONSTANT_OVERFLOW (arg2))
! {
! t = copy_node (t);
! TREE_CONSTANT_OVERFLOW (t) = 1;
! }
}
else
t = force_fit_type (t, 1,
Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.44
diff -c -3 -p -r1.44 params.def
*** params.def 6 Aug 2004 17:20:52 -0000 1.44
--- params.def 19 Aug 2004 08:28:08 -0000
*************** DEFPARAM(PARAM_MAX_SCHED_REGION_INSNS,
*** 379,384 ****
--- 379,392 ----
"The maximum number of insns in a region to be considered for interblock scheduling",
100)
+ /* INTEGER_CST nodes are shared for values [{-1,0} .. N) for
+ {signed,unsigned} integral types. This determines N.
+ Experimentation shows 256 to be a good value. */
+ DEFPARAM (PARAM_INTEGER_SHARE_LIMIT,
+ "integer-share-limit",
+ "The upper bound for sharing integer constants",
+ 256)
+
/*
Local variables:
mode:c
Index: params.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.h,v
retrieving revision 1.20
diff -c -3 -p -r1.20 params.h
*** params.h 25 May 2004 12:54:54 -0000 1.20
--- params.h 19 Aug 2004 08:28:08 -0000
*************** typedef enum compiler_param
*** 122,125 ****
--- 122,127 ----
PARAM_VALUE (PARAM_GLOBAL_VAR_THRESHOLD)
#define MAX_ALIASED_VOPS \
PARAM_VALUE (PARAM_MAX_ALIASED_VOPS)
+ #define INTEGER_SHARE_LIMIT \
+ PARAM_VALUE (PARAM_INTEGER_SHARE_LIMIT)
#endif /* ! GCC_PARAMS_H */
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.201
diff -c -3 -p -r1.201 stor-layout.c
*** stor-layout.c 15 Aug 2004 15:45:00 -0000 1.201
--- stor-layout.c 19 Aug 2004 08:28:13 -0000
*************** Software Foundation, 59 Temple Place - S
*** 35,40 ****
--- 35,41 ----
#include "target.h"
#include "langhooks.h"
#include "regs.h"
+ #include "params.h"
/* Set to one when set_sizetype has been called. */
static int sizetype_set;
*************** set_sizetype (tree type)
*** 1900,1906 ****
/* Make copies of nodes since we'll be setting TYPE_IS_SIZETYPE. */
sizetype = copy_node (type);
! TYPE_ORIG_SIZE_TYPE (sizetype) = type;
TYPE_IS_SIZETYPE (sizetype) = 1;
bitsizetype = make_node (INTEGER_TYPE);
TYPE_NAME (bitsizetype) = TYPE_NAME (type);
--- 1901,1909 ----
/* Make copies of nodes since we'll be setting TYPE_IS_SIZETYPE. */
sizetype = copy_node (type);
! TYPE_CACHED_VALUES (sizetype) = make_tree_vec (INTEGER_SHARE_LIMIT);
! TYPE_CACHED_VALUES_P (sizetype) = 1;
! TREE_TYPE (TYPE_CACHED_VALUES (sizetype)) = type;
TYPE_IS_SIZETYPE (sizetype) = 1;
bitsizetype = make_node (INTEGER_TYPE);
TYPE_NAME (bitsizetype) = TYPE_NAME (type);
*************** fixup_unsigned_type (tree type)
*** 2047,2052 ****
--- 2050,2057 ----
if (precision > HOST_BITS_PER_WIDE_INT * 2)
precision = HOST_BITS_PER_WIDE_INT * 2;
+ TYPE_UNSIGNED (type) = 1;
+
set_min_and_max_values_for_integral_type (type, precision,
/*is_unsigned=*/true);
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.410
diff -c -3 -p -r1.410 tree.c
*** tree.c 15 Aug 2004 15:45:01 -0000 1.410
--- tree.c 19 Aug 2004 08:28:24 -0000
*************** Software Foundation, 59 Temple Place - S
*** 48,53 ****
--- 48,54 ----
#include "tree-iterator.h"
#include "basic-block.h"
#include "tree-flow.h"
+ #include "params.h"
/* obstack.[ch] explicitly declined to prototype this. */
extern int _obstack_allocated_p (struct obstack *h, void *obj);
*************** tree
*** 427,441 ****
build_int_cst (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
{
tree t;
if (!type)
type = integer_type_node;
!
t = make_node (INTEGER_CST);
TREE_INT_CST_LOW (t) = low;
TREE_INT_CST_HIGH (t) = hi;
TREE_TYPE (t) = type;
return t;
}
--- 428,511 ----
build_int_cst (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
{
tree t;
+ int ix = -1;
+ int limit = 0;
if (!type)
type = integer_type_node;
!
! switch (TREE_CODE (type))
! {
! case POINTER_TYPE:
! case REFERENCE_TYPE:
! /* Cache NULL pointer. */
! if (!hi && !low)
! {
! limit = 1;
! ix = 0;
! }
! break;
!
! case BOOLEAN_TYPE:
! /* Cache false or true. */
! limit = 2;
! if (!hi && low < 2)
! ix = low;
! break;
!
! case INTEGER_TYPE:
! case CHAR_TYPE:
! case OFFSET_TYPE:
! if (TYPE_UNSIGNED (type))
! {
! /* Cache 0..N */
! limit = INTEGER_SHARE_LIMIT;
! if (!hi && low < (unsigned HOST_WIDE_INT)INTEGER_SHARE_LIMIT)
! ix = low;
! }
! else
! {
! /* Cache -1..N */
! limit = INTEGER_SHARE_LIMIT + 1;
! if (!hi && low < (unsigned HOST_WIDE_INT)INTEGER_SHARE_LIMIT)
! ix = low + 1;
! else if (hi == -1 && low == -(unsigned HOST_WIDE_INT)1)
! ix = 0;
! }
! break;
! default:
! break;
! }
!
! if (ix >= 0)
! {
! if (!TYPE_CACHED_VALUES_P (type))
! {
! TYPE_CACHED_VALUES_P (type) = 1;
! TYPE_CACHED_VALUES (type) = make_tree_vec (limit);
! }
!
! t = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix);
! if (t)
! {
! /* Make sure no one is clobbering the shared constant. */
! if (TREE_TYPE (t) != type)
! abort ();
! if (TREE_INT_CST_LOW (t) != low || TREE_INT_CST_HIGH (t) != hi)
! abort ();
! return t;
! }
! }
!
t = make_node (INTEGER_CST);
TREE_INT_CST_LOW (t) = low;
TREE_INT_CST_HIGH (t) = hi;
TREE_TYPE (t) = type;
+
+ if (ix >= 0)
+ TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix) = t;
+
return t;
}
*************** build_type_copy (tree type)
*** 3097,3102 ****
--- 3167,3180 ----
tree t, m = TYPE_MAIN_VARIANT (type);
t = copy_node (type);
+ if (TYPE_CACHED_VALUES_P(t))
+ {
+ /* Do not copy the values cache. */
+ if (TREE_CODE (t) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t))
+ abort ();
+ TYPE_CACHED_VALUES_P (t) = 0;
+ TYPE_CACHED_VALUES (t) = NULL_TREE;
+ }
TYPE_POINTER_TO (t) = 0;
TYPE_REFERENCE_TO (t) = 0;
Index: tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.def,v
retrieving revision 1.97
diff -c -3 -p -r1.97 tree.def
*** tree.def 6 Aug 2004 10:40:30 -0000 1.97
--- tree.def 19 Aug 2004 08:28:27 -0000
*************** DEFTREECODE (LANG_TYPE, "lang_type", 't'
*** 258,267 ****
/* First, the constants. */
/* Contents are in TREE_INT_CST_LOW and TREE_INT_CST_HIGH fields,
! 32 bits each, giving us a 64 bit constant capability.
! Note: constants of type char in Pascal are INTEGER_CST,
! and so are pointer constants such as nil in Pascal or NULL in C.
! `(int *) 1' in C also results in an INTEGER_CST. */
DEFTREECODE (INTEGER_CST, "integer_cst", 'c', 0)
/* Contents are in TREE_REAL_CST field. */
--- 258,270 ----
/* First, the constants. */
/* Contents are in TREE_INT_CST_LOW and TREE_INT_CST_HIGH fields,
! 32 bits each, giving us a 64 bit constant capability. INTEGER_CST
! nodes can be shared, and therefore should be considered read only.
! They should be copied, before setting a flag such as
! TREE_OVERFLOW. If an INTEGER_CST has TREE_OVERFLOW or
! TREE_CONSTANT_OVERFLOW already set, it is known to be unique.
! INTEGER_CST nodes are created for the integral types, for pointer
! types and for vector and float types in some circumstances. */
DEFTREECODE (INTEGER_CST, "integer_cst", 'c', 0)
/* Contents are in TREE_REAL_CST field. */
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.591
diff -c -3 -p -r1.591 tree.h
*** tree.h 17 Aug 2004 00:00:18 -0000 1.591
--- tree.h 19 Aug 2004 08:28:37 -0000
*************** struct tree_common GTY(())
*** 230,235 ****
--- 230,237 ----
VAR_DECL or FUNCTION_DECL or IDENTIFIER_NODE
ASM_VOLATILE_P in
ASM_EXPR
+ TYPE_CACHED_VALUES_P in
+ ..._TYPE
private_flag:
*************** extern void tree_operand_check_failed (i
*** 782,787 ****
--- 784,793 ----
for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
+ /* In a _TYPE, indicates whether TYPE_CACHED_VALUES contains a vector
+ of cached values, or is something else. */
+ #define TYPE_CACHED_VALUES_P(NODE) (TYPE_CHECK(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
*************** struct tree_block GTY(())
*** 1377,1386 ****
#define TYPE_SIZE(NODE) (TYPE_CHECK (NODE)->type.size)
#define TYPE_SIZE_UNIT(NODE) (TYPE_CHECK (NODE)->type.size_unit)
#define TYPE_MODE(NODE) (TYPE_CHECK (NODE)->type.mode)
- #define TYPE_ORIG_SIZE_TYPE(NODE) (INTEGER_TYPE_CHECK (NODE)->type.values)
#define TYPE_VALUES(NODE) (ENUMERAL_TYPE_CHECK (NODE)->type.values)
#define TYPE_DOMAIN(NODE) (SET_OR_ARRAY_CHECK (NODE)->type.values)
#define TYPE_FIELDS(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.values)
#define TYPE_METHODS(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.maxval)
#define TYPE_VFIELD(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.minval)
#define TYPE_ARG_TYPES(NODE) (FUNC_OR_METHOD_CHECK (NODE)->type.values)
--- 1383,1395 ----
#define TYPE_SIZE(NODE) (TYPE_CHECK (NODE)->type.size)
#define TYPE_SIZE_UNIT(NODE) (TYPE_CHECK (NODE)->type.size_unit)
#define TYPE_MODE(NODE) (TYPE_CHECK (NODE)->type.mode)
#define TYPE_VALUES(NODE) (ENUMERAL_TYPE_CHECK (NODE)->type.values)
#define TYPE_DOMAIN(NODE) (SET_OR_ARRAY_CHECK (NODE)->type.values)
#define TYPE_FIELDS(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.values)
+ #define TYPE_CACHED_VALUES(NODE) (TYPE_CHECK(NODE)->type.values)
+ #define TYPE_ORIG_SIZE_TYPE(NODE) \
+ (INTEGER_TYPE_CHECK (NODE)->type.values \
+ ? TREE_TYPE ((NODE)->type.values) : NULL_TREE)
#define TYPE_METHODS(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.maxval)
#define TYPE_VFIELD(NODE) (RECORD_OR_UNION_CHECK (NODE)->type.minval)
#define TYPE_ARG_TYPES(NODE) (FUNC_OR_METHOD_CHECK (NODE)->type.values)
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1273
diff -c -3 -p -r1.1273 decl.c
*** cp/decl.c 16 Aug 2004 02:07:51 -0000 1.1273
--- cp/decl.c 19 Aug 2004 08:29:08 -0000
*************** finish_enum (tree enumtype)
*** 9311,9326 ****
maxnode = value;
else if (tree_int_cst_lt (value, minnode))
minnode = value;
-
- /* Set the TREE_TYPE for the values as well. That's so that when
- we call decl_constant_value we get an entity of the right type
- (but with the constant value). But first make a copy so we
- don't clobber shared INTEGER_CSTs. */
- if (TREE_TYPE (value) != enumtype)
- {
- value = DECL_INITIAL (decl) = copy_node (value);
- TREE_TYPE (value) = enumtype;
- }
}
}
else
--- 9311,9316 ----
*************** finish_enum (tree enumtype)
*** 9405,9410 ****
--- 9395,9404 ----
decl = TREE_VALUE (values);
value = perform_implicit_conversion (underlying_type,
DECL_INITIAL (decl));
+
+ /* Do not clobber shared ints. */
+ value = copy_node (value);
+
TREE_TYPE (value) = enumtype;
DECL_INITIAL (decl) = value;
TREE_VALUE (values) = value;
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.339
diff -c -3 -p -r1.339 lex.c
*** cp/lex.c 15 Aug 2004 15:45:25 -0000 1.339
--- cp/lex.c 19 Aug 2004 08:29:10 -0000
*************** cxx_init (void)
*** 354,361 ****
cxx_init_decl_processing ();
! /* Create the built-in __null node. */
! null_node = build_int_cst (c_common_type_for_size (POINTER_SIZE, 0), 0, 0);
ridpointers[RID_NULL] = null_node;
interface_unknown = 1;
--- 354,363 ----
cxx_init_decl_processing ();
! /* Create the built-in __null node. It is important that this is
! not shared. */
! null_node = make_node (INTEGER_CST);
! TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0);
ridpointers[RID_NULL] = null_node;
interface_unknown = 1;
Index: java/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.111
diff -c -3 -p -r1.111 lex.c
*** java/lex.c 15 Aug 2004 15:45:30 -0000 1.111
--- java/lex.c 19 Aug 2004 08:29:14 -0000
*************** do_java_lex (YYSTYPE *java_lval)
*** 1303,1311 ****
value = build_int_cst (long_suffix ? long_type_node : int_type_node,
low, high);
value = force_fit_type (value, 0, false, false);
! SET_LVAL_NODE (value);
! JAVA_RADIX10_FLAG (value) = radix == 10;
#endif
return INT_LIT_TK;
}
--- 1303,1316 ----
value = build_int_cst (long_suffix ? long_type_node : int_type_node,
low, high);
value = force_fit_type (value, 0, false, false);
!
! if (radix != 10)
! {
! value = copy_node (value);
! JAVA_NOT_RADIX10_FLAG (value) = 1;
! }
! SET_LVAL_NODE (value);
#endif
return INT_LIT_TK;
}
*************** static void
*** 1733,1739 ****
error_if_numeric_overflow (tree value)
{
if (TREE_CODE (value) == INTEGER_CST
! && JAVA_RADIX10_FLAG (value)
&& tree_int_cst_sgn (value) < 0)
{
if (TREE_TYPE (value) == long_type_node)
--- 1738,1744 ----
error_if_numeric_overflow (tree value)
{
if (TREE_CODE (value) == INTEGER_CST
! && !JAVA_NOT_RADIX10_FLAG (value)
&& tree_int_cst_sgn (value) < 0)
{
if (TREE_TYPE (value) == long_type_node)
Index: java/parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.99
diff -c -3 -p -r1.99 parse.h
*** java/parse.h 1 Aug 2004 18:04:42 -0000 1.99
--- java/parse.h 19 Aug 2004 08:29:17 -0000
*************** struct parser_ctxt GTY(()) {
*** 910,918 ****
TREE_PURPOSE (CPC_INSTANCE_INITIALIZER_LIST (C)) = (S);
/* This is used by the lexer to communicate with the parser. It is
! set on an integer constant if the radix is 10, so that the parser
can correctly diagnose a numeric overflow. */
! #define JAVA_RADIX10_FLAG(NODE) TREE_LANG_FLAG_0(NODE)
#ifndef JC1_LITE
void java_complete_class (void);
--- 910,918 ----
TREE_PURPOSE (CPC_INSTANCE_INITIALIZER_LIST (C)) = (S);
/* This is used by the lexer to communicate with the parser. It is
! set on an integer constant if the radix is NOT 10, so that the parser
can correctly diagnose a numeric overflow. */
! #define JAVA_NOT_RADIX10_FLAG(NODE) TREE_LANG_FLAG_0(NODE)
#ifndef JC1_LITE
void java_complete_class (void);