tree.def (ARRAY_RANGE_REF): New code.

* tree.def (ARRAY_RANGE_REF): New code.
	* alias.c (handled_component_p, can_address_p): Handle it.
	* dwarf2out.c (loc_descriptor_from_tree): Likewise.
	* explow.c (set_mem_attributes): Likewise.
	* expr.c (expand_assignment, get_inner_reference): Likewise.
	(expand_expr, expand_expr_unaligned, do_jump): Likewise.
	* fold-const.c (operand_equal_p): Likewise.
	* tree.c (staticp, stabilize_reference): Likewise.
	* varasm.c (decode_addr_const): Likewise.

From-SVN: r42848
This commit is contained in:
Richard Kenner 2001-06-04 13:21:38 +00:00 committed by Richard Kenner
parent c7d468e698
commit b4e3fabb4d
9 changed files with 71 additions and 26 deletions

View File

@ -1,3 +1,15 @@
Mon Jun 4 09:21:19 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* tree.def (ARRAY_RANGE_REF): New code.
* alias.c (handled_component_p, can_address_p): Handle it.
* dwarf2out.c (loc_descriptor_from_tree): Likewise.
* explow.c (set_mem_attributes): Likewise.
* expr.c (expand_assignment, get_inner_reference): Likewise.
(expand_expr, expand_expr_unaligned, do_jump): Likewise.
* fold-const.c (operand_equal_p): Likewise.
* tree.c (staticp, stabilize_reference): Likewise.
* varasm.c (decode_addr_const): Likewise.
Sun Jun 3 21:59:51 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* reload.c (reload_inner_reg_of_subreg): Return 1 for PLUS.

View File

@ -412,6 +412,7 @@ handled_component_p (t)
case BIT_FIELD_REF:
case COMPONENT_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
case NON_LVALUE_EXPR:
return 1;
@ -445,7 +446,7 @@ can_address_p (t)
&& can_address_p (TREE_OPERAND (t, 0)))
return 1;
else if (TREE_CODE (t) == ARRAY_REF
else if ((TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
&& ! TYPE_NONALIASED_COMPONENT (TREE_TYPE (TREE_OPERAND (t, 0)))
&& can_address_p (TREE_OPERAND (t, 0)))
return 1;

View File

@ -7592,6 +7592,7 @@ loc_descriptor_from_tree (loc, addressp)
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
{
tree obj, offset;
HOST_WIDE_INT bitsize, bitpos, bytepos;

View File

@ -1,6 +1,6 @@
/* Subroutines for manipulating rtx's in semantically interesting ways.
Copyright (C) 1987, 1991, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@ -702,6 +702,7 @@ set_mem_attributes (ref, t, objectp)
if (DECL_P (t))
MEM_SCALAR_P (ref) = 1;
else if (TREE_CODE (t) == COMPONENT_REF || TREE_CODE (t) == ARRAY_REF
|| TREE_CODE (t) == ARRAY_RANGE_REF
|| TREE_CODE (t) == BIT_FIELD_REF)
MEM_IN_STRUCT_P (ref) = 1;
}

View File

@ -3675,7 +3675,7 @@ expand_assignment (to, from, want_value, suggest_reg)
problem. */
if (TREE_CODE (to) == COMPONENT_REF || TREE_CODE (to) == BIT_FIELD_REF
|| TREE_CODE (to) == ARRAY_REF)
|| TREE_CODE (to) == ARRAY_REF || TREE_CODE (to) == ARRAY_RANGE_REF)
{
enum machine_mode mode1;
HOST_WIDE_INT bitsize, bitpos;
@ -5333,8 +5333,8 @@ store_field (target, bitsize, bitpos, mode, exp, value_mode,
}
/* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
or an ARRAY_REF, look for nested COMPONENT_REFs, BIT_FIELD_REFs, or
ARRAY_REFs and find the ultimate containing object, which we return.
an ARRAY_REF, or an ARRAY_RANGE_REF, look for nested operations of these
codes and find the ultimate containing object, which we return.
We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
bit position, and *PUNSIGNEDP to the signedness of the field.
@ -5438,12 +5438,14 @@ get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
alignment = MIN (alignment, DECL_OFFSET_ALIGN (field));
}
else if (TREE_CODE (exp) == ARRAY_REF)
else if (TREE_CODE (exp) == ARRAY_REF
|| TREE_CODE (exp) == ARRAY_RANGE_REF)
{
tree index = TREE_OPERAND (exp, 1);
tree domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (exp, 0)));
tree array = TREE_OPERAND (exp, 0);
tree domain = TYPE_DOMAIN (TREE_TYPE (array));
tree low_bound = (domain ? TYPE_MIN_VALUE (domain) : 0);
tree unit_size = TYPE_SIZE_UNIT (TREE_TYPE (exp));
tree unit_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (array)));
/* We assume all arrays have sizes that are a multiple of a byte.
First subtract the lower bound, if any, in the type of the
@ -5461,8 +5463,7 @@ get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
index = build (WITH_RECORD_EXPR, TREE_TYPE (index), index, exp);
if (! TREE_CONSTANT (unit_size)
&& contains_placeholder_p (unit_size))
unit_size = build (WITH_RECORD_EXPR, sizetype, unit_size,
TREE_OPERAND (exp, 0));
unit_size = build (WITH_RECORD_EXPR, sizetype, unit_size, array);
offset = size_binop (PLUS_EXPR, offset,
size_binop (MULT_EXPR,
@ -6117,10 +6118,12 @@ expand_expr (exp, target, tmode, modifier)
return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
VOIDmode, ro_modifier);
else if (TREE_CODE_CLASS (code) == '2' || TREE_CODE_CLASS (code) == '<'
|| code == ARRAY_REF)
|| code == ARRAY_REF || code == ARRAY_RANGE_REF)
{
expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, ro_modifier);
expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode, ro_modifier);
expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
ro_modifier);
expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode,
ro_modifier);
return const0_rtx;
}
else if ((code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
@ -6131,9 +6134,12 @@ expand_expr (exp, target, tmode, modifier)
VOIDmode, ro_modifier);
else if (code == BIT_FIELD_REF)
{
expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, ro_modifier);
expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode, ro_modifier);
expand_expr (TREE_OPERAND (exp, 2), const0_rtx, VOIDmode, ro_modifier);
expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode,
ro_modifier);
expand_expr (TREE_OPERAND (exp, 1), const0_rtx, VOIDmode,
ro_modifier);
expand_expr (TREE_OPERAND (exp, 2), const0_rtx, VOIDmode,
ro_modifier);
return const0_rtx;
}
;
@ -6150,6 +6156,7 @@ expand_expr (exp, target, tmode, modifier)
&& TREE_CODE (exp) != INTEGER_CST
&& TREE_CODE (exp) != PARM_DECL
&& TREE_CODE (exp) != ARRAY_REF
&& TREE_CODE (exp) != ARRAY_RANGE_REF
&& TREE_CODE (exp) != COMPONENT_REF
&& TREE_CODE (exp) != BIT_FIELD_REF
&& TREE_CODE (exp) != INDIRECT_REF
@ -6168,6 +6175,7 @@ expand_expr (exp, target, tmode, modifier)
&& TREE_CODE (exp) != INTEGER_CST
&& TREE_CODE (exp) != PARM_DECL
&& TREE_CODE (exp) != ARRAY_REF
&& TREE_CODE (exp) != ARRAY_RANGE_REF
&& TREE_CODE (exp) != COMPONENT_REF
&& TREE_CODE (exp) != BIT_FIELD_REF
&& TREE_CODE (exp) != INDIRECT_REF
@ -6906,11 +6914,12 @@ expand_expr (exp, target, tmode, modifier)
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_RANGE_REF:
/* If the operand is a CONSTRUCTOR, we can just extract the
appropriate field if it is present. Don't do this if we have
already written the data since we want to refer to that copy
and varasm.c assumes that's what we'll do. */
if (code != ARRAY_REF
if (code == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
&& TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
{
@ -8468,8 +8477,10 @@ expand_expr (exp, target, tmode, modifier)
temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
noncopied_parts = init_noncopied_parts (stabilize_reference (lhs),
TYPE_NONCOPIED_PARTS (lhs_type));
noncopied_parts
= init_noncopied_parts (stabilize_reference (lhs),
TYPE_NONCOPIED_PARTS (lhs_type));
while (noncopied_parts != 0)
{
expand_assignment (TREE_VALUE (noncopied_parts),
@ -8529,8 +8540,9 @@ expand_expr (exp, target, tmode, modifier)
if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
&& ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
noncopied_parts = save_noncopied_parts (stabilize_reference (lhs),
TYPE_NONCOPIED_PARTS (lhs_type));
noncopied_parts
= save_noncopied_parts (stabilize_reference (lhs),
TYPE_NONCOPIED_PARTS (lhs_type));
temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
while (noncopied_parts != 0)
@ -8946,11 +8958,12 @@ expand_expr_unaligned (exp, palign)
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_RANGE_REF:
/* If the operand is a CONSTRUCTOR, we can just extract the
appropriate field if it is present. Don't do this if we have
already written the data since we want to refer to that copy
and varasm.c assumes that's what we'll do. */
if (TREE_CODE (exp) != ARRAY_REF
if (TREE_CODE (exp) == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
&& TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
{
@ -9522,7 +9535,8 @@ do_jump (exp, if_false_label, if_true_label)
case NOP_EXPR:
if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF)
|| TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF
|| TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_RANGE_REF)
goto normal;
case CONVERT_EXPR:
/* If we are narrowing the operand, we have to do the compare in the
@ -9628,6 +9642,7 @@ do_jump (exp, if_false_label, if_true_label)
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
{
HOST_WIDE_INT bitsize, bitpos;
int unsignedp;

View File

@ -2396,6 +2396,7 @@ operand_equal_p (arg0, arg1, only_const)
case COMPONENT_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
return (operand_equal_p (TREE_OPERAND (arg0, 0),
TREE_OPERAND (arg1, 0), 0)
&& operand_equal_p (TREE_OPERAND (arg0, 1),

View File

@ -1518,6 +1518,7 @@ staticp (arg)
#endif
case ARRAY_REF:
case ARRAY_RANGE_REF:
if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
return staticp (TREE_OPERAND (arg, 0));
@ -2209,6 +2210,12 @@ stabilize_reference (ref)
stabilize_reference_1 (TREE_OPERAND (ref, 1)));
break;
case ARRAY_RANGE_REF:
result = build_nt (ARRAY_RANGE_REF,
stabilize_reference (TREE_OPERAND (ref, 0)),
stabilize_reference_1 (TREE_OPERAND (ref, 1)));
break;
case COMPOUND_EXPR:
/* We cannot wrap the first expression in a SAVE_EXPR, as then
it wouldn't be ignored. This matters when dealing with

View File

@ -1,6 +1,7 @@
/* This file contains the definitions and documentation for the
tree codes used in the GNU C compiler.
Copyright (C) 1987, 1988, 1993, 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1987, 1988, 1993, 1995, 1997, 1998, 2000, 2001
Free Software Foundation, Inc.
This file is part of GNU CC.
@ -369,10 +370,15 @@ DEFTREECODE (INDIRECT_REF, "indirect_ref", 'r', 1)
/* Pascal `^` on a file. One operand, an expression for the file. */
DEFTREECODE (BUFFER_REF, "buffer_ref", 'r', 1)
/* Array indexing in languages other than C.
/* Array indexing.
Operand 0 is the array; operand 1 is a (single) array index. */
DEFTREECODE (ARRAY_REF, "array_ref", 'r', 2)
/* Likewise, except that the result is a range of the array. The starting
index of the array is taken from operand 0 and the size of the range
is taken from the type of the expression. */
DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", 'r', 2)
/* Constructor: return an aggregate value made from specified components.
In C, this is used only for structure and array initializers.
Also used for SET_TYPE in Chill (and potentially Pascal).

View File

@ -2180,7 +2180,8 @@ decode_addr_const (exp, value)
offset += int_byte_position (TREE_OPERAND (target, 1));
target = TREE_OPERAND (target, 0);
}
else if (TREE_CODE (target) == ARRAY_REF)
else if (TREE_CODE (target) == ARRAY_REF
|| TREE_CODE (target) == ARRAY_RANGE_REF)
{
offset += (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target)), 1)
* tree_low_cst (TREE_OPERAND (target, 1), 0));