diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0fb72226bab..11704878a53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2009-04-20 Richard Guenther + + * expr.c (handled_component_p): Move ... + * tree.h (handled_component_p): ... here. + * tree.def: Re-order BIT_FIELD_REF, COMPONENT_REF, + ARRAY_REF, ARRAY_RANGE_REF, VIEW_CONVERT_EXPR, IMAGPART_EXPR + and REALPART_EXPR to be in one group. + 2009-04-20 Richard Guenther * basic-block.h (get_all_dominated_blocks): Declare. diff --git a/gcc/expr.c b/gcc/expr.c index cd530d0a4f4..ce740d24d91 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6199,27 +6199,6 @@ component_ref_field_offset (tree exp) else return SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_FIELD_OFFSET (field), exp); } - -/* Return 1 if T is an expression that get_inner_reference handles. */ - -int -handled_component_p (const_tree t) -{ - switch (TREE_CODE (t)) - { - case BIT_FIELD_REF: - case COMPONENT_REF: - case ARRAY_REF: - case ARRAY_RANGE_REF: - case VIEW_CONVERT_EXPR: - case REALPART_EXPR: - case IMAGPART_EXPR: - return 1; - - default: - return 0; - } -} /* Given an rtx VALUE that may contain additions and multiplications, return an equivalent value that just refers to a register, memory, or constant. diff --git a/gcc/tree.def b/gcc/tree.def index a4c524e1807..41a9e908cab 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -383,6 +383,9 @@ DEFTREECODE (TRANSLATION_UNIT_DECL, "translation_unit_decl",\ /* References to storage. */ +/* The ordering of the following codes is optimized for the classification + in handled_component_p. Keep them in a consecutive group. */ + /* Value is structure or union component. Operand 0 is the structure or union (an expression). Operand 1 is the field (a node of type FIELD_DECL). @@ -400,6 +403,23 @@ DEFTREECODE (COMPONENT_REF, "component_ref", tcc_reference, 3) to its mode width. */ DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3) +/* Used only on an operand of complex type, these return + a value of the corresponding component type. */ +DEFTREECODE (REALPART_EXPR, "realpart_expr", tcc_reference, 1) +DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", tcc_reference, 1) + +/* Array indexing. + Operand 0 is the array; operand 1 is a (single) array index. + Operand 2, if present, is a copy of TYPE_MIN_VALUE of the index. + Operand 3, if present, is the element size, measured in units of + the alignment of the element type. */ +DEFTREECODE (ARRAY_REF, "array_ref", tcc_reference, 4) + +/* Likewise, except that the result is a range ("slice") of the array. The + starting index of the resulting array is taken from operand 1 and the size + of the range is taken from the type of the expression. */ +DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4) + /* The ordering of the following codes is optimized for the checking macros in tree.h. Changing the order will degrade the speed of the compiler. INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF. */ @@ -418,18 +438,6 @@ DEFTREECODE (ALIGN_INDIRECT_REF, "align_indirect_ref", tcc_reference, 1) or 0 if the alignment is unknown. */ DEFTREECODE (MISALIGNED_INDIRECT_REF, "misaligned_indirect_ref", tcc_reference, 2) -/* Array indexing. - Operand 0 is the array; operand 1 is a (single) array index. - Operand 2, if present, is a copy of TYPE_MIN_VALUE of the index. - Operand 3, if present, is the element size, measured in units of - the alignment of the element type. */ -DEFTREECODE (ARRAY_REF, "array_ref", tcc_reference, 4) - -/* Likewise, except that the result is a range ("slice") of the array. The - starting index of the resulting array is taken from operand 1 and the size - of the range is taken from the type of the expression. */ -DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4) - /* Used to represent lookup of runtime type dependent data. Often this is a reference to a vtable, but it needn't be. Operands are: OBJ_TYPE_REF_EXPR: An expression that evaluates the value to use. @@ -806,11 +814,6 @@ DEFTREECODE (COMPLEX_EXPR, "complex_expr", tcc_binary, 2) /* Complex conjugate of operand. Used only on complex types. */ DEFTREECODE (CONJ_EXPR, "conj_expr", tcc_unary, 1) -/* Used only on an operand of complex type, these return - a value of the corresponding component type. */ -DEFTREECODE (REALPART_EXPR, "realpart_expr", tcc_reference, 1) -DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", tcc_reference, 1) - /* Nodes for ++ and -- in C. The second arg is how much to increment or decrement by. For a pointer, it would be the size of the object pointed to. */ diff --git a/gcc/tree.h b/gcc/tree.h index c5c855fad23..8902b43254d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4503,7 +4503,24 @@ extern tree get_narrower (tree, int *); /* Return true if T is an expression that get_inner_reference handles. */ -extern int handled_component_p (const_tree); +static inline bool +handled_component_p (const_tree t) +{ + switch (TREE_CODE (t)) + { + case BIT_FIELD_REF: + case COMPONENT_REF: + case ARRAY_REF: + case ARRAY_RANGE_REF: + case VIEW_CONVERT_EXPR: + case REALPART_EXPR: + case IMAGPART_EXPR: + return true; + + default: + return false; + } +} /* Given an expression EXP that is a handled_component_p, look for the ultimate containing object, which is returned and specify