diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2000-02-27 21:39:40 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2000-02-27 16:39:40 -0500 |
commit | fed3cef0dbbd17e3d7b8860f42cd8490f0325340 (patch) | |
tree | da73c398c9c03435ecc0d3821031b7c0fe89911d /gcc/cp/class.c | |
parent | 43931371e2321b6c50c3e0b9095d46606ec48ce1 (diff) | |
download | gcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.zip gcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.tar.gz gcc-fed3cef0dbbd17e3d7b8860f42cd8490f0325340.tar.bz2 |
builtins.c (c_strlen): Use size_diffop and return ssizetype value.
* builtins.c (c_strlen): Use size_diffop and return ssizetype value.
(expand_builtin_strcpy): Pass correct type to size_binop.
(expand_builtin_strcmp): Likewise.
Clean up conditional structure.
* c-decl.c (init_decl_processing): Don't call set_sizetype twice.
(complete_array_type): Don't use size_binop for MAXINDEX.
* c-typeck.c (c_sizeof): Use size_one_node and TYPE_SIZE_UNIT.
(c_sizeof_nowarn, c_size_in_bytes): Likewise.
(c_alignof): Use size_one_node.
(build_unary_op): Pass arg of proper type to size_binop.
(really_start_incremental_init, push_init_level): Use sizetype for
constructor{,_bit,_unfilled}_index.
(pop_init_label, output_init_element): Likewise.
(output_pending_init_elements, process_init_element): Likewise.
* calls.c (compute_argument_block_size): Field VAR is ssizetype.
* expr.c (store_expr): Use size_int.
(store_constructor): Use proper types for size_binop args.
(get_inner_reference, expand_expr, case ARRAY_REF): Likewise.
(expand_expr_unaligned): Likewise.
(string_contant): Return object of sizetype.
* expr.h (SUB_PARM_SIZE): Call size_diffop and pass proper types.
(ARGS_SIZE_RTX): Call ARGS_SIZE_TREE.
(ARGS_SIZE_TREE): Pass proper types to size_binop.
* fold-const.c (int_const_binop): Refine when size_int is called.
(fold_convert): Likewise.
(size_int_wide): Rework to take KIND as arg, only take low order
bits, handle new sizetype_tab datatype, and chain entries in
size_table.
(size_int_type_wide): New function.
(size_binop): Validate types of arguments.
(ssize_binop): Deleted.
(size_diffop): New function.
(extract_muldiv): Only fold division into multiplication for sizetypes.
* function.c (assign_parms): Use size_diffop and make sure
VAR field is of ssizetype; also pass proper type to size_binop.
(locate_and_pad_parm, pad_to_arg_alignment): Likewise.
(round_down): Deleted from here.
* store-layout.c (sizetype_tab): Now an array.
(sizetype_set, early_root_list): New variables.
(variable_size): Use size_one_node.
(round_up): Pass proper type to size_binop.
(round_down): Moved to here and corrected as above.
(layout_record): Pass proper arg types to size_binop.
(layout_type): Likewise.
If sizetype_set is zero, record the type just laid out.
(make_unsigned_type): Don't call set_sizetype;
(make_signed_type): Likewise; also, call fixup_signed_type.
(initialize_sizetypes): New function.
(set_sizetype): Make copy of types, set TYPE_IS_SIZETYPE, and
set name of bitsizetype to "bit_size_type".
Fix up type of sizes of all types made before call.
* tm.texi (ROUND_TYPE_SIZE_UNIT): New macro.
* tree.c (fix_sizetype): Deleted.
(build_common_tree_nodes): Call initialize_sizetypes.
(build_common_tree_nodes_2): Don't call fix_sizetype.
* tree.h (TYPE_IS_SIZETYPE): New macro.
(initialize_sizetype): New declaration.
(enum size_type_kind): New type.
(struct sizetype_tab): Deleted.
(sizetype_tab): Now array; adjust sizetype macros.
(size_diffop, size_int_type_wide): New functions.
(size_int_wide): Change number of args and type; access macros changed.
(ssize_int, sbitsize_int): New macros.
* config/i960/i960.h (ROUND_TYPE_SIZE): Use size_int.
(ROUND_TYPE_SIZE_UNIT): New macro.
* ch/actions.c (chill_convert_for_assignment): Don't use size_binop
for things that aren't sizes.
(expand_varying_length_assignment): Likewise.
* ch/convert.c (digest_array_tuple, convert): Likewise.
* ch/typeck.c (build_chill_slice, smash_dummy_type): Likewise.
(build_chill_slice_with_range): Likewise.
(build_chill_slice_with_length): Likewise.
(build_array_from_set): Adjust types for size_binop.
* ch/expr.c (build_concat_expr, build_chill_repetition_op): Likewise.
(build_chill_sizeof): Use TYPE_SIZE_UNIT.
* ch/tree.c (build_string_type): Pass proper type to size_binop.
* cp/class.c (dfs_build_vtable_offset_vtbl_entries): Don't use
size_binop on things that are not sizes; ssize_binop deleted.
Call size_diffop when appropriate.
(dfs_build_vcall_offset_vtbl_entries): Likewise.
(build_primary_vtable, build_secondary_vtable): Likewise.
(dfs_set_offset_for_unshared_vbases, dfs_modify_vtables): Likewise.
Variable I is HOST_WIDE_INT.
(get_vfield_offset): Pass proper types to size_binop.
(size_extra_vtbl_entries, layout_virtual_bases): Likewise.
(finish_struct_1): Likewise.
(skip_rtti_stuff): Arg N is now pointer to signed.
(layout_class_type): Use size_zero_node.
* cp/cp-tree.h (skip_rtti_stuff): Arg N is pointer to signed.
* cp/cvt.c (cp_convert_to_pointer): Pass proper types to size_binop.
* cp/decl.c (complete_arry_type): Pass proper types to size_binop.
(xref_basetypes): BINFO_OFFSET is sizetype.
* cp/error.c (dump_expr): Don't use size_binop non-sizes.
* cp/expr.c (cplus_expand_constant): Pass proper types to size_binop.
* cp/init.c (construct_virtual_bases): Fix type error.
(build_vec_delete_1): Pass proper type to size_binop and don't
fold result.
* cp/lex.c (cp_make_lang_type): BINFO_OFFSET is sizetype.
* cp/rtti.c (get_base_offset): Pass proper type to size_binop.
* cp/search.c (dfs_find_vbases): Fix type error.
(expand_upcast_fixups): Arg to skip_rtti_stuff is pointer to signed.
(dfs_get_vbase_types): BINFO_OFFSET is sizetype.
* cp/tree.c (debug_binfo): Variable N is signed.
Use HOST_WIDE_INT_PRINT_DEC.
* cp/typeck.c (comptypes): sizetype is same as equivalent integer type.
(c_sizeof, c_sizeof_nowarn, expr_sizeof): Use TYPE_SIZE_UNIT,
size_one_node and size_zero_node.
(c_alignof): Use size_one_node.
(build_component_addr): Pass proper types to size_binop.
(expand_ptrmemfunc_cst): Don't use size_binop on non-sizes.
* f/com.c (ffecom_arrayref_): Convert args to size_binop to proper
type.
(ffecom_tree_canonize_ptr_): Don't use size_binop for non-sizes.
(ffecom_tree_canonize_ref_): Likewise.
(type_for_mode): Handle TImode.
* f/ste.c (ffeste_io_dofio_, ffeste_io_douio_): Use TYPE_SIZE_UNIT.
(ffeste_io_ciclist_): Likewise.
* java/expr.c (build_java_ret): Pass proper type to size_binop.
From-SVN: r32225
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 113 |
1 files changed, 48 insertions, 65 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d186027..5b0ab16 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -274,17 +274,16 @@ dfs_build_vbase_offset_vtbl_entries (binfo, data) else { BINFO_VPTR_FIELD (vbase) = TREE_PURPOSE (TREE_VALUE (list)); - BINFO_VPTR_FIELD (vbase) = ssize_binop (MINUS_EXPR, - BINFO_VPTR_FIELD (vbase), - integer_one_node); + BINFO_VPTR_FIELD (vbase) + = fold (build (MINUS_EXPR, integer_type_node, + BINFO_VPTR_FIELD (vbase), integer_one_node)); } /* And record the offset at which this virtual base lies in the vtable. */ init = BINFO_OFFSET (binfo); TREE_VALUE (list) = tree_cons (BINFO_VPTR_FIELD (vbase), - init, - TREE_VALUE (list)); + init, TREE_VALUE (list)); } SET_BINFO_VTABLE_PATH_MARKED (binfo); @@ -338,17 +337,14 @@ build_vbase_offset_vtbl_entries (binfo, t) object, and we need offsets from this BINFO. */ for (init = inits; init; init = TREE_CHAIN (init)) { - tree exp = TREE_VALUE (init); - - exp = ssize_binop (MINUS_EXPR, exp, BINFO_OFFSET (binfo)); - exp = build1 (NOP_EXPR, vtable_entry_type, exp); - exp = fold (exp); - TREE_CONSTANT (exp) = 1; /* The dfs_build_vbase_offset_vtbl_entries routine uses the TREE_PURPOSE to scribble in. But, we need to clear it now so that the values are not perceived as labeled initializers. */ TREE_PURPOSE (init) = NULL_TREE; - TREE_VALUE (init) = exp; + TREE_VALUE (init) + = fold (build1 (NOP_EXPR, vtable_entry_type, + size_diffop (TREE_VALUE (init), + BINFO_OFFSET (binfo)))); } return inits; @@ -406,25 +402,19 @@ dfs_build_vcall_offset_vtbl_entries (binfo, data) virtuals; virtuals = TREE_CHAIN (virtuals)) { - tree fn; - tree base; - tree base_binfo; - tree offset; - /* Figure out what function we're looking at. */ - fn = TREE_VALUE (virtuals); - base = DECL_CONTEXT (fn); - + tree fn = TREE_VALUE (virtuals); + tree base = DECL_CONTEXT (fn); /* The FN comes from BASE. So, we must caculate the adjustment from the virtual base that derived from BINFO to BASE. */ - base_binfo = get_binfo (base, vod->derived, /*protect=*/0); - offset = ssize_binop (MINUS_EXPR, - BINFO_OFFSET (base_binfo), - BINFO_OFFSET (vod->vbase)); - offset = build1 (NOP_EXPR, vtable_entry_type, offset); - offset = fold (offset); - TREE_CONSTANT (offset) = 1; - binfo_inits = tree_cons (NULL_TREE, offset, binfo_inits); + tree base_binfo = get_binfo (base, vod->derived, /*protect=*/0); + + binfo_inits + = tree_cons (NULL_TREE, + fold (build1 (NOP_EXPR, vtable_entry_type, + size_diffop (BINFO_OFFSET (base_binfo), + BINFO_OFFSET (vod->vbase)))), + binfo_inits); } /* Now add the initializers we've just created to the list that will @@ -634,11 +624,10 @@ build_vbase_path (code, type, expr, path, nonnull) if (changed) { tree intype = TREE_TYPE (TREE_TYPE (expr)); + if (TYPE_MAIN_VARIANT (intype) != BINFO_TYPE (last)) - { - tree binfo = get_binfo (last, TYPE_MAIN_VARIANT (intype), 0); - offset = BINFO_OFFSET (binfo); - } + offset + = BINFO_OFFSET (get_binfo (last, TYPE_MAIN_VARIANT (intype), 0)); } else offset = BINFO_OFFSET (last); @@ -647,10 +636,6 @@ build_vbase_path (code, type, expr, path, nonnull) { /* Bash types to make the backend happy. */ offset = cp_convert (type, offset); -#if 0 - /* This shouldn't be necessary. (mrs) */ - expr = build1 (NOP_EXPR, type, expr); -#endif /* If expr might be 0, we need to preserve that zeroness. */ if (nonnull == 0) @@ -921,16 +906,18 @@ get_vfield_offset (binfo) tree tmp = size_binop (FLOOR_DIV_EXPR, DECL_FIELD_BITPOS (TYPE_VFIELD (BINFO_TYPE (binfo))), - size_int (BITS_PER_UNIT)); - tmp = convert (sizetype, tmp); - return size_binop (PLUS_EXPR, tmp, BINFO_OFFSET (binfo)); + bitsize_int (BITS_PER_UNIT)); + + return size_binop (PLUS_EXPR, convert (sizetype, tmp), + BINFO_OFFSET (binfo)); } /* Get the offset to the start of the original binfo that we derived this binfo from. If we find TYPE first, return the offset only that far. The shortened search is useful because the this pointer on method calling is expected to point to a DECL_CONTEXT (fndecl) - object, and not a baseclass of it. */ + object, and not a baseclass of it. */ + static tree get_derived_offset (binfo, type) @@ -939,14 +926,16 @@ get_derived_offset (binfo, type) tree offset1 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo))); tree offset2; int i; + while (BINFO_BASETYPES (binfo) - && (i=CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1) + && (i = CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1) { tree binfos = BINFO_BASETYPES (binfo); if (BINFO_TYPE (binfo) == type) break; binfo = TREE_VEC_ELT (binfos, i); } + offset2 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo))); return size_binop (MINUS_EXPR, offset1, offset2); } @@ -1085,7 +1074,7 @@ build_primary_vtable (binfo, type) /* Now do rtti stuff. */ offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE); - offset = ssize_binop (MINUS_EXPR, integer_zero_node, offset); + offset = size_diffop (size_zero_node, offset); set_rtti_entry (virtuals, offset, type); } else @@ -1175,7 +1164,7 @@ build_secondary_vtable (binfo, for_type) offset = BINFO_OFFSET (binfo); set_rtti_entry (BINFO_VIRTUALS (binfo), - ssize_binop (MINUS_EXPR, integer_zero_node, offset), + size_diffop (size_zero_node, offset), for_type); /* In the new ABI, secondary vtables are laid out as part of the @@ -2620,12 +2609,8 @@ tree size_extra_vtbl_entries (binfo) tree binfo; { - tree offset; - - offset = size_binop (EXACT_DIV_EXPR, - TYPE_SIZE (vtable_entry_type), - size_int (BITS_PER_UNIT)); - offset = size_binop (MULT_EXPR, offset, num_extra_vtbl_entries (binfo)); + tree offset = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (vtable_entry_type), + num_extra_vtbl_entries (binfo)); return fold (offset); } @@ -3039,7 +3024,7 @@ tree skip_rtti_stuff (binfo, t, n) tree binfo; tree t; - unsigned HOST_WIDE_INT *n; + HOST_WIDE_INT *n; { tree virtuals; @@ -3121,7 +3106,7 @@ dfs_modify_vtables (binfo, data) tree overrider; tree vindex; tree delta; - int i; + HOST_WIDE_INT i; /* Find the function which originally caused this vtable entry to be present. */ @@ -3151,9 +3136,7 @@ dfs_modify_vtables (binfo, data) get_derived_offset (binfo, DECL_VIRTUAL_CONTEXT (fn)), BINFO_OFFSET (binfo)); - delta = ssize_binop (MINUS_EXPR, - BINFO_OFFSET (TREE_VALUE (overrider)), - delta); + delta = size_diffop (BINFO_OFFSET (TREE_VALUE (overrider)), delta); modify_vtable_entry (t, binfo, @@ -4568,8 +4551,7 @@ dfs_propagate_binfo_offsets (binfo, data) tree offset = (tree) data; /* Update the BINFO_OFFSET for this base. */ - BINFO_OFFSET (binfo) - = size_binop (PLUS_EXPR, BINFO_OFFSET (binfo), offset); + BINFO_OFFSET (binfo) = size_binop (PLUS_EXPR, BINFO_OFFSET (binfo), offset); SET_BINFO_MARKED (binfo); @@ -4714,9 +4696,8 @@ dfs_set_offset_for_unshared_vbases (binfo, data) tree offset; vbase = BINFO_FOR_VBASE (BINFO_TYPE (binfo), t); - offset = ssize_binop (MINUS_EXPR, - BINFO_OFFSET (vbase), - BINFO_OFFSET (binfo)); + offset = size_binop (MINUS_EXPR, + BINFO_OFFSET (vbase), BINFO_OFFSET (binfo)); propagate_binfo_offsets (binfo, offset); } @@ -4789,9 +4770,10 @@ layout_virtual_bases (t) /* Now, make sure that the total size of the type is a multiple of its alignment. */ dsize = CEIL (dsize, TYPE_ALIGN (t)) * TYPE_ALIGN (t); - TYPE_SIZE (t) = size_int (dsize); - TYPE_SIZE_UNIT (t) = size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (t), - size_int (BITS_PER_UNIT)); + TYPE_SIZE (t) = bitsize_int (dsize); + TYPE_SIZE_UNIT (t) = convert (sizetype, + size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (t), + bitsize_int (BITS_PER_UNIT))); } /* Finish the work of layout_record, now taking virtual bases into account. @@ -4915,7 +4897,7 @@ layout_class_type (t, empty_p, has_virtual_p, if (*empty_p && flag_new_abi) { CLASSTYPE_SIZE (t) = bitsize_int (0); - CLASSTYPE_SIZE_UNIT (t) = size_int (0); + CLASSTYPE_SIZE_UNIT (t) = size_zero_node; } else if (flag_new_abi && TYPE_HAS_COMPLEX_INIT_REF (t) && TYPE_HAS_COMPLEX_ASSIGN_REF (t)) @@ -5026,13 +5008,14 @@ finish_struct_1 (t) && DECL_FIELD_CONTEXT (vfield) != t) { tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0); - tree offset = BINFO_OFFSET (binfo); + tree offset = convert (bitsizetype, BINFO_OFFSET (binfo)); vfield = copy_node (vfield); copy_lang_decl (vfield); if (! integer_zerop (offset)) - offset = size_binop (MULT_EXPR, offset, size_int (BITS_PER_UNIT)); + offset = size_binop (MULT_EXPR, offset, bitsize_int (BITS_PER_UNIT)); + DECL_FIELD_CONTEXT (vfield) = t; DECL_FIELD_BITPOS (vfield) = size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield)); |