* Clean up usages of TREE_INT_CST_LOW.

* c-parse.in (RESTORE_WARN_FLAGS): Use tree_low_cst.
	* c-parse.y, c-parse.c, objc/objc-parse.y, objc/objc-parse.c:
	Regenerated.
	* c-tree.h (min_precision): Move declaration to here.
	* c-typeck.c (build_binary_op): Use host_integerp and tree_low_cst.
	(build_unary_op, add_pending_init): Use bit_position.
	(pending_init_member, process_init_element): Likewise.
	(really_start_incremental_init, push_init_level, pop_init_level):
	Don't make copies of nodes or modify them in place, use consistent
	types when tracking positions, and use tree routines computations.
	(set_init_index, output_init_element): Likewise.
	(output_pending_init_elements, process_init_element): Likewise.
	* dbxout.c (dbxout_type_fields): Use bit_position, host_integerp,
	tree_low_cst and int_bit_position; also minor cleanup.
	(dbxout_type_method_1, dbxout_range_type, dbxout_type): Likewise.
	(print_cst_octal): Precision is unsigned.
	(dbxout_symbol): Ensure DECL_INITIAL is in-range and use tree_low_cst.
	* dwarf2out.c (ceiling): Input and output are unsigned HOST_WIDE_INT.
	(simple_type_align_in_bits): Result is unsigned int.
	Use tree_int_low_cst and host_integerp.
	(simple_type_size_in_bits): Result is unsigned HOST_WIDE_INT.
	(field_byte_offset): Result is HOST_WIDE_INT.
	Change types of internal variables so alignments are unsigned int,
	offsets are HOST_WIDE_INT and sizes are unsigned HOST_WIDE_INT.
	Use host_integerp, tree_low_cst, and int_bit_position.
	(add_bit_offset_attribute): Likewise.
	(add_data_member_location_attribute): Use tree_cst_low.
	(add_bound_info): Use host_integerp, integer_zerop, and integer_onep.
	(add_bit_size_attribute): Use tree_low_cst.
	(add_pure_or_virtual_attribute, gen_enumeration_type_die): Likewise.
	* dwarfout.c: Similar changes to dwarf2out.c.
	* expr.c (expand_expr, case ARRAY_REF): Remove redundant code.
	* genoutput.c (n_occurences): Return -1 for null string.
	(strip_whitespace): Accept null string and make into function.
	(scan_operands): Reflect above changes.
	* sdbout.c (plain_type_1): Use host_integerp and tree_low_cst.
	(sdbout_field_types, sdbout_one_type): Likewise; also use bit_position.
	* ssa.c (rename_registers): Add missing cast of arg to bzero.
	* tree.c (int_size_in_bytes): Check for too big to represent.
	(bit_position, int_bit_position, host_integerp, tree_low_cst): New fns.
	* tree.h (host_integerp, tree_low_cst, bit_position, int_bit_position):
	New declarations.
	(min_precision): Delete from here.
	* varasm.c (decode_addr_const): Use host_integerp, bit_position,
	and int_bit_position.
	* objc/objc-act.c (encode_method_prototype): Sizes are HOST_WIDE_INT.
	(encode_method_def): Likewise.
	(build_ivar_list_initializer): Use int_bit_position.
	(generate_shared_structures): Convert size.
	(encode_type, encode_complete_bitfield): Use integer_zerop.
	(encode_bitfield): Use tree_low_cst and int_bit_position.
	* ch/typeck.c (min_precision): New function.
	(build_chill_slice): Use host_integerp and tree_low_cst.
	(expand_constant_to_buffer): Likewise and also int_bit_position.
	LO is unsigned HOST_WIDE_INT
	(build_chill_array_ref_1): Make `i' be HOST_WIDE_INT; use tree_low_cst.
	(extract_constant_from_buffer): Sizes are now HOST_WIDE_INT.
	Use host_integerp and tree_low_cst.
	(build_chill_bin_type): Use host_integerp and tree_low_cst.
	(layout_chill_range_type): Use tree_int_cst_sgn, compare_tree_int,
	tree_low_cst, and min_precision.
	(apply_chill_array_layout): Cleanups for types of variables
	and use tree_int_cst_sgn, compare_tree_int, and tree_low_cst.
	(apply_chill_field_layout): Likewise.
	* cp/class.c (build_vbase_path): Use integer_zerop.
	(build_vtable_entry): Use tree_low_cst.
	(get_vfield_offset): Use bit_position.
	(dfs_modify_vtables): New variable vindex_val; `i' is HOST_WIDE_INT.
	Use tree_low_cst.
	(check_bitfield_decl): Set DECL_SIZE using convert.
	(build_base_field): Set DECL_SIZE and DECL_SIZE_UNIT using size_binop.
	(layout_virtual_bases): DSIZE is unsigned HOST_WIDE_INT.
	Use tree_low_cst.
	(finish_struct_1): Use bit_position.
	(dump_class_hierarchy): Use tree_low_cst.
	* cp/cp-tree.h (min_precision): Add declaration.
	* cp/decl.c (xref_tag, xref_basetypes): Use tree_low_cst.
	* cp/error.c (dump_type_suffix): Use host_integerp and tree_low_cst.
	(dump_expr): Use integer_zerop, host_integerp, and tree_low_cst.
	* cp/expr.c (cplus_expand_constant): Use bit_position.
	* cp/init.c (build_vec_init): Use host_integerp and tree_low_cst.
	* cp/rtti.c (get_base_offset): Use bit_position.
	* cp/typeck.c (build_binary_op): Use integer_zerop, compare_tree_int,
	host_integerp, and tree_low_cst.
	(pointer_int_sum): Use integer_zerop.
	(build_component_addr): Use bit_position.
	* java/class.c (make_field_value): Properly handle sizes.
	(get_dispatch_vector): Use tree_low_cst and host_integerp.
	(layout_class_method): Count using trees.
	* java/decl.c (push_promoted_type): Set TYPE_{MIN,MAX}_VALUE with
	copy_node.
	* java/expr.c (java_array_data_offset): Use int_bit_position.
	(build_newarray, build_anewarray): Use host_integerp and tree_low_cst.
	(build_invokevirtual): Use tree_low_cst and do computations with trees.

From-SVN: r32607
This commit is contained in:
Richard Kenner 2000-03-17 17:31:58 +00:00 committed by Richard Kenner
parent 63f034bfe3
commit 665f250366
34 changed files with 756 additions and 605 deletions

View File

@ -1,3 +1,58 @@
Fri Mar 17 08:09:14 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* Clean up usages of TREE_INT_CST_LOW.
* c-parse.in (RESTORE_WARN_FLAGS): Use tree_low_cst.
* c-parse.y, c-parse.c, objc/objc-parse.y, objc/objc-parse.c:
Regenerated.
* c-tree.h (min_precision): Move declaration to here.
* c-typeck.c (build_binary_op): Use host_integerp and tree_low_cst.
(build_unary_op, add_pending_init): Use bit_position.
(pending_init_member, process_init_element): Likewise.
(really_start_incremental_init, push_init_level, pop_init_level):
Don't make copies of nodes or modify them in place, use consistent
types when tracking positions, and use tree routines computations.
(set_init_index, output_init_element): Likewise.
(output_pending_init_elements, process_init_element): Likewise.
* dbxout.c (dbxout_type_fields): Use bit_position, host_integerp,
tree_low_cst and int_bit_position; also minor cleanup.
(dbxout_type_method_1, dbxout_range_type, dbxout_type): Likewise.
(print_cst_octal): Precision is unsigned.
(dbxout_symbol): Ensure DECL_INITIAL is in-range and use tree_low_cst.
* dwarf2out.c (ceiling): Input and output are unsigned HOST_WIDE_INT.
(simple_type_align_in_bits): Result is unsigned int.
Use tree_int_low_cst and host_integerp.
(simple_type_size_in_bits): Result is unsigned HOST_WIDE_INT.
(field_byte_offset): Result is HOST_WIDE_INT.
Change types of internal variables so alignments are unsigned int,
offsets are HOST_WIDE_INT and sizes are unsigned HOST_WIDE_INT.
Use host_integerp, tree_low_cst, and int_bit_position.
(add_bit_offset_attribute): Likewise.
(add_data_member_location_attribute): Use tree_cst_low.
(add_bound_info): Use host_integerp, integer_zerop, and integer_onep.
(add_bit_size_attribute): Use tree_low_cst.
(add_pure_or_virtual_attribute, gen_enumeration_type_die): Likewise.
* dwarfout.c: Similar changes to dwarf2out.c.
* expr.c (expand_expr, case ARRAY_REF): Remove redundant code.
* genoutput.c (n_occurences): Return -1 for null string.
(strip_whitespace): Accept null string and make into function.
(scan_operands): Reflect above changes.
* sdbout.c (plain_type_1): Use host_integerp and tree_low_cst.
(sdbout_field_types, sdbout_one_type): Likewise; also use bit_position.
* ssa.c (rename_registers): Add missing cast of arg to bzero.
* tree.c (int_size_in_bytes): Check for too big to represent.
(bit_position, int_bit_position, host_integerp, tree_low_cst): New fns.
* tree.h (host_integerp, tree_low_cst, bit_position, int_bit_position):
New declarations.
(min_precision): Delete from here.
* varasm.c (decode_addr_const): Use host_integerp, bit_position,
and int_bit_position.
* objc/objc-act.c (encode_method_prototype): Sizes are HOST_WIDE_INT.
(encode_method_def): Likewise.
(build_ivar_list_initializer): Use int_bit_position.
(generate_shared_structures): Convert size.
(encode_type, encode_complete_bitfield): Use integer_zerop.
(encode_bitfield): Use tree_low_cst and int_bit_position.
2000-03-17 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* config/c4x/c4x.h (CPP_SPEC): Fix typo.

View File

@ -129,7 +129,7 @@ static int undeclared_variable_notice;
build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
#define RESTORE_WARN_FLAGS(tval) \
do { \
int val = TREE_INT_CST_LOW (tval); \
int val = tree_low_cst (tval, 0); \
pedantic = val & 1; \
warn_pointer_arith = (val >> 1) & 1; \
} while (0)

View File

@ -235,7 +235,7 @@ static int undeclared_variable_notice;
build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
#define RESTORE_WARN_FLAGS(tval) \
do { \
int val = TREE_INT_CST_LOW (tval); \
int val = tree_low_cst (tval, 0); \
pedantic = val & 1; \
warn_pointer_arith = (val >> 1) & 1; \
} while (0)

View File

@ -210,7 +210,7 @@ static int undeclared_variable_notice;
build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
#define RESTORE_WARN_FLAGS(tval) \
do { \
int val = TREE_INT_CST_LOW (tval); \
int val = tree_low_cst (tval, 0); \
pedantic = val & 1; \
warn_pointer_arith = (val >> 1) & 1; \
} while (0)

View File

@ -170,6 +170,9 @@ extern void c_parse_init PARAMS ((void));
/* in c-aux-info.c */
extern void gen_aux_info_record PARAMS ((tree, int, int, int));
/* In c-common.c */
extern unsigned int min_precision PARAMS ((tree, int));
/* in c-convert.c */
extern tree convert PARAMS ((tree, tree));

View File

