X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ftree.c;h=c45e807b43d96dd46932a43540a1a65d3c8d8bf1;hb=d62a642a79aa9558d852f37bb0d922734ad707e2;hp=76be316eef9f58bdbdc85c9fb7aefbd3164ca361;hpb=578fcce9dee02ac2ac2a7f76634d8befccc51ef3;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/tree.c b/gcc/tree.c index 76be316eef9..c45e807b43d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1041,6 +1041,14 @@ build_int_cst (tree type, HOST_WIDE_INT low) return build_int_cst_wide (type, low, low < 0 ? -1 : 0); } +/* Create an INT_CST node with a LOW value zero extended. */ + +tree +build_int_cstu (tree type, unsigned HOST_WIDE_INT low) +{ + return build_int_cst_wide (type, low, 0); +} + /* Create an INT_CST node with a LOW value in TYPE. The value is sign extended if it is negative. This function is similar to build_int_cst, but the extra bits outside of the type precision are cleared. Constants @@ -1080,12 +1088,7 @@ build_int_cst_wide_type (tree type, tree double_int_to_tree (tree type, double_int cst) { - /* Size types *are* sign extended. */ - bool sign_extended_type = (!TYPE_UNSIGNED (type) - || (TREE_CODE (type) == INTEGER_TYPE - && TYPE_IS_SIZETYPE (type))); - - cst = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); + cst = double_int_ext (cst, TYPE_PRECISION (type), TYPE_UNSIGNED (type)); return build_int_cst_wide (type, cst.low, cst.high); } @@ -1096,13 +1099,9 @@ double_int_to_tree (tree type, double_int cst) bool double_int_fits_to_tree_p (const_tree type, double_int cst) { - /* Size types *are* sign extended. */ - bool sign_extended_type = (!TYPE_UNSIGNED (type) - || (TREE_CODE (type) == INTEGER_TYPE - && TYPE_IS_SIZETYPE (type))); - - double_int ext - = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); + double_int ext = double_int_ext (cst, + TYPE_PRECISION (type), + TYPE_UNSIGNED (type)); return double_int_equal_p (cst, ext); } @@ -1333,22 +1332,8 @@ tree build_constructor (tree type, VEC(constructor_elt,gc) *vals) { tree c = make_node (CONSTRUCTOR); - unsigned int i; - constructor_elt *elt; - bool constant_p = true; - TREE_TYPE (c) = type; CONSTRUCTOR_ELTS (c) = vals; - - for (i = 0; VEC_iterate (constructor_elt, vals, i, elt); i++) - if (!TREE_CONSTANT (elt->value)) - { - constant_p = false; - break; - } - - TREE_CONSTANT (c) = constant_p; - return c; } @@ -1359,13 +1344,16 @@ build_constructor_single (tree type, tree index, tree value) { VEC(constructor_elt,gc) *v; constructor_elt *elt; + tree t; v = VEC_alloc (constructor_elt, gc, 1); elt = VEC_quick_push (constructor_elt, v, NULL); elt->index = index; elt->value = value; - return build_constructor (type, v); + t = build_constructor (type, v); + TREE_CONSTANT (t) = TREE_CONSTANT (value); + return t; } @@ -1374,17 +1362,27 @@ build_constructor_single (tree type, tree index, tree value) tree build_constructor_from_list (tree type, tree vals) { - tree t; + tree t, val; VEC(constructor_elt,gc) *v = NULL; + bool constant_p = true; if (vals) { v = VEC_alloc (constructor_elt, gc, list_length (vals)); for (t = vals; t; t = TREE_CHAIN (t)) - CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t)); + { + constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL); + val = TREE_VALUE (t); + elt->index = TREE_PURPOSE (t); + elt->value = val; + if (!TREE_CONSTANT (val)) + constant_p = false; + } } - return build_constructor (type, v); + t = build_constructor (type, v); + TREE_CONSTANT (t) = constant_p; + return t; } /* Return a new FIXED_CST node whose type is TYPE and value is F. */ @@ -2125,6 +2123,25 @@ tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) return node; } +/* Return the elements of a CONSTRUCTOR as a TREE_LIST. */ + +tree +ctor_to_list (tree ctor) +{ + tree list = NULL_TREE; + tree *p = &list; + unsigned ix; + tree purpose, val; + + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), ix, purpose, val) + { + *p = build_tree_list (purpose, val); + p = &TREE_CHAIN (*p); + } + + return list; +} + /* Return the values of the elements of a CONSTRUCTOR as a vector of trees. */ @@ -5021,6 +5038,7 @@ free_lang_data (void) lang_hooks.dwarf_name = lhd_dwarf_name; lang_hooks.decl_printable_name = gimple_decl_printable_name; lang_hooks.set_decl_assembler_name = lhd_set_decl_assembler_name; + lang_hooks.fold_obj_type_ref = gimple_fold_obj_type_ref; /* Reset diagnostic machinery. */ diagnostic_starter (global_dc) = default_diagnostic_starter; @@ -7331,7 +7349,7 @@ build_function_type_list_1 (bool vaargs, tree return_type, va_list argp) last = args; if (args != NULL_TREE) args = nreverse (args); - gcc_assert (last != void_list_node); + gcc_assert (args != NULL_TREE && last != void_list_node); } else if (args == NULL_TREE) args = void_list_node; @@ -9084,13 +9102,10 @@ build_common_builtin_nodes (void) tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); ftype = build_function_type (ptr_type_node, tmp); local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA, - "alloca", ECF_MALLOC | ECF_NOTHROW); + "alloca", + ECF_MALLOC | (flag_stack_check ? 0 : ECF_NOTHROW)); } - /* If we're checking the stack, `alloca' can throw. */ - if (flag_stack_check) - TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA]) = 0; - tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); @@ -10377,6 +10392,22 @@ tree_block (tree t) return NULL; } +/* Build and return a TREE_LIST of arguments in the CALL_EXPR exp. + FIXME: don't use this function. It exists for compatibility with + the old representation of CALL_EXPRs where a list was used to hold the + arguments. Places that currently extract the arglist from a CALL_EXPR + ought to be rewritten to use the CALL_EXPR itself. */ +tree +call_expr_arglist (tree exp) +{ + tree arglist = NULL_TREE; + int i; + for (i = call_expr_nargs (exp) - 1; i >= 0; i--) + arglist = tree_cons (NULL_TREE, CALL_EXPR_ARG (exp, i), arglist); + return arglist; +} + + /* Create a nameless artificial label and put it in the current function context. The label has a location of LOC. Returns the newly created label. */ @@ -10780,60 +10811,4 @@ lhd_gcc_personality (void) return gcc_eh_personality_decl; } -/* Try to find a base info of BINFO that would have its field decl at offset - OFFSET within the BINFO type and which is of EXPECTED_TYPE. If it can be - found, return, otherwise return NULL_TREE. */ - -tree -get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type) -{ - tree type; - - if (offset == 0) - return binfo; - - type = TREE_TYPE (binfo); - while (offset > 0) - { - tree base_binfo, found_binfo; - HOST_WIDE_INT pos, size; - tree fld; - int i; - - if (TREE_CODE (type) != RECORD_TYPE) - return NULL_TREE; - - for (fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld)) - { - if (TREE_CODE (fld) != FIELD_DECL) - continue; - - pos = int_bit_position (fld); - size = tree_low_cst (DECL_SIZE (fld), 1); - if (pos <= offset && (pos + size) > offset) - break; - } - if (!fld) - return NULL_TREE; - - found_binfo = NULL_TREE; - for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) - if (TREE_TYPE (base_binfo) == TREE_TYPE (fld)) - { - found_binfo = base_binfo; - break; - } - - if (!found_binfo) - return NULL_TREE; - - type = TREE_TYPE (fld); - binfo = found_binfo; - offset -= pos; - } - if (type != expected_type) - return NULL_TREE; - return binfo; -} - #include "gt-tree.h"