This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Factor unrelated declarations out of tree.h (1/2)


On Thu, Nov 14, 2013 at 12:28 PM, Diego Novillo <dnovillo@google.com> wrote:
> This patch applies the rule that functions defined in FOO.c must be
> declared in FOO.h. One of the worst offenders in the code base is
> tree.h, unsurprisingly.
>
> The first patch contains the actual moves from tree.h into the
> various .h files.  The second patch contains the mechanical
> side-effects of the first one.
>
> This patch creates several new headers: attribs.h calls.h
> fold-const.h gcc-symtab.h print-rtl.h print-tree.h stmt.h
> stor-layout.h stringpool.h tree-nested.h tree-object-size.h
> varasm.h.
>
> Functions in each corresponding .c file got moved to those
> headers and others that already existed. I wanted to make this
> patch as mechanical as possible, so I made no attempt to fix
> problems like having build_addr defined in tree-inline.c. I left
> that for later.
>
> There were some declarations that I could not move out of tree.h
> because of header poisoning. We forbid the inclusion of things
> like expr.h from FE files. While that's a reasonable idea, the FE
> file *still* manage to at expr.c functionality because the
> declarations they want to use were defined in tree.h.
>
> If that functionality is allowed to be accessed from the FEs,
> then I will later move those functions out of expr.c into tree.c.
> I have moved these declarations to the bottom of tree.h so they
> are easy to identify later.
>
> There is a namespace collision with libcpp. The file gcc/symtab.c
> cannot use gcc/symtab.h because the #include command picks up
> libcpp/include/symtab.h first. So I named this file gcc-symtab.h
> for now.
>
> This patch should offer some minimal incremental build advantages
> by reducing the size of tree.h. Changes that would otherwise
> affected tree.h, will now go to other headers which are less
> frequently included.
>
> The cleanup is not complete, but this is already bulky:
>
> - There are some declarations that are still in tree.h that
>   should be moved. Andrew is also modifying those files, so I
>   chose to leave them in tree.h for now.
>
> - Some header files always need another header file. I chose to
>   #include that header in the file. At this stage we want to do
>   the opposite, but this would've added even more bulk to the
>   change, so I left a FIXME marker for the next pass.
>
> I've tested these changes with all the languages and all the
> targets in contrib/config-list.mk. However, I would not be
> surprised if something slipped. Please CC me on any fallout, so I
> can fix it.
>
> I'm doing a final round of testing and will commit once
> everything finishes.
>
>
> 2013-11-14  Diego Novillo  <dnovillo@google.com>
>
>         * tree.h: Include fold-const.h.
>         (aggregate_value_p): Moved to function.h.
>         (alloca_call_p): Moved to calls.h.
>         (allocate_struct_function): Moved to function.h.
>         (apply_tm_attr): Moved to attribs.h.
>         (array_at_struct_end_p): Moved to expr.h.
>         (array_ref_element_size): Moved to tree-dfa.h.
>         (array_ref_low_bound): Moved to tree-dfa.h.
>         (array_ref_up_bound): Moved to tree.h.
>         (assemble_alias): Moved to cgraph.h.
>         (avoid_folding_inline_builtin): Moved to builtins.h.
>         (bit_from_pos): Moved to stor-layout.h.
>         (build_addr): Moved to tree-nested.h.
>         (build_call_expr): Moved to builtins.h.
>         (build_call_expr_loc): Moved to builtins.h.
>         (build_call_expr_loc_array): Moved to builtins.h.
>         (build_call_expr_loc_vec): Moved to builtins.h.
>         (build_duplicate_type): Moved to tree-inline.h.
>         (build_fold_addr_expr): Moved to fold-const.h.
>         (build_fold_addr_expr_with_type): Moved to fold-const.h.
>         (build_fold_addr_expr_with_type_loc): Moved to fold-const.h.
>         (build_fold_indirect_ref): Moved to fold-const.h.
>         (build_fold_indirect_ref_loc): Moved to fold-const.h.
>         (build_personality_function): Moved to tree.h.
>         (build_range_check): Moved to fold-const.h.
>         (build_simple_mem_ref): Moved to fold-const.h.
>         (build_simple_mem_ref_loc): Moved to fold-const.h.
>         (build_string_literal): Moved to builtins.h.
>         (build_tm_abort_call): Moved to trans-mem.h.
>         (builtin_mathfn_code): Moved to builtins.h.
>         (builtin_memset_read_str): Moved to builtins.h.
>         (byte_from_pos): Moved to stor-layout.h.
>         (c_strlen): Moved to builtins.h.
>         (call_expr_flags): Moved to calls.h.
>         (can_move_by_pieces): Moved to expr.h.
>         (categorize_ctor_elements): Moved to expr.h.
>         (change_decl_assembler_name): Moved to gcc-symtab.h.
>         (combine_comparisons): Moved to fold-const.h.
>         (complete_ctor_at_level_p): Moved to tree.h.
>         (component_ref_field_offset): Moved to tree-dfa.h.
>         (compute_builtin_object_size): Moved to tree-object-size.h.
>         (compute_record_mode): Moved to stor-layout.h.
>         (constant_boolean_node): Moved to fold-const.h.
>         (constructor_static_from_elts_p): Moved to varasm.h.
>         (cxx11_attribute_p): Moved to attribs.h.
>         (debug_body): Moved to print-tree.h.
>         (debug_find_tree): Moved to tree-inline.h.
>         (debug_fold_checksum): Moved to fold-const.h.
>         (debug_head): Moved to print-tree.h.
>         (debug_head): Moved to print-tree.h.
>         (debug_raw): Moved to print-tree.h.
>         (debug_tree): Moved to print-tree.h.
>         (debug_vec_tree): Moved to print-tree.h.
>         (debug_verbose): Moved to print-tree.h.
>         (debug_verbose): Moved to print-tree.h.
>         (decl_attributes): Moved to attribs.h.
>         (decl_binds_to_current_def_p): Moved to varasm.h.
>         (decl_default_tls_model): Moved to varasm.h.
>         (decl_replaceable_p): Moved to varasm.h.
>         (div_if_zero_remainder): Moved to fold-const.h.
>         (double_int mem_ref_offset): Moved to fold-const.h.
>         (dump_addr): Moved to print-tree.h.
>         (element_precision): Moved to machmode.h.
>         (expand_dummy_function_end): Moved to function.h.
>         (expand_function_end): Moved to function.h.
>         (expand_function_start): Moved to function.h.
>         (expand_label): Moved to stmt.h.
>         (expr_first): Moved to tree-iterator.h.
>         (expr_last): Moved to tree-iterator.h.
>         (finalize_size_functions): Moved to stor-layout.h.
>         (finish_builtin_struct): Moved to stor-layout.h.
>         (finish_record_layout): Moved to stor-layout.h.
>         (fixup_signed_type): Moved to stor-layout.h.
>         (fixup_unsigned_type): Moved to stor-layout.h.
>         (flags_from_decl_or_type): Moved to calls.h.
>         (fold): Moved to fold-const.h.
>         (fold_abs_const): Moved to fold-const.h.
>         (fold_binary): Moved to fold-const.h.
>         (fold_binary_loc): Moved to fold-const.h.
>         (fold_binary_to_constant): Moved to fold-const.h.
>         (fold_build1): Moved to fold-const.h.
>         (fold_build1_initializer_loc): Moved to fold-const.h.
>         (fold_build1_loc): Moved to fold-const.h.
>         (fold_build1_stat_loc): Moved to fold-const.h.
>         (fold_build2): Moved to fold-const.h.
>         (fold_build2_initializer_loc): Moved to fold-const.h.
>         (fold_build2_loc): Moved to fold-const.h.
>         (fold_build2_stat_loc): Moved to fold-const.h.
>         (fold_build3): Moved to fold-const.h.
>         (fold_build3_loc): Moved to fold-const.h.
>         (fold_build3_stat_loc): Moved to fold-const.h.
>         (fold_build_call_array): Moved to fold-const.h.
>         (fold_build_call_array_initializer): Moved to fold-const.h.
>         (fold_build_call_array_initializer_loc): Moved to fold-const.h.
>         (fold_build_call_array_loc): Moved to fold-const.h.
>         (fold_build_cleanup_point_expr): Moved to fold-const.h.
>         (fold_builtin_call_array): Moved to builtins.h.
>         (fold_builtin_fputs): Moved to builtins.h.
>         (fold_builtin_memory_chk): Moved to builtins.h.
>         (fold_builtin_next_arg): Moved to builtins.h.
>         (fold_builtin_strcpy): Moved to builtins.h.
>         (fold_builtin_strncpy): Moved to builtins.h.
>         (fold_builtin_stxcpy_chk): Moved to builtins.h.
>         (fold_builtin_stxncpy_chk): Moved to builtins.h.
>         (fold_call_expr): Moved to builtins.h.
>         (fold_call_stmt): Moved to builtins.h.
>         (fold_convert): Moved to fold-const.h.
>         (fold_convert_loc): Moved to fold-const.h.
>         (fold_convertible_p): Moved to fold-const.h.
>         (fold_defer_overflow_warnings): Moved to fold-const.h.
>         (fold_deferring_overflow_warnings_p): Moved to fold-const.h.
>         (fold_fma): Moved to fold-const.h.
>         (fold_ignored_result): Moved to fold-const.h.
>         (fold_indirect_ref): Moved to fold-const.h.
>         (fold_indirect_ref_1): Moved to fold-const.h.
>         (fold_indirect_ref_loc): Moved to fold-const.h.
>         (fold_read_from_constant_string): Moved to fold-const.h.
>         (fold_real_zero_addition_p): Moved to fold-const.h.
>         (fold_single_bit_test): Moved to fold-const.h.
>         (fold_strip_sign_ops): Moved to fold-const.h.
>         (fold_ternary): Moved to fold-const.h.
>         (fold_ternary_loc): Moved to fold-const.h.
>         (fold_unary): Moved to tree-data-ref.h.
>         (fold_unary_ignore_overflow): Moved to fold-const.h.
>         (fold_unary_ignore_overflow_loc): Moved to fold-const.h.
>         (fold_unary_loc): Moved to fold-const.h.
>         (fold_unary_to_constant): Moved to fold-const.h.
>         (fold_undefer_and_ignore_overflow_warnings): Moved to fold-const.h.
>         (fold_undefer_overflow_warnings): Moved to fold-const.h.
>         (folding_initializer): Moved to fold-const.h.
>         (force_folding_builtin_constant_p): Moved to builtins.h.
>         (free_temp_slots): Moved to function.h.
>         (generate_setjmp_warnings): Moved to function.h.
>         (get_attribute_name): Moved to attribs.h.
>         (get_identifier): Moved to stringpool.h.
>         (get_identifier_with_length): Moved to stringpool.h.
>         (get_inner_reference): Moved to tree.h.
>         (get_object_alignment): Moved to builtins.h.
>         (get_object_alignment_1): Moved to builtins.h.
>         (get_pointer_alignment): Moved to builtins.h.
>         (get_pointer_alignment_1): Moved to builtins.h.
>         (gimple_alloca_call_p): Moved to calls.h.
>         (gimple_fold_builtin_snprintf_chk): Moved to builtins.h.
>         (gimplify_parameters): Moved to function.h.
>         (highest_pow2_factor): Moved to expr.h.
>         (indent_to): Moved to print-tree.h.
>         (init_attributes): Moved to attribs.h.
>         (init_dummy_function_start): Moved to function.h.
>         (init_function_start): Moved to function.h.
>         (init_inline_once): Moved to tree-inline.h.
>         (init_object_sizes): Moved to tree-object-size.h.
>         (init_temp_slots): Moved to function.h.
>         (init_tree_optimization_optabs): Moved to optabs.h.
>         (initialize_sizetypes): Moved to stor-layout.h.
>         (initializer_constant_valid_for_bitfield_p): Moved to varasm.h.
>         (initializer_constant_valid_p): Moved to varasm.h.
>         (int_const_binop): Moved to fold-const.h.
>         (internal_reference_types): Moved to stor-layout.h.
>         (invert_tree_comparison): Moved to fold-const.h.
>         (invert_truthvalue): Moved to fold-const.h.
>         (invert_truthvalue_loc): Moved to fold-const.h.
>         (is_builtin_fn): Moved to builtins.h.
>         (is_inexpensive_builtin): Moved to builtins.h.
>         (is_simple_builtin): Moved to builtins.h.
>         (is_tm_ending_fndecl): Moved to trans-mem.h.
>         (is_tm_may_cancel_outer): Moved to trans-mem.h.
>         (is_tm_pure): Moved to trans-mem.h.
>         (is_tm_safe): Moved to trans-mem.h.
>         (layout_decl): Moved to stor-layout.h.
>         (layout_type): Moved to stor-layout.h.
>         (lookup_attribute_spec): Moved to attribs.h.
>         (make_accum_type): Moved to stor-layout.h.
>         (make_decl_one_only): Moved to varasm.h.
>         (make_decl_rtl): Moved to tree.h.
>         (make_decl_rtl_for_debug): Moved to varasm.h.
>         (make_fract_type): Moved to stor-layout.h.
>         (make_or_reuse_sat_signed_accum_type): Moved to stor-layout.h.
>         (make_or_reuse_sat_signed_fract_type): Moved to stor-layout.h.
>         (make_or_reuse_sat_unsigned_accum_type): Moved to stor-layout.h.
>         (make_or_reuse_sat_unsigned_fract_type): Moved to stor-layout.h.
>         (make_or_reuse_signed_accum_type): Moved to stor-layout.h.
>         (make_or_reuse_signed_fract_type): Moved to stor-layout.h.
>         (make_or_reuse_unsigned_accum_type): Moved to stor-layout.h.
>         (make_or_reuse_unsigned_fract_type): Moved to stor-layout.h.
>         (make_range): Moved to fold-const.h.
>         (make_range_step): Moved to fold-const.h.
>         (make_sat_signed_accum_type): Moved to stor-layout.h.
>         (make_sat_signed_fract_type): Moved to stor-layout.h.
>         (make_sat_unsigned_accum_type): Moved to stor-layout.h.
>         (make_sat_unsigned_fract_type): Moved to stor-layout.h.
>         (make_signed_accum_type): Moved to stor-layout.h.
>         (make_signed_fract_type): Moved to stor-layout.h.
>         (make_signed_type): Moved to stor-layout.h.
>         (make_unsigned_accum_type): Moved to stor-layout.h.
>         (make_unsigned_fract_type): Moved to stor-layout.h.
>         (make_unsigned_type): Moved to stor-layout.h.
>         (mark_decl_referenced): Moved to varasm.h.
>         (mark_referenced): Moved to varasm.h.
>         (mathfn_built_in): Moved to builtins.h.
>         (may_negate_without_overflow_p): Moved to fold-const.h.
>         (maybe_get_identifier): Moved to stringpool.h.
>         (merge_ranges): Moved to fold-const.h.
>         (merge_weak): Moved to varasm.h.
>         (mode_for_size_tree): Moved to stor-layout.h.
>         (multiple_of_p): Moved to fold-const.h.
>         (must_pass_in_stack_var_size): Moved to calls.h.
>         (must_pass_in_stack_var_size_or_pad): Moved to calls.h.
>         (native_encode_expr): Moved to fold-const.h.
>         (native_interpret_expr): Moved to fold-const.h.
>         (non_lvalue): Moved to fold-const.h.
>         (non_lvalue_loc): Moved to fold-const.h.
>         (normalize_offset): Moved to stor-layout.h.
>         (normalize_rli): Moved to stor-layout.h.
>         (notice_global_symbol): Moved to varasm.h.
>         (omit_one_operand): Moved to fold-const.h.
>         (omit_one_operand_loc): Moved to fold-const.h.
>         (omit_two_operands): Moved to fold-const.h.
>         (omit_two_operands_loc): Moved to fold-const.h.
>         (operand_equal_p): Moved to tree-data-ref.h.
>         (parse_input_constraint): Moved to stmt.h.
>         (parse_output_constraint): Moved to stmt.h.
>         (place_field): Moved to stor-layout.h.
>         (pop_function_context): Moved to function.h.
>         (pop_temp_slots): Moved to function.h.
>         (pos_from_bit): Moved to stor-layout.h.
>         (preserve_temp_slots): Moved to function.h.
>         (print_node): Moved to print-tree.h.
>         (print_node_brief): Moved to print-tree.h.
>         (print_rtl): Moved to rtl.h.
>         (process_pending_assemble_externals): Moved to varasm.h.
>         (ptr_difference_const): Moved to fold-const.h.
>         (push_function_context): Moved to function.h.
>         (push_struct_function): Moved to function.h.
>         (push_temp_slots): Moved to function.h.
>         (record_tm_replacement): Moved to trans-mem.h.
>         (relayout_decl): Moved to stor-layout.h.
>         (resolve_asm_operand_names): Moved to stmt.h.
>         (resolve_unique_section): Moved to varasm.h.
>         (rli_size_so_far): Moved to stor-layout.h.
>         (rli_size_unit_so_far): Moved to stor-layout.h.
>         (round_down): Moved to fold-const.h.
>         (round_down_loc): Moved to fold-const.h.
>         (round_up): Moved to fold-const.h.
>         (round_up_loc): Moved to fold-const.h.
>         (set_builtin_user_assembler_name): Moved to builtins.h.
>         (set_decl_incoming_rtl): Moved to emit-rtl.h.
>         (set_decl_rtl): Moved to tree.h.
>         (set_min_and_max_values_for_integral_type): Moved to stor-layout.h.
>         (set_user_assembler_name): Moved to varasm.h.
>         (setjmp_call_p): Moved to calls.h.
>         (size_binop): Moved to fold-const.h.
>         (size_binop_loc): Moved to fold-const.h.
>         (size_diffop): Moved to fold-const.h.
>         (size_diffop_loc): Moved to fold-const.h.
>         (size_int_kind): Moved to fold-const.h.
>         (stack_protect_epilogue): Moved to function.h.
>         (start_record_layout): Moved to stor-layout.h.
>         (supports_one_only): Moved to varasm.h.
>         (swap_tree_comparison): Moved to fold-const.h.
>         (tm_malloc_replacement): Moved to trans-mem.h.
>         (tree build_fold_addr_expr_loc): Moved to fold-const.h.
>         (tree build_invariant_address): Moved to fold-const.h.
>         (tree_binary_nonnegative_warnv_p): Moved to fold-const.h.
>         (tree_binary_nonzero_warnv_p): Moved to fold-const.h.
>         (tree_call_nonnegative_warnv_p): Moved to fold-const.h.
>         (tree_expr_nonnegative_p): Moved to fold-const.h.
>         (tree_expr_nonnegative_warnv_p): Moved to fold-const.h.
>         (tree_output_constant_def): Moved to varasm.h.
>         (tree_overlaps_hard_reg_set): Moved to stmt.h.
>         (tree_single_nonnegative_warnv_p): Moved to fold-const.h.
>         (tree_single_nonzero_warnv_p): Moved to fold-const.h.
>         (tree_swap_operands_p): Moved to fold-const.h.
>         (tree_unary_nonnegative_warnv_p): Moved to fold-const.h.
>         (tree_unary_nonzero_warnv_p): Moved to fold-const.h.
>         (update_alignment_for_field): Moved to stor-layout.h.
>         (use_register_for_decl): Moved to function.h.
>         (variable_size): Moved to rtl.h.
>         (vector_type_mode): Moved to stor-layout.h.
>         * builtins.h: Corresponding changes.
>         * cgraph.h: Corresponding changes.
>         * emit-rtl.h: Corresponding changes.
>         * expr.h: Corresponding changes.
>         * function.h: Corresponding changes.
>         * optabs.h: Corresponding changes.
>         * trans-mem.h: Corresponding changes.
>         Protect against multiple inclusion.
>         * tree-inline.h: Corresponding changes.
>         * tree-iterator.h: Corresponding changes.
>         * tree-dfa.h: Include expr.h.
>         * tree-ssanames.h: Include stringpool.h.
>         * attribs.h: New file.
>         * calls.h: New file.
>         * fold-const.h: New file.
>         * gcc-symtab.h: New file.
>         * print-rtl.h: New file.
>         * print-tree.h: New file.
>         * stmt.h: New file.
>         * stor-layout.h: New file.
>         * strinpool.h: New file.
>         * tree-nested.h: New file
>         * tree-object-size.h: New file.
>         * varasm.h: New file.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59212

H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]