@ -2373,8 +2373,10 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
enum tree_code xresultcode = resultcode;
tree val
= shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
if (val != 0)
return val;
op0 = xop0, op1 = xop1;
converted = 1;
resultcode = xresultcode;
@ -2384,7 +2386,6 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
{
int op0_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op0));
int op1_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op1));
int unsignedp0, unsignedp1;
tree primop0 = get_narrower (op0, &unsignedp0);
tree primop1 = get_narrower (op1, &unsignedp1);
@ -2395,11 +2396,12 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
STRIP_TYPE_NOPS (xop1);
/* Give warnings for comparisons between signed and unsigned
quantities that may fail. */
/* Do the checking based on the original operand trees, so that
casts will be considered, but default promotions won't be. */
quantities that may fail.
/* Do not warn if the comparison is being done in a signed type,
Do the checking based on the original operand trees, so that
casts will be considered, but default promotions won't be.
Do not warn if the comparison is being done in a signed type,
since the signed type will only be chosen if it can represent
all the values of the unsigned type. */
if (! TREE_UNSIGNED (result_type))
@ -2410,6 +2412,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
else
{
tree sop, uop;
if (op0_signed)
sop = xop0, uop = xop1;
else
@ -2458,24 +2461,23 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
primop1 = get_narrower (TREE_OPERAND (primop1, 0),
&unsignedp1);
if (TREE_CODE (primop0) == INTEGER_CST
|| TREE_CODE (primop1) == INTEGER_CST)
if (host_integerp (primop0, 0) || host_integerp (primop1, 0))
{
tree primop;
HOST_WIDE_INT constant, mask;
int unsignedp, bits;
if (TREE_CODE (primop0) == INTEGER_CST)
if (host_integerp (primop0, 0))
{
primop = primop1;
unsignedp = unsignedp1;
constant = TREE_INT_CST_LOW (primop0);
constant = tree_low_cst (primop0, 0);
}
else
{
primop = primop0;
unsignedp = unsignedp0;
constant = TREE_INT_CST_LOW (primop1);
constant = tree_low_cst (primop1, 0);
}
bits = TYPE_PRECISION (TREE_TYPE (primop));
@ -3018,10 +3020,10 @@ build_unary_op (code, xarg, noconvert)
addr = convert (argtype, addr);
if (! integer_zerop (DECL_FIELD_BITPOS (field)))
if (! integer_zerop (bit_position (field)))
{
tree offset
= size_binop (EASY_DIV_EXPR, DECL_FIELD_BITPOS (field),
= size_binop (EASY_DIV_EXPR, bit_position (field),
bitsize_int (BITS_PER_UNIT));
int flag = TREE_CONSTANT (addr);
@ -4723,8 +4725,7 @@ static tree constructor_type;
static tree constructor_fields;
/* For an ARRAY_TYPE, this is the specified index
at which to store the next element we get.
This is a special INTEGER_CST node that we modify in place. */
at which to store the next element we get. */
static tree constructor_index;
/* For an ARRAY_TYPE, this is the end index of the range
@ -4739,13 +4740,11 @@ static tree constructor_max_index;
static tree constructor_unfilled_fields;
/* For an ARRAY_TYPE, this is the index of the first element
not yet written out.
This is a special INTEGER_CST node that we modify in place. */
not yet written out. */
static tree constructor_unfilled_index;
/* In a RECORD_TYPE, the byte index of the next consecutive field.
This is so we can generate gaps between fields, when appropriate.
This is a special INTEGER_CST node that we modify in place. */
This is so we can generate gaps between fields, when appropriate. */
static tree constructor_bit_index;
/* If we are saving up the elements rather than allocating them,
@ -5028,8 +5027,9 @@ really_start_incremental_init (type)
while (constructor_fields != 0 && DECL_C_BIT_FIELD (constructor_fields)
&& DECL_NAME (constructor_fields) == 0)
constructor_fields = TREE_CHAIN (constructor_fields);
constructor_unfilled_fields = constructor_fields;
constructor_bit_index = copy_node (size_zero_node);
constructor_bit_index = bitsize_int (0);
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
@ -5039,14 +5039,13 @@ really_start_incremental_init (type)
constructor_max_index
= TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
constructor_index
= copy_node (convert (bitsizetype,
TYPE_MIN_VALUE
(TYPE_DOMAIN (constructor_type))));
= convert (bitsizetype,
TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
}
else
constructor_index = copy_node (bitsize_int (0));
constructor_index = bitsize_int (0);
constructor_unfilled_index = copy_node (constructor_index);
constructor_unfilled_index = constructor_index;
}
else
{
@ -5101,20 +5100,16 @@ push_init_level (implicit)
{
/* Advance to offset of this element. */
if (! tree_int_cst_equal (constructor_bit_index,
DECL_FIELD_BITPOS (constructor_fields)))
{
/* By using unsigned arithmetic, the result will be correct even
in case of overflows, if BITS_PER_UNIT is a power of two. */
unsigned next = (TREE_INT_CST_LOW
(DECL_FIELD_BITPOS (constructor_fields))
/ (unsigned)BITS_PER_UNIT);
unsigned here = (TREE_INT_CST_LOW (constructor_bit_index)
/ (unsigned)BITS_PER_UNIT);
bit_position (constructor_fields)))
assemble_zeros
(tree_low_cst
(size_binop (TRUNC_DIV_EXPR,
size_binop (MINUS_EXPR,
bit_position (constructor_fields),
constructor_bit_index),
bitsize_int (BITS_PER_UNIT)),
1));
assemble_zeros ((next - here)
* (unsigned)BITS_PER_UNIT
/ (unsigned)BITS_PER_UNIT);
}
/* Indicate that we have now filled the structure up to the current
field. */
constructor_unfilled_fields = constructor_fields;
@ -5170,7 +5165,7 @@ push_init_level (implicit)
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
constructor_type = TREE_TYPE (constructor_type);
push_array_bounds (TREE_INT_CST_LOW (constructor_index));
push_array_bounds (tree_low_cst (constructor_index, 0));
constructor_depth++;
if (! tree_int_cst_equal (constructor_index, constructor_unfilled_index)
|| constructor_range_end != 0)
@ -5202,8 +5197,9 @@ push_init_level (implicit)
while (constructor_fields != 0 && DECL_C_BIT_FIELD (constructor_fields)
&& DECL_NAME (constructor_fields) == 0)
constructor_fields = TREE_CHAIN (constructor_fields);
constructor_unfilled_fields = constructor_fields;
constructor_bit_index = copy_node (size_zero_node);
constructor_bit_index = bitsize_int (0);
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
@ -5213,14 +5209,14 @@ push_init_level (implicit)
constructor_max_index
= TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
constructor_index
= copy_node (convert (bitsizetype,
= convert (bitsizetype,
TYPE_MIN_VALUE
(TYPE_DOMAIN (constructor_type))));
(TYPE_DOMAIN (constructor_type)));
}
else
constructor_index = bitsize_int (0);
constructor_unfilled_index = copy_node (constructor_index);
constructor_unfilled_index = constructor_index;
}
else
{
@ -5282,7 +5278,7 @@ pop_init_level (implicit)
int implicit;
{
struct constructor_stack *p;
int size = 0;
HOST_WIDE_INT size = 0;
tree constructor = 0;
if (implicit == 0)
@ -5402,7 +5398,7 @@ pop_init_level (implicit)
/* Find the offset of the end of that field. */
filled = size_binop (CEIL_DIV_EXPR,
constructor_bit_index,
size_int (BITS_PER_UNIT));
bitsize_int (BITS_PER_UNIT));
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
@ -5422,10 +5418,12 @@ pop_init_level (implicit)
in the array, because we start counting at zero. Therefore,
warn only if the value is less than zero. */
if (pedantic
&& (tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
&& (tree_int_cst_sgn
(TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
< 0))
error_with_decl (constructor_decl,
"zero or negative array size `%s'");
layout_type (constructor_type);
size = int_size_in_bytes (constructor_type);
}
@ -5440,7 +5438,7 @@ pop_init_level (implicit)
filled = 0;
if (filled != 0)
assemble_zeros (size - TREE_INT_CST_LOW (filled));
assemble_zeros (size - tree_low_cst (filled, 1));
}
@ -5486,14 +5484,15 @@ set_init_index (first, last)
|| TREE_CODE (first) == NON_LVALUE_EXPR)
&& (TYPE_MODE (TREE_TYPE (first))
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (first, 0)))))
(first) = TREE_OPERAND (first, 0);
first = TREE_OPERAND (first, 0);
if (last)
while ((TREE_CODE (last) == NOP_EXPR
|| TREE_CODE (last) == CONVERT_EXPR
|| TREE_CODE (last) == NON_LVALUE_EXPR)
&& (TYPE_MODE (TREE_TYPE (last))
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (last, 0)))))
(last) = TREE_OPERAND (last, 0);
last = TREE_OPERAND (last, 0);
if (TREE_CODE (first) != INTEGER_CST)
error_init ("nonconstant array index in initializer");
@ -5505,8 +5504,7 @@ set_init_index (first, last)
error_init ("duplicate array index in initializer");
else
{
TREE_INT_CST_LOW (constructor_index) = TREE_INT_CST_LOW (first);
TREE_INT_CST_HIGH (constructor_index) = TREE_INT_CST_HIGH (first);
constructor_index = convert (bitsizetype, first);
if (last != 0 && tree_int_cst_lt (last, first))
error_init ("empty index range in initializer");
@ -5514,7 +5512,8 @@ set_init_index (first, last)
{
if (pedantic)
pedwarn ("ANSI C forbids specifying element to initialize");
constructor_range_end = last;
constructor_range_end = last ? convert (bitsizetype, last) : 0;
}
}
}
@ -5587,8 +5586,8 @@ add_pending_init (purpose, value)
while (*q != NULL)
{
p = *q;
if (tree_int_cst_lt (DECL_FIELD_BITPOS (purpose),
DECL_FIELD_BITPOS (p->purpose)))
if (tree_int_cst_lt (bit_position (purpose),
bit_position (p->purpose)))
q = &p->left;
else if (p->purpose != purpose)
q = &p->right;
@ -5789,8 +5788,8 @@ pending_init_member (field)
{
if (field == p->purpose)
return 1;
else if (tree_int_cst_lt (DECL_FIELD_BITPOS (field),
DECL_FIELD_BITPOS (p->purpose)))
else if (tree_int_cst_lt (bit_position (field),
bit_position (p->purpose)))
p = p->left;
else
p = p->right;
@ -5870,12 +5869,10 @@ output_init_element (value, type, field, pending)
/* If this element doesn't come next in sequence,
put it on constructor_pending_elts. */
if (TREE_CODE (constructor_type) == ARRAY_TYPE
&& !tree_int_cst_equal (field, constructor_unfilled_index))
&& ! tree_int_cst_equal (field, constructor_unfilled_index))
{
if (! duplicate)
/* The copy_node is needed in case field is actually
constructor_index, which is modified in place. */
add_pending_init (copy_node (field),
add_pending_init (field,
digest_init (type, value, require_constant_value,
require_constant_elements));
}
@ -5911,27 +5908,18 @@ output_init_element (value, type, field, pending)
{
/* Structure elements may require alignment.
Do this, if necessary. */
if (TREE_CODE (constructor_type) == RECORD_TYPE)
{
/* Advance to offset of this element. */
if (! tree_int_cst_equal (constructor_bit_index,
DECL_FIELD_BITPOS (field)))
{
/* By using unsigned arithmetic, the result will be
correct even in case of overflows, if BITS_PER_UNIT
is a power of two. */
unsigned next = (TREE_INT_CST_LOW
(DECL_FIELD_BITPOS (field))
/ (unsigned)BITS_PER_UNIT);
unsigned here = (TREE_INT_CST_LOW
(constructor_bit_index)
/ (unsigned)BITS_PER_UNIT);
if (TREE_CODE (constructor_type) == RECORD_TYPE
&& ! tree_int_cst_equal (constructor_bit_index,
bit_position (field)))
/* Advance to offset of this element. */
assemble_zeros
(tree_low_cst
(size_binop (TRUNC_DIV_EXPR,
size_binop (MINUS_EXPR, bit_position (field),
constructor_bit_index),
bitsize_int (BITS_PER_UNIT)),
0));
assemble_zeros ((next - here)
* (unsigned)BITS_PER_UNIT
/ (unsigned)BITS_PER_UNIT);
}
}
output_constant (digest_init (type, value,
require_constant_value,
require_constant_elements),
@ -5941,33 +5929,22 @@ output_init_element (value, type, field, pending)
keep track of end position of last field. */
if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE)
{
tree temp = size_binop (PLUS_EXPR, DECL_FIELD_BITPOS (field),
DECL_SIZE (field));
TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (temp);
TREE_INT_CST_HIGH (constructor_bit_index)
= TREE_INT_CST_HIGH (temp);
}
constructor_bit_index
= size_binop (PLUS_EXPR, bit_position (field),
DECL_SIZE (field));
}
}
/* Advance the variable that indicates sequential elements output. */
if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
tree tem = size_binop (PLUS_EXPR, constructor_unfilled_index,
bitsize_int (1));
TREE_INT_CST_LOW (constructor_unfilled_index)
= TREE_INT_CST_LOW (tem);
TREE_INT_CST_HIGH (constructor_unfilled_index)
= TREE_INT_CST_HIGH (tem);
}
constructor_unfilled_index
= size_binop (PLUS_EXPR, constructor_unfilled_index,
bitsize_int (1));
else if (TREE_CODE (constructor_type) == RECORD_TYPE)
{
constructor_unfilled_fields =
TREE_CHAIN (constructor_unfilled_fields);
constructor_unfilled_fields
= TREE_CHAIN (constructor_unfilled_fields);
/* Skip any nameless bit fields. */
while (constructor_unfilled_fields != 0
&& DECL_C_BIT_FIELD (constructor_unfilled_fields)
@ -6067,8 +6044,8 @@ output_pending_init_elements (all)
constructor_unfilled_fields,
0);
}
else if (tree_int_cst_lt (DECL_FIELD_BITPOS (constructor_unfilled_fields),
DECL_FIELD_BITPOS (elt->purpose)))
else if (tree_int_cst_lt (bit_position (constructor_unfilled_fields),
bit_position (elt->purpose)))
{
/* Advance to the next smaller node. */
if (elt->left)
@ -6094,8 +6071,9 @@ output_pending_init_elements (all)
elt = elt->parent;
elt = elt->parent;
if (elt
&& tree_int_cst_lt (DECL_FIELD_BITPOS (constructor_unfilled_fields),
DECL_FIELD_BITPOS (elt->purpose)))
&& (tree_int_cst_lt
(bit_position (constructor_unfilled_fields),
bit_position (elt->purpose))))
{
next = elt->purpose;
break;
@ -6131,20 +6109,17 @@ output_pending_init_elements (all)
/* Find the offset of the end of that field. */
filled = size_binop (CEIL_DIV_EXPR,
size_binop (PLUS_EXPR,
DECL_FIELD_BITPOS (tail),
bit_position (tail),
DECL_SIZE (tail)),
bitsize_int (BITS_PER_UNIT));
else
filled = bitsize_int (0);
nextpos_tree = size_binop (CEIL_DIV_EXPR,
DECL_FIELD_BITPOS (next),
bit_position (next),
bitsize_int (BITS_PER_UNIT));
TREE_INT_CST_HIGH (constructor_bit_index)
= TREE_INT_CST_HIGH (DECL_FIELD_BITPOS (next));
TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (next));
constructor_bit_index = bit_position (next);
constructor_unfilled_fields = next;
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
@ -6158,20 +6133,13 @@ output_pending_init_elements (all)
= size_binop (MULT_EXPR, next,
convert (bitsizetype, TYPE_SIZE_UNIT
(TREE_TYPE (constructor_type))));
TREE_INT_CST_LOW (constructor_unfilled_index)
= TREE_INT_CST_LOW (next);
TREE_INT_CST_HIGH (constructor_unfilled_index)
= TREE_INT_CST_HIGH (next);
constructor_unfilled_index = next;
}
else
filled = 0;
if (filled)
{
int nextpos = TREE_INT_CST_LOW (nextpos_tree);
assemble_zeros (nextpos - TREE_INT_CST_LOW (filled));
}
assemble_zeros (tree_low_cst (size_diffop (nextpos_tree, filled), 1));
}
else
{
@ -6182,12 +6150,7 @@ output_pending_init_elements (all)
|| TREE_CODE (constructor_type) == UNION_TYPE)
constructor_unfilled_fields = next;
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
TREE_INT_CST_LOW (constructor_unfilled_index)
= TREE_INT_CST_LOW (next);
TREE_INT_CST_HIGH (constructor_unfilled_index)
= TREE_INT_CST_HIGH (next);
}
constructor_unfilled_index = next;
}
/* ELT now points to the node in the pending tree with the next
@ -6305,14 +6268,10 @@ process_init_element (value)
directly output as a constructor. */
{
/* For a record, keep track of end position of last field. */
tree temp = size_binop (PLUS_EXPR,
DECL_FIELD_BITPOS (constructor_fields),
DECL_SIZE (constructor_fields));
TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (temp);
TREE_INT_CST_HIGH (constructor_bit_index)
= TREE_INT_CST_HIGH (temp);
constructor_bit_index
= size_binop (PLUS_EXPR,
bit_position (constructor_fields),
DECL_SIZE (constructor_fields));
constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
/* Skip any nameless bit fields. */
@ -6375,11 +6334,7 @@ process_init_element (value)
/* Do the bookkeeping for an element that was
directly output as a constructor. */
{
TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (DECL_SIZE (constructor_fields));
TREE_INT_CST_HIGH (constructor_bit_index)
= TREE_INT_CST_HIGH (DECL_SIZE (constructor_fields));
constructor_bit_index = DECL_SIZE (constructor_fields);
constructor_unfilled_fields = TREE_CHAIN (constructor_fields);
}
@ -6424,10 +6379,7 @@ process_init_element (value)
constructor_range_end))
{
pedwarn_init ("excess elements in array initializer");
TREE_INT_CST_HIGH (constructor_range_end)
= TREE_INT_CST_HIGH (constructor_max_index);
TREE_INT_CST_LOW (constructor_range_end)
= TREE_INT_CST_LOW (constructor_max_index);
constructor_range_end = constructor_max_index;
}
value = save_expr (value);
@ -6438,29 +6390,21 @@ process_init_element (value)
If there is a range, repeat it till we advance past the range. */
do
{
tree tem;
if (value)
{
push_array_bounds (TREE_INT_CST_LOW (constructor_index));
push_array_bounds (tree_low_cst (constructor_index, 0));
output_init_element (value, elttype, constructor_index, 1);
RESTORE_SPELLING_DEPTH (constructor_depth);
}
tem = size_binop (PLUS_EXPR, constructor_index, bitsize_int (1));
TREE_INT_CST_LOW (constructor_index) = TREE_INT_CST_LOW (tem);
TREE_INT_CST_HIGH (constructor_index) = TREE_INT_CST_HIGH (tem);
constructor_index
= size_binop (PLUS_EXPR, constructor_index, bitsize_int (1));
if (!value)
if (! value)
/* If we are doing the bookkeeping for an element that was
directly output as a constructor,
we must update constructor_unfilled_index. */
{
TREE_INT_CST_LOW (constructor_unfilled_index)
= TREE_INT_CST_LOW (constructor_index);
TREE_INT_CST_HIGH (constructor_unfilled_index)
= TREE_INT_CST_HIGH (constructor_index);
}
directly output as a constructor, we must update
constructor_unfilled_index. */
constructor_unfilled_index = constructor_index;
}
while (! (constructor_range_end == 0
|| tree_int_cst_lt (constructor_range_end,

View File

@ -1,3 +1,19 @@
Fri Mar 17 08:09:14 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* typeck.c (min_precision): New function.
(build_chill_slice): Use host_integerp and tree_low_cst.
(expand_constant_to_buffer): Likewise and also int_bit_position.
LO is unsigned HOST_WIDE_INT
(build_chill_array_ref_1): Make `i' be HOST_WIDE_INT; use tree_low_cst.
(extract_constant_from_buffer): Sizes are now HOST_WIDE_INT.
Use host_integerp and tree_low_cst.
(build_chill_bin_type): Use host_integerp and tree_low_cst.
(layout_chill_range_type): Use tree_int_cst_sgn, compare_tree_int,
tree_low_cst, and min_precision.
(apply_chill_array_layout): Cleanups for types of variables
and use tree_int_cst_sgn, compare_tree_int, and tree_low_cst.
(apply_chill_field_layout): Likewise.
2000-03-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* grant.c (globalize_decl): Constify a char*.

View File

@ -46,6 +46,7 @@ static tree extract_constant_from_buffer PARAMS ((tree, const unsigned char *, i
static int expand_constant_to_buffer PARAMS ((tree, unsigned char *, int));
static tree build_empty_string PARAMS ((tree));
static tree make_chill_pointer_type PARAMS ((tree, enum tree_code));
static unsigned int min_precision PARAMS ((tree, int));
static tree make_chill_range_type PARAMS ((tree, tree, tree));
static void apply_chill_array_layout PARAMS ((tree));
static int field_decl_cmp PARAMS ((tree *, tree*));
@ -243,13 +244,15 @@ build_chill_slice (array, min_value, length)
SET_CH_NOVELTY (slice_type, CH_NOVELTY (array_type));
if (TREE_CONSTANT (array) && TREE_CODE (min_value) == INTEGER_CST
&& TREE_CODE (length) == INTEGER_CST)
if (TREE_CONSTANT (array) && host_integerp (min_value, 0)
&& host_integerp (length, 0))
{
int type_size = int_size_in_bytes (array_type);
unsigned char *buffer = (unsigned char*) alloca (type_size);
int delta = int_size_in_bytes (element_type)
* (TREE_INT_CST_LOW (min_value) - TREE_INT_CST_LOW (domain_min));
unsigned HOST_WIDE_INT type_size = int_size_in_bytes (array_type);
unsigned char *buffer = (unsigned char *) alloca (type_size);
int delta = (int_size_in_bytes (element_type)
* (tree_low_cst (min_value, 0)
- tree_low_cst (domain_min, 0)));
bzero (buffer, type_size);
if (expand_constant_to_buffer (array, buffer, type_size))
{
@ -626,13 +629,14 @@ build_chill_array_ref_1 (array, idx)
else if (TREE_CODE (array) == STRING_CST
&& CH_CHARS_TYPE_P (TREE_TYPE (array)))
{
HOST_WIDE_INT i = TREE_INT_CST_LOW (idx);
HOST_WIDE_INT i = tree_low_cst (idx, 0);
if (i >= 0 && i < TREE_STRING_LENGTH (array))
{
char ch = TREE_STRING_POINTER (array) [i];
return convert_to_class (class,
build_int_2 ((unsigned char)ch, 0));
}
return
convert_to_class
(class,
build_int_2
((unsigned char) TREE_STRING_POINTER (array) [i], 0));
}
}
@ -731,16 +735,18 @@ expand_constant_to_buffer (value, buffer, buf_size)
{
case INTEGER_CST:
{
HOST_WIDE_INT lo = TREE_INT_CST_LOW (value);
unsigned HOST_WIDE_INT lo = TREE_INT_CST_LOW (value);
HOST_WIDE_INT hi = TREE_INT_CST_HIGH (value);
for (i = 0; i < size; i++)
{
/* Doesn't work if host and target BITS_PER_UNIT differ. */
unsigned char byte = lo & ((1 << BITS_PER_UNIT) - 1);
if (BYTES_BIG_ENDIAN)
buffer[size - i - 1] = byte;
else
buffer[i] = byte;
rshift_double (lo, hi, BITS_PER_UNIT, BITS_PER_UNIT * size,
&lo, &hi, 0);
}
@ -770,10 +776,10 @@ expand_constant_to_buffer (value, buffer, buf_size)
tree min_val = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
if (min_val)
{
if (TREE_CODE (min_val) != INTEGER_CST)
if (! host_integerp (min_val, 0))
return 0;
else
min_index = TREE_INT_CST_LOW (min_val);
min_index = tree_low_cst (min_val, 0);
}
}
@ -784,14 +790,15 @@ expand_constant_to_buffer (value, buffer, buf_size)
HOST_WIDE_INT offset;
HOST_WIDE_INT last_index;
tree purpose = TREE_PURPOSE (list);
if (purpose)
{
if (TREE_CODE (purpose) == INTEGER_CST)
last_index = next_index = TREE_INT_CST_LOW (purpose);
if (host_integerp (purpose, 0))
last_index = next_index = tree_low_cst (purpose, 0);
else if (TREE_CODE (purpose) == RANGE_EXPR)
{
next_index = TREE_INT_CST_LOW (TREE_OPERAND(purpose, 0));
last_index = TREE_INT_CST_LOW (TREE_OPERAND(purpose, 1));
next_index = tree_low_cst (TREE_OPERAND (purpose, 0), 0);
last_index = tree_low_cst (TREE_OPERAND (purpose, 1), 0);
}
else
return 0;
@ -816,12 +823,14 @@ expand_constant_to_buffer (value, buffer, buf_size)
{
tree field = TREE_PURPOSE (list);
HOST_WIDE_INT offset;
if (field == NULL_TREE || TREE_CODE (field) != FIELD_DECL)
return 0;
if (DECL_BIT_FIELD (field))
return 0;
offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
/ BITS_PER_UNIT;
offset = int_bit_position (field) / BITS_PER_UNIT;
if (!expand_constant_to_buffer (TREE_VALUE (list),
buffer + offset,
buf_size - offset))
@ -854,10 +863,12 @@ extract_constant_from_buffer (type, buffer, buf_size)
int buf_size;
{
tree value;
int size = int_size_in_bytes (type);
int i;
HOST_WIDE_INT size = int_size_in_bytes (type);
HOST_WIDE_INT i;
if (size < 0 || size > buf_size)
return 0;
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
@ -902,16 +913,18 @@ extract_constant_from_buffer (type, buffer, buf_size)
value = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
if (value)
{
if (TREE_CODE (value) != INTEGER_CST)
if (! host_integerp (value, 0))
return 0;
else
min_index = TREE_INT_CST_LOW (value);
min_index = tree_low_cst (value, 0);
}
value = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
if (value == NULL_TREE || TREE_CODE (value) != INTEGER_CST)
if (value == NULL_TREE || ! host_integerp (value, 0))
return 0;
else
max_index = TREE_INT_CST_LOW (value);
max_index = tree_low_cst (value, 0);
for (cur_index = max_index; cur_index >= min_index; cur_index--)
{
HOST_WIDE_INT offset = (cur_index - min_index) * element_size;
@ -933,8 +946,8 @@ extract_constant_from_buffer (type, buffer, buf_size)
tree field = TYPE_FIELDS (type);
for (; field != NULL_TREE; field = TREE_CHAIN (field))
{
HOST_WIDE_INT offset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)) / BITS_PER_UNIT;
HOST_WIDE_INT offset = int_bit_position (field) / BITS_PER_UNIT;
if (DECL_BIT_FIELD (field))
return 0;
value = extract_constant_from_buffer (TREE_TYPE (field),
@ -953,7 +966,7 @@ extract_constant_from_buffer (type, buffer, buf_size)
case UNION_TYPE:
{
tree longest_variant = NULL_TREE;
int longest_size = 0;
unsigned HOST_WIDE_INT longest_size = 0;
tree field = TYPE_FIELDS (type);
/* This is a kludge. We assume that converting the data to te
@ -966,7 +979,8 @@ extract_constant_from_buffer (type, buffer, buf_size)
for (; field != NULL_TREE; field = TREE_CHAIN (field))
{
int size = TREE_INT_CST_LOW (size_in_bytes (TREE_TYPE (field)));
unsigned HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (field));
if (size > longest_size)
{
@ -974,9 +988,13 @@ extract_constant_from_buffer (type, buffer, buf_size)
longest_variant = field;
}
}
if (longest_variant == NULL_TREE)
return NULL_TREE;
return extract_constant_from_buffer (TREE_TYPE (longest_variant), buffer, buf_size);
return
extract_constant_from_buffer (TREE_TYPE (longest_variant),
buffer, buf_size);
}
case SET_TYPE:
@ -984,26 +1002,32 @@ extract_constant_from_buffer (type, buffer, buf_size)
tree list = NULL_TREE;
int i;
HOST_WIDE_INT min_index, max_index;
if (TYPE_DOMAIN (type) == 0)
return 0;
value = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
if (value == NULL_TREE)
min_index = 0;
else if (TREE_CODE (value) != INTEGER_CST)
else if (! host_integerp (value, 0))
return 0;
else
min_index = TREE_INT_CST_LOW (value);
min_index = tree_low_cst (value, 0);
value = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
if (value == NULL_TREE)
max_index = 0;
else if (TREE_CODE (value) != INTEGER_CST)
else if (! host_integerp (value, 0))
return 0;
else
max_index = TREE_INT_CST_LOW (value);
max_index = tree_low_cst (value, 0);
for (i = max_index + 1 - min_index; --i >= 0; )
{
unsigned char byte = (unsigned char)buffer[i / BITS_PER_UNIT];
unsigned bit_pos = (unsigned)i % (unsigned)BITS_PER_UNIT;
unsigned char byte = (unsigned char) buffer[i / BITS_PER_UNIT];
unsigned bit_pos = (unsigned) i % (unsigned) BITS_PER_UNIT;
if (BYTES_BIG_ENDIAN
? (byte & (1 << (BITS_PER_UNIT - 1 - bit_pos)))
: (byte & (1 << bit_pos)))
@ -1241,14 +1265,16 @@ build_chill_bin_type (size)
tree size;
{
#if 0
int isize;
HOST_WIDE_INT isize;
if (TREE_CODE (size) != INTEGER_CST
|| (isize = TREE_INT_CST_LOW (size), isize <= 0))
if (! host_integerp (size, 1))
{
error ("operand to bin must be a non-negative integer literal");
return error_mark_node;
}
isize = tree_low_cst (size, 1);
if (isize <= TYPE_PRECISION (unsigned_char_type_node))
return unsigned_char_type_node;
if (isize <= TYPE_PRECISION (short_unsigned_type_node))
@ -2500,6 +2526,36 @@ make_chill_range_type (type, lowval, highval)
return itype;
}
/* Return the minimum number of bits needed to represent VALUE in a
signed or unsigned type, UNSIGNEDP says which. */
static unsigned int
min_precision (value, unsignedp)
tree value;
int unsignedp;
{
int log;
/* If the value is negative, compute its negative minus 1. The latter
adjustment is because the absolute value of the largest negative value
is one larger than the largest positive value. This is equivalent to
a bit-wise negation, so use that operation instead. */
if (tree_int_cst_sgn (value) < 0)
value = fold (build1 (BIT_NOT_EXPR, TREE_TYPE (value), value));
/* Return the number of bits needed, taking into account the fact
that we need one more bit for a signed than unsigned type. */
if (integer_zerop (value))
log = 0;
else
log = tree_floor_log2 (value);
return log + 1 + ! unsignedp;
}
tree
layout_chill_range_type (rangetype, must_be_const)
tree rangetype;
@ -2518,30 +2574,31 @@ layout_chill_range_type (rangetype, must_be_const)
{
int binsize;
/* make a range out of it */
/* Make a range out of it */
if (TREE_CODE (highval) != INTEGER_CST)
{
error ("non-constant expression for BIN");
return error_mark_node;
}
binsize = TREE_INT_CST_LOW (highval);
if (binsize < 0)
else if (tree_int_cst_sgn (highval) < 0)
{
error ("expression for BIN must not be negative");
return error_mark_node;
}
if (binsize > 32)
else if (compare_tree_int (highval, 32) > 0)
{
error ("cannot process BIN (>32)");
return error_mark_node;
}
binsize = tree_low_cst (highval, 1);
type = ridpointers [(int) RID_RANGE];
lowval = integer_zero_node;
highval = build_int_2 ((1 << binsize) - 1, 0);
}
if (TREE_CODE (lowval) == ERROR_MARK ||
TREE_CODE (highval) == ERROR_MARK)
if (TREE_CODE (lowval) == ERROR_MARK
|| TREE_CODE (highval) == ERROR_MARK)
return error_mark_node;
if (!CH_COMPATIBLE_CLASSES (lowval, highval))
@ -2578,37 +2635,14 @@ layout_chill_range_type (rangetype, must_be_const)
&& TREE_CODE (lowval) == INTEGER_CST
&& TREE_CODE (highval) == INTEGER_CST)
{
/* The logic of this code has been copied from finish_enum
in c-decl.c. FIXME duplication! */
int precision = 0;
HOST_WIDE_INT maxvalue = TREE_INT_CST_LOW (highval);
HOST_WIDE_INT minvalue = TREE_INT_CST_LOW (lowval);
if (TREE_INT_CST_HIGH (lowval) >= 0
? tree_int_cst_lt (TYPE_MAX_VALUE (unsigned_type_node), highval)
: (tree_int_cst_lt (lowval, TYPE_MIN_VALUE (integer_type_node))
|| tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), highval)))
precision = TYPE_PRECISION (long_long_integer_type_node);
else
{
if (maxvalue > 0)
precision = floor_log2 (maxvalue) + 1;
if (minvalue < 0)
{
/* Compute number of bits to represent magnitude of a
negative value. Add one to MINVALUE since range of
negative numbers includes the power of two. */
int negprecision = floor_log2 (-minvalue - 1) + 1;
if (negprecision > precision)
precision = negprecision;
precision += 1; /* room for sign bit */
}
int unsignedp = tree_int_cst_sgn (lowval) >= 0;
unsigned int precision = MAX (min_precision (highval, unsignedp),
min_precision (lowval, unsignedp));
if (!precision)
precision = 1;
}
type = type_for_size (precision, minvalue >= 0);
type = type_for_size (precision, unsignedp);
}
TREE_TYPE (rangetype) = type;
}
else
@ -2736,7 +2770,9 @@ apply_chill_array_layout (array_type)
tree array_type;
{
tree layout, temp, what, element_type;
int stepsize=0, word, start_bit=0, length, natural_length;
HOST_WIDE_INT stepsize = 0;
HOST_WIDE_INT word, start_bit = 0, length;
HOST_WIDE_INT natural_length;
int stepsize_specified;
int start_bit_error = 0;
int length_error = 0;
@ -2757,8 +2793,10 @@ apply_chill_array_layout (array_type)
&& get_type_precision (TYPE_MIN_VALUE (element_type),
TYPE_MAX_VALUE (element_type)) == 1)
natural_length = 1;
else if (host_integerp (TYPE_SIZE (element_type), 1))
natural_length = tree_low_cst (TYPE_SIZE (element_type), 1);
else
natural_length = TREE_INT_CST_LOW (TYPE_SIZE (element_type));
natural_length = -1;
if (layout == integer_one_node) /* PACK */
{
@ -2774,31 +2812,32 @@ apply_chill_array_layout (array_type)
temp = TREE_VALUE (layout);
if (TREE_VALUE (temp) != NULL_TREE)
{
if (TREE_CODE (TREE_VALUE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_VALUE (temp), 0))
error ("Stepsize in STEP must be an integer constant");
else
{
stepsize = TREE_INT_CST_LOW (TREE_VALUE (temp));
if (stepsize <= 0)
if (tree_int_cst_sgn (TREE_VALUE (temp)) <= 0)
error ("Stepsize in STEP must be > 0");
else
stepsize_specified = 1;
stepsize = tree_low_cst (TREE_VALUE (temp), 1);
if (stepsize != natural_length)
sorry ("Stepsize in STEP must be the natural width of the array element mode");
}
}
temp = TREE_PURPOSE (temp);
if (TREE_CODE (TREE_PURPOSE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_PURPOSE (temp), 0))
error ("Starting word in POS must be an integer constant");
else
{
word = TREE_INT_CST_LOW (TREE_PURPOSE (temp));
if (word < 0)
if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0)
error ("Starting word in POS must be >= 0");
if (word != 0)
if (! integer_zerop (TREE_PURPOSE (temp)))
sorry ("Starting word in POS within STEP must be 0");
word = tree_low_cst (TREE_PURPOSE (temp), 0);
}
length = natural_length;
@ -2806,23 +2845,25 @@ apply_chill_array_layout (array_type)
if (temp != NULL_TREE)
{
int wordsize = TYPE_PRECISION (chill_integer_type_node);
if (TREE_CODE (TREE_PURPOSE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_PURPOSE (temp), 0))
{
error ("Starting bit in POS must be an integer constant");
start_bit_error = 1;
}
else
{
start_bit = TREE_INT_CST_LOW (TREE_PURPOSE (temp));
if (start_bit != 0)
if (! integer_zerop (TREE_PURPOSE (temp)))
sorry ("Starting bit in POS within STEP must be 0");
if (start_bit < 0)
if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0)
{
error ("Starting bit in POS must be >= 0");
start_bit = 0;
start_bit_error = 1;
}
else if (start_bit >= wordsize)
start_bit = tree_low_cst (TREE_PURPOSE (temp), 0);
if (start_bit >= wordsize)
{
error ("Starting bit in POS must be < the width of a word");
start_bit = 0;
@ -2836,28 +2877,29 @@ apply_chill_array_layout (array_type)
what = TREE_PURPOSE (temp);
if (what == integer_zero_node)
{
if (TREE_CODE (TREE_VALUE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_VALUE (temp), 0))
{
error ("Length in POS must be an integer constant");
length_error = 1;
}
else
{
length = TREE_INT_CST_LOW (TREE_VALUE (temp));
length = tree_low_cst (TREE_VALUE (temp), 0);
if (length <= 0)
error ("Length in POS must be > 0");
}
}
else
{
if (TREE_CODE (TREE_VALUE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_VALUE (temp), 0))
{
error ("End bit in POS must be an integer constant");
length_error = 1;
}
else
{
int end_bit = TREE_INT_CST_LOW (TREE_VALUE (temp));
HOST_WIDE_INT end_bit = tree_low_cst (TREE_VALUE (temp), 0);
if (end_bit < start_bit)
{
error ("End bit in POS must be >= the start bit");
@ -2876,10 +2918,9 @@ apply_chill_array_layout (array_type)
length = end_bit - start_bit + 1;
}
}
if (! length_error && length != natural_length)
{
sorry ("The length specified on POS within STEP must be the natural length of the array element type");
}
sorry ("The length specified on POS within STEP must be the natural length of the array element type");
}
}
@ -3053,8 +3094,10 @@ apply_chill_field_layout (decl, next_struct_offset)
if (is_discrete)
natural_length
= get_type_precision (TYPE_MIN_VALUE (type), TYPE_MAX_VALUE (type));
else if (host_integerp (TYPE_SIZE (type), 1))
natural_length = tree_low_cst (TYPE_SIZE (type), 1);
else
natural_length = TREE_INT_CST_LOW (TYPE_SIZE (type));
natural_length = -1;
if (layout == integer_zero_node) /* NOPACK */
{
@ -3082,20 +3125,21 @@ apply_chill_field_layout (decl, next_struct_offset)
natural width of the underlying type. */
temp = TREE_PURPOSE (layout);
if (TREE_CODE (TREE_PURPOSE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_PURPOSE (temp), 0))
{
error ("Starting word in POS must be an integer constant");
pos_error = 1;
}
else
{
word = TREE_INT_CST_LOW (TREE_PURPOSE (temp));
if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0)
{
error ("Starting word in POS must be >= 0");
word = 0;
pos_error = 1;
}
else
word = tree_low_cst (TREE_PURPOSE (temp), 0);
}
wordsize = TYPE_PRECISION (chill_integer_type_node);
@ -3105,7 +3149,7 @@ apply_chill_field_layout (decl, next_struct_offset)
temp = TREE_VALUE (temp);
if (temp != NULL_TREE)
{
if (TREE_CODE (TREE_PURPOSE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_PURPOSE (temp), 0))
{
error ("Starting bit in POS must be an integer constant");
start_bit = *next_struct_offset - offset;
@ -3113,14 +3157,15 @@ apply_chill_field_layout (decl, next_struct_offset)
}
else
{
start_bit = TREE_INT_CST_LOW (TREE_PURPOSE (temp));
if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0)
{
error ("Starting bit in POS must be >= 0");
start_bit = *next_struct_offset - offset;
pos_error = 1;
}
else if (start_bit >= wordsize)
start_bit = tree_low_cst (TREE_PURPOSE (temp), 0);
if (start_bit >= wordsize)
{
error ("Starting bit in POS must be < the width of a word");
start_bit = *next_struct_offset - offset;
@ -3134,32 +3179,34 @@ apply_chill_field_layout (decl, next_struct_offset)
what = TREE_PURPOSE (temp);
if (what == integer_zero_node)
{
if (TREE_CODE (TREE_VALUE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_VALUE (temp), 0))
{
error ("Length in POS must be an integer constant");
pos_error = 1;
}
else
{
length = TREE_INT_CST_LOW (TREE_VALUE (temp));
if (tree_int_cst_sgn (TREE_VALUE (temp)) < 0)
{
error ("Length in POS must be > 0");
length = natural_length;
pos_error = 1;
}
else
length = tree_low_cst (TREE_VALUE (temp), 0);
}
}
else
{
if (TREE_CODE (TREE_VALUE (temp)) != INTEGER_CST)
if (! host_integerp (TREE_VALUE (temp), 0))
{
error ("End bit in POS must be an integer constant");
pos_error = 1;
}
else
{
HOST_WIDE_INT end_bit = TREE_INT_CST_LOW (TREE_VALUE (temp));
HOST_WIDE_INT end_bit = tree_low_cst (TREE_VALUE (temp), 0);
if (end_bit < start_bit)
{

View File

@ -1,3 +1,28 @@
Fri Mar 17 08:09:14 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* class.c (build_vbase_path): Use integer_zerop.
(build_vtable_entry): Use tree_low_cst.
(get_vfield_offset): Use bit_position.
(dfs_modify_vtables): New variable vindex_val; `i' is HOST_WIDE_INT.
Use tree_low_cst.
(check_bitfield_decl): Set DECL_SIZE using convert.
(build_base_field): Set DECL_SIZE and DECL_SIZE_UNIT using size_binop.
(layout_virtual_bases): DSIZE is unsigned HOST_WIDE_INT.
Use tree_low_cst.
(finish_struct_1): Use bit_position.
(dump_class_hierarchy): Use tree_low_cst.
* cp-tree.h (min_precision): Add declaration.
* decl.c (xref_tag, xref_basetypes): Use tree_low_cst.
* error.c (dump_type_suffix): Use host_integerp and tree_low_cst.
(dump_expr): Use integer_zerop, host_integerp, and tree_low_cst.
* expr.c (cplus_expand_constant): Use bit_position.
* init.c (build_vec_init): Use host_integerp and tree_low_cst.
* rtti.c (get_base_offset): Use bit_position.
* typeck.c (build_binary_op): Use integer_zerop, compare_tree_int,
host_integerp, and tree_low_cst.
(pointer_int_sum): Use integer_zerop.
(build_component_addr): Use bit_position.
2000-03-17 Nathan Sidwell <nathan@codesourcery.com>
* typeck.c (require_complete_type): Don't assume size_zero_node.

View File

@ -635,7 +635,7 @@ build_vbase_path (code, type, expr, path, nonnull)
else
offset = BINFO_OFFSET (last);
if (TREE_INT_CST_LOW (offset))
if (! integer_zerop (offset))
{
/* Bash types to make the backend happy. */
offset = cp_convert (type, offset);
@ -691,8 +691,8 @@ build_vtable_entry (delta, vcall_index, entry)
HOST_WIDE_INT idelta;
HOST_WIDE_INT ivindex;
idelta = TREE_INT_CST_LOW (delta);
ivindex = TREE_INT_CST_LOW (vcall_index);
idelta = tree_low_cst (delta, 0);
ivindex = tree_low_cst (vcall_index, 0);
if ((idelta || ivindex)
&& ! DECL_PURE_VIRTUAL_P (TREE_OPERAND (entry, 0)))
{
@ -908,7 +908,7 @@ get_vfield_offset (binfo)
{
tree tmp
= size_binop (FLOOR_DIV_EXPR,
DECL_FIELD_BITPOS (TYPE_VFIELD (BINFO_TYPE (binfo))),
bit_position (TYPE_VFIELD (BINFO_TYPE (binfo))),
bitsize_int (BITS_PER_UNIT));
return size_binop (PLUS_EXPR, convert (sizetype, tmp),
@ -3111,7 +3111,8 @@ dfs_modify_vtables (binfo, data)
tree overrider;
tree vindex;
tree delta;
unsigned HOST_WIDE_INT i;
HOST_WIDE_INT vindex_val, i;
/* Find the function which originally caused this vtable
entry to be present. */
@ -3121,7 +3122,8 @@ dfs_modify_vtables (binfo, data)
fn = skip_rtti_stuff (TYPE_BINFO (BINFO_TYPE (b)),
BINFO_TYPE (b),
&i);
while (i < TREE_INT_CST_LOW (vindex))
vindex_val = tree_low_cst (vindex, 0);
while (i < vindex_val)
{
fn = TREE_CHAIN (fn);
++i;
@ -3685,7 +3687,7 @@ check_bitfield_decl (field)
if (DECL_INITIAL (field))
{
DECL_INITIAL (field) = NULL_TREE;
DECL_SIZE (field) = bitsize_int (TREE_INT_CST_LOW (w));
DECL_SIZE (field) = convert (bitsizetype, w);
DECL_BIT_FIELD (field) = 1;
if (integer_zerop (w))
@ -4268,12 +4270,10 @@ build_base_field (rli, binfo, empty_p, base_align, v)
here. */
*base_align = MAX (*base_align, DECL_ALIGN (decl));
DECL_SIZE (decl)
= size_int (MAX ((HOST_WIDE_INT) TREE_INT_CST_LOW (DECL_SIZE (decl)),
(int) (*base_align)));
= size_binop (MAX_EXPR, DECL_SIZE (decl), bitsize_int (*base_align));
DECL_SIZE_UNIT (decl)
= size_int (MAX (((HOST_WIDE_INT) TREE_INT_CST_LOW
(DECL_SIZE_UNIT (decl))),
(int) *base_align / BITS_PER_UNIT));
= size_binop (MAX_EXPR, DECL_SIZE_UNIT (decl),
size_int (*base_align / BITS_PER_UNIT));
}
if (!integer_zerop (DECL_SIZE (decl)))
@ -4768,10 +4768,11 @@ layout_virtual_bases (t)
tree t;
{
tree vbase;
int dsize;
unsigned HOST_WIDE_INT dsize;
/* DSIZE is the size of the class without the virtual bases. */
dsize = TREE_INT_CST_LOW (TYPE_SIZE (t));
dsize = tree_low_cst (TYPE_SIZE (t), 1);
/* Make every class have alignment of at least one. */
TYPE_ALIGN (t) = MAX (TYPE_ALIGN (t), BITS_PER_UNIT);
@ -4800,7 +4801,7 @@ layout_virtual_bases (t)
/* Every virtual baseclass takes a least a UNIT, so that we can
take it's address and get something different for each base. */
dsize += MAX (BITS_PER_UNIT,
TREE_INT_CST_LOW (CLASSTYPE_SIZE (basetype)));
tree_low_cst (CLASSTYPE_SIZE (basetype), 0));
}
/* Make sure that all of the CLASSTYPE_VBASECLASSES have their
@ -5038,7 +5039,7 @@ layout_class_type (t, empty_p, has_virtual_p,
For C++, we must handle the building of derived classes.
Also, C++ allows static class members. The way that this is
handled is to keep the field name where it is (as the DECL_NAME
of the field), and place the overloaded decl in the DECL_FIELD_BITPOS
of the field), and place the overloaded decl in the bit position
of the field. layout_record and layout_union will know about this.
More C++ hair: inline functions have text in their
@ -5124,7 +5125,7 @@ finish_struct_1 (t)
DECL_FIELD_CONTEXT (vfield) = t;
DECL_FIELD_BITPOS (vfield)
= size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
= size_binop (PLUS_EXPR, offset, bit_position (vfield));
TYPE_VFIELD (t) = vfield;
}
@ -6538,7 +6539,7 @@ dump_class_hierarchy (binfo, indent)
(unsigned long) binfo,
type_as_string (binfo, TS_PLAIN));
fprintf (stderr, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (BINFO_OFFSET (binfo)));
tree_low_cst (BINFO_OFFSET (binfo), 0));
fprintf (stderr, " %s\n",
BINFO_PRIMARY_MARKED_P (binfo) ? "primary" : "");

View File

@ -3116,6 +3116,7 @@ extern tree convert_and_check PARAMS ((tree, tree));
extern void overflow_warning PARAMS ((tree));
extern void unsigned_conversion_warning PARAMS ((tree, tree));
extern void c_apply_type_quals_to_decl PARAMS ((int, tree));
extern unsigned int min_precision PARAMS ((tree, int));
/* Read the rest of the current #-directive line. */
#if USE_CPPLIB

View File

@ -12350,7 +12350,7 @@ xref_tag (code_type_node, name, globalize)
code_type_node = TREE_VALUE (code_type_node);
}
tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node);
tag_code = (enum tag_types) tree_low_cst (code_type_node, 1);
switch (tag_code)
{
case record_type:
@ -12578,7 +12578,7 @@ xref_basetypes (code_type_node, name, ref, binfo)
tree base;
int i, len;
enum tag_types tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node);
enum tag_types tag_code = (enum tag_types) tree_low_cst (code_type_node, 1);
if (tag_code == union_type)
{

View File

@ -721,8 +721,8 @@ dump_type_suffix (t, flags)
OB_PUTC ('[');
if (TYPE_DOMAIN (t))
{
if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == INTEGER_CST)
OB_PUTI (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) + 1);
if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
OB_PUTI (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR)
dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0),
flags & ~TS_EXPR_PARENS);
@ -1477,9 +1477,7 @@ dump_expr (t, flags)
}
else if (type == boolean_type_node)
{
if (t == boolean_false_node
|| (TREE_INT_CST_LOW (t) == 0
&& TREE_INT_CST_HIGH (t) == 0))
if (t == boolean_false_node || integer_zerop (t))
OB_PUTS ("false");
else if (t == boolean_true_node)
OB_PUTS ("true");
@ -1487,7 +1485,7 @@ dump_expr (t, flags)
else if (type == char_type_node)
{
OB_PUTC ('\'');
dump_char (TREE_INT_CST_LOW (t));
dump_char (tree_low_cst (t, 0));
OB_PUTC ('\'');
}
else if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t)
@ -1851,8 +1849,7 @@ dump_expr (t, flags)
OB_PUTS (") 0)");
break;
}
else if (TREE_CODE (idx) == INTEGER_CST
&& TREE_INT_CST_HIGH (idx) == 0)
else if (host_integerp (idx, 0))
{
tree virtuals;
unsigned HOST_WIDE_INT n;
@ -1861,7 +1858,7 @@ dump_expr (t, flags)
t = TYPE_METHOD_BASETYPE (t);
virtuals = TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t));
n = TREE_INT_CST_LOW (idx);
n = tree_low_cst (idx, 0);
/* Map vtable index back one, to allow for the null pointer to
member. */

