Commit Graph

494 Commits

Author SHA1 Message Date
Diego Novillo 953ff28998 [multiple changes]
2006-01-18  Richard Henderson  <rth@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>

	* libgomp: New directory.
	* Makefile.def: Add target_module libgomp.
	* Makefile.in: Regenerate.
	* configure.in (target_libraries): Add target-libgomp.
	* configure: Regenerate.


contrib/

2006-01-18  Richard Henderson  <rth@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>

	* gcc_update (files_and_dependencies): Add libgomp files.


gcc/

2006-01-18  Richard Henderson  <rth@redhat.com>
            Aldy Hernandez  <aldyh@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>

	* omp-low.c: New file.
	* c-omp.c: New file.

2006-01-18  Richard Henderson  <rth@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>

	* doc/invoke.texi: Document -fopenmp.
	* tree-dump.h (debug_function): Declare.

	* hooks.c (hook_bool_tree_bool_false): New function.
	(hook_tree_tree_null): Remove.
	(hook_tree_tree_tree_null): New.
	* hooks.h: Update to match.

	* tree-pretty-print.c (debug_tree_chain): New.
	(print_generic_expr): Handle TDF_CHAIN.
	(dump_generic_node): Handle BLOCK.
	Do not abort with incomplete SWITCH_EXPRs.
	Do not dump body of an OpenMP directive if TDF_SLIM is given.
	<case OMP_PARALLEL, OMP_FOR, OMP_SECTIONS>: Don't
	print space after directive name.
	<OMP_FOR>: Handle printing OMP_FOR_PRE_BODY.
	Handle OMP_MASTER and OMP_ORDERED.
	Handle printing of OMP_BODY just in one place, goto
	dump_omp_body in the rest of OMP_* nodes that have
	OMP_BODY.
	Don't handle clause nodes here.  Update omp statements to
	use dump_omp_clauses.
	Handle OMP_SINGLE, OMP_SECTIONS, OMP_SECTION,
	OMP_CLAUSE_ORDERED, OMP_CLAUSE_SCHEDULE, OMP_ATOMIC,
	OMP_CRITICAL, OMP_CLAUSE_NOWAIT, GOMP_CLAUSE_IF,
	GOMP_CLAUSE_NUM_THREADS, GOMP_FOR, GOMP_CLAUSE_SHARED,
	GOMP_CLAUSE_FIRSTPRIVATE, GOMP_CLAUSE_LASTPRIVATE,
	GOMP_CLAUSE_COPYIN and GOMP_CLAUSE_COPYPRIVATE.
	Adjust output for GOMP_PARALLEL.
	(dump_omp_clauses): New.
	(print_declaration): Dump DECL_VALUE_EXPR.
	(op_symbol_1): Split out of op_symbol.
	(dumping_stmts): Remove.  Update all users.

	* cgraph.c (cgraph_analyze_queue): New.
	(cgraph_add_new_function): New.
	* cgraph.h (cgraph_analyze_queue): Declare.
	(cgraph_add_new_function): Declare.
	(cgraph_lower_function): Remove.

	* tree.c (walk_tree): Walk OMP_CLAUSE_CHAIN of OMP_CLAUSE_*
	nodes.  Use switch for all nodes, handle most of IS_EXPR_CODE_CLASS
	and TYPE_P nodes in its default clause.
	(empty_body_p): New.
	(tree_range_check_failed): New.
	(build5_stat): New.

	* tree.h (OMP_CLAUSE_REDUCTION_INIT,
	OMP_CLAUSE_REDUCTION_MERGE,
	OMP_CLAUSE_REDUCTION_PLACEHOLDER,
	OMP_CLAUSE_PRIVATE_DEBUG,
	OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE, OMP_FOR_PRE_BODY,
	OMP_MASTER_BODY, OMP_ORDERED_BODY OMP_BODY,
	OMP_CLAUSES, OMP_CLAUSE_DECL, OMP_CLAUSE_DEFAULT_KIND,
	OMP_CLAUSE_CHAIN, OMP_CLAUSE_OUTER_DECL,
	OMP_CLAUSE_INNER_DECL, OMP_CLAUSE_NUM_THREADS_EXPR,
	OMP_CLAUSE_IF_EXPR, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR,
	OMP_CLAUSE_SCHEDULE_CHUNK_SIZE. OMP_PARALLEL_VAR_INIT,
	OMP_PARALLEL_VAR_REDUC, OMP_FOR_VAR_INIT,
	OMP_FOR_VAR_LAST, OMP_FOR_VAR_REDUC,
	OMP_SECTIONS_VAR_INIT, OMP_SECTIONS_VAR_LAST,
	OMP_SECTIONS_VAR_REDUC, OMP_CLAUSE_REDUCTION_CODE
	OMP_SINGLE_CLAUSES, OMP_SINGLE_BODY,
	OMP_CLAUSE_SCHEDULE_CHUNK_SIZE, OMP_SECTION_BODY,
	OMP_CRITICAL_NAME, OMP_CRITICAL_BODY): New.
	(TREE_RANGE_CHECK): New.
	(empty_body_p): Declare.
	(enum omp_clause_default_kind): New.
	(build_string_literal): Declare.
	(enum omp_clause_schedule_kind, OMP_CLAUSE_SCHEDULE_KIND): New.
	(build5_stat, build5): Declare.

	* tree-pass.h (TDF_CHAIN): Define.
	* tree-pass.h (PROP_gimple_lomp): Define.
	(pass_lower_omp): Declare.

	* diagnostic.h (debug_tree_chain): Declare.

	* builtins.c (get_builtin_sync_mode): Use 0 as last argument to
	mode_for_size.
	(expand_builtin): Handle sync BUILT_IN_*_16 builtins.
	* builtins.c (build_string_literal): Make extern.

	* gcc.c (include_spec_function): New.
	(static_spec_functions): Add it.
	(main): Move load of libgomp.spec ...
	(LINK_COMMAND_SPEC): ... here.
	(link_gomp_spec): New.
	(static_specs): Include it.
	(LINK_COMMAND_SPEC): Add link_gomp.
	(GOMP_SELF_SPECS): New.
	(driver_self_specs): Include it.
	(switch_matches): Don't mark inline.
	(main): Load libgomp.spec.

	* tree-gimple.c (is_gimple_stmt): True for OMP_MASTER,
	OMP_ORDERED, OMP_CRITICAL, OMP_SECTIONS, OMP_SECTION,
	and OMP_SINGLE, OMP_FOR and OMP_PARALLEL.

	* tree-gimple.h (enum omp_parallel): Declare.
	(determine_parallel_type): Declare.
	(omp_firstprivatize_variable): Declare.
	(omp_reduction_init): Declare.
	(diagnose_omp_structured_block_errors): Declare.
	(struct walk_stmt_info): Add want_return_expr.
	(struct walk_stmt_info): Add want_bind_expr, want_locations.
	(find_omp_clause): Declare.
	(insert_field_into_struct): Declare.
	(struct walk_stmt_info): Move from tree-nested.c
	(walk_stmts): Declare.

	* c-cppbuiltin.c (c_cpp_builtins): If -fopenmp, #define _OPENMP
	to 200505.

	* cgraphunit.c (cgraph_lower_function): Make static.
	(cgraph_finalize_pending_functions): New.
	(cgraph_finalize_function): Call it.
	(cgraph_finalize_compilation_unit): Likewise.

	* builtin-types.def (BT_I16, BT_FN_I16_VPTR_I16,
	BT_FN_BOOL_VPTR_I16_I16, BT_FN_I16_VPTR_I16_I16): Add.
	(BT_FN_UINT_UINT): New.
	(DEF_FUNCTION_TYPE_6, DEF_FUNCTION_TYPE_7,
	DEF_FUNCTION_TYPE_VAR_4): Document.
	(BT_PTR_LONG, BT_PTR_PTR, BT_FN_BOOL, BT_FN_INT,
	BT_FN_VOID_PTRPTR, BT_PTR_FN_VOID_PTR,
	BT_FN_BOOL_LONGPTR_LONGPTR, BT_FN_VOID_OMPFN_PTR_UINT,
	BT_FN_VOID_OMPFN_PTR_UINT_UINT,
	BT_FN_BOOL_LONG_LONG_LONG_LONGPTR_LONGPTR,
	BT_FN_BOOL_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR,
	BT_FN_VOID_OMPFN_PTR_UINT_LONG_LONG_LONG,
	BT_FN_VOID_OMPFN_PTR_UINT_LONG_LONG_LONG_LONG): New.

	* builtins.def: Update DEF_BUILTIN comment to include COND argument.
	Move all DEF_SYNC_BUILTIN () and DEF_GOMP_BUILTIN () builtins
	into separate files.
	(DEF_GOMP_BUILTIN): New.
	(BUILT_IN_OMP_GET_THREAD_NUM, BUILT_IN_GOMP_BARRIER,
	BUILT_IN_GOMP_CRITICAL_START, BUILT_IN_GOMP_CRITICAL_END,
	BUILT_IN_GOMP_CRITICAL_NAME_START, BUILT_IN_GOMP_CRITICAL_NAME_END,
	BUILT_IN_GOMP_LOOP_STATIC_START, BUILT_IN_GOMP_LOOP_DYNAMIC_START,
	BUILT_IN_GOMP_LOOP_GUIDED_START, BUILT_IN_GOMP_LOOP_RUNTIME_START,
	BUILT_IN_GOMP_LOOP_ORDERED_STATIC_START,
	BUILT_IN_GOMP_LOOP_ORDERED_DYNAMIC_START,
	BUILT_IN_GOMP_LOOP_ORDERED_GUIDED_START,
	BUILT_IN_GOMP_LOOP_ORDERED_RUNTIME_START,
	BUILT_IN_GOMP_LOOP_STATIC_NEXT, BUILT_IN_GOMP_LOOP_DYNAMIC_NEXT,
	BUILT_IN_GOMP_LOOP_GUIDED_NEXT, BUILT_IN_GOMP_LOOP_RUNTIME_NEXT,
	BUILT_IN_GOMP_LOOP_ORDERED_STATIC_NEXT,
	BUILT_IN_GOMP_LOOP_ORDERED_DYNAMIC_NEXT,
	BUILT_IN_GOMP_LOOP_ORDERED_GUIDED_NEXT,
	BUILT_IN_GOMP_LOOP_ORDERED_RUNTIME_NEXT,
	BUILT_IN_GOMP_PARALLEL_LOOP_STATIC_START,
	BUILT_IN_GOMP_PARALLEL_LOOP_DYNAMIC_START,
	BUILT_IN_GOMP_PARALLEL_LOOP_GUIDED_START,
	BUILT_IN_GOMP_PARALLEL_LOOP_RUNTIME_START,
	BUILT_IN_GOMP_LOOP_END, BUILT_IN_GOMP_LOOP_END_NOWAIT,
	BUILT_IN_GOMP_ORDERED_START, BUILT_IN_GOMP_ORDERED_END,
	BUILT_IN_GOMP_PARALLEL_START, BUILT_IN_GOMP_PARALLEL_END,
	BUILT_IN_GOMP_SECTIONS_START, BUILT_IN_GOMP_SECTIONS_NEXT,
	BUILT_IN_GOMP_PARALLEL_SECTIONS_START, BUILT_IN_GOMP_SECTIONS_END,
	BUILT_IN_GOMP_SECTIONS_END_NOWAIT, BUILT_IN_GOMP_SINGLE_START,
	BUILT_IN_GOMP_SINGLE_COPY_START, BUILT_IN_GOMP_SINGLE_COPY_END): New.
	* sync-builtins.def: New file, moved from builtins.def.
	* omp-builtins.def: New file, moved from builtins.def.

	* c-objc-common.h (LANG_HOOKS_OMP_PREDETERMINED_SHARING): Redefine.

	* gimple-low.c (lower_function_body): Clear data.
	(lower_stmt): Do not handle COMPOUND_EXPR.
	Remove call to print_node_brief.

	* c-tree.h (c_finish_omp_clauses): New prototype.
	(C_DECL_THREADPRIVATE_P): Define.
	(lookup_name_no_remap, c_omp_remap_private): Remove
	(c_begin_omp_parallel, c_finish_omp_parallel): Update.
	(check_for_loop_decls): Update decl.
	(lookup_name_no_remap, c_omp_remap_private): Declare.
	(build_indirect_ref, build_modify_expr, pushdecl,
	pushdecl_top_level): Move to c-common.h.

	* dwarf2out.c (loc_descriptor_from_tree_1): Don't set unsignedp
	before the switch, but just in the 2 places that need it.

	* c-decl.c (diagnose_mismatched_decls): Do not check for
	mismatched thread-local attributes when OLDDECL is marked
	threadprivate and NEWDECL has no thread-local attributes.
	(merge_decls): Merge C_DECL_THREADPRIVATE_P.
	(c_gimple_diagnostics_recursively): Rename from
	c_warn_unused_result_recursively.  Invoke
	diagnose_omp_structured_block_errors.
	(check_for_loop_decls): Return a singular decl found.

	* langhooks.c (lhd_omp_predetermined_sharing): Return
	OMP_CLAUSE_DEFAULT_SHARED for DECL_ARTIFICIAL decls.
	(lhd_omp_firstprivatize_type_sizes): New.
	(lhd_omp_assignment): New.
	(lhd_omp_predetermined_sharing): New.

	* langhooks.h (struct gimplify_omp_ctx): Forward declare.
	(struct lang_hooks_for_types): Add
	omp_firstprivatize_type_sizes, omp_privatize_by_reference,
	omp_predetermined_sharing, omp_disregard_value_expr,
	omp_private_debug_clause, omp_clause_default_ctor,
	omp_clause_copy_ctor, omp_clause_assign_op, omp_clause_dtor.

	(c_finish_omp_clauses): New.
	(c_finish_bc_stmt): Diagnose break within omp for.
	(c_begin_omp_parallel, c_finish_omp_parallel): New.
	(build_unary_op): Return error_mark after reporting
	a readonly_error.
	(build_modify_expr): Likewise.

	* gimplify.c: Include optabs.h and pointer-set.h.
	(enum gimplify_omp_var_data): Declare.
	(struct gimplify_omp_ctx): Declare.
	(struct gimplify_ctx): Add fields prev_context, combined_pre_p
	and combined_ctxp.
	(gimplify_ctxp, gimplify_omp_ctxp): New local variables.
	(push_gimplify_context, pop_gimplify_context): Allow nesting.
	(splay_tree_compare_decl_uid): New.
	(new_omp_context): New.
	(delete_omp_context): New.
	(gimple_add_tmp_var): Call omp_add_variable.
	(gimplify_bind_expr): Likewise.
	(gimplify_var_or_parm_decl): If omp_notice_variable returned
	true, disregard DECL_VALUE_EXPR on the decl if any.
	(gimplify_expr_in_ctx): New.
	(omp_firstprivatize_variable, omp_firstprivatize_type_sizes
	omp_add_variable, omp_notice_variable, omp_is_private
	gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses_1
	gimplify_adjust_omp_clauses, gimplify_omp_parallel
	gimplify_omp_for, gimplify_omp_workshare, goa_lhs_expr_p
	gimplify_omp_atomic_fetch_op, goa_stabilize_expr
	gimplify_omp_atomic_pipeline, gimplify_omp_atomic_mutex
	gimplify_omp_atomic): New.
	(gimplify_expr): Handle OMP_PARALLEL, OMP_FOR, OMP_SECTIONS,
	OMP_SINGLE, OMP_SECTION, OMP_MASTER, OMP_ORDERED,
	OMP_CRITICAL and OMP_ATOMIC.
	(gimplify_body): Verify gimplify_ctxp is empty after gimplification.

	* c-pragma.h (enum pragma_kind): Add
	PRAGMA_OMP_ATOMIC, PRAGMA_OMP_BARRIER,
	PRAGMA_OMP_CRITICAL, PRAGMA_OMP_FLUSH, PRAGMA_OMP_FOR,
	PRAGMA_OMP_MASTER, PRAGMA_OMP_ORDERED,
	PRAGMA_OMP_PARALLEL, PRAGMA_OMP_PARALLEL_FOR,
	PRAGMA_OMP_PARALLEL_SECTIONS, PRAGMA_OMP_SECTION,
	PRAGMA_OMP_SECTIONS, PRAGMA_OMP_SINGLE,
	PRAGMA_OMP_THREADPRIVATE.

	* tree.def (OMP_PARALLEL, OMP_FOR, OMP_SECTIONS,
	OMP_SINGLE, OMP_SECTION, OMP_MASTER, OMP_ORDERED,
	OMP_CRITICAL, OMP_ATOMIC, OMP_CLAUSE_PRIVATE,
	OMP_CLAUSE_SHARED, OMP_CLAUSE_FIRSTPRIVATE,
	OMP_CLAUSE_LASTPRIVATE, OMP_CLAUSE_REDUCTION,
	OMP_CLAUSE_COPYIN, OMP_CLAUSE_COPYPRIVATE,
	OMP_CLAUSE_IF, OMP_CLAUSE_NUM_THREADS,
	OMP_CLAUSE_SCHEDULE, OMP_CLAUSE_NOWAIT,
	OMP_CLAUSE_ORDERED, OMP_CLAUSE_DEFAULT): Define.

	* print-tree.c (print_node): Dump DECL_VALUE_EXPR.

	* tree-ssa-dce.c (find_control_dependence): Do not assume that
	ENTRY_BLOCK_PTR->next_bb == single_succ (ENTRY_BLOCK_PTR).

	* tree-nested.c (convert_call_expr): Call walk_body on OMP_BODY for
	OpenMP directives.
	(struct nesting_info): Add field_map,
	suppress_expansion, debug_var_chain.
	(create_nesting_tree): Initialize them.
	(lookup_field_for_decl): Use field_map.
	(get_nonlocal_debug_decl, get_local_debug_decl): New.
	(convert_local_omp_clauses): New.
	(finalize_nesting_tree_1): Add debug_var_chain to toplevel block.
	(walk_body): Split out of walk_function.
	(convert_nonlocal_omp_clauses, convert_local_omp_clauses): New.
	(convert_nonlocal_reference): Handle omp statements.
	(convert_local_reference): Likewise.
	(unnest_nesting_tree_1): Split out of finalize_nesting_tree_1.
	(unnest_nesting_tree): New.
	(lower_nested_functions): Call it.
	(insert_field_into_struct): Make extern.
	(struct walk_stmt_info): Move to tree-gimple.h.
	(walk_stmts): Make extern.

	* omp-builtins.def: New file.

	* tree-iterator.c (expr_only): Clarify comment.

	* c-common.h (pushdecl_top_level, pushdecl,
	build_modify_expr, build_indirect_ref,
	c_finish_omp_master, c_finish_omp_critical,
	c_finish_omp_ordered, c_finish_omp_barrier,
	c_finish_omp_atomic, c_finish_omp_flush,
	c_finish_omp_for, c_split_parallel_clauses,
	omp_clause_default_kind, c_omp_sharing_predetermined,
	c_omp_remap_decl): Declare.

	* Makefile.in (BUILTINS_DEF): Add omp-builtins.def.
	(OBJS-common): Add omp-low.o.
	(c-omp.o, omp-low.o): Add.
	(gimplify.o): Add dependency on $(OPTABS_H).
	(GTFILES): Add omp-low.c.
	(gt-stringpool.h): Add.

	* tree-cfg.c (set_bb_for_stmt): Do not update the
	block-to-labels map if we are currently expanding to RTL.
	(tree_node_can_be_shared): Remove unnecessary CONSTANT_CLASS_P
	checks.
	Handle IDENTIFIER_NODE.
	(tree_verify_flow_info): Do not ICE when emitting error
	messages about invalid labels.
	(dump_function_to_file): Reset CFUN before emitting the body
	of the function.
	(debug_function): New.

	* passes.c (init_optimization_passes): Schedule
	pass_lower_omp.

	* langhooks-def.h (lhd_omp_predetermined_sharing,
	lhd_omp_assignment, lhd_omp_firstprivatize_type_sizes):
	Declare.
	(LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Use it.
	(LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE,
	LANG_HOOKS_OMP_PREDETERMINED_SHARING,
	LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR,
	LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE,
	LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR,
	LANG_HOOKS_OMP_CLAUSE_COPY_CTOR,
	LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP,
	LANG_HOOKS_OMP_CLAUSE_DTOR): Define.
	(LANG_HOOK_DECLS): Use them.


2006-01-18  Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
	    Richard Henderson  <rth@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>

	* c-parser.c (pragma_omp_clause): Define.
	(c_parser_declaration_or_fndef): Document OpenMP syntax.
	(c_parser_compound_statement): Likewise.
	(c_parser_statement): Likewise.
	(c_parser_pragma): Handle omp pragmas.
	(OMP_FOR_CLAUSE_MASK, OMP_SECTIONS_CLAUSE_MASK,
	OMP_PARALLEL_CLAUSE_MASK, OMP_SINGLE_CLAUSE_MASK): Define.
	(c_parser_omp_clause_name, check_no_duplicate_clause,
	c_parser_omp_variable_list,
	c_parser_omp_var_list_parens, c_parser_omp_clause_copyin,
	c_parser_omp_clause_copyprivate,
	c_parser_omp_clause_default,
	c_parser_omp_clause_firstprivate, c_parser_omp_clause_if,
	c_parser_omp_clause_lastprivate,
	c_parser_omp_clause_nowait,
	c_parser_omp_clause_num_threads,
	c_parser_omp_clause_ordered, c_parser_omp_clause_private,
	c_parser_omp_clause_reduction,
	c_parser_omp_clause_schedule, c_parser_omp_clause_shared,
	c_parser_omp_all_clauses, c_parser_omp_structured_block,
	c_parser_omp_atomic, c_parser_omp_barrier,
	c_parser_omp_critical, c_parser_omp_flush,
	c_parser_omp_for_loop, c_parser_omp_for,
	c_parser_omp_master, c_parser_omp_ordered,
	c_parser_omp_sections_scope, c_parser_omp_sections,
	c_parser_omp_parallel, c_parser_omp_single,
	c_parser_omp_construct, c_parser_omp_threadprivate): New.
	* c-pragma.c (init_pragma): Do omp pragma registration here.
	* c.opt (fopenmp): New flag.


2006-01-18  Eric Christopher  <echristo@apple.com>

	* gcc.c (GOMP_SELF_SPECS): Bracket in #ifndef/#endif.
	* config/darwin.h (GOMP_SELF_SPECS): Define.


testsuite/

2006-01-18  Richard Henderson  <rth@redhat.com>
            Aldy Hernandez  <aldyh@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>
            Diego Novillo  <dnovillo@redhat.com>
            Uros Bizjak  <uros@kss-loka.si>

	* testsuite/gcc.dg/gomp: New directory.

From-SVN: r109902
2006-01-18 14:21:25 -05:00
Richard Guenther 403e54f013 builtins.c (expand_builtin_sincos): New function.
2006-01-13  Richard Guenther  <rguenther@suse.de>

	* builtins.c (expand_builtin_sincos): New function.
	(expand_builtin_mathfn_3): Remove dead code, sin and cos
	do not set errno.
	(expand_builtin): Expand sincos using expand_builtin_sincos.

	* gcc.target/i386/387-9.c: New testcase.

From-SVN: r109664
2006-01-13 11:31:49 +00:00
Adrian Straetling 1387fef3fb builtins.c (get_builtin_sync_mem): New function.
2006-01-03  Adrian Straetling  <straetling@de.ibm.com>

	* gcc/builtins.c (get_builtin_sync_mem): New function.
	(expand_builtin_sync_operation, expand_builtin_compare_and_swap,
	expand_builtin_lock_test_and_set, expand_builtin_lock_release):
	Call get_builtin_sync_mem to generate mem rtx.

From-SVN: r109279
2006-01-03 11:52:29 +00:00
Jakub Jelinek a0274e3e23 backport: builtins.def: Move all DEF_SYNC_BUILTIN to ...
Merge from gomp-branch.
        * builtins.def: Move all DEF_SYNC_BUILTIN to ...
        * sync-builtins.def: ... new file.
        (BUILT_IN_FETCH_AND_ADD_16,
        BUILT_IN_FETCH_AND_SUB_16, BUILT_IN_FETCH_AND_OR_16,
        BUILT_IN_FETCH_AND_AND_16, BUILT_IN_FETCH_AND_XOR_16,
        BUILT_IN_FETCH_AND_NAND_16, BUILT_IN_ADD_AND_FETCH_16,
        BUILT_IN_SUB_AND_FETCH_16, BUILT_IN_OR_AND_FETCH_16,
        BUILT_IN_AND_AND_FETCH_16, BUILT_IN_XOR_AND_FETCH_16,
        BUILT_IN_NAND_AND_FETCH_16, BUILT_IN_BOOL_COMPARE_AND_SWAP_16,
        BUILT_IN_VAL_COMPARE_AND_SWAP_16, BUILT_IN_LOCK_TEST_AND_SET_16,
        BUILT_IN_LOCK_RELEASE_16): New builtins.
        * builtin-types.def (BT_I16, BT_FN_I16_VPTR_I16,
        BT_FN_BOOL_VPTR_I16_I16, BT_FN_I16_VPTR_I16_I16): Add.
        * builtins.c (expand_builtin): Handle sync BUILT_IN_*_16 builtins.
        * c-common.c (enum c_builtin_type): Move to top-level from
        c_common_nodes_and_builtins enum builtin_type.
        (builtin_types): Move from c_common_nodes_and_builtins.
        (def_fn_type): New.
        (c_common_nodes_and_builtins): Use it.
        (def_builtin_1): Check for error_mark_node.
        (sync_resolve_size): Handle also 128 bit sync builtins.
        * Makefile.in (BUILTINS_DEF): New.  Use it instead of builtins.def.

        * config/i386/i386.h (x86_cmpxchg8b, x86_cmpxchg16b): New decls.
        (TARGET_CMPXCHG8B, TARGET_CMPXCHG16B): Define.
        * config/i386/i386.c (x86_cmpxchg8b, x86_cmpxchg16b): New variables.
        * config/i386/sync.md (CASMODE, DCASMODE): New mode macros.
        (doublemodesuffix, DCASHMODE): New mode attrs.
        (sync_compare_and_swap<mode>): Change into expand, use CASMODE
        instead of IMODE, if mode is wider than a word, expand into
        sync_double_compare_and_swap*.
        (*sync_compare_and_swap<mode>): New insn.
        (sync_double_compare_and_swap<mode>): Likewise.
        (*sync_double_compare_and_swapdi_pic): Likewise.
        (sync_compare_and_swap_cc<mode>): Use CASMODE instead of IMODE, if
        mode is wider than a word, expand into
        sync_double_compare_and_swap_cc*.
        (sync_double_compare_and_swap_cc<mode>): New insn.
        (*sync_double_compare_and_swap_ccdi_pic): Likewise.

From-SVN: r108997
2005-12-22 16:43:34 -08:00
Richard Guenther f5a7da0f62 re PR middle-end/24306 (va_arg gets confused when skipping over certain zero-sized types with -msse)
2005-12-20  Richard Guenther  <rguenther@suse.de>

	PR middle-end/24306
	* builtins.c (std_gimplify_va_arg_expr): Do not align
	va frame for zero sized types.
	* config/i386/i386.c (ix86_gimplify_va_arg): Likewise.

        * gcc.target/i386/pr24306.c: New testcase.

From-SVN: r108854
2005-12-20 16:20:27 +00:00
Jon Grimm 9a8ce21f3b target-def.h (TARGET_DECIMAL_FLOAT_SUPPORTED_P): New.
2005-12-16  Jon Grimm  <jgrimm2@us.ibm.com>
	    Janis Johnson  <janis187@us.ibm.com>
	    Ben Elliston  <bje@au.ibm.com>

	* target-def.h (TARGET_DECIMAL_FLOAT_SUPPORTED_P): New.
	(TARGET_INITIALIZER): Add TARGET_DECIMAL_FLOAT_P.
	* target.h (struct gcc_target): Add decimal_float_supported_p.
	* targhooks.c (default_scalar_mode_supported_p): Handle
	MODE_DECIMAL_FLOAT.
	* builtins.def: Add new builtins for 32, 64 and 128 bit variants
	of inf, nan, finite, isinf and isnan.
	* builtin-types.def (BT_DFLOAT32, BT_DFLOAT64, BT_DFLOAT128,
	BT_DFLOAT32_PTR, BT_DFLOAT64_PTR, BT_DFLOAT128_PTR,
	BT_FN_DFLOAT32, BT_FN_DFLOAT64, BT_FN_DFLOAT128,
	BT_FN_INT_DFLOAT32, BT_FN_INT_DFLOAT64, BT_FN_INT_DFLOAT128,
	BT_FN_DFLOAT32_CONST_STRING, BT_FN_DFLOAT64_CONST_STRING,
	BT_FN_DFLOAT32_CONST_STRING, BT_FN_DFLOAT32_DFLOAT32,
	BT_FN_DFLOAT64_DFLOAT64, BT_FN_DFLOAT128_DFLOAT128): New.
	* c-decl.c (declspecs_add_type): Verify combos on type qualifiers.
	Pedwarn if decimal floating point types are used.  Error if
	decimal floating point is not supported by the target.
	(finish_declspecs): Return type from DFP typespec_word.
	* c-typeck.c (c_common_type): Choose the decimal floating point
	type with the greater precision when determining a common type.
	(convert_arguments): Warn if there is a mismatch between argument
	and prototype for decimal float types.  Warn of conversions with
	binary float types and of precision narrowing due to prototype.
	* c-parser.c (reswords): Add _Decimal32, _Decimal64, _Decimal128.
	(c_token_starts_typename): Handle RID_DFLOAT32/64/128.
	(c_token_starts_declspecs): Likewise.
	(c_parser_attributes): Likewise.
	* c-common.h (enum rid): Add new enumeration values RID_DFLOAT32,
	RID_DFLOAT64, RID_DFLOAT128.
	(T_D32, TEX_D32, T_D64, TEX_D64, T_D128, TEX_D128): New macros.
	* c-common.c (c_common_type_for_mode): Handle decimal float modes.
	(shorten_compare): Convert DFP/BFP operands to a common type.
	(c_common_modes_and_builtins): Register built-in decimal float
	types if the target supports them.
	(handle_mode_addtribute): Handle MODE_DECIMAL_FLOAT.
	* builtins.c (fold_builtin_1): Handle 32, 64 and 128 bit cases of
	inf, nan, finite, isinf and isnan builtins.
	* c-cppbuiltin.c (builtin_define_decimal_float_constants): New.
	(builtin_define_float_constants): Assert non-decimal radix.
	(c_cpp_builtins): Register built-in __DEC_EVAL_METHOD__ define.
	Call builtin_define_decimal_float_constants for each type.
	* c-lex.c (interpret_float): Decode decimal float types from CPP_N
	flags.  Use real_from_string3, which can handle binary or decimal
	floats.
	* c-tree.h (enum c_typespec_keyword): Add cts_dfloat32,
	cts_dfloat64, cts_dfloat128.
	* tree.c (build_common_tree_nodes_2): Add decimal float types.
	* tree.h (enum tree_index): Add new enumeration values
	TI_DFLOAT32_TYPE, TI_DFLOAT64_TYPE, TI_DFLOAT128_TYPE,
	TI_DFLOAT32_PTR_TYPE, TI_DFLOAT64_PTR_TYPE, TI_DFLOAT128_PTR_TYPE.
	(dfloat32_type_node): New macro.
	(dfloat64_type_node, dfloat128_type_node): Likewise.
	(dfloat32_ptr_type_node, dfloat64_ptr_type_node): Likewise.
	(dfloat128_ptr_type_node): Likewise.
	* c-pretty-print.c (pp_c_floating_constant): Append 32, 64 and 128
	bit decimal floating point types with "df", "dd" and "dl".
	* c-format.h (enum format_lengths): Add new enumeration values
	FMT_LEN_H, FMT_LEN_D and FMT_LEN_DD.
	* c-format.c (printf_length_specs, scanf_length_specs): Add
	entries for H, D, DD.
	(print_char_table, scan_char_table): Use new entries.
	(asm_fprintf_char_table, gcc_diag_char_table,
	gcc_cdiag_char_table, gcc_cxxdiag_char_table): Adjust for longer
	length arrays.
	* defaults.h (DECIMAL32_TYPE_SIZE): Define.
	(DECIMAL64_TYPE_SIZE): Likewise.
	(DECIMAL128_TYPE_SIZE): Likewise.
	(TARGET_DEC_EVAL_METHOD): Likewise.
	* doc/extend.texi (Decimal Float): New node.
	(Constructing Calls): Document decimal float built-ins.
	* doc/tm.texi: Document TARGET_DECIMAL_FLOAT_SUPPORTED_P hook.
	* Makefile.in (USER_H): Add $(srcdir)/ginclude/decfloat.h.
	* ginclude/decfloat.h: New file.

Co-Authored-By: Ben Elliston <bje@au.ibm.com>
Co-Authored-By: Janis Johnson <janis187@us.ibm.com>

From-SVN: r108629
2005-12-16 17:38:26 +11:00
Kaveh R. Ghazi 625a34391b re PR middle-end/25158 (FAIL: gcc.c-torture/execute/builtins/fprintf.c compilation)
PR middle-end/25158
	* builtins.c (fold_builtin_fputs): Defer check for missing
	replacement functions.

From-SVN: r107762
2005-12-01 02:31:49 +00:00
Volker Reichelt ea6a662747 tree.h (CASE_FLT_FN, [...]): New macros.
* tree.h (CASE_FLT_FN, CASE_INT_FN): New macros.
	* builtins.c (expand_builtin_mathfn): Use them.
	(expand_builtin_mathfn_2): Likewise.
	(expand_builtin_mathfn_3): Likewise.
	(expand_builtin_int_roundingfn): Likewise.
	(expand_builtin): Likewise.
	(integer_valued_real_p): Likewise.
	(fold_builtin_int_roundingfn): Likewise.
	(fold_builtin_bitop): Likewise.
	(fold_builtin_logarithm): Likewise.
	(fold_builtin_1): Likewise.
	* convert.c (convert_to_integer): Likewise.
	* fold-const.c (negate_mathfn_p): Likewise.
	(tree_expr_nonnegative_p): Likewise.

From-SVN: r107733
2005-11-30 19:59:50 +00:00
Kaveh R. Ghazi 000ba23d04 re PR middle-end/20109 (printf optimizations and non-ASCII character sets)
PR middle-end/20109
	PR middle-end/25120
	* builtins.c (init_target_chars): New.
	(expand_builtin_printf, expand_builtin_fprintf,
	expand_builtin_sprintf, fold_builtin_sprintf,
	maybe_emit_sprintf_chk_warning, fold_builtin_sprintf_chk,
	fold_builtin_snprintf_chk, fold_builtin_printf,
	fold_builtin_fprintf): Check for matching format strings using
	the target charset.
	
testsuite:
	* gcc.dg/charset/builtin2.c: New test.

From-SVN: r107652
2005-11-29 05:17:20 +00:00
Kaveh R. Ghazi 7e7b53aa73 re PR middle-end/25022 (failure to transform the unlocked stdio calls)
PR middle-end/25022
	* builtins.c (expand_builtin_printf, expand_builtin_fprintf,
	fold_builtin_fputs, fold_builtin_printf, fold_builtin_fprintf):
	Lookup the explicit replacement functions for any unlocked
	stdio builtin transformations.

testsuite:
	* gcc.c-torture/execute/builtins/fprintf.c,
	gcc.c-torture/execute/builtins/fputs-lib.c,
	gcc.c-torture/execute/builtins/fputs.c,
	gcc.c-torture/execute/builtins/lib/fprintf.c,
	gcc.c-torture/execute/builtins/lib/printf.c,
	gcc.c-torture/execute/builtins/printf.c: Test the unlocked style.

From-SVN: r107535
2005-11-26 01:25:20 +00:00
James E Wilson 817f9ef2e5 Fix spurious warning for strstr (s, "").
* builtins.c (fold_builtin_strstr): Pass s1 through fold_convert before
returning it.
* gcc.dg/builtin-strstr.c: New.

From-SVN: r107206
2005-11-18 18:25:25 -08:00
Andrew Pinski 646c38e94e re PR middle-end/24820 (SEGV in integer_valued_real_p at gcc/builtins.c:6711)
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * testsuite/gcc.dg/pr24820.c: New test.
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * builtins.c (integer_valued_real_p): Add break in
        REAL_CST having TREE_OVERFLOW set.

From-SVN: r106851
2005-11-12 22:18:48 -08:00
Richard Henderson 74395677b7 builtins.c (expand_builtin_synchronize): Build a new-style asm with a memory clobber.
* builtins.c (expand_builtin_synchronize): Build a new-style asm
        with a memory clobber.

From-SVN: r105535
2005-10-17 20:12:55 -07:00
Hans-Peter Nilsson 2de0aa52f5 builtins.c (get_builtin_sync_mode): Make unlimited mode_for_size request.
* builtins.c (get_builtin_sync_mode): Make unlimited
	mode_for_size request.

From-SVN: r105469
2005-10-16 21:30:42 +00:00
Richard Henderson 1e188d1e13 re PR middle-end/23714 (ICE in expand_assignment)
PR 23714
        * builtins.c (expand_builtin_trap): Export.
        * expr.h (expand_builtin_trap): Declare.
        * expr.c (expand_assignment): Emit a trap for integral offsets
        from registers that weren't reduced to bitpos.

        * tree-cfg.c (mark_array_ref_addressable_1): Remove.
        (mark_array_ref_addressable): Remove.
        * tree-flow.h (mark_array_ref_addressable): Remove.
        * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Don't call it.

From-SVN: r105449
2005-10-15 17:07:17 -07:00
Ulrich Weigand baab454a0a re PR middle-end/19382 (ACATS cxb4005 cxb5002 simple To_COBOL/To_Fortran test fails at runtime on s390-linux)
PR ada/19382
	* builtins.c (fold_builtin_memcmp): When constructing the pointer
	type used to access data in the inlined length == 1 case, use
	build_pointer_type_for_mode with CAN_ALIAS_ALL set to true.
	(fold_builtin_strcmp, fold_builtin_strncmp): Likewise.

From-SVN: r104948
2005-10-04 16:14:52 +00:00
Richard Henderson 02ee605c6c builtins.c (get_builtin_sync_mode): New.
* builtins.c (get_builtin_sync_mode): New.
        (expand_builtin_sync_operation): Pass in mode argument.
        (expand_builtin_compare_and_swap): Likewise.
        (expand_builtin_lock_test_and_set): Likewise.
        (expand_builtin_lock_release): Likewise.
        (expand_builtin): Update to match.

From-SVN: r104741
2005-09-28 11:16:54 -07:00
J"orn Rennecke bf877a7649 rtl.h (gen_frame_mem, [...]): Declare.
* rtl.h (gen_frame_mem, gen_tmp_stack_mem): Declare.
	* emit-rtl.c (gen_frame_mem, gen_tmp_stack_mem): New functions.
	* builtins.c (expand_builtin_return_addr): Use gen_frame_mem.

From-SVN: r103917
2005-09-05 17:45:20 +01:00
Adrian Straetling ab17392846 builtins.c: (expand_builtin_strcpy...
2005-08-31  Adrian Straetling  <straetling@de.ibm.com>

	* builtins.c: (expand_builtin_strcpy, expand_builtin_strcat): Change
	arguments, adjust all callers.
	(expand_builtin_strcat): Rewrite to call strcpy instead of mempcpy.

From-SVN: r103661
2005-08-31 07:49:27 +00:00
Jakub Jelinek f28d3046d2 re PR middle-end/23484 (__builtin___memcpy_chk miscompilation)
PR middle-end/23484
	* builtins.c (fold_builtin_memory_chk, fold_builtin_stxcpy_chk,
	fold_builtin_strncpy_chk, fold_builtin_snprintf_chk): If len is
	not constant, but maxlen is, don't set len to maxlen, rather
	set maxlen to len if len is a constant.

	* gcc.c-torture/execute/builtins/pr23484-chk.c: New test.
	* gcc.c-torture/execute/builtins/pr23484-chk-lib.c: New file.

From-SVN: r103594
2005-08-29 10:40:48 +02:00
Jakub Jelinek a6017253cb re PR ada/23593 (5 ACATS compiler SEGV c371002 c371003 c52008b cc51004 cc51b03)
PR ada/23593
	* builtins.c (get_memory_rtx): Don't strip nops
	in between COMPONENT_REFs.

From-SVN: r103578
2005-08-28 13:01:31 +02:00
Jakub Jelinek 435bb2a125 re PR rtl-optimization/23561 (nonoverlapping_memrefs_p returns true even for overlapping memory references)
PR rtl-optimization/23561
	* builtins.c (get_memory_rtx): Add LEN argument.  If MEM_EXPR is
	a COMPONENT_REF, remove all COMPONENT_REF from MEM_EXPR unless
	at most LEN bytes long memory fits into the field.
	(expand_builtin_memcpy, expand_builtin_mempcpy, expand_movstr,
	expand_builtin_strncpy, expand_builtin_memset, expand_builtin_memcmp,
	expand_builtin_strcmp, expand_builtin_strncmp): Adjust callers.

	* gcc.c-torture/execute/20050826-1.c: New test.

From-SVN: r103541
2005-08-27 00:02:44 +02:00
James E Wilson c8f27794b8 Fix uninitialized register read problem.
* builtins.c (expand_builtin_return_addr): Set
current_function_accesses_prior_frames when count != 0.  Use
frame_pointer_rtx when count == 0.
* function.h (struct function): Add accesses_prior_frames field.
(current_function_accesses_prior_frames): Define.
* reload1.c (init_elim_table): Check
current_function_accesses_prior_frames.
* doc/tm.texi (INITIAL_FRAME_ADDRESS_RTX): Update docs.

From-SVN: r103294
2005-08-19 14:16:20 -07:00
Andrew Pinski 7563412918 re PR middle-end/16045 (ICE fold check: original tree changed by fold)
2005-08-18  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/16045
        * builtins.c (fold_builtin): Create a new NOP_EXPR all the time.

From-SVN: r103243
2005-08-17 22:01:43 -07:00
Volker Reichelt 543e2cc3e4 builtins.c (expand_builtin_strcat): Remove superfluous call to fold.
* builtins.c (expand_builtin_strcat): Remove superfluous call to fold.
	(fold_builtin_isdigit): Use fold_buildN.
	(build_function_call_expr): Likewise.
	* c-typeck.c (c_finish_loop): Likewise.

From-SVN: r103154
2005-08-16 12:14:10 +00:00
Volker Reichelt 206048bd41 builtins.c: Fix comment typo(s).
* builtins.c: Fix comment typo(s).
	* genautomata.c: Likewise.
	* gimplify.c: Likewise.
	* tree-dfa.c: Likewise.
	* tree-flow-inline.h: Likewise.
	* tree-into-ssa.c: Likewise.
	* tree-ssa-alias.c: Likewise.
	* tree-ssa-ccp.c: Likewise.
	* tree-ssa-copy.c: Likewise.
	* tree-ssa-dce.c: Likewise.
	* tree-ssa-dom.c: Likewise.
	* tree-ssa-operands.c: Likewise.
	* tree-tailcall.c: Likewise.
	* tree-vectorizer.c: Likewise.
	* tree-vrp.c: Likewise.
	* tree.c: Likewise.

From-SVN: r102491
2005-07-28 16:30:00 +00:00
Adrian Straetling 40c1d5f854 builtins.c: (expand_builtin_memcmp, expand_builtin_strncmp): s/cmpstrsi/cmpstrnsi
2005-07-12  Adrian Straetling  <straetling@de.ibm.com>

	* builtins.c: (expand_builtin_memcmp, expand_builtin_strncmp):
	s/cmpstrsi/cmpstrnsi
	(expand_builtin_strcmp): Rewrite to support both 'cmpstrsi' and
	'cmpstrnsi'.
	* optabs.c: (prepare_cmp_insn): Add availability of 'cmpstrn'.
	(init_optabs): Initialize cmpstrn_optab.
	* optabs.h: (enum insn_code cmpstrn_optab): Declare.
	* genopinit.c: (optabs[]): Add 'cmpstrn' to initialisation.
	* expr.c: (enum insn_code cmpstrn_optab): Declare.
	* config/i386/i386.md: s/cmpstr/cmpstrn
	* config/c4x/c4x.md: s/cmpstr/cmpstrn
	* doc/md.texi: Update documentation.

From-SVN: r101916
2005-07-12 09:20:21 +00:00
Adrian Straetling 57e84f1840 builtins.c: (expand_builtin_memset): Rewrite to support 'set_storage_via_setmem'.
2006-06-28  Adrian Straetling  <straetling@de.ibm.com>

	* builtins.c: (expand_builtin_memset): Rewrite to support
	'set_storage_via_setmem'.
	* expr.c: (enum insn_code setmem_optab): Define.
	(enum insn_code clrmem_optab): Remove.
	(set_storage_via_setmem): New function.
	(clear_storage_via_setmem): Remove.
	(clear_storage): Replace call to "clear_storage_via_clrmem" with
	"set_storage_via_setmem".
	* expr.h: (set_storage_via_setmem): Declare.
	(CLEAR_RATIO): Redefine using HAVE_setmemM.
	* optabs.h: (enum insn_code setmem_optab): Declare.
	(enum insn_code clrmem_optab): Remove.
	* optabs.c: (init_optabs): Initialize setmem_optab.
	(enum insn_code clrmem_optab): Remove.
	* genopinit.c: (otabs): Likewise.
	* doc/md.texi: Document new standard pattern 'setmem'. Remove
	  'clrmem'.
	* config/alpha/alpha.c: (alpha_expand_block_clear): Adjust
	'operands' ordering.
	* config/frv/frv.c: (frv_expand_block_clear): Likewise.
	* config/rs6000/rs6000.c: (expand_block_clear): Likewise.
	* config/alpha/alpha.md: ("clrmemqi", "clrmemdi"): Rename to "setmemM".
	FAIL on operands[2]!=const0_rtx. Adjust 'operands' ordering.
	* config/avr/avr.md: ("clrmemhi"): Likewise.
	* config/frv/frv.md: ("clrmemsi"): Likewise.
	* config/i386/i386.md: ("clrmemsi", "clrmemdi"): Likewise.
	* config/pa/pa.md: ("clrmemsi", "clrmemdi"): Likewise.
	* config/rs6000/rs6000.md: ("clrmemsi"): Likewise.
	* config/s390/s390.md: ("clrmem<mode>"): Likewise.

From-SVN: r101386
2005-06-28 19:56:23 +00:00
Jakub Jelinek 10a0d49571 builtin-attrs.def (DEF_ATTR_FOR_INT): Add for 5 and 6.
* builtin-attrs.def (DEF_ATTR_FOR_INT): Add for 5 and 6.
	(DEF_LIST_INT_INT): Add for 4,0, 4,5, 5,0, 5,6.
	(ATTR_NOTHROW_NONNULL_4, ATTR_NOTHROW_NONNULL_5): Define.
	(ATTR_FORMAT_PRINTF_4_0, ATTR_FORMAT_PRINTF_4_5,
	ATTR_FORMAT_PRINTF_5_0, ATTR_FORMAT_PRINTF_5_6): Define.
	* builtins.c: Include tree-flow.h.
	(expand_builtin_mempcpy, expand_builtin_memmove): Comment fixes.
	(expand_builtin_object_size, expand_builtin_memory_chk,
	maybe_emit_chk_warning, maybe_emit_sprintf_chk_warning,
	compute_object_offset, compute_builtin_object_size,
	fold_builtin_object_size): New functions.
	(expand_builtin): Handle BUILT_IN_OBJECT_SIZE and BUILT_IN_*_CHK.
	(fold_builtin_1): Likewise.  Handle BUILT_IN_{,V}{,F}PRINTF
	and BUILT_IN_{,F}PRINTF_UNLOCKED.
	(fold_builtin_memory_chk, fold_builtin_stxcpy_chk,
	fold_builtin_strncpy_chk, fold_builtin_strcat_chk,
	fold_builtin_strncat_chk, fold_builtin_sprintf_chk,
	fold_builtin_snprintf_chk, fold_builtin_printf, fold_builtin_fprintf):
	New functions.
	* builtins.def (BUILT_IN_OBJECT_SIZE, BUILT_IN_MEMCPY_CHK,
	BUILT_IN_MEMMOVE_CHK, BUILT_IN_MEMPCPY_CHK, BUILT_IN_MEMSET_CHK,
	BUILT_IN_STPCPY_CHK, BUILT_IN_STRCAT_CHK, BUILT_IN_STRCPY_CHK,
	BUILT_IN_STRNCAT_CHK, BUILT_IN_STRNCPY_CHK, BUILT_IN_SNPRINTF_CHK,
	BUILT_IN_SPRINTF_CHK, BUILT_IN_VSNPRINTF_CHK, BUILT_IN_VSPRINTF_CHK,
	BUILT_IN_FPRINTF_CHK, BUILT_IN_PRINTF_CHK, BUILT_IN_VFPRINTF_CHK,
	BUILT_IN_VPRINTF_CHK): New builtins.
	* builtin-types.def (DEF_FUNCTION_TYPE_5, DEF_FUNCTION_TYPE_VAR_4):
	Document.
	(BT_FN_SIZE_CONST_PTR_INT, BT_FN_INT_INT_CONST_STRING_VALIST_ARG,
	BT_FN_PTR_PTR_CONST_PTR_SIZE_SIZE, BT_FN_PTR_PTR_INT_SIZE_SIZE,
	BT_FN_STRING_STRING_CONST_STRING_SIZE_SIZE,
	BT_FN_INT_FILEPTR_INT_CONST_STRING_VALIST_ARG,
	BT_FN_INT_STRING_INT_SIZE_CONST_STRING_VALIST_ARG,
	BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VALIST_ARG,
	BT_FN_INT_INT_CONST_STRING_VAR, BT_FN_INT_FILEPTR_INT_CONST_STRING_VAR,
	BT_FN_INT_STRING_INT_SIZE_CONST_STRING_VAR,
	BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VAR): New types.
	* c-common.c (DEF_FUNCTION_TYPE_5, DEF_FUNCTION_TYPE_6,
	DEF_FUNCTION_TYPE_VAR_4, DEF_FUNCTION_TYPE_VAR_5): Define.
	* Makefile.in (OBJS-common): Add tree-object-size.o.
	(tree-object-size.o): Add dependencies.
	* tree-pass.h (pass_object_sizes): Add.
	* tree-optimize.c (init_tree_optimization_passes): Add
	pass_object_sizes.
	* tree-object-size.c: New file.
	* tree.h (fold_builtin_memory_chk, fold_builtin_stxcpy_chk,
	fold_builtin_strncpy_chk, fold_builtin_snprintf_chk,
	compute_builtin_object_size, init_object_sizes, fini_object_sizes):
	New prototypes.
	* tree-ssa-ccp.c (get_strlen): Rename to ...
	(get_maxval_strlen): ...this function.  Handle also computing of maximum
	string length and maximum integral value.
	(ccp_fold_builtin): Handle BUILT_IN_*_CHK.  Use get_maxval_strlen
	instead of get_strlen.  Pass CALLEE and ARGLIST variables to the
	folding functions instead of computing them again.
	(execute_fold_all_builtins): Retry ccp_fold_builtin if a builtin changed
	into some other builtin.
	* doc/extend.texi (Object Size Checking): Document.

	* gcc.c-torture/execute/builtins/lib/main.c (abort): Add prototype.
	* gcc.c-torture/execute/builtins/lib/strncat.c (strncat): Avoid
	testing uninitialized var.

	* gcc.c-torture/execute/builtins/chk.h: New.
	* gcc.c-torture/execute/builtins/lib/chk.c: New.
	* gcc.c-torture/execute/builtins/memcpy-chk.c: New test.
	* gcc.c-torture/execute/builtins/memcpy-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/memmove-chk.c: New test.
	* gcc.c-torture/execute/builtins/memmove-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/mempcpy-chk.c: New test.
	* gcc.c-torture/execute/builtins/mempcpy-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/memset-chk.c: New test.
	* gcc.c-torture/execute/builtins/memset-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/snprintf-chk.c: New test.
	* gcc.c-torture/execute/builtins/snprintf-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/sprintf-chk.c: New test.
	* gcc.c-torture/execute/builtins/sprintf-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/stpcpy-chk.c: New test.
	* gcc.c-torture/execute/builtins/stpcpy-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/strcat-chk.c: New test.
	* gcc.c-torture/execute/builtins/strcat-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/strcpy-chk.c: New test.
	* gcc.c-torture/execute/builtins/strcpy-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/strncat-chk.c: New test.
	* gcc.c-torture/execute/builtins/strncat-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/strncpy-chk.c: New test.
	* gcc.c-torture/execute/builtins/strncpy-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/vsnprintf-chk.c: New test.
	* gcc.c-torture/execute/builtins/vsnprintf-chk-lib.c: New.
	* gcc.c-torture/execute/builtins/vsprintf-chk.c: New test.
	* gcc.c-torture/execute/builtins/vsprintf-chk-lib.c: New.
	* gcc.dg/builtin-object-size-1.c: New test.
	* gcc.dg/builtin-object-size-2.c: New test.
	* gcc.dg/builtin-object-size-3.c: New test.
	* gcc.dg/builtin-object-size-4.c: New test.
	* gcc.dg/builtin-object-size-5.c: New test.
	* gcc.dg/builtin-stringop-chk-1.c: New test.
	* gcc.dg/builtin-stringop-chk-2.c: New test.
	* gcc.dg/tree-ssa/builtin-fprintf-1.c: New test.
	* gcc.dg/tree-ssa/builtin-fprintf-chk-1.c: New test.
	* gcc.dg/tree-ssa/builtin-printf-1.c: New test.
	* gcc.dg/tree-ssa/builtin-printf-chk-1.c: New test.
	* gcc.dg/tree-ssa/builtin-vfprintf-1.c: New test.
	* gcc.dg/tree-ssa/builtin-vfprintf-chk-1.c: New test.
	* gcc.dg/tree-ssa/builtin-vprintf-1.c: New test.
	* gcc.dg/tree-ssa/builtin-vprintf-chk-1.c: New test.
	* gcc.c-torture/execute/printf-1.c: New test.
	* gcc.c-torture/execute/fprintf-1.c: New test.
	* gcc.c-torture/execute/vprintf-1.c: New test.
	* gcc.c-torture/execute/vfprintf-1.c: New test.
	* gcc.c-torture/execute/printf-chk-1.c: New test.
	* gcc.c-torture/execute/fprintf-chk-1.c: New test.
	* gcc.c-torture/execute/vprintf-chk-1.c: New test.
	* gcc.c-torture/execute/vfprintf-chk-1.c: New test.

From-SVN: r101352
2005-06-27 14:17:39 +02:00
Kazu Hirata 987b67bc55 builtins.c, [...]: Use fold_buildN instead of fold (buildN (...)).
* builtins.c, c-common.c, c-convert.c, c-decl.c, c-typeck.c,
	convert.c, lambda-code.c, predict.c, tree-cfg.c,
	tree-complex.c, tree-data-ref.c, tree-if-conv.c,
	tree-mudflap.c, tree-scalar-evolution.c, tree-ssa-ccp.c,
	tree-ssa-loop-ivcanon.c, tree-ssa-loop-ivopts.c,
	tree-ssa-loop-manip.c, tree-ssa-phiopt.c, tree-ssa-pre.c,
	tree-vect-analyze.c, tree-vect-transform.c, tree-vectorizer.c,
	tree.c: Use fold_buildN instead of fold (buildN (...)).

From-SVN: r101338
2005-06-26 21:21:34 +00:00
Kelley Cook 366ccddb2b Update FSF address.
From-SVN: r101317
2005-06-25 02:02:01 +00:00
Richard Henderson 8f8abce4cf re PR tree-optimization/22035 (complex float comparison broken)
PR tree-opt/22035
        * builtins.c (fold_builtin_complex_mul): Remove.
        (fold_builtin_complex_div): Remove.
        (fold_builtin_1): Don't call them.
        * fold-const.c (fold_complex_add, fold_complex_mult_parts,
        fold_complex_mult, fold_complex_div_parts, fold_complex_div): Remove.
        (fold_binary): Don't call them.  Don't expand complex comparisons to
        elementary comparisons.
        * tree-complex.c (init_dont_simulate_again): Enhance search for
        stmts that require decomposition.
        (complex_visit_stmt): Handle RETURN_EXPR properly.
        (create_components): Handle no referenced variables properly.
        * tree.h (fold_complex_mult_parts): Remove.
        (fold_complex_div_parts): Remove.

From-SVN: r101086
2005-06-16 11:09:34 -07:00
Richard Guenther fb664a2cba re PR middle-end/21595 (__builtin_constant_p(&"Hello"[0]) is true for C but not for C++)
2005-05-17  Richard Guenther  <rguenth@gcc.gnu.org>

	PR middle-end/21595
	* builtins.c (fold_builtin_constant_p): Handle
	&"string cst"[0] as constant.

	* g++.dg/tree-ssa/builtin1.C: New testcase.

From-SVN: r99825
2005-05-17 09:00:03 +00:00
Jakub Jelinek 8148fe656d re PR middle-end/21265 (GCC fails to optimize tail call to memset)
PR middle-end/21265
	* expr.h (enum block_op_methods): Add BLOCK_OP_TAILCALL.
	(clear_storage): Add argument.
	* expr.c (emit_block_move_via_libcall, clear_storage_via_libcall):
	Add tailcall argument, set CALL_EXPR_TAILCALL of the CALL_EXPR to
	tailcall.
	(emit_block_move): Handle BLOCK_OP_TAILCALL method.
	(clear_storage): Add method argument, handle BLOCK_OP_TAILCALL.
	(store_expr, store_constructor): Adjust callers.
	* builtins.c (expand_builtin_memcpy): Pass BLOCK_OP_TAILCALL
	to emit_block_move if CALL_EXPR_TAILCALL (exp).
	(expand_builtin_memmove): Add ORIG_EXP argument, copy
	CALL_EXPR_TAILCALL from ORIG_EXP to the new CALL_EXPR.
	(expand_builtin_bcopy): Replace ARGLIST and TYPE arguments
	with EXP.  Pass EXP to expand_builtin_memmove.
	(expand_builtin_memset): Add ORIG_EXP argument, pass
	BLOCK_OP_TAILCALL to clear_storage if CALL_EXPR_TAILCALL (orig_exp).
	(expand_builtin_bzero): Replace ARGLIST argument with EXP.
	Pass EXP to expand_builtin_memset.
	(expand_builtin_strcmp): Copy CALL_EXPR_TAILCALL from EXP to
	the new CALL_EXPR.
	(expand_builtin_strncmp): Likewise.
	(expand_builtin_printf): Replace ARGLIST argument with EXP.
	Copy CALL_EXPR_TAILCALL from EXP to the new CALL_EXPR.
	(expand_builtin_fprintf): Likewise.
	(expand_builtin): Adjust calls to
	expand_builtin_{memmove,bcopy,memset,bzero,{,f}printf}.

	* gcc.dg/20050503-1.c: New test.

From-SVN: r99187
2005-05-04 00:22:02 +02:00
DJ Delorie d4ee4d2525 diagnostic.c (warning): Accept parameter to classify warning option.
* diagnostic.c (warning): Accept parameter to classify warning option.
(warning0): New, for when a pointer to an error() like function is needed.
* errors.c (warning): Likewise.
* errors.h (warning, warning0): Adjust prototypes.
* toplev.h (warning, warning0): Likewise.

* attribs.c, builtins.c, c-common.c, c-decl.c, c-format.c,
c-gimplify.c, c-lex.c, c-objc-common.c, c-opts.c, c-parser.c,
c-pragma.c, c-typeck.c, calls.c, cgraph.c, coverage.c, emit-rtl.c,
fold-const.c, fortran/trans-decl.c, function.c, gcse.c,
genautomata.c, haifa-sched.c, opts.c, passes.c, regclass.c,
reload1.c, stmt.c, stor-layout.c, toplev.c, tree-cfg.c,
tree-dump.c, tree-inline.c, tree-mudflap.c, tree-optimize.c,
tree-ssa.c, tree.c, varasm.c: Adjust warning() callers.

* config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c,
config/avr/avr.c, config/bfin/bfin.c, config/c4x/c4x-c.c,
config/c4x/c4x.c, config/cris/cris.c, config/darwin-c.c,
config/darwin.c, config/darwin.h, config/h8300/h8300.c,
config/i386/cygming.h, config/i386/djgpp.h, config/i386/i386.c,
config/i386/winnt.c, config/ia64/ia64-c.c, config/ia64/ia64.c,
config/ip2k/ip2k.c, config/m32r/m32r.c, config/m68hc11/m68hc11.c,
config/m68k/m68k.c, config/mcore/mcore.c, config/mips/mips.c,
config/mmix/mmix.c, config/ns32k/ns32k.c, config/pa/pa-hpux11.h,
config/pa/pa.c, config/rs6000/aix43.h, config/rs6000/aix51.h,
config/rs6000/aix52.h, config/rs6000/darwin.h,
config/rs6000/rs6000-c.c, config/rs6000/rs6000.c,
config/s390/s390.c, config/sh/sh.c, config/sh/sh.h,
config/sh/symbian.c, config/sol2-c.c, config/sol2.c,
config/stormy16/stormy16.c, config/v850/v850-c.c,
config/v850/v850.c, config/xtensa/xtensa.c: Adjust warning()
callers.

* ada/misc.c: Adjust warning() callers.

* cp/call.c, cp/class.c, cp/cvt.c, cp/decl.c, cp/decl2.c,
cp/except.c, cp/friend.c, cp/init.c, cp/lex.c, cp/mangle.c,
cp/method.c, cp/name-lookup.c, cp/parser.c, cp/repo.c, cp/rtti.c,
cp/tree.c, cp/typeck.c, cp/typeck2.c: Adjust warning() callers.

* fortran/trans-decl.c: Adjust warning() callers.

* java/class.c, java/decl.c, java/expr.c, java/jcf-io.c,
java/jcf-parse.c, java/jv-scan.c, java/parse.y: Adjust warning()
callers.

* objc/objc-act.c: Adjust warning() callers.

* treelang/parse.y: Adjust warning() callers.

From-SVN: r98633
2005-04-23 17:29:07 -04:00
Nathan Sidwell 535a42b116 builtins.c (gimplify_va_arg_expr): Reword comments to avoid 'abort'.
* builtins.c (gimplify_va_arg_expr): Reword comments to avoid
	'abort'. Use gcc_assert and gcc_unreachable as appropriate.
	* c-format.c (get_constant, decode_format_attr, get_flag_spec,
	find_char_info_specifier_index,
	find_length_info_modifier_index): Likewise.
	* c-typeck.c (composite_type, pop_init_level): Likewise.
	* combine.c (cant_combine_insn_p, try_combine): Likewise.
	* cse.c (cse_insn): Likewise
	* dominance.c (calc_dfs_tree): Likewise
	dwarf2out.c (loc_descriptor_from_tree_1,
	add_abstract_origin_attribute, force_decl_die,
	force_type_die): Likewise
	emit-rtl.c (operand_subword_force): Likewise
	explow.c (hard_function_value): Likewise
	expmed.c (store_bit_field, expand_divmod,
	emit_store_flag_force): Likewise
	expr.c (emit_move_multi_word, store_expr,
	expand_expr_real_1): Likewise
	final.c (this_is_asm_operands, shorten_branches, final_scan_insn,
	output_operand): Likewise
	flow.c (recompute_reg_usage): Likewise
	* function.c (assign_stack_temp_for_type, assign_temp,
	handle_epilogue_set): Likewise
	* genextract.c (main): Likewise
	* gimplify.c (mostly_copy_tree_r, gimplify_return_expr,
	gimplify_modify_expr_rhs, gimplify_expr): Likewise
	* haifa-sched.c (ready_lastpos, ready_remove_first, ready_element,
	ready_remove, rm_line_notes, rm_other_notes,
	schedule_block): Likewise
	mips-tfile.c (copy_object, out_of_bounds): Likewise

From-SVN: r98567
2005-04-22 16:14:55 +00:00
Richard Henderson f12b785df3 builtins.c (expand_builtin_sync_operation): Revert last change.
* builtins.c (expand_builtin_sync_operation): Revert last change.
        * optabs.c (expand_bool_compare_and_swap): Compare vs old value,
        not vs new value.
        (expand_compare_and_swap_loop): Likewise.
        (expand_sync_operation): Remove fallback from NAND to AND; invert
        memory operand when expanding from cmpxchg.
        (expand_sync_fetch_operation): Likewise.
        * doc/extend.texi (Atomic Builtins): Fix docs for nand and
        compare-and-swap.

        * config/alpha/alpha.c (alpha_split_atomic_op): Invert memory operand
        when implementing NAND.  Fix double-add for AFTER.
        * config/alpha/sync.md (sync_nand<I48MODE>): Invert memory operand.
        (sync_old_nand<I48MODE>, sync_new_nand<I48MODE>): Likewise.
        (sync_compare_and_swap<I48MODE>): Fix compare vs zero.  Return old
        memory value.
        (sync_lock_test_and_set<I48MODE>): Remove extra label and last
        memory barrier.

        * config/i386/sync.md (sync_compare_and_swap<IMODE>): Fix pattern
        to return old memory value.
        (sync_compare_and_swap_cc<IMODE>): Likewise.

        * config/ia64/ia64.c (ia64_dependencies_evaluation_hook): Early
        return pre-reload.  Don't consider output or anti dependencies.
        * config/ia64/sync.md (IMODE): New.
        (modesuffix): Add QI and HI.
        (memory_barrier): Simplify expansion.
        (sync_compare_and_swap<IMODE>): Use IMODE, not I48MODE.
        (cmpxchg_acq_<IMODE>): Likewise.
        (sync_lock_test_and_set<IMODE>): Likewise.
        (sync_lock_release<IMODE>): Likewise.

From-SVN: r98436
2005-04-19 21:54:11 -07:00
Richard Henderson e2939e7513 builtins.c (expand_builtin_sync_operation): Fold nand to and for constants.
* builtins.c (expand_builtin_sync_operation): Fold nand to and
        for constants.

From-SVN: r98324
2005-04-18 09:02:14 -07:00
Kazu Hirata 10dcf22182 re PR middle-end/21024 (fold generates a comparison of two operands whose types do not match)
PR middle-end/21024
	* builtins.c (expand_builtin_strcat): Convert the result of
	strlen to the right type.
	* fold-const.c (fold_binary) <PLUS_EXPR>: Use fold_convert to
	avoid creating type mismatches.
	<GE_EXPR>: Pass op0 and op1 to fold_build2 to avoid creating
	type mismatches.

From-SVN: r98244
2005-04-17 01:38:24 +00:00
Richard Henderson 5b5513d00e re PR target/21051 (sync tests ICE on ia64)
PR target/21051
        * builtins.c (expand_builtin) <BUILT_IN_BOOL_COMPARE_AND_SWAP_*>:
        Use the mode of boolean_type_node when the user doesn't provide one.
        * config/ia64/sync.md (sync_lock_release<I48MODE>): Use operand 1.

From-SVN: r98239
2005-04-16 16:19:35 -07:00
Uros Bizjak 1c432a0c34 re PR tree-optimization/21004 (gcc.dg/builtins-53.c fails)
PR tree-optimization/21004
	* convert.c (convert_to_integer): Convert ceilf, ceill, floorf
	and floorl in c99 mode only.
	* builtins.c (expand_builtin_int_roundingfn): Assert that
	fallback_fndecl is not NULL_TREE.

testsuite:

	PR tree-optimization/21004
	* gcc.dg/builtins-53.c: Include builtins-config.h.
	Check floorf, ceilf, floorl and ceill transformations
	only when HAVE_C99_RUNTIME is defined.

From-SVN: r98174
2005-04-15 07:43:56 +02:00
Richard Henderson 48ae6c138c re PR middle-end/14311 (builtins for atomic operations needed)
PR middle-end/14311
	* builtin-types.def (BT_BOOL, BT_VOLATILE_PTR, BT_I1, BT_I2,
	BT_I4, BT_I8, BT_FN_VOID_VPTR, BT_FN_I1_VPTR_I1, BT_FN_I2_VPTR_I2,
	BT_FN_I4_VPTR_I4, BT_FN_I8_VPTR_I8, BT_FN_BOOL_VPTR_I1_I1,
	BT_FN_BOOL_VPTR_I2_I2, BT_FN_BOOL_VPTR_I4_I4, BT_FN_BOOL_VPTR_I8_I8,
	BT_FN_I1_VPTR_I1_I1, BT_FN_I2_VPTR_I2_I2, BT_FN_I4_VPTR_I4_I4,
	BT_FN_I8_VPTR_I8_I8): New.
	* builtins.def (DEF_SYNC_BUILTIN): New.
	(BUILT_IN_FETCH_AND_ADD_N, BUILT_IN_FETCH_AND_ADD_1,
	BUILT_IN_FETCH_AND_ADD_2, BUILT_IN_FETCH_AND_ADD_4,
	BUILT_IN_FETCH_AND_ADD_8, BUILT_IN_FETCH_AND_SUB_N,
	BUILT_IN_FETCH_AND_SUB_1, BUILT_IN_FETCH_AND_SUB_2,
	BUILT_IN_FETCH_AND_SUB_4, BUILT_IN_FETCH_AND_SUB_8,
	BUILT_IN_FETCH_AND_OR_N, BUILT_IN_FETCH_AND_OR_1,
	BUILT_IN_FETCH_AND_OR_2, BUILT_IN_FETCH_AND_OR_4,
	BUILT_IN_FETCH_AND_OR_8, BUILT_IN_FETCH_AND_AND_N,
	BUILT_IN_FETCH_AND_AND_1, BUILT_IN_FETCH_AND_AND_2,
	BUILT_IN_FETCH_AND_AND_4, BUILT_IN_FETCH_AND_AND_8,
	BUILT_IN_FETCH_AND_XOR_N, BUILT_IN_FETCH_AND_XOR_1,
	BUILT_IN_FETCH_AND_XOR_2, BUILT_IN_FETCH_AND_XOR_4,
	BUILT_IN_FETCH_AND_XOR_8, BUILT_IN_FETCH_AND_NAND_N,
	BUILT_IN_FETCH_AND_NAND_1, BUILT_IN_FETCH_AND_NAND_2,
	BUILT_IN_FETCH_AND_NAND_4, BUILT_IN_FETCH_AND_NAND_8,
	BUILT_IN_ADD_AND_FETCH_N, BUILT_IN_ADD_AND_FETCH_1,
	BUILT_IN_ADD_AND_FETCH_2, BUILT_IN_ADD_AND_FETCH_4,
	BUILT_IN_ADD_AND_FETCH_8, BUILT_IN_SUB_AND_FETCH_N,
	BUILT_IN_SUB_AND_FETCH_1, BUILT_IN_SUB_AND_FETCH_2,
	BUILT_IN_SUB_AND_FETCH_4, BUILT_IN_SUB_AND_FETCH_8,
	BUILT_IN_OR_AND_FETCH_N, BUILT_IN_OR_AND_FETCH_1,
	BUILT_IN_OR_AND_FETCH_2, BUILT_IN_OR_AND_FETCH_4,
	BUILT_IN_OR_AND_FETCH_8, BUILT_IN_AND_AND_FETCH_N,
	BUILT_IN_AND_AND_FETCH_1, BUILT_IN_AND_AND_FETCH_2,
	BUILT_IN_AND_AND_FETCH_4, BUILT_IN_AND_AND_FETCH_8,
	BUILT_IN_XOR_AND_FETCH_N, BUILT_IN_XOR_AND_FETCH_1,
	BUILT_IN_XOR_AND_FETCH_2, BUILT_IN_XOR_AND_FETCH_4,
	BUILT_IN_XOR_AND_FETCH_8, BUILT_IN_NAND_AND_FETCH_N,
	BUILT_IN_NAND_AND_FETCH_1, BUILT_IN_NAND_AND_FETCH_2,
	BUILT_IN_NAND_AND_FETCH_4, BUILT_IN_NAND_AND_FETCH_8,
	BUILT_IN_BOOL_COMPARE_AND_SWAP_N, BUILT_IN_BOOL_COMPARE_AND_SWAP_1,
	BUILT_IN_BOOL_COMPARE_AND_SWAP_2, BUILT_IN_BOOL_COMPARE_AND_SWAP_4,
	BUILT_IN_BOOL_COMPARE_AND_SWAP_8, BUILT_IN_VAL_COMPARE_AND_SWAP_N,
	BUILT_IN_VAL_COMPARE_AND_SWAP_1, BUILT_IN_VAL_COMPARE_AND_SWAP_2,
	BUILT_IN_VAL_COMPARE_AND_SWAP_4, BUILT_IN_VAL_COMPARE_AND_SWAP_8,
	BUILT_IN_LOCK_TEST_AND_SET_N, BUILT_IN_LOCK_TEST_AND_SET_1,
	BUILT_IN_LOCK_TEST_AND_SET_2, BUILT_IN_LOCK_TEST_AND_SET_4,
	BUILT_IN_LOCK_TEST_AND_SET_8, BUILT_IN_LOCK_RELEASE_N,
	BUILT_IN_LOCK_RELEASE_1, BUILT_IN_LOCK_RELEASE_2,
	BUILT_IN_LOCK_RELEASE_4, BUILT_IN_LOCK_RELEASE_8,
	BUILT_IN_SYNCHRONIZE: New.
	* builtins.c (called_as_built_in): Rewrite from CALLED_AS_BUILT_IN
	as a function.  Accept __sync_ as a prefix as well.
	(expand_builtin_sync_operation, expand_builtin_compare_and_swap,
	expand_builtin_lock_test_and_set, expand_builtin_synchronize,
	expand_builtin_lock_release): New.
	(expand_builtin): Call them.
	* c-common.c (DEF_BUILTIN): Don't require __builtin_ prefix if
	neither BOTH_P nor FALLBACK_P are defined.
	(builtin_type_for_size): New.
	(sync_resolve_size, sync_resolve_params, sync_resolve_return): New.
	(resolve_overloaded_builtin): New.
	* c-common.h (resolve_overloaded_builtin): Declare.
	(builtin_type_for_size): Declare.
	* c-typeck.c (build_function_call): Invoke resolve_overloaded_builtin.
	* expr.c (sync_add_optab, sync_sub_optab, sync_ior_optab,
	sync_and_optab, sync_xor_optab, sync_nand_optab, sync_old_add_optab,
	sync_old_sub_optab, sync_old_ior_optab, sync_old_and_optab,
	sync_old_xor_optab, sync_old_nand_optab, sync_new_add_optab,
	sync_new_sub_optab, sync_new_ior_optab, sync_new_and_optab,
	sync_new_xor_optab, sync_new_nand_optab, sync_compare_and_swap,
	sync_compare_and_swap_cc, sync_lock_test_and_set,
	sync_lock_release): New.
	* optabs.h: Declare them.
	* expr.h (expand_val_compare_and_swap, expand_bool_compare_and_swap,
	expand_sync_operation, expand_sync_fetch_operation,
	expand_sync_lock_test_and_set): Declare.
	* genopinit.c (optabs): Add sync optabs.
	* optabs.c (init_optabs): Initialize sync optabs.
	(expand_val_compare_and_swap_1, expand_val_compare_and_swap,
	expand_bool_compare_and_swap, expand_compare_and_swap_loop,
	expand_sync_operation, expand_sync_fetch_operation,
	expand_sync_lock_test_and_set): New.
	* doc/extend.texi (Atomic Builtins): New section
	* doc/md.texi (Standard Names): Add sync patterns.

From-SVN: r98154
2005-04-14 16:37:47 -07:00
Uros Bizjak f94b16611c * builtins.def (BUILT_IN_LCEIL, BUILT_IN_LCEILF, BUILT_IN_LCEILL)
(BUILT_IN_LLCEIL, BUILT_IN_LLCEILF, BUILT_IN_LLCEILL): New.
	* optabs.h (enum optab_index): Add new OTI_lceil.
	(lceil_optab): Define corresponding macro.
	* optabs.c (init_optabs): Initialize lceil_optab.
	* genopinit.c (optabs): Implement lceil_optab using lceilsi2
	and lceildi2 patterns.

	* builtins.c (expand_builtin_int_roundingfn): Handle
	BUILT_IN_LCEIL{,F,L} and BUILT_IN_LLCEIL{,F,L}.
	(fold_builtin_int_roundingfn): Handle BUILT_IN_LCEIL{,F,L} and
	BUILT_IN_LLCEIL{,F,L}.
	(fold_builtin_1): Fold BUILT_IN_LCEIL{,F,L} and
	BUILT_IN_LLCEIL{,F,L} using fold_builtin_int_roundingfn.
	(mathfn_built_in): Handle BUILT_IN LCEIL and BUILT_IN_LLCEIL.
	(expand_builtin): Expand BUILT_IN_LCEIL{,F,L} and
	BUILT_IN_LLCEIL{,F,L} using expand_builtin_int_roundingfn.

	* convert.c (convert_to_integer): Convert (long int)ceil{,f,l},
	into lceil built-in function and (long long int)ceil{,f,l} into
	llceil built-in function.
	* fold-const.c (tree_expr_nonnegative_p): Add BUILT_IN_LCEIL and
	BUILT_IN_LLCEIL.
testsuite:

	* gcc.dg/builtins-53.c: Also check (int)ceil* and
	(long long int)ceil*.

From-SVN: r97964
2005-04-11 08:16:39 +02:00
Uros Bizjak d8b42d069e * builtins.def (BUILT_IN_LFLOOR, BUILT_IN_LFLOORF, BUILT_IN_LFLOORL)
(BUILT_IN_LLFLOOR, BUILT_IN_LLFLOORF, BUILT_IN_LLFLOORL): New.
	* optabs.h (enum optab_index): Add new OTI_lfloor.
	(lfloor_optab): Define corresponding macro.
	* optabs.c (init_optabs): Initialize lfloor_optab.
	* genopinit.c (optabs): Implement lfloor_optab using lfloorsi2
	and lfloordi2 patterns.

	* builtins.c (expand_builtin_int_roundingfn): New prototype.
	(expand_builtin_int_roundingfn): New function.
	(fold_builtin_int_roundingfn): New prototype.
	(fold_builtin_int_roundingfn): New function, renamed from
	fold_builtin_lround.
	Handle BUILT_IN_LROUND{,F,L}, BUILT_IN_LLROUND{,F,L} and
	BUILT_IN_LFLOOR{,F,L}, BUILT_IN_LLFLOOR{,F,L}.
	(fold_builtin_1): Fold BUILT_IN_LFLOOR{,F,L} and
	BUILT_IN_LLFLOOR{,F,L} using fold_builtin_int_roundingfn.
	(mathfn_built_in): Handle BUILT_IN LFLOOR and BUILT_IN_LLFLOOR.
	(expand_builtin): Expand BUILT_IN_LFLOOR{,F,L} and
	BUILT_IN_LLFLOOR{,F,L} using expand_builtin_int_roundingfn.

	* convert.c (convert_to_integer): Convert (long int)floor{,f,l},
	into lfloor built-in function and (long long int)floor{,f,l} into
	llfloor built-in function.
	* fold-const.c (tree_expr_nonnegative_p): Add BUILT_IN_LFLOOR and
	BUILT_IN_LLFLOOR.

testsuite:

	* gcc.dg/builtins-53.c: New test.

From-SVN: r97886
2005-04-09 07:31:46 +02:00
Tom Tromey 5662a50dd8 tree.def (FILE_TYPE): Removed.
gcc:
	* tree.def (FILE_TYPE): Removed.
	* typeclass.h (enum type_class): Removed file_type_class.
	* dwarf2out.c (is_base_type): Updated.
	(gen_type_die): Likewise.
	* dbxout.c (dbxout_type): Updated.
	* builtins.c (type_to_class): Updated.
	* tree.c (type_contains_placeholder_1): Updated.
	* config/sparc/sparc.c (sparc_type_code): Updated.
	* config/ia64/ia64.c (hfa_element_mode): Updated.
	* expr.c (count_type_elements): Updated.
	* stor-layout.c (layout_type): Updated.
	* tree-inline.c (remap_type): Updated.
	* tree-pretty-print.c (dump_generic_node): Updated.
gcc/java:
	* decl.c (gnat_substitute_in_type): Don't handle FILE_TYPE.

From-SVN: r97282
2005-03-30 21:34:41 +00:00
Fariborz Jahanian 0b8495ae45 Fix problem with calling powi* builtins.
OKed by Richard Henderson.

From-SVN: r97278
2005-03-30 20:59:21 +00:00
Alan Modra 6f6e8901fb re PR target/20203 (unrecognizable insn when using long long and memset)
PR target/20203
	* builtins.c (get_memory_rtx): Expand address exp using EXPAND_NORMAL.
	Remove convert_memory_address call duplicating that in memory_address.

From-SVN: r97233
2005-03-30 13:21:12 +09:30
Uros Bizjak 59d4982b57 optabs.h (enum optab_index): Remove OTI_llrint.
* optabs.h (enum optab_index): Remove OTI_llrint.
	(llrint_optab): Remove macro.
	* optabs.c (init_optabs): Remove llrint_optab initialization.
	* genopinit.c (optabs): Remove llrint_optab implementation.
	* builtins.c (expand_builtin_mathfn): Handle BUILT_IN_LLRINT{,F,L}
	using lrint_optab.

From-SVN: r96983
2005-03-24 07:22:37 +01:00
Uros Bizjak 21e01bf10d optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint.
* optabs.h (enum optab_index): Add new OTI_lrint and OTI_llrint.
	(lrint_optab, llrint_optab): Define corresponding macros.
	* optabs.c (init_optabs): Initialize lrint_optab and llrint_optab.
	* genopinit.c (optabs): Implement lrint_optab using lrintsi2
	pattern and llrint_optab using llrintdi2 patterns.
	* builtins.c (expand_builtin_mathfn): Handle BUILT_IN_LRINT{,F,L}
	using lrint_optab and BUILT_IN_LLRINT{,F,L} using llrint_optab.
	(expand_builtin): Expand BUILT_IN_LRINT{,F,L} and
	BUILT_IN_LLRINT{,F,L} using expand_builtin_mathfn if
	flag_unsafe_math_optimizations is set.

testsuite:

	* gcc.dg/builtins-46.c: Also check lrint* and llrint*.

From-SVN: r96802
2005-03-21 15:42:48 +01:00
Kazu Hirata 49d1af8985 builtins.c (fold_builtin): Take decomposed arguments of CALL_EXPR.
* builtins.c (fold_builtin): Take decomposed arguments of
	CALL_EXPR.
	* fold-const.c (fold_ternary): Update a call to fold_builtin.
	* gimplify.c (gimplify_call_expr): Likewise.
	* tree-ssa-ccp.c (ccp_fold, ccp_fold_builtin): Likewise.
	* tree.h: Update the prototype of fold_builtin.

From-SVN: r96800
2005-03-21 14:35:08 +00:00