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]

[RFC] Builtin infrastructure change


This patch touches a bunch of files, but most of the changes are fairly
mechanical.  What this does is change the infrastructure of how machine
independent builtin functions are handled.  At this point, there is no change
to the compiler from a user perspective.  Instead of having two parallel arrays
that have tree pointers for built-in functions:

	built_in_decls
	implicit_built_in_decls

I have replaced these by two macros that call inline functions:

	BUILT_IN_DECLS
	IMPLICIT_BUILT_IN_DECLS

and changed the other parts that want to modify the builtins.  By changing it
to a functional approach instead of an array, we can more easily change the
code underneath.

Assuming there no objections that I can't deal with, the next patch would then
add the support to only dynamically allocate the tree structures for the
builtin functions and the types/attributes as we need them.  So if you never
touch any builtin function, you would not allocate some 600-1,000 tree nodes to
hold all of the declarations that aren't needed.  Now, we still would have the
identifier nodes that have the names.

After this, I hope to modify the powerpc back end to do similar savings, and
then have builtins be enabled and disabled, via the target attribute or pragma.

I have built the full compiler (C, C++, Java, Ada, Fortran, Objective C, and
Objection C++) on the powerpc and did a comparison against an unpatched
compiler and there were no regressions.  I have also built a full x86 compiler
with the changes, but I have not yet done the make check comparison.

Right now, I have not built the other targets (sparc, vms, pa, darwinm and
ia64) where there were changes made.  I would appreciate it if other
maintainers could do a smoke test of the patches.

Any comments?

[gcc]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* tree.h (built_in_decls): Change builtin interface from being an
	array to an inline function for both normal and implicit builtin
	functions.  Change all references to built_in_decls and
	implicit_built_in_decls to the new macros/functions, and poison
	the old names. Make sure 0 is not a legitimate builtin index.
	(implicit_built_in_decls): Ditto.
	(struct built_in_decl_info): Ditto.
	(built_in_info): Ditto.
	(built_in_get_decl): Ditto.
	(built_in_set_decl): Ditto.
	(built_in_copy_decl): Ditto.
	(built_in_no_implicit): Ditto.
	(BUILT_IN_DECLS): Ditto.
	(IMPLICIT_BUILT_IN_DECLS): Ditto.
	* tree-complex.c (expand_complex_libcall): Ditto.
	* tree-loop-distribution.c (generate_memset_zero): Ditto.
	* tree.c (iterative_hash_expr): Ditto.
	(build_common_builtin_nodes): Ditto.
	* builtins.c (built_in_decls): Ditto.
	(implicit_built_in_decls): Ditto.
	(mathfn_built_in_1): Ditto.
	(expand_builtin_cexpi): Ditto.
	(expand_builtin_mempcpy_args): Ditto.
	(expand_builtin_stpcpy): Ditto.
	(gimplify_va_arg_expr): Ditto.
	(expand_builtin_sync_operation): Ditto.
	(build_builtin_expect_predicate): Ditto.
	(fold_builtin_memory_op): Ditto.
	(fold_builtin_strcpy): Ditto.
	(fold_builtin_strncpy): Ditto.
	(fold_builtin_interclass_mathfn): Ditto.
	(fold_builtin_classify): Ditto.
	(fold_builtin_2): Ditto.
	(fold_builtin_strstr): Ditto.
	(fold_builtin_strpbrk): Ditto.
	(fold_builtin_strcat): Ditto.
	(fold_builtin_strncat): Ditto.
	(fold_builtin_strcspn): Ditto.
	(fold_builtin_fputs): Ditto.
	(fold_builtin_sprintf): Ditto.
	(fold_builtin_snprintf): Ditto.
	(expand_builtin_memory_chk): Ditto.
	(fold_builtin_stxcpy_chk): Ditto.
	(fold_builtin_strncpy_chk): Ditto.
	(fold_builtin_strcat_chk): Ditto.
	(fold_builtin_strncat_chk): Ditto.
	(fold_builtin_sprintf_chk_1): Ditto.
	(fold_builtin_printf): Ditto.
	(fold_builtin_fprintf): Ditto.
	(fold_call_stmt): Ditto.
	(set_builtin_user_assembler_name): Ditto.
	* tree-emults.c (emutls_common_1): Ditto.
	(lower_emutls_function_body): Ditto.
	* omp-low.c (scan_omp): Ditto.
	(lower_rec_input_clauses): Ditto.
	(lower_reduction_clauses): Ditto.
	(expand_parallel_call): Ditto.
	(expand_task_call): Ditto.
	(maybe_catch_exception): Ditto.
	(optimize_omp_library_calls): Ditto.
	(expand_omp_for_generic): Ditto.
	(expand_omp_for_static_chunk): Ditto.
	(expand_omp_sections): Ditto.
	(expand_omp_atomic_pipeline): Ditto.
	(expand_omp_atomic_mutex): Ditto.
	(lower_omp_single_simple): Ditto.
	(lower_omp_single_copy): Ditto.
	(lower_omp_single): Ditto.
	(lower_omp_master): Ditto.
	(lower_omp_ordered): Ditto.
	(lower_omp_critical): Ditto.
	* tree-ssa-ccp.c (optimize_stdarg_builtin): Ditto.
	* builtins.def (BUILT_IN_NONE): Ditto.
	* tree-ssa-math-opts.c (execute_optimize_bswap): Ditto.
	* gimple-low.c (lower_function_body): Ditto.
	(lower_builtin_setjmp): Ditto.
	* c-decl.c (finish_decl): Ditto.
	* tree-eh.c (lower_resx): ditto.
	(lower_eh_dispatch): Ditto.
	* function.c (gimplify_parameters): Ditto.
	* c-typeck.c (build_function_call_vec): Ditto.
	* gimplify.c (build_stack_save_restore): Ditto.
	(gimplify_vla_decl): Ditto.
	(gimplify_modify_expr_to_memcpy): Ditto.
	(gimplify_modify_expr_to_memset): Ditto.
	(gimplify_variable_sized_compare): Ditto.
	(gimplify_function_tree): Ditto.
	* calls.c (emit_call_1): Ditto.
	* tree-nested.c (convert_nl_goto_reference): Ditto.
	(convert_tramp_reference_op): Ditto.
	(finalize_nesting_tree_1): Ditto.
	* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Ditto.
	(tree_ssa_prefetch_arrays): Ditto.
	* tree-streamer-in.c (streamer_get_builtin_tree): Ditto.
	* config/sparc/sparc.c (sparc_gimplify_va_arg): Ditto.
	* config/i386/i386.c (ix86_gimplify_va_arg): Ditto.
	(ix86_veclibabi_svml): Ditto.
	(ix86_veclibabi_acml): Ditto.
	* config/vms/vms.c (vms_patch_builtins): Ditto.
	* config/ia64/ia64.c (ia64_init_builtins): Ditto.
	* config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass): Ditto.
	(rs6000_gimplify_va_arg): Ditto.
	(rs6000_init_builtins): Ditto.
	* config/darwin.c (darwin_override_options): Ditto.
	(darwin_patch_builtin): Ditto.
	(darwin_rename_builtins): Ditto.
	* config/pa/pa.c (pa_init_builtins): Ditto.

[gcc/ada]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* gcc-interface/utils.c (def_builtin_1):  Change to use new
	builtin accessor macros instead of refering to the built_in_decls
	and implicit_built_in_decls directly.
	* gcc-interface/trans.c (Exception_Handler_to_gnu_zcx): Ditto.
	(gnat_to_gnu): Ditto.

[gcc/c-family]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* c-common.c (def_builtin_1): Change to use new builtin accessor
	macros instead of refering to the built_in_decls and
	implicit_built_in_decls directly.
	(resolve_overloaded_builtin): Ditto.
	* c-omp.c (c_finish_omp_barrier): Ditto.
	(c_finish_omp_taskwait): Ditto.
	(c_finish_omp_taskyield): Ditto.
	(c_finish_omp_flush): Ditto.

[gcc/fortran]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* trans.c (gfc_call_malloc):  Change to use new builtin accessor
	macros instead of refering to the built_in_decls and
	implicit_built_in_decls directly.
	(gfc_allocate_using_malloc): Ditto.
	(gfc_call_free): Ditto.
	(gfc_deallocate_with_status): Ditto.
	(gfc_deallocate_scalar_with_status): Ditto.
	(gfc_call_realloc): Ditto.
	(gfc_unlikely): Ditto.
	(gfc_likely): Ditto.
	 * f95-lang.c (gfc_define_builtin): Ditto.
	(gfc_init_builtin_functions): Ditto.
	* trans-decl.c (create_main_function): Ditto.
	* trans-intrinsic.c (builtin_decl_for_precision): Ditto.
	(gfc_build_intrinsic_lib_fndecls): Ditto.
	(gfc_conv_intrinsic_minmax): Ditto.
	(gfc_conv_intrinsic_leadz): Ditto.
	(gfc_conv_intrinsic_trailz): Ditto.
	(gfc_conv_intrinsic_popcnt_poppar): Ditto.
	(gfc_conv_intrinsic_isnan): Ditto.
	(gfc_conv_intrinsic_transfer): Ditto.
	(scalar_transfer): Ditto.
	(gfc_conv_intrinsic_repeat): Ditto.

[gcc/java]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* class.c (build_static_field_ref):  Change to use new builtin
	accessor macros instead of refering to the built_in_decls and
	implicit_built_in_decls directly.
	* decl.c (java_init_decl_processing): Ditto.
	* except.c (expand_end_java_handler): Ditto.
	* builtins.c (compareAndSwapInt_builtin): Ditto.
	(compareAndSwapLong_builtin): Ditto.
	(compareAndSwapObject_builtin): Ditto.
	(compareAndSwapObject_builtin): Ditto.
	(putVolatile_builtin): Ditto.
	(getVolatile_builtin): Ditto.
	(define_builtin): Ditto.
	(check_for_builtin): Ditto.
	* expr.c (rewrite_arglist_getcaller): Ditto.
	(expand_java_field_op): Ditto.

[gcc/lto]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* lto-lang.c (def_builtin_1):  Change to use new builtin accessor
	macros instead of refering to the built_in_decls and
	implicit_built_in_decls directly.

[gcc/objc]
2011-09-09  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* objc-next-runtime-abi-01.c (objc_build_exc_ptr): Change to use
	new builtin accessor macros instead of refering to the
	built_in_decls and implicit_built_in_decls directly.
	* objc-next-runtime-abi-02.c (objc_build_exc_ptr): Ditto.
	* objc-gnu-runtime-abi-01.c (objc_build_exc_ptr): Ditto.


-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com	fax +1 (978) 399-6899

Attachment: gcc-power7.patch276b
Description: Text document


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