View File

@ -62,7 +62,7 @@ cplus_expand_constant (cst)
/* Find the offset for the field. */
offset = convert (sizetype,
size_binop (EASY_DIV_EXPR,
DECL_FIELD_BITPOS (member),
bit_position (member),
bitsize_int (BITS_PER_UNIT)));
/* We offset all pointer to data members by 1 so that we

View File

@ -2872,9 +2872,9 @@ build_vec_init (decl, base, maxindex, init, from_array)
if (from_array
|| (TYPE_NEEDS_CONSTRUCTING (type)
&& ! (TREE_CODE (maxindex) == INTEGER_CST
&& ! (host_integerp (maxindex, 0)
&& (num_initialized_elts
== (HOST_WIDE_INT) TREE_INT_CST_LOW (maxindex) + 1))))
== tree_low_cst (maxindex, 0) + 1))))
{
/* If the ITERATOR is equal to -1, then we don't have to loop;
we've already initialized all the elements. */

View File

@ -524,8 +524,7 @@ get_base_offset (binfo, parent)
FORMAT_VBASE_NAME (name, t);
field = lookup_field (parent, get_identifier (name), 0, 0);
offset = size_binop (FLOOR_DIV_EXPR,
DECL_FIELD_BITPOS (field),
offset = size_binop (FLOOR_DIV_EXPR, bit_position (field),
bitsize_int (BITS_PER_UNIT));
offset = convert (sizetype, offset);
}

