diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/java/class.c | 48 | ||||
-rw-r--r-- | gcc/java/decl.c | 6 | ||||
-rw-r--r-- | gcc/java/expr.c | 24 |
4 files changed, 49 insertions, 39 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 23575cf..5d58d88 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,13 @@ +Fri Mar 17 08:09:14 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * class.c (make_field_value): Properly handle sizes. + (get_dispatch_vector): Use tree_low_cst and host_integerp. + (layout_class_method): Count using trees. + * decl.c (push_promoted_type): Set TYPE_{MIN,MAX}_VALUE with copy_node. + * expr.c (java_array_data_offset): Use int_bit_position. + (build_newarray, build_anewarray): Use host_integerp and tree_low_cst. + (build_invokevirtual): Use tree_low_cst and do computations with trees. + 2000-03-16 Tom Tromey <tromey@cygnus.com> * lang.c (flag_hash_synchronization): New global. diff --git a/gcc/java/class.c b/gcc/java/class.c index 99d38e0..1332639 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1073,9 +1073,10 @@ make_field_value (fdecl) tree fdecl; { tree finit, info; - int bsize, flags; + int flags; tree type = TREE_TYPE (fdecl); int resolved = is_compiled_class (type); + START_RECORD_CONSTRUCTOR (finit, field_type_node); PUSH_FIELD_VALUE (finit, "name", build_utf8_ref (DECL_NAME (fdecl))); if (resolved) @@ -1091,24 +1092,24 @@ make_field_value (fdecl) flags = get_access_flags_from_decl (fdecl); if (! resolved) flags |= 0x8000 /* FIELD_UNRESOLVED_FLAG */; + PUSH_FIELD_VALUE (finit, "accflags", build_int_2 (flags, 0)); - bsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (fdecl))) / BITS_PER_UNIT; - PUSH_FIELD_VALUE (finit, "bsize", build_int_2 (bsize, 0)); + PUSH_FIELD_VALUE (finit, "bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl))); if (FIELD_STATIC (fdecl)) { - tree cfield = TREE_CHAIN (TYPE_FIELDS(field_info_union_node)); + tree cfield = TREE_CHAIN (TYPE_FIELDS (field_info_union_node)); tree faddr = build_address_of (build_static_field_ref (fdecl)); + info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE, build_tree_list (cfield, faddr)); } else - { - int boffset - = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (fdecl)) / BITS_PER_UNIT; - info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE, - build_tree_list (TYPE_FIELDS(field_info_union_node), - build_int_2 (boffset, 0))); - } + info = build (CONSTRUCTOR, field_info_union_node, NULL_TREE, + build_tree_list (TYPE_FIELDS (field_info_union_node), + build_int_2 ((int_bit_position (fdecl) + / BITS_PER_UNIT), + 0))); + PUSH_FIELD_VALUE (finit, "info", info); FINISH_RECORD_CONSTRUCTOR (finit); @@ -1152,29 +1153,28 @@ get_dispatch_vector (type) tree vtable = TYPE_VTABLE (type); if (vtable == NULL) { - int i; + HOST_WIDE_INT i; tree method; tree super = CLASSTYPE_SUPER (type); - int nvirtuals = TREE_INT_CST_LOW (TYPE_NVIRTUALS (type)); + HOST_WIDE_INT nvirtuals = tree_low_cst (TYPE_NVIRTUALS (type), 0); vtable = make_tree_vec (nvirtuals); TYPE_VTABLE (type) = vtable; if (super != NULL_TREE) { tree super_vtable = get_dispatch_vector (super); - for ( i = TREE_INT_CST_LOW (TYPE_NVIRTUALS (super)); --i >= 0; ) + + for (i = tree_low_cst (TYPE_NVIRTUALS (super), 0); --i >= 0; ) TREE_VEC_ELT (vtable, i) = TREE_VEC_ELT (super_vtable, i); } + for (method = TYPE_METHODS (type); method != NULL_TREE; method = TREE_CHAIN (method)) - { - if (DECL_VINDEX (method) != NULL_TREE - && TREE_CODE (DECL_VINDEX (method)) == INTEGER_CST) - { - TREE_VEC_ELT (vtable, TREE_INT_CST_LOW (DECL_VINDEX (method))) - = method; - } - } + if (DECL_VINDEX (method) != NULL_TREE + && host_integerp (DECL_VINDEX (method), 0)) + TREE_VEC_ELT (vtable, tree_low_cst (DECL_VINDEX (method), 0)) + = method; } + return vtable; } @@ -1966,9 +1966,11 @@ layout_class_method (this_class, super_class, method_decl, dtable_count) && dtable_count) { DECL_VINDEX (method_decl) = dtable_count; - dtable_count = build_int_2 (1+TREE_INT_CST_LOW (dtable_count), 0); + dtable_count = fold (build (PLUS_EXPR, integer_type_node, + dtable_count, integer_one_node)); } } + return dtable_count; } diff --git a/gcc/java/decl.c b/gcc/java/decl.c index bd2514a..f5cd80e 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -401,11 +401,9 @@ push_promoted_type (name, actual_type) tree in_min = TYPE_MIN_VALUE (actual_type); tree in_max = TYPE_MAX_VALUE (actual_type); #endif - TYPE_MIN_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_min), - TREE_INT_CST_HIGH (in_min)); + TYPE_MIN_VALUE (type) = copy_node (in_min); TREE_TYPE (TYPE_MIN_VALUE (type)) = type; - TYPE_MAX_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_max), - TREE_INT_CST_HIGH (in_max)); + TYPE_MAX_VALUE (type) = copy_node (in_max); TREE_TYPE (TYPE_MAX_VALUE (type)) = type; TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node); layout_type (type); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index f92fc8d..dc56857 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -693,8 +693,7 @@ java_array_data_offset (array) if (data_fld == NULL_TREE) return size_in_bytes (array_type); else - return build_int_2 (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (data_fld)) - / BITS_PER_UNIT, 0); + return build_int_2 (int_bit_position (data_fld) / BITS_PER_UNIT, 0); } /* Implement array indexing (either as l-value or r-value). @@ -788,8 +787,8 @@ build_newarray (atype_value, length) { tree type = build_java_array_type (decode_newarray_type (atype_value), - TREE_CODE (length) == INTEGER_CST - ? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1); + host_integerp (length, 0) == INTEGER_CST + ? tree_low_cst (length, 0) : -1); return build (CALL_EXPR, promote_type (type), build_address_of (soft_newarray_node), @@ -809,8 +808,8 @@ build_anewarray (class_type, length) { tree type = build_java_array_type (class_type, - TREE_CODE (length) == INTEGER_CST - ? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1); + host_integerp (length, 0) + ? tree_low_cst (length, 0) : -1); return build (CALL_EXPR, promote_type (type), build_address_of (soft_anewarray_node), @@ -1646,14 +1645,15 @@ build_invokevirtual (dtable, method) tree func; tree nativecode_ptr_ptr_type_node = build_pointer_type (nativecode_ptr_type_node); - int method_index = TREE_INT_CST_LOW (DECL_VINDEX (method)); + tree method_index = convert (sizetype, DECL_VINDEX (method)); + /* Add one to skip "class" field of dtable, and one to skip unused vtable entry (for C++ compatibility). */ - method_index += 2; - method_index - *= int_size_in_bytes (nativecode_ptr_ptr_type_node); - func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node, - dtable, build_int_2 (method_index, 0))); + method_index = size_binop (PLUS_EXPR, method_index, size_int (2)); + method_index = size_binop (MULT_EXPR, method_index, + TYPE_SIZE_UNIT (nativecode_ptr_ptr_type_node)); + func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable, + convert (nativecode_ptr_ptr_type_node, method_index))); func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func); return func; |