+2004-07-18 Roger Sayle <roger@eyesopen.com>
+
+ * builtins.c (max_builtin, min_builtin,
+ java_build_function_call_expr): Replace calls to build with buildN.
+ * class.c (build_class_ref, build_static_field_ref,
+ get_dispatch_table, make_class_data, layout_class_method): Likewise.
+ * constants.c (build_ref_from_constant_pool): Likewise.
+ * decl.c (update_aliases, push_jvm_slot, poplevel, finish_method,
+ add_stmt_to_compound): Likewise.
+ * except.c (build_exception_object_ref, expand_end_java_handler):
+ Likewise.
+ * java-gimplify.c (java_gimplify_case_expr,
+ java_gimplify_default_expr, java_gimplify_block,
+ java_gimplify_new_array_init, java_gimplify_try_expr): Likewise.
+ * jcf-write.c (generate_bytecode_insns): Likewise.
+ * typeck.c (convert_ieee_real_to_integer): Likewise.
+
2004-07-17 Joseph S. Myers <jsm@polyomino.org.uk>
* java-tree.h (builtin_function): Declare.
static tree
max_builtin (tree method_return_type, tree method_arguments)
{
- return fold (build (MAX_EXPR, method_return_type,
- TREE_VALUE (method_arguments),
- TREE_VALUE (TREE_CHAIN (method_arguments))));
+ return fold (build2 (MAX_EXPR, method_return_type,
+ TREE_VALUE (method_arguments),
+ TREE_VALUE (TREE_CHAIN (method_arguments))));
}
static tree
min_builtin (tree method_return_type, tree method_arguments)
{
- return fold (build (MIN_EXPR, method_return_type,
- TREE_VALUE (method_arguments),
- TREE_VALUE (TREE_CHAIN (method_arguments))));
+ return fold (build2 (MIN_EXPR, method_return_type,
+ TREE_VALUE (method_arguments),
+ TREE_VALUE (TREE_CHAIN (method_arguments))));
}
static tree
tree call_expr;
call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
- call_expr = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
- call_expr, arglist, NULL_TREE);
+ call_expr = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
+ call_expr, arglist, NULL_TREE);
TREE_SIDE_EFFECTS (call_expr) = 1;
return fold (call_expr);
}
abort ();
prim_class = lookup_class (get_identifier (prim_class_name));
- return build (COMPONENT_REF, NULL_TREE,
- prim_class, TYPE_identifier_node, NULL_TREE);
+ return build3 (COMPONENT_REF, NULL_TREE,
+ prim_class, TYPE_identifier_node, NULL_TREE);
}
decl_name = TYPE_NAME (type);
if (TREE_CODE (decl_name) == TYPE_DECL)
= build_int_2 (get_symbol_table_index
(fdecl, &TYPE_ATABLE_METHODS (output_class)), 0);
tree field_address
- = build (ARRAY_REF, build_pointer_type (TREE_TYPE (fdecl)),
- TYPE_ATABLE_DECL (output_class), table_index,
- NULL_TREE, NULL_TREE);
+ = build4 (ARRAY_REF, build_pointer_type (TREE_TYPE (fdecl)),
+ TYPE_ATABLE_DECL (output_class), table_index,
+ NULL_TREE, NULL_TREE);
return fold (build1 (INDIRECT_REF, TREE_TYPE (fdecl),
field_address));
}
tree fld;
int field_index = 0;
ref = build1 (INDIRECT_REF, class_type_node, ref);
- ref = build (COMPONENT_REF, field_ptr_type_node, ref,
- lookup_field (&class_type_node, fields_ident),
- NULL_TREE);
+ ref = build3 (COMPONENT_REF, field_ptr_type_node, ref,
+ lookup_field (&class_type_node, fields_ident),
+ NULL_TREE);
for (fld = TYPE_FIELDS (fclass); ; fld = TREE_CHAIN (fld))
{
field_index++;
}
field_index *= int_size_in_bytes (field_type_node);
- ref = fold (build (PLUS_EXPR, field_ptr_type_node,
- ref, build_int_2 (field_index, 0)));
+ ref = fold (build2 (PLUS_EXPR, field_ptr_type_node,
+ ref, build_int_2 (field_index, 0)));
ref = build1 (INDIRECT_REF, field_type_node, ref);
- ref = build (COMPONENT_REF, field_info_union_node,
- ref, lookup_field (&field_type_node, info_ident),
- NULL_TREE);
- ref = build (COMPONENT_REF, ptr_type_node,
- ref, TREE_CHAIN (TYPE_FIELDS (field_info_union_node)),
- NULL_TREE);
+ ref = build3 (COMPONENT_REF, field_info_union_node,
+ ref, lookup_field (&field_type_node, info_ident),
+ NULL_TREE);
+ ref = build3 (COMPONENT_REF, ptr_type_node,
+ ref, TREE_CHAIN (TYPE_FIELDS (field_info_union_node)),
+ NULL_TREE);
ref = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (fdecl)), ref);
return fold (build1 (INDIRECT_REF, TREE_TYPE(fdecl), ref));
}
if (TARGET_VTABLE_USES_DESCRIPTORS)
for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
{
- tree fdesc = build (FDESC_EXPR, nativecode_ptr_type_node,
- method, build_int_2 (j, 0));
+ tree fdesc = build2 (FDESC_EXPR, nativecode_ptr_type_node,
+ method, build_int_2 (j, 0));
TREE_CONSTANT (fdesc) = 1;
TREE_INVARIANT (fdesc) = 1;
list = tree_cons (NULL_TREE, fdesc, list);
START_RECORD_CONSTRUCTOR (temp, object_type_node);
PUSH_FIELD_VALUE (temp, "vtable",
- build (PLUS_EXPR, dtable_ptr_type,
- build1 (ADDR_EXPR, dtable_ptr_type, class_dtable_decl),
- dtable_start_offset));
+ build2 (PLUS_EXPR, dtable_ptr_type,
+ build1 (ADDR_EXPR, dtable_ptr_type,
+ class_dtable_decl),
+ dtable_start_offset));
if (! flag_hash_synchronization)
PUSH_FIELD_VALUE (temp, "sync_info", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (temp);
else
PUSH_FIELD_VALUE (cons, "vtable",
dtable_decl == NULL_TREE ? null_pointer_node
- : build (PLUS_EXPR, dtable_ptr_type,
- build1 (ADDR_EXPR, dtable_ptr_type, dtable_decl),
- dtable_start_offset));
+ : build2 (PLUS_EXPR, dtable_ptr_type,
+ build1 (ADDR_EXPR, dtable_ptr_type,
+ dtable_decl),
+ dtable_start_offset));
if (TYPE_OTABLE_METHODS (type) == NULL_TREE)
{
PUSH_FIELD_VALUE (cons, "otable", null_pointer_node);
&& dtable_count)
{
set_method_index (method_decl, dtable_count);
- dtable_count = fold (build (PLUS_EXPR, integer_type_node,
- dtable_count, integer_one_node));
+ dtable_count = fold (build2 (PLUS_EXPR, integer_type_node,
+ dtable_count, integer_one_node));
}
}
{
tree d = build_constant_data_ref ();
tree i = build_int_2 (index, 0);
- return build (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i,
- NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (d)), d, i,
+ NULL_TREE, NULL_TREE);
}
/* Build an initializer for the constants field of the current constant pool.
&& TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (tmp)))
{
tree src = build1 (NOP_EXPR, TREE_TYPE (tmp), decl);
- java_add_stmt
- (build (MODIFY_EXPR, TREE_TYPE (tmp), tmp, src));
+ java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (tmp), tmp, src));
}
tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
}
/* At the point of its creation this decl inherits whatever
is in the slot. */
tree src = build1 (NOP_EXPR, TREE_TYPE (decl), tmp);
- java_add_stmt
- (build (MODIFY_EXPR, TREE_TYPE (decl), decl, src));
+ java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (decl), decl, src));
break;
}
tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
}
*var = NULL;
- bind = build (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block),
+ bind = build3 (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block),
BLOCK_EXPR_BODY (block), block);
BIND_EXPR_BODY (bind) = current_binding_level->stmts;
lock = DECL_ARGUMENTS (fndecl);
BUILD_MONITOR_ENTER (enter, lock);
BUILD_MONITOR_EXIT (exit, lock);
- *tp = build (COMPOUND_EXPR, void_type_node,
- enter,
- build (TRY_FINALLY_EXPR, void_type_node, *tp, exit));
+ *tp = build2 (COMPOUND_EXPR, void_type_node, enter,
+ build2 (TRY_FINALLY_EXPR, void_type_node, *tp, exit));
}
/* Prepend class initialization for static methods reachable from
&& ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl))))
{
tree clas = DECL_CONTEXT (fndecl);
- tree init = build (CALL_EXPR, void_type_node,
- build_address_of (soft_initclass_node),
- build_tree_list (NULL_TREE, build_class_ref (clas)),
- NULL_TREE);
- *tp = build (COMPOUND_EXPR, TREE_TYPE (*tp), init, *tp);
+ tree init = build3 (CALL_EXPR, void_type_node,
+ build_address_of (soft_initclass_node),
+ build_tree_list (NULL_TREE, build_class_ref (clas)),
+ NULL_TREE);
+ *tp = build2 (COMPOUND_EXPR, TREE_TYPE (*tp), init, *tp);
}
/* Convert function tree to GENERIC prior to inlining. */
return existing;
else if (existing)
{
- tree expr = build (COMPOUND_EXPR, type, existing, stmt);
- TREE_SIDE_EFFECTS (expr)
- = TREE_SIDE_EFFECTS (existing) | TREE_SIDE_EFFECTS (stmt);
+ tree expr = build2 (COMPOUND_EXPR, type, existing, stmt);
+ TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (existing)
+ | TREE_SIDE_EFFECTS (stmt);
return expr;
}
else
/* Java only passes object via pointer and doesn't require adjusting.
The java object is immediately before the generic exception header. */
- obj = build (EXC_PTR_EXPR, build_pointer_type (type));
- obj = build (MINUS_EXPR, TREE_TYPE (obj), obj,
- TYPE_SIZE_UNIT (TREE_TYPE (obj)));
+ obj = build0 (EXC_PTR_EXPR, build_pointer_type (type));
+ obj = build2 (MINUS_EXPR, TREE_TYPE (obj), obj,
+ TYPE_SIZE_UNIT (TREE_TYPE (obj)));
obj = build1 (INDIRECT_REF, type, obj);
return obj;
type = prepare_eh_table_type (type);
{
- tree catch_expr
- = build (CATCH_EXPR, void_type_node, type,
- build (GOTO_EXPR, void_type_node, TREE_VALUE (handler)));
- tree try_catch_expr = build (TRY_CATCH_EXPR, void_type_node,
- *get_stmts (), catch_expr);
+ tree catch_expr = build2 (CATCH_EXPR, void_type_node, type,
+ build1 (GOTO_EXPR, void_type_node,
+ TREE_VALUE (handler)));
+ tree try_catch_expr = build2 (TRY_CATCH_EXPR, void_type_node,
+ *get_stmts (), catch_expr);
*get_stmts () = try_catch_expr;
}
}
java_gimplify_case_expr (tree expr)
{
tree label = create_artificial_label ();
- return build (CASE_LABEL_EXPR, void_type_node,
- TREE_OPERAND (expr, 0), NULL_TREE, label);
+ return build3 (CASE_LABEL_EXPR, void_type_node,
+ TREE_OPERAND (expr, 0), NULL_TREE, label);
}
static tree
java_gimplify_default_expr (tree expr ATTRIBUTE_UNUSED)
{
tree label = create_artificial_label ();
- return build (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE, label);
+ return build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE, label);
}
/* Gimplify BLOCK into a BIND_EXPR. */
BLOCK_SUBBLOCKS (outer) = chainon (BLOCK_SUBBLOCKS (outer), block);
}
- return build (BIND_EXPR, TREE_TYPE (java_block), decls, body, block);
+ return build3 (BIND_EXPR, TREE_TYPE (java_block), decls, body, block);
}
/* Gimplify a NEW_ARRAY_INIT node into array/element assignments. */
tree values = CONSTRUCTOR_ELTS (init);
tree array_ptr_type = build_pointer_type (array_type);
- tree block = build (BLOCK, array_ptr_type);
+ tree block = build0 (BLOCK, array_ptr_type);
tree tmp = build_decl (VAR_DECL, get_identifier ("<tmp>"), array_ptr_type);
- tree array = build_decl (VAR_DECL, get_identifier ("<array>"), array_ptr_type);
- tree body = build (MODIFY_EXPR, array_ptr_type, tmp,
- build_new_array (element_type, length));
+ tree array = build_decl (VAR_DECL, get_identifier ("<array>"),
+ array_ptr_type);
+ tree body = build2 (MODIFY_EXPR, array_ptr_type, tmp,
+ build_new_array (element_type, length));
int index = 0;
{
/* FIXME: Should use build_java_arrayaccess here, but avoid
bounds checking. */
- tree lhs = build (COMPONENT_REF, TREE_TYPE (data_field),
- build_java_indirect_ref (array_type, tmp, 0),
- data_field, NULL_TREE);
- tree assignment = build (MODIFY_EXPR, element_type,
- build (ARRAY_REF, element_type, lhs,
- build_int_2 (index++, 0),
- NULL_TREE, NULL_TREE),
- TREE_VALUE (values));
- body = build (COMPOUND_EXPR, element_type, body, assignment);
+ tree lhs = build3 (COMPONENT_REF, TREE_TYPE (data_field),
+ build_java_indirect_ref (array_type, tmp, 0),
+ data_field, NULL_TREE);
+ tree assignment = build2 (MODIFY_EXPR, element_type,
+ build4 (ARRAY_REF, element_type, lhs,
+ build_int_2 (index++, 0),
+ NULL_TREE, NULL_TREE),
+ TREE_VALUE (values));
+ body = build2 (COMPOUND_EXPR, element_type, body, assignment);
values = TREE_CHAIN (values);
}
- body = build (COMPOUND_EXPR, array_ptr_type, body,
- build (MODIFY_EXPR, array_ptr_type, array, tmp));
+ body = build2 (COMPOUND_EXPR, array_ptr_type, body,
+ build2 (MODIFY_EXPR, array_ptr_type, array, tmp));
TREE_CHAIN (tmp) = array;
BLOCK_VARS (block) = tmp;
BLOCK_EXPR_BODY (block) = body;
{
tree java_catch = TREE_OPERAND (handler, 0);
tree catch_type = TREE_TYPE (TREE_TYPE (BLOCK_EXPR_DECLS (java_catch)));
- tree expr = build (CATCH_EXPR, void_type_node,
- prepare_eh_table_type (catch_type),
- handler);
+ tree expr = build2 (CATCH_EXPR, void_type_node,
+ prepare_eh_table_type (catch_type),
+ handler);
if (catch)
- catch = build (COMPOUND_EXPR, void_type_node, catch, expr);
+ catch = build2 (COMPOUND_EXPR, void_type_node, catch, expr);
else
catch = expr;
handler = TREE_CHAIN (handler);
}
- return build (TRY_CATCH_EXPR, void_type_node, body, catch);
+ return build2 (TRY_CATCH_EXPR, void_type_node, body, catch);
}
/* Dump a tree of some kind. This is a convenience wrapper for the
/* This function correctly handles the case where the LHS
of a binary expression is NULL_TREE. */
- rhs = build (TREE_CODE (rhs), TREE_TYPE (rhs),
- NULL_TREE, TREE_OPERAND (rhs, 1));
+ rhs = build2 (TREE_CODE (rhs), TREE_TYPE (rhs),
+ NULL_TREE, TREE_OPERAND (rhs, 1));
}
generate_bytecode_insns (rhs, STACK_TARGET, state);
tree x;
if (TREE_SIDE_EFFECTS (op0) || TREE_SIDE_EFFECTS (op1))
abort ();
- x = build (COND_EXPR, TREE_TYPE (exp),
- build (code, boolean_type_node, op0, op1),
- op0, op1);
+ x = build3 (COND_EXPR, TREE_TYPE (exp),
+ build2 (code, boolean_type_node, op0, op1),
+ op0, op1);
generate_bytecode_insns (x, target, state);
break;
}
tree result;
expr = save_expr (expr);
- result = build (COND_EXPR, type,
- build (NE_EXPR, boolean_type_node, expr, expr),
- convert (type, integer_zero_node),
- convert_to_integer (type, expr));
+ result = build3 (COND_EXPR, type,
+ build2 (NE_EXPR, boolean_type_node, expr, expr),
+ convert (type, integer_zero_node),
+ convert_to_integer (type, expr));
- result = build (COND_EXPR, type,
- build (LE_EXPR, boolean_type_node, expr,
- convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
- TYPE_MIN_VALUE (type),
- result);
-
- result = build (COND_EXPR, type,
- build (GE_EXPR, boolean_type_node, expr,
- convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
- TYPE_MAX_VALUE (type),
- result);
+ result = build3 (COND_EXPR, type,
+ build2 (LE_EXPR, boolean_type_node, expr,
+ convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
+ TYPE_MIN_VALUE (type),
+ result);
+
+ result = build3 (COND_EXPR, type,
+ build2 (GE_EXPR, boolean_type_node, expr,
+ convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
+ TYPE_MAX_VALUE (type),
+ result);
return result;
}