View File

@ -3512,11 +3512,9 @@ build_binary_op (code, orig_op0, orig_op1)
warning ("right shift count is negative");
else
{
if (TREE_INT_CST_LOW (op1) | TREE_INT_CST_HIGH (op1))
if (! integer_zerop (op1))
short_shift = 1;
if (TREE_INT_CST_HIGH (op1) != 0
|| ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
>= TYPE_PRECISION (type0)))
if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
warning ("right shift count >= width of type");
}
}
@ -3537,9 +3535,7 @@ build_binary_op (code, orig_op0, orig_op1)
{
if (tree_int_cst_lt (op1, integer_zero_node))
warning ("left shift count is negative");
else if (TREE_INT_CST_HIGH (op1) != 0
|| ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
>= TYPE_PRECISION (type0)))
else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
warning ("left shift count >= width of type");
}
/* Convert the shift-count to an integer, regardless of
@ -3561,9 +3557,7 @@ build_binary_op (code, orig_op0, orig_op1)
if (tree_int_cst_lt (op1, integer_zero_node))
warning ("%s rotate count is negative",
(code == LROTATE_EXPR) ? "left" : "right");
else if (TREE_INT_CST_HIGH (op1) != 0
|| ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
>= TYPE_PRECISION (type0)))
else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
warning ("%s rotate count >= width of type",
(code == LROTATE_EXPR) ? "left" : "right");
}
@ -3894,8 +3888,7 @@ build_binary_op (code, orig_op0, orig_op1)
if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
/* We can shorten only if the shift count is less than the
number of bits in the smaller type size. */
&& TREE_INT_CST_HIGH (op1) == 0
&& TYPE_PRECISION (TREE_TYPE (arg0)) > TREE_INT_CST_LOW (op1)
&& compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
/* If arg is sign-extended and then unsigned-shifted,
we can simulate this with a signed shift in arg's type
only if the extended result is at least twice as wide
@ -4009,25 +4002,24 @@ build_binary_op (code, orig_op0, orig_op1)
if (TREE_CODE (primop1) == BIT_NOT_EXPR)
primop1 = get_narrower (TREE_OPERAND (op1, 0), &unsignedp1);
if (TREE_CODE (primop0) == INTEGER_CST
|| TREE_CODE (primop1) == INTEGER_CST)
if (host_integerp (primop0, 0) || host_integerp (primop1, 0))
{
tree primop;
HOST_WIDE_INT constant, mask;
int unsignedp;
unsigned bits;
unsigned int bits;
if (TREE_CODE (primop0) == INTEGER_CST)
if (host_integerp (primop0, 0))
{
primop = primop1;
unsignedp = unsignedp1;
constant = TREE_INT_CST_LOW (primop0);
constant = tree_low_cst (primop0, 0);
}
else
{
primop = primop0;
unsignedp = unsignedp0;
constant = TREE_INT_CST_LOW (primop1);
constant = tree_low_cst (primop1, 0);
}
bits = TYPE_PRECISION (TREE_TYPE (primop));
@ -4157,9 +4149,7 @@ pointer_int_sum (resultcode, ptrop, intop)
/* Needed to make OOPS V2R3 work. */
intop = folded;
if (TREE_CODE (intop) == INTEGER_CST
&& TREE_INT_CST_LOW (intop) == 0
&& TREE_INT_CST_HIGH (intop) == 0)
if (integer_zerop (intop))
return ptrop;
/* If what we are about to multiply by the size of the elements
@ -4295,11 +4285,12 @@ build_component_addr (arg, argtype)
/* This conversion is harmless. */
rval = convert_force (argtype, rval, 0);
if (! integer_zerop (DECL_FIELD_BITPOS (field)))
if (! integer_zerop (bit_position (field)))
{
tree offset = size_binop (EASY_DIV_EXPR, DECL_FIELD_BITPOS (field),
tree offset = size_binop (EASY_DIV_EXPR, bit_position (field),
bitsize_int (BITS_PER_UNIT));
int flag = TREE_CONSTANT (rval);
offset = convert (sizetype, offset);
rval = fold (build (PLUS_EXPR, argtype,
rval, cp_convert (argtype, offset)));

View File

@ -623,29 +623,28 @@ dbxout_type_fields (type)
tree type;
{
tree tem;
/* Output the name, type, position (in bits), size (in bits) of each
field. */
field that we can support. */
for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
{
/* Omit here local type decls until we know how to support them. */
if (TREE_CODE (tem) == TYPE_DECL)
continue;
/* Omit fields whose position or size are variable. */
else if (TREE_CODE (tem) == FIELD_DECL
&& (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
|| TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
continue;
/* Omit here the nameless fields that are used to skip bits. */
else if (DECL_IGNORED_P (tem))
if (TREE_CODE (tem) == TYPE_DECL
/* Omit fields whose position or size are variable or too large to
represent. */
|| (TREE_CODE (tem) == FIELD_DECL
&& (! host_integerp (bit_position (tem), 0)
|| ! host_integerp (DECL_SIZE (tem), 1)))
/* Omit here the nameless fields that are used to skip bits. */
|| DECL_IGNORED_P (tem))
continue;
else if (TREE_CODE (tem) != CONST_DECL)
{
/* Continue the line if necessary,
but not before the first field. */
if (tem != TYPE_FIELDS (type))
{
CONTIN;
}
CONTIN;
if (use_gnu_debug_info_extensions
&& flag_minimal_debug
@ -661,7 +660,7 @@ dbxout_type_fields (type)
dbxout_type (TREE_TYPE (tem), 0, 0);
fputc (',', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
int_bit_position (tem));
fputc (';', asmfile);
continue;
}
@ -691,8 +690,7 @@ dbxout_type_fields (type)
dbxout_type ((TREE_CODE (tem) == FIELD_DECL
&& DECL_BIT_FIELD_TYPE (tem))
? DECL_BIT_FIELD_TYPE (tem)
: TREE_TYPE (tem), 0, 0);
? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0, 0);
if (TREE_CODE (tem) == VAR_DECL)
{
@ -705,22 +703,20 @@ dbxout_type_fields (type)
CHARS (strlen (name));
}
else
{
/* If TEM is non-static, GDB won't understand it. */
fprintf (asmfile, ",0,0;");
}
/* If TEM is non-static, GDB won't understand it. */
fprintf (asmfile, ",0,0;");
}
else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
else
{
fputc (',', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
int_bit_position (tem));
fputc (',', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (DECL_SIZE (tem)));
tree_low_cst (DECL_SIZE (tem), 1));
fputc (';', asmfile);
CHARS (23);
}
CHARS (23);
}
}
}
@ -758,13 +754,15 @@ dbxout_type_method_1 (decl, debug_name)
}
fprintf (asmfile, ":%s;%c%c%c", debug_name,
TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
TREE_PRIVATE (decl) ? '0'
: TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
- (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
if (DECL_VINDEX (decl))
if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
{
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (DECL_VINDEX (decl)));
tree_low_cst (DECL_VINDEX (decl), 0));
fputc (';', asmfile);
dbxout_type (DECL_CONTEXT (decl), 0, 0);
fprintf (asmfile, ";");
@ -959,20 +957,23 @@ dbxout_range_type (type)
else
dbxout_type_index (integer_type_node);
}
if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
if (TYPE_MIN_VALUE (type) != 0
&& host_integerp (TYPE_MIN_VALUE (type), 0))
{
fputc (';', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
tree_low_cst (TYPE_MIN_VALUE (type), 0));
}
else
fprintf (asmfile, ";0");
if (TYPE_MAX_VALUE (type)
&& TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
if (TYPE_MAX_VALUE (type) != 0
&& host_integerp (TYPE_MAX_VALUE (type), 0))
{
fputc (';', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
tree_low_cst (TYPE_MAX_VALUE (type), 0));
fputc (';', asmfile);
}
else
@ -1407,17 +1408,15 @@ dbxout_type (type, full, show_arg_types)
for (i = 0; i < n_baseclasses; i++)
{
tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
if (use_gnu_debug_info_extensions)
{
have_used_extensions = 1;
putc (TREE_VIA_VIRTUAL (child) ? '1'
: '0',
asmfile);
putc (TREE_VIA_PUBLIC (child) ? '2'
: '0',
asmfile);
putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
putc (TREE_VIA_PUBLIC (child) ? '2' : '0', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
(tree_low_cst (BINFO_OFFSET (child), 0)
* BITS_PER_UNIT));
fputc (',', asmfile);
CHARS (15);
dbxout_type (BINFO_TYPE (child), 0, 0);
@ -1432,10 +1431,13 @@ dbxout_type (type, full, show_arg_types)
dbxout_type (BINFO_TYPE (child), full, 0);
fputc (',', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
tree_low_cst (BINFO_OFFSET (child), 0)
* BITS_PER_UNIT);
fputc (',', asmfile);
fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
(tree_low_cst (DECL_SIZE (TYPE_NAME
(BINFO_TYPE (child))), 0)
* BITS_PER_UNIT));
fputc (';', asmfile);
CHARS (20);
}
@ -1451,6 +1453,7 @@ dbxout_type (type, full, show_arg_types)
have_used_extensions = 1;
dbxout_type_methods (type);
}
putc (';', asmfile);
if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
@ -1615,7 +1618,7 @@ print_int_cst_octal (c)
unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
int width = TYPE_PRECISION (TREE_TYPE (c));
unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
/* GDB wants constants with no extra leading "1" bits, so
we need to remove any sign-extension that might be
@ -1928,6 +1931,7 @@ dbxout_symbol (decl, local)
and not written in memory, inform the debugger. */
if (TREE_STATIC (decl) && TREE_READONLY (decl)
&& DECL_INITIAL (decl) != 0
&& host_integerp (DECL_INITIAL (decl), 0)
&& ! TREE_ASM_WRITTEN (decl)
&& (DECL_FIELD_CONTEXT (decl) == NULL_TREE
|| TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
@ -1936,10 +1940,11 @@ dbxout_symbol (decl, local)
{
/* The sun4 assembler does not grok this. */
const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
{
HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
#ifdef DBX_OUTPUT_CONSTANT_SYMBOL
DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
#else

View File

@ -2470,11 +2470,11 @@ static int is_based_loc PARAMS ((rtx));
static dw_loc_descr_ref mem_loc_descriptor PARAMS ((rtx, enum machine_mode mode));
static dw_loc_descr_ref concat_loc_descriptor PARAMS ((rtx, rtx));
static dw_loc_descr_ref loc_descriptor PARAMS ((rtx));
static unsigned ceiling PARAMS ((unsigned, unsigned));
static HOST_WIDE_INT ceiling PARAMS ((HOST_WIDE_INT, unsigned int));
static tree field_type PARAMS ((tree));
static unsigned simple_type_align_in_bits PARAMS ((tree));
static unsigned simple_type_size_in_bits PARAMS ((tree));
static unsigned field_byte_offset PARAMS ((tree));
static unsigned int simple_type_align_in_bits PARAMS ((tree));
static unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
static void add_AT_location_description PARAMS ((dw_die_ref,
enum dwarf_attribute, rtx));
static void add_data_member_location_attribute PARAMS ((dw_die_ref, tree));
@ -6471,13 +6471,13 @@ loc_descriptor (rtl)
return loc_result;
}
/* Given an unsigned value, round it up to the lowest multiple of `boundary'
/* Given a value, round it up to the lowest multiple of `boundary'
which is not less than the value itself. */
static inline unsigned
static inline HOST_WIDE_INT
ceiling (value, boundary)
register unsigned value;
register unsigned boundary;
HOST_WIDE_INT value;
unsigned int boundary;
{
return (((value + boundary - 1) / boundary) * boundary);
}
@ -6521,7 +6521,7 @@ simple_type_align_in_bits (type)
else return BITS_PER_WORD if the type actually turns out to be an
ERROR_MARK node. */
static inline unsigned
static inline unsigned HOST_WIDE_INT
simple_type_size_in_bits (type)
register tree type;
{
@ -6531,10 +6531,10 @@ simple_type_size_in_bits (type)
{
register tree type_size_tree = TYPE_SIZE (type);
if (TREE_CODE (type_size_tree) != INTEGER_CST)
if (! host_integerp (type_size_tree, 1))
return TYPE_ALIGN (type);
return (unsigned) TREE_INT_CST_LOW (type_size_tree);
return tree_low_cst (type_size_tree, 1);
}
}
@ -6545,22 +6545,21 @@ simple_type_size_in_bits (type)
be a pointer to an ERROR_MARK node, or because the offset is actually
variable. (We can't handle the latter case just yet). */
static unsigned
static HOST_WIDE_INT
field_byte_offset (decl)
register tree decl;
{
register unsigned type_align_in_bytes;
register unsigned type_align_in_bits;
register unsigned type_size_in_bits;
register unsigned object_offset_in_align_units;
register unsigned object_offset_in_bits;
register unsigned object_offset_in_bytes;
register tree type;
register tree bitpos_tree;
register tree field_size_tree;
register unsigned bitpos_int;
register unsigned deepest_bitpos;
register unsigned field_size_in_bits;
unsigned int type_align_in_bytes;
unsigned int type_align_in_bits;
unsigned HOST_WIDE_INT type_size_in_bits;
HOST_WIDE_INT object_offset_in_align_units;
HOST_WIDE_INT object_offset_in_bits;
HOST_WIDE_INT object_offset_in_bytes;
tree type;
tree field_size_tree;
HOST_WIDE_INT bitpos_int;
HOST_WIDE_INT deepest_bitpos;
unsigned HOST_WIDE_INT field_size_in_bits;
if (TREE_CODE (decl) == ERROR_MARK)
return 0;
@ -6569,8 +6568,6 @@ field_byte_offset (decl)
abort ();
type = field_type (decl);
bitpos_tree = DECL_FIELD_BITPOS (decl);
field_size_tree = DECL_SIZE (decl);
/* If there was an error, the size could be zero. */
@ -6578,20 +6575,21 @@ field_byte_offset (decl)
{
if (errorcount)
return 0;
abort ();
}
/* We cannot yet cope with fields whose positions are variable, so
for now, when we see such things, we simply return 0. Someday, we may
be able to handle such cases, but it will be damn difficult. */
if (TREE_CODE (bitpos_tree) != INTEGER_CST)
if (! host_integerp (bit_position (decl), 0))
return 0;
bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
bitpos_int = int_bit_position (decl);
/* If we don't know the size of the field, pretend it's a full word. */
if (TREE_CODE (field_size_tree) == INTEGER_CST)
field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
if (host_integerp (field_size_tree, 1))
field_size_in_bits = tree_low_cst (field_size_tree, 1);
else
field_size_in_bits = BITS_PER_WORD;
@ -6727,7 +6725,7 @@ add_data_member_location_attribute (die, decl)
register enum dwarf_location_atom op;
if (TREE_CODE (decl) == TREE_VEC)
offset = TREE_INT_CST_LOW (BINFO_OFFSET (decl));
offset = tree_low_cst (BINFO_OFFSET (decl), 0);
else
offset = field_byte_offset (decl);
@ -7063,8 +7061,6 @@ add_bound_info (subrange_die, bound_attr, bound)
register enum dwarf_attribute bound_attr;
register tree bound;
{
register unsigned bound_value = 0;
/* If this is an Ada unconstrained array type, then don't emit any debug
info because the array bounds are unknown. They are parameterized when
the type is instantiated. */
@ -7078,13 +7074,14 @@ add_bound_info (subrange_die, bound_attr, bound)
/* All fixed-bounds are represented by INTEGER_CST nodes. */
case INTEGER_CST:
bound_value = TREE_INT_CST_LOW (bound);
if (bound_attr == DW_AT_lower_bound
&& ((is_c_family () && bound_value == 0)
|| (is_fortran () && bound_value == 1)))
/* use the default */;
if (! host_integerp (bound, 0)
|| (bound_attr == DW_AT_lower_bound
&& ((is_c_family () && integer_zerop (bound))
|| (is_fortran () && integer_onep (bound)))))
/* use the default */
;
else
add_AT_unsigned (subrange_die, bound_attr, bound_value);
add_AT_unsigned (subrange_die, bound_attr, tree_low_cst (bound, 0));
break;
case CONVERT_EXPR:
@ -7297,13 +7294,12 @@ add_bit_offset_attribute (die, decl)
register dw_die_ref die;
register tree decl;
{
register unsigned object_offset_in_bytes = field_byte_offset (decl);
register tree type = DECL_BIT_FIELD_TYPE (decl);
register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
register unsigned bitpos_int;
register unsigned highest_order_object_bit_offset;
register unsigned highest_order_field_bit_offset;
register unsigned bit_offset;
HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
tree type = DECL_BIT_FIELD_TYPE (decl);
HOST_WIDE_INT bitpos_int;
HOST_WIDE_INT highest_order_object_bit_offset;
HOST_WIDE_INT highest_order_field_bit_offset;
HOST_WIDE_INT unsigned bit_offset;
/* Must be a field and a bit field. */
if (!type
@ -7312,11 +7308,12 @@ add_bit_offset_attribute (die, decl)
/* We can't yet handle bit-fields whose offsets are variable, so if we
encounter such things, just return without generating any attribute
whatsoever. */
if (TREE_CODE (bitpos_tree) != INTEGER_CST)
whatsoever. Likewise for variable or too large size. */
if (! host_integerp (bit_position (decl), 0)
|| ! host_integerp (DECL_SIZE (decl), 1))
return;
bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
bitpos_int = int_bit_position (decl);
/* Note that the bit offset is always the distance (in bits) from the
highest-order bit of the "containing object" to the highest-order bit of
@ -7328,9 +7325,7 @@ add_bit_offset_attribute (die, decl)
if (! BYTES_BIG_ENDIAN)
{
highest_order_field_bit_offset
+= (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 0);
highest_order_object_bit_offset += simple_type_size_in_bits (type);
}
@ -7354,8 +7349,9 @@ add_bit_size_attribute (die, decl)
if (TREE_CODE (decl) != FIELD_DECL
|| ! DECL_BIT_FIELD_TYPE (decl))
abort ();
add_AT_unsigned (die, DW_AT_bit_size,
(unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
if (host_integerp (DECL_SIZE (decl), 1))
add_AT_unsigned (die, DW_AT_bit_size, tree_low_cst (DECL_SIZE (decl), 1));
}
/* If the compiled language is ANSI C, then add a 'prototyped'
@ -7420,10 +7416,12 @@ add_pure_or_virtual_attribute (die, func_decl)
if (DECL_VINDEX (func_decl))
{
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
add_AT_loc (die, DW_AT_vtable_elem_location,
new_loc_descr (DW_OP_constu,
TREE_INT_CST_LOW (DECL_VINDEX (func_decl)),
0));
if (host_integerp (DECL_VINDEX (func_decl), 0))
add_AT_loc (die, DW_AT_vtable_elem_location,
new_loc_descr (DW_OP_constu,
tree_low_cst (DECL_VINDEX (func_decl), 0),
0));
/* GNU extension: Record what type this method came from originally. */
if (debug_info_level > DINFO_LEVEL_TERSE)
@ -7914,8 +7912,10 @@ gen_enumeration_type_die (type, context_die)
add_name_attribute (enum_die,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
add_AT_unsigned (enum_die, DW_AT_const_value,
(unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
if (host_integerp (TREE_VALUE (link), 0))
add_AT_unsigned (enum_die, DW_AT_const_value,
tree_low_cst (TREE_VALUE (link), 0));
}
}
else

View File

@ -331,11 +331,11 @@ static void output_mem_loc_descriptor PARAMS ((rtx));
static void output_loc_descriptor PARAMS ((rtx));
static void output_bound_representation PARAMS ((tree, unsigned, int));
static void output_enumeral_list PARAMS ((tree));
static inline unsigned ceiling PARAMS ((unsigned, unsigned));
static inline HOST_WIDE_INT ceiling PARAMS ((HOST_WIDE_INT, unsigned int));
static inline tree field_type PARAMS ((tree));
static inline unsigned simple_type_align_in_bits PARAMS ((tree));
static inline unsigned simple_type_size_in_bits PARAMS ((tree));
static unsigned field_byte_offset PARAMS ((tree));
static inline unsigned int simple_type_align_in_bits PARAMS ((tree));
static inline unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
static inline void sibling_attribute PARAMS ((void));
static void location_attribute PARAMS ((rtx));
static void data_member_location_attribute PARAMS ((tree));
@ -1806,8 +1806,8 @@ output_bound_representation (bound, dim_num, u_or_l)
/* All fixed-bounds are represented by INTEGER_CST nodes. */
case INTEGER_CST:
ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
(unsigned) TREE_INT_CST_LOW (bound));
if (host_integerp (bound, 0))
ASM_OUTPUT_DWARF_DATA4 (asm_out_file, tree_low_cst (bound, 0));
break;
default:
@ -1881,8 +1881,11 @@ output_enumeral_list (link)
if (link)
{
output_enumeral_list (TREE_CHAIN (link));
ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
(unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
if (host_integerp (TREE_VALUE (link), 0))
ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
tree_low_cst (TREE_VALUE (link), 0));
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
}
@ -1891,10 +1894,10 @@ output_enumeral_list (link)
/* Given an unsigned value, round it up to the lowest multiple of `boundary'
which is not less than the value itself. */
static inline unsigned
static inline HOST_WIDE_INT
ceiling (value, boundary)
register unsigned value;
register unsigned boundary;
register HOST_WIDE_INT value;
register unsigned int boundary;
{
return (((value + boundary - 1) / boundary) * boundary);
}
@ -1922,7 +1925,7 @@ field_type (decl)
node, return the alignment in bits for the type, or else return
BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
static inline unsigned
static inline unsigned int
simple_type_align_in_bits (type)
register tree type;
{
@ -1935,7 +1938,7 @@ simple_type_align_in_bits (type)
constant, or else return BITS_PER_WORD if the type actually turns out
to be an ERROR_MARK node. */
static inline unsigned
static inline unsigned HOST_WIDE_INT
simple_type_size_in_bits (type)
register tree type;
{
@ -1945,10 +1948,10 @@ simple_type_size_in_bits (type)
{
register tree type_size_tree = TYPE_SIZE (type);
if (TREE_CODE (type_size_tree) != INTEGER_CST)
if (! host_integerp (type_size_tree, 1))
return TYPE_ALIGN (type);
return (unsigned) TREE_INT_CST_LOW (type_size_tree);
return tree_low_cst (type_size_tree, 1);
}
}
@ -1959,22 +1962,21 @@ simple_type_size_in_bits (type)
pointer to an ERROR_MARK node, or because the offset is actually variable.
(We can't handle the latter case just yet.) */
static unsigned
static HOST_WIDE_INT
field_byte_offset (decl)
register tree decl;
{
register unsigned type_align_in_bytes;
register unsigned type_align_in_bits;
register unsigned type_size_in_bits;
register unsigned object_offset_in_align_units;
register unsigned object_offset_in_bits;
register unsigned object_offset_in_bytes;
register tree type;
register tree bitpos_tree;
register tree field_size_tree;
register unsigned bitpos_int;
register unsigned deepest_bitpos;
register unsigned field_size_in_bits;
unsigned int type_align_in_bytes;
unsigned int type_align_in_bits;
unsigned HOST_WIDE_INT type_size_in_bits;
HOST_WIDE_INT object_offset_in_align_units;
HOST_WIDE_INT object_offset_in_bits;
HOST_WIDE_INT object_offset_in_bytes;
tree type;
tree field_size_tree;
HOST_WIDE_INT bitpos_int;
HOST_WIDE_INT deepest_bitpos;
unsigned HOST_WIDE_INT field_size_in_bits;
if (TREE_CODE (decl) == ERROR_MARK)
return 0;
@ -1983,8 +1985,6 @@ field_byte_offset (decl)
abort ();
type = field_type (decl);
bitpos_tree = DECL_FIELD_BITPOS (decl);
field_size_tree = DECL_SIZE (decl);
/* If there was an error, the size could be zero. */
@ -1992,24 +1992,22 @@ field_byte_offset (decl)
{
if (errorcount)
return 0;
abort ();
}
/* We cannot yet cope with fields whose positions or sizes are variable,
so for now, when we see such things, we simply return 0. Someday,
we may be able to handle such cases, but it will be damn difficult. */
if (TREE_CODE (bitpos_tree) != INTEGER_CST)
if (! host_integerp (bit_position (decl), 0)
|| ! host_integerp (field_size_tree, 1))
return 0;
bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
if (TREE_CODE (field_size_tree) != INTEGER_CST)
return 0;
field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
bitpos_int = int_bit_position (decl);
field_size_in_bits = tree_low_cst (field_size_tree, 1);
type_size_in_bits = simple_type_size_in_bits (type);
type_align_in_bits = simple_type_align_in_bits (type);
type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
@ -2058,8 +2056,7 @@ field_byte_offset (decl)
The value we deduce is then used (by the callers of this routine) to
generate AT_location and AT_bit_offset attributes for fields (both
bit-fields and, in the case of AT_location, regular fields as well).
*/
bit-fields and, in the case of AT_location, regular fields as well). */
/* Figure out the bit-distance from the start of the structure to the
"deepest" bit of the bit-field. */
@ -2201,7 +2198,7 @@ data_member_location_attribute (t)
char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
if (TREE_CODE (t) == TREE_VEC)
object_offset_in_bytes = TREE_INT_CST_LOW (BINFO_OFFSET (t));
object_offset_in_bytes = tree_low_cst (BINFO_OFFSET (t), 0);
else
object_offset_in_bytes = field_byte_offset (t);
@ -2258,8 +2255,8 @@ const_value_attribute (rtl)
simplicity we always just output CONST_DOUBLEs using 8 bytes. */
ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
(unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
(unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
(unsigned int) CONST_DOUBLE_HIGH (rtl),
(unsigned int) CONST_DOUBLE_LOW (rtl));
break;
case CONST_STRING:
@ -2715,26 +2712,27 @@ static inline void
bit_offset_attribute (decl)
register tree decl;
{
register unsigned object_offset_in_bytes = field_byte_offset (decl);
register tree type = DECL_BIT_FIELD_TYPE (decl);
register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
register unsigned bitpos_int;
register unsigned highest_order_object_bit_offset;
register unsigned highest_order_field_bit_offset;
register unsigned bit_offset;
HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
tree type = DECL_BIT_FIELD_TYPE (decl);
HOST_WIDE_INT bitpos_int;
HOST_WIDE_INT highest_order_object_bit_offset;
HOST_WIDE_INT highest_order_field_bit_offset;
HOST_WIDE_INT bit_offset;
/* Must be a bit field. */
if (!type
|| TREE_CODE (decl) != FIELD_DECL)
abort ();
/* We can't yet handle bit-fields whose offsets are variable, so if we
encounter such things, just return without generating any attribute
whatsoever. */
/* We can't yet handle bit-fields whose offsets or sizes are variable, so
if we encounter such things, just return without generating any
attribute whatsoever. */
if (TREE_CODE (bitpos_tree) != INTEGER_CST)
if (! host_integerp (bit_position (decl), 0)
|| ! host_integerp (DECL_SIZE (decl), 1))
return;
bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
bitpos_int = int_bit_position (decl);
/* Note that the bit offset is always the distance (in bits) from the
highest-order bit of the "containing object" to the highest-order
@ -2747,9 +2745,7 @@ bit_offset_attribute (decl)
if (! BYTES_BIG_ENDIAN)
{
highest_order_field_bit_offset
+= (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 1);
highest_order_object_bit_offset += simple_type_size_in_bits (type);
}
@ -2774,9 +2770,12 @@ bit_size_attribute (decl)
|| ! DECL_BIT_FIELD_TYPE (decl))
abort ();
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
(unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
if (host_integerp (DECL_SIZE (decl), 1))
{
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
tree_low_cst (DECL_SIZE (decl), 1));
}
}
/* The following routine outputs the `element_list' attribute for enumeration

View File

@ -6530,7 +6530,7 @@ expand_expr (exp, target, tmode, modifier)
if (TREE_CODE (init) == CONSTRUCTOR)
{
tree elem = CONSTRUCTOR_ELTS (init);
tree elem;
for (elem = CONSTRUCTOR_ELTS (init);
(elem

View File

@ -103,8 +103,8 @@ struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
static int n_occurrences PARAMS ((int, const char *));
static void strip_whitespace PARAMS ((char *));
static int n_occurrences PARAMS ((int, const char *));
static const char *strip_whitespace PARAMS ((const char *));
/* insns in the machine description are assigned sequential code numbers
that are used by insn-recog.c (produced by genrecog) to communicate
@ -438,13 +438,9 @@ scan_operands (d, part, this_address_p, this_strict_low)
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = this_strict_low;
d->operand[opno].predicate = XSTR (part, 1);
d->operand[opno].constraint = XSTR (part, 2);
if (XSTR (part, 2) != NULL && *XSTR (part, 2) != 0)
{
strip_whitespace (XSTR (part, 2));
d->operand[opno].n_alternatives
= n_occurrences (',', XSTR (part, 2)) + 1;
}
d->operand[opno].constraint = strip_whitespace (XSTR (part, 2));
d->operand[opno].n_alternatives
= n_occurrences (',', d->operand[opno].constraint) + 1;
d->operand[opno].address_p = this_address_p;
d->operand[opno].eliminable = 1;
return;
@ -466,13 +462,9 @@ scan_operands (d, part, this_address_p, this_strict_low)
d->operand[opno].mode = GET_MODE (part);
d->operand[opno].strict_low = 0;
d->operand[opno].predicate = "scratch_operand";
d->operand[opno].constraint = XSTR (part, 1);
if (XSTR (part, 1) != NULL && *XSTR (part, 1) != 0)
{
strip_whitespace (XSTR (part, 1));
d->operand[opno].n_alternatives
= n_occurrences (',', XSTR (part, 1)) + 1;
}
d->operand[opno].constraint = strip_whitespace (XSTR (part, 1));
d->operand[opno].n_alternatives
= n_occurrences (',', d->operand[opno].constraint) + 1;
d->operand[opno].address_p = 0;
d->operand[opno].eliminable = 0;
return;
@ -965,28 +957,43 @@ main (argc, argv)
? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
}
/* Return the number of occurrences of character C in string S or
-1 if S is the null string. */
static int
n_occurrences (c, s)
int c;
const char *s;
{
int n = 0;
if (s == 0 || *s == '\0')
return -1;
while (*s)
n += (*s++ == c);
return n;
}
/* Remove whitespace in `s' by moving up characters until the end. */
static void
strip_whitespace (s)
char *s;
{
char *p = s;
int ch;
/* Remove whitespace in `s' by moving up characters until the end.
Return a new string. */
static const char *
strip_whitespace (s)
const char *s;
{
char *p, *q;
char ch;
if (s == 0)
return 0;
p = q = xmalloc (strlen (s) + 1);
while ((ch = *s++) != '\0')
if (! ISSPACE (ch))
*p++ = ch;
*p = '\0';
return q;
}

View File

@ -1,3 +1,13 @@
Fri Mar 17 08:09:14 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* class.c (make_field_value): Properly handle sizes.
(get_dispatch_vector): Use tree_low_cst and host_integerp.
(layout_class_method): Count using trees.
* decl.c (push_promoted_type): Set TYPE_{MIN,MAX}_VALUE with copy_node.
* expr.c (java_array_data_offset): Use int_bit_position.
(build_newarray, build_anewarray): Use host_integerp and tree_low_cst.
(build_invokevirtual): Use tree_low_cst and do computations with trees.
2000-03-16 Tom Tromey <tromey@cygnus.com>
* lang.c (flag_hash_synchronization): New global.

View File

@ -1073,9 +1073,10 @@ make_field_value (fdecl)
tree fdecl;
{
tree finit, info;
int bsize, flags;
int flags;
tree type = TREE_TYPE (fdecl);
int resolved = is_compiled_class (type);
START_RECORD_CONSTRUCTOR (finit, field_type_node);
PUSH_FIELD_VALUE (finit, "name", build_utf8_ref (DECL_NAME (fdecl)));
if (resolved)
@ -1091,24 +1092,24 @@ make_field_value (fdecl)
flags = get_access_flags_from_decl (fdecl);
if (! resolved)
flags |= 0x8000 /* FIELD_UNRESOLVED_FLAG */;
PUSH_FIELD_VALUE (finit, "accflags", build_int_2 (flags, 0));
bsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (fdecl))) / BITS_PER_UNIT;
PUSH_FIELD_VALUE (finit, "bsize", build_int_2 (bsize, 0));
PUSH_FIELD_VALUE (finit, "bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl)));
if (FIELD_STATIC (fdecl))
{
tree cfield = TREE_CHAIN (TYPE_FIELDS(field_info_union_node));
tree cfield = TREE_CHAIN (TYPE_FIELDS (field_info_union_node));
tree faddr = build_address_of (build_static_field_ref (fdecl));
info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE,
build_tree_list (cfield, faddr));
}
else
{
int boffset
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (fdecl)) / BITS_PER_UNIT;
info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE,
build_tree_list (TYPE_FIELDS(field_info_union_node),
build_int_2 (boffset, 0)));
}
info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE,
build_tree_list (TYPE_FIELDS (field_info_union_node),
build_int_2 ((int_bit_position (fdecl)
/ BITS_PER_UNIT),
0)));
PUSH_FIELD_VALUE (finit, "info", info);
FINISH_RECORD_CONSTRUCTOR (finit);
@ -1152,29 +1153,28 @@ get_dispatch_vector (type)
tree vtable = TYPE_VTABLE (type);
if (vtable == NULL)
{
int i;
HOST_WIDE_INT i;
tree method;
tree super = CLASSTYPE_SUPER (type);
int nvirtuals = TREE_INT_CST_LOW (TYPE_NVIRTUALS (type));
HOST_WIDE_INT nvirtuals = tree_low_cst (TYPE_NVIRTUALS (type), 0);
vtable = make_tree_vec (nvirtuals);
TYPE_VTABLE (type) = vtable;
if (super != NULL_TREE)
{
tree super_vtable = get_dispatch_vector (super);
for ( i = TREE_INT_CST_LOW (TYPE_NVIRTUALS (super)); --i >= 0; )
for (i = tree_low_cst (TYPE_NVIRTUALS (super), 0); --i >= 0; )
TREE_VEC_ELT (vtable, i) = TREE_VEC_ELT (super_vtable, i);
}
for (method = TYPE_METHODS (type); method != NULL_TREE;
method = TREE_CHAIN (method))
{
if (DECL_VINDEX (method) != NULL_TREE
&& TREE_CODE (DECL_VINDEX (method)) == INTEGER_CST)
{
TREE_VEC_ELT (vtable, TREE_INT_CST_LOW (DECL_VINDEX (method)))
= method;
}
}
if (DECL_VINDEX (method) != NULL_TREE
&& host_integerp (DECL_VINDEX (method), 0))
TREE_VEC_ELT (vtable, tree_low_cst (DECL_VINDEX (method), 0))
= method;
}
return vtable;
}
@ -1966,9 +1966,11 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
&& dtable_count)
{
DECL_VINDEX (method_decl) = dtable_count;
dtable_count = build_int_2 (1+TREE_INT_CST_LOW (dtable_count), 0);
dtable_count = fold (build (PLUS_EXPR, integer_type_node,
dtable_count, integer_one_node));
}
}
return dtable_count;
}

View File

@ -401,11 +401,9 @@ push_promoted_type (name, actual_type)
tree in_min = TYPE_MIN_VALUE (actual_type);
tree in_max = TYPE_MAX_VALUE (actual_type);
#endif
TYPE_MIN_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_min),
TREE_INT_CST_HIGH (in_min));
TYPE_MIN_VALUE (type) = copy_node (in_min);
TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
TYPE_MAX_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_max),
TREE_INT_CST_HIGH (in_max));
TYPE_MAX_VALUE (type) = copy_node (in_max);
TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
layout_type (type);

View File

@ -693,8 +693,7 @@ java_array_data_offset (array)
if (data_fld == NULL_TREE)
return size_in_bytes (array_type);
else
return build_int_2 (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (data_fld))
/ BITS_PER_UNIT, 0);
return build_int_2 (int_bit_position (data_fld) / BITS_PER_UNIT, 0);
}
/* Implement array indexing (either as l-value or r-value).
@ -788,8 +787,8 @@ build_newarray (atype_value, length)
{
tree type
= build_java_array_type (decode_newarray_type (atype_value),
TREE_CODE (length) == INTEGER_CST
? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1);
host_integerp (length, 0) == INTEGER_CST
? tree_low_cst (length, 0) : -1);
return build (CALL_EXPR, promote_type (type),
build_address_of (soft_newarray_node),
@ -809,8 +808,8 @@ build_anewarray (class_type, length)
{
tree type
= build_java_array_type (class_type,
TREE_CODE (length) == INTEGER_CST
? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1);
host_integerp (length, 0)
? tree_low_cst (length, 0) : -1);
return build (CALL_EXPR, promote_type (type),
build_address_of (soft_anewarray_node),
@ -1646,14 +1645,15 @@ build_invokevirtual (dtable, method)
tree func;
tree nativecode_ptr_ptr_type_node
= build_pointer_type (nativecode_ptr_type_node);
int method_index = TREE_INT_CST_LOW (DECL_VINDEX (method));
tree method_index = convert (sizetype, DECL_VINDEX (method));
/* Add one to skip "class" field of dtable, and one to skip unused
vtable entry (for C++ compatibility). */
method_index += 2;
method_index
*= int_size_in_bytes (nativecode_ptr_ptr_type_node);
func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node,
dtable, build_int_2 (method_index, 0)));
method_index = size_binop (PLUS_EXPR, method_index, size_int (2));
method_index = size_binop (MULT_EXPR, method_index,
TYPE_SIZE_UNIT (nativecode_ptr_ptr_type_node));
func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable,
convert (nativecode_ptr_ptr_type_node, method_index)));
func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func);
return func;

