1 /* Language-independent node constructors for parse phase of GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* This file contains the low level primitives for operating on tree nodes,
23 including allocation, list operations, interning of identifiers,
24 construction of data type nodes and statement nodes,
25 and construction of type conversion nodes. It also contains
26 tables index by tree code that describe how to take apart
29 It is intended to be language-independent, but occasionally
30 calls language-dependent routines defined (for C) in typecheck.c. */
34 #include "coretypes.h"
47 #include "langhooks.h"
48 #include "tree-iterator.h"
49 #include "basic-block.h"
50 #include "tree-flow.h"
52 /* obstack.[ch] explicitly declined to prototype this. */
53 extern int _obstack_allocated_p (struct obstack
*h
, void *obj
);
55 #ifdef GATHER_STATISTICS
56 /* Statistics-gathering stuff. */
58 int tree_node_counts
[(int) all_kinds
];
59 int tree_node_sizes
[(int) all_kinds
];
61 /* Keep in sync with tree.h:enum tree_node_kind. */
62 static const char * const tree_node_kind_names
[] = {
80 #endif /* GATHER_STATISTICS */
82 /* Unique id for next decl created. */
83 static GTY(()) int next_decl_uid
;
84 /* Unique id for next type created. */
85 static GTY(()) int next_type_uid
= 1;
87 /* Since we cannot rehash a type after it is in the table, we have to
88 keep the hash code. */
90 struct type_hash
GTY(())
96 /* Initial size of the hash table (rounded to next prime). */
97 #define TYPE_HASH_INITIAL_SIZE 1000
99 /* Now here is the hash table. When recording a type, it is added to
100 the slot whose index is the hash code. Note that the hash table is
101 used for several kinds of types (function types, array types and
102 array index range types, for now). While all these live in the
103 same table, they are completely independent, and the hash code is
104 computed differently for each of these. */
106 static GTY ((if_marked ("type_hash_marked_p"), param_is (struct type_hash
)))
107 htab_t type_hash_table
;
109 static void set_type_quals (tree
, int);
110 static int type_hash_eq (const void *, const void *);
111 static hashval_t
type_hash_hash (const void *);
112 static void print_type_hash_statistics (void);
113 static void finish_vector_type (tree
);
114 static int type_hash_marked_p (const void *);
115 static unsigned int type_hash_list (tree
, hashval_t
);
116 static unsigned int attribute_hash_list (tree
, hashval_t
);
118 tree global_trees
[TI_MAX
];
119 tree integer_types
[itk_none
];
126 /* Initialize the hash table of types. */
127 type_hash_table
= htab_create_ggc (TYPE_HASH_INITIAL_SIZE
, type_hash_hash
,
132 /* The name of the object as the assembler will see it (but before any
133 translations made by ASM_OUTPUT_LABELREF). Often this is the same
134 as DECL_NAME. It is an IDENTIFIER_NODE. */
136 decl_assembler_name (tree decl
)
138 if (!DECL_ASSEMBLER_NAME_SET_P (decl
))
139 lang_hooks
.set_decl_assembler_name (decl
);
140 return DECL_CHECK (decl
)->decl
.assembler_name
;
143 /* Compute the number of bytes occupied by 'node'. This routine only
144 looks at TREE_CODE and, if the code is TREE_VEC, TREE_VEC_LENGTH. */
146 tree_size (tree node
)
148 enum tree_code code
= TREE_CODE (node
);
150 switch (TREE_CODE_CLASS (code
))
152 case 'd': /* A decl node */
153 return sizeof (struct tree_decl
);
155 case 't': /* a type node */
156 return sizeof (struct tree_type
);
158 case 'r': /* a reference */
159 case 'e': /* an expression */
160 case 's': /* an expression with side effects */
161 case '<': /* a comparison expression */
162 case '1': /* a unary arithmetic expression */
163 case '2': /* a binary arithmetic expression */
164 return (sizeof (struct tree_exp
)
165 + TREE_CODE_LENGTH (code
) * sizeof (char *) - sizeof (char *));
167 case 'c': /* a constant */
170 case INTEGER_CST
: return sizeof (struct tree_int_cst
);
171 case REAL_CST
: return sizeof (struct tree_real_cst
);
172 case COMPLEX_CST
: return sizeof (struct tree_complex
);
173 case VECTOR_CST
: return sizeof (struct tree_vector
);
174 case STRING_CST
: return sizeof (struct tree_string
);
176 return lang_hooks
.tree_size (code
);
179 case 'x': /* something random, like an identifier. */
182 case IDENTIFIER_NODE
: return lang_hooks
.identifier_size
;
183 case TREE_LIST
: return sizeof (struct tree_list
);
184 case TREE_VEC
: return (sizeof (struct tree_vec
)
185 + TREE_VEC_LENGTH(node
) * sizeof(char *)
189 case PLACEHOLDER_EXPR
: return sizeof (struct tree_common
);
191 case PHI_NODE
: return (sizeof (struct tree_phi_node
)
192 + (PHI_ARG_CAPACITY (node
) - 1) *
193 sizeof (struct phi_arg_d
));
195 case EPHI_NODE
: return (sizeof (struct tree_ephi_node
)
196 + (EPHI_ARG_CAPACITY (node
) - 1) *
197 sizeof (struct ephi_arg_d
));
199 case SSA_NAME
: return sizeof (struct tree_ssa_name
);
200 case EUSE_NODE
: return sizeof (struct tree_euse_node
);
203 case EEXIT_NODE
: return sizeof (struct tree_eref_common
);
205 case STATEMENT_LIST
: return sizeof (struct tree_statement_list
);
206 case BLOCK
: return sizeof (struct tree_block
);
209 return lang_hooks
.tree_size (code
);
217 /* Return a newly allocated node of code CODE.
218 For decl and type nodes, some other fields are initialized.
219 The rest of the node is initialized to zero.
221 Achoo! I got a code in the node. */
224 make_node_stat (enum tree_code code MEM_STAT_DECL
)
227 int type
= TREE_CODE_CLASS (code
);
229 #ifdef GATHER_STATISTICS
232 struct tree_common ttmp
;
234 /* We can't allocate a TREE_VEC, PHI_NODE, EPHI_NODE or STRING_CST
235 without knowing how many elements it will have. */
236 if (code
== TREE_VEC
|| code
== PHI_NODE
|| code
== EPHI_NODE
)
239 TREE_SET_CODE ((tree
)&ttmp
, code
);
240 length
= tree_size ((tree
)&ttmp
);
242 #ifdef GATHER_STATISTICS
245 case 'd': /* A decl node */
249 case 't': /* a type node */
253 case 's': /* an expression with side effects */
257 case 'r': /* a reference */
261 case 'e': /* an expression */
262 case '<': /* a comparison expression */
263 case '1': /* a unary arithmetic expression */
264 case '2': /* a binary arithmetic expression */
268 case 'c': /* a constant */
272 case 'x': /* something random, like an identifier. */
273 if (code
== IDENTIFIER_NODE
)
275 else if (code
== TREE_VEC
)
277 else if (code
== PHI_NODE
)
279 else if (code
== SSA_NAME
)
280 kind
= ssa_name_kind
;
281 else if (code
== BLOCK
)
291 tree_node_counts
[(int) kind
]++;
292 tree_node_sizes
[(int) kind
] += length
;
295 t
= ggc_alloc_zone_stat (length
, tree_zone PASS_MEM_STAT
);
297 memset (t
, 0, length
);
299 TREE_SET_CODE (t
, code
);
304 TREE_SIDE_EFFECTS (t
) = 1;
308 if (code
!= FUNCTION_DECL
)
310 DECL_USER_ALIGN (t
) = 0;
311 DECL_IN_SYSTEM_HEADER (t
) = in_system_header
;
312 DECL_SOURCE_LOCATION (t
) = input_location
;
313 DECL_UID (t
) = next_decl_uid
++;
315 /* We have not yet computed the alias set for this declaration. */
316 DECL_POINTER_ALIAS_SET (t
) = -1;
320 TYPE_UID (t
) = next_type_uid
++;
321 TYPE_ALIGN (t
) = char_type_node
? TYPE_ALIGN (char_type_node
) : 0;
322 TYPE_USER_ALIGN (t
) = 0;
323 TYPE_MAIN_VARIANT (t
) = t
;
325 /* Default to no attributes for type, but let target change that. */
326 TYPE_ATTRIBUTES (t
) = NULL_TREE
;
327 targetm
.set_default_type_attributes (t
);
329 /* We have not yet computed the alias set for this type. */
330 TYPE_ALIAS_SET (t
) = -1;
334 TREE_CONSTANT (t
) = 1;
335 TREE_INVARIANT (t
) = 1;
345 case PREDECREMENT_EXPR
:
346 case PREINCREMENT_EXPR
:
347 case POSTDECREMENT_EXPR
:
348 case POSTINCREMENT_EXPR
:
349 /* All of these have side-effects, no matter what their
351 TREE_SIDE_EFFECTS (t
) = 1;
363 /* Return a new node with the same contents as NODE except that its
364 TREE_CHAIN is zero and it has a fresh uid. */
367 copy_node_stat (tree node MEM_STAT_DECL
)
370 enum tree_code code
= TREE_CODE (node
);
373 #ifdef ENABLE_CHECKING
374 if (code
== STATEMENT_LIST
)
378 length
= tree_size (node
);
379 t
= ggc_alloc_zone_stat (length
, tree_zone PASS_MEM_STAT
);
380 memcpy (t
, node
, length
);
383 TREE_ASM_WRITTEN (t
) = 0;
384 TREE_VISITED (t
) = 0;
387 if (TREE_CODE_CLASS (code
) == 'd')
388 DECL_UID (t
) = next_decl_uid
++;
389 else if (TREE_CODE_CLASS (code
) == 't')
391 TYPE_UID (t
) = next_type_uid
++;
392 /* The following is so that the debug code for
393 the copy is different from the original type.
394 The two statements usually duplicate each other
395 (because they clear fields of the same union),
396 but the optimizer should catch that. */
397 TYPE_SYMTAB_POINTER (t
) = 0;
398 TYPE_SYMTAB_ADDRESS (t
) = 0;
404 /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
405 For example, this can copy a list made of TREE_LIST nodes. */
408 copy_list (tree list
)
416 head
= prev
= copy_node (list
);
417 next
= TREE_CHAIN (list
);
420 TREE_CHAIN (prev
) = copy_node (next
);
421 prev
= TREE_CHAIN (prev
);
422 next
= TREE_CHAIN (next
);
428 /* Return a newly constructed INTEGER_CST node whose constant value
429 is specified by the two ints LOW and HI.
430 The TREE_TYPE is set to `int'.
432 This function should be used via the `build_int_2' macro. */
435 build_int_2_wide (unsigned HOST_WIDE_INT low
, HOST_WIDE_INT hi
)
437 tree t
= make_node (INTEGER_CST
);
439 TREE_INT_CST_LOW (t
) = low
;
440 TREE_INT_CST_HIGH (t
) = hi
;
441 TREE_TYPE (t
) = integer_type_node
;
445 /* Return a new VECTOR_CST node whose type is TYPE and whose values
446 are in a list pointed by VALS. */
449 build_vector (tree type
, tree vals
)
451 tree v
= make_node (VECTOR_CST
);
452 int over1
= 0, over2
= 0;
455 TREE_VECTOR_CST_ELTS (v
) = vals
;
456 TREE_TYPE (v
) = type
;
458 /* Iterate through elements and check for overflow. */
459 for (link
= vals
; link
; link
= TREE_CHAIN (link
))
461 tree value
= TREE_VALUE (link
);
463 over1
|= TREE_OVERFLOW (value
);
464 over2
|= TREE_CONSTANT_OVERFLOW (value
);
467 TREE_OVERFLOW (v
) = over1
;
468 TREE_CONSTANT_OVERFLOW (v
) = over2
;
473 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
474 are in a list pointed to by VALS. */
476 build_constructor (tree type
, tree vals
)
478 tree c
= make_node (CONSTRUCTOR
);
479 TREE_TYPE (c
) = type
;
480 CONSTRUCTOR_ELTS (c
) = vals
;
482 /* ??? May not be necessary. Mirrors what build does. */
485 TREE_SIDE_EFFECTS (c
) = TREE_SIDE_EFFECTS (vals
);
486 TREE_READONLY (c
) = TREE_READONLY (vals
);
487 TREE_CONSTANT (c
) = TREE_CONSTANT (vals
);
488 TREE_INVARIANT (c
) = TREE_INVARIANT (vals
);
494 /* Return a new REAL_CST node whose type is TYPE and value is D. */
497 build_real (tree type
, REAL_VALUE_TYPE d
)
503 /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE.
504 Consider doing it via real_convert now. */
506 v
= make_node (REAL_CST
);
507 dp
= ggc_alloc (sizeof (REAL_VALUE_TYPE
));
508 memcpy (dp
, &d
, sizeof (REAL_VALUE_TYPE
));
510 TREE_TYPE (v
) = type
;
511 TREE_REAL_CST_PTR (v
) = dp
;
512 TREE_OVERFLOW (v
) = TREE_CONSTANT_OVERFLOW (v
) = overflow
;
516 /* Return a new REAL_CST node whose type is TYPE
517 and whose value is the integer value of the INTEGER_CST node I. */
520 real_value_from_int_cst (tree type
, tree i
)
524 /* Clear all bits of the real value type so that we can later do
525 bitwise comparisons to see if two values are the same. */
526 memset (&d
, 0, sizeof d
);
528 real_from_integer (&d
, type
? TYPE_MODE (type
) : VOIDmode
,
529 TREE_INT_CST_LOW (i
), TREE_INT_CST_HIGH (i
),
530 TYPE_UNSIGNED (TREE_TYPE (i
)));
534 /* Given a tree representing an integer constant I, return a tree
535 representing the same value as a floating-point constant of type TYPE. */
538 build_real_from_int_cst (tree type
, tree i
)
541 int overflow
= TREE_OVERFLOW (i
);
543 v
= build_real (type
, real_value_from_int_cst (type
, i
));
545 TREE_OVERFLOW (v
) |= overflow
;
546 TREE_CONSTANT_OVERFLOW (v
) |= overflow
;
550 /* Return a newly constructed STRING_CST node whose value is
551 the LEN characters at STR.
552 The TREE_TYPE is not initialized. */
555 build_string (int len
, const char *str
)
557 tree s
= make_node (STRING_CST
);
559 TREE_STRING_LENGTH (s
) = len
;
560 TREE_STRING_POINTER (s
) = ggc_alloc_string (str
, len
);
565 /* Return a newly constructed COMPLEX_CST node whose value is
566 specified by the real and imaginary parts REAL and IMAG.
567 Both REAL and IMAG should be constant nodes. TYPE, if specified,
568 will be the type of the COMPLEX_CST; otherwise a new type will be made. */
571 build_complex (tree type
, tree real
, tree imag
)
573 tree t
= make_node (COMPLEX_CST
);
575 TREE_REALPART (t
) = real
;
576 TREE_IMAGPART (t
) = imag
;
577 TREE_TYPE (t
) = type
? type
: build_complex_type (TREE_TYPE (real
));
578 TREE_OVERFLOW (t
) = TREE_OVERFLOW (real
) | TREE_OVERFLOW (imag
);
579 TREE_CONSTANT_OVERFLOW (t
)
580 = TREE_CONSTANT_OVERFLOW (real
) | TREE_CONSTANT_OVERFLOW (imag
);
584 /* Build a newly constructed TREE_VEC node of length LEN. */
587 make_tree_vec_stat (int len MEM_STAT_DECL
)
590 int length
= (len
- 1) * sizeof (tree
) + sizeof (struct tree_vec
);
592 #ifdef GATHER_STATISTICS
593 tree_node_counts
[(int) vec_kind
]++;
594 tree_node_sizes
[(int) vec_kind
] += length
;
597 t
= ggc_alloc_zone_stat (length
, tree_zone PASS_MEM_STAT
);
599 memset (t
, 0, length
);
601 TREE_SET_CODE (t
, TREE_VEC
);
602 TREE_VEC_LENGTH (t
) = len
;
607 /* Return 1 if EXPR is the integer constant zero or a complex constant
611 integer_zerop (tree expr
)
615 return ((TREE_CODE (expr
) == INTEGER_CST
616 && ! TREE_CONSTANT_OVERFLOW (expr
)
617 && TREE_INT_CST_LOW (expr
) == 0
618 && TREE_INT_CST_HIGH (expr
) == 0)
619 || (TREE_CODE (expr
) == COMPLEX_CST
620 && integer_zerop (TREE_REALPART (expr
))
621 && integer_zerop (TREE_IMAGPART (expr
))));
624 /* Return 1 if EXPR is the integer constant one or the corresponding
628 integer_onep (tree expr
)
632 return ((TREE_CODE (expr
) == INTEGER_CST
633 && ! TREE_CONSTANT_OVERFLOW (expr
)
634 && TREE_INT_CST_LOW (expr
) == 1
635 && TREE_INT_CST_HIGH (expr
) == 0)
636 || (TREE_CODE (expr
) == COMPLEX_CST
637 && integer_onep (TREE_REALPART (expr
))
638 && integer_zerop (TREE_IMAGPART (expr
))));
641 /* Return 1 if EXPR is an integer containing all 1's in as much precision as
642 it contains. Likewise for the corresponding complex constant. */
645 integer_all_onesp (tree expr
)
652 if (TREE_CODE (expr
) == COMPLEX_CST
653 && integer_all_onesp (TREE_REALPART (expr
))
654 && integer_zerop (TREE_IMAGPART (expr
)))
657 else if (TREE_CODE (expr
) != INTEGER_CST
658 || TREE_CONSTANT_OVERFLOW (expr
))
661 uns
= TYPE_UNSIGNED (TREE_TYPE (expr
));
663 return (TREE_INT_CST_LOW (expr
) == ~(unsigned HOST_WIDE_INT
) 0
664 && TREE_INT_CST_HIGH (expr
) == -1);
666 /* Note that using TYPE_PRECISION here is wrong. We care about the
667 actual bits, not the (arbitrary) range of the type. */
668 prec
= GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr
)));
669 if (prec
>= HOST_BITS_PER_WIDE_INT
)
671 HOST_WIDE_INT high_value
;
674 shift_amount
= prec
- HOST_BITS_PER_WIDE_INT
;
676 if (shift_amount
> HOST_BITS_PER_WIDE_INT
)
677 /* Can not handle precisions greater than twice the host int size. */
679 else if (shift_amount
== HOST_BITS_PER_WIDE_INT
)
680 /* Shifting by the host word size is undefined according to the ANSI
681 standard, so we must handle this as a special case. */
684 high_value
= ((HOST_WIDE_INT
) 1 << shift_amount
) - 1;
686 return (TREE_INT_CST_LOW (expr
) == ~(unsigned HOST_WIDE_INT
) 0
687 && TREE_INT_CST_HIGH (expr
) == high_value
);
690 return TREE_INT_CST_LOW (expr
) == ((unsigned HOST_WIDE_INT
) 1 << prec
) - 1;
693 /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only
697 integer_pow2p (tree expr
)
700 HOST_WIDE_INT high
, low
;
704 if (TREE_CODE (expr
) == COMPLEX_CST
705 && integer_pow2p (TREE_REALPART (expr
))
706 && integer_zerop (TREE_IMAGPART (expr
)))
709 if (TREE_CODE (expr
) != INTEGER_CST
|| TREE_CONSTANT_OVERFLOW (expr
))
712 prec
= (POINTER_TYPE_P (TREE_TYPE (expr
))
713 ? POINTER_SIZE
: TYPE_PRECISION (TREE_TYPE (expr
)));
714 high
= TREE_INT_CST_HIGH (expr
);
715 low
= TREE_INT_CST_LOW (expr
);
717 /* First clear all bits that are beyond the type's precision in case
718 we've been sign extended. */
720 if (prec
== 2 * HOST_BITS_PER_WIDE_INT
)
722 else if (prec
> HOST_BITS_PER_WIDE_INT
)
723 high
&= ~((HOST_WIDE_INT
) (-1) << (prec
- HOST_BITS_PER_WIDE_INT
));
727 if (prec
< HOST_BITS_PER_WIDE_INT
)
728 low
&= ~((HOST_WIDE_INT
) (-1) << prec
);
731 if (high
== 0 && low
== 0)
734 return ((high
== 0 && (low
& (low
- 1)) == 0)
735 || (low
== 0 && (high
& (high
- 1)) == 0));
738 /* Return 1 if EXPR is an integer constant other than zero or a
739 complex constant other than zero. */
742 integer_nonzerop (tree expr
)
746 return ((TREE_CODE (expr
) == INTEGER_CST
747 && ! TREE_CONSTANT_OVERFLOW (expr
)
748 && (TREE_INT_CST_LOW (expr
) != 0
749 || TREE_INT_CST_HIGH (expr
) != 0))
750 || (TREE_CODE (expr
) == COMPLEX_CST
751 && (integer_nonzerop (TREE_REALPART (expr
))
752 || integer_nonzerop (TREE_IMAGPART (expr
)))));
755 /* Return the power of two represented by a tree node known to be a
759 tree_log2 (tree expr
)
762 HOST_WIDE_INT high
, low
;
766 if (TREE_CODE (expr
) == COMPLEX_CST
)
767 return tree_log2 (TREE_REALPART (expr
));
769 prec
= (POINTER_TYPE_P (TREE_TYPE (expr
))
770 ? POINTER_SIZE
: TYPE_PRECISION (TREE_TYPE (expr
)));
772 high
= TREE_INT_CST_HIGH (expr
);
773 low
= TREE_INT_CST_LOW (expr
);
775 /* First clear all bits that are beyond the type's precision in case
776 we've been sign extended. */
778 if (prec
== 2 * HOST_BITS_PER_WIDE_INT
)
780 else if (prec
> HOST_BITS_PER_WIDE_INT
)
781 high
&= ~((HOST_WIDE_INT
) (-1) << (prec
- HOST_BITS_PER_WIDE_INT
));
785 if (prec
< HOST_BITS_PER_WIDE_INT
)
786 low
&= ~((HOST_WIDE_INT
) (-1) << prec
);
789 return (high
!= 0 ? HOST_BITS_PER_WIDE_INT
+ exact_log2 (high
)
793 /* Similar, but return the largest integer Y such that 2 ** Y is less
794 than or equal to EXPR. */
797 tree_floor_log2 (tree expr
)
800 HOST_WIDE_INT high
, low
;
804 if (TREE_CODE (expr
) == COMPLEX_CST
)
805 return tree_log2 (TREE_REALPART (expr
));
807 prec
= (POINTER_TYPE_P (TREE_TYPE (expr
))
808 ? POINTER_SIZE
: TYPE_PRECISION (TREE_TYPE (expr
)));
810 high
= TREE_INT_CST_HIGH (expr
);
811 low
= TREE_INT_CST_LOW (expr
);
813 /* First clear all bits that are beyond the type's precision in case
814 we've been sign extended. Ignore if type's precision hasn't been set
815 since what we are doing is setting it. */
817 if (prec
== 2 * HOST_BITS_PER_WIDE_INT
|| prec
== 0)
819 else if (prec
> HOST_BITS_PER_WIDE_INT
)
820 high
&= ~((HOST_WIDE_INT
) (-1) << (prec
- HOST_BITS_PER_WIDE_INT
));
824 if (prec
< HOST_BITS_PER_WIDE_INT
)
825 low
&= ~((HOST_WIDE_INT
) (-1) << prec
);
828 return (high
!= 0 ? HOST_BITS_PER_WIDE_INT
+ floor_log2 (high
)
832 /* Return 1 if EXPR is the real constant zero. */
835 real_zerop (tree expr
)
839 return ((TREE_CODE (expr
) == REAL_CST
840 && ! TREE_CONSTANT_OVERFLOW (expr
)
841 && REAL_VALUES_EQUAL (TREE_REAL_CST (expr
), dconst0
))
842 || (TREE_CODE (expr
) == COMPLEX_CST
843 && real_zerop (TREE_REALPART (expr
))
844 && real_zerop (TREE_IMAGPART (expr
))));
847 /* Return 1 if EXPR is the real constant one in real or complex form. */
850 real_onep (tree expr
)
854 return ((TREE_CODE (expr
) == REAL_CST
855 && ! TREE_CONSTANT_OVERFLOW (expr
)
856 && REAL_VALUES_EQUAL (TREE_REAL_CST (expr
), dconst1
))
857 || (TREE_CODE (expr
) == COMPLEX_CST
858 && real_onep (TREE_REALPART (expr
))
859 && real_zerop (TREE_IMAGPART (expr
))));
862 /* Return 1 if EXPR is the real constant two. */
865 real_twop (tree expr
)
869 return ((TREE_CODE (expr
) == REAL_CST
870 && ! TREE_CONSTANT_OVERFLOW (expr
)
871 && REAL_VALUES_EQUAL (TREE_REAL_CST (expr
), dconst2
))
872 || (TREE_CODE (expr
) == COMPLEX_CST
873 && real_twop (TREE_REALPART (expr
))
874 && real_zerop (TREE_IMAGPART (expr
))));
877 /* Return 1 if EXPR is the real constant minus one. */
880 real_minus_onep (tree expr
)
884 return ((TREE_CODE (expr
) == REAL_CST
885 && ! TREE_CONSTANT_OVERFLOW (expr
)
886 && REAL_VALUES_EQUAL (TREE_REAL_CST (expr
), dconstm1
))
887 || (TREE_CODE (expr
) == COMPLEX_CST
888 && real_minus_onep (TREE_REALPART (expr
))
889 && real_zerop (TREE_IMAGPART (expr
))));
892 /* Nonzero if EXP is a constant or a cast of a constant. */
895 really_constant_p (tree exp
)
897 /* This is not quite the same as STRIP_NOPS. It does more. */
898 while (TREE_CODE (exp
) == NOP_EXPR
899 || TREE_CODE (exp
) == CONVERT_EXPR
900 || TREE_CODE (exp
) == NON_LVALUE_EXPR
)
901 exp
= TREE_OPERAND (exp
, 0);
902 return TREE_CONSTANT (exp
);
905 /* Return first list element whose TREE_VALUE is ELEM.
906 Return 0 if ELEM is not in LIST. */
909 value_member (tree elem
, tree list
)
913 if (elem
== TREE_VALUE (list
))
915 list
= TREE_CHAIN (list
);
920 /* Return first list element whose TREE_PURPOSE is ELEM.
921 Return 0 if ELEM is not in LIST. */
924 purpose_member (tree elem
, tree list
)
928 if (elem
== TREE_PURPOSE (list
))
930 list
= TREE_CHAIN (list
);
935 /* Return first list element whose BINFO_TYPE is ELEM.
936 Return 0 if ELEM is not in LIST. */
939 binfo_member (tree elem
, tree list
)
943 if (elem
== BINFO_TYPE (list
))
945 list
= TREE_CHAIN (list
);
950 /* Return nonzero if ELEM is part of the chain CHAIN. */
953 chain_member (tree elem
, tree chain
)
959 chain
= TREE_CHAIN (chain
);
965 /* Return the length of a chain of nodes chained through TREE_CHAIN.
966 We expect a null pointer to mark the end of the chain.
967 This is the Lisp primitive `length'. */
973 #ifdef ENABLE_TREE_CHECKING
981 #ifdef ENABLE_TREE_CHECKING
993 /* Returns the number of FIELD_DECLs in TYPE. */
996 fields_length (tree type
)
998 tree t
= TYPE_FIELDS (type
);
1001 for (; t
; t
= TREE_CHAIN (t
))
1002 if (TREE_CODE (t
) == FIELD_DECL
)
1008 /* Concatenate two chains of nodes (chained through TREE_CHAIN)
1009 by modifying the last node in chain 1 to point to chain 2.
1010 This is the Lisp primitive `nconc'. */
1013 chainon (tree op1
, tree op2
)
1022 for (t1
= op1
; TREE_CHAIN (t1
); t1
= TREE_CHAIN (t1
))
1024 TREE_CHAIN (t1
) = op2
;
1026 #ifdef ENABLE_TREE_CHECKING
1029 for (t2
= op2
; t2
; t2
= TREE_CHAIN (t2
))
1031 abort (); /* Circularity created. */
1038 /* Return the last node in a chain of nodes (chained through TREE_CHAIN). */
1041 tree_last (tree chain
)
1045 while ((next
= TREE_CHAIN (chain
)))
1050 /* Reverse the order of elements in the chain T,
1051 and return the new head of the chain (old last element). */
1056 tree prev
= 0, decl
, next
;
1057 for (decl
= t
; decl
; decl
= next
)
1059 next
= TREE_CHAIN (decl
);
1060 TREE_CHAIN (decl
) = prev
;
1066 /* Return a newly created TREE_LIST node whose
1067 purpose and value fields are PARM and VALUE. */
1070 build_tree_list_stat (tree parm
, tree value MEM_STAT_DECL
)
1072 tree t
= make_node_stat (TREE_LIST PASS_MEM_STAT
);
1073 TREE_PURPOSE (t
) = parm
;
1074 TREE_VALUE (t
) = value
;
1078 /* Return a newly created TREE_LIST node whose
1079 purpose and value fields are PURPOSE and VALUE
1080 and whose TREE_CHAIN is CHAIN. */
1083 tree_cons_stat (tree purpose
, tree value
, tree chain MEM_STAT_DECL
)
1087 node
= ggc_alloc_zone_stat (sizeof (struct tree_list
),
1088 tree_zone PASS_MEM_STAT
);
1090 memset (node
, 0, sizeof (struct tree_common
));
1092 #ifdef GATHER_STATISTICS
1093 tree_node_counts
[(int) x_kind
]++;
1094 tree_node_sizes
[(int) x_kind
] += sizeof (struct tree_list
);
1097 TREE_SET_CODE (node
, TREE_LIST
);
1098 TREE_CHAIN (node
) = chain
;
1099 TREE_PURPOSE (node
) = purpose
;
1100 TREE_VALUE (node
) = value
;
1105 /* Return the size nominally occupied by an object of type TYPE
1106 when it resides in memory. The value is measured in units of bytes,
1107 and its data type is that normally used for type sizes
1108 (which is the first type created by make_signed_type or
1109 make_unsigned_type). */
1112 size_in_bytes (tree type
)
1116 if (type
== error_mark_node
)
1117 return integer_zero_node
;
1119 type
= TYPE_MAIN_VARIANT (type
);
1120 t
= TYPE_SIZE_UNIT (type
);
1124 lang_hooks
.types
.incomplete_type_error (NULL_TREE
, type
);
1125 return size_zero_node
;
1128 if (TREE_CODE (t
) == INTEGER_CST
)
1129 force_fit_type (t
, 0);
1134 /* Return the size of TYPE (in bytes) as a wide integer
1135 or return -1 if the size can vary or is larger than an integer. */
1138 int_size_in_bytes (tree type
)
1142 if (type
== error_mark_node
)
1145 type
= TYPE_MAIN_VARIANT (type
);
1146 t
= TYPE_SIZE_UNIT (type
);
1148 || TREE_CODE (t
) != INTEGER_CST
1149 || TREE_OVERFLOW (t
)
1150 || TREE_INT_CST_HIGH (t
) != 0
1151 /* If the result would appear negative, it's too big to represent. */
1152 || (HOST_WIDE_INT
) TREE_INT_CST_LOW (t
) < 0)
1155 return TREE_INT_CST_LOW (t
);
1158 /* Return the bit position of FIELD, in bits from the start of the record.
1159 This is a tree of type bitsizetype. */
1162 bit_position (tree field
)
1164 return bit_from_pos (DECL_FIELD_OFFSET (field
),
1165 DECL_FIELD_BIT_OFFSET (field
));
1168 /* Likewise, but return as an integer. Abort if it cannot be represented
1169 in that way (since it could be a signed value, we don't have the option
1170 of returning -1 like int_size_in_byte can. */
1173 int_bit_position (tree field
)
1175 return tree_low_cst (bit_position (field
), 0);
1178 /* Return the byte position of FIELD, in bytes from the start of the record.
1179 This is a tree of type sizetype. */
1182 byte_position (tree field
)
1184 return byte_from_pos (DECL_FIELD_OFFSET (field
),
1185 DECL_FIELD_BIT_OFFSET (field
));
1188 /* Likewise, but return as an integer. Abort if it cannot be represented
1189 in that way (since it could be a signed value, we don't have the option
1190 of returning -1 like int_size_in_byte can. */
1193 int_byte_position (tree field
)
1195 return tree_low_cst (byte_position (field
), 0);
1198 /* Return the strictest alignment, in bits, that T is known to have. */
1203 unsigned int align0
, align1
;
1205 switch (TREE_CODE (t
))
1207 case NOP_EXPR
: case CONVERT_EXPR
: case NON_LVALUE_EXPR
:
1208 /* If we have conversions, we know that the alignment of the
1209 object must meet each of the alignments of the types. */
1210 align0
= expr_align (TREE_OPERAND (t
, 0));
1211 align1
= TYPE_ALIGN (TREE_TYPE (t
));
1212 return MAX (align0
, align1
);
1214 case SAVE_EXPR
: case COMPOUND_EXPR
: case MODIFY_EXPR
:
1215 case INIT_EXPR
: case TARGET_EXPR
: case WITH_CLEANUP_EXPR
:
1216 case CLEANUP_POINT_EXPR
: case UNSAVE_EXPR
:
1217 /* These don't change the alignment of an object. */
1218 return expr_align (TREE_OPERAND (t
, 0));
1221 /* The best we can do is say that the alignment is the least aligned
1223 align0
= expr_align (TREE_OPERAND (t
, 1));
1224 align1
= expr_align (TREE_OPERAND (t
, 2));
1225 return MIN (align0
, align1
);
1227 case LABEL_DECL
: case CONST_DECL
:
1228 case VAR_DECL
: case PARM_DECL
: case RESULT_DECL
:
1229 if (DECL_ALIGN (t
) != 0)
1230 return DECL_ALIGN (t
);
1234 return FUNCTION_BOUNDARY
;
1240 /* Otherwise take the alignment from that of the type. */
1241 return TYPE_ALIGN (TREE_TYPE (t
));
1244 /* Return, as a tree node, the number of elements for TYPE (which is an
1245 ARRAY_TYPE) minus one. This counts only elements of the top array. */
1248 array_type_nelts (tree type
)
1250 tree index_type
, min
, max
;
1252 /* If they did it with unspecified bounds, then we should have already
1253 given an error about it before we got here. */
1254 if (! TYPE_DOMAIN (type
))
1255 return error_mark_node
;
1257 index_type
= TYPE_DOMAIN (type
);
1258 min
= TYPE_MIN_VALUE (index_type
);
1259 max
= TYPE_MAX_VALUE (index_type
);
1261 return (integer_zerop (min
)
1263 : fold (build2 (MINUS_EXPR
, TREE_TYPE (max
), max
, min
)));
1266 /* Return nonzero if arg is static -- a reference to an object in
1267 static storage. This is not the same as the C meaning of `static'. */
1272 switch (TREE_CODE (arg
))
1275 /* Nested functions aren't static, since taking their address
1276 involves a trampoline. */
1277 return ((decl_function_context (arg
) == 0 || DECL_NO_STATIC_CHAIN (arg
))
1278 && ! DECL_NON_ADDR_CONST_P (arg
));
1281 return ((TREE_STATIC (arg
) || DECL_EXTERNAL (arg
))
1282 && ! DECL_THREAD_LOCAL (arg
)
1283 && ! DECL_NON_ADDR_CONST_P (arg
));
1286 return TREE_STATIC (arg
);
1293 /* If the thing being referenced is not a field, then it is
1294 something language specific. */
1295 if (TREE_CODE (TREE_OPERAND (arg
, 1)) != FIELD_DECL
)
1296 return (*lang_hooks
.staticp
) (arg
);
1298 /* If we are referencing a bitfield, we can't evaluate an
1299 ADDR_EXPR at compile time and so it isn't a constant. */
1300 if (DECL_BIT_FIELD (TREE_OPERAND (arg
, 1)))
1303 return staticp (TREE_OPERAND (arg
, 0));
1309 /* This case is technically correct, but results in setting
1310 TREE_CONSTANT on ADDR_EXPRs that cannot be evaluated at
1313 return TREE_CONSTANT (TREE_OPERAND (arg
, 0));
1317 case ARRAY_RANGE_REF
:
1318 if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg
))) == INTEGER_CST
1319 && TREE_CODE (TREE_OPERAND (arg
, 1)) == INTEGER_CST
)
1320 return staticp (TREE_OPERAND (arg
, 0));
1325 if ((unsigned int) TREE_CODE (arg
)
1326 >= (unsigned int) LAST_AND_UNUSED_TREE_CODE
)
1327 return lang_hooks
.staticp (arg
);
1333 /* Wrap a SAVE_EXPR around EXPR, if appropriate.
1334 Do this to any expression which may be used in more than one place,
1335 but must be evaluated only once.
1337 Normally, expand_expr would reevaluate the expression each time.
1338 Calling save_expr produces something that is evaluated and recorded
1339 the first time expand_expr is called on it. Subsequent calls to
1340 expand_expr just reuse the recorded value.
1342 The call to expand_expr that generates code that actually computes
1343 the value is the first call *at compile time*. Subsequent calls
1344 *at compile time* generate code to use the saved value.
1345 This produces correct result provided that *at run time* control
1346 always flows through the insns made by the first expand_expr
1347 before reaching the other places where the save_expr was evaluated.
1348 You, the caller of save_expr, must make sure this is so.
1350 Constants, and certain read-only nodes, are returned with no
1351 SAVE_EXPR because that is safe. Expressions containing placeholders
1352 are not touched; see tree.def for an explanation of what these
1356 save_expr (tree expr
)
1358 tree t
= fold (expr
);
1361 /* If the tree evaluates to a constant, then we don't want to hide that
1362 fact (i.e. this allows further folding, and direct checks for constants).
1363 However, a read-only object that has side effects cannot be bypassed.
1364 Since it is no problem to reevaluate literals, we just return the
1366 inner
= skip_simple_arithmetic (t
);
1368 if (TREE_INVARIANT (inner
)
1369 || (TREE_READONLY (inner
) && ! TREE_SIDE_EFFECTS (inner
))
1370 || TREE_CODE (inner
) == SAVE_EXPR
1371 || TREE_CODE (inner
) == ERROR_MARK
)
1374 /* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
1375 it means that the size or offset of some field of an object depends on
1376 the value within another field.
1378 Note that it must not be the case that T contains both a PLACEHOLDER_EXPR
1379 and some variable since it would then need to be both evaluated once and
1380 evaluated more than once. Front-ends must assure this case cannot
1381 happen by surrounding any such subexpressions in their own SAVE_EXPR
1382 and forcing evaluation at the proper time. */
1383 if (contains_placeholder_p (inner
))
1386 t
= build3 (SAVE_EXPR
, TREE_TYPE (expr
), t
, current_function_decl
,
1389 /* This expression might be placed ahead of a jump to ensure that the
1390 value was computed on both sides of the jump. So make sure it isn't
1391 eliminated as dead. */
1392 TREE_SIDE_EFFECTS (t
) = 1;
1393 TREE_READONLY (t
) = 1;
1394 TREE_INVARIANT (t
) = 1;
1398 /* Look inside EXPR and into any simple arithmetic operations. Return
1399 the innermost non-arithmetic node. */
1402 skip_simple_arithmetic (tree expr
)
1406 /* We don't care about whether this can be used as an lvalue in this
1408 while (TREE_CODE (expr
) == NON_LVALUE_EXPR
)
1409 expr
= TREE_OPERAND (expr
, 0);
1411 /* If we have simple operations applied to a SAVE_EXPR or to a SAVE_EXPR and
1412 a constant, it will be more efficient to not make another SAVE_EXPR since
1413 it will allow better simplification and GCSE will be able to merge the
1414 computations if they actually occur. */
1418 if (TREE_CODE_CLASS (TREE_CODE (inner
)) == '1')
1419 inner
= TREE_OPERAND (inner
, 0);
1420 else if (TREE_CODE_CLASS (TREE_CODE (inner
)) == '2')
1422 if (TREE_INVARIANT (TREE_OPERAND (inner
, 1)))
1423 inner
= TREE_OPERAND (inner
, 0);
1424 else if (TREE_INVARIANT (TREE_OPERAND (inner
, 0)))
1425 inner
= TREE_OPERAND (inner
, 1);
1436 /* Arrange for an expression to be expanded multiple independent
1437 times. This is useful for cleanup actions, as the backend can
1438 expand them multiple times in different places. */
1441 unsave_expr (tree expr
)
1445 /* If this is already protected, no sense in protecting it again. */
1446 if (TREE_CODE (expr
) == UNSAVE_EXPR
)
1449 t
= build1 (UNSAVE_EXPR
, TREE_TYPE (expr
), expr
);
1450 TREE_SIDE_EFFECTS (t
) = TREE_SIDE_EFFECTS (expr
);
1454 /* Returns the index of the first non-tree operand for CODE, or the number
1455 of operands if all are trees. */
1458 first_rtl_op (enum tree_code code
)
1464 case GOTO_SUBROUTINE_EXPR
:
1467 case WITH_CLEANUP_EXPR
:
1470 return TREE_CODE_LENGTH (code
);
1474 /* Return which tree structure is used by T. */
1476 enum tree_node_structure_enum
1477 tree_node_structure (tree t
)
1479 enum tree_code code
= TREE_CODE (t
);
1481 switch (TREE_CODE_CLASS (code
))
1483 case 'd': return TS_DECL
;
1484 case 't': return TS_TYPE
;
1485 case 'r': case '<': case '1': case '2': case 'e': case 's':
1487 default: /* 'c' and 'x' */
1493 case INTEGER_CST
: return TS_INT_CST
;
1494 case REAL_CST
: return TS_REAL_CST
;
1495 case COMPLEX_CST
: return TS_COMPLEX
;
1496 case VECTOR_CST
: return TS_VECTOR
;
1497 case STRING_CST
: return TS_STRING
;
1499 case ERROR_MARK
: return TS_COMMON
;
1500 case IDENTIFIER_NODE
: return TS_IDENTIFIER
;
1501 case TREE_LIST
: return TS_LIST
;
1502 case TREE_VEC
: return TS_VEC
;
1503 case PHI_NODE
: return TS_PHI_NODE
;
1504 case EPHI_NODE
: return TS_EPHI_NODE
;
1505 case EUSE_NODE
: return TS_EUSE_NODE
;
1506 case EKILL_NODE
: return TS_EREF_NODE
;
1507 case EEXIT_NODE
: return TS_EREF_NODE
;
1508 case SSA_NAME
: return TS_SSA_NAME
;
1509 case PLACEHOLDER_EXPR
: return TS_COMMON
;
1510 case STATEMENT_LIST
: return TS_STATEMENT_LIST
;
1511 case BLOCK
: return TS_BLOCK
;
1518 /* Perform any modifications to EXPR required when it is unsaved. Does
1519 not recurse into EXPR's subtrees. */
1522 unsave_expr_1 (tree expr
)
1524 switch (TREE_CODE (expr
))
1527 if (! SAVE_EXPR_PERSISTENT_P (expr
))
1528 SAVE_EXPR_RTL (expr
) = 0;
1532 /* Don't mess with a TARGET_EXPR that hasn't been expanded.
1533 It's OK for this to happen if it was part of a subtree that
1534 isn't immediately expanded, such as operand 2 of another
1536 if (TREE_OPERAND (expr
, 1))
1539 TREE_OPERAND (expr
, 1) = TREE_OPERAND (expr
, 3);
1540 TREE_OPERAND (expr
, 3) = NULL_TREE
;
1544 /* I don't yet know how to emit a sequence multiple times. */
1545 if (RTL_EXPR_SEQUENCE (expr
) != 0)
1554 /* Return 0 if it is safe to evaluate EXPR multiple times,
1555 return 1 if it is safe if EXPR is unsaved afterward, or
1556 return 2 if it is completely unsafe.
1558 This assumes that CALL_EXPRs and TARGET_EXPRs are never replicated in
1559 an expression tree, so that it safe to unsave them and the surrounding
1560 context will be correct.
1562 SAVE_EXPRs basically *only* appear replicated in an expression tree,
1563 occasionally across the whole of a function. It is therefore only
1564 safe to unsave a SAVE_EXPR if you know that all occurrences appear
1565 below the UNSAVE_EXPR.
1567 RTL_EXPRs consume their rtl during evaluation. It is therefore
1568 never possible to unsave them. */
1571 unsafe_for_reeval (tree expr
)
1574 enum tree_code code
;
1579 if (expr
== NULL_TREE
)
1582 code
= TREE_CODE (expr
);
1583 first_rtl
= first_rtl_op (code
);
1591 /* A label can only be emitted once. */
1600 for (exp
= expr
; exp
!= 0; exp
= TREE_CHAIN (exp
))
1602 tmp
= unsafe_for_reeval (TREE_VALUE (exp
));
1603 unsafeness
= MAX (tmp
, unsafeness
);
1609 tmp2
= unsafe_for_reeval (TREE_OPERAND (expr
, 0));
1610 tmp
= unsafe_for_reeval (TREE_OPERAND (expr
, 1));
1611 return MAX (MAX (tmp
, 1), tmp2
);
1617 case EXIT_BLOCK_EXPR
:
1618 /* EXIT_BLOCK_LABELED_BLOCK, a.k.a. TREE_OPERAND (expr, 0), holds
1619 a reference to an ancestor LABELED_BLOCK, so we need to avoid
1620 unbounded recursion in the 'e' traversal code below. */
1621 exp
= EXIT_BLOCK_RETURN (expr
);
1622 return exp
? unsafe_for_reeval (exp
) : 0;
1625 tmp
= lang_hooks
.unsafe_for_reeval (expr
);
1631 switch (TREE_CODE_CLASS (code
))
1633 case 'c': /* a constant */
1634 case 't': /* a type node */
1635 case 'x': /* something random, like an identifier or an ERROR_MARK. */
1636 case 'd': /* A decl node */
1639 case 'e': /* an expression */
1640 case 'r': /* a reference */
1641 case 's': /* an expression with side effects */
1642 case '<': /* a comparison expression */
1643 case '2': /* a binary arithmetic expression */
1644 case '1': /* a unary arithmetic expression */
1645 for (i
= first_rtl
- 1; i
>= 0; i
--)
1647 tmp
= unsafe_for_reeval (TREE_OPERAND (expr
, i
));
1648 unsafeness
= MAX (tmp
, unsafeness
);
1658 /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size
1659 or offset that depends on a field within a record. */
1662 contains_placeholder_p (tree exp
)
1664 enum tree_code code
;
1670 code
= TREE_CODE (exp
);
1671 if (code
== PLACEHOLDER_EXPR
)
1674 switch (TREE_CODE_CLASS (code
))
1677 /* Don't look at any PLACEHOLDER_EXPRs that might be in index or bit
1678 position computations since they will be converted into a
1679 WITH_RECORD_EXPR involving the reference, which will assume
1680 here will be valid. */
1681 return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 0));
1684 if (code
== TREE_LIST
)
1685 return (CONTAINS_PLACEHOLDER_P (TREE_VALUE (exp
))
1686 || CONTAINS_PLACEHOLDER_P (TREE_CHAIN (exp
)));
1695 /* Ignoring the first operand isn't quite right, but works best. */
1696 return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 1));
1699 return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 0))
1700 || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 1))
1701 || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 2)));
1704 /* If we already know this doesn't have a placeholder, don't
1706 if (SAVE_EXPR_NOPLACEHOLDER (exp
) || SAVE_EXPR_RTL (exp
) != 0)
1709 SAVE_EXPR_NOPLACEHOLDER (exp
) = 1;
1710 result
= CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 0));
1712 SAVE_EXPR_NOPLACEHOLDER (exp
) = 0;
1720 switch (first_rtl_op (code
))
1723 return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 0));
1725 return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 0))
1726 || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp
, 1)));
1737 /* Return 1 if any part of the computation of TYPE involves a PLACEHOLDER_EXPR.
1738 This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and field
1742 type_contains_placeholder_p (tree type
)
1744 /* If the size contains a placeholder or the parent type (component type in
1745 the case of arrays) type involves a placeholder, this type does. */
1746 if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type
))
1747 || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type
))
1748 || (TREE_TYPE (type
) != 0
1749 && type_contains_placeholder_p (TREE_TYPE (type
))))
1752 /* Now do type-specific checks. Note that the last part of the check above
1753 greatly limits what we have to do below. */
1754 switch (TREE_CODE (type
))
1763 case REFERENCE_TYPE
:
1771 /* Here we just check the bounds. */
1772 return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type
))
1773 || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type
)));
1778 /* We're already checked the component type (TREE_TYPE), so just check
1780 return type_contains_placeholder_p (TYPE_DOMAIN (type
));
1784 case QUAL_UNION_TYPE
:
1786 static tree seen_types
= 0;
1790 /* We have to be careful here that we don't end up in infinite
1791 recursions due to a field of a type being a pointer to that type
1792 or to a mutually-recursive type. So we store a list of record
1793 types that we've seen and see if this type is in them. To save
1794 memory, we don't use a list for just one type. Here we check
1795 whether we've seen this type before and store it if not. */
1796 if (seen_types
== 0)
1798 else if (TREE_CODE (seen_types
) != TREE_LIST
)
1800 if (seen_types
== type
)
1803 seen_types
= tree_cons (NULL_TREE
, type
,
1804 build_tree_list (NULL_TREE
, seen_types
));
1808 if (value_member (type
, seen_types
) != 0)
1811 seen_types
= tree_cons (NULL_TREE
, type
, seen_types
);
1814 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
1815 if (TREE_CODE (field
) == FIELD_DECL
1816 && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field
))
1817 || (TREE_CODE (type
) == QUAL_UNION_TYPE
1818 && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field
)))
1819 || type_contains_placeholder_p (TREE_TYPE (field
))))
1825 /* Now remove us from seen_types and return the result. */
1826 if (seen_types
== type
)
1829 seen_types
= TREE_CHAIN (seen_types
);
1839 /* Return 1 if EXP contains any expressions that produce cleanups for an
1840 outer scope to deal with. Used by fold. */
1843 has_cleanups (tree exp
)
1847 if (! TREE_SIDE_EFFECTS (exp
))
1850 switch (TREE_CODE (exp
))
1853 case GOTO_SUBROUTINE_EXPR
:
1854 case WITH_CLEANUP_EXPR
:
1857 case CLEANUP_POINT_EXPR
:
1861 for (exp
= TREE_OPERAND (exp
, 1); exp
; exp
= TREE_CHAIN (exp
))
1863 cmp
= has_cleanups (TREE_VALUE (exp
));
1873 /* This general rule works for most tree codes. All exceptions should be
1874 handled above. If this is a language-specific tree code, we can't
1875 trust what might be in the operand, so say we don't know
1877 if ((int) TREE_CODE (exp
) >= (int) LAST_AND_UNUSED_TREE_CODE
)
1880 nops
= first_rtl_op (TREE_CODE (exp
));
1881 for (i
= 0; i
< nops
; i
++)
1882 if (TREE_OPERAND (exp
, i
) != 0)
1884 int type
= TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, i
)));
1885 if (type
== 'e' || type
== '<' || type
== '1' || type
== '2'
1886 || type
== 'r' || type
== 's')
1888 cmp
= has_cleanups (TREE_OPERAND (exp
, i
));
1897 /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
1898 return a tree with all occurrences of references to F in a
1899 PLACEHOLDER_EXPR replaced by R. Note that we assume here that EXP
1900 contains only arithmetic expressions or a CALL_EXPR with a
1901 PLACEHOLDER_EXPR occurring only in its arglist. */
1904 substitute_in_expr (tree exp
, tree f
, tree r
)
1906 enum tree_code code
= TREE_CODE (exp
);
1911 /* We handle TREE_LIST and COMPONENT_REF separately. */
1912 if (code
== TREE_LIST
)
1914 op0
= SUBSTITUTE_IN_EXPR (TREE_CHAIN (exp
), f
, r
);
1915 op1
= SUBSTITUTE_IN_EXPR (TREE_VALUE (exp
), f
, r
);
1916 if (op0
== TREE_CHAIN (exp
) && op1
== TREE_VALUE (exp
))
1919 return tree_cons (TREE_PURPOSE (exp
), op1
, op0
);
1921 else if (code
== COMPONENT_REF
)
1923 /* If this expression is getting a value from a PLACEHOLDER_EXPR
1924 and it is the right field, replace it with R. */
1925 for (inner
= TREE_OPERAND (exp
, 0);
1926 TREE_CODE_CLASS (TREE_CODE (inner
)) == 'r';
1927 inner
= TREE_OPERAND (inner
, 0))
1929 if (TREE_CODE (inner
) == PLACEHOLDER_EXPR
1930 && TREE_OPERAND (exp
, 1) == f
)
1933 /* If this expression hasn't been completed let, leave it
1935 if (TREE_CODE (inner
) == PLACEHOLDER_EXPR
&& TREE_TYPE (inner
) == 0)
1938 op0
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 0), f
, r
);
1939 if (op0
== TREE_OPERAND (exp
, 0))
1942 new = fold (build2 (code
, TREE_TYPE (exp
), op0
, TREE_OPERAND (exp
, 1)));
1945 switch (TREE_CODE_CLASS (code
))
1957 switch (first_rtl_op (code
))
1963 op0
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 0), f
, r
);
1964 if (op0
== TREE_OPERAND (exp
, 0))
1967 new = fold (build1 (code
, TREE_TYPE (exp
), op0
));
1971 op0
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 0), f
, r
);
1972 op1
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 1), f
, r
);
1974 if (op0
== TREE_OPERAND (exp
, 0) && op1
== TREE_OPERAND (exp
, 1))
1977 new = fold (build2 (code
, TREE_TYPE (exp
), op0
, op1
));
1981 op0
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 0), f
, r
);
1982 op1
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 1), f
, r
);
1983 op2
= SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp
, 2), f
, r
);
1985 if (op0
== TREE_OPERAND (exp
, 0) && op1
== TREE_OPERAND (exp
, 1)
1986 && op2
== TREE_OPERAND (exp
, 2))
1989 new = fold (build3 (code
, TREE_TYPE (exp
), op0
, op1
, op2
));
2001 TREE_READONLY (new) = TREE_READONLY (exp
);
2005 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
2006 for it within OBJ, a tree that is an object or a chain of references. */
2009 substitute_placeholder_in_expr (tree exp
, tree obj
)
2011 enum tree_code code
= TREE_CODE (exp
);
2012 tree op0
, op1
, op2
, op3
;
2014 /* If this is a PLACEHOLDER_EXPR, see if we find a corresponding type
2015 in the chain of OBJ. */
2016 if (code
== PLACEHOLDER_EXPR
)
2018 tree need_type
= TYPE_MAIN_VARIANT (TREE_TYPE (exp
));
2021 for (elt
= obj
; elt
!= 0;
2022 elt
= ((TREE_CODE (elt
) == COMPOUND_EXPR
2023 || TREE_CODE (elt
) == COND_EXPR
)
2024 ? TREE_OPERAND (elt
, 1)
2025 : (TREE_CODE_CLASS (TREE_CODE (elt
)) == 'r'
2026 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '1'
2027 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '2'
2028 || TREE_CODE_CLASS (TREE_CODE (elt
)) == 'e')
2029 ? TREE_OPERAND (elt
, 0) : 0))
2030 if (TYPE_MAIN_VARIANT (TREE_TYPE (elt
)) == need_type
)
2033 for (elt
= obj
; elt
!= 0;
2034 elt
= ((TREE_CODE (elt
) == COMPOUND_EXPR
2035 || TREE_CODE (elt
) == COND_EXPR
)
2036 ? TREE_OPERAND (elt
, 1)
2037 : (TREE_CODE_CLASS (TREE_CODE (elt
)) == 'r'
2038 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '1'
2039 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '2'
2040 || TREE_CODE_CLASS (TREE_CODE (elt
)) == 'e')
2041 ? TREE_OPERAND (elt
, 0) : 0))
2042 if (POINTER_TYPE_P (TREE_TYPE (elt
))
2043 && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt
)))
2045 return fold (build1 (INDIRECT_REF
, need_type
, elt
));
2047 /* If we didn't find it, return the original PLACEHOLDER_EXPR. If it
2048 survives until RTL generation, there will be an error. */
2052 /* TREE_LIST is special because we need to look at TREE_VALUE
2053 and TREE_CHAIN, not TREE_OPERANDS. */
2054 else if (code
== TREE_LIST
)
2056 op0
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp
), obj
);
2057 op1
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp
), obj
);
2058 if (op0
== TREE_CHAIN (exp
) && op1
== TREE_VALUE (exp
))
2061 return tree_cons (TREE_PURPOSE (exp
), op1
, op0
);
2064 switch (TREE_CODE_CLASS (code
))
2077 switch (first_rtl_op (code
))
2083 op0
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 0), obj
);
2084 if (op0
== TREE_OPERAND (exp
, 0))
2087 return fold (build1 (code
, TREE_TYPE (exp
), op0
));
2090 op0
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 0), obj
);
2091 op1
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 1), obj
);
2093 if (op0
== TREE_OPERAND (exp
, 0) && op1
== TREE_OPERAND (exp
, 1))
2096 return fold (build2 (code
, TREE_TYPE (exp
), op0
, op1
));
2099 op0
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 0), obj
);
2100 op1
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 1), obj
);
2101 op2
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 2), obj
);
2103 if (op0
== TREE_OPERAND (exp
, 0) && op1
== TREE_OPERAND (exp
, 1)
2104 && op2
== TREE_OPERAND (exp
, 2))
2107 return fold (build3 (code
, TREE_TYPE (exp
), op0
, op1
, op2
));
2110 op0
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 0), obj
);
2111 op1
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 1), obj
);
2112 op2
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 2), obj
);
2113 op3
= SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp
, 3), obj
);
2115 if (op0
== TREE_OPERAND (exp
, 0) && op1
== TREE_OPERAND (exp
, 1)
2116 && op2
== TREE_OPERAND (exp
, 2)
2117 && op3
== TREE_OPERAND (exp
, 3))
2120 return fold (build4 (code
, TREE_TYPE (exp
), op0
, op1
, op2
, op3
));
2132 /* Stabilize a reference so that we can use it any number of times
2133 without causing its operands to be evaluated more than once.
2134 Returns the stabilized reference. This works by means of save_expr,
2135 so see the caveats in the comments about save_expr.
2137 Also allows conversion expressions whose operands are references.
2138 Any other kind of expression is returned unchanged. */
2141 stabilize_reference (tree ref
)
2144 enum tree_code code
= TREE_CODE (ref
);
2151 /* No action is needed in this case. */
2157 case FIX_TRUNC_EXPR
:
2158 case FIX_FLOOR_EXPR
:
2159 case FIX_ROUND_EXPR
:
2161 result
= build_nt (code
, stabilize_reference (TREE_OPERAND (ref
, 0)));
2165 result
= build_nt (INDIRECT_REF
,
2166 stabilize_reference_1 (TREE_OPERAND (ref
, 0)));
2170 result
= build_nt (COMPONENT_REF
,
2171 stabilize_reference (TREE_OPERAND (ref
, 0)),
2172 TREE_OPERAND (ref
, 1));
2176 result
= build_nt (BIT_FIELD_REF
,
2177 stabilize_reference (TREE_OPERAND (ref
, 0)),
2178 stabilize_reference_1 (TREE_OPERAND (ref
, 1)),
2179 stabilize_reference_1 (TREE_OPERAND (ref
, 2)));
2183 result
= build_nt (ARRAY_REF
,
2184 stabilize_reference (TREE_OPERAND (ref
, 0)),
2185 stabilize_reference_1 (TREE_OPERAND (ref
, 1)));
2188 case ARRAY_RANGE_REF
:
2189 result
= build_nt (ARRAY_RANGE_REF
,
2190 stabilize_reference (TREE_OPERAND (ref
, 0)),
2191 stabilize_reference_1 (TREE_OPERAND (ref
, 1)));
2195 /* We cannot wrap the first expression in a SAVE_EXPR, as then
2196 it wouldn't be ignored. This matters when dealing with
2198 return stabilize_reference_1 (ref
);
2201 result
= build1 (INDIRECT_REF
, TREE_TYPE (ref
),
2202 save_expr (build1 (ADDR_EXPR
,
2203 build_pointer_type (TREE_TYPE (ref
)),
2207 /* If arg isn't a kind of lvalue we recognize, make no change.
2208 Caller should recognize the error for an invalid lvalue. */
2213 return error_mark_node
;
2216 TREE_TYPE (result
) = TREE_TYPE (ref
);
2217 TREE_READONLY (result
) = TREE_READONLY (ref
);
2218 TREE_SIDE_EFFECTS (result
) = TREE_SIDE_EFFECTS (ref
);
2219 TREE_THIS_VOLATILE (result
) = TREE_THIS_VOLATILE (ref
);
2224 /* Subroutine of stabilize_reference; this is called for subtrees of
2225 references. Any expression with side-effects must be put in a SAVE_EXPR
2226 to ensure that it is only evaluated once.
2228 We don't put SAVE_EXPR nodes around everything, because assigning very
2229 simple expressions to temporaries causes us to miss good opportunities
2230 for optimizations. Among other things, the opportunity to fold in the
2231 addition of a constant into an addressing mode often gets lost, e.g.
2232 "y[i+1] += x;". In general, we take the approach that we should not make
2233 an assignment unless we are forced into it - i.e., that any non-side effect
2234 operator should be allowed, and that cse should take care of coalescing
2235 multiple utterances of the same expression should that prove fruitful. */
2238 stabilize_reference_1 (tree e
)
2241 enum tree_code code
= TREE_CODE (e
);
2243 /* We cannot ignore const expressions because it might be a reference
2244 to a const array but whose index contains side-effects. But we can
2245 ignore things that are actual constant or that already have been
2246 handled by this function. */
2248 if (TREE_INVARIANT (e
))
2251 switch (TREE_CODE_CLASS (code
))
2260 /* If the expression has side-effects, then encase it in a SAVE_EXPR
2261 so that it will only be evaluated once. */
2262 /* The reference (r) and comparison (<) classes could be handled as
2263 below, but it is generally faster to only evaluate them once. */
2264 if (TREE_SIDE_EFFECTS (e
))
2265 return save_expr (e
);
2269 /* Constants need no processing. In fact, we should never reach
2274 /* Division is slow and tends to be compiled with jumps,
2275 especially the division by powers of 2 that is often
2276 found inside of an array reference. So do it just once. */
2277 if (code
== TRUNC_DIV_EXPR
|| code
== TRUNC_MOD_EXPR
2278 || code
== FLOOR_DIV_EXPR
|| code
== FLOOR_MOD_EXPR
2279 || code
== CEIL_DIV_EXPR
|| code
== CEIL_MOD_EXPR
2280 || code
== ROUND_DIV_EXPR
|| code
== ROUND_MOD_EXPR
)
2281 return save_expr (e
);
2282 /* Recursively stabilize each operand. */
2283 result
= build_nt (code
, stabilize_reference_1 (TREE_OPERAND (e
, 0)),
2284 stabilize_reference_1 (TREE_OPERAND (e
, 1)));
2288 /* Recursively stabilize each operand. */
2289 result
= build_nt (code
, stabilize_reference_1 (TREE_OPERAND (e
, 0)));
2296 TREE_TYPE (result
) = TREE_TYPE (e
);
2297 TREE_READONLY (result
) = TREE_READONLY (e
);
2298 TREE_SIDE_EFFECTS (result
) = TREE_SIDE_EFFECTS (e
);
2299 TREE_THIS_VOLATILE (result
) = TREE_THIS_VOLATILE (e
);
2300 TREE_INVARIANT (result
) = 1;
2305 /* Low-level constructors for expressions. */
2307 /* A helper function for build1 and constant folders.
2308 Set TREE_CONSTANT and TREE_INVARIANT for an ADDR_EXPR. */
2311 recompute_tree_invarant_for_addr_expr (tree t
)
2313 tree node
= TREE_OPERAND (t
, 0);
2314 bool tc
= false, ti
= false;
2316 /* Addresses of constants and static variables are constant;
2317 all other decl addresses are invariant. */
2322 /* Step past constant offsets. */
2325 if (TREE_CODE (node
) == COMPONENT_REF
2326 && TREE_CODE (TREE_OPERAND (node
, 1)) == FIELD_DECL
2327 && ! DECL_BIT_FIELD (TREE_OPERAND (node
, 1)))
2329 else if (TREE_CODE (node
) == ARRAY_REF
2330 && TREE_CONSTANT (TREE_OPERAND (node
, 1)))
2334 node
= TREE_OPERAND (node
, 0);
2340 TREE_CONSTANT (t
) = tc
;
2341 TREE_INVARIANT (t
) = ti
;
2344 /* Build an expression of code CODE, data type TYPE, and operands as
2345 specified. Expressions and reference nodes can be created this way.
2346 Constants, decls, types and misc nodes cannot be.
2348 We define 5 non-variadic functions, from 0 to 4 arguments. This is
2349 enough for all extant tree codes. These functions can be called
2350 directly (preferably!), but can also be obtained via GCC preprocessor
2351 magic within the build macro. */
2354 build0_stat (enum tree_code code
, tree tt MEM_STAT_DECL
)
2358 #ifdef ENABLE_CHECKING
2359 if (TREE_CODE_LENGTH (code
) != 0)
2363 t
= make_node_stat (code PASS_MEM_STAT
);
2370 build1_stat (enum tree_code code
, tree type
, tree node MEM_STAT_DECL
)
2372 int length
= sizeof (struct tree_exp
);
2373 #ifdef GATHER_STATISTICS
2374 tree_node_kind kind
;
2378 #ifdef GATHER_STATISTICS
2379 switch (TREE_CODE_CLASS (code
))
2381 case 's': /* an expression with side effects */
2384 case 'r': /* a reference */
2392 tree_node_counts
[(int) kind
]++;
2393 tree_node_sizes
[(int) kind
] += length
;
2396 #ifdef ENABLE_CHECKING
2397 if (TREE_CODE_LENGTH (code
) != 1)
2399 #endif /* ENABLE_CHECKING */
2401 t
= ggc_alloc_zone_stat (length
, tree_zone PASS_MEM_STAT
);
2403 memset (t
, 0, sizeof (struct tree_common
));
2405 TREE_SET_CODE (t
, code
);
2407 TREE_TYPE (t
) = type
;
2408 SET_EXPR_LOCUS (t
, NULL
);
2409 TREE_COMPLEXITY (t
) = 0;
2410 TREE_OPERAND (t
, 0) = node
;
2411 TREE_BLOCK (t
) = NULL_TREE
;
2412 if (node
&& !TYPE_P (node
) && first_rtl_op (code
) != 0)
2414 TREE_SIDE_EFFECTS (t
) = TREE_SIDE_EFFECTS (node
);
2415 TREE_READONLY (t
) = TREE_READONLY (node
);
2418 if (TREE_CODE_CLASS (code
) == 's')
2419 TREE_SIDE_EFFECTS (t
) = 1;
2426 case PREDECREMENT_EXPR
:
2427 case PREINCREMENT_EXPR
:
2428 case POSTDECREMENT_EXPR
:
2429 case POSTINCREMENT_EXPR
:
2430 /* All of these have side-effects, no matter what their
2432 TREE_SIDE_EFFECTS (t
) = 1;
2433 TREE_READONLY (t
) = 0;
2437 /* Whether a dereference is readonly has nothing to do with whether
2438 its operand is readonly. */
2439 TREE_READONLY (t
) = 0;
2445 recompute_tree_invarant_for_addr_expr (t
);
2447 /* The address of a volatile decl or reference does not have
2448 side-effects. But be careful not to ignore side-effects from
2449 other sources deeper in the expression--if node is a _REF and
2450 one of its operands has side-effects, so do we. */
2451 if (TREE_THIS_VOLATILE (node
))
2453 TREE_SIDE_EFFECTS (t
) = 0;
2456 int i
= first_rtl_op (TREE_CODE (node
)) - 1;
2459 if (TREE_SIDE_EFFECTS (TREE_OPERAND (node
, i
)))
2460 TREE_SIDE_EFFECTS (t
) = 1;
2468 if (TREE_CODE_CLASS (code
) == '1' && node
&& !TYPE_P (node
)
2469 && TREE_CONSTANT (node
))
2470 TREE_CONSTANT (t
) = 1;
2471 if (TREE_CODE_CLASS (code
) == '1' && node
&& TREE_INVARIANT (node
))
2472 TREE_INVARIANT (t
) = 1;
2479 #define PROCESS_ARG(N) \
2481 TREE_OPERAND (t, N) = arg##N; \
2482 if (arg##N &&!TYPE_P (arg##N) && fro > N) \
2484 if (TREE_SIDE_EFFECTS (arg##N)) \
2486 if (!TREE_READONLY (arg##N)) \
2488 if (!TREE_CONSTANT (arg##N)) \
2490 if (!TREE_INVARIANT (arg##N)) \
2496 build2_stat (enum tree_code code
, tree tt
, tree arg0
, tree arg1 MEM_STAT_DECL
)
2498 bool constant
, read_only
, side_effects
, invariant
;
2502 #ifdef ENABLE_CHECKING
2503 if (TREE_CODE_LENGTH (code
) != 2)
2507 t
= make_node_stat (code PASS_MEM_STAT
);
2510 /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_READONLY for the
2511 result based on those same flags for the arguments. But if the
2512 arguments aren't really even `tree' expressions, we shouldn't be trying
2514 fro
= first_rtl_op (code
);
2516 /* Expressions without side effects may be constant if their
2517 arguments are as well. */
2518 constant
= (TREE_CODE_CLASS (code
) == '<'
2519 || TREE_CODE_CLASS (code
) == '2');
2521 side_effects
= TREE_SIDE_EFFECTS (t
);
2522 invariant
= constant
;
2527 TREE_READONLY (t
) = read_only
;
2528 TREE_CONSTANT (t
) = constant
;
2529 TREE_INVARIANT (t
) = invariant
;
2530 TREE_SIDE_EFFECTS (t
) = side_effects
;
2536 build3_stat (enum tree_code code
, tree tt
, tree arg0
, tree arg1
,
2537 tree arg2 MEM_STAT_DECL
)
2539 bool constant
, read_only
, side_effects
, invariant
;
2543 #ifdef ENABLE_CHECKING
2544 if (TREE_CODE_LENGTH (code
) != 3)
2548 t
= make_node_stat (code PASS_MEM_STAT
);
2551 fro
= first_rtl_op (code
);
2553 side_effects
= TREE_SIDE_EFFECTS (t
);
2559 if (code
== CALL_EXPR
&& !side_effects
)
2564 /* Calls have side-effects, except those to const or
2566 i
= call_expr_flags (t
);
2567 if (!(i
& (ECF_CONST
| ECF_PURE
)))
2570 /* And even those have side-effects if their arguments do. */
2571 else for (node
= arg1
; node
; node
= TREE_CHAIN (node
))
2572 if (TREE_SIDE_EFFECTS (TREE_VALUE (node
)))
2579 TREE_SIDE_EFFECTS (t
) = side_effects
;
2585 build4_stat (enum tree_code code
, tree tt
, tree arg0
, tree arg1
,
2586 tree arg2
, tree arg3 MEM_STAT_DECL
)
2588 bool constant
, read_only
, side_effects
, invariant
;
2592 #ifdef ENABLE_CHECKING
2593 if (TREE_CODE_LENGTH (code
) != 4)
2597 t
= make_node_stat (code PASS_MEM_STAT
);
2600 fro
= first_rtl_op (code
);
2602 side_effects
= TREE_SIDE_EFFECTS (t
);
2609 TREE_SIDE_EFFECTS (t
) = side_effects
;
2614 /* Backup definition for non-gcc build compilers. */
2617 (build
) (enum tree_code code
, tree tt
, ...)
2619 tree t
, arg0
, arg1
, arg2
, arg3
;
2620 int length
= TREE_CODE_LENGTH (code
);
2627 t
= build0 (code
, tt
);
2630 arg0
= va_arg (p
, tree
);
2631 t
= build1 (code
, tt
, arg0
);
2634 arg0
= va_arg (p
, tree
);
2635 arg1
= va_arg (p
, tree
);
2636 t
= build2 (code
, tt
, arg0
, arg1
);
2639 arg0
= va_arg (p
, tree
);
2640 arg1
= va_arg (p
, tree
);
2641 arg2
= va_arg (p
, tree
);
2642 t
= build3 (code
, tt
, arg0
, arg1
, arg2
);
2645 arg0
= va_arg (p
, tree
);
2646 arg1
= va_arg (p
, tree
);
2647 arg2
= va_arg (p
, tree
);
2648 arg3
= va_arg (p
, tree
);
2649 t
= build4 (code
, tt
, arg0
, arg1
, arg2
, arg3
);
2659 /* Similar except don't specify the TREE_TYPE
2660 and leave the TREE_SIDE_EFFECTS as 0.
2661 It is permissible for arguments to be null,
2662 or even garbage if their values do not matter. */
2665 build_nt (enum tree_code code
, ...)
2674 t
= make_node (code
);
2675 length
= TREE_CODE_LENGTH (code
);
2677 for (i
= 0; i
< length
; i
++)
2678 TREE_OPERAND (t
, i
) = va_arg (p
, tree
);
2684 /* Create a DECL_... node of code CODE, name NAME and data type TYPE.
2685 We do NOT enter this node in any sort of symbol table.
2687 layout_decl is used to set up the decl's storage layout.
2688 Other slots are initialized to 0 or null pointers. */
2691 build_decl_stat (enum tree_code code
, tree name
, tree type MEM_STAT_DECL
)
2695 t
= make_node_stat (code PASS_MEM_STAT
);
2697 /* if (type == error_mark_node)
2698 type = integer_type_node; */
2699 /* That is not done, deliberately, so that having error_mark_node
2700 as the type can suppress useless errors in the use of this variable. */
2702 DECL_NAME (t
) = name
;
2703 TREE_TYPE (t
) = type
;
2705 if (code
== VAR_DECL
|| code
== PARM_DECL
|| code
== RESULT_DECL
)
2707 else if (code
== FUNCTION_DECL
)
2708 DECL_MODE (t
) = FUNCTION_MODE
;
2713 /* BLOCK nodes are used to represent the structure of binding contours
2714 and declarations, once those contours have been exited and their contents
2715 compiled. This information is used for outputting debugging info. */
2718 build_block (tree vars
, tree tags ATTRIBUTE_UNUSED
, tree subblocks
,
2719 tree supercontext
, tree chain
)
2721 tree block
= make_node (BLOCK
);
2723 BLOCK_VARS (block
) = vars
;
2724 BLOCK_SUBBLOCKS (block
) = subblocks
;
2725 BLOCK_SUPERCONTEXT (block
) = supercontext
;
2726 BLOCK_CHAIN (block
) = chain
;
2730 static GTY(()) tree last_annotated_node
;
2732 /* Record the exact location where an expression or an identifier were
2736 annotate_with_file_line (tree node
, const char *file
, int line
)
2738 /* Roughly one percent of the calls to this function are to annotate
2739 a node with the same information already attached to that node!
2740 Just return instead of wasting memory. */
2741 if (EXPR_LOCUS (node
)
2742 && (EXPR_FILENAME (node
) == file
2743 || ! strcmp (EXPR_FILENAME (node
), file
))
2744 && EXPR_LINENO (node
) == line
)
2746 last_annotated_node
= node
;
2750 /* In heavily macroized code (such as GCC itself) this single
2751 entry cache can reduce the number of allocations by more
2753 if (last_annotated_node
2754 && EXPR_LOCUS (last_annotated_node
)
2755 && (EXPR_FILENAME (last_annotated_node
) == file
2756 || ! strcmp (EXPR_FILENAME (last_annotated_node
), file
))
2757 && EXPR_LINENO (last_annotated_node
) == line
)
2759 SET_EXPR_LOCUS (node
, EXPR_LOCUS (last_annotated_node
));
2763 SET_EXPR_LOCUS (node
, ggc_alloc (sizeof (location_t
)));
2764 EXPR_LINENO (node
) = line
;
2765 EXPR_FILENAME (node
) = file
;
2766 last_annotated_node
= node
;
2770 annotate_with_locus (tree node
, location_t locus
)
2772 annotate_with_file_line (node
, locus
.file
, locus
.line
);
2775 /* Return a declaration like DDECL except that its DECL_ATTRIBUTES
2779 build_decl_attribute_variant (tree ddecl
, tree attribute
)
2781 DECL_ATTRIBUTES (ddecl
) = attribute
;
2785 /* Return a type like TTYPE except that its TYPE_ATTRIBUTE
2788 Record such modified types already made so we don't make duplicates. */
2791 build_type_attribute_variant (tree ttype
, tree attribute
)
2793 if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype
), attribute
))
2795 hashval_t hashcode
= 0;
2797 enum tree_code code
= TREE_CODE (ttype
);
2799 ntype
= copy_node (ttype
);
2801 TYPE_POINTER_TO (ntype
) = 0;
2802 TYPE_REFERENCE_TO (ntype
) = 0;
2803 TYPE_ATTRIBUTES (ntype
) = attribute
;
2805 /* Create a new main variant of TYPE. */
2806 TYPE_MAIN_VARIANT (ntype
) = ntype
;
2807 TYPE_NEXT_VARIANT (ntype
) = 0;
2808 set_type_quals (ntype
, TYPE_UNQUALIFIED
);
2810 hashcode
= iterative_hash_object (code
, hashcode
);
2811 if (TREE_TYPE (ntype
))
2812 hashcode
= iterative_hash_object (TYPE_HASH (TREE_TYPE (ntype
)),
2814 hashcode
= attribute_hash_list (attribute
, hashcode
);
2816 switch (TREE_CODE (ntype
))
2819 hashcode
= type_hash_list (TYPE_ARG_TYPES (ntype
), hashcode
);
2822 hashcode
= iterative_hash_object (TYPE_HASH (TYPE_DOMAIN (ntype
)),
2826 hashcode
= iterative_hash_object
2827 (TREE_INT_CST_LOW (TYPE_MAX_VALUE (ntype
)), hashcode
);
2828 hashcode
= iterative_hash_object
2829 (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (ntype
)), hashcode
);
2833 unsigned int precision
= TYPE_PRECISION (ntype
);
2834 hashcode
= iterative_hash_object (precision
, hashcode
);
2841 ntype
= type_hash_canon (hashcode
, ntype
);
2842 ttype
= build_qualified_type (ntype
, TYPE_QUALS (ttype
));
2848 /* Return nonzero if IDENT is a valid name for attribute ATTR,
2851 We try both `text' and `__text__', ATTR may be either one. */
2852 /* ??? It might be a reasonable simplification to require ATTR to be only
2853 `text'. One might then also require attribute lists to be stored in
2854 their canonicalized form. */
2857 is_attribute_p (const char *attr
, tree ident
)
2859 int ident_len
, attr_len
;
2862 if (TREE_CODE (ident
) != IDENTIFIER_NODE
)
2865 if (strcmp (attr
, IDENTIFIER_POINTER (ident
)) == 0)
2868 p
= IDENTIFIER_POINTER (ident
);
2869 ident_len
= strlen (p
);
2870 attr_len
= strlen (attr
);
2872 /* If ATTR is `__text__', IDENT must be `text'; and vice versa. */
2876 || attr
[attr_len
- 2] != '_'
2877 || attr
[attr_len
- 1] != '_')
2879 if (ident_len
== attr_len
- 4
2880 && strncmp (attr
+ 2, p
, attr_len
- 4) == 0)
2885 if (ident_len
== attr_len
+ 4
2886 && p
[0] == '_' && p
[1] == '_'
2887 && p
[ident_len
- 2] == '_' && p
[ident_len
- 1] == '_'
2888 && strncmp (attr
, p
+ 2, attr_len
) == 0)
2895 /* Given an attribute name and a list of attributes, return a pointer to the
2896 attribute's list element if the attribute is part of the list, or NULL_TREE
2897 if not found. If the attribute appears more than once, this only
2898 returns the first occurrence; the TREE_CHAIN of the return value should
2899 be passed back in if further occurrences are wanted. */
2902 lookup_attribute (const char *attr_name
, tree list
)
2906 for (l
= list
; l
; l
= TREE_CHAIN (l
))
2908 if (TREE_CODE (TREE_PURPOSE (l
)) != IDENTIFIER_NODE
)
2910 if (is_attribute_p (attr_name
, TREE_PURPOSE (l
)))
2917 /* Return an attribute list that is the union of a1 and a2. */
2920 merge_attributes (tree a1
, tree a2
)
2924 /* Either one unset? Take the set one. */
2926 if ((attributes
= a1
) == 0)
2929 /* One that completely contains the other? Take it. */
2931 else if (a2
!= 0 && ! attribute_list_contained (a1
, a2
))
2933 if (attribute_list_contained (a2
, a1
))
2937 /* Pick the longest list, and hang on the other list. */
2939 if (list_length (a1
) < list_length (a2
))
2940 attributes
= a2
, a2
= a1
;
2942 for (; a2
!= 0; a2
= TREE_CHAIN (a2
))
2945 for (a
= lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2
)),
2948 a
= lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2
)),
2951 if (simple_cst_equal (TREE_VALUE (a
), TREE_VALUE (a2
)) == 1)
2956 a1
= copy_node (a2
);
2957 TREE_CHAIN (a1
) = attributes
;
2966 /* Given types T1 and T2, merge their attributes and return
2970 merge_type_attributes (tree t1
, tree t2
)
2972 return merge_attributes (TYPE_ATTRIBUTES (t1
),
2973 TYPE_ATTRIBUTES (t2
));
2976 /* Given decls OLDDECL and NEWDECL, merge their attributes and return
2980 merge_decl_attributes (tree olddecl
, tree newdecl
)
2982 return merge_attributes (DECL_ATTRIBUTES (olddecl
),
2983 DECL_ATTRIBUTES (newdecl
));
2986 #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
2988 /* Specialization of merge_decl_attributes for various Windows targets.
2990 This handles the following situation:
2992 __declspec (dllimport) int foo;
2995 The second instance of `foo' nullifies the dllimport. */
2998 merge_dllimport_decl_attributes (tree old
, tree
new)
3001 int delete_dllimport_p
;
3003 old
= DECL_ATTRIBUTES (old
);
3004 new = DECL_ATTRIBUTES (new);
3006 /* What we need to do here is remove from `old' dllimport if it doesn't
3007 appear in `new'. dllimport behaves like extern: if a declaration is
3008 marked dllimport and a definition appears later, then the object
3009 is not dllimport'd. */
3010 if (lookup_attribute ("dllimport", old
) != NULL_TREE
3011 && lookup_attribute ("dllimport", new) == NULL_TREE
)
3012 delete_dllimport_p
= 1;
3014 delete_dllimport_p
= 0;
3016 a
= merge_attributes (old
, new);
3018 if (delete_dllimport_p
)
3022 /* Scan the list for dllimport and delete it. */
3023 for (prev
= NULL_TREE
, t
= a
; t
; prev
= t
, t
= TREE_CHAIN (t
))
3025 if (is_attribute_p ("dllimport", TREE_PURPOSE (t
)))
3027 if (prev
== NULL_TREE
)
3030 TREE_CHAIN (prev
) = TREE_CHAIN (t
);
3039 #endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES */
3041 /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
3042 of the various TYPE_QUAL values. */
3045 set_type_quals (tree type
, int type_quals
)
3047 TYPE_READONLY (type
) = (type_quals
& TYPE_QUAL_CONST
) != 0;
3048 TYPE_VOLATILE (type
) = (type_quals
& TYPE_QUAL_VOLATILE
) != 0;
3049 TYPE_RESTRICT (type
) = (type_quals
& TYPE_QUAL_RESTRICT
) != 0;
3052 /* Returns true iff cand is equivalent to base with type_quals. */
3055 check_qualified_type (tree cand
, tree base
, int type_quals
)
3057 return (TYPE_QUALS (cand
) == type_quals
3058 && TYPE_NAME (cand
) == TYPE_NAME (base
)
3059 /* Apparently this is needed for Objective-C. */
3060 && TYPE_CONTEXT (cand
) == TYPE_CONTEXT (base
)
3061 && attribute_list_equal (TYPE_ATTRIBUTES (cand
),
3062 TYPE_ATTRIBUTES (base
)));
3065 /* Return a version of the TYPE, qualified as indicated by the
3066 TYPE_QUALS, if one exists. If no qualified version exists yet,
3067 return NULL_TREE. */
3070 get_qualified_type (tree type
, int type_quals
)
3074 if (TYPE_QUALS (type
) == type_quals
)
3077 /* Search the chain of variants to see if there is already one there just
3078 like the one we need to have. If so, use that existing one. We must
3079 preserve the TYPE_NAME, since there is code that depends on this. */
3080 for (t
= TYPE_MAIN_VARIANT (type
); t
; t
= TYPE_NEXT_VARIANT (t
))
3081 if (check_qualified_type (t
, type
, type_quals
))
3087 /* Like get_qualified_type, but creates the type if it does not
3088 exist. This function never returns NULL_TREE. */
3091 build_qualified_type (tree type
, int type_quals
)
3095 /* See if we already have the appropriate qualified variant. */
3096 t
= get_qualified_type (type
, type_quals
);
3098 /* If not, build it. */
3101 t
= build_type_copy (type
);
3102 set_type_quals (t
, type_quals
);
3108 /* Create a new variant of TYPE, equivalent but distinct.
3109 This is so the caller can modify it. */
3112 build_type_copy (tree type
)
3114 tree t
, m
= TYPE_MAIN_VARIANT (type
);
3116 t
= copy_node (type
);
3118 TYPE_POINTER_TO (t
) = 0;
3119 TYPE_REFERENCE_TO (t
) = 0;
3121 /* Add this type to the chain of variants of TYPE. */
3122 TYPE_NEXT_VARIANT (t
) = TYPE_NEXT_VARIANT (m
);
3123 TYPE_NEXT_VARIANT (m
) = t
;
3128 /* Hashing of types so that we don't make duplicates.
3129 The entry point is `type_hash_canon'. */
3131 /* Compute a hash code for a list of types (chain of TREE_LIST nodes
3132 with types in the TREE_VALUE slots), by adding the hash codes
3133 of the individual types. */
3136 type_hash_list (tree list
, hashval_t hashcode
)
3140 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3141 if (TREE_VALUE (tail
) != error_mark_node
)
3142 hashcode
= iterative_hash_object (TYPE_HASH (TREE_VALUE (tail
)),
3148 /* These are the Hashtable callback functions. */
3150 /* Returns true iff the types are equivalent. */
3153 type_hash_eq (const void *va
, const void *vb
)
3155 const struct type_hash
*a
= va
, *b
= vb
;
3157 /* First test the things that are the same for all types. */
3158 if (a
->hash
!= b
->hash
3159 || TREE_CODE (a
->type
) != TREE_CODE (b
->type
)
3160 || TREE_TYPE (a
->type
) != TREE_TYPE (b
->type
)
3161 || !attribute_list_equal (TYPE_ATTRIBUTES (a
->type
),
3162 TYPE_ATTRIBUTES (b
->type
))
3163 || TYPE_ALIGN (a
->type
) != TYPE_ALIGN (b
->type
)
3164 || TYPE_MODE (a
->type
) != TYPE_MODE (b
->type
))
3167 switch (TREE_CODE (a
->type
))
3173 case REFERENCE_TYPE
:
3177 if (TYPE_VALUES (a
->type
) != TYPE_VALUES (b
->type
)
3178 && !(TYPE_VALUES (a
->type
)
3179 && TREE_CODE (TYPE_VALUES (a
->type
)) == TREE_LIST
3180 && TYPE_VALUES (b
->type
)
3181 && TREE_CODE (TYPE_VALUES (b
->type
)) == TREE_LIST
3182 && type_list_equal (TYPE_VALUES (a
->type
),
3183 TYPE_VALUES (b
->type
))))
3186 /* ... fall through ... */
3192 return ((TYPE_MAX_VALUE (a
->type
) == TYPE_MAX_VALUE (b
->type
)
3193 || tree_int_cst_equal (TYPE_MAX_VALUE (a
->type
),
3194 TYPE_MAX_VALUE (b
->type
)))
3195 && (TYPE_MIN_VALUE (a
->type
) == TYPE_MIN_VALUE (b
->type
)
3196 && tree_int_cst_equal (TYPE_MIN_VALUE (a
->type
),
3197 TYPE_MIN_VALUE (b
->type
))));
3200 return TYPE_OFFSET_BASETYPE (a
->type
) == TYPE_OFFSET_BASETYPE (b
->type
);
3203 return (TYPE_METHOD_BASETYPE (a
->type
) == TYPE_METHOD_BASETYPE (b
->type
)
3204 && (TYPE_ARG_TYPES (a
->type
) == TYPE_ARG_TYPES (b
->type
)
3205 || (TYPE_ARG_TYPES (a
->type
)
3206 && TREE_CODE (TYPE_ARG_TYPES (a
->type
)) == TREE_LIST
3207 && TYPE_ARG_TYPES (b
->type
)
3208 && TREE_CODE (TYPE_ARG_TYPES (b
->type
)) == TREE_LIST
3209 && type_list_equal (TYPE_ARG_TYPES (a
->type
),
3210 TYPE_ARG_TYPES (b
->type
)))));
3214 return TYPE_DOMAIN (a
->type
) == TYPE_DOMAIN (b
->type
);
3218 case QUAL_UNION_TYPE
:
3219 return (TYPE_FIELDS (a
->type
) == TYPE_FIELDS (b
->type
)
3220 || (TYPE_FIELDS (a
->type
)
3221 && TREE_CODE (TYPE_FIELDS (a
->type
)) == TREE_LIST
3222 && TYPE_FIELDS (b
->type
)
3223 && TREE_CODE (TYPE_FIELDS (b
->type
)) == TREE_LIST
3224 && type_list_equal (TYPE_FIELDS (a
->type
),
3225 TYPE_FIELDS (b
->type
))));
3228 return (TYPE_ARG_TYPES (a
->type
) == TYPE_ARG_TYPES (b
->type
)
3229 || (TYPE_ARG_TYPES (a
->type
)
3230 && TREE_CODE (TYPE_ARG_TYPES (a
->type
)) == TREE_LIST
3231 && TYPE_ARG_TYPES (b
->type
)
3232 && TREE_CODE (TYPE_ARG_TYPES (b
->type
)) == TREE_LIST
3233 && type_list_equal (TYPE_ARG_TYPES (a
->type
),
3234 TYPE_ARG_TYPES (b
->type
))));
3241 /* Return the cached hash value. */
3244 type_hash_hash (const void *item
)
3246 return ((const struct type_hash
*) item
)->hash
;
3249 /* Look in the type hash table for a type isomorphic to TYPE.
3250 If one is found, return it. Otherwise return 0. */
3253 type_hash_lookup (hashval_t hashcode
, tree type
)
3255 struct type_hash
*h
, in
;
3257 /* The TYPE_ALIGN field of a type is set by layout_type(), so we
3258 must call that routine before comparing TYPE_ALIGNs. */
3264 h
= htab_find_with_hash (type_hash_table
, &in
, hashcode
);
3270 /* Add an entry to the type-hash-table
3271 for a type TYPE whose hash code is HASHCODE. */
3274 type_hash_add (hashval_t hashcode
, tree type
)
3276 struct type_hash
*h
;
3279 h
= ggc_alloc (sizeof (struct type_hash
));
3282 loc
= htab_find_slot_with_hash (type_hash_table
, h
, hashcode
, INSERT
);
3283 *(struct type_hash
**) loc
= h
;
3286 /* Given TYPE, and HASHCODE its hash code, return the canonical
3287 object for an identical type if one already exists.
3288 Otherwise, return TYPE, and record it as the canonical object.
3290 To use this function, first create a type of the sort you want.
3291 Then compute its hash code from the fields of the type that
3292 make it different from other similar types.
3293 Then call this function and use the value. */
3296 type_hash_canon (unsigned int hashcode
, tree type
)
3300 /* The hash table only contains main variants, so ensure that's what we're
3302 if (TYPE_MAIN_VARIANT (type
) != type
)
3305 if (!lang_hooks
.types
.hash_types
)
3308 /* See if the type is in the hash table already. If so, return it.
3309 Otherwise, add the type. */
3310 t1
= type_hash_lookup (hashcode
, type
);
3313 #ifdef GATHER_STATISTICS
3314 tree_node_counts
[(int) t_kind
]--;
3315 tree_node_sizes
[(int) t_kind
] -= sizeof (struct tree_type
);
3321 type_hash_add (hashcode
, type
);
3326 /* See if the data pointed to by the type hash table is marked. We consider
3327 it marked if the type is marked or if a debug type number or symbol
3328 table entry has been made for the type. This reduces the amount of
3329 debugging output and eliminates that dependency of the debug output on
3330 the number of garbage collections. */
3333 type_hash_marked_p (const void *p
)
3335 tree type
= ((struct type_hash
*) p
)->type
;
3337 return ggc_marked_p (type
) || TYPE_SYMTAB_POINTER (type
);
3341 print_type_hash_statistics (void)
3343 fprintf (stderr
, "Type hash: size %ld, %ld elements, %f collisions\n",
3344 (long) htab_size (type_hash_table
),
3345 (long) htab_elements (type_hash_table
),
3346 htab_collisions (type_hash_table
));
3349 /* Compute a hash code for a list of attributes (chain of TREE_LIST nodes
3350 with names in the TREE_PURPOSE slots and args in the TREE_VALUE slots),
3351 by adding the hash codes of the individual attributes. */
3354 attribute_hash_list (tree list
, hashval_t hashcode
)
3358 for (tail
= list
; tail
; tail
= TREE_CHAIN (tail
))
3359 /* ??? Do we want to add in TREE_VALUE too? */
3360 hashcode
= iterative_hash_object
3361 (IDENTIFIER_HASH_VALUE (TREE_PURPOSE (tail
)), hashcode
);
3365 /* Given two lists of attributes, return true if list l2 is
3366 equivalent to l1. */
3369 attribute_list_equal (tree l1
, tree l2
)
3371 return attribute_list_contained (l1
, l2
)
3372 && attribute_list_contained (l2
, l1
);
3375 /* Given two lists of attributes, return true if list L2 is
3376 completely contained within L1. */
3377 /* ??? This would be faster if attribute names were stored in a canonicalized
3378 form. Otherwise, if L1 uses `foo' and L2 uses `__foo__', the long method
3379 must be used to show these elements are equivalent (which they are). */
3380 /* ??? It's not clear that attributes with arguments will always be handled
3384 attribute_list_contained (tree l1
, tree l2
)
3388 /* First check the obvious, maybe the lists are identical. */
3392 /* Maybe the lists are similar. */
3393 for (t1
= l1
, t2
= l2
;
3395 && TREE_PURPOSE (t1
) == TREE_PURPOSE (t2
)
3396 && TREE_VALUE (t1
) == TREE_VALUE (t2
);
3397 t1
= TREE_CHAIN (t1
), t2
= TREE_CHAIN (t2
));
3399 /* Maybe the lists are equal. */
3400 if (t1
== 0 && t2
== 0)
3403 for (; t2
!= 0; t2
= TREE_CHAIN (t2
))
3406 for (attr
= lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2
)), l1
);
3408 attr
= lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2
)),
3411 if (simple_cst_equal (TREE_VALUE (t2
), TREE_VALUE (attr
)) == 1)
3418 if (simple_cst_equal (TREE_VALUE (t2
), TREE_VALUE (attr
)) != 1)
3425 /* Given two lists of types
3426 (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
3427 return 1 if the lists contain the same types in the same order.
3428 Also, the TREE_PURPOSEs must match. */
3431 type_list_equal (tree l1
, tree l2
)
3435 for (t1
= l1
, t2
= l2
; t1
&& t2
; t1
= TREE_CHAIN (t1
), t2
= TREE_CHAIN (t2
))
3436 if (TREE_VALUE (t1
) != TREE_VALUE (t2
)
3437 || (TREE_PURPOSE (t1
) != TREE_PURPOSE (t2
)
3438 && ! (1 == simple_cst_equal (TREE_PURPOSE (t1
), TREE_PURPOSE (t2
))
3439 && (TREE_TYPE (TREE_PURPOSE (t1
))
3440 == TREE_TYPE (TREE_PURPOSE (t2
))))))
3446 /* Returns the number of arguments to the FUNCTION_TYPE or METHOD_TYPE
3447 given by TYPE. If the argument list accepts variable arguments,
3448 then this function counts only the ordinary arguments. */
3451 type_num_arguments (tree type
)
3456 for (t
= TYPE_ARG_TYPES (type
); t
; t
= TREE_CHAIN (t
))
3457 /* If the function does not take a variable number of arguments,
3458 the last element in the list will have type `void'. */
3459 if (VOID_TYPE_P (TREE_VALUE (t
)))
3467 /* Nonzero if integer constants T1 and T2
3468 represent the same constant value. */
3471 tree_int_cst_equal (tree t1
, tree t2
)
3476 if (t1
== 0 || t2
== 0)
3479 if (TREE_CODE (t1
) == INTEGER_CST
3480 && TREE_CODE (t2
) == INTEGER_CST
3481 && TREE_INT_CST_LOW (t1
) == TREE_INT_CST_LOW (t2
)
3482 && TREE_INT_CST_HIGH (t1
) == TREE_INT_CST_HIGH (t2
))
3488 /* Nonzero if integer constants T1 and T2 represent values that satisfy <.
3489 The precise way of comparison depends on their data type. */
3492 tree_int_cst_lt (tree t1
, tree t2
)
3497 if (TYPE_UNSIGNED (TREE_TYPE (t1
)) != TYPE_UNSIGNED (TREE_TYPE (t2
)))
3499 int t1_sgn
= tree_int_cst_sgn (t1
);
3500 int t2_sgn
= tree_int_cst_sgn (t2
);
3502 if (t1_sgn
< t2_sgn
)
3504 else if (t1_sgn
> t2_sgn
)
3506 /* Otherwise, both are non-negative, so we compare them as
3507 unsigned just in case one of them would overflow a signed
3510 else if (!TYPE_UNSIGNED (TREE_TYPE (t1
)))
3511 return INT_CST_LT (t1
, t2
);
3513 return INT_CST_LT_UNSIGNED (t1
, t2
);
3516 /* Returns -1 if T1 < T2, 0 if T1 == T2, and 1 if T1 > T2. */
3519 tree_int_cst_compare (tree t1
, tree t2
)
3521 if (tree_int_cst_lt (t1
, t2
))
3523 else if (tree_int_cst_lt (t2
, t1
))
3529 /* Return 1 if T is an INTEGER_CST that can be manipulated efficiently on
3530 the host. If POS is zero, the value can be represented in a single
3531 HOST_WIDE_INT. If POS is nonzero, the value must be positive and can
3532 be represented in a single unsigned HOST_WIDE_INT. */
3535 host_integerp (tree t
, int pos
)
3537 return (TREE_CODE (t
) == INTEGER_CST
3538 && ! TREE_OVERFLOW (t
)
3539 && ((TREE_INT_CST_HIGH (t
) == 0
3540 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (t
) >= 0)
3541 || (! pos
&& TREE_INT_CST_HIGH (t
) == -1
3542 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (t
) < 0
3543 && !TYPE_UNSIGNED (TREE_TYPE (t
)))
3544 || (pos
&& TREE_INT_CST_HIGH (t
) == 0)));
3547 /* Return the HOST_WIDE_INT least significant bits of T if it is an
3548 INTEGER_CST and there is no overflow. POS is nonzero if the result must
3549 be positive. Abort if we cannot satisfy the above conditions. */
3552 tree_low_cst (tree t
, int pos
)
3554 if (host_integerp (t
, pos
))
3555 return TREE_INT_CST_LOW (t
);
3560 /* Return the most significant bit of the integer constant T. */
3563 tree_int_cst_msb (tree t
)
3567 unsigned HOST_WIDE_INT l
;
3569 /* Note that using TYPE_PRECISION here is wrong. We care about the
3570 actual bits, not the (arbitrary) range of the type. */
3571 prec
= GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t
))) - 1;
3572 rshift_double (TREE_INT_CST_LOW (t
), TREE_INT_CST_HIGH (t
), prec
,
3573 2 * HOST_BITS_PER_WIDE_INT
, &l
, &h
, 0);
3574 return (l
& 1) == 1;
3577 /* Return an indication of the sign of the integer constant T.
3578 The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
3579 Note that -1 will never be returned it T's type is unsigned. */
3582 tree_int_cst_sgn (tree t
)
3584 if (TREE_INT_CST_LOW (t
) == 0 && TREE_INT_CST_HIGH (t
) == 0)
3586 else if (TYPE_UNSIGNED (TREE_TYPE (t
)))
3588 else if (TREE_INT_CST_HIGH (t
) < 0)
3594 /* Compare two constructor-element-type constants. Return 1 if the lists
3595 are known to be equal; otherwise return 0. */
3598 simple_cst_list_equal (tree l1
, tree l2
)
3600 while (l1
!= NULL_TREE
&& l2
!= NULL_TREE
)
3602 if (simple_cst_equal (TREE_VALUE (l1
), TREE_VALUE (l2
)) != 1)
3605 l1
= TREE_CHAIN (l1
);
3606 l2
= TREE_CHAIN (l2
);
3612 /* Return truthvalue of whether T1 is the same tree structure as T2.
3613 Return 1 if they are the same.
3614 Return 0 if they are understandably different.
3615 Return -1 if either contains tree structure not understood by
3619 simple_cst_equal (tree t1
, tree t2
)
3621 enum tree_code code1
, code2
;
3627 if (t1
== 0 || t2
== 0)
3630 code1
= TREE_CODE (t1
);
3631 code2
= TREE_CODE (t2
);
3633 if (code1
== NOP_EXPR
|| code1
== CONVERT_EXPR
|| code1
== NON_LVALUE_EXPR
)
3635 if (code2
== NOP_EXPR
|| code2
== CONVERT_EXPR
3636 || code2
== NON_LVALUE_EXPR
)
3637 return simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3639 return simple_cst_equal (TREE_OPERAND (t1
, 0), t2
);
3642 else if (code2
== NOP_EXPR
|| code2
== CONVERT_EXPR
3643 || code2
== NON_LVALUE_EXPR
)
3644 return simple_cst_equal (t1
, TREE_OPERAND (t2
, 0));
3652 return (TREE_INT_CST_LOW (t1
) == TREE_INT_CST_LOW (t2
)
3653 && TREE_INT_CST_HIGH (t1
) == TREE_INT_CST_HIGH (t2
));
3656 return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1
), TREE_REAL_CST (t2
));
3659 return (TREE_STRING_LENGTH (t1
) == TREE_STRING_LENGTH (t2
)
3660 && ! memcmp (TREE_STRING_POINTER (t1
), TREE_STRING_POINTER (t2
),
3661 TREE_STRING_LENGTH (t1
)));
3664 return simple_cst_list_equal (CONSTRUCTOR_ELTS (t1
),
3665 CONSTRUCTOR_ELTS (t2
));
3668 return simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3671 cmp
= simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3675 simple_cst_list_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t2
, 1));
3678 /* Special case: if either target is an unallocated VAR_DECL,
3679 it means that it's going to be unified with whatever the
3680 TARGET_EXPR is really supposed to initialize, so treat it
3681 as being equivalent to anything. */
3682 if ((TREE_CODE (TREE_OPERAND (t1
, 0)) == VAR_DECL
3683 && DECL_NAME (TREE_OPERAND (t1
, 0)) == NULL_TREE
3684 && !DECL_RTL_SET_P (TREE_OPERAND (t1
, 0)))
3685 || (TREE_CODE (TREE_OPERAND (t2
, 0)) == VAR_DECL
3686 && DECL_NAME (TREE_OPERAND (t2
, 0)) == NULL_TREE
3687 && !DECL_RTL_SET_P (TREE_OPERAND (t2
, 0))))
3690 cmp
= simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3695 return simple_cst_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t2
, 1));
3697 case WITH_CLEANUP_EXPR
:
3698 cmp
= simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3702 return simple_cst_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t1
, 1));
3705 if (TREE_OPERAND (t1
, 1) == TREE_OPERAND (t2
, 1))
3706 return simple_cst_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
3720 /* This general rule works for most tree codes. All exceptions should be
3721 handled above. If this is a language-specific tree code, we can't
3722 trust what might be in the operand, so say we don't know
3724 if ((int) code1
>= (int) LAST_AND_UNUSED_TREE_CODE
)
3727 switch (TREE_CODE_CLASS (code1
))
3736 for (i
= 0; i
< TREE_CODE_LENGTH (code1
); i
++)
3738 cmp
= simple_cst_equal (TREE_OPERAND (t1
, i
), TREE_OPERAND (t2
, i
));
3750 /* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value.
3751 Return -1, 0, or 1 if the value of T is less than, equal to, or greater
3752 than U, respectively. */
3755 compare_tree_int (tree t
, unsigned HOST_WIDE_INT u
)
3757 if (tree_int_cst_sgn (t
) < 0)
3759 else if (TREE_INT_CST_HIGH (t
) != 0)
3761 else if (TREE_INT_CST_LOW (t
) == u
)
3763 else if (TREE_INT_CST_LOW (t
) < u
)
3769 /* Return true if CODE represents an associative tree code. Otherwise
3772 associative_tree_code (enum tree_code code
)
3791 /* Return true if CODE represents an commutative tree code. Otherwise
3794 commutative_tree_code (enum tree_code code
)
3815 /* Generate a hash value for an expression. This can be used iteratively
3816 by passing a previous result as the "val" argument.
3818 This function is intended to produce the same hash for expressions which
3819 would compare equal using operand_equal_p. */
3822 iterative_hash_expr (tree t
, hashval_t val
)
3825 enum tree_code code
;
3829 return iterative_hash_object (t
, val
);
3831 code
= TREE_CODE (t
);
3832 class = TREE_CODE_CLASS (code
);
3836 /* Decls we can just compare by pointer. */
3837 val
= iterative_hash_object (t
, val
);
3839 else if (class == 'c')
3841 /* Alas, constants aren't shared, so we can't rely on pointer
3843 if (code
== INTEGER_CST
)
3845 val
= iterative_hash_object (TREE_INT_CST_LOW (t
), val
);
3846 val
= iterative_hash_object (TREE_INT_CST_HIGH (t
), val
);
3848 else if (code
== REAL_CST
)
3849 val
= iterative_hash (TREE_REAL_CST_PTR (t
),
3850 sizeof (REAL_VALUE_TYPE
), val
);
3851 else if (code
== STRING_CST
)
3852 val
= iterative_hash (TREE_STRING_POINTER (t
),
3853 TREE_STRING_LENGTH (t
), val
);
3854 else if (code
== COMPLEX_CST
)
3856 val
= iterative_hash_expr (TREE_REALPART (t
), val
);
3857 val
= iterative_hash_expr (TREE_IMAGPART (t
), val
);
3859 else if (code
== VECTOR_CST
)
3860 val
= iterative_hash_expr (TREE_VECTOR_CST_ELTS (t
), val
);
3864 else if (IS_EXPR_CODE_CLASS (class))
3866 val
= iterative_hash_object (code
, val
);
3868 /* Don't hash the type, that can lead to having nodes which
3869 compare equal according to operand_equal_p, but which
3870 have different hash codes. */
3871 if (code
== NOP_EXPR
3872 || code
== CONVERT_EXPR
3873 || code
== NON_LVALUE_EXPR
)
3875 /* Make sure to include signness in the hash computation. */
3876 val
+= TYPE_UNSIGNED (TREE_TYPE (t
));
3877 val
= iterative_hash_expr (TREE_OPERAND (t
, 0), val
);
3880 if (commutative_tree_code (code
))
3882 /* It's a commutative expression. We want to hash it the same
3883 however it appears. We do this by first hashing both operands
3884 and then rehashing based on the order of their independent
3886 hashval_t one
= iterative_hash_expr (TREE_OPERAND (t
, 0), 0);
3887 hashval_t two
= iterative_hash_expr (TREE_OPERAND (t
, 1), 0);
3891 t
= one
, one
= two
, two
= t
;
3893 val
= iterative_hash_object (one
, val
);
3894 val
= iterative_hash_object (two
, val
);
3897 for (i
= first_rtl_op (code
) - 1; i
>= 0; --i
)
3898 val
= iterative_hash_expr (TREE_OPERAND (t
, i
), val
);
3900 else if (code
== TREE_LIST
)
3902 /* A list of expressions, for a CALL_EXPR or as the elements of a
3904 for (; t
; t
= TREE_CHAIN (t
))
3905 val
= iterative_hash_expr (TREE_VALUE (t
), val
);
3907 else if (code
== SSA_NAME
)
3909 val
= iterative_hash_object (SSA_NAME_VERSION (t
), val
);
3910 val
= iterative_hash_expr (SSA_NAME_VAR (t
), val
);
3918 /* Constructors for pointer, array and function types.
3919 (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
3920 constructed by language-dependent code, not here.) */
3922 /* Construct, lay out and return the type of pointers to TO_TYPE with
3923 mode MODE. If CAN_ALIAS_ALL is TRUE, indicate this type can
3924 reference all of memory. If such a type has already been
3925 constructed, reuse it. */
3928 build_pointer_type_for_mode (tree to_type
, enum machine_mode mode
,
3933 /* In some cases, languages will have things that aren't a POINTER_TYPE
3934 (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
3935 In that case, return that type without regard to the rest of our
3938 ??? This is a kludge, but consistent with the way this function has
3939 always operated and there doesn't seem to be a good way to avoid this
3941 if (TYPE_POINTER_TO (to_type
) != 0
3942 && TREE_CODE (TYPE_POINTER_TO (to_type
)) != POINTER_TYPE
)
3943 return TYPE_POINTER_TO (to_type
);
3945 /* First, if we already have a type for pointers to TO_TYPE and it's
3946 the proper mode, use it. */
3947 for (t
= TYPE_POINTER_TO (to_type
); t
; t
= TYPE_NEXT_PTR_TO (t
))
3948 if (TYPE_MODE (t
) == mode
&& TYPE_REF_CAN_ALIAS_ALL (t
) == can_alias_all
)
3951 t
= make_node (POINTER_TYPE
);
3953 TREE_TYPE (t
) = to_type
;
3954 TYPE_MODE (t
) = mode
;
3955 TYPE_REF_CAN_ALIAS_ALL (t
) = can_alias_all
;
3956 TYPE_NEXT_PTR_TO (t
) = TYPE_POINTER_TO (to_type
);
3957 TYPE_POINTER_TO (to_type
) = t
;
3959 /* Lay out the type. This function has many callers that are concerned
3960 with expression-construction, and this simplifies them all. */
3966 /* By default build pointers in ptr_mode. */
3969 build_pointer_type (tree to_type
)
3971 return build_pointer_type_for_mode (to_type
, ptr_mode
, false);
3974 /* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE. */
3977 build_reference_type_for_mode (tree to_type
, enum machine_mode mode
,
3982 /* In some cases, languages will have things that aren't a REFERENCE_TYPE
3983 (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
3984 In that case, return that type without regard to the rest of our
3987 ??? This is a kludge, but consistent with the way this function has
3988 always operated and there doesn't seem to be a good way to avoid this
3990 if (TYPE_REFERENCE_TO (to_type
) != 0
3991 && TREE_CODE (TYPE_REFERENCE_TO (to_type
)) != REFERENCE_TYPE
)
3992 return TYPE_REFERENCE_TO (to_type
);
3994 /* First, if we already have a type for pointers to TO_TYPE and it's
3995 the proper mode, use it. */
3996 for (t
= TYPE_REFERENCE_TO (to_type
); t
; t
= TYPE_NEXT_REF_TO (t
))
3997 if (TYPE_MODE (t
) == mode
&& TYPE_REF_CAN_ALIAS_ALL (t
) == can_alias_all
)
4000 t
= make_node (REFERENCE_TYPE
);
4002 TREE_TYPE (t
) = to_type
;
4003 TYPE_MODE (t
) = mode
;
4004 TYPE_REF_CAN_ALIAS_ALL (t
) = can_alias_all
;
4005 TYPE_NEXT_REF_TO (t
) = TYPE_REFERENCE_TO (to_type
);
4006 TYPE_REFERENCE_TO (to_type
) = t
;
4014 /* Build the node for the type of references-to-TO_TYPE by default
4018 build_reference_type (tree to_type
)
4020 return build_reference_type_for_mode (to_type
, ptr_mode
, false);
4023 /* Build a type that is compatible with t but has no cv quals anywhere
4026 const char *const *const * -> char ***. */
4029 build_type_no_quals (tree t
)
4031 switch (TREE_CODE (t
))
4034 return build_pointer_type_for_mode (build_type_no_quals (TREE_TYPE (t
)),
4036 TYPE_REF_CAN_ALIAS_ALL (t
));
4037 case REFERENCE_TYPE
:
4039 build_reference_type_for_mode (build_type_no_quals (TREE_TYPE (t
)),
4041 TYPE_REF_CAN_ALIAS_ALL (t
));
4043 return TYPE_MAIN_VARIANT (t
);
4047 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
4048 MAXVAL should be the maximum value in the domain
4049 (one less than the length of the array).
4051 The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
4052 We don't enforce this limit, that is up to caller (e.g. language front end).
4053 The limit exists because the result is a signed type and we don't handle
4054 sizes that use more than one HOST_WIDE_INT. */
4057 build_index_type (tree maxval
)
4059 tree itype
= make_node (INTEGER_TYPE
);
4061 TREE_TYPE (itype
) = sizetype
;
4062 TYPE_PRECISION (itype
) = TYPE_PRECISION (sizetype
);
4063 TYPE_MIN_VALUE (itype
) = size_zero_node
;
4064 TYPE_MAX_VALUE (itype
) = convert (sizetype
, maxval
);
4065 TYPE_MODE (itype
) = TYPE_MODE (sizetype
);
4066 TYPE_SIZE (itype
) = TYPE_SIZE (sizetype
);
4067 TYPE_SIZE_UNIT (itype
) = TYPE_SIZE_UNIT (sizetype
);
4068 TYPE_ALIGN (itype
) = TYPE_ALIGN (sizetype
);
4069 TYPE_USER_ALIGN (itype
) = TYPE_USER_ALIGN (sizetype
);
4071 if (host_integerp (maxval
, 1))
4072 return type_hash_canon (tree_low_cst (maxval
, 1), itype
);
4077 /* Create a range of some discrete type TYPE (an INTEGER_TYPE,
4078 ENUMERAL_TYPE, BOOLEAN_TYPE, or CHAR_TYPE), with
4079 low bound LOWVAL and high bound HIGHVAL.
4080 if TYPE==NULL_TREE, sizetype is used. */
4083 build_range_type (tree type
, tree lowval
, tree highval
)
4085 tree itype
= make_node (INTEGER_TYPE
);
4087 TREE_TYPE (itype
) = type
;
4088 if (type
== NULL_TREE
)
4091 TYPE_MIN_VALUE (itype
) = convert (type
, lowval
);
4092 TYPE_MAX_VALUE (itype
) = highval
? convert (type
, highval
) : NULL
;
4094 TYPE_PRECISION (itype
) = TYPE_PRECISION (type
);
4095 TYPE_MODE (itype
) = TYPE_MODE (type
);
4096 TYPE_SIZE (itype
) = TYPE_SIZE (type
);
4097 TYPE_SIZE_UNIT (itype
) = TYPE_SIZE_UNIT (type
);
4098 TYPE_ALIGN (itype
) = TYPE_ALIGN (type
);
4099 TYPE_USER_ALIGN (itype
) = TYPE_USER_ALIGN (type
);
4101 if (host_integerp (lowval
, 0) && highval
!= 0 && host_integerp (highval
, 0))
4102 return type_hash_canon (tree_low_cst (highval
, 0)
4103 - tree_low_cst (lowval
, 0),
4109 /* Just like build_index_type, but takes lowval and highval instead
4110 of just highval (maxval). */
4113 build_index_2_type (tree lowval
, tree highval
)
4115 return build_range_type (sizetype
, lowval
, highval
);
4118 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
4119 and number of elements specified by the range of values of INDEX_TYPE.
4120 If such a type has already been constructed, reuse it. */
4123 build_array_type (tree elt_type
, tree index_type
)
4126 hashval_t hashcode
= 0;
4128 if (TREE_CODE (elt_type
) == FUNCTION_TYPE
)
4130 error ("arrays of functions are not meaningful");
4131 elt_type
= integer_type_node
;
4134 t
= make_node (ARRAY_TYPE
);
4135 TREE_TYPE (t
) = elt_type
;
4136 TYPE_DOMAIN (t
) = index_type
;
4138 if (index_type
== 0)
4141 hashcode
= iterative_hash_object (TYPE_HASH (elt_type
), hashcode
);
4142 hashcode
= iterative_hash_object (TYPE_HASH (index_type
), hashcode
);
4143 t
= type_hash_canon (hashcode
, t
);
4145 if (!COMPLETE_TYPE_P (t
))
4150 /* Return the TYPE of the elements comprising
4151 the innermost dimension of ARRAY. */
4154 get_inner_array_type (tree array
)
4156 tree type
= TREE_TYPE (array
);
4158 while (TREE_CODE (type
) == ARRAY_TYPE
)
4159 type
= TREE_TYPE (type
);
4164 /* Construct, lay out and return
4165 the type of functions returning type VALUE_TYPE
4166 given arguments of types ARG_TYPES.
4167 ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
4168 are data type nodes for the arguments of the function.
4169 If such a type has already been constructed, reuse it. */
4172 build_function_type (tree value_type
, tree arg_types
)
4175 hashval_t hashcode
= 0;
4177 if (TREE_CODE (value_type
) == FUNCTION_TYPE
)
4179 error ("function return type cannot be function");
4180 value_type
= integer_type_node
;
4183 /* Make a node of the sort we want. */
4184 t
= make_node (FUNCTION_TYPE
);
4185 TREE_TYPE (t
) = value_type
;
4186 TYPE_ARG_TYPES (t
) = arg_types
;
4188 /* If we already have such a type, use the old one. */
4189 hashcode
= iterative_hash_object (TYPE_HASH (value_type
), hashcode
);
4190 hashcode
= type_hash_list (arg_types
, hashcode
);
4191 t
= type_hash_canon (hashcode
, t
);
4193 if (!COMPLETE_TYPE_P (t
))
4198 /* Build a function type. The RETURN_TYPE is the type returned by the
4199 function. If additional arguments are provided, they are
4200 additional argument types. The list of argument types must always
4201 be terminated by NULL_TREE. */
4204 build_function_type_list (tree return_type
, ...)
4209 va_start (p
, return_type
);
4211 t
= va_arg (p
, tree
);
4212 for (args
= NULL_TREE
; t
!= NULL_TREE
; t
= va_arg (p
, tree
))
4213 args
= tree_cons (NULL_TREE
, t
, args
);
4216 args
= nreverse (args
);
4217 TREE_CHAIN (last
) = void_list_node
;
4218 args
= build_function_type (return_type
, args
);
4224 /* Build a METHOD_TYPE for a member of BASETYPE. The RETTYPE (a TYPE)
4225 and ARGTYPES (a TREE_LIST) are the return type and arguments types
4226 for the method. An implicit additional parameter (of type
4227 pointer-to-BASETYPE) is added to the ARGTYPES. */
4230 build_method_type_directly (tree basetype
,
4238 /* Make a node of the sort we want. */
4239 t
= make_node (METHOD_TYPE
);
4241 TYPE_METHOD_BASETYPE (t
) = TYPE_MAIN_VARIANT (basetype
);
4242 TREE_TYPE (t
) = rettype
;
4243 ptype
= build_pointer_type (basetype
);
4245 /* The actual arglist for this function includes a "hidden" argument
4246 which is "this". Put it into the list of argument types. */
4247 argtypes
= tree_cons (NULL_TREE
, ptype
, argtypes
);
4248 TYPE_ARG_TYPES (t
) = argtypes
;
4250 /* If we already have such a type, use the old one. */
4251 hashcode
= iterative_hash_object (TYPE_HASH (basetype
), hashcode
);
4252 hashcode
= iterative_hash_object (TYPE_HASH (rettype
), hashcode
);
4253 hashcode
= type_hash_list (argtypes
, hashcode
);
4254 t
= type_hash_canon (hashcode
, t
);
4256 if (!COMPLETE_TYPE_P (t
))
4262 /* Construct, lay out and return the type of methods belonging to class
4263 BASETYPE and whose arguments and values are described by TYPE.
4264 If that type exists already, reuse it.
4265 TYPE must be a FUNCTION_TYPE node. */
4268 build_method_type (tree basetype
, tree type
)
4270 if (TREE_CODE (type
) != FUNCTION_TYPE
)
4273 return build_method_type_directly (basetype
,
4275 TYPE_ARG_TYPES (type
));
4278 /* Construct, lay out and return the type of offsets to a value
4279 of type TYPE, within an object of type BASETYPE.
4280 If a suitable offset type exists already, reuse it. */
4283 build_offset_type (tree basetype
, tree type
)
4286 hashval_t hashcode
= 0;
4288 /* Make a node of the sort we want. */
4289 t
= make_node (OFFSET_TYPE
);
4291 TYPE_OFFSET_BASETYPE (t
) = TYPE_MAIN_VARIANT (basetype
);
4292 TREE_TYPE (t
) = type
;
4294 /* If we already have such a type, use the old one. */
4295 hashcode
= iterative_hash_object (TYPE_HASH (basetype
), hashcode
);
4296 hashcode
= iterative_hash_object (TYPE_HASH (type
), hashcode
);
4297 t
= type_hash_canon (hashcode
, t
);
4299 if (!COMPLETE_TYPE_P (t
))
4305 /* Create a complex type whose components are COMPONENT_TYPE. */
4308 build_complex_type (tree component_type
)
4313 /* Make a node of the sort we want. */
4314 t
= make_node (COMPLEX_TYPE
);
4316 TREE_TYPE (t
) = TYPE_MAIN_VARIANT (component_type
);
4318 /* If we already have such a type, use the old one. */
4319 hashcode
= iterative_hash_object (TYPE_HASH (component_type
), 0);
4320 t
= type_hash_canon (hashcode
, t
);
4322 if (!COMPLETE_TYPE_P (t
))
4325 /* If we are writing Dwarf2 output we need to create a name,
4326 since complex is a fundamental type. */
4327 if ((write_symbols
== DWARF2_DEBUG
|| write_symbols
== VMS_AND_DWARF2_DEBUG
)
4331 if (component_type
== char_type_node
)
4332 name
= "complex char";
4333 else if (component_type
== signed_char_type_node
)
4334 name
= "complex signed char";
4335 else if (component_type
== unsigned_char_type_node
)
4336 name
= "complex unsigned char";
4337 else if (component_type
== short_integer_type_node
)
4338 name
= "complex short int";
4339 else if (component_type
== short_unsigned_type_node
)
4340 name
= "complex short unsigned int";
4341 else if (component_type
== integer_type_node
)
4342 name
= "complex int";
4343 else if (component_type
== unsigned_type_node
)
4344 name
= "complex unsigned int";
4345 else if (component_type
== long_integer_type_node
)
4346 name
= "complex long int";
4347 else if (component_type
== long_unsigned_type_node
)
4348 name
= "complex long unsigned int";
4349 else if (component_type
== long_long_integer_type_node
)
4350 name
= "complex long long int";
4351 else if (component_type
== long_long_unsigned_type_node
)
4352 name
= "complex long long unsigned int";
4357 TYPE_NAME (t
) = get_identifier (name
);
4360 return build_qualified_type (t
, TYPE_QUALS (component_type
));
4363 /* Return OP, stripped of any conversions to wider types as much as is safe.
4364 Converting the value back to OP's type makes a value equivalent to OP.
4366 If FOR_TYPE is nonzero, we return a value which, if converted to
4367 type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
4369 If FOR_TYPE is nonzero, unaligned bit-field references may be changed to the
4370 narrowest type that can hold the value, even if they don't exactly fit.
4371 Otherwise, bit-field references are changed to a narrower type
4372 only if they can be fetched directly from memory in that type.
4374 OP must have integer, real or enumeral type. Pointers are not allowed!
4376 There are some cases where the obvious value we could return
4377 would regenerate to OP if converted to OP's type,
4378 but would not extend like OP to wider types.
4379 If FOR_TYPE indicates such extension is contemplated, we eschew such values.
4380 For example, if OP is (unsigned short)(signed char)-1,
4381 we avoid returning (signed char)-1 if FOR_TYPE is int,
4382 even though extending that to an unsigned short would regenerate OP,
4383 since the result of extending (signed char)-1 to (int)
4384 is different from (int) OP. */
4387 get_unwidened (tree op
, tree for_type
)
4389 /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension. */
4390 tree type
= TREE_TYPE (op
);
4392 = TYPE_PRECISION (for_type
!= 0 ? for_type
: type
);
4394 = (for_type
!= 0 && for_type
!= type
4395 && final_prec
> TYPE_PRECISION (type
)
4396 && TYPE_UNSIGNED (type
));
4399 while (TREE_CODE (op
) == NOP_EXPR
)
4402 = TYPE_PRECISION (TREE_TYPE (op
))
4403 - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op
, 0)));
4405 /* Truncations are many-one so cannot be removed.
4406 Unless we are later going to truncate down even farther. */
4408 && final_prec
> TYPE_PRECISION (TREE_TYPE (op
)))
4411 /* See what's inside this conversion. If we decide to strip it,
4413 op
= TREE_OPERAND (op
, 0);
4415 /* If we have not stripped any zero-extensions (uns is 0),
4416 we can strip any kind of extension.
4417 If we have previously stripped a zero-extension,
4418 only zero-extensions can safely be stripped.
4419 Any extension can be stripped if the bits it would produce
4420 are all going to be discarded later by truncating to FOR_TYPE. */
4424 if (! uns
|| final_prec
<= TYPE_PRECISION (TREE_TYPE (op
)))
4426 /* TYPE_UNSIGNED says whether this is a zero-extension.
4427 Let's avoid computing it if it does not affect WIN
4428 and if UNS will not be needed again. */
4429 if ((uns
|| TREE_CODE (op
) == NOP_EXPR
)
4430 && TYPE_UNSIGNED (TREE_TYPE (op
)))
4438 if (TREE_CODE (op
) == COMPONENT_REF
4439 /* Since type_for_size always gives an integer type. */
4440 && TREE_CODE (type
) != REAL_TYPE
4441 /* Don't crash if field not laid out yet. */
4442 && DECL_SIZE (TREE_OPERAND (op
, 1)) != 0
4443 && host_integerp (DECL_SIZE (TREE_OPERAND (op
, 1)), 1))
4445 unsigned int innerprec
4446 = tree_low_cst (DECL_SIZE (TREE_OPERAND (op
, 1)), 1);
4447 int unsignedp
= (DECL_UNSIGNED (TREE_OPERAND (op
, 1))
4448 || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op
, 1))));
4449 type
= lang_hooks
.types
.type_for_size (innerprec
, unsignedp
);
4451 /* We can get this structure field in the narrowest type it fits in.
4452 If FOR_TYPE is 0, do this only for a field that matches the
4453 narrower type exactly and is aligned for it
4454 The resulting extension to its nominal type (a fullword type)
4455 must fit the same conditions as for other extensions. */
4458 && INT_CST_LT_UNSIGNED (TYPE_SIZE (type
), TYPE_SIZE (TREE_TYPE (op
)))
4459 && (for_type
|| ! DECL_BIT_FIELD (TREE_OPERAND (op
, 1)))
4460 && (! uns
|| final_prec
<= innerprec
|| unsignedp
))
4462 win
= build2 (COMPONENT_REF
, type
, TREE_OPERAND (op
, 0),
4463 TREE_OPERAND (op
, 1));
4464 TREE_SIDE_EFFECTS (win
) = TREE_SIDE_EFFECTS (op
);
4465 TREE_THIS_VOLATILE (win
) = TREE_THIS_VOLATILE (op
);
4472 /* Return OP or a simpler expression for a narrower value
4473 which can be sign-extended or zero-extended to give back OP.
4474 Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
4475 or 0 if the value should be sign-extended. */
4478 get_narrower (tree op
, int *unsignedp_ptr
)
4484 while (TREE_CODE (op
) == NOP_EXPR
)
4487 = (TYPE_PRECISION (TREE_TYPE (op
))
4488 - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op
, 0))));
4490 /* Truncations are many-one so cannot be removed. */
4494 /* See what's inside this conversion. If we decide to strip it,
4499 op
= TREE_OPERAND (op
, 0);
4500 /* An extension: the outermost one can be stripped,
4501 but remember whether it is zero or sign extension. */
4503 uns
= TYPE_UNSIGNED (TREE_TYPE (op
));
4504 /* Otherwise, if a sign extension has been stripped,
4505 only sign extensions can now be stripped;
4506 if a zero extension has been stripped, only zero-extensions. */
4507 else if (uns
!= TYPE_UNSIGNED (TREE_TYPE (op
)))
4511 else /* bitschange == 0 */
4513 /* A change in nominal type can always be stripped, but we must
4514 preserve the unsignedness. */
4516 uns
= TYPE_UNSIGNED (TREE_TYPE (op
));
4518 op
= TREE_OPERAND (op
, 0);
4524 if (TREE_CODE (op
) == COMPONENT_REF
4525 /* Since type_for_size always gives an integer type. */
4526 && TREE_CODE (TREE_TYPE (op
)) != REAL_TYPE
4527 /* Ensure field is laid out already. */
4528 && DECL_SIZE (TREE_OPERAND (op
, 1)) != 0)
4530 unsigned HOST_WIDE_INT innerprec
4531 = tree_low_cst (DECL_SIZE (TREE_OPERAND (op
, 1)), 1);
4532 int unsignedp
= (DECL_UNSIGNED (TREE_OPERAND (op
, 1))
4533 || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op
, 1))));
4534 tree type
= lang_hooks
.types
.type_for_size (innerprec
, unsignedp
);
4536 /* We can get this structure field in a narrower type that fits it,
4537 but the resulting extension to its nominal type (a fullword type)
4538 must satisfy the same conditions as for other extensions.
4540 Do this only for fields that are aligned (not bit-fields),
4541 because when bit-field insns will be used there is no
4542 advantage in doing this. */
4544 if (innerprec
< TYPE_PRECISION (TREE_TYPE (op
))
4545 && ! DECL_BIT_FIELD (TREE_OPERAND (op
, 1))
4546 && (first
|| uns
== DECL_UNSIGNED (TREE_OPERAND (op
, 1)))
4550 uns
= DECL_UNSIGNED (TREE_OPERAND (op
, 1));
4551 win
= build2 (COMPONENT_REF
, type
, TREE_OPERAND (op
, 0),
4552 TREE_OPERAND (op
, 1));
4553 TREE_SIDE_EFFECTS (win
) = TREE_SIDE_EFFECTS (op
);
4554 TREE_THIS_VOLATILE (win
) = TREE_THIS_VOLATILE (op
);
4557 *unsignedp_ptr
= uns
;
4561 /* Nonzero if integer constant C has a value that is permissible
4562 for type TYPE (an INTEGER_TYPE). */
4565 int_fits_type_p (tree c
, tree type
)
4567 tree type_low_bound
= TYPE_MIN_VALUE (type
);
4568 tree type_high_bound
= TYPE_MAX_VALUE (type
);
4569 int ok_for_low_bound
, ok_for_high_bound
;
4571 /* Perform some generic filtering first, which may allow making a decision
4572 even if the bounds are not constant. First, negative integers never fit
4573 in unsigned types, */
4574 if ((TYPE_UNSIGNED (type
) && tree_int_cst_sgn (c
) < 0)
4575 /* Also, unsigned integers with top bit set never fit signed types. */
4576 || (! TYPE_UNSIGNED (type
)
4577 && TYPE_UNSIGNED (TREE_TYPE (c
)) && tree_int_cst_msb (c
)))
4580 /* If at least one bound of the type is a constant integer, we can check
4581 ourselves and maybe make a decision. If no such decision is possible, but
4582 this type is a subtype, try checking against that. Otherwise, use
4583 force_fit_type, which checks against the precision.
4585 Compute the status for each possibly constant bound, and return if we see
4586 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
4587 for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
4588 for "constant known to fit". */
4590 ok_for_low_bound
= -1;
4591 ok_for_high_bound
= -1;
4593 /* Check if C >= type_low_bound. */
4594 if (type_low_bound
&& TREE_CODE (type_low_bound
) == INTEGER_CST
)
4596 ok_for_low_bound
= ! tree_int_cst_lt (c
, type_low_bound
);
4597 if (! ok_for_low_bound
)
4601 /* Check if c <= type_high_bound. */
4602 if (type_high_bound
&& TREE_CODE (type_high_bound
) == INTEGER_CST
)
4604 ok_for_high_bound
= ! tree_int_cst_lt (type_high_bound
, c
);
4605 if (! ok_for_high_bound
)
4609 /* If the constant fits both bounds, the result is known. */
4610 if (ok_for_low_bound
== 1 && ok_for_high_bound
== 1)
4613 /* If we haven't been able to decide at this point, there nothing more we
4614 can check ourselves here. Look at the base type if we have one. */
4615 else if (TREE_CODE (type
) == INTEGER_TYPE
&& TREE_TYPE (type
) != 0)
4616 return int_fits_type_p (c
, TREE_TYPE (type
));
4618 /* Or to force_fit_type, if nothing else. */
4622 TREE_TYPE (c
) = type
;
4623 return !force_fit_type (c
, 0);
4627 /* Returns true if T is, contains, or refers to a type with variable
4628 size. This concept is more general than that of C99 'variably
4629 modified types': in C99, a struct type is never variably modified
4630 because a VLA may not appear as a structure member. However, in
4633 struct S { int i[f()]; };
4635 is valid, and other languages may define similar constructs. */
4638 variably_modified_type_p (tree type
)
4642 if (type
== error_mark_node
)
4645 /* If TYPE itself has variable size, it is variably modified.
4647 We do not yet have a representation of the C99 '[*]' syntax.
4648 When a representation is chosen, this function should be modified
4649 to test for that case as well. */
4650 t
= TYPE_SIZE (type
);
4651 if (t
&& t
!= error_mark_node
&& TREE_CODE (t
) != INTEGER_CST
)
4654 switch (TREE_CODE (type
))
4657 case REFERENCE_TYPE
:
4661 if (variably_modified_type_p (TREE_TYPE (type
)))
4667 /* If TYPE is a function type, it is variably modified if any of the
4668 parameters or the return type are variably modified. */
4669 if (variably_modified_type_p (TREE_TYPE (type
)))
4672 for (t
= TYPE_ARG_TYPES (type
);
4673 t
&& t
!= void_list_node
;
4675 if (variably_modified_type_p (TREE_VALUE (t
)))
4684 /* Scalar types are variably modified if their end points
4686 t
= TYPE_MIN_VALUE (type
);
4687 if (t
&& t
!= error_mark_node
&& TREE_CODE (t
) != INTEGER_CST
)
4690 t
= TYPE_MAX_VALUE (type
);
4691 if (t
&& t
!= error_mark_node
&& TREE_CODE (t
) != INTEGER_CST
)
4697 case QUAL_UNION_TYPE
:
4698 /* We can't see if any of the field are variably-modified by the
4699 definition we normally use, since that would produce infinite
4700 recursion via pointers. */
4701 /* This is variably modified if some field's type is. */
4702 for (t
= TYPE_FIELDS (type
); t
; t
= TREE_CHAIN (t
))
4703 if (TREE_CODE (t
) == FIELD_DECL
)
4705 tree t1
= DECL_FIELD_OFFSET (t
);
4707 if (t1
&& t1
!= error_mark_node
&& TREE_CODE (t1
) != INTEGER_CST
)
4711 if (t1
&& t1
!= error_mark_node
&& TREE_CODE (t1
) != INTEGER_CST
)
4720 /* The current language may have other cases to check, but in general,
4721 all other types are not variably modified. */
4722 return lang_hooks
.tree_inlining
.var_mod_type_p (type
);
4725 /* Given a DECL or TYPE, return the scope in which it was declared, or
4726 NULL_TREE if there is no containing scope. */
4729 get_containing_scope (tree t
)
4731 return (TYPE_P (t
) ? TYPE_CONTEXT (t
) : DECL_CONTEXT (t
));
4734 /* Return the innermost context enclosing DECL that is
4735 a FUNCTION_DECL, or zero if none. */
4738 decl_function_context (tree decl
)
4742 if (TREE_CODE (decl
) == ERROR_MARK
)
4745 if (TREE_CODE (decl
) == SAVE_EXPR
)
4746 context
= SAVE_EXPR_CONTEXT (decl
);
4748 /* C++ virtual functions use DECL_CONTEXT for the class of the vtable
4749 where we look up the function at runtime. Such functions always take
4750 a first argument of type 'pointer to real context'.
4752 C++ should really be fixed to use DECL_CONTEXT for the real context,
4753 and use something else for the "virtual context". */
4754 else if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_VINDEX (decl
))
4757 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
4759 context
= DECL_CONTEXT (decl
);
4761 while (context
&& TREE_CODE (context
) != FUNCTION_DECL
)
4763 if (TREE_CODE (context
) == BLOCK
)
4764 context
= BLOCK_SUPERCONTEXT (context
);
4766 context
= get_containing_scope (context
);
4772 /* Return the innermost context enclosing DECL that is
4773 a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
4774 TYPE_DECLs and FUNCTION_DECLs are transparent to this function. */
4777 decl_type_context (tree decl
)
4779 tree context
= DECL_CONTEXT (decl
);
4782 switch (TREE_CODE (context
))
4784 case NAMESPACE_DECL
:
4785 case TRANSLATION_UNIT_DECL
:
4790 case QUAL_UNION_TYPE
:
4795 context
= DECL_CONTEXT (context
);
4799 context
= BLOCK_SUPERCONTEXT (context
);
4809 /* CALL is a CALL_EXPR. Return the declaration for the function
4810 called, or NULL_TREE if the called function cannot be
4814 get_callee_fndecl (tree call
)
4818 /* It's invalid to call this function with anything but a
4820 if (TREE_CODE (call
) != CALL_EXPR
)
4823 /* The first operand to the CALL is the address of the function
4825 addr
= TREE_OPERAND (call
, 0);
4829 /* If this is a readonly function pointer, extract its initial value. */
4830 if (DECL_P (addr
) && TREE_CODE (addr
) != FUNCTION_DECL
4831 && TREE_READONLY (addr
) && ! TREE_THIS_VOLATILE (addr
)
4832 && DECL_INITIAL (addr
))
4833 addr
= DECL_INITIAL (addr
);
4835 /* If the address is just `&f' for some function `f', then we know
4836 that `f' is being called. */
4837 if (TREE_CODE (addr
) == ADDR_EXPR
4838 && TREE_CODE (TREE_OPERAND (addr
, 0)) == FUNCTION_DECL
)
4839 return TREE_OPERAND (addr
, 0);
4841 /* We couldn't figure out what was being called. Maybe the front
4842 end has some idea. */
4843 return lang_hooks
.lang_get_callee_fndecl (call
);
4846 /* Print debugging information about tree nodes generated during the compile,
4847 and any language-specific information. */
4850 dump_tree_statistics (void)
4852 #ifdef GATHER_STATISTICS
4854 int total_nodes
, total_bytes
;
4857 fprintf (stderr
, "\n??? tree nodes created\n\n");
4858 #ifdef GATHER_STATISTICS
4859 fprintf (stderr
, "Kind Nodes Bytes\n");
4860 fprintf (stderr
, "---------------------------------------\n");
4861 total_nodes
= total_bytes
= 0;
4862 for (i
= 0; i
< (int) all_kinds
; i
++)
4864 fprintf (stderr
, "%-20s %7d %10d\n", tree_node_kind_names
[i
],
4865 tree_node_counts
[i
], tree_node_sizes
[i
]);
4866 total_nodes
+= tree_node_counts
[i
];
4867 total_bytes
+= tree_node_sizes
[i
];
4869 fprintf (stderr
, "---------------------------------------\n");
4870 fprintf (stderr
, "%-20s %7d %10d\n", "Total", total_nodes
, total_bytes
);
4871 fprintf (stderr
, "---------------------------------------\n");
4872 ssanames_print_statistics ();
4873 phinodes_print_statistics ();
4875 fprintf (stderr
, "(No per-node statistics)\n");
4877 print_type_hash_statistics ();
4878 lang_hooks
.print_statistics ();
4881 #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
4883 /* Generate a crc32 of a string. */
4886 crc32_string (unsigned chksum
, const char *string
)
4890 unsigned value
= *string
<< 24;
4893 for (ix
= 8; ix
--; value
<<= 1)
4897 feedback
= (value
^ chksum
) & 0x80000000 ? 0x04c11db7 : 0;
4906 /* P is a string that will be used in a symbol. Mask out any characters
4907 that are not valid in that context. */
4910 clean_symbol_name (char *p
)
4914 #ifndef NO_DOLLAR_IN_LABEL /* this for `$'; unlikely, but... -- kr */
4917 #ifndef NO_DOT_IN_LABEL /* this for `.'; unlikely, but... */
4924 /* Generate a name for a function unique to this translation unit.
4925 TYPE is some string to identify the purpose of this function to the
4926 linker or collect2. */
4929 get_file_function_name_long (const char *type
)
4935 if (first_global_object_name
)
4936 p
= first_global_object_name
;
4939 /* We don't have anything that we know to be unique to this translation
4940 unit, so use what we do have and throw in some randomness. */
4942 const char *name
= weak_global_object_name
;
4943 const char *file
= main_input_filename
;
4948 file
= input_filename
;
4950 len
= strlen (file
);
4951 q
= alloca (9 * 2 + len
+ 1);
4952 memcpy (q
, file
, len
+ 1);
4953 clean_symbol_name (q
);
4955 sprintf (q
+ len
, "_%08X_%08X", crc32_string (0, name
),
4956 crc32_string (0, flag_random_seed
));
4961 buf
= alloca (sizeof (FILE_FUNCTION_FORMAT
) + strlen (p
) + strlen (type
));
4963 /* Set up the name of the file-level functions we may need.
4964 Use a global object (which is already required to be unique over
4965 the program) rather than the file name (which imposes extra
4967 sprintf (buf
, FILE_FUNCTION_FORMAT
, type
, p
);
4969 return get_identifier (buf
);
4972 /* If KIND=='I', return a suitable global initializer (constructor) name.
4973 If KIND=='D', return a suitable global clean-up (destructor) name. */
4976 get_file_function_name (int kind
)
4983 return get_file_function_name_long (p
);
4986 /* Expand (the constant part of) a SET_TYPE CONSTRUCTOR node.
4987 The result is placed in BUFFER (which has length BIT_SIZE),
4988 with one bit in each char ('\000' or '\001').
4990 If the constructor is constant, NULL_TREE is returned.
4991 Otherwise, a TREE_LIST of the non-constant elements is emitted. */
4994 get_set_constructor_bits (tree init
, char *buffer
, int bit_size
)
4998 HOST_WIDE_INT domain_min
4999 = tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (init
))), 0);
5000 tree non_const_bits
= NULL_TREE
;
5002 for (i
= 0; i
< bit_size
; i
++)
5005 for (vals
= TREE_OPERAND (init
, 1);
5006 vals
!= NULL_TREE
; vals
= TREE_CHAIN (vals
))
5008 if (!host_integerp (TREE_VALUE (vals
), 0)
5009 || (TREE_PURPOSE (vals
) != NULL_TREE
5010 && !host_integerp (TREE_PURPOSE (vals
), 0)))
5012 = tree_cons (TREE_PURPOSE (vals
), TREE_VALUE (vals
), non_const_bits
);
5013 else if (TREE_PURPOSE (vals
) != NULL_TREE
)
5015 /* Set a range of bits to ones. */
5016 HOST_WIDE_INT lo_index
5017 = tree_low_cst (TREE_PURPOSE (vals
), 0) - domain_min
;
5018 HOST_WIDE_INT hi_index
5019 = tree_low_cst (TREE_VALUE (vals
), 0) - domain_min
;
5021 if (lo_index
< 0 || lo_index
>= bit_size
5022 || hi_index
< 0 || hi_index
>= bit_size
)
5024 for (; lo_index
<= hi_index
; lo_index
++)
5025 buffer
[lo_index
] = 1;
5029 /* Set a single bit to one. */
5031 = tree_low_cst (TREE_VALUE (vals
), 0) - domain_min
;
5032 if (index
< 0 || index
>= bit_size
)
5034 error ("invalid initializer for bit string");
5040 return non_const_bits
;
5043 /* Expand (the constant part of) a SET_TYPE CONSTRUCTOR node.
5044 The result is placed in BUFFER (which is an array of bytes).
5045 If the constructor is constant, NULL_TREE is returned.
5046 Otherwise, a TREE_LIST of the non-constant elements is emitted. */
5049 get_set_constructor_bytes (tree init
, unsigned char *buffer
, int wd_size
)
5052 int set_word_size
= BITS_PER_UNIT
;
5053 int bit_size
= wd_size
* set_word_size
;
5055 unsigned char *bytep
= buffer
;
5056 char *bit_buffer
= alloca (bit_size
);
5057 tree non_const_bits
= get_set_constructor_bits (init
, bit_buffer
, bit_size
);
5059 for (i
= 0; i
< wd_size
; i
++)
5062 for (i
= 0; i
< bit_size
; i
++)
5066 if (BYTES_BIG_ENDIAN
)
5067 *bytep
|= (1 << (set_word_size
- 1 - bit_pos
));
5069 *bytep
|= 1 << bit_pos
;
5072 if (bit_pos
>= set_word_size
)
5073 bit_pos
= 0, bytep
++;
5075 return non_const_bits
;
5078 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
5080 /* Complain that the tree code of NODE does not match the expected CODE.
5081 FILE, LINE, and FUNCTION are of the caller. */
5084 tree_check_failed (const tree node
, enum tree_code code
, const char *file
,
5085 int line
, const char *function
)
5087 internal_error ("tree check: expected %s, have %s in %s, at %s:%d",
5088 tree_code_name
[code
], tree_code_name
[TREE_CODE (node
)],
5089 function
, trim_filename (file
), line
);
5092 /* Similar to above except that we allowed the code to be one of two
5096 tree_check2_failed (const tree node
, enum tree_code code1
,
5097 enum tree_code code2
, const char *file
,
5098 int line
, const char *function
)
5100 internal_error ("tree check: expected %s or %s, have %s in %s, at %s:%d",
5101 tree_code_name
[code1
], tree_code_name
[code2
],
5102 tree_code_name
[TREE_CODE (node
)],
5103 function
, trim_filename (file
), line
);
5106 /* Likewise for three different codes. */
5109 tree_check3_failed (const tree node
, enum tree_code code1
,
5110 enum tree_code code2
, enum tree_code code3
,
5111 const char *file
, int line
, const char *function
)
5113 internal_error ("tree check: expected %s, %s or %s; have %s in %s, at %s:%d",
5114 tree_code_name
[code1
], tree_code_name
[code2
],
5115 tree_code_name
[code3
], tree_code_name
[TREE_CODE (node
)],
5116 function
, trim_filename (file
), line
);
5119 /* ... and for four different codes. */
5122 tree_check4_failed (const tree node
, enum tree_code code1
,
5123 enum tree_code code2
, enum tree_code code3
,
5124 enum tree_code code4
, const char *file
, int line
,
5125 const char *function
)
5128 ("tree check: expected %s, %s, %s or %s; have %s in %s, at %s:%d",
5129 tree_code_name
[code1
], tree_code_name
[code2
], tree_code_name
[code3
],
5130 tree_code_name
[code4
], tree_code_name
[TREE_CODE (node
)], function
,
5131 trim_filename (file
), line
);
5134 /* ... and for five different codes. */
5137 tree_check5_failed (const tree node
, enum tree_code code1
,
5138 enum tree_code code2
, enum tree_code code3
,
5139 enum tree_code code4
, enum tree_code code5
,
5140 const char *file
, int line
, const char *function
)
5143 ("tree check: expected %s, %s, %s, %s or %s; have %s in %s, at %s:%d",
5144 tree_code_name
[code1
], tree_code_name
[code2
], tree_code_name
[code3
],
5145 tree_code_name
[code4
], tree_code_name
[code5
],
5146 tree_code_name
[TREE_CODE (node
)], function
, trim_filename (file
), line
);
5149 /* Similar to tree_check_failed, except that we check for a class of tree
5150 code, given in CL. */
5153 tree_class_check_failed (const tree node
, int cl
, const char *file
,
5154 int line
, const char *function
)
5157 ("tree check: expected class '%c', have '%c' (%s) in %s, at %s:%d",
5158 cl
, TREE_CODE_CLASS (TREE_CODE (node
)),
5159 tree_code_name
[TREE_CODE (node
)], function
, trim_filename (file
), line
);
5162 /* Similar to above, except that the check is for the bounds of a TREE_VEC's
5163 (dynamically sized) vector. */
5166 tree_vec_elt_check_failed (int idx
, int len
, const char *file
, int line
,
5167 const char *function
)
5170 ("tree check: accessed elt %d of tree_vec with %d elts in %s, at %s:%d",
5171 idx
+ 1, len
, function
, trim_filename (file
), line
);
5174 /* Similar to above, except that the check is for the bounds of a EPHI_NODE's
5175 (dynamically sized) vector. */
5178 ephi_node_elt_check_failed (int idx
, int len
, const char *file
, int line
,
5179 const char *function
)
5182 ("tree check: accessed elt %d of ephi_node with %d elts in %s, at %s:%d",
5183 idx
+ 1, len
, function
, trim_filename (file
), line
);
5186 /* Similar to above, except that the check is for the bounds of a PHI_NODE's
5187 (dynamically sized) vector. */
5190 phi_node_elt_check_failed (int idx
, int len
, const char *file
, int line
,
5191 const char *function
)
5194 ("tree check: accessed elt %d of phi_node with %d elts in %s, at %s:%d",
5195 idx
+ 1, len
, function
, trim_filename (file
), line
);
5198 /* Similar to above, except that the check is for the bounds of the operand
5199 vector of an expression node. */
5202 tree_operand_check_failed (int idx
, enum tree_code code
, const char *file
,
5203 int line
, const char *function
)
5206 ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d",
5207 idx
+ 1, tree_code_name
[code
], TREE_CODE_LENGTH (code
),
5208 function
, trim_filename (file
), line
);
5210 #endif /* ENABLE_TREE_CHECKING */
5212 /* For a new vector type node T, build the information necessary for
5213 debugging output. */
5216 finish_vector_type (tree t
)
5221 tree index
= build_int_2 (TYPE_VECTOR_SUBPARTS (t
) - 1, 0);
5222 tree array
= build_array_type (TREE_TYPE (t
),
5223 build_index_type (index
));
5224 tree rt
= make_node (RECORD_TYPE
);
5226 TYPE_FIELDS (rt
) = build_decl (FIELD_DECL
, get_identifier ("f"), array
);
5227 DECL_CONTEXT (TYPE_FIELDS (rt
)) = rt
;
5229 TYPE_DEBUG_REPRESENTATION_TYPE (t
) = rt
;
5230 /* In dwarfout.c, type lookup uses TYPE_UID numbers. We want to output
5231 the representation type, and we want to find that die when looking up
5232 the vector type. This is most easily achieved by making the TYPE_UID
5234 TYPE_UID (rt
) = TYPE_UID (t
);
5239 make_or_reuse_type (unsigned size
, int unsignedp
)
5241 if (size
== INT_TYPE_SIZE
)
5242 return unsignedp
? unsigned_type_node
: integer_type_node
;
5243 if (size
== CHAR_TYPE_SIZE
)
5244 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
5245 if (size
== SHORT_TYPE_SIZE
)
5246 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
5247 if (size
== LONG_TYPE_SIZE
)
5248 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
5249 if (size
== LONG_LONG_TYPE_SIZE
)
5250 return (unsignedp
? long_long_unsigned_type_node
5251 : long_long_integer_type_node
);
5254 return make_unsigned_type (size
);
5256 return make_signed_type (size
);
5259 /* Create nodes for all integer types (and error_mark_node) using the sizes
5260 of C datatypes. The caller should call set_sizetype soon after calling
5261 this function to select one of the types as sizetype. */
5264 build_common_tree_nodes (int signed_char
)
5266 error_mark_node
= make_node (ERROR_MARK
);
5267 TREE_TYPE (error_mark_node
) = error_mark_node
;
5269 initialize_sizetypes ();
5271 /* Define both `signed char' and `unsigned char'. */
5272 signed_char_type_node
= make_signed_type (CHAR_TYPE_SIZE
);
5273 unsigned_char_type_node
= make_unsigned_type (CHAR_TYPE_SIZE
);
5275 /* Define `char', which is like either `signed char' or `unsigned char'
5276 but not the same as either. */
5279 ? make_signed_type (CHAR_TYPE_SIZE
)
5280 : make_unsigned_type (CHAR_TYPE_SIZE
));
5282 short_integer_type_node
= make_signed_type (SHORT_TYPE_SIZE
);
5283 short_unsigned_type_node
= make_unsigned_type (SHORT_TYPE_SIZE
);
5284 integer_type_node
= make_signed_type (INT_TYPE_SIZE
);
5285 unsigned_type_node
= make_unsigned_type (INT_TYPE_SIZE
);
5286 long_integer_type_node
= make_signed_type (LONG_TYPE_SIZE
);
5287 long_unsigned_type_node
= make_unsigned_type (LONG_TYPE_SIZE
);
5288 long_long_integer_type_node
= make_signed_type (LONG_LONG_TYPE_SIZE
);
5289 long_long_unsigned_type_node
= make_unsigned_type (LONG_LONG_TYPE_SIZE
);
5291 /* Define a boolean type. This type only represents boolean values but
5292 may be larger than char depending on the value of BOOL_TYPE_SIZE.
5293 Front ends which want to override this size (i.e. Java) can redefine
5294 boolean_type_node before calling build_common_tree_nodes_2. */
5295 boolean_type_node
= make_unsigned_type (BOOL_TYPE_SIZE
);
5296 TREE_SET_CODE (boolean_type_node
, BOOLEAN_TYPE
);
5297 TYPE_MAX_VALUE (boolean_type_node
) = build_int_2 (1, 0);
5298 TREE_TYPE (TYPE_MAX_VALUE (boolean_type_node
)) = boolean_type_node
;
5299 TYPE_PRECISION (boolean_type_node
) = 1;
5301 /* Fill in the rest of the sized types. Reuse existing type nodes
5303 intQI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (QImode
), 0);
5304 intHI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (HImode
), 0);
5305 intSI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (SImode
), 0);
5306 intDI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (DImode
), 0);
5307 intTI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (TImode
), 0);
5309 unsigned_intQI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (QImode
), 1);
5310 unsigned_intHI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (HImode
), 1);
5311 unsigned_intSI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (SImode
), 1);
5312 unsigned_intDI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (DImode
), 1);
5313 unsigned_intTI_type_node
= make_or_reuse_type (GET_MODE_BITSIZE (TImode
), 1);
5315 access_public_node
= get_identifier ("public");
5316 access_protected_node
= get_identifier ("protected");
5317 access_private_node
= get_identifier ("private");
5320 /* Call this function after calling build_common_tree_nodes and set_sizetype.
5321 It will create several other common tree nodes. */
5324 build_common_tree_nodes_2 (int short_double
)
5326 /* Define these next since types below may used them. */
5327 integer_zero_node
= build_int_2 (0, 0);
5328 integer_one_node
= build_int_2 (1, 0);
5329 integer_minus_one_node
= build_int_2 (-1, -1);
5331 size_zero_node
= size_int (0);
5332 size_one_node
= size_int (1);
5333 bitsize_zero_node
= bitsize_int (0);
5334 bitsize_one_node
= bitsize_int (1);
5335 bitsize_unit_node
= bitsize_int (BITS_PER_UNIT
);
5337 boolean_false_node
= TYPE_MIN_VALUE (boolean_type_node
);
5338 boolean_true_node
= TYPE_MAX_VALUE (boolean_type_node
);
5340 void_type_node
= make_node (VOID_TYPE
);
5341 layout_type (void_type_node
);
5343 /* We are not going to have real types in C with less than byte alignment,
5344 so we might as well not have any types that claim to have it. */
5345 TYPE_ALIGN (void_type_node
) = BITS_PER_UNIT
;
5346 TYPE_USER_ALIGN (void_type_node
) = 0;
5348 null_pointer_node
= build_int_2 (0, 0);
5349 TREE_TYPE (null_pointer_node
) = build_pointer_type (void_type_node
);
5350 layout_type (TREE_TYPE (null_pointer_node
));
5352 ptr_type_node
= build_pointer_type (void_type_node
);
5354 = build_pointer_type (build_type_variant (void_type_node
, 1, 0));
5356 float_type_node
= make_node (REAL_TYPE
);
5357 TYPE_PRECISION (float_type_node
) = FLOAT_TYPE_SIZE
;
5358 layout_type (float_type_node
);
5360 double_type_node
= make_node (REAL_TYPE
);
5362 TYPE_PRECISION (double_type_node
) = FLOAT_TYPE_SIZE
;
5364 TYPE_PRECISION (double_type_node
) = DOUBLE_TYPE_SIZE
;
5365 layout_type (double_type_node
);
5367 long_double_type_node
= make_node (REAL_TYPE
);
5368 TYPE_PRECISION (long_double_type_node
) = LONG_DOUBLE_TYPE_SIZE
;
5369 layout_type (long_double_type_node
);
5371 float_ptr_type_node
= build_pointer_type (float_type_node
);
5372 double_ptr_type_node
= build_pointer_type (double_type_node
);
5373 long_double_ptr_type_node
= build_pointer_type (long_double_type_node
);
5374 integer_ptr_type_node
= build_pointer_type (integer_type_node
);
5376 complex_integer_type_node
= make_node (COMPLEX_TYPE
);
5377 TREE_TYPE (complex_integer_type_node
) = integer_type_node
;
5378 layout_type (complex_integer_type_node
);
5380 complex_float_type_node
= make_node (COMPLEX_TYPE
);
5381 TREE_TYPE (complex_float_type_node
) = float_type_node
;
5382 layout_type (complex_float_type_node
);
5384 complex_double_type_node
= make_node (COMPLEX_TYPE
);
5385 TREE_TYPE (complex_double_type_node
) = double_type_node
;
5386 layout_type (complex_double_type_node
);
5388 complex_long_double_type_node
= make_node (COMPLEX_TYPE
);
5389 TREE_TYPE (complex_long_double_type_node
) = long_double_type_node
;
5390 layout_type (complex_long_double_type_node
);
5393 tree t
= targetm
.build_builtin_va_list ();
5395 /* Many back-ends define record types without setting TYPE_NAME.
5396 If we copied the record type here, we'd keep the original
5397 record type without a name. This breaks name mangling. So,
5398 don't copy record types and let c_common_nodes_and_builtins()
5399 declare the type to be __builtin_va_list. */
5400 if (TREE_CODE (t
) != RECORD_TYPE
)
5401 t
= build_type_copy (t
);
5403 va_list_type_node
= t
;
5407 /* HACK. GROSS. This is absolutely disgusting. I wish there was a
5410 If we requested a pointer to a vector, build up the pointers that
5411 we stripped off while looking for the inner type. Similarly for
5412 return values from functions.
5414 The argument TYPE is the top of the chain, and BOTTOM is the
5415 new type which we will point to. */
5418 reconstruct_complex_type (tree type
, tree bottom
)
5422 if (POINTER_TYPE_P (type
))
5424 inner
= reconstruct_complex_type (TREE_TYPE (type
), bottom
);
5425 outer
= build_pointer_type (inner
);
5427 else if (TREE_CODE (type
) == ARRAY_TYPE
)
5429 inner
= reconstruct_complex_type (TREE_TYPE (type
), bottom
);
5430 outer
= build_array_type (inner
, TYPE_DOMAIN (type
));
5432 else if (TREE_CODE (type
) == FUNCTION_TYPE
)
5434 inner
= reconstruct_complex_type (TREE_TYPE (type
), bottom
);
5435 outer
= build_function_type (inner
, TYPE_ARG_TYPES (type
));
5437 else if (TREE_CODE (type
) == METHOD_TYPE
)
5439 inner
= reconstruct_complex_type (TREE_TYPE (type
), bottom
);
5440 outer
= build_method_type_directly (TYPE_METHOD_BASETYPE (type
),
5442 TYPE_ARG_TYPES (type
));
5447 TYPE_READONLY (outer
) = TYPE_READONLY (type
);
5448 TYPE_VOLATILE (outer
) = TYPE_VOLATILE (type
);
5453 /* Returns a vector tree node given a vector mode and inner type. */
5455 build_vector_type_for_mode (tree innertype
, enum machine_mode mode
)
5458 t
= make_node (VECTOR_TYPE
);
5459 TREE_TYPE (t
) = innertype
;
5460 TYPE_MODE (t
) = mode
;
5461 finish_vector_type (t
);
5465 /* Similarly, but takes inner type and units. */
5468 build_vector_type (tree innertype
, int nunits
)
5470 enum machine_mode innermode
= TYPE_MODE (innertype
);
5471 enum machine_mode mode
;
5473 if (GET_MODE_CLASS (innermode
) == MODE_FLOAT
)
5474 mode
= MIN_MODE_VECTOR_FLOAT
;
5476 mode
= MIN_MODE_VECTOR_INT
;
5478 for (; mode
!= VOIDmode
; mode
= GET_MODE_WIDER_MODE (mode
))
5479 if (GET_MODE_NUNITS (mode
) == nunits
&& GET_MODE_INNER (mode
) == innermode
)
5480 return build_vector_type_for_mode (innertype
, mode
);
5485 /* Given an initializer INIT, return TRUE if INIT is zero or some
5486 aggregate of zeros. Otherwise return FALSE. */
5488 initializer_zerop (tree init
)
5494 switch (TREE_CODE (init
))
5497 return integer_zerop (init
);
5500 /* ??? Note that this is not correct for C4X float formats. There,
5501 a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
5502 negative exponent. */
5503 return real_zerop (init
)
5504 && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init
));
5507 return integer_zerop (init
)
5508 || (real_zerop (init
)
5509 && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init
)))
5510 && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init
))));
5513 for (elt
= TREE_VECTOR_CST_ELTS (init
); elt
; elt
= TREE_CHAIN (elt
))
5514 if (!initializer_zerop (TREE_VALUE (elt
)))
5519 elt
= CONSTRUCTOR_ELTS (init
);
5520 if (elt
== NULL_TREE
)
5523 /* A set is empty only if it has no elements. */
5524 if (TREE_CODE (TREE_TYPE (init
)) == SET_TYPE
)
5527 for (; elt
; elt
= TREE_CHAIN (elt
))
5528 if (! initializer_zerop (TREE_VALUE (elt
)))
5538 add_var_to_bind_expr (tree bind_expr
, tree var
)
5540 BIND_EXPR_VARS (bind_expr
)
5541 = chainon (BIND_EXPR_VARS (bind_expr
), var
);
5542 if (BIND_EXPR_BLOCK (bind_expr
))
5543 BLOCK_VARS (BIND_EXPR_BLOCK (bind_expr
))
5544 = BIND_EXPR_VARS (bind_expr
);
5547 /* Build an empty statement. */
5550 build_empty_stmt (void)
5552 return build1 (NOP_EXPR
, void_type_node
, size_zero_node
);
5556 is_essa_node (tree t
)
5558 if (TREE_CODE (t
) == EPHI_NODE
|| TREE_CODE (t
) == EUSE_NODE
5559 || TREE_CODE (t
) == EEXIT_NODE
|| TREE_CODE (t
) == EKILL_NODE
)
5565 /* Return true if T (assumed to be a DECL) must be assigned a memory
5569 needs_to_live_in_memory (tree t
)
5571 return (DECL_NEEDS_TO_LIVE_IN_MEMORY_INTERNAL (t
)
5573 || DECL_EXTERNAL (t
)
5574 || DECL_NONLOCAL (t
)
5575 || (TREE_CODE (t
) == RESULT_DECL
5576 && aggregate_value_p (t
, current_function_decl
))
5577 || decl_function_context (t
) != current_function_decl
);
5580 #include "gt-tree.h"