From 923ab88cb2f07d36569c71cf53f8a0529ca1c2d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Wed, 25 Aug 2004 17:50:36 +0200 Subject: [PATCH] trans.h (build2_v, build3_v): New macros. * trans.h (build2_v, build3_v): New macros. (build_v): Remove. * f95-lang.c (gfc_truthvalue_conversion): Use build2 instead of build. * trans-array.c (gfc_conv_descriptor_data, gfc_conv_descriptor_offset, gfc_conv_descriptor_dimension, gfc_conv_descriptor_stride, gfc_conv_descriptor_lbound, gfc_conv_descriptor_ubound, gfc_trans_allocate_array_storage, gfc_trans_allocate_temp_array, gfc_trans_array_constructor_subarray, gfc_trans_array_constructor_value, gfc_conv_array_index_ref, gfc_trans_array_bound_check, gfc_conv_array_index_offset, gfc_conv_scalarized_array_ref, gfc_conv_array_ref, gfc_conv_array_ref, gfc_trans_preloop_setup, gfc_trans_scalarized_loop_end, gfc_conv_ss_startstride, gfc_conv_loop_setup, gfc_array_init_size, gfc_conv_array_initializer, gfc_trans_array_bounds, gfc_trans_auto_array_allocation, gfc_trans_dummy_array_bias, gfc_conv_expr_descriptor, gfc_conv_array_parameter, gfc_trans_deferred_array): Use buildN and buildN_v macros instead of build and build_v as appropriate. * trans-common.c (create_common): Same. * trans-decl.c (gfc_trans_auto_character_variable, gfc_trans_entry_master_switch, gfc_generate_function_code): Same. * trans-expr.c (gfc_conv_expr_present, gfc_conv_substring, gfc_conv_component_ref, gfc_conv_unary_op, gfc_conv_powi, gfc_conv_cst_int_power, gfc_conv_string_tmp, gfc_conv_concat_op, gfc_conv_expr_op, gfc_conv_function_call, gfc_trans_structure_assign): Same. * trans-intrinsic.c (build_fixbound_expr, build_round_expr, gfc_conv_intrinsic_aint, gfc_conv_intrinsic_bound, gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_mod, gfc_conv_intrinsic_dim, gfc_conv_intrinsic_sign, gfc_conv_intrinsic_dprod, gfc_conv_intrinsic_minmax, gfc_conv_intrinsic_anyall, gfc_conv_intrinsic_count, gfc_conv_intrinsic_arith, gfc_conv_intrinsic_minmaxloc, gfc_conv_intrinsic_minmaxval, gfc_conv_intrinsic_btest, gfc_conv_intrinsic_bitop, gfc_conv_intrinsic_singlebitop, gfc_conv_intrinsic_ibits, gfc_conv_intrinsic_ishft, gfc_conv_intrinsic_merge, gfc_conv_intrinsic_strcmp, gfc_conv_allocated, gfc_conv_associated, prepare_arg_info, gfc_conv_intrinsic_spacing, gfc_conv_intrinsic_rrspacing, gfc_conv_intrinsic_trim, gfc_conv_intrinsic_repeat, gfc_conv_intrinsic_iargc): Same. * trans-io.c (set_parameter_value, set_parameter_ref, set_string, set_flag, add_case, io_result, transfer_namelist_element, transfer_expr): Same. * trans-stmt.c (gfc_trans_goto, gfc_trans_return, gfc_trans_if_1, gfc_trans_arithmetic_if, gfc_trans_do, gfc_trans_do_while, gfc_trans_integer_select, gfc_trans_logical_select, gfc_trans_character_select, gfc_trans_forall_loop, gfc_trans_nested_forall_loop, gfc_do_allocate, generate_loop_for_temp_to_lhs, generate_loop_for_rhs_to_temp, compute_inner_temp_size, compute_overall_iter_number, allocate_temp_for_forall_nest, gfc_trans_pointer_assign_need_temp, gfc_trans_forall_1, gfc_evaluate_where_mask, gfc_trans_where_assign, gfc_trans_allocate): Same. * trans-types.c (gfc_get_dtype, gfc_get_array_type_bounds): Same. * trans.c (gfc_add_modify_expr, gfc_finish_block, gfc_build_array_ref, gfc_build_function_call, gfc_trans_runtime_check): Same. From-SVN: r86554 --- gcc/fortran/ChangeLog | 64 ++++++++ gcc/fortran/f95-lang.c | 2 +- gcc/fortran/trans-array.c | 284 ++++++++++++++++----------------- gcc/fortran/trans-common.c | 4 +- gcc/fortran/trans-decl.c | 12 +- gcc/fortran/trans-expr.c | 72 ++++----- gcc/fortran/trans-intrinsic.c | 291 +++++++++++++++++----------------- gcc/fortran/trans-io.c | 31 ++-- gcc/fortran/trans-stmt.c | 197 +++++++++++------------ gcc/fortran/trans-types.c | 12 +- gcc/fortran/trans.c | 11 +- gcc/fortran/trans.h | 5 +- 12 files changed, 525 insertions(+), 460 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0e8aab90b36..f93b3a434dc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,67 @@ +2004-08-25 Tobias Schlueter + + * trans.h (build2_v, build3_v): New macros. + (build_v): Remove. + * f95-lang.c (gfc_truthvalue_conversion): Use build2 instead of + build. + * trans-array.c (gfc_conv_descriptor_data, + gfc_conv_descriptor_offset, gfc_conv_descriptor_dimension, + gfc_conv_descriptor_stride, gfc_conv_descriptor_lbound, + gfc_conv_descriptor_ubound, gfc_trans_allocate_array_storage, + gfc_trans_allocate_temp_array, + gfc_trans_array_constructor_subarray, + gfc_trans_array_constructor_value, gfc_conv_array_index_ref, + gfc_trans_array_bound_check, gfc_conv_array_index_offset, + gfc_conv_scalarized_array_ref, gfc_conv_array_ref, + gfc_conv_array_ref, gfc_trans_preloop_setup, + gfc_trans_scalarized_loop_end, gfc_conv_ss_startstride, + gfc_conv_loop_setup, gfc_array_init_size, + gfc_conv_array_initializer, gfc_trans_array_bounds, + gfc_trans_auto_array_allocation, gfc_trans_dummy_array_bias, + gfc_conv_expr_descriptor, gfc_conv_array_parameter, + gfc_trans_deferred_array): Use buildN and buildN_v macros instead + of build and build_v as appropriate. + * trans-common.c (create_common): Same. + * trans-decl.c (gfc_trans_auto_character_variable, + gfc_trans_entry_master_switch, gfc_generate_function_code): Same. + * trans-expr.c (gfc_conv_expr_present, gfc_conv_substring, + gfc_conv_component_ref, gfc_conv_unary_op, gfc_conv_powi, + gfc_conv_cst_int_power, gfc_conv_string_tmp, gfc_conv_concat_op, + gfc_conv_expr_op, gfc_conv_function_call, + gfc_trans_structure_assign): Same. + * trans-intrinsic.c (build_fixbound_expr, build_round_expr, + gfc_conv_intrinsic_aint, gfc_conv_intrinsic_bound, + gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_mod, + gfc_conv_intrinsic_dim, gfc_conv_intrinsic_sign, + gfc_conv_intrinsic_dprod, gfc_conv_intrinsic_minmax, + gfc_conv_intrinsic_anyall, gfc_conv_intrinsic_count, + gfc_conv_intrinsic_arith, gfc_conv_intrinsic_minmaxloc, + gfc_conv_intrinsic_minmaxval, gfc_conv_intrinsic_btest, + gfc_conv_intrinsic_bitop, gfc_conv_intrinsic_singlebitop, + gfc_conv_intrinsic_ibits, gfc_conv_intrinsic_ishft, + gfc_conv_intrinsic_merge, gfc_conv_intrinsic_strcmp, + gfc_conv_allocated, gfc_conv_associated, prepare_arg_info, + gfc_conv_intrinsic_spacing, gfc_conv_intrinsic_rrspacing, + gfc_conv_intrinsic_trim, gfc_conv_intrinsic_repeat, + gfc_conv_intrinsic_iargc): Same. + * trans-io.c (set_parameter_value, set_parameter_ref, set_string, + set_flag, add_case, io_result, transfer_namelist_element, + transfer_expr): Same. + * trans-stmt.c (gfc_trans_goto, gfc_trans_return, gfc_trans_if_1, + gfc_trans_arithmetic_if, gfc_trans_do, gfc_trans_do_while, + gfc_trans_integer_select, gfc_trans_logical_select, + gfc_trans_character_select, gfc_trans_forall_loop, + gfc_trans_nested_forall_loop, gfc_do_allocate, + generate_loop_for_temp_to_lhs, generate_loop_for_rhs_to_temp, + compute_inner_temp_size, compute_overall_iter_number, + allocate_temp_for_forall_nest, gfc_trans_pointer_assign_need_temp, + gfc_trans_forall_1, gfc_evaluate_where_mask, + gfc_trans_where_assign, gfc_trans_allocate): Same. + * trans-types.c (gfc_get_dtype, gfc_get_array_type_bounds): Same. + * trans.c (gfc_add_modify_expr, gfc_finish_block, + gfc_build_array_ref, gfc_build_function_call, + gfc_trans_runtime_check): Same. + 2004-08-25 Tobias Schlueter * trans-const.c (gfc_conv_mpz_to_tree): Change call to diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index d5b58ce9fd3..77950e945f3 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -237,7 +237,7 @@ gfc_truthvalue_conversion (tree expr) if (TREE_CODE (expr) == INTEGER_CST) return integer_zerop (expr) ? boolean_false_node : boolean_true_node; else - return build (NE_EXPR, boolean_type_node, expr, integer_zero_node); + return build2 (NE_EXPR, boolean_type_node, expr, integer_zero_node); default: internal_error ("Unexpected type in truthvalue_conversion"); diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index f79ab1e6a74..b8480fdfa32 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -189,7 +189,7 @@ gfc_conv_descriptor_data (tree desc) && TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (field))) == ARRAY_TYPE); - return build (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); + return build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); } tree @@ -204,7 +204,7 @@ gfc_conv_descriptor_offset (tree desc) field = gfc_advance_chain (TYPE_FIELDS (type), OFFSET_FIELD); assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type); - return build (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); + return build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); } tree @@ -219,7 +219,7 @@ gfc_conv_descriptor_dtype (tree desc) field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD); assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type); - return build (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); + return build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); } static tree @@ -237,7 +237,7 @@ gfc_conv_descriptor_dimension (tree desc, tree dim) && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (field))) == RECORD_TYPE); - tmp = build (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE); tmp = gfc_build_array_ref (tmp, dim); return tmp; } @@ -253,7 +253,7 @@ gfc_conv_descriptor_stride (tree desc, tree dim) field = gfc_advance_chain (field, STRIDE_SUBFIELD); assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type); - tmp = build (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); return tmp; } @@ -268,7 +268,7 @@ gfc_conv_descriptor_lbound (tree desc, tree dim) field = gfc_advance_chain (field, LBOUND_SUBFIELD); assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type); - tmp = build (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); return tmp; } @@ -283,7 +283,7 @@ gfc_conv_descriptor_ubound (tree desc, tree dim) field = gfc_advance_chain (field, UBOUND_SUBFIELD); assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type); - tmp = build (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE); return tmp; } @@ -469,8 +469,8 @@ gfc_trans_allocate_array_storage (gfc_loopinfo * loop, gfc_ss_info * info, if (onstack) { /* Make a temporary variable to hold the data. */ - tmp = fold (build (MINUS_EXPR, TREE_TYPE (nelem), nelem, - integer_one_node)); + tmp = fold (build2 (MINUS_EXPR, TREE_TYPE (nelem), nelem, + integer_one_node)); tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node, tmp); tmp = build_array_type (gfc_get_element_type (TREE_TYPE (desc)), @@ -548,8 +548,8 @@ gfc_trans_allocate_temp_array (gfc_loopinfo * loop, gfc_ss_info * info, { /* Callee allocated arrays may not have a known bound yet. */ if (loop->to[n]) - loop->to[n] = fold (build (MINUS_EXPR, gfc_array_index_type, - loop->to[n], loop->from[n])); + loop->to[n] = fold (build2 (MINUS_EXPR, gfc_array_index_type, + loop->to[n], loop->from[n])); loop->from[n] = gfc_index_zero_node; } @@ -592,9 +592,9 @@ gfc_trans_allocate_temp_array (gfc_loopinfo * loop, gfc_ss_info * info, { /* For a callee allocated array express the loop bounds in terms of the descriptor fields. */ - tmp = build (MINUS_EXPR, gfc_array_index_type, - gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]), - gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n])); + tmp = build2 (MINUS_EXPR, gfc_array_index_type, + gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]), + gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n])); loop->to[n] = tmp; size = NULL_TREE; continue; @@ -610,10 +610,10 @@ gfc_trans_allocate_temp_array (gfc_loopinfo * loop, gfc_ss_info * info, tmp = gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]); gfc_add_modify_expr (&loop->pre, tmp, loop->to[n]); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - loop->to[n], gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + loop->to[n], gfc_index_one_node)); - size = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp)); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, size, tmp)); size = gfc_evaluate_now (size, &loop->pre); } @@ -624,8 +624,8 @@ gfc_trans_allocate_temp_array (gfc_loopinfo * loop, gfc_ss_info * info, /* Get the size of the array. */ nelem = size; if (size) - size = fold (build (MULT_EXPR, gfc_array_index_type, size, - TYPE_SIZE_UNIT (gfc_get_element_type (type)))); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, size, + TYPE_SIZE_UNIT (gfc_get_element_type (type)))); gfc_trans_allocate_array_storage (loop, info, size, nelem); @@ -697,7 +697,7 @@ gfc_trans_array_constructor_subarray (stmtblock_t * pblock, gfc_add_modify_expr (&body, tmp, se.expr); /* Increment the offset. */ - tmp = build (PLUS_EXPR, gfc_array_index_type, *poffset, gfc_index_one_node); + tmp = build2 (PLUS_EXPR, gfc_array_index_type, *poffset, gfc_index_one_node); gfc_add_modify_expr (&body, *poffset, tmp); /* Finish the loop. */ @@ -772,8 +772,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, fold_convert (TREE_TYPE (ref), se.expr)); gfc_add_block_to_block (&body, &se.post); - *poffset = fold (build (PLUS_EXPR, gfc_array_index_type, - *poffset, gfc_index_one_node)); + *poffset = fold (build2 (PLUS_EXPR, gfc_array_index_type, + *poffset, gfc_index_one_node)); } else { @@ -829,8 +829,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, tmp); gfc_add_expr_to_block (&body, tmp); - *poffset = fold (build (PLUS_EXPR, gfc_array_index_type, - *poffset, bound)); + *poffset = fold (build2 (PLUS_EXPR, gfc_array_index_type, + *poffset, bound)); } if (!INTEGER_CST_P (*poffset)) { @@ -875,22 +875,22 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, gfc_start_block (&body); /* Generate the exit condition. */ - end = build (GT_EXPR, boolean_type_node, loopvar, end); + end = build2 (GT_EXPR, boolean_type_node, loopvar, end); tmp = build1_v (GOTO_EXPR, exit_label); TREE_USED (exit_label) = 1; - tmp = build_v (COND_EXPR, end, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, end, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); /* The main loop body. */ gfc_add_expr_to_block (&body, loopbody); /* Increment the loop variable. */ - tmp = build (PLUS_EXPR, TREE_TYPE (loopvar), loopvar, step); + tmp = build2 (PLUS_EXPR, TREE_TYPE (loopvar), loopvar, step); gfc_add_modify_expr (&body, loopvar, tmp); /* Finish the loop. */ tmp = gfc_finish_block (&body); - tmp = build_v (LOOP_EXPR, tmp); + tmp = build1_v (LOOP_EXPR, tmp); gfc_add_expr_to_block (pblock, tmp); /* Add the exit label. */ @@ -1300,9 +1300,9 @@ gfc_conv_array_index_ref (gfc_se * se, tree pointer, tree * indices, { /* index = index + stride[n]*indices[n] */ tmp = gfc_conv_array_stride (se->expr, n); - tmp = fold (build (MULT_EXPR, gfc_array_index_type, indices[n], tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, indices[n], tmp)); - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, tmp)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, index, tmp)); } /* Result = data[index]. */ @@ -1330,11 +1330,11 @@ gfc_trans_array_bound_check (gfc_se * se, tree descriptor, tree index, int n) index = gfc_evaluate_now (index, &se->pre); /* Check lower bound. */ tmp = gfc_conv_array_lbound (descriptor, n); - fault = fold (build (LT_EXPR, boolean_type_node, index, tmp)); + fault = fold (build2 (LT_EXPR, boolean_type_node, index, tmp)); /* Check upper bound. */ tmp = gfc_conv_array_ubound (descriptor, n); - cond = fold (build (GT_EXPR, boolean_type_node, index, tmp)); - fault = fold (build (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); + cond = fold (build2 (GT_EXPR, boolean_type_node, index, tmp)); + fault = fold (build2 (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); gfc_trans_runtime_check (fault, gfc_strconst_fault, &se->pre); @@ -1429,10 +1429,10 @@ gfc_conv_array_index_offset (gfc_se * se, gfc_ss_info * info, int dim, int i, /* Multiply the loop variable by the stride and dela. */ index = se->loop->loopvar[i]; - index = fold (build (MULT_EXPR, gfc_array_index_type, index, - info->stride[i])); - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, - info->delta[i])); + index = fold (build2 (MULT_EXPR, gfc_array_index_type, index, + info->stride[i])); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, index, + info->delta[i])); if (ar->dimen_type[dim] == DIMEN_VECTOR) { @@ -1453,12 +1453,12 @@ gfc_conv_array_index_offset (gfc_se * se, gfc_ss_info * info, int dim, int i, assert (se->loop); index = se->loop->loopvar[se->loop->order[i]]; if (!integer_zerop (info->delta[i])) - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, - info->delta[i])); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, + index, info->delta[i])); } /* Multiply by the stride. */ - index = fold (build (MULT_EXPR, gfc_array_index_type, index, stride)); + index = fold (build2 (MULT_EXPR, gfc_array_index_type, index, stride)); return index; } @@ -1484,7 +1484,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar) info->stride0); /* Add the offset for this dimension to the stored offset for all other dimensions. */ - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, info->offset)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, index, info->offset)); tmp = gfc_build_indirect_ref (info->data); se->expr = gfc_build_array_ref (tmp, index); @@ -1548,23 +1548,25 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar) indexse.expr = gfc_evaluate_now (indexse.expr, &se->pre); tmp = gfc_conv_array_lbound (se->expr, n); - cond = fold (build (LT_EXPR, boolean_type_node, indexse.expr, tmp)); + cond = fold (build2 (LT_EXPR, boolean_type_node, + indexse.expr, tmp)); fault = - fold (build (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); + fold (build2 (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); tmp = gfc_conv_array_ubound (se->expr, n); - cond = fold (build (GT_EXPR, boolean_type_node, indexse.expr, tmp)); + cond = fold (build2 (GT_EXPR, boolean_type_node, + indexse.expr, tmp)); fault = - fold (build (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); + fold (build2 (TRUTH_OR_EXPR, boolean_type_node, fault, cond)); } /* Multiply the index by the stride. */ stride = gfc_conv_array_stride (se->expr, n); - tmp = fold (build (MULT_EXPR, gfc_array_index_type, indexse.expr, - stride)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, indexse.expr, + stride)); /* And add it to the total. */ - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, tmp)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, index, tmp)); } if (flag_bounds_check) @@ -1572,7 +1574,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar) tmp = gfc_conv_array_offset (se->expr); if (!integer_zerop (tmp)) - index = fold (build (PLUS_EXPR, gfc_array_index_type, index, tmp)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, index, tmp)); /* Access the calculated element. */ tmp = gfc_conv_array_data (se->expr); @@ -1633,8 +1635,8 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, stride); gfc_add_block_to_block (pblock, &se.pre); - info->offset = fold (build (PLUS_EXPR, gfc_array_index_type, - info->offset, index)); + info->offset = fold (build2 (PLUS_EXPR, gfc_array_index_type, + info->offset, index)); info->offset = gfc_evaluate_now (info->offset, pblock); } @@ -1672,8 +1674,8 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, index = gfc_conv_array_index_offset (&se, info, info->dim[i], i, ar, stride); gfc_add_block_to_block (pblock, &se.pre); - info->offset = fold (build (PLUS_EXPR, gfc_array_index_type, - info->offset, index)); + info->offset = fold (build2 (PLUS_EXPR, gfc_array_index_type, + info->offset, index)); info->offset = gfc_evaluate_now (info->offset, pblock); } @@ -1739,23 +1741,23 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n, gfc_init_block (&block); /* The exit condition. */ - cond = build (GT_EXPR, boolean_type_node, loop->loopvar[n], loop->to[n]); + cond = build2 (GT_EXPR, boolean_type_node, loop->loopvar[n], loop->to[n]); tmp = build1_v (GOTO_EXPR, exit_label); TREE_USED (exit_label) = 1; - tmp = build_v (COND_EXPR, cond, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); /* The main body. */ gfc_add_expr_to_block (&block, loopbody); /* Increment the loopvar. */ - tmp = build (PLUS_EXPR, gfc_array_index_type, - loop->loopvar[n], gfc_index_one_node); + tmp = build2 (PLUS_EXPR, gfc_array_index_type, + loop->loopvar[n], gfc_index_one_node); gfc_add_modify_expr (&block, loop->loopvar[n], tmp); /* Build the loop. */ tmp = gfc_finish_block (&block); - tmp = build_v (LOOP_EXPR, tmp); + tmp = build1_v (LOOP_EXPR, tmp); gfc_add_expr_to_block (&loop->code[n], tmp); /* Add the exit label. */ @@ -2071,30 +2073,30 @@ gfc_conv_ss_startstride (gfc_loopinfo * loop) /* Check lower bound. */ bound = gfc_conv_array_lbound (desc, dim); tmp = info->start[n]; - tmp = fold (build (LT_EXPR, boolean_type_node, tmp, bound)); - fault = fold (build (TRUTH_OR_EXPR, boolean_type_node, fault, - tmp)); + tmp = fold (build2 (LT_EXPR, boolean_type_node, tmp, bound)); + fault = fold (build2 (TRUTH_OR_EXPR, boolean_type_node, fault, + tmp)); /* Check the upper bound. */ bound = gfc_conv_array_ubound (desc, dim); end = gfc_conv_section_upper_bound (ss, n, &block); - tmp = fold (build (GT_EXPR, boolean_type_node, end, bound)); - fault = fold (build (TRUTH_OR_EXPR, boolean_type_node, fault, - tmp)); + tmp = fold (build2 (GT_EXPR, boolean_type_node, end, bound)); + fault = fold (build2 (TRUTH_OR_EXPR, boolean_type_node, fault, + tmp)); /* Check the section sizes match. */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, end, - info->start[n])); - tmp = fold (build (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, - info->stride[n])); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, end, + info->start[n])); + tmp = fold (build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, + info->stride[n])); /* We remember the size of the first section, and check all the others against this. */ if (size[n]) { tmp = - fold (build (NE_EXPR, boolean_type_node, tmp, size[n])); + fold (build2 (NE_EXPR, boolean_type_node, tmp, size[n])); fault = - build (TRUTH_OR_EXPR, boolean_type_node, fault, tmp); + build2 (TRUTH_OR_EXPR, boolean_type_node, fault, tmp); } else size[n] = gfc_evaluate_now (tmp, &block); @@ -2370,12 +2372,10 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) /* To = from + (size - 1) * stride. */ tmp = gfc_conv_mpz_to_tree (i, gfc_index_integer_kind); if (!integer_onep (info->stride[n])) - { - tmp = fold (build (MULT_EXPR, gfc_array_index_type, - tmp, info->stride[n])); - } - loop->to[n] = fold (build (PLUS_EXPR, gfc_array_index_type, - loop->from[n], tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, + tmp, info->stride[n])); + loop->to[n] = fold (build2 (PLUS_EXPR, gfc_array_index_type, + loop->from[n], tmp)); } else { @@ -2413,10 +2413,10 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) with start = 0, this simplifies to last = end / step; for (i = 0; i<=last; i++){...}; */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, loop->to[n], - loop->from[n])); - tmp = fold (build (TRUNC_DIV_EXPR, gfc_array_index_type, tmp, - info->stride[n])); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + loop->to[n], loop->from[n])); + tmp = fold (build2 (TRUNC_DIV_EXPR, gfc_array_index_type, + tmp, info->stride[n])); loop->to[n] = gfc_evaluate_now (tmp, &loop->pre); /* Make the loop variable start at 0. */ loop->from[n] = gfc_index_zero_node; @@ -2469,12 +2469,12 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) { /* Calculate the offset relative to the loop variable. First multiply by the stride. */ - tmp = fold (build (MULT_EXPR, gfc_array_index_type, - loop->from[n], info->stride[n])); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, + loop->from[n], info->stride[n])); /* Then subtract this from our starting value. */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, - info->start[n], tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + info->start[n], tmp)); info->delta[n] = gfc_evaluate_now (tmp, &loop->pre); } @@ -2557,12 +2557,12 @@ gfc_array_init_size (tree descriptor, int rank, tree * poffset, gfc_add_modify_expr (pblock, tmp, se.expr); /* Work out the offset for this component. */ - tmp = fold (build (MULT_EXPR, gfc_array_index_type, se.expr, stride)); - offset = fold (build (MINUS_EXPR, gfc_array_index_type, offset, tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, se.expr, stride)); + offset = fold (build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp)); /* Start the calculation for the size of this dimension. */ - size = build (MINUS_EXPR, gfc_array_index_type, - gfc_index_one_node, se.expr); + size = build2 (MINUS_EXPR, gfc_array_index_type, + gfc_index_one_node, se.expr); /* Set upper bound. */ gfc_init_se (&se, NULL); @@ -2578,17 +2578,17 @@ gfc_array_init_size (tree descriptor, int rank, tree * poffset, gfc_add_modify_expr (pblock, tmp, stride); /* Calculate the size of this dimension. */ - size = fold (build (PLUS_EXPR, gfc_array_index_type, se.expr, size)); + size = fold (build2 (PLUS_EXPR, gfc_array_index_type, se.expr, size)); /* Multiply the stride by the number of elements in this dimension. */ - stride = fold (build (MULT_EXPR, gfc_array_index_type, stride, size)); + stride = fold (build2 (MULT_EXPR, gfc_array_index_type, stride, size)); stride = gfc_evaluate_now (stride, pblock); } /* The stride is the number of elements in the array, so multiply by the size of an element to get the total size. */ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type)); - size = fold (build (MULT_EXPR, gfc_array_index_type, stride, tmp)); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, stride, tmp)); if (poffset != NULL) { @@ -2776,7 +2776,7 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) else tmp1 = gfc_conv_mpz_to_tree (c->n.offset, gfc_index_integer_kind); - range = build (RANGE_EXPR, integer_type_node, tmp1, tmp2); + range = build2 (RANGE_EXPR, integer_type_node, tmp1, tmp2); } else range = NULL; @@ -2864,8 +2864,8 @@ gfc_trans_array_bounds (tree type, gfc_symbol * sym, tree * poffset, gfc_add_modify_expr (pblock, ubound, se.expr); } /* The offset of this dimension. offset = offset - lbound * stride. */ - tmp = fold (build (MULT_EXPR, gfc_array_index_type, lbound, size)); - offset = fold (build (MINUS_EXPR, gfc_array_index_type, offset, tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, lbound, size)); + offset = fold (build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp)); /* The size of this dimension, and the stride of the next. */ if (dim + 1 < as->rank) @@ -2876,10 +2876,10 @@ gfc_trans_array_bounds (tree type, gfc_symbol * sym, tree * poffset, if (ubound != NULL_TREE && !(stride && INTEGER_CST_P (stride))) { /* Calculate stride = size * (ubound + 1 - lbound). */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, - gfc_index_one_node, lbound)); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, ubound, tmp)); - tmp = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + gfc_index_one_node, lbound)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, ubound, tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, size, tmp)); if (stride) gfc_add_modify_expr (pblock, stride, tmp); else @@ -2927,7 +2927,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody) /* Emit a DECL_EXPR for this variable, which will cause the gimplifier to allocate stoage, and all that good stuff. */ - tmp = build (DECL_EXPR, TREE_TYPE (decl), decl); + tmp = build1 (DECL_EXPR, TREE_TYPE (decl), decl); gfc_add_expr_to_block (&block, tmp); } @@ -2952,7 +2952,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody) /* The size is the number of elements in the array, so multiply by the size of an element to get the total size. */ tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type)); - size = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp)); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, size, tmp)); /* Allocate memory to hold the data. */ tmp = gfc_chainon_list (NULL_TREE, size); @@ -3110,7 +3110,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) partial = gfc_create_var (boolean_type_node, "partial"); TREE_USED (partial) = 1; tmp = gfc_conv_descriptor_stride (dumdesc, gfc_rank_cst[0]); - tmp = fold (build (EQ_EXPR, boolean_type_node, tmp, integer_one_node)); + tmp = fold (build2 (EQ_EXPR, boolean_type_node, tmp, integer_one_node)); gfc_add_modify_expr (&block, partial, tmp); } else @@ -3126,9 +3126,9 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) stride = gfc_conv_descriptor_stride (dumdesc, gfc_rank_cst[0]); stride = gfc_evaluate_now (stride, &block); - tmp = build (EQ_EXPR, boolean_type_node, stride, integer_zero_node); - tmp = build (COND_EXPR, gfc_array_index_type, tmp, - gfc_index_one_node, stride); + tmp = build2 (EQ_EXPR, boolean_type_node, stride, integer_zero_node); + tmp = build3 (COND_EXPR, gfc_array_index_type, tmp, + gfc_index_one_node, stride); stride = GFC_TYPE_ARRAY_STRIDE (type, 0); gfc_add_modify_expr (&block, stride, tmp); @@ -3157,8 +3157,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) if (stmt_packed != NULL_TREE && stmt_unpacked != NULL_TREE) { /* Don't repack unknown shape arrays when the first stride is 1. */ - tmp = build (COND_EXPR, TREE_TYPE (stmt_packed), partial, - stmt_packed, stmt_unpacked); + tmp = build3 (COND_EXPR, TREE_TYPE (stmt_packed), partial, + stmt_packed, stmt_unpacked); } else tmp = stmt_packed != NULL_TREE ? stmt_packed : stmt_unpacked; @@ -3211,11 +3211,11 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) { /* Check (ubound(a) - lbound(a) == ubound(b) - lbound(b)). */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, ubound, - lbound)); - stride = build (MINUS_EXPR, gfc_array_index_type, dubound, - dlbound); - tmp = fold (build (NE_EXPR, gfc_array_index_type, tmp, stride)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + ubound, lbound)); + stride = build2 (MINUS_EXPR, gfc_array_index_type, + dubound, dlbound); + tmp = fold (build2 (NE_EXPR, gfc_array_index_type, tmp, stride)); gfc_trans_runtime_check (tmp, gfc_strconst_bounds, &block); } } @@ -3223,13 +3223,13 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) { /* For assumed shape arrays move the upper bound by the same amount as the lower bound. */ - tmp = build (MINUS_EXPR, gfc_array_index_type, dubound, dlbound); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, tmp, lbound)); + tmp = build2 (MINUS_EXPR, gfc_array_index_type, dubound, dlbound); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, tmp, lbound)); gfc_add_modify_expr (&block, ubound, tmp); } /* The offset of this dimension. offset = offset - lbound * stride. */ - tmp = fold (build (MULT_EXPR, gfc_array_index_type, lbound, stride)); - offset = fold (build (MINUS_EXPR, gfc_array_index_type, offset, tmp)); + tmp = fold (build2 (MULT_EXPR, gfc_array_index_type, lbound, stride)); + offset = fold (build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp)); /* The size of this dimension, and the stride of the next. */ if (n + 1 < sym->as->rank) @@ -3250,21 +3250,19 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) else { /* Calculate stride = size * (ubound + 1 - lbound). */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, - gfc_index_one_node, lbound)); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - ubound, tmp)); - size = fold (build (MULT_EXPR, gfc_array_index_type, - size, tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + gfc_index_one_node, lbound)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + ubound, tmp)); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, + size, tmp)); stmt_packed = size; } /* Assign the stride. */ if (stmt_packed != NULL_TREE && stmt_unpacked != NULL_TREE) - { - tmp = build (COND_EXPR, gfc_array_index_type, partial, - stmt_unpacked, stmt_packed); - } + tmp = build3 (COND_EXPR, gfc_array_index_type, partial, + stmt_unpacked, stmt_packed); else tmp = (stmt_packed != NULL_TREE) ? stmt_packed : stmt_unpacked; gfc_add_modify_expr (&block, stride, tmp); @@ -3286,7 +3284,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) if (optional_arg) { tmp = gfc_conv_expr_present (sym); - stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); + stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); } gfc_add_expr_to_block (&block, stmt); @@ -3317,13 +3315,13 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) /* Only do the cleanup if the array was repacked. */ tmp = gfc_build_indirect_ref (dumdesc); tmp = gfc_conv_descriptor_data (tmp); - tmp = build (NE_EXPR, boolean_type_node, tmp, tmpdesc); - stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); + tmp = build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc); + stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); if (optional_arg) { tmp = gfc_conv_expr_present (sym); - stmt = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); + stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); } gfc_add_expr_to_block (&block, stmt); } @@ -3646,10 +3644,10 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) } tmp = gfc_conv_array_lbound (desc, n); - tmp = fold (build (MINUS_EXPR, TREE_TYPE (tmp), start, tmp)); + tmp = fold (build2 (MINUS_EXPR, TREE_TYPE (tmp), start, tmp)); - tmp = fold (build (MULT_EXPR, TREE_TYPE (tmp), tmp, stride)); - offset = fold (build (PLUS_EXPR, TREE_TYPE (tmp), offset, tmp)); + tmp = fold (build2 (MULT_EXPR, TREE_TYPE (tmp), tmp, stride)); + offset = fold (build2 (PLUS_EXPR, TREE_TYPE (tmp), offset, tmp)); if (info->ref->u.ar.dimen_type[n] == DIMEN_ELEMENT) { @@ -3666,9 +3664,9 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) if (!integer_onep (from)) { /* Make sure the new section starts at 1. */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, gfc_index_one_node, from)); - to = fold (build (PLUS_EXPR, gfc_array_index_type, to, tmp)); + to = fold (build2 (PLUS_EXPR, gfc_array_index_type, to, tmp)); from = gfc_index_one_node; } tmp = gfc_conv_descriptor_lbound (parm, gfc_rank_cst[dim]); @@ -3680,14 +3678,12 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) /* Multiply the stride by the section stride to get the total stride. */ - stride = fold (build (MULT_EXPR, gfc_array_index_type, stride, - info->stride[dim])); + stride = fold (build2 (MULT_EXPR, gfc_array_index_type, + stride, info->stride[dim])); if (se->direct_byref) - { - base = fold (build (MINUS_EXPR, TREE_TYPE (base), - base, stride)); - } + base = fold (build2 (MINUS_EXPR, TREE_TYPE (base), + base, stride)); /* Store the new stride. */ tmp = gfc_conv_descriptor_stride (parm, gfc_rank_cst[dim]); @@ -3810,8 +3806,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77) loop cleanup code. */ tmp = gfc_build_indirect_ref (desc); tmp = gfc_conv_array_data (tmp); - tmp = build (NE_EXPR, boolean_type_node, ptr, tmp); - tmp = build_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); + tmp = build2 (NE_EXPR, boolean_type_node, ptr, tmp); + tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &se->post); @@ -3887,8 +3883,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, tree body) deallocate = gfc_array_deallocate (descriptor); tmp = gfc_conv_descriptor_data (descriptor); - tmp = build (NE_EXPR, boolean_type_node, tmp, integer_zero_node); - tmp = build_v (COND_EXPR, tmp, deallocate, build_empty_stmt ()); + tmp = build2 (NE_EXPR, boolean_type_node, tmp, integer_zero_node); + tmp = build3_v (COND_EXPR, tmp, deallocate, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); tmp = gfc_finish_block (&block); diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 451312ef410..69cb1a3a20b 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -422,8 +422,8 @@ create_common (gfc_common_head *com) /* Build component reference for each variable. */ for (s = current_common; s; s = next_s) { - s->sym->backend_decl = build (COMPONENT_REF, TREE_TYPE (s->field), - decl, s->field, NULL_TREE); + s->sym->backend_decl = build3 (COMPONENT_REF, TREE_TYPE (s->field), + decl, s->field, NULL_TREE); next_s = s->next; gfc_free (s); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 71889058814..9f6af8efc58 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1856,7 +1856,7 @@ gfc_trans_auto_character_variable (gfc_symbol * sym, tree fnbody) /* Emit a DECL_EXPR for this variable, which will cause the gimplifier to allocate storage, and all that good stuff. */ - tmp = build (DECL_EXPR, TREE_TYPE (decl), decl); + tmp = build1 (DECL_EXPR, TREE_TYPE (decl), decl); gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, fnbody); @@ -2114,7 +2114,7 @@ gfc_trans_entry_master_switch (gfc_entry_list * el) label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); DECL_CONTEXT (label) = current_function_decl; val = build_int_cst (gfc_array_index_type, el->id); - tmp = build_v (CASE_LABEL_EXPR, val, NULL_TREE, label); + tmp = build3_v (CASE_LABEL_EXPR, val, NULL_TREE, label); gfc_add_expr_to_block (&block, tmp); /* And jump to the actual entry point. */ @@ -2130,7 +2130,7 @@ gfc_trans_entry_master_switch (gfc_entry_list * el) tmp = gfc_finish_block (&block); /* The first argument selects the entry point. */ val = DECL_ARGUMENTS (current_function_decl); - tmp = build_v (SWITCH_EXPR, val, tmp, NULL_TREE); + tmp = build3_v (SWITCH_EXPR, val, tmp, NULL_TREE); return tmp; } @@ -2233,9 +2233,9 @@ gfc_generate_function_code (gfc_namespace * ns) else { /* Set the return value to the dummy result variable. */ - tmp = build (MODIFY_EXPR, TREE_TYPE (result), - DECL_RESULT (fndecl), result); - tmp = build_v (RETURN_EXPR, tmp); + tmp = build2 (MODIFY_EXPR, TREE_TYPE (result), + DECL_RESULT (fndecl), result); + tmp = build1_v (RETURN_EXPR, tmp); gfc_add_expr_to_block (&block, tmp); } } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 127a820754f..50aa9ca338a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -136,8 +136,8 @@ gfc_conv_expr_present (gfc_symbol * sym) || GFC_ARRAY_TYPE_P (TREE_TYPE (decl))); decl = GFC_DECL_SAVED_DESCRIPTOR (decl); } - return build (NE_EXPR, boolean_type_node, decl, - fold_convert (TREE_TYPE (decl), null_pointer_node)); + return build2 (NE_EXPR, boolean_type_node, decl, + fold_convert (TREE_TYPE (decl), null_pointer_node)); } @@ -199,10 +199,10 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind) gfc_add_block_to_block (&se->pre, &end.pre); } tmp = - build (MINUS_EXPR, gfc_strlen_type_node, - fold_convert (gfc_strlen_type_node, integer_one_node), - start.expr); - tmp = build (PLUS_EXPR, gfc_strlen_type_node, end.expr, tmp); + build2 (MINUS_EXPR, gfc_strlen_type_node, + fold_convert (gfc_strlen_type_node, integer_one_node), + start.expr); + tmp = build2 (PLUS_EXPR, gfc_strlen_type_node, end.expr, tmp); se->string_length = fold (tmp); } @@ -224,7 +224,7 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) field = c->backend_decl; assert (TREE_CODE (field) == FIELD_DECL); decl = se->expr; - tmp = build (COMPONENT_REF, TREE_TYPE (field), decl, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), decl, field, NULL_TREE); se->expr = tmp; @@ -379,8 +379,8 @@ gfc_conv_unary_op (enum tree_code code, gfc_se * se, gfc_expr * expr) We must convert it to a compare to 0 (e.g. EQ_EXPR (op1, 0)). All other unary operators have an equivalent GIMPLE unary operator. */ if (code == TRUTH_NOT_EXPR) - se->expr = build (EQ_EXPR, type, operand.expr, - convert (type, integer_zero_node)); + se->expr = build2 (EQ_EXPR, type, operand.expr, + convert (type, integer_zero_node)); else se->expr = build1 (code, type, operand.expr); @@ -469,7 +469,7 @@ gfc_conv_powi (gfc_se * se, int n, tree * tmpvar) op1 = op0; } - tmp = fold (build (MULT_EXPR, TREE_TYPE (op0), op0, op1)); + tmp = fold (build2 (MULT_EXPR, TREE_TYPE (op0), op0, op1)); tmp = gfc_evaluate_now (tmp, &se->pre); if (n < POWI_TABLE_SIZE) @@ -508,29 +508,29 @@ gfc_conv_cst_int_power (gfc_se * se, tree lhs, tree rhs) /* If rhs < 0 and lhs is an integer, the result is -1, 0 or 1. */ if ((sgn == -1) && (TREE_CODE (type) == INTEGER_TYPE)) { - tmp = build (EQ_EXPR, boolean_type_node, lhs, - fold_convert (TREE_TYPE (lhs), integer_minus_one_node)); - cond = build (EQ_EXPR, boolean_type_node, lhs, - convert (TREE_TYPE (lhs), integer_one_node)); + tmp = build2 (EQ_EXPR, boolean_type_node, lhs, + fold_convert (TREE_TYPE (lhs), integer_minus_one_node)); + cond = build2 (EQ_EXPR, boolean_type_node, lhs, + convert (TREE_TYPE (lhs), integer_one_node)); /* If rhs is even, result = (lhs == 1 || lhs == -1) ? 1 : 0. */ if ((n & 1) == 0) { - tmp = build (TRUTH_OR_EXPR, boolean_type_node, tmp, cond); - se->expr = build (COND_EXPR, type, tmp, - convert (type, integer_one_node), - convert (type, integer_zero_node)); + tmp = build2 (TRUTH_OR_EXPR, boolean_type_node, tmp, cond); + se->expr = build3 (COND_EXPR, type, tmp, + convert (type, integer_one_node), + convert (type, integer_zero_node)); return 1; } /* If rhs is odd, result = (lhs == 1) ? 1 : (lhs == -1) ? -1 : 0. */ - tmp = build (COND_EXPR, type, tmp, - convert (type, integer_minus_one_node), - convert (type, integer_zero_node)); - se->expr = build (COND_EXPR, type, cond, - convert (type, integer_one_node), - tmp); + tmp = build3 (COND_EXPR, type, tmp, + convert (type, integer_minus_one_node), + convert (type, integer_zero_node)); + se->expr = build3 (COND_EXPR, type, cond, + convert (type, integer_one_node), + tmp); return 1; } @@ -539,7 +539,7 @@ gfc_conv_cst_int_power (gfc_se * se, tree lhs, tree rhs) if (sgn == -1) { tmp = gfc_build_const (type, integer_one_node); - vartmp[1] = build (RDIV_EXPR, type, tmp, vartmp[1]); + vartmp[1] = build2 (RDIV_EXPR, type, tmp, vartmp[1]); } se->expr = gfc_conv_powi (se, n, vartmp); @@ -691,9 +691,9 @@ gfc_conv_string_tmp (gfc_se * se, tree type, tree len) if (gfc_can_put_var_on_stack (len)) { /* Create a temporary variable to hold the result. */ - tmp = fold (build (MINUS_EXPR, gfc_strlen_type_node, len, - convert (gfc_strlen_type_node, - integer_one_node))); + tmp = fold (build2 (MINUS_EXPR, gfc_strlen_type_node, len, + convert (gfc_strlen_type_node, + integer_one_node))); tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node, tmp); tmp = build_array_type (gfc_character1_type_node, tmp); var = gfc_create_var (tmp, "str"); @@ -750,8 +750,8 @@ gfc_conv_concat_op (gfc_se * se, gfc_expr * expr) len = TYPE_MAX_VALUE (TYPE_DOMAIN (type)); if (len == NULL_TREE) { - len = fold (build (PLUS_EXPR, TREE_TYPE (lse.string_length), - lse.string_length, rse.string_length)); + len = fold (build2 (PLUS_EXPR, TREE_TYPE (lse.string_length), + lse.string_length, rse.string_length)); } type = build_pointer_type (type); @@ -944,11 +944,11 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) if (lop) { /* The result of logical ops is always boolean_type_node. */ - tmp = fold (build (code, type, lse.expr, rse.expr)); + tmp = fold (build2 (code, type, lse.expr, rse.expr)); se->expr = convert (type, tmp); } else - se->expr = fold (build (code, type, lse.expr, rse.expr)); + se->expr = fold (build2 (code, type, lse.expr, rse.expr)); /* Add the post blocks. */ gfc_add_block_to_block (&se->post, &rse.post); @@ -1167,8 +1167,8 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node; fntype = TREE_TYPE (TREE_TYPE (se->expr)); - se->expr = build (CALL_EXPR, TREE_TYPE (fntype), se->expr, - arglist, NULL_TREE); + se->expr = build3 (CALL_EXPR, TREE_TYPE (fntype), se->expr, + arglist, NULL_TREE); /* A pure function may still have side-effects - it may modify its parameters. */ @@ -1193,7 +1193,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, /* Check the data pointer hasn't been modified. This would happen in a function returning a pointer. */ tmp = gfc_conv_descriptor_data (info->descriptor); - tmp = build (NE_EXPR, boolean_type_node, tmp, info->data); + tmp = build2 (NE_EXPR, boolean_type_node, tmp, info->data); gfc_trans_runtime_check (tmp, gfc_strconst_fault, &se->pre); } se->expr = info->descriptor; @@ -1617,7 +1617,7 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr) continue; field = cm->backend_decl; - tmp = build (COMPONENT_REF, TREE_TYPE (field), dest, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), dest, field, NULL_TREE); tmp = gfc_trans_subcomponent_assign (tmp, cm, c->expr); gfc_add_expr_to_block (&block, tmp); } diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index cfe305136f2..cfcbd2fb13d 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -226,11 +226,11 @@ build_fixbound_expr (stmtblock_t * pblock, tree arg, tree type, int up) intval = gfc_evaluate_now (intval, pblock); tmp = convert (argtype, intval); - cond = build (up ? GE_EXPR : LE_EXPR, boolean_type_node, tmp, arg); + cond = build2 (up ? GE_EXPR : LE_EXPR, boolean_type_node, tmp, arg); - tmp = build (up ? PLUS_EXPR : MINUS_EXPR, type, intval, - convert (type, integer_one_node)); - tmp = build (COND_EXPR, type, cond, intval, tmp); + tmp = build2 (up ? PLUS_EXPR : MINUS_EXPR, type, intval, + convert (type, integer_one_node)); + tmp = build3 (COND_EXPR, type, cond, intval, tmp); return tmp; } @@ -258,10 +258,10 @@ build_round_expr (stmtblock_t * pblock, tree arg, tree type) neg = build_real (argtype, r); tmp = gfc_build_const (argtype, integer_zero_node); - cond = fold (build (GT_EXPR, boolean_type_node, arg, tmp)); + cond = fold (build2 (GT_EXPR, boolean_type_node, arg, tmp)); - tmp = fold (build (COND_EXPR, argtype, cond, pos, neg)); - tmp = fold (build (PLUS_EXPR, argtype, arg, tmp)); + tmp = fold (build3 (COND_EXPR, argtype, cond, pos, neg)); + tmp = fold (build2 (PLUS_EXPR, argtype, arg, tmp)); return fold (build1 (FIX_TRUNC_EXPR, type, tmp)); } @@ -368,17 +368,17 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, int op) n = gfc_validate_kind (BT_INTEGER, kind); mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE); tmp = gfc_conv_mpfr_to_tree (huge, kind); - cond = build (LT_EXPR, boolean_type_node, arg, tmp); + cond = build2 (LT_EXPR, boolean_type_node, arg, tmp); mpfr_neg (huge, huge, GFC_RND_MODE); tmp = gfc_conv_mpfr_to_tree (huge, kind); - tmp = build (GT_EXPR, boolean_type_node, arg, tmp); - cond = build (TRUTH_AND_EXPR, boolean_type_node, cond, tmp); + tmp = build2 (GT_EXPR, boolean_type_node, arg, tmp); + cond = build2 (TRUTH_AND_EXPR, boolean_type_node, cond, tmp); itype = gfc_get_int_type (kind); tmp = build_fix_expr (&se->pre, arg, itype, op); tmp = convert (type, tmp); - se->expr = build (COND_EXPR, type, cond, tmp, arg); + se->expr = build3 (COND_EXPR, type, cond, tmp, arg); mpfr_clear (huge); } @@ -641,8 +641,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper) assert (se->ss->expr == expr); gfc_advance_se_ss_chain (se); bound = se->loop->loopvar[0]; - bound = fold (build (MINUS_EXPR, gfc_array_index_type, bound, - se->loop->from[0])); + bound = fold (build2 (MINUS_EXPR, gfc_array_index_type, bound, + se->loop->from[0])); } else { @@ -653,8 +653,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper) gfc_add_block_to_block (&se->pre, &argse.pre); bound = argse.expr; /* Convert from one based to zero based. */ - bound = fold (build (MINUS_EXPR, gfc_array_index_type, bound, - gfc_index_one_node)); + bound = fold (build2 (MINUS_EXPR, gfc_array_index_type, bound, + gfc_index_one_node)); } /* TODO: don't re-evaluate the descriptor on each iteration. */ @@ -679,11 +679,12 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper) if (flag_bounds_check) { bound = gfc_evaluate_now (bound, &se->pre); - cond = fold (build (LT_EXPR, boolean_type_node, bound, - convert (TREE_TYPE (bound), integer_zero_node))); + cond = fold (build2 (LT_EXPR, boolean_type_node, + bound, convert (TREE_TYPE (bound), + integer_zero_node))); tmp = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (TREE_TYPE (desc))]; - tmp = fold (build (GE_EXPR, boolean_type_node, bound, tmp)); - cond = fold(build (TRUTH_ORIF_EXPR, boolean_type_node, cond, tmp)); + tmp = fold (build2 (GE_EXPR, boolean_type_node, bound, tmp)); + cond = fold(build2 (TRUTH_ORIF_EXPR, boolean_type_node, cond, tmp)); gfc_trans_runtime_check (cond, gfc_strconst_fault, &se->pre); } } @@ -761,7 +762,7 @@ gfc_conv_intrinsic_cmplx (gfc_se * se, gfc_expr * expr, int both) else imag = build_real_from_int_cst (TREE_TYPE (type), integer_zero_node); - se->expr = fold (build (COMPLEX_EXPR, type, real, imag)); + se->expr = fold (build2 (COMPLEX_EXPR, type, real, imag)); } /* Remainder function MOD(A, P) = A - INT(A / P) * P. @@ -791,7 +792,7 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo) { case BT_INTEGER: /* Integer case is easy, we've got a builtin op. */ - se->expr = build (TRUNC_MOD_EXPR, type, arg, arg2); + se->expr = build2 (TRUNC_MOD_EXPR, type, arg, arg2); break; case BT_REAL: @@ -799,26 +800,26 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo) arg = gfc_evaluate_now (arg, &se->pre); arg2 = gfc_evaluate_now (arg2, &se->pre); - tmp = build (RDIV_EXPR, type, arg, arg2); + tmp = build2 (RDIV_EXPR, type, arg, arg2); /* Test if the value is too large to handle sensibly. */ gfc_set_model_kind (expr->ts.kind); mpfr_init (huge); n = gfc_validate_kind (BT_INTEGER, expr->ts.kind); mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE); test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind); - test2 = build (LT_EXPR, boolean_type_node, tmp, test); + test2 = build2 (LT_EXPR, boolean_type_node, tmp, test); mpfr_neg (huge, huge, GFC_RND_MODE); test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind); - test = build (GT_EXPR, boolean_type_node, tmp, test); - test2 = build (TRUTH_AND_EXPR, boolean_type_node, test, test2); + test = build2 (GT_EXPR, boolean_type_node, tmp, test); + test2 = build2 (TRUTH_AND_EXPR, boolean_type_node, test, test2); itype = gfc_get_int_type (expr->ts.kind); tmp = build_fix_expr (&se->pre, tmp, itype, FIX_TRUNC_EXPR); tmp = convert (type, tmp); - tmp = build (COND_EXPR, type, test2, tmp, arg); - tmp = build (MULT_EXPR, type, tmp, arg2); - se->expr = build (MINUS_EXPR, type, arg, tmp); + tmp = build3 (COND_EXPR, type, test2, tmp, arg); + tmp = build2 (MULT_EXPR, type, tmp, arg2); + se->expr = build2 (MINUS_EXPR, type, arg, tmp); mpfr_clear (huge); break; @@ -830,16 +831,16 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo) { zero = gfc_build_const (type, integer_zero_node); /* Build !(A > 0 .xor. P > 0). */ - test = build (GT_EXPR, boolean_type_node, arg, zero); - test2 = build (GT_EXPR, boolean_type_node, arg2, zero); - test = build (TRUTH_XOR_EXPR, boolean_type_node, test, test2); + test = build2 (GT_EXPR, boolean_type_node, arg, zero); + test2 = build2 (GT_EXPR, boolean_type_node, arg2, zero); + test = build2 (TRUTH_XOR_EXPR, boolean_type_node, test, test2); test = build1 (TRUTH_NOT_EXPR, boolean_type_node, test); /* Build (A == 0) .or. !(A > 0 .xor. P > 0). */ - test2 = build (EQ_EXPR, boolean_type_node, arg, zero); - test = build (TRUTH_OR_EXPR, boolean_type_node, test, test2); + test2 = build2 (EQ_EXPR, boolean_type_node, arg, zero); + test = build2 (TRUTH_OR_EXPR, boolean_type_node, test, test2); - se->expr = build (COND_EXPR, type, test, se->expr, - build (PLUS_EXPR, type, se->expr, arg2)); + se->expr = build3 (COND_EXPR, type, test, se->expr, + build2 (PLUS_EXPR, type, se->expr, arg2)); } } @@ -860,12 +861,12 @@ gfc_conv_intrinsic_dim (gfc_se * se, gfc_expr * expr) arg = TREE_VALUE (arg); type = TREE_TYPE (arg); - val = build (MINUS_EXPR, type, arg, arg2); + val = build2 (MINUS_EXPR, type, arg, arg2); val = gfc_evaluate_now (val, &se->pre); zero = gfc_build_const (type, integer_zero_node); - tmp = build (LE_EXPR, boolean_type_node, val, zero); - se->expr = build (COND_EXPR, type, tmp, zero, val); + tmp = build2 (LE_EXPR, boolean_type_node, val, zero); + se->expr = build3 (COND_EXPR, type, tmp, zero, val); } @@ -910,11 +911,11 @@ gfc_conv_intrinsic_sign (gfc_se * se, gfc_expr * expr) type = TREE_TYPE (arg); zero = gfc_build_const (type, integer_zero_node); - testa = fold (build (GE_EXPR, boolean_type_node, arg, zero)); - testb = fold (build (GE_EXPR, boolean_type_node, arg2, zero)); - tmp = fold (build (TRUTH_XOR_EXPR, boolean_type_node, testa, testb)); - se->expr = fold (build (COND_EXPR, type, tmp, - build1 (NEGATE_EXPR, type, arg), arg)); + testa = fold (build2 (GE_EXPR, boolean_type_node, arg, zero)); + testb = fold (build2 (GE_EXPR, boolean_type_node, arg2, zero)); + tmp = fold (build2 (TRUTH_XOR_EXPR, boolean_type_node, testa, testb)); + se->expr = fold (build3 (COND_EXPR, type, tmp, + build1 (NEGATE_EXPR, type, arg), arg)); } @@ -949,7 +950,7 @@ gfc_conv_intrinsic_dprod (gfc_se * se, gfc_expr * expr) type = gfc_typenode_for_spec (&expr->ts); arg = convert (type, arg); arg2 = convert (type, arg2); - se->expr = build (MULT_EXPR, type, arg, arg2); + se->expr = build2 (MULT_EXPR, type, arg, arg2); } @@ -1016,7 +1017,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, int op) limit = gfc_evaluate_now(limit, &se->pre); mvar = gfc_create_var (type, "M"); - elsecase = build_v (MODIFY_EXPR, mvar, limit); + elsecase = build2_v (MODIFY_EXPR, mvar, limit); for (arg = TREE_CHAIN (arg); arg != NULL_TREE; arg = TREE_CHAIN (arg)) { val = TREE_VALUE (arg); @@ -1027,10 +1028,10 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, int op) if (TREE_CODE (val) != VAR_DECL && !TREE_CONSTANT (val)) val = gfc_evaluate_now(val, &se->pre); - thencase = build_v (MODIFY_EXPR, mvar, convert (type, val)); + thencase = build2_v (MODIFY_EXPR, mvar, convert (type, val)); - tmp = build (op, boolean_type_node, val, limit); - tmp = build_v (COND_EXPR, tmp, thencase, elsecase); + tmp = build2 (op, boolean_type_node, val, limit); + tmp = build3_v (COND_EXPR, tmp, thencase, elsecase); gfc_add_expr_to_block (&se->pre, tmp); elsecase = build_empty_stmt (); limit = mvar; @@ -1177,10 +1178,10 @@ gfc_conv_intrinsic_anyall (gfc_se * se, gfc_expr * expr, int op) gfc_conv_expr_val (&arrayse, actual->expr); gfc_add_block_to_block (&body, &arrayse.pre); - tmp = build (op, boolean_type_node, arrayse.expr, - fold_convert (TREE_TYPE (arrayse.expr), - integer_zero_node)); - tmp = build_v (COND_EXPR, tmp, found, build_empty_stmt ()); + tmp = build2 (op, boolean_type_node, arrayse.expr, + fold_convert (TREE_TYPE (arrayse.expr), + integer_zero_node)); + tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); gfc_add_block_to_block (&body, &arrayse.post); @@ -1239,15 +1240,15 @@ gfc_conv_intrinsic_count (gfc_se * se, gfc_expr * expr) /* Generate the loop body. */ gfc_start_scalarized_body (&loop, &body); - tmp = build (PLUS_EXPR, TREE_TYPE (resvar), resvar, - convert (TREE_TYPE (resvar), integer_one_node)); - tmp = build_v (MODIFY_EXPR, resvar, tmp); + tmp = build2 (PLUS_EXPR, TREE_TYPE (resvar), resvar, + convert (TREE_TYPE (resvar), integer_one_node)); + tmp = build2_v (MODIFY_EXPR, resvar, tmp); gfc_init_se (&arrayse, NULL); gfc_copy_loopinfo_to_se (&arrayse, &loop); arrayse.ss = arrayss; gfc_conv_expr_val (&arrayse, actual->expr); - tmp = build_v (COND_EXPR, arrayse.expr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, arrayse.expr, tmp, build_empty_stmt ()); gfc_add_block_to_block (&body, &arrayse.pre); gfc_add_expr_to_block (&body, tmp); @@ -1350,7 +1351,7 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, int op) gfc_conv_expr_val (&arrayse, arrayexpr); gfc_add_block_to_block (&block, &arrayse.pre); - tmp = build (op, type, resvar, arrayse.expr); + tmp = build2 (op, type, resvar, arrayse.expr); gfc_add_modify_expr (&block, resvar, tmp); gfc_add_block_to_block (&block, &arrayse.post); @@ -1359,7 +1360,7 @@ gfc_conv_intrinsic_arith (gfc_se * se, gfc_expr * expr, int op) /* We enclose the above in if (mask) {...} . */ tmp = gfc_finish_block (&block); - tmp = build_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); } else tmp = gfc_finish_block (&block); @@ -1460,12 +1461,12 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) size we need to return zero. Otherwise use the first element of the array, in case all elements are equal to the limit. ie. pos = (ubound >= lbound) ? lbound, lbound - 1; */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, - loop.from[0], gfc_index_one_node)); - cond = fold (build (GE_EXPR, boolean_type_node, - loop.to[0], loop.from[0])); - tmp = fold (build (COND_EXPR, gfc_array_index_type, cond, - loop.from[0], tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + loop.from[0], gfc_index_one_node)); + cond = fold (build2 (GE_EXPR, boolean_type_node, + loop.to[0], loop.from[0])); + tmp = fold (build3 (COND_EXPR, gfc_array_index_type, cond, + loop.from[0], tmp)); gfc_add_modify_expr (&loop.pre, pos, tmp); gfc_mark_ss_chain_used (arrayss, 1); @@ -1507,8 +1508,8 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) ifbody = gfc_finish_block (&ifblock); /* If it is a more extreme value. */ - tmp = build (op, boolean_type_node, arrayse.expr, limit); - tmp = build_v (COND_EXPR, tmp, ifbody, build_empty_stmt ()); + tmp = build2 (op, boolean_type_node, arrayse.expr, limit); + tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); if (maskss) @@ -1516,7 +1517,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) /* We enclose the above in if (mask) {...}. */ tmp = gfc_finish_block (&block); - tmp = build_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); } else tmp = gfc_finish_block (&block); @@ -1529,9 +1530,9 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op) gfc_cleanup_loop (&loop); /* Return a value in the range 1..SIZE(array). */ - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, loop.from[0], - gfc_index_one_node)); - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, pos, tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, loop.from[0], + gfc_index_one_node)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, pos, tmp)); /* And convert to the required type. */ se->expr = convert (type, tmp); } @@ -1639,20 +1640,18 @@ gfc_conv_intrinsic_minmaxval (gfc_se * se, gfc_expr * expr, int op) gfc_add_block_to_block (&block, &arrayse.pre); /* Assign the value to the limit... */ - ifbody = build_v (MODIFY_EXPR, limit, arrayse.expr); + ifbody = build2_v (MODIFY_EXPR, limit, arrayse.expr); /* If it is a more extreme value. */ - tmp = build (op, boolean_type_node, arrayse.expr, limit); - tmp = build_v (COND_EXPR, tmp, ifbody, build_empty_stmt ()); + tmp = build2 (op, boolean_type_node, arrayse.expr, limit); + tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &arrayse.post); tmp = gfc_finish_block (&block); if (maskss) - { - /* We enclose the above in if (mask) {...}. */ - tmp = build_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); - } + /* We enclose the above in if (mask) {...}. */ + tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); gfc_trans_scalarizing_loops (&loop, &body); @@ -1678,10 +1677,10 @@ gfc_conv_intrinsic_btest (gfc_se * se, gfc_expr * expr) arg = TREE_VALUE (arg); type = TREE_TYPE (arg); - tmp = build (LSHIFT_EXPR, type, convert (type, integer_one_node), arg2); - tmp = build (BIT_AND_EXPR, type, arg, tmp); - tmp = fold (build (NE_EXPR, boolean_type_node, tmp, - convert (type, integer_zero_node))); + tmp = build2 (LSHIFT_EXPR, type, convert (type, integer_one_node), arg2); + tmp = build2 (BIT_AND_EXPR, type, arg, tmp); + tmp = fold (build2 (NE_EXPR, boolean_type_node, tmp, + convert (type, integer_zero_node))); type = gfc_typenode_for_spec (&expr->ts); se->expr = convert (type, tmp); } @@ -1699,7 +1698,7 @@ gfc_conv_intrinsic_bitop (gfc_se * se, gfc_expr * expr, int op) arg = TREE_VALUE (arg); type = TREE_TYPE (arg); - se->expr = fold (build (op, type, arg, arg2)); + se->expr = fold (build2 (op, type, arg, arg2)); } /* Bitwise not. */ @@ -1729,7 +1728,7 @@ gfc_conv_intrinsic_singlebitop (gfc_se * se, gfc_expr * expr, int set) arg = TREE_VALUE (arg); type = TREE_TYPE (arg); - tmp = fold (build (LSHIFT_EXPR, type, + tmp = fold (build2 (LSHIFT_EXPR, type, convert (type, integer_one_node), arg2)); if (set) op = BIT_IOR_EXPR; @@ -1738,7 +1737,7 @@ gfc_conv_intrinsic_singlebitop (gfc_se * se, gfc_expr * expr, int set) op = BIT_AND_EXPR; tmp = fold (build1 (BIT_NOT_EXPR, type, tmp)); } - se->expr = fold (build (op, type, arg, tmp)); + se->expr = fold (build2 (op, type, arg, tmp)); } /* Extract a sequence of bits. @@ -1761,12 +1760,12 @@ gfc_conv_intrinsic_ibits (gfc_se * se, gfc_expr * expr) type = TREE_TYPE (arg); mask = build_int_cst (NULL_TREE, -1); - mask = build (LSHIFT_EXPR, type, mask, arg3); + mask = build2 (LSHIFT_EXPR, type, mask, arg3); mask = build1 (BIT_NOT_EXPR, type, mask); - tmp = build (RSHIFT_EXPR, type, arg, arg2); + tmp = build2 (RSHIFT_EXPR, type, arg, arg2); - se->expr = fold (build (BIT_AND_EXPR, type, tmp, mask)); + se->expr = fold (build2 (BIT_AND_EXPR, type, tmp, mask)); } /* ISHFT (I, SHIFT) = (shift >= 0) ? i << shift : i >> -shift. */ @@ -1786,21 +1785,21 @@ gfc_conv_intrinsic_ishft (gfc_se * se, gfc_expr * expr) type = TREE_TYPE (arg); /* Left shift if positive. */ - lshift = build (LSHIFT_EXPR, type, arg, arg2); + lshift = build2 (LSHIFT_EXPR, type, arg, arg2); /* Right shift if negative. This will perform an arithmetic shift as we are dealing with signed integers. Section 13.5.7 allows this. */ tmp = build1 (NEGATE_EXPR, TREE_TYPE (arg2), arg2); - rshift = build (RSHIFT_EXPR, type, arg, tmp); + rshift = build2 (RSHIFT_EXPR, type, arg, tmp); - tmp = build (GT_EXPR, boolean_type_node, arg2, - convert (TREE_TYPE (arg2), integer_zero_node)); - rshift = build (COND_EXPR, type, tmp, lshift, rshift); + tmp = build2 (GT_EXPR, boolean_type_node, arg2, + convert (TREE_TYPE (arg2), integer_zero_node)); + rshift = build3 (COND_EXPR, type, tmp, lshift, rshift); /* Do nothing if shift == 0. */ - tmp = build (EQ_EXPR, boolean_type_node, arg2, - convert (TREE_TYPE (arg2), integer_zero_node)); - se->expr = build (COND_EXPR, type, tmp, arg, rshift); + tmp = build2 (EQ_EXPR, boolean_type_node, arg2, + convert (TREE_TYPE (arg2), integer_zero_node)); + se->expr = build3 (COND_EXPR, type, tmp, arg, rshift); } /* Circular shift. AKA rotate or barrel shift. */ @@ -1849,20 +1848,20 @@ gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr) type = TREE_TYPE (arg); /* Rotate left if positive. */ - lrot = build (LROTATE_EXPR, type, arg, arg2); + lrot = build2 (LROTATE_EXPR, type, arg, arg2); /* Rotate right if negative. */ tmp = build1 (NEGATE_EXPR, TREE_TYPE (arg2), arg2); - rrot = build (RROTATE_EXPR, type, arg, tmp); + rrot = build2 (RROTATE_EXPR, type, arg, tmp); - tmp = build (GT_EXPR, boolean_type_node, arg2, - convert (TREE_TYPE (arg2), integer_zero_node)); - rrot = build (COND_EXPR, type, tmp, lrot, rrot); + tmp = build2 (GT_EXPR, boolean_type_node, arg2, + convert (TREE_TYPE (arg2), integer_zero_node)); + rrot = build3 (COND_EXPR, type, tmp, lrot, rrot); /* Do nothing if shift == 0. */ - tmp = build (EQ_EXPR, boolean_type_node, arg2, - convert (TREE_TYPE (arg2), integer_zero_node)); - se->expr = build (COND_EXPR, type, tmp, arg, rrot); + tmp = build2 (EQ_EXPR, boolean_type_node, arg2, + convert (TREE_TYPE (arg2), integer_zero_node)); + se->expr = build3 (COND_EXPR, type, tmp, arg, rrot); } /* The length of a character string. */ @@ -1998,7 +1997,7 @@ gfc_conv_intrinsic_merge (gfc_se * se, gfc_expr * expr) mask = TREE_VALUE (arg); type = TREE_TYPE (tsource); - se->expr = fold (build (COND_EXPR, type, mask, tsource, fsource)); + se->expr = fold (build3 (COND_EXPR, type, mask, tsource, fsource)); } @@ -2054,8 +2053,8 @@ gfc_conv_intrinsic_strcmp (gfc_se * se, gfc_expr * expr, int op) se->expr = gfc_build_function_call (gfor_fndecl_compare_string, args); type = gfc_typenode_for_spec (&expr->ts); - se->expr = build (op, type, se->expr, - convert (TREE_TYPE (se->expr), integer_zero_node)); + se->expr = build2 (op, type, se->expr, + convert (TREE_TYPE (se->expr), integer_zero_node)); } /* Generate a call to the adjustl/adjustr library function. */ @@ -2145,8 +2144,8 @@ gfc_conv_allocated (gfc_se *se, gfc_expr *expr) gfc_conv_expr_descriptor (&arg1se, arg1->expr, ss1); tmp = gfc_conv_descriptor_data (arg1se.expr); - tmp = build (NE_EXPR, boolean_type_node, tmp, - fold_convert (TREE_TYPE (tmp), null_pointer_node)); + tmp = build2 (NE_EXPR, boolean_type_node, tmp, + fold_convert (TREE_TYPE (tmp), null_pointer_node)); se->expr = convert (gfc_typenode_for_spec (&expr->ts), tmp); } @@ -2192,8 +2191,8 @@ gfc_conv_associated (gfc_se *se, gfc_expr *expr) gfc_conv_expr_lhs (&arg1se, arg1->expr); tmp2 = gfc_conv_descriptor_data (arg1se.expr); } - tmp = build (NE_EXPR, boolean_type_node, tmp2, - fold_convert (TREE_TYPE (tmp2), null_pointer_node)); + tmp = build2 (NE_EXPR, boolean_type_node, tmp2, + fold_convert (TREE_TYPE (tmp2), null_pointer_node)); se->expr = tmp; } else @@ -2208,7 +2207,7 @@ gfc_conv_associated (gfc_se *se, gfc_expr *expr) gfc_conv_expr (&arg1se, arg1->expr); arg2se.want_pointer = 1; gfc_conv_expr (&arg2se, arg2->expr); - tmp = build (EQ_EXPR, boolean_type_node, arg1se.expr, arg2se.expr); + tmp = build2 (EQ_EXPR, boolean_type_node, arg1se.expr, arg2se.expr); se->expr = tmp; } else @@ -2333,29 +2332,29 @@ void prepare_arg_info (gfc_se * se, gfc_expr * expr, rcs->fdigits = convert (masktype, tmp); wbits = build_int_cst (NULL_TREE, TYPE_PRECISION (rcs->type) - 1); wbits = convert (masktype, wbits); - rcs->edigits = fold (build (MINUS_EXPR, masktype, wbits, tmp)); + rcs->edigits = fold (build2 (MINUS_EXPR, masktype, wbits, tmp)); /* Form masks for exponent/fraction/sign */ one = gfc_build_const (masktype, integer_one_node); - rcs->smask = fold (build (LSHIFT_EXPR, masktype, one, wbits)); - rcs->f1 = fold (build (LSHIFT_EXPR, masktype, one, rcs->fdigits)); - rcs->emask = fold (build (MINUS_EXPR, masktype, rcs->smask, rcs->f1)); - rcs->fmask = fold (build (MINUS_EXPR, masktype, rcs->f1, one)); + rcs->smask = fold (build2 (LSHIFT_EXPR, masktype, one, wbits)); + rcs->f1 = fold (build2 (LSHIFT_EXPR, masktype, one, rcs->fdigits)); + rcs->emask = fold (build2 (MINUS_EXPR, masktype, rcs->smask, rcs->f1)); + rcs->fmask = fold (build2 (MINUS_EXPR, masktype, rcs->f1, one)); /* Form bias. */ - tmp = fold (build (MINUS_EXPR, masktype, rcs->edigits, one)); - tmp = fold (build (LSHIFT_EXPR, masktype, one, tmp)); - rcs->bias = fold (build (MINUS_EXPR, masktype, tmp ,one)); + tmp = fold (build2 (MINUS_EXPR, masktype, rcs->edigits, one)); + tmp = fold (build2 (LSHIFT_EXPR, masktype, one, tmp)); + rcs->bias = fold (build2 (MINUS_EXPR, masktype, tmp ,one)); if (all) { /* exponent, and fraction */ - tmp = build (BIT_AND_EXPR, masktype, arg, rcs->emask); - tmp = build (RSHIFT_EXPR, masktype, tmp, rcs->fdigits); + tmp = build2 (BIT_AND_EXPR, masktype, arg, rcs->emask); + tmp = build2 (RSHIFT_EXPR, masktype, tmp, rcs->fdigits); exponent = gfc_create_var (masktype, "exponent"); gfc_add_modify_expr(&se->pre, exponent, tmp); rcs->expn = exponent; - tmp = build (BIT_AND_EXPR, masktype, arg, rcs->fmask); + tmp = build2 (BIT_AND_EXPR, masktype, arg, rcs->fmask); fraction = gfc_create_var (masktype, "fraction"); gfc_add_modify_expr(&se->pre, fraction, tmp); rcs->frac = fraction; @@ -2409,12 +2408,12 @@ gfc_conv_intrinsic_spacing (gfc_se * se, gfc_expr * expr) fdigits = rcs.fdigits; tiny = rcs.f1; zero = gfc_build_const (masktype, integer_zero_node); - tmp = build (BIT_AND_EXPR, masktype, rcs.emask, arg); - tmp = build (RSHIFT_EXPR, masktype, tmp, fdigits); - tmp = build (MINUS_EXPR, masktype, tmp, fdigits); - cond = build (LE_EXPR, boolean_type_node, tmp, zero); - t1 = build (LSHIFT_EXPR, masktype, tmp, fdigits); - tmp = build (COND_EXPR, masktype, cond, tiny, t1); + tmp = build2 (BIT_AND_EXPR, masktype, rcs.emask, arg); + tmp = build2 (RSHIFT_EXPR, masktype, tmp, fdigits); + tmp = build2 (MINUS_EXPR, masktype, tmp, fdigits); + cond = build2 (LE_EXPR, boolean_type_node, tmp, zero); + t1 = build2 (LSHIFT_EXPR, masktype, tmp, fdigits); + tmp = build3 (COND_EXPR, masktype, cond, tiny, t1); tmp = build1 (VIEW_CONVERT_EXPR, rcs.type, tmp); se->expr = tmp; @@ -2452,23 +2451,23 @@ gfc_conv_intrinsic_rrspacing (gfc_se * se, gfc_expr * expr) fraction = rcs.frac; one = gfc_build_const (masktype, integer_one_node); zero = gfc_build_const (masktype, integer_zero_node); - t2 = build (PLUS_EXPR, masktype, rcs.edigits, one); + t2 = build2 (PLUS_EXPR, masktype, rcs.edigits, one); t1 = call_builtin_clz (masktype, fraction); - tmp = build (PLUS_EXPR, masktype, t1, one); - tmp = build (LSHIFT_EXPR, masktype, fraction, tmp); - tmp = build (RSHIFT_EXPR, masktype, tmp, t2); - cond = build (EQ_EXPR, boolean_type_node, rcs.expn, zero); - fraction = build (COND_EXPR, masktype, cond, tmp, fraction); + tmp = build2 (PLUS_EXPR, masktype, t1, one); + tmp = build2 (LSHIFT_EXPR, masktype, fraction, tmp); + tmp = build2 (RSHIFT_EXPR, masktype, tmp, t2); + cond = build2 (EQ_EXPR, boolean_type_node, rcs.expn, zero); + fraction = build3 (COND_EXPR, masktype, cond, tmp, fraction); - tmp = build (PLUS_EXPR, masktype, rcs.bias, fdigits); - tmp = build (LSHIFT_EXPR, masktype, tmp, fdigits); - tmp = build (BIT_IOR_EXPR, masktype, tmp, fraction); + tmp = build2 (PLUS_EXPR, masktype, rcs.bias, fdigits); + tmp = build2 (LSHIFT_EXPR, masktype, tmp, fdigits); + tmp = build2 (BIT_IOR_EXPR, masktype, tmp, fraction); - cond2 = build (EQ_EXPR, boolean_type_node, rcs.frac, zero); - cond = build (TRUTH_ANDIF_EXPR, boolean_type_node, cond, cond2); - tmp = build (COND_EXPR, masktype, cond, - convert (masktype, integer_zero_node), tmp); + cond2 = build2 (EQ_EXPR, boolean_type_node, rcs.frac, zero); + cond = build2 (TRUTH_ANDIF_EXPR, boolean_type_node, cond, cond2); + tmp = build3 (COND_EXPR, masktype, cond, + convert (masktype, integer_zero_node), tmp); tmp = build1 (VIEW_CONVERT_EXPR, rcs.type, tmp); se->expr = tmp; @@ -2545,11 +2544,11 @@ gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr) gfc_add_expr_to_block (&se->pre, tmp); /* Free the temporary afterwards, if necessary. */ - cond = build (GT_EXPR, boolean_type_node, len, - convert (TREE_TYPE (len), integer_zero_node)); + cond = build2 (GT_EXPR, boolean_type_node, len, + convert (TREE_TYPE (len), integer_zero_node)); arglist = gfc_chainon_list (NULL_TREE, var); tmp = gfc_build_function_call (gfor_fndecl_internal_free, arglist); - tmp = build_v (COND_EXPR, cond, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&se->post, tmp); se->expr = var; @@ -2574,7 +2573,7 @@ gfc_conv_intrinsic_repeat (gfc_se * se, gfc_expr * expr) len = TREE_VALUE (args); tmp = gfc_advance_chain (args, 2); ncopies = TREE_VALUE (tmp); - len = fold (build (MULT_EXPR, gfc_int4_type_node, len, ncopies)); + len = fold (build2 (MULT_EXPR, gfc_int4_type_node, len, ncopies)); type = gfc_get_character_type (expr->ts.kind, expr->ts.cl); var = gfc_conv_string_tmp (se, build_pointer_type (type), len); @@ -2608,7 +2607,7 @@ gfc_conv_intrinsic_iargc (gfc_se * se, gfc_expr * expr, bool args_only) tmp = fold_convert (type, tmp); if (args_only) - tmp = build (MINUS_EXPR, type, tmp, convert (type, integer_one_node)); + tmp = build2 (MINUS_EXPR, type, tmp, convert (type, integer_one_node)); se->expr = tmp; } diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index 3d04332bd31..2c3c8b6a96d 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -360,7 +360,7 @@ set_parameter_value (stmtblock_t * block, tree var, gfc_expr * e) gfc_conv_expr_type (&se, e, TREE_TYPE (var)); gfc_add_block_to_block (block, &se.pre); - tmp = build (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); gfc_add_modify_expr (block, tmp, se.expr); } @@ -380,7 +380,7 @@ set_parameter_ref (stmtblock_t * block, tree var, gfc_expr * e) gfc_conv_expr_type (&se, e, TREE_TYPE (var)); gfc_add_block_to_block (block, &se.pre); - tmp = build (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); gfc_add_modify_expr (block, tmp, se.expr); } @@ -401,9 +401,9 @@ set_string (stmtblock_t * block, stmtblock_t * postblock, tree var, gfc_init_se (&se, NULL); gfc_conv_expr (&se, e); - io = build (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); - len = build (COMPONENT_REF, TREE_TYPE (var_len), ioparm_var, var_len, - NULL_TREE); + io = build3 (COMPONENT_REF, TREE_TYPE (var), ioparm_var, var, NULL_TREE); + len = build3 (COMPONENT_REF, TREE_TYPE (var_len), ioparm_var, var_len, + NULL_TREE); /* Integer variable assigned a format label. */ if (e->ts.type == BT_INTEGER && e->symtree->n.sym->attr.assign == 1) @@ -411,8 +411,8 @@ set_string (stmtblock_t * block, stmtblock_t * postblock, tree var, msg = gfc_build_string_const (37, "Assigned label is not a format label"); tmp = GFC_DECL_STRING_LEN (se.expr); - tmp = build (LE_EXPR, boolean_type_node, - tmp, convert (TREE_TYPE (tmp), integer_minus_one_node)); + tmp = build2 (LE_EXPR, boolean_type_node, + tmp, convert (TREE_TYPE (tmp), integer_minus_one_node)); gfc_trans_runtime_check (tmp, msg, &se.pre); gfc_add_modify_expr (&se.pre, io, GFC_DECL_ASSIGN_ADDR (se.expr)); gfc_add_modify_expr (&se.pre, len, GFC_DECL_STRING_LEN (se.expr)); @@ -436,7 +436,7 @@ set_flag (stmtblock_t *block, tree var) { tree tmp, type = TREE_TYPE (var); - tmp = build (COMPONENT_REF, type, ioparm_var, var, NULL_TREE); + tmp = build3 (COMPONENT_REF, type, ioparm_var, var, NULL_TREE); gfc_add_modify_expr (block, tmp, convert (type, integer_one_node)); } @@ -458,7 +458,7 @@ add_case (int label_value, gfc_st_label * label, stmtblock_t * body) DECL_CONTEXT (tmp) = current_function_decl; /* And the case itself. */ - tmp = build_v (CASE_LABEL_EXPR, value, NULL_TREE, tmp); + tmp = build3_v (CASE_LABEL_EXPR, value, NULL_TREE, tmp); gfc_add_expr_to_block (body, tmp); /* Jump to the label. */ @@ -498,10 +498,10 @@ io_result (stmtblock_t * block, gfc_st_label * err_label, tmp = gfc_finish_block (&body); - rc = build (COMPONENT_REF, TREE_TYPE (ioparm_library_return), ioparm_var, - ioparm_library_return, NULL_TREE); + rc = build3 (COMPONENT_REF, TREE_TYPE (ioparm_library_return), ioparm_var, + ioparm_library_return, NULL_TREE); - tmp = build_v (SWITCH_EXPR, rc, tmp, NULL_TREE); + tmp = build3_v (SWITCH_EXPR, rc, tmp, NULL_TREE); gfc_add_expr_to_block (block, tmp); } @@ -873,7 +873,8 @@ transfer_namelist_element (stmtblock_t * block, gfc_typespec * ts, tree addr_exp { tree field = c->backend_decl; assert (field && TREE_CODE (field) == FIELD_DECL); - tmp = build (COMPONENT_REF, TREE_TYPE (field), expr, field, NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), + expr, field, NULL_TREE); if (c->dimension) gfc_todo_error ("NAMELIST IO of array in derived type"); @@ -1185,8 +1186,8 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr) field = c->backend_decl; assert (field && TREE_CODE (field) == FIELD_DECL); - tmp = build (COMPONENT_REF, TREE_TYPE (field), expr, field, - NULL_TREE); + tmp = build3 (COMPONENT_REF, TREE_TYPE (field), expr, field, + NULL_TREE); if (c->ts.type == BT_CHARACTER) { diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 3b891072e1e..1df24153fea 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -147,7 +147,7 @@ gfc_trans_goto (gfc_code * code) assign_error = gfc_build_string_const (37, "Assigned label is not a target label"); tmp = GFC_DECL_STRING_LEN (se.expr); - tmp = build (NE_EXPR, boolean_type_node, tmp, integer_minus_one_node); + tmp = build2 (NE_EXPR, boolean_type_node, tmp, integer_minus_one_node); gfc_trans_runtime_check (tmp, assign_error, &se.pre); assigned_goto = GFC_DECL_ASSIGN_ADDR (se.expr); @@ -168,8 +168,8 @@ gfc_trans_goto (gfc_code * code) { tmp = gfc_get_label_decl (code->label); tmp = gfc_build_addr_expr (pvoid_type_node, tmp); - tmp = build (EQ_EXPR, boolean_type_node, tmp, assigned_goto); - tmp = build_v (COND_EXPR, tmp, target, build_empty_stmt ()); + tmp = build2 (EQ_EXPR, boolean_type_node, tmp, assigned_goto); + tmp = build3_v (COND_EXPR, tmp, target, build_empty_stmt ()); gfc_add_expr_to_block (&se.pre, tmp); code = code->block; } @@ -256,7 +256,7 @@ gfc_trans_return (gfc_code * code ATTRIBUTE_UNUSED) gfc_conv_expr (&se, code->expr); - tmp = build (MODIFY_EXPR, TREE_TYPE (result), result, se.expr); + tmp = build2 (MODIFY_EXPR, TREE_TYPE (result), result, se.expr); gfc_add_expr_to_block (&se.pre, tmp); tmp = build1_v (GOTO_EXPR, gfc_get_return_label ()); @@ -414,7 +414,7 @@ gfc_trans_if_1 (gfc_code * code) elsestmt = build_empty_stmt (); /* Build the condition expression and add it to the condition block. */ - stmt = build_v (COND_EXPR, if_se.expr, stmt, elsestmt); + stmt = build3_v (COND_EXPR, if_se.expr, stmt, elsestmt); gfc_add_expr_to_block (&if_se.pre, stmt); @@ -471,13 +471,13 @@ gfc_trans_arithmetic_if (gfc_code * code) branch1 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label)); branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label2)); - tmp = build (LT_EXPR, boolean_type_node, se.expr, zero); - branch1 = build_v (COND_EXPR, tmp, branch1, branch2); + tmp = build2 (LT_EXPR, boolean_type_node, se.expr, zero); + branch1 = build3_v (COND_EXPR, tmp, branch1, branch2); /* if (cond <= 0) take branch1 else take branch2. */ branch2 = build1_v (GOTO_EXPR, gfc_get_label_decl (code->label3)); - tmp = build (LE_EXPR, boolean_type_node, se.expr, zero); - branch1 = build_v (COND_EXPR, tmp, branch1, branch2); + tmp = build2 (LE_EXPR, boolean_type_node, se.expr, zero); + branch1 = build3_v (COND_EXPR, tmp, branch1, branch2); /* Append the COND_EXPR to the evaluation of COND, and return. */ gfc_add_expr_to_block (&se.pre, branch1); @@ -574,9 +574,9 @@ gfc_trans_do (gfc_code * code) /* Initialise loop count. This code is executed before we enter the loop body. We generate: count = (to + step - from) / step. */ - tmp = fold (build (MINUS_EXPR, type, step, from)); - tmp = fold (build (PLUS_EXPR, type, to, tmp)); - tmp = fold (build (TRUNC_DIV_EXPR, type, tmp, step)); + tmp = fold (build2 (MINUS_EXPR, type, step, from)); + tmp = fold (build2 (PLUS_EXPR, type, to, tmp)); + tmp = fold (build2 (TRUNC_DIV_EXPR, type, tmp, step)); count = gfc_create_var (type, "count"); gfc_add_modify_expr (&block, count, tmp); @@ -592,10 +592,10 @@ gfc_trans_do (gfc_code * code) exit_label = gfc_build_label_decl (NULL_TREE); /* Start with the loop condition. Loop until count <= 0. */ - cond = build (LE_EXPR, boolean_type_node, count, integer_zero_node); + cond = build2 (LE_EXPR, boolean_type_node, count, integer_zero_node); tmp = build1_v (GOTO_EXPR, exit_label); TREE_USED (exit_label) = 1; - tmp = build_v (COND_EXPR, cond, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); /* Put these labels where they can be found later. We put the @@ -617,18 +617,18 @@ gfc_trans_do (gfc_code * code) } /* Increment the loop variable. */ - tmp = build (PLUS_EXPR, type, dovar, step); + tmp = build2 (PLUS_EXPR, type, dovar, step); gfc_add_modify_expr (&body, dovar, tmp); /* Decrement the loop count. */ - tmp = build (MINUS_EXPR, type, count, gfc_index_one_node); + tmp = build2 (MINUS_EXPR, type, count, gfc_index_one_node); gfc_add_modify_expr (&body, count, tmp); /* End of loop body. */ tmp = gfc_finish_block (&body); /* The for loop itself. */ - tmp = build_v (LOOP_EXPR, tmp); + tmp = build1_v (LOOP_EXPR, tmp); gfc_add_expr_to_block (&block, tmp); /* Add the exit label. */ @@ -690,7 +690,7 @@ gfc_trans_do_while (gfc_code * code) /* Build "IF (! cond) GOTO exit_label". */ tmp = build1_v (GOTO_EXPR, exit_label); TREE_USED (exit_label) = 1; - tmp = build_v (COND_EXPR, cond.expr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond.expr, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); /* The main body of the loop. */ @@ -709,7 +709,7 @@ gfc_trans_do_while (gfc_code * code) gfc_init_block (&block); /* Build the loop. */ - tmp = build_v (LOOP_EXPR, tmp); + tmp = build1_v (LOOP_EXPR, tmp); gfc_add_expr_to_block (&block, tmp); /* Add the exit label. */ @@ -842,7 +842,7 @@ gfc_trans_integer_select (gfc_code * code) /* Add this case label. Add parameter 'label', make it match GCC backend. */ - tmp = build (CASE_LABEL_EXPR, void_type_node, low, high, label); + tmp = build3 (CASE_LABEL_EXPR, void_type_node, low, high, label); gfc_add_expr_to_block (&body, tmp); } @@ -856,7 +856,7 @@ gfc_trans_integer_select (gfc_code * code) } tmp = gfc_finish_block (&body); - tmp = build_v (SWITCH_EXPR, se.expr, tmp, NULL_TREE); + tmp = build3_v (SWITCH_EXPR, se.expr, tmp, NULL_TREE); gfc_add_expr_to_block (&block, tmp); tmp = build1_v (LABEL_EXPR, end_label); @@ -957,8 +957,8 @@ gfc_trans_logical_select (gfc_code * code) if (f != NULL) false_tree = gfc_trans_code (f->next); - gfc_add_expr_to_block (&block, build_v (COND_EXPR, se.expr, - true_tree, false_tree)); + gfc_add_expr_to_block (&block, build3_v (COND_EXPR, se.expr, + true_tree, false_tree)); } return gfc_finish_block (&block); @@ -1044,14 +1044,14 @@ gfc_trans_character_select (gfc_code *code) { for (d = c->ext.case_list; d; d = d->next) { - tmp = build_v (LABEL_EXPR, labels[d->n]); + tmp = build1_v (LABEL_EXPR, labels[d->n]); gfc_add_expr_to_block (&body, tmp); } tmp = gfc_trans_code (c->next); gfc_add_expr_to_block (&body, tmp); - tmp = build_v (GOTO_EXPR, end_label); + tmp = build1_v (GOTO_EXPR, end_label); gfc_add_expr_to_block (&body, tmp); } @@ -1138,7 +1138,7 @@ gfc_trans_character_select (gfc_code *code) tmp = gfc_finish_block (&body); gfc_add_expr_to_block (&block, tmp); - tmp = build_v (LABEL_EXPR, end_label); + tmp = build1_v (LABEL_EXPR, end_label); gfc_add_expr_to_block (&block, tmp); if (n != 0) @@ -1227,16 +1227,16 @@ gfc_trans_forall_loop (forall_info *forall_tmp, int nvar, tree body, int mask_fl gfc_init_block (&block); /* The exit condition. */ - cond = build (LE_EXPR, boolean_type_node, count, integer_zero_node); + cond = build2 (LE_EXPR, boolean_type_node, count, integer_zero_node); tmp = build1_v (GOTO_EXPR, exit_label); - tmp = build_v (COND_EXPR, cond, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&block, tmp); /* The main loop body. */ gfc_add_expr_to_block (&block, body); /* Increment the loop variable. */ - tmp = build (PLUS_EXPR, TREE_TYPE (var), var, step); + tmp = build2 (PLUS_EXPR, TREE_TYPE (var), var, step); gfc_add_modify_expr (&block, var, tmp); /* Advance to the next mask element. */ @@ -1246,13 +1246,13 @@ gfc_trans_forall_loop (forall_info *forall_tmp, int nvar, tree body, int mask_fl maskindex = forall_tmp->maskindex; if (mask) { - tmp = build (PLUS_EXPR, gfc_array_index_type, - maskindex, gfc_index_one_node); + tmp = build2 (PLUS_EXPR, gfc_array_index_type, + maskindex, gfc_index_one_node); gfc_add_modify_expr (&block, maskindex, tmp); } } /* Decrement the loop counter. */ - tmp = build (MINUS_EXPR, TREE_TYPE (var), count, gfc_index_one_node); + tmp = build2 (MINUS_EXPR, TREE_TYPE (var), count, gfc_index_one_node); gfc_add_modify_expr (&block, count, tmp); body = gfc_finish_block (&block); @@ -1262,13 +1262,13 @@ gfc_trans_forall_loop (forall_info *forall_tmp, int nvar, tree body, int mask_fl gfc_add_modify_expr (&block, var, start); /* Initialize the loop counter. */ - tmp = fold (build (MINUS_EXPR, TREE_TYPE (var), step, start)); - tmp = fold (build (PLUS_EXPR, TREE_TYPE (var), end, tmp)); - tmp = fold (build (TRUNC_DIV_EXPR, TREE_TYPE (var), tmp, step)); + tmp = fold (build2 (MINUS_EXPR, TREE_TYPE (var), step, start)); + tmp = fold (build2 (PLUS_EXPR, TREE_TYPE (var), end, tmp)); + tmp = fold (build2 (TRUNC_DIV_EXPR, TREE_TYPE (var), tmp, step)); gfc_add_modify_expr (&block, count, tmp); /* The loop expression. */ - tmp = build_v (LOOP_EXPR, body); + tmp = build1_v (LOOP_EXPR, body); gfc_add_expr_to_block (&block, tmp); /* The exit label. */ @@ -1321,7 +1321,7 @@ gfc_trans_nested_forall_loop (forall_info * nested_forall_info, tree body, tmp = mask; tmp = gfc_build_array_ref (tmp, maskindex); - body = build_v (COND_EXPR, tmp, body, build_empty_stmt ()); + body = build3_v (COND_EXPR, tmp, body, build_empty_stmt ()); } } nvar = forall_tmp->nvar; @@ -1353,8 +1353,8 @@ gfc_do_allocate (tree bytesize, tree size, tree * pdata, stmtblock_t * pblock, if (INTEGER_CST_P (size)) { - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, size, - gfc_index_one_node)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, size, + gfc_index_one_node)); } else tmp = NULL_TREE; @@ -1422,7 +1422,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree size, gfc_add_block_to_block (&block, &lse.post); /* Increment the count1. */ - tmp = fold (build (PLUS_EXPR, TREE_TYPE (count1), count1, size)); + tmp = fold (build2 (PLUS_EXPR, TREE_TYPE (count1), count1, size)); gfc_add_modify_expr (&block, count1, tmp); tmp = gfc_finish_block (&block); } @@ -1456,8 +1456,8 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree size, /* Form the expression of the temporary. */ if (lss != gfc_ss_terminator) { - index = fold (build (PLUS_EXPR, gfc_array_index_type, - count1, count2)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count1, count2)); rse.expr = gfc_build_array_ref (tmp1, index); } /* Translate expr. */ @@ -1476,25 +1476,25 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree size, while (tmp2) { tmp1 = gfc_build_array_ref (tmp2, count3); - wheremaskexpr = build (TRUTH_AND_EXPR, TREE_TYPE (tmp1), - wheremaskexpr, tmp1); + wheremaskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1), + wheremaskexpr, tmp1); tmp2 = TREE_CHAIN (tmp2); } - tmp = build_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ()); } gfc_add_expr_to_block (&body, tmp); /* Increment count2. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count2, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count2, gfc_index_one_node)); gfc_add_modify_expr (&body, count2, tmp); /* Increment count3. */ if (count3) { - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count3, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count3, gfc_index_one_node)); gfc_add_modify_expr (&body, count3, tmp); } @@ -1505,7 +1505,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree size, gfc_cleanup_loop (&loop1); /* Increment count1. */ - tmp = fold (build (PLUS_EXPR, TREE_TYPE (count1), count1, size)); + tmp = fold (build2 (PLUS_EXPR, TREE_TYPE (count1), count1, size)); gfc_add_modify_expr (&block, count1, tmp); tmp = gfc_finish_block (&block); } @@ -1565,7 +1565,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree size, gfc_conv_expr (&rse, expr2); /* Form the expression of the temporary. */ - index = fold (build (PLUS_EXPR, gfc_array_index_type, count1, count2)); + index = fold (build2 (PLUS_EXPR, gfc_array_index_type, count1, count2)); lse.expr = gfc_build_array_ref (tmp1, index); } @@ -1582,11 +1582,11 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree size, while (tmp2) { tmp1 = gfc_build_array_ref (tmp2, count3); - wheremaskexpr = build (TRUTH_AND_EXPR, TREE_TYPE (tmp1), - wheremaskexpr, tmp1); + wheremaskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1), + wheremaskexpr, tmp1); tmp2 = TREE_CHAIN (tmp2); } - tmp = build_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, wheremaskexpr, tmp, build_empty_stmt ()); } gfc_add_expr_to_block (&body1, tmp); @@ -1598,15 +1598,15 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree size, else { /* Increment count2. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count2, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count2, gfc_index_one_node)); gfc_add_modify_expr (&body1, count2, tmp); /* Increment count3. */ if (count3) { - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count3, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count3, gfc_index_one_node)); gfc_add_modify_expr (&body1, count3, tmp); } @@ -1621,7 +1621,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree size, as tree nodes in SS may not be valid in different scope. */ } /* Increment count1. */ - tmp = fold (build (PLUS_EXPR, TREE_TYPE (count1), count1, size)); + tmp = fold (build2 (PLUS_EXPR, TREE_TYPE (count1), count1, size)); gfc_add_modify_expr (&block, count1, tmp); tmp = gfc_finish_block (&block); @@ -1678,11 +1678,11 @@ compute_inner_temp_size (gfc_expr *expr1, gfc_expr *expr2, /* Figure out how many elements we need. */ for (i = 0; i < loop.dimen; i++) { - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, - gfc_index_one_node, loop.from[i])); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - tmp, loop.to[i])); - size = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, + gfc_index_one_node, loop.from[i])); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + tmp, loop.to[i])); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, size, tmp)); } gfc_add_block_to_block (pblock, &loop.pre); size = gfc_evaluate_now (size, pblock); @@ -1711,8 +1711,8 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size, gfc_start_block (&body); if (nested_forall_info) - tmp = build (PLUS_EXPR, gfc_array_index_type, number, - inner_size); + tmp = build2 (PLUS_EXPR, gfc_array_index_type, number, + inner_size); else tmp = inner_size; gfc_add_modify_expr (&body, number, tmp); @@ -1746,7 +1746,7 @@ allocate_temp_for_forall_nest (forall_info * nested_forall_info, tree type, size = compute_overall_iter_number (nested_forall_info, inner_size, block); unit = TYPE_SIZE_UNIT (type); - bytesize = fold (build (MULT_EXPR, gfc_array_index_type, size, unit)); + bytesize = fold (build2 (MULT_EXPR, gfc_array_index_type, size, unit)); *ptemp1 = NULL; temp1 = gfc_do_allocate (bytesize, size, ptemp1, block, type); @@ -1911,8 +1911,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, gfc_add_block_to_block (&body, &rse.post); /* Increment count. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count, gfc_index_one_node)); gfc_add_modify_expr (&body, count, tmp); tmp = gfc_finish_block (&body); @@ -1956,8 +1956,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, gfc_add_modify_expr (&body, lse.expr, rse.expr); gfc_add_block_to_block (&body, &lse.post); /* Increment count. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count, gfc_index_one_node)); gfc_add_modify_expr (&body, count, tmp); tmp = gfc_finish_block (&body); @@ -2000,8 +2000,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, gfc_add_block_to_block (&body, &lse.post); /* Increment count. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count, gfc_index_one_node)); gfc_add_modify_expr (&body, count, tmp); tmp = gfc_finish_block (&body); @@ -2045,8 +2045,8 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2, gfc_add_block_to_block (&body, &lse.post); /* Increment count. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count, gfc_index_one_node)); gfc_add_modify_expr (&body, count, tmp); tmp = gfc_finish_block (&body); @@ -2223,13 +2223,14 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info) lenvar = NULL_TREE; /* size = (end + step - start) / step. */ - tmp = fold (build (MINUS_EXPR, TREE_TYPE (start[n]), step[n], start[n])); - tmp = fold (build (PLUS_EXPR, TREE_TYPE (end[n]), end[n], tmp)); + tmp = fold (build2 (MINUS_EXPR, TREE_TYPE (start[n]), + step[n], start[n])); + tmp = fold (build2 (PLUS_EXPR, TREE_TYPE (end[n]), end[n], tmp)); - tmp = fold (build (FLOOR_DIV_EXPR, TREE_TYPE (tmp), tmp, step[n])); + tmp = fold (build2 (FLOOR_DIV_EXPR, TREE_TYPE (tmp), tmp, step[n])); tmp = convert (gfc_array_index_type, tmp); - size = fold (build (MULT_EXPR, gfc_array_index_type, size, tmp)); + size = fold (build2 (MULT_EXPR, gfc_array_index_type, size, tmp)); } /* Record the nvar and size of current forall level. */ @@ -2253,8 +2254,8 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info) if (code->expr) { /* Allocate the mask temporary. */ - bytesize = fold (build (MULT_EXPR, gfc_array_index_type, size, - TYPE_SIZE_UNIT (boolean_type_node))); + bytesize = fold (build2 (MULT_EXPR, gfc_array_index_type, size, + TYPE_SIZE_UNIT (boolean_type_node))); mask = gfc_do_allocate (bytesize, size, &pmask, &block, boolean_type_node); @@ -2285,7 +2286,7 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info) gfc_add_modify_expr (&body, tmp, se.expr); /* Advance to the next mask element. */ - tmp = build (PLUS_EXPR, gfc_array_index_type, + tmp = build2 (PLUS_EXPR, gfc_array_index_type, maskindex, gfc_index_one_node); gfc_add_modify_expr (&body, maskindex, tmp); @@ -2536,7 +2537,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info, else { /* Increment count. */ - tmp1 = fold (build (PLUS_EXPR, gfc_array_index_type, count, + tmp1 = fold (build2 (PLUS_EXPR, gfc_array_index_type, count, gfc_index_one_node)); gfc_add_modify_expr (&body1, count, tmp1); @@ -2691,20 +2692,20 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, tree mask, while (tmp) { tmp1 = gfc_build_array_ref (tmp, index); - maskexpr = build (TRUTH_AND_EXPR, TREE_TYPE (tmp1), maskexpr, tmp1); + maskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1), maskexpr, tmp1); tmp = TREE_CHAIN (tmp); } /* Use the scalar assignment as is. */ tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type); - tmp = build_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); if (lss == gfc_ss_terminator) { /* Increment count1. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count1, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count1, gfc_index_one_node)); gfc_add_modify_expr (&body, count1, tmp); /* Use the scalar assignment as is. */ @@ -2721,8 +2722,8 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, tree mask, { /* Increment count1 before finish the main body of a scalarized expression. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count1, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count1, gfc_index_one_node)); gfc_add_modify_expr (&body, count1, tmp); gfc_trans_scalarized_loop_boundary (&loop, &body); @@ -2757,25 +2758,25 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2, tree mask, while (tmp) { tmp1 = gfc_build_array_ref (tmp, index); - maskexpr = build (TRUTH_AND_EXPR, TREE_TYPE (tmp1), maskexpr, - tmp1); + maskexpr = build2 (TRUTH_AND_EXPR, TREE_TYPE (tmp1), + maskexpr, tmp1); tmp = TREE_CHAIN (tmp); } /* Use the scalar assignment as is. */ tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts.type); - tmp = build_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&body, tmp); /* Increment count2. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count2, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count2, gfc_index_one_node)); gfc_add_modify_expr (&body, count2, tmp); } else { /* Increment count1. */ - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, - count1, gfc_index_one_node)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, + count1, gfc_index_one_node)); gfc_add_modify_expr (&body, count1, tmp); } @@ -3073,8 +3074,8 @@ gfc_trans_allocate (gfc_code * code) { tmp = build1_v (GOTO_EXPR, error_label); parm = - build (NE_EXPR, boolean_type_node, stat, integer_zero_node); - tmp = build_v (COND_EXPR, parm, tmp, build_empty_stmt ()); + build2 (NE_EXPR, boolean_type_node, stat, integer_zero_node); + tmp = build3_v (COND_EXPR, parm, tmp, build_empty_stmt ()); gfc_add_expr_to_block (&se.pre, tmp); } } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 6f963159a0a..6fdb84a2645 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -603,8 +603,8 @@ gfc_get_dtype (tree type, int rank) if (size && !INTEGER_CST_P (size)) { tmp = build_int_cst (gfc_array_index_type, GFC_DTYPE_SIZE_SHIFT); - tmp = fold (build (LSHIFT_EXPR, gfc_array_index_type, size, tmp)); - dtype = fold (build (PLUS_EXPR, gfc_array_index_type, tmp, dtype)); + tmp = fold (build2 (LSHIFT_EXPR, gfc_array_index_type, size, tmp)); + dtype = fold (build2 (PLUS_EXPR, gfc_array_index_type, tmp, dtype)); } /* If we don't know the size we leave it as zero. This should never happen for anything that is actually used. */ @@ -836,11 +836,11 @@ gfc_get_array_type_bounds (tree etype, int dimen, tree * lbound, if (upper != NULL_TREE && lower != NULL_TREE && stride != NULL_TREE) { - tmp = fold (build (MINUS_EXPR, gfc_array_index_type, upper, lower)); - tmp = fold (build (PLUS_EXPR, gfc_array_index_type, tmp, - gfc_index_one_node)); + tmp = fold (build2 (MINUS_EXPR, gfc_array_index_type, upper, lower)); + tmp = fold (build2 (PLUS_EXPR, gfc_array_index_type, tmp, + gfc_index_one_node)); stride = - fold (build (MULT_EXPR, gfc_array_index_type, tmp, stride)); + fold (build2 (MULT_EXPR, gfc_array_index_type, tmp, stride)); /* Check the folding worked. */ assert (INTEGER_CST_P (stride)); } diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 16ef85cf780..74bab19735b 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -156,7 +156,7 @@ gfc_add_modify_expr (stmtblock_t * pblock, tree lhs, tree rhs) abort (); #endif - tmp = fold (build_v (MODIFY_EXPR, lhs, rhs)); + tmp = fold (build2_v (MODIFY_EXPR, lhs, rhs)); gfc_add_expr_to_block (pblock, tmp); } @@ -238,7 +238,7 @@ gfc_finish_block (stmtblock_t * stmtblock) if (decl) { block = poplevel (1, 0, 0); - expr = build_v (BIND_EXPR, decl, expr, block); + expr = build3_v (BIND_EXPR, decl, expr, block); } else poplevel (0, 0, 0); @@ -316,7 +316,7 @@ gfc_build_array_ref (tree base, tree offset) if (DECL_P (base)) TREE_ADDRESSABLE (base) = 1; - return build (ARRAY_REF, type, base, offset, NULL_TREE, NULL_TREE); + return build4 (ARRAY_REF, type, base, offset, NULL_TREE, NULL_TREE); } @@ -330,7 +330,8 @@ gfc_build_function_call (tree fndecl, tree arglist) tree call; fn = gfc_build_addr_expr (NULL, fndecl); - call = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fndecl)), fn, arglist, NULL); + call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fndecl)), + fn, arglist, NULL); TREE_SIDE_EFFECTS (call) = 1; return call; @@ -384,7 +385,7 @@ gfc_trans_runtime_check (tree cond, tree msg, stmtblock_t * pblock) tmp = gfc_chainon_list (tmp, integer_zero_node); cond = gfc_build_function_call (built_in_decls[BUILT_IN_EXPECT], tmp); - tmp = build_v (COND_EXPR, cond, body, build_empty_stmt ()); + tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt ()); gfc_add_expr_to_block (pblock, tmp); } } diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 3faf4001b87..b9b467bb33f 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -557,7 +557,10 @@ struct lang_decl GTY(()) /* Build an expression with void type. */ #define build1_v(code, arg) build(code, void_type_node, arg) -#define build_v(code, args...) build(code, void_type_node, args) +#define build2_v(code, arg1, arg2) build2(code, void_type_node, \ + arg1, arg2) +#define build3_v(code, arg1, arg2, arg3) build3(code, void_type_node, \ + arg1, arg2, arg3) /* flag for alternative return labels. */ extern int has_alternate_specifier; /* for caller */ -- 2.30.2