View File

@ -2819,7 +2819,7 @@ encode_method_prototype (method_decl, func_decl)
tree parms;
int stack_size, i;
tree user_args;
int max_parm_end = 0;
HOST_WIDE_INT max_parm_end = 0;
char buf[40];
tree result;
@ -2835,9 +2835,8 @@ encode_method_prototype (method_decl, func_decl)
for (parms = DECL_ARGUMENTS (func_decl); parms;
parms = TREE_CHAIN (parms))
{
int parm_end = (forwarding_offset (parms)
+ (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms)))
/ BITS_PER_UNIT));
HOST_WIDE_INT parm_end = (forwarding_offset (parms)
+ int_size_in_bytes (parms));
if (!offset_is_register && max_parm_end < parm_end)
max_parm_end = parm_end;
@ -3822,9 +3821,7 @@ build_ivar_list_initializer (type, field_decl)
ivar
= tree_cons
(NULL_TREE,
build_int_2 ((TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field_decl))
/ BITS_PER_UNIT),
0),
build_int_2 ((int_bit_position (field_decl) / BITS_PER_UNIT), 0),
ivar);
initlist = tree_cons (NULL_TREE,
@ -4489,9 +4486,7 @@ generate_shared_structures ()
= build_shared_structure_initializer
(TREE_TYPE (decl),
root_expr, super_expr, name_expr,
build_int_2 ((TREE_INT_CST_LOW (TYPE_SIZE (objc_class_template))
/ BITS_PER_UNIT),
0),
convert (integer_type_node, TYPE_SIZE_UNIT (objc_class_template)),
2 /*CLS_META*/,
UOBJC_CLASS_METHODS_decl,
UOBJC_CLASS_VARIABLES_decl,
@ -4509,11 +4504,9 @@ generate_shared_structures ()
(TREE_TYPE (decl),
build_unary_op (ADDR_EXPR, UOBJC_METACLASS_decl, 0),
super_expr, name_expr,
build_int_2
((TREE_INT_CST_LOW
(TYPE_SIZE (CLASS_STATIC_TEMPLATE (implementation_template)))
/ BITS_PER_UNIT),
0),
convert (integer_type_node,
TYPE_SIZE_UNIT (CLASS_STATIC_TEMPLATE
(implementation_template))),
1 /*CLS_FACTORY*/,
UOBJC_INSTANCE_METHODS_decl,
UOBJC_INSTANCE_VARIABLES_decl,
@ -6726,8 +6719,7 @@ encode_type (type, curtype, format)
if (code == INTEGER_TYPE)
{
if (TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) == 0
&& TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) == 0)
if (integer_zerop (TYPE_MIN_VALUE (type)))
{
/* Unsigned integer types. */
@ -6802,8 +6794,7 @@ encode_complete_bitfield (int position, tree type, int size)
if (code == INTEGER_TYPE)
{
if (TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) == 0
&& TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) == 0)
if (integer_zerop (TYPE_MIN_VALUE (type)))
{
/* Unsigned integer types. */
@ -6865,16 +6856,16 @@ encode_field_decl (field_decl, curtype, format)
if (flag_next_runtime)
{
if (DECL_BIT_FIELD (field_decl))
encode_bitfield (TREE_INT_CST_LOW (DECL_SIZE (field_decl)));
encode_bitfield (tree_low_cst (DECL_SIZE (field_decl), 1));
else
encode_type (TREE_TYPE (field_decl), curtype, format);
}
else
{
if (DECL_BIT_FIELD (field_decl))
encode_complete_bitfield (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field_decl)),
encode_complete_bitfield (int_bit_position (field_decl),
DECL_BIT_FIELD_TYPE (field_decl),
TREE_INT_CST_LOW (DECL_SIZE (field_decl)));
tree_low_cst (DECL_SIZE (field_decl), 1));
else
encode_type (TREE_TYPE (field_decl), curtype, format);
}
@ -7294,7 +7285,7 @@ encode_method_def (func_decl)
{
tree parms;
int stack_size;
int max_parm_end = 0;
HOST_WIDE_INT max_parm_end = 0;
char buffer[40];
tree result;
@ -7307,11 +7298,10 @@ encode_method_def (func_decl)
for (parms = DECL_ARGUMENTS (func_decl); parms;
parms = TREE_CHAIN (parms))
{
int parm_end = (forwarding_offset (parms)
+ (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms)))
/ BITS_PER_UNIT));
HOST_WIDE_INT parm_end = (forwarding_offset (parms)
+ int_size_in_bytes (TREE_TYPE (parms)));
if (!offset_is_register && parm_end > max_parm_end)
if (! offset_is_register && parm_end > max_parm_end)
max_parm_end = parm_end;
}

View File

@ -130,7 +130,7 @@ static int undeclared_variable_notice;
build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
#define RESTORE_WARN_FLAGS(tval) \
do { \
int val = TREE_INT_CST_LOW (tval); \
int val = tree_low_cst (tval, 0); \
pedantic = val & 1; \
warn_pointer_arith = (val >> 1) & 1; \
} while (0)

View File

@ -222,7 +222,7 @@ static int undeclared_variable_notice;
build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
#define RESTORE_WARN_FLAGS(tval) \
do { \
int val = TREE_INT_CST_LOW (tval); \
int val = tree_low_cst (tval, 0); \
pedantic = val & 1; \
warn_pointer_arith = (val >> 1) & 1; \
} while (0)

View File

@ -607,12 +607,14 @@ plain_type_1 (type, level)
if (sdb_n_dims < SDB_MAX_DIM)
sdb_dims[sdb_n_dims++]
= (TYPE_DOMAIN (type)
&& TYPE_MAX_VALUE (TYPE_DOMAIN (type))
&& TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
&& TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
? (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
- TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1)
&& TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != 0
&& TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != 0
&& host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
&& host_integerp (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0)
? (tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), 0)
- tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0) + 1)
: 0);
return PUSH_DERIVED_LEVEL (DT_ARY, m);
}
@ -1089,8 +1091,8 @@ sdbout_field_types (type)
below. */
if (TREE_CODE (tail) == FIELD_DECL
&& DECL_NAME (tail) != 0
&& TREE_CODE (DECL_SIZE (tail)) == INTEGER_CST
&& TREE_CODE (DECL_FIELD_BITPOS (tail)) == INTEGER_CST)
&& ! host_integerp (DECL_SIZE (tail), 1)
&& ! host_integerp (bit_position (tail), 0))
{
if (POINTER_TYPE_P (TREE_TYPE (tail)))
sdbout_one_type (TREE_TYPE (TREE_TYPE (tail)));
@ -1239,7 +1241,7 @@ sdbout_one_type (type)
CONTIN;
PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name));
PUT_SDB_INT_VAL (TREE_INT_CST_LOW (BINFO_OFFSET (child)));
PUT_SDB_INT_VAL (tree_low_cst (BINFO_OFFSET (child), 0));
PUT_SDB_SCL (member_scl);
sdbout_type (BINFO_TYPE (child));
PUT_SDB_ENDEF;
@ -1250,13 +1252,14 @@ sdbout_one_type (type)
if (TREE_CODE (type) == ENUMERAL_TYPE)
for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
{
PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
PUT_SDB_INT_VAL (TREE_INT_CST_LOW (TREE_VALUE (tem)));
PUT_SDB_SCL (C_MOE);
PUT_SDB_TYPE (T_MOE);
PUT_SDB_ENDEF;
}
if (host_integerp (TREE_VALUE (tem), 0))
{
PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
PUT_SDB_INT_VAL (tree_low_cst (TREE_VALUE (tem), 0));
PUT_SDB_SCL (C_MOE);
PUT_SDB_TYPE (T_MOE);
PUT_SDB_ENDEF;
}
else /* record or union type */
for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
@ -1268,8 +1271,8 @@ sdbout_one_type (type)
Also omit non FIELD_DECL nodes that GNU C++ may put here. */
if (TREE_CODE (tem) == FIELD_DECL
&& DECL_NAME (tem) != 0
&& TREE_CODE (DECL_SIZE (tem)) == INTEGER_CST
&& TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
&& host_integerp (DECL_SIZE (tem), 1)
&& host_integerp (bit_position (tem), 0))
{
char *name;
@ -1278,15 +1281,14 @@ sdbout_one_type (type)
PUT_SDB_DEF (name);
if (DECL_BIT_FIELD_TYPE (tem))
{
PUT_SDB_INT_VAL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
PUT_SDB_INT_VAL (int_bit_position (tem));
PUT_SDB_SCL (C_FIELD);
sdbout_type (DECL_BIT_FIELD_TYPE (tem));
PUT_SDB_SIZE (TREE_INT_CST_LOW (DECL_SIZE (tem)));
PUT_SDB_SIZE (tree_low_cst (DECL_SIZE (tem), 1));
}
else
{
PUT_SDB_INT_VAL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem))
/ BITS_PER_UNIT);
PUT_SDB_INT_VAL (int_bit_position (tem) / BITS_PER_UNIT);
PUT_SDB_SCL (member_scl);
sdbout_type (TREE_TYPE (tem));
}

View File

@ -764,7 +764,7 @@ rename_registers (nregs, idom)
VARRAY_RTX_INIT (ssa_rename_from, nregs * 3, "ssa_rename_from");
ssa_rename_to = (rtx *) alloca (nregs * sizeof(rtx));
bzero (ssa_rename_to, nregs * sizeof(rtx));
bzero ((char *) ssa_rename_to, nregs * sizeof(rtx));
rename_block (0, idom);

View File

@ -2301,13 +2301,36 @@ int_size_in_bytes (type)
if (t == 0
|| TREE_CODE (t) != INTEGER_CST
|| TREE_OVERFLOW (t)
|| TREE_INT_CST_HIGH (t) != 0)
|| TREE_INT_CST_HIGH (t) != 0
/* If the result would appear negative, it's too big to represent. */
|| (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)
return -1;
return TREE_INT_CST_LOW (t);
}
/* Return the bit position of FIELD, in bits from the start of the record.
This is a tree of type bitsizetype. */
/* Return the strictest alignment, in bits, that T is known to have. */
tree
bit_position (field)
tree field;
{
return DECL_FIELD_BITPOS (field);
}
/* Likewise, but return as an integer. Abort if it cannot be represented
in that way (since it could be a signed value, we don't have the option
of returning -1 like int_size_in_byte can. */
HOST_WIDE_INT
int_bit_position (field)
tree field;
{
return tree_low_cst (bit_position (field), 0);
}
/* Return the strictest alignment, in bits, that T is known to have. */
unsigned int
expr_align (t)
@ -4107,6 +4130,37 @@ tree_int_cst_lt (t1, t2)
return INT_CST_LT_UNSIGNED (t1, t2);
}
/* Return 1 if T is an INTEGER_CST that can be represented in a single
HOST_WIDE_INT value. If POS is nonzero, the result must be positive. */
int
host_integerp (t, pos)
tree t;
int pos;
{
return (TREE_CODE (t) == INTEGER_CST
&& ! TREE_OVERFLOW (t)
&& ((TREE_INT_CST_HIGH (t) == 0
&& (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
|| (! pos && TREE_INT_CST_HIGH (t) == -1
&& (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)));
}
/* Return the HOST_WIDE_INT least significant bits of T if it is an
INTEGER_CST and there is no overflow. POS is nonzero if the result must
be positive. Abort if we cannot satisfy the above conditions. */
HOST_WIDE_INT
tree_low_cst (t, pos)
tree t;
int pos;
{
if (host_integerp (t, pos))
return TREE_INT_CST_LOW (t);
else
abort ();
}
/* Return the most significant bit of the integer constant T. */
int

View File

@ -1703,6 +1703,8 @@ extern int attribute_list_equal PARAMS ((tree, tree));
extern int attribute_list_contained PARAMS ((tree, tree));
extern int tree_int_cst_equal PARAMS ((tree, tree));
extern int tree_int_cst_lt PARAMS ((tree, tree));
extern int host_integerp PARAMS ((tree, int));
extern HOST_WIDE_INT tree_low_cst PARAMS ((tree, int));
extern int tree_int_cst_msb PARAMS ((tree));
extern int tree_int_cst_sgn PARAMS ((tree));
extern int index_type_equal PARAMS ((tree, tree));
@ -1850,6 +1852,8 @@ extern tree convert PARAMS ((tree, tree));
extern unsigned int expr_align PARAMS ((tree));
extern tree size_in_bytes PARAMS ((tree));
extern HOST_WIDE_INT int_size_in_bytes PARAMS ((tree));
extern tree bit_position PARAMS ((tree));
extern HOST_WIDE_INT int_bit_position PARAMS ((tree));
/* Define data structures, macros, and functions for handling sizes
and the various types used to represent sizes. */
@ -2554,7 +2558,6 @@ extern void print_lang_statistics PARAMS ((void));
/* In c-common.c */
extern tree truthvalue_conversion PARAMS ((tree));
extern unsigned int min_precision PARAMS ((tree, int));
extern void split_specs_attrs PARAMS ((tree, tree *, tree *));
/* In c-decl.c */

View File

@ -2281,10 +2281,12 @@ decode_addr_const (exp, value)
while (1)
{
if (TREE_CODE (target) == COMPONENT_REF
&& (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
== INTEGER_CST))
&& host_integerp (bit_position (TREE_OPERAND (target, 1)), 0))
{
offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
offset
+= int_bit_position (TREE_OPERAND (target, 1)) / BITS_PER_UNIT;
target = TREE_OPERAND (target, 0);
}
else if (TREE_CODE (target) == ARRAY_REF)