diff options
Diffstat (limited to 'gcc')
64 files changed, 853 insertions, 466 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 61ca1e779c3..9be1e21ace5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,129 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * tree.h (built_in_decls): Delete old interface with two parallel + arrays to hold standard builtin declarations, and replace it with + a function based interface that can support creating builtins on + the fly in the future. Change all uses, and poison the old + names. Make sure 0 is not a legitimate builtin index. + (implicit_built_in_decls): Ditto. + (built_in_info): Ditto. + (BUILTIN_VALID_P): Ditto. + (builtin_decl_explicit): Ditto. + (builtin_decl_implicit): Ditto. + (set_builtin_decl): Ditto. + (set_builtin_decl_implicit_p): Ditto. + (builtin_decl_explicit_p): Ditto. + (builtin_decl_implicit_p): Ditto. + * tree-complex.c (expand_complex_libcall): Ditto. + * tree-loop-distribution.c (generate_memset_zero): Ditto. + * tree-ssa-strlen.c (get_string_length): Ditto. + (handle_builtin_strcpy): Ditto. + (handle_builtin_strcat): Ditto. + * tree.c (iterative_hash_expr): Ditto. + (local_define_builtin): Ditto. + (build_common_builtin_nodes): Ditto. + * builtins.c (built_in_decls): Ditto. + (implicit_built_in_decls): Ditto. + (built_in_info): Ditto + (expand_builtin_classify_type): 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_stpcpy): Ditto. + (fold_builtin_strncpy): Ditto. + (fold_builtin_interclass_mathfn): Ditto. + (fold_builtin_classify): Ditto. + (fold_builtin_2): Ditto. + (fold_builtin_strstr): Ditto. + (fold_builtin_strrchr): 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_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_snprintf_chk_1): Ditto. + (fold_builtin_printf): Ditto. + (fold_builtin_fprintf): Ditto. + (fold_call_stmt): Ditto. + (set_builtin_user_assembler_name): Ditto. + * tree-emutls.c (emutls_common_1): 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_nochunk): Ditto. + (expand_omp_for_static_chunk): Ditto. + (expand_omp_sections): Ditto. + (expand_omp_atomic_fetch_op): Ditto. + (expand_omp_atomic_pipeline): Ditto. + (expand_omp_atomic_mutex): Ditto. + (lower_omp_single_simple): Ditto. + (lower_omp_single_copy): Ditto. + (lower_omp_master): Ditto. + (lower_omp_ordered): Ditto. + (lower_omp_critical): Ditto. + * tree-ssa-ccp.c (optimize_stdarg_builtin): Ditto. + * builtins.c (DEF_BUILTIN_STUB): Ditto. + (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 (merge_decls): Ditto. + * tree-eh.c (lower_resx): Ditto. + (lower_resx): Ditto. + (lower_eh_dispatch): Ditto. + * function (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-ssa-forprop.c (simplify_builtin_call): 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. + * system.h (built_in_decls): Ditto. + (implicit_built_in_decls): Ditto. + * tree-vect-generic.c (expand_vector_operations_1): 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_gimplify_va_arg): Ditto. + (rs6000_builtin_vectorized_libmass): 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. + 2011-10-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com> * tree.h (copy_ref_info): Expose existing function. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 9e113853f86..bbcb20bafcc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * gcc-interface/utils.c (def_builtin_1): Delete old interface with + two parallel arrays to hold standard builtin declarations, and + replace it with a function based interface that can support + creating builtins on the fly in the future. Change all uses, and + poison the old names. Make sure 0 is not a legitimate builtin + index. + * gcc-interface/trans.c (Exception_Handler_to_gnu_zcx): Ditto. + (gnat_to_gnu): Ditto. + 2011-10-07 Eric Botcazou <ebotcazou@adacore.com> PR lto/50492 diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index af7e9af9608..858810ae4e8 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4230,7 +4230,7 @@ Exception_Handler_to_gnu_zcx (Node_Id gnat_node) time, and reuse it to feed the end_handler hook's argument at exit. */ gnu_current_exc_ptr - = build_call_expr (built_in_decls [BUILT_IN_EH_POINTER], + = build_call_expr (builtin_decl_explicit (BUILT_IN_EH_POINTER), 1, integer_zero_node); prev_gnu_incoming_exc_ptr = gnu_incoming_exc_ptr; gnu_incoming_exc_ptr = create_var_decl (get_identifier ("EXPTR"), NULL_TREE, @@ -5520,7 +5520,7 @@ gnat_to_gnu (Node_Id gnat_node) to_ptr = build_fold_addr_expr (to); from_ptr = build_fold_addr_expr (from); - t = implicit_built_in_decls[BUILT_IN_MEMMOVE]; + t = builtin_decl_implicit (BUILT_IN_MEMMOVE); gnu_result = build_call_expr (t, 3, to_ptr, from_ptr, size); } } diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index ca3218fd079..7c7e7c6c499 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -5657,7 +5657,7 @@ def_builtin_1 (enum built_in_function fncode, /* Preserve an already installed decl. It most likely was setup in advance (e.g. as part of the internal builtins) for specific reasons. */ - if (built_in_decls[(int) fncode] != NULL_TREE) + if (builtin_decl_explicit (fncode) != NULL_TREE) return; gcc_assert ((!both_p && !fallback_p) @@ -5674,9 +5674,7 @@ def_builtin_1 (enum built_in_function fncode, add_builtin_function (libname, libtype, fncode, fnclass, NULL, fnattrs); - built_in_decls[(int) fncode] = decl; - if (implicit_p) - implicit_built_in_decls[(int) fncode] = decl; + set_builtin_decl (fncode, decl, implicit_p); } static int flag_isoc94 = 0; diff --git a/gcc/builtins.c b/gcc/builtins.c index bf1766a56a6..296c5b7dd91 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -75,11 +75,7 @@ const char * built_in_names[(int) END_BUILTINS] = /* Setup an array of _DECL trees, make sure each element is initialized to NULL_TREE. */ -tree built_in_decls[(int) END_BUILTINS]; -/* Declarations used when constructing the builtin implicitly in the compiler. - It may be NULL_TREE when this is invalid (for instance runtime is not - required to implement the function call in all cases). */ -tree implicit_built_in_decls[(int) END_BUILTINS]; +builtin_info_type builtin_info; static const char *c_getstr (tree); static rtx c_readstr (const char *, enum machine_mode); @@ -1791,17 +1787,15 @@ expand_builtin_classify_type (tree exp) fcode = BUILT_IN_MATHFN##_R; fcodef = BUILT_IN_MATHFN##F_R ; \ fcodel = BUILT_IN_MATHFN##L_R ; break; -/* Return mathematic function equivalent to FN but operating directly - on TYPE, if available. If IMPLICIT is true find the function in - implicit_built_in_decls[], otherwise use built_in_decls[]. If we - can't do the conversion, return zero. */ +/* Return mathematic function equivalent to FN but operating directly on TYPE, + if available. If IMPLICIT is true use the implicit builtin declaration, + otherwise use the explicit declaration. If we can't do the conversion, + return zero. */ static tree -mathfn_built_in_1 (tree type, enum built_in_function fn, bool implicit) +mathfn_built_in_1 (tree type, enum built_in_function fn, bool implicit_p) { - tree const *const fn_arr - = implicit ? implicit_built_in_decls : built_in_decls; - enum built_in_function fcode, fcodef, fcodel; + enum built_in_function fcode, fcodef, fcodel, fcode2; switch (fn) { @@ -1898,13 +1892,18 @@ mathfn_built_in_1 (tree type, enum built_in_function fn, bool implicit) } if (TYPE_MAIN_VARIANT (type) == double_type_node) - return fn_arr[fcode]; + fcode2 = fcode; else if (TYPE_MAIN_VARIANT (type) == float_type_node) - return fn_arr[fcodef]; + fcode2 = fcodef; else if (TYPE_MAIN_VARIANT (type) == long_double_type_node) - return fn_arr[fcodel]; + fcode2 = fcodel; else return NULL_TREE; + + if (implicit_p && !builtin_decl_implicit_p (fcode2)) + return NULL_TREE; + + return builtin_decl_explicit (fcode2); } /* Like mathfn_built_in_1(), but always use the implicit array. */ @@ -2554,11 +2553,11 @@ expand_builtin_cexpi (tree exp, rtx target) rtx op1a, op2a; if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPIF) - fn = built_in_decls[BUILT_IN_SINCOSF]; + fn = builtin_decl_explicit (BUILT_IN_SINCOSF); else if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPI) - fn = built_in_decls[BUILT_IN_SINCOS]; + fn = builtin_decl_explicit (BUILT_IN_SINCOS); else if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPIL) - fn = built_in_decls[BUILT_IN_SINCOSL]; + fn = builtin_decl_explicit (BUILT_IN_SINCOSL); else gcc_unreachable (); @@ -2580,11 +2579,11 @@ expand_builtin_cexpi (tree exp, rtx target) tree ctype = build_complex_type (type); if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPIF) - fn = built_in_decls[BUILT_IN_CEXPF]; + fn = builtin_decl_explicit (BUILT_IN_CEXPF); else if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPI) - fn = built_in_decls[BUILT_IN_CEXP]; + fn = builtin_decl_explicit (BUILT_IN_CEXP); else if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CEXPIL) - fn = built_in_decls[BUILT_IN_CEXPL]; + fn = builtin_decl_explicit (BUILT_IN_CEXPL); else gcc_unreachable (); @@ -3129,9 +3128,9 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len, rtx target, enum machine_mode mode, int endp) { /* If return value is ignored, transform mempcpy into memcpy. */ - if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_MEMCPY]) + if (target == const0_rtx && builtin_decl_implicit_p (BUILT_IN_MEMCPY)) { - tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY); tree result = build_call_nofold_loc (UNKNOWN_LOCATION, fn, 3, dest, src, len); return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -3292,9 +3291,9 @@ expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode) src = CALL_EXPR_ARG (exp, 1); /* If return value is ignored, transform stpcpy into strcpy. */ - if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_STRCPY]) + if (target == const0_rtx && builtin_decl_implicit (BUILT_IN_STRCPY)) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCPY); tree result = build_call_nofold_loc (loc, fn, 2, dst, src); return expand_expr (result, target, mode, EXPAND_NORMAL); } @@ -4353,7 +4352,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) expression to exit or longjmp. */ gimplify_and_add (valist, pre_p); t = build_call_expr_loc (loc, - implicit_built_in_decls[BUILT_IN_TRAP], 0); + builtin_decl_implicit (BUILT_IN_TRAP), 0); gimplify_and_add (t, pre_p); /* This is dead code, but go ahead and finish so that the @@ -5126,7 +5125,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp, if (warned_f_a_n) break; - fndecl = implicit_built_in_decls[BUILT_IN_SYNC_FETCH_AND_NAND_N]; + fndecl = builtin_decl_implicit (BUILT_IN_SYNC_FETCH_AND_NAND_N); inform (loc, "%qD changed semantics in GCC 4.4", fndecl); warned_f_a_n = true; break; @@ -5140,7 +5139,7 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp, if (warned_n_a_f) break; - fndecl = implicit_built_in_decls[BUILT_IN_SYNC_NAND_AND_FETCH_N]; + fndecl = builtin_decl_implicit (BUILT_IN_SYNC_NAND_AND_FETCH_N); inform (loc, "%qD changed semantics in GCC 4.4", fndecl); warned_n_a_f = true; break; @@ -6247,7 +6246,7 @@ build_builtin_expect_predicate (location_t loc, tree pred, tree expected) { tree fn, arg_types, pred_type, expected_type, call_expr, ret_type; - fn = built_in_decls[BUILT_IN_EXPECT]; + fn = builtin_decl_explicit (BUILT_IN_EXPECT); arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn)); ret_type = TREE_TYPE (TREE_TYPE (fn)); pred_type = TREE_VALUE (arg_types); @@ -8039,7 +8038,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, && (MIN (src_align, dest_align) / BITS_PER_UNIT >= (unsigned HOST_WIDE_INT) tree_low_cst (len, 1)))) { - tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; return build_call_expr_loc (loc, fn, 3, dest, src, len); @@ -8098,7 +8097,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, else return NULL_TREE; - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; return build_call_expr_loc (loc, fn, 3, dest, src, len); @@ -8117,7 +8116,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, if (!refs_may_alias_p_1 (&destr, &srcr, false)) { tree fn; - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; return build_call_expr_loc (loc, fn, 3, dest, src, len); @@ -8292,7 +8291,7 @@ fold_builtin_strcpy (location_t loc, tree fndecl, tree dest, tree src, tree len) if (optimize_function_for_size_p (cfun)) return NULL_TREE; - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; @@ -8331,7 +8330,7 @@ fold_builtin_stpcpy (location_t loc, tree fndecl, tree dest, tree src) && !integer_zerop (len)) return NULL_TREE; - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; @@ -8390,7 +8389,7 @@ fold_builtin_strncpy (location_t loc, tree fndecl, tree dest, return NULL_TREE; /* OK transform into builtin memcpy. */ - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (!fn) return NULL_TREE; @@ -9213,7 +9212,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg) CASE_FLT_FN (BUILT_IN_ISINF): { /* isinf(x) -> isgreater(fabs(x),DBL_MAX). */ - tree const isgr_fn = built_in_decls[BUILT_IN_ISGREATER]; + tree const isgr_fn = builtin_decl_explicit (BUILT_IN_ISGREATER); tree const type = TREE_TYPE (arg); REAL_VALUE_TYPE r; char buf[128]; @@ -9229,7 +9228,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg) case BUILT_IN_ISFINITE: { /* isfinite(x) -> islessequal(fabs(x),DBL_MAX). */ - tree const isle_fn = built_in_decls[BUILT_IN_ISLESSEQUAL]; + tree const isle_fn = builtin_decl_explicit (BUILT_IN_ISLESSEQUAL); tree const type = TREE_TYPE (arg); REAL_VALUE_TYPE r; char buf[128]; @@ -9252,8 +9251,8 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg) { /* isnormal(x) -> isgreaterequal(fabs(x),DBL_MIN) & islessequal(fabs(x),DBL_MAX). */ - tree const isle_fn = built_in_decls[BUILT_IN_ISLESSEQUAL]; - tree const isge_fn = built_in_decls[BUILT_IN_ISGREATEREQUAL]; + tree const isle_fn = builtin_decl_explicit (BUILT_IN_ISLESSEQUAL); + tree const isge_fn = builtin_decl_explicit (BUILT_IN_ISGREATEREQUAL); tree const type = TREE_TYPE (arg); REAL_VALUE_TYPE rmax, rmin; char buf[128]; @@ -9314,7 +9313,7 @@ fold_builtin_classify (location_t loc, tree fndecl, tree arg, int builtin_index) 1. So e.g. "if (isinf_sign(x))" would be folded to just "if (isinf(x) ? 1 : 0)" which becomes "if (isinf(x))". */ tree signbit_fn = mathfn_built_in_1 (TREE_TYPE (arg), BUILT_IN_SIGNBIT, 0); - tree isinf_fn = built_in_decls[BUILT_IN_ISINF]; + tree isinf_fn = builtin_decl_explicit (BUILT_IN_ISINF); tree tmp = NULL_TREE; arg = builtin_save_expr (arg); @@ -10037,7 +10036,7 @@ fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1, bool ignore) case BUILT_IN_STPCPY: if (ignore) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCPY); if (!fn) break; @@ -10837,7 +10836,7 @@ fold_builtin_strstr (location_t loc, tree s1, tree s2, tree type) if (p2[1] != '\0') return NULL_TREE; - fn = implicit_built_in_decls[BUILT_IN_STRCHR]; + fn = builtin_decl_implicit (BUILT_IN_STRCHR); if (!fn) return NULL_TREE; @@ -10957,7 +10956,7 @@ fold_builtin_strrchr (location_t loc, tree s1, tree s2, tree type) if (! integer_zerop (s2)) return NULL_TREE; - fn = implicit_built_in_decls[BUILT_IN_STRCHR]; + fn = builtin_decl_implicit (BUILT_IN_STRCHR); if (!fn) return NULL_TREE; @@ -11021,7 +11020,7 @@ fold_builtin_strpbrk (location_t loc, tree s1, tree s2, tree type) if (p2[1] != '\0') return NULL_TREE; /* Really call strpbrk. */ - fn = implicit_built_in_decls[BUILT_IN_STRCHR]; + fn = builtin_decl_implicit (BUILT_IN_STRCHR); if (!fn) return NULL_TREE; @@ -11068,8 +11067,8 @@ fold_builtin_strcat (location_t loc ATTRIBUTE_UNUSED, tree dst, tree src) { /* See if we can store by pieces into (dst + strlen(dst)). */ tree newdst, call; - tree strlen_fn = implicit_built_in_decls[BUILT_IN_STRLEN]; - tree strcpy_fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree strlen_fn = builtin_decl_implicit (BUILT_IN_STRLEN); + tree strcpy_fn = builtin_decl_implicit (BUILT_IN_STRCPY); if (!strlen_fn || !strcpy_fn) return NULL_TREE; @@ -11142,7 +11141,7 @@ fold_builtin_strncat (location_t loc, tree dst, tree src, tree len) if (TREE_CODE (len) == INTEGER_CST && p && compare_tree_int (len, strlen (p)) >= 0) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCAT]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCAT); /* If the replacement _DECL isn't initialized, don't do the transformation. */ @@ -11247,7 +11246,7 @@ fold_builtin_strcspn (location_t loc, tree s1, tree s2) /* If the second argument is "", return __builtin_strlen(s1). */ if (p2 && *p2 == '\0') { - tree fn = implicit_built_in_decls[BUILT_IN_STRLEN]; + tree fn = builtin_decl_implicit (BUILT_IN_STRLEN); /* If the replacement _DECL isn't initialized, don't do the transformation. */ @@ -11273,10 +11272,12 @@ fold_builtin_fputs (location_t loc, tree arg0, tree arg1, { /* If we're using an unlocked function, assume the other unlocked functions exist explicitly. */ - tree const fn_fputc = unlocked ? built_in_decls[BUILT_IN_FPUTC_UNLOCKED] - : implicit_built_in_decls[BUILT_IN_FPUTC]; - tree const fn_fwrite = unlocked ? built_in_decls[BUILT_IN_FWRITE_UNLOCKED] - : implicit_built_in_decls[BUILT_IN_FWRITE]; + tree const fn_fputc = (unlocked + ? builtin_decl_explicit (BUILT_IN_FPUTC_UNLOCKED) + : builtin_decl_implicit (BUILT_IN_FPUTC)); + tree const fn_fwrite = (unlocked + ? builtin_decl_explicit (BUILT_IN_FWRITE_UNLOCKED) + : builtin_decl_implicit (BUILT_IN_FWRITE)); /* If the return value is used, don't do the transformation. */ if (!ignore) @@ -11470,7 +11471,7 @@ fold_builtin_sprintf (location_t loc, tree dest, tree fmt, /* If the format doesn't contain % args or %%, use strcpy. */ if (strchr (fmt_str, target_percent) == NULL) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCPY); if (!fn) return NULL_TREE; @@ -11490,7 +11491,7 @@ fold_builtin_sprintf (location_t loc, tree dest, tree fmt, else if (fmt_str && strcmp (fmt_str, target_percent_s) == 0) { tree fn; - fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + fn = builtin_decl_implicit (BUILT_IN_STRCPY); if (!fn) return NULL_TREE; @@ -11512,7 +11513,7 @@ fold_builtin_sprintf (location_t loc, tree dest, tree fmt, if (call && retval) { retval = fold_convert_loc - (loc, TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SPRINTF])), + (loc, TREE_TYPE (TREE_TYPE (builtin_decl_implicit (BUILT_IN_SPRINTF))), retval); return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval); } @@ -11565,7 +11566,7 @@ fold_builtin_snprintf (location_t loc, tree dest, tree destsize, tree fmt, /* If the format doesn't contain % args or %%, use strcpy. */ if (strchr (fmt_str, target_percent) == NULL) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCPY); size_t len = strlen (fmt_str); /* Don't optimize snprintf (buf, 4, "abc", ptr++). */ @@ -11597,7 +11598,7 @@ fold_builtin_snprintf (location_t loc, tree dest, tree destsize, tree fmt, /* If the format is "%s", use strcpy if the result isn't used. */ else if (fmt_str && strcmp (fmt_str, target_percent_s) == 0) { - tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + tree fn = builtin_decl_implicit (BUILT_IN_STRCPY); unsigned HOST_WIDE_INT origlen; /* Don't crash on snprintf (str1, cst, "%s"). */ @@ -11632,7 +11633,7 @@ fold_builtin_snprintf (location_t loc, tree dest, tree destsize, tree fmt, if (call && retval) { - tree fn = built_in_decls[BUILT_IN_SNPRINTF]; + tree fn = builtin_decl_explicit (BUILT_IN_SNPRINTF); retval = fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fn)), retval); return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval); } @@ -11720,16 +11721,16 @@ expand_builtin_memory_chk (tree exp, rtx target, enum machine_mode mode, switch (fcode) { case BUILT_IN_MEMCPY_CHK: - fn = built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY); break; case BUILT_IN_MEMPCPY_CHK: - fn = built_in_decls[BUILT_IN_MEMPCPY]; + fn = builtin_decl_explicit (BUILT_IN_MEMPCPY); break; case BUILT_IN_MEMMOVE_CHK: - fn = built_in_decls[BUILT_IN_MEMMOVE]; + fn = builtin_decl_explicit (BUILT_IN_MEMMOVE); break; case BUILT_IN_MEMSET_CHK: - fn = built_in_decls[BUILT_IN_MEMSET]; + fn = builtin_decl_explicit (BUILT_IN_MEMSET); break; default: break; @@ -11781,7 +11782,7 @@ expand_builtin_memory_chk (tree exp, rtx target, enum machine_mode mode, normal __memcpy_chk. */ if (readonly_data_expr (src)) { - tree fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; + tree fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); if (!fn) return NULL_RTX; fn = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 4, @@ -12045,7 +12046,7 @@ fold_builtin_memory_chk (location_t loc, tree fndecl, { /* (void) __mempcpy_chk () can be optimized into (void) __memcpy_chk (). */ - fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); if (!fn) return NULL_TREE; @@ -12067,16 +12068,16 @@ fold_builtin_memory_chk (location_t loc, tree fndecl, switch (fcode) { case BUILT_IN_MEMCPY_CHK: - fn = built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY); break; case BUILT_IN_MEMPCPY_CHK: - fn = built_in_decls[BUILT_IN_MEMPCPY]; + fn = builtin_decl_explicit (BUILT_IN_MEMPCPY); break; case BUILT_IN_MEMMOVE_CHK: - fn = built_in_decls[BUILT_IN_MEMMOVE]; + fn = builtin_decl_explicit (BUILT_IN_MEMMOVE); break; case BUILT_IN_MEMSET_CHK: - fn = built_in_decls[BUILT_IN_MEMSET]; + fn = builtin_decl_explicit (BUILT_IN_MEMSET); break; default: break; @@ -12131,7 +12132,7 @@ fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, /* If return value of __stpcpy_chk is ignored, optimize into __strcpy_chk. */ - fn = built_in_decls[BUILT_IN_STRCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_STRCPY_CHK); if (!fn) return NULL_TREE; @@ -12143,7 +12144,7 @@ fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, /* If c_strlen returned something, but not a constant, transform __strcpy_chk into __memcpy_chk. */ - fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); if (!fn) return NULL_TREE; @@ -12163,8 +12164,8 @@ fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, } /* If __builtin_st{r,p}cpy_chk is used, assume st{r,p}cpy is available. */ - fn = built_in_decls[fcode == BUILT_IN_STPCPY_CHK - ? BUILT_IN_STPCPY : BUILT_IN_STRCPY]; + fn = builtin_decl_explicit (fcode == BUILT_IN_STPCPY_CHK + ? BUILT_IN_STPCPY : BUILT_IN_STRCPY); if (!fn) return NULL_TREE; @@ -12208,7 +12209,7 @@ fold_builtin_strncpy_chk (location_t loc, tree dest, tree src, } /* If __builtin_strncpy_chk is used, assume strncpy is available. */ - fn = built_in_decls[BUILT_IN_STRNCPY]; + fn = builtin_decl_explicit (BUILT_IN_STRNCPY); if (!fn) return NULL_TREE; @@ -12239,7 +12240,7 @@ fold_builtin_strcat_chk (location_t loc, tree fndecl, tree dest, return NULL_TREE; /* If __builtin_strcat_chk is used, assume strcat is available. */ - fn = built_in_decls[BUILT_IN_STRCAT]; + fn = builtin_decl_explicit (BUILT_IN_STRCAT); if (!fn) return NULL_TREE; @@ -12281,7 +12282,7 @@ fold_builtin_strncat_chk (location_t loc, tree fndecl, && ! tree_int_cst_lt (len, src_len)) { /* If LEN >= strlen (SRC), optimize into __strcat_chk. */ - fn = built_in_decls[BUILT_IN_STRCAT_CHK]; + fn = builtin_decl_explicit (BUILT_IN_STRCAT_CHK); if (!fn) return NULL_TREE; @@ -12291,7 +12292,7 @@ fold_builtin_strncat_chk (location_t loc, tree fndecl, } /* If __builtin_strncat_chk is used, assume strncat is available. */ - fn = built_in_decls[BUILT_IN_STRNCAT]; + fn = builtin_decl_explicit (BUILT_IN_STRNCAT); if (!fn) return NULL_TREE; @@ -12382,8 +12383,8 @@ fold_builtin_sprintf_chk_1 (location_t loc, int nargs, tree *args, } /* If __builtin_{,v}sprintf_chk is used, assume {,v}sprintf is available. */ - fn = built_in_decls[fcode == BUILT_IN_VSPRINTF_CHK - ? BUILT_IN_VSPRINTF : BUILT_IN_SPRINTF]; + fn = builtin_decl_explicit (fcode == BUILT_IN_VSPRINTF_CHK + ? BUILT_IN_VSPRINTF : BUILT_IN_SPRINTF); if (!fn) return NULL_TREE; @@ -12471,8 +12472,8 @@ fold_builtin_snprintf_chk_1 (location_t loc, int nargs, tree *args, /* If __builtin_{,v}snprintf_chk is used, assume {,v}snprintf is available. */ - fn = built_in_decls[fcode == BUILT_IN_VSNPRINTF_CHK - ? BUILT_IN_VSNPRINTF : BUILT_IN_SNPRINTF]; + fn = builtin_decl_explicit (fcode == BUILT_IN_VSNPRINTF_CHK + ? BUILT_IN_VSNPRINTF : BUILT_IN_SNPRINTF); if (!fn) return NULL_TREE; @@ -12526,13 +12527,13 @@ fold_builtin_printf (location_t loc, tree fndecl, tree fmt, { /* If we're using an unlocked function, assume the other unlocked functions exist explicitly. */ - fn_putchar = built_in_decls[BUILT_IN_PUTCHAR_UNLOCKED]; - fn_puts = built_in_decls[BUILT_IN_PUTS_UNLOCKED]; + fn_putchar = builtin_decl_explicit (BUILT_IN_PUTCHAR_UNLOCKED); + fn_puts = builtin_decl_explicit (BUILT_IN_PUTS_UNLOCKED); } else { - fn_putchar = implicit_built_in_decls[BUILT_IN_PUTCHAR]; - fn_puts = implicit_built_in_decls[BUILT_IN_PUTS]; + fn_putchar = builtin_decl_implicit (BUILT_IN_PUTCHAR); + fn_puts = builtin_decl_implicit (BUILT_IN_PUTS); } if (!init_target_chars ()) @@ -12677,13 +12678,13 @@ fold_builtin_fprintf (location_t loc, tree fndecl, tree fp, { /* If we're using an unlocked function, assume the other unlocked functions exist explicitly. */ - fn_fputc = built_in_decls[BUILT_IN_FPUTC_UNLOCKED]; - fn_fputs = built_in_decls[BUILT_IN_FPUTS_UNLOCKED]; + fn_fputc = builtin_decl_explicit (BUILT_IN_FPUTC_UNLOCKED); + fn_fputs = builtin_decl_explicit (BUILT_IN_FPUTS_UNLOCKED); } else { - fn_fputc = implicit_built_in_decls[BUILT_IN_FPUTC]; - fn_fputs = implicit_built_in_decls[BUILT_IN_FPUTS]; + fn_fputc = builtin_decl_implicit (BUILT_IN_FPUTC); + fn_fputs = builtin_decl_implicit (BUILT_IN_FPUTS); } if (!init_target_chars ()) @@ -13485,7 +13486,7 @@ fold_call_stmt (gimple stmt, bool ignore) return NULL_TREE; } -/* Look up the function in built_in_decls that corresponds to DECL +/* Look up the function in builtin_decl that corresponds to DECL and set ASMSPEC as its user assembler name. DECL must be a function decl that declares a builtin. */ @@ -13497,8 +13498,9 @@ set_builtin_user_assembler_name (tree decl, const char *asmspec) && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL && asmspec != 0); - builtin = built_in_decls [DECL_FUNCTION_CODE (decl)]; - set_user_assembler_name (builtin, asmspec); + builtin = builtin_decl_explicit (DECL_FUNCTION_CODE (decl)); + set_user_assembler_name ( +builtin, asmspec); switch (DECL_FUNCTION_CODE (decl)) { case BUILT_IN_MEMCPY: diff --git a/gcc/builtins.def b/gcc/builtins.def index 59c082de983..0420b550f3b 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -131,8 +131,8 @@ along with GCC; see the file COPYING3. If not see define it here at all. */ #undef DEF_BUILTIN_STUB #define DEF_BUILTIN_STUB(ENUM, NAME) \ - DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, 0, 0, false, false, \ - false, 0, false, false) + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, BT_LAST, BT_LAST, false, false, \ + false, ATTR_LAST, false, false) /* Builtin used by the implementation of GNU OpenMP. None of these are actually implemented in the compiler; they're all in libgomp. */ @@ -173,6 +173,9 @@ along with GCC; see the file COPYING3. If not see #undef ATTR_MATHFN_FPROUNDING_STORE #define ATTR_MATHFN_FPROUNDING_STORE ATTR_NOTHROW_LEAF_LIST +/* Make sure 0 is not a legitimate builtin. */ +DEF_BUILTIN_STUB(BUILT_IN_NONE, (const char *)0) + /* Category: math builtins. */ DEF_LIB_BUILTIN (BUILT_IN_ACOS, "acos", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO) DEF_C99_C90RES_BUILTIN (BUILT_IN_ACOSF, "acosf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO) diff --git a/gcc/c-decl.c b/gcc/c-decl.c index cb58d324dca..7af70f00c0f 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2372,17 +2372,21 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) { C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0; if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL) - switch (DECL_FUNCTION_CODE (newdecl)) - { - /* If a compatible prototype of these builtin functions - is seen, assume the runtime implements it with the - expected semantics. */ - case BUILT_IN_STPCPY: - implicit_built_in_decls[DECL_FUNCTION_CODE (newdecl)] - = built_in_decls[DECL_FUNCTION_CODE (newdecl)]; - default: - break; - } + { + enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl); + switch (fncode) + { + /* If a compatible prototype of these builtin functions + is seen, assume the runtime implements it with the + expected semantics. */ + case BUILT_IN_STPCPY: + if (builtin_decl_explicit_p (fncode)) + set_builtin_decl_implicit_p (fncode, true); + break; + default: + break; + } + } } else C_DECL_BUILTIN_PROTOTYPE (newdecl) @@ -4338,7 +4342,7 @@ finish_decl (tree decl, location_t init_loc, tree init, } /* If this is a function and an assembler name is specified, reset DECL_RTL - so we can give it its new name. Also, update built_in_decls if it + so we can give it its new name. Also, update builtin_decl if it was a normal built-in. */ if (TREE_CODE (decl) == FUNCTION_DECL && asmspec) { diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e93b98dd451..3a26e170ecc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * c-common.c (def_builtin_1): Delete old interface with two + parallel arrays to hold standard builtin declarations, and replace + it with a function based interface that can support creating + builtins on the fly in the future. Change all uses, and poison + the old names. Make sure 0 is not a legitimate builtin index. + * c-omp.c (c_finish_omp_barrier): Ditto. + (c_finish_omp_taskwait): Ditto. + (c_finish_omp_flush): Ditto. + 2011-10-11 Tristan Gingold <gingold@adacore.com> * c.opt: (fallow-parameterless-variadic-functions): New. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2c5a48916ff..0aa0fefbd7c 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5168,15 +5168,14 @@ def_builtin_1 (enum built_in_function fncode, decl = add_builtin_function (name, fntype, fncode, fnclass, (fallback_p ? libname : NULL), fnattrs); + + set_builtin_decl (fncode, decl, implicit_p); + if (both_p && !flag_no_builtin && !builtin_function_disabled_p (libname) && !(nonansi_p && flag_no_nonansi_builtin)) add_builtin_function (libname, libtype, fncode, fnclass, NULL, fnattrs); - - built_in_decls[(int) fncode] = decl; - if (implicit_p) - implicit_built_in_decls[(int) fncode] = decl; } /* Nonzero if the type T promotes to int. This is (nearly) the @@ -9144,11 +9143,13 @@ resolve_overloaded_builtin (location_t loc, tree function, VEC(tree,gc) *params) { int n = sync_resolve_size (function, params); tree new_function, first_param, result; + enum built_in_function fncode; if (n == 0) return error_mark_node; - new_function = built_in_decls[orig_code + exact_log2 (n) + 1]; + fncode = (enum built_in_function)((int)orig_code + exact_log2 (n) + 1); + new_function = builtin_decl_explicit (fncode); if (!sync_resolve_params (function, new_function, params)) return error_mark_node; diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 4a5b0ca928b..481211ed72d 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -77,7 +77,7 @@ c_finish_omp_barrier (location_t loc) { tree x; - x = built_in_decls[BUILT_IN_GOMP_BARRIER]; + x = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER); x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -91,7 +91,7 @@ c_finish_omp_taskwait (location_t loc) { tree x; - x = built_in_decls[BUILT_IN_GOMP_TASKWAIT]; + x = builtin_decl_explicit (BUILT_IN_GOMP_TASKWAIT); x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -105,7 +105,7 @@ c_finish_omp_taskyield (location_t loc) { tree x; - x = built_in_decls[BUILT_IN_GOMP_TASKYIELD]; + x = builtin_decl_explicit (BUILT_IN_GOMP_TASKYIELD); x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -260,7 +260,7 @@ c_finish_omp_flush (location_t loc) { tree x; - x = built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE]; + x = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); x = build_call_expr_loc (loc, x, 0); add_stmt (x); } diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index d0a0b5ef07c..7dfdae2b38e 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2766,7 +2766,8 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, && !comptypes (fntype, TREE_TYPE (tem))) { tree return_type = TREE_TYPE (fntype); - tree trap = build_function_call (loc, built_in_decls[BUILT_IN_TRAP], + tree trap = build_function_call (loc, + builtin_decl_explicit (BUILT_IN_TRAP), NULL_TREE); int i; diff --git a/gcc/calls.c b/gcc/calls.c index 3fa70b571f4..eeb6b2ec602 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -274,6 +274,7 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU if (fndecl && TREE_CODE (fndecl) == FUNCTION_DECL) { tree t = fndecl; + /* Although a built-in FUNCTION_DECL and its non-__builtin counterpart compare equal and get a shared mem_attrs, they produce different dump output in compare-debug compilations, @@ -281,10 +282,14 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU adds a different (but equivalent) entry, while the other doesn't run the garbage collector at the same spot and then shares the mem_attr with the equivalent entry. */ - if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL - && built_in_decls[DECL_FUNCTION_CODE (t)]) - t = built_in_decls[DECL_FUNCTION_CODE (t)]; - set_mem_expr (funmem, t); + if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL) + { + tree t2 = builtin_decl_explicit (DECL_FUNCTION_CODE (t)); + if (t2) + t = t2; + } + + set_mem_expr (funmem, t); } else if (fntree) set_mem_expr (funmem, build_simple_mem_ref (CALL_EXPR_FN (fntree))); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index bedda1ec65b..d8e5cd974a2 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2962,7 +2962,7 @@ darwin_override_options (void) static void darwin_patch_builtin (int fncode) { - tree fn = built_in_decls[fncode]; + tree fn = builtin_decl_explicit (fncode); tree sym; char *newname; @@ -2974,7 +2974,7 @@ darwin_patch_builtin (int fncode) set_user_assembler_name (fn, newname); - fn = implicit_built_in_decls[fncode]; + fn = builtin_decl_implicit (fncode); if (fn) set_user_assembler_name (fn, newname); } @@ -3149,9 +3149,10 @@ darwin_rename_builtins (void) use the faster version. */ if (!flag_unsafe_math_optimizations) { - int dcode = (BUILT_IN_COMPLEX_DIV_MIN - + DCmode - MIN_MODE_COMPLEX_FLOAT); - tree fn = built_in_decls[dcode]; + enum built_in_function dcode + = (enum built_in_function)(BUILT_IN_COMPLEX_DIV_MIN + + DCmode - MIN_MODE_COMPLEX_FLOAT); + tree fn = builtin_decl_explicit (dcode); /* Fortran and c call TARGET_INIT_BUILTINS and TARGET_INIT_LIBFUNCS at different times, so we have to put a call into each to ensure that at least one of them is called @@ -3159,7 +3160,7 @@ darwin_rename_builtins (void) new hook to run after build_common_builtin_nodes runs. */ if (fn) set_user_assembler_name (fn, "___ieee_divdc3"); - fn = implicit_built_in_decls[dcode]; + fn = builtin_decl_implicit (dcode); if (fn) set_user_assembler_name (fn, "___ieee_divdc3"); } diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 490bf4eae3e..625c55e76d9 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -8027,7 +8027,7 @@ ix86_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, else { tree copy - = build_call_expr (implicit_built_in_decls[BUILT_IN_MEMCPY], + = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY), 3, dest_addr, src_addr, size_int (cur_size)); gimplify_and_add (copy, pre_p); @@ -29160,7 +29160,7 @@ ix86_veclibabi_svml (enum built_in_function fn, tree type_out, tree type_in) return NULL_TREE; } - bname = IDENTIFIER_POINTER (DECL_NAME (implicit_built_in_decls[fn])); + bname = IDENTIFIER_POINTER (DECL_NAME (builtin_decl_implicit (fn))); if (fn == BUILT_IN_LOGF) strcpy (name, "vmlsLn4"); @@ -29178,7 +29178,8 @@ ix86_veclibabi_svml (enum built_in_function fn, tree type_out, tree type_in) name[4] &= ~0x20; arity = 0; - for (args = DECL_ARGUMENTS (implicit_built_in_decls[fn]); args; + for (args = DECL_ARGUMENTS (builtin_decl_implicit (fn)); + args; args = TREE_CHAIN (args)) arity++; @@ -29259,11 +29260,12 @@ ix86_veclibabi_acml (enum built_in_function fn, tree type_out, tree type_in) return NULL_TREE; } - bname = IDENTIFIER_POINTER (DECL_NAME (implicit_built_in_decls[fn])); + bname = IDENTIFIER_POINTER (DECL_NAME (builtin_decl_implicit (fn))); sprintf (name + 7, "%s", bname+10); arity = 0; - for (args = DECL_ARGUMENTS (implicit_built_in_decls[fn]); args; + for (args = DECL_ARGUMENTS (builtin_decl_implicit (fn)); + args; args = TREE_CHAIN (args)) arity++; diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index f4fbf08396d..6d3ac6d45ee 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -10100,15 +10100,12 @@ ia64_init_builtins (void) if (TARGET_HPUX) { - if (built_in_decls [BUILT_IN_FINITE]) - set_user_assembler_name (built_in_decls [BUILT_IN_FINITE], - "_Isfinite"); - if (built_in_decls [BUILT_IN_FINITEF]) - set_user_assembler_name (built_in_decls [BUILT_IN_FINITEF], - "_Isfinitef"); - if (built_in_decls [BUILT_IN_FINITEL]) - set_user_assembler_name (built_in_decls [BUILT_IN_FINITEL], - "_Isfinitef128"); + if ((decl = builtin_decl_explicit (BUILT_IN_FINITE))) != NULL_TREE) + set_user_assembler_name (decl, "_Isfinite"); + if ((decl = builtin_decl_explicit (BUILT_IN_FINITEF))) != NULL_TREE) + set_user_assembler_name (decl, "_Isfinitef"); + if ((decl = builtin_decl_explicit (BUILT_IN_FINITEL))) != NULL_TREE) + set_user_assembler_name (decl, "_Isfinitef128"); } } diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index e3ad4c80d89..66e3fc700b4 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -555,16 +555,21 @@ static void pa_init_builtins (void) { #ifdef DONT_HAVE_FPUTC_UNLOCKED - built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED] = - built_in_decls[(int) BUILT_IN_PUTC_UNLOCKED]; - implicit_built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED] - = implicit_built_in_decls[(int) BUILT_IN_PUTC_UNLOCKED]; + { + tree decl = builtin_decl_explicit (BUILT_IN_PUTC_UNLOCKED); + set_builtin_decl (BUILT_IN_FPUTC_UNLOCKED, decl, + builtin_decl_implicit_p (BUILT_IN_PUTC_UNLOCKED)); + } #endif #if TARGET_HPUX_11 - if (built_in_decls [BUILT_IN_FINITE]) - set_user_assembler_name (built_in_decls [BUILT_IN_FINITE], "_Isfinite"); - if (built_in_decls [BUILT_IN_FINITEF]) - set_user_assembler_name (built_in_decls [BUILT_IN_FINITEF], "_Isfinitef"); + { + tree decl; + + if ((decl = builtin_decl_explicit (BUILT_IN_FINITE)) != NULL_TREE) + set_user_assembler_name (decl, "_Isfinite"); + if ((decl = builtin_decl_explicit (BUILT_IN_FINITEF)) != NULL_TREE) + set_user_assembler_name (decl, "_Isfinitef"); + } #endif if (HPUX_LONG_DOUBLE_LIBRARY) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 63c0f0ce201..4fd2192d380 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3739,7 +3739,7 @@ rs6000_builtin_vectorized_libmass (tree fndecl, tree type_out, tree type_in) case BUILT_IN_SQRT: case BUILT_IN_TAN: case BUILT_IN_TANH: - bdecl = implicit_built_in_decls[fn]; + bdecl = builtin_decl_implicit (fn); suffix = "d2"; /* pow -> powd2 */ if (el_mode != DFmode || n != 2) @@ -3776,7 +3776,7 @@ rs6000_builtin_vectorized_libmass (tree fndecl, tree type_out, tree type_in) case BUILT_IN_SQRTF: case BUILT_IN_TANF: case BUILT_IN_TANHF: - bdecl = implicit_built_in_decls[fn]; + bdecl = builtin_decl_implicit (fn); suffix = "4"; /* powf -> powf4 */ if (el_mode != SFmode || n != 4) @@ -9400,7 +9400,7 @@ rs6000_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, tree tmp = create_tmp_var (type, "va_arg_tmp"); tree dest_addr = build_fold_addr_expr (tmp); - tree copy = build_call_expr (implicit_built_in_decls[BUILT_IN_MEMCPY], + tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY), 3, dest_addr, addr, size_int (rsize * 4)); gimplify_and_add (copy, pre_p); @@ -12213,8 +12213,8 @@ rs6000_init_builtins (void) #if TARGET_XCOFF /* AIX libm provides clog as __clog. */ - if (built_in_decls [BUILT_IN_CLOG]) - set_user_assembler_name (built_in_decls [BUILT_IN_CLOG], "__clog"); + if ((tdecl = builtin_decl_explicit ([BUILT_IN_CLOG))) != NULL_TREE) + set_user_assembler_name (tdecl, "__clog"); #endif #ifdef SUBTARGET_INIT_BUILTINS diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 9606f68d9b5..9c7cc56b43e 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -6789,7 +6789,7 @@ sparc_gimplify_va_arg (tree valist, tree type, gimple_seq *pre_p, { tree tmp = create_tmp_var (type, "va_arg_tmp"); tree dest_addr = build_fold_addr_expr (tmp); - tree copy = build_call_expr (implicit_built_in_decls[BUILT_IN_MEMCPY], + tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY), 3, dest_addr, addr, size_int (rsize)); TREE_ADDRESSABLE (tmp) = 1; gimplify_and_add (copy, pre_p); diff --git a/gcc/config/vms/vms.c b/gcc/config/vms/vms.c index 62a16619856..44940a3aa3b 100644 --- a/gcc/config/vms/vms.c +++ b/gcc/config/vms/vms.c @@ -99,8 +99,11 @@ vms_patch_builtins (void) unsigned int i; /* Fwrite on VMS is non-standard. */ - implicit_built_in_decls[(int) BUILT_IN_FWRITE] = NULL_TREE; - implicit_built_in_decls[(int) BUILT_IN_FWRITE_UNLOCKED] = NULL_TREE; + if (builtin_decl_implicit_p (BUILT_IN_WRITE)) + set_builtin_decl_implicit_p (BUILT_IN_WRITE, false); + + if (builtin_decl_implicit_p (BUILT_IN_WRITE_UNLOCKED)) + set_builtin_decl_implicit_p (BUILT_IN_WRITE_UNLOCKED, false); /* Define aliases for names. */ for (i = 0; i < NBR_CRTL_NAMES; i++) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 69c0eeb7b6d..ca8566f0f5c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * decl.c (duplicate_decls): Delete old interface with two parallel + arrays to hold standard builtin declarations, and replace it with + a function based interface that can support creating builtins on + the fly in the future. Change all uses, and poison the old + names. Make sure 0 is not a legitimate builtin index. + * except.c (build_eh_type_type): Ditto. + (choose_personality_routine): Ditto. + * semantics.c (finish_omp_atomic): Ditto. + (finish_omp_barrier): Ditto. + (finish_omp_flush): Ditto. + (finish_omp_taskwait): Ditto. + 2011-10-11 Jason Merrill <jason@redhat.com> PR c++/49855 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 984d1f2f372..c8f325548cb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1357,11 +1357,13 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (DECL_BUILT_IN_CLASS (olddecl) == BUILT_IN_NORMAL && DECL_ANTICIPATED (olddecl) && TREE_NOTHROW (newdecl) - && !TREE_NOTHROW (olddecl) - && built_in_decls [DECL_FUNCTION_CODE (olddecl)] != NULL_TREE - && built_in_decls [DECL_FUNCTION_CODE (olddecl)] != olddecl - && types_match) - TREE_NOTHROW (built_in_decls [DECL_FUNCTION_CODE (olddecl)]) = 1; + && !TREE_NOTHROW (olddecl)) + { + enum built_in_function fncode = DECL_FUNCTION_CODE (olddecl); + tree tmpdecl = builtin_decl_explicit (fncode); + if (tmpdecl && tmpdecl != olddecl && types_match) + TREE_NOTHROW (tmpdecl) = 1; + } /* Whether or not the builtin can throw exceptions has no bearing on this declarator. */ @@ -2136,17 +2138,21 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) regardless of declaration matches. */ COPY_DECL_RTL (olddecl, newdecl); if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL) - switch (DECL_FUNCTION_CODE (newdecl)) - { - /* If a compatible prototype of these builtin functions - is seen, assume the runtime implements it with the - expected semantics. */ - case BUILT_IN_STPCPY: - implicit_built_in_decls[DECL_FUNCTION_CODE (newdecl)] - = built_in_decls[DECL_FUNCTION_CODE (newdecl)]; - default: - break; - } + { + enum built_in_function fncode = DECL_FUNCTION_CODE (newdecl); + switch (fncode) + { + /* If a compatible prototype of these builtin functions + is seen, assume the runtime implements it with the + expected semantics. */ + case BUILT_IN_STPCPY: + if (builtin_decl_explicit_p (fncode)) + set_builtin_decl_implicit_p (fncode, true); + break; + default: + break; + } + } } DECL_RESULT (newdecl) = DECL_RESULT (olddecl); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index ceec858be1f..e529685c992 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -140,7 +140,7 @@ build_eh_type_type (tree type) tree build_exc_ptr (void) { - return build_call_n (built_in_decls [BUILT_IN_EH_POINTER], + return build_call_n (builtin_decl_explicit (BUILT_IN_EH_POINTER), 1, integer_zero_node); } @@ -333,7 +333,7 @@ choose_personality_routine (enum languages lang) case lang_java: state = chose_java; - terminate_node = built_in_decls [BUILT_IN_ABORT]; + terminate_node = builtin_decl_explicit (BUILT_IN_ABORT); pragma_java_exceptions = true; break; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 189c13ad3e9..eed38e62f7b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4784,7 +4784,7 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs, void finish_omp_barrier (void) { - tree fn = built_in_decls[BUILT_IN_GOMP_BARRIER]; + tree fn = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER); VEC(tree,gc) *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); @@ -4794,7 +4794,7 @@ finish_omp_barrier (void) void finish_omp_flush (void) { - tree fn = built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE]; + tree fn = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); VEC(tree,gc) *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); @@ -4804,7 +4804,7 @@ finish_omp_flush (void) void finish_omp_taskwait (void) { - tree fn = built_in_decls[BUILT_IN_GOMP_TASKWAIT]; + tree fn = builtin_decl_explicit (BUILT_IN_GOMP_TASKWAIT); VEC(tree,gc) *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); @@ -4814,7 +4814,7 @@ finish_omp_taskwait (void) void finish_omp_taskyield (void) { - tree fn = built_in_decls[BUILT_IN_GOMP_TASKYIELD]; + tree fn = builtin_decl_explicit (BUILT_IN_GOMP_TASKYIELD); VEC(tree,gc) *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 34c688b3104..029edf2c290 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,37 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * trans-expr.c (gfc_conv_power_op): Delete old interface with two + parallel arrays to hold standard builtin declarations, and replace + it with a function based interface that can support creating + builtins on the fly in the future. Change all uses, and poison + the old names. Make sure 0 is not a legitimate builtin index. + (fill_with_spaces): Ditto. + (gfc_trans_string_copy): Ditto. + (gfc_trans_zero_assign): Ditto. + (gfc_build_memcpy_call): Ditto. + (alloc_scalar_allocatable_for_assignment): Ditto. + * trans-array.c (gfc_trans_array_constructor_value): Ditto. + (duplicate_allocatable): Ditto. + (gfc_alloc_allocatable_for_assignment): Ditto. + * trans-openmp.c (gfc_omp_clause_copy_ctor): Ditto. + (gfc_omp_clause_assign_op): Ditto. + (gfc_trans_omp_atomic): Ditto. + (gfc_trans_omp_do): Ditto. + (gfc_trans_omp_task): Ditto. + * trans-stmt.c (gfc_trans_stop): Ditto. + (gfc_trans_sync): Ditto. + (gfc_trans_allocate): Ditto. + (gfc_trans_deallocate): Ditto. + * trans.c (gfc_call_malloc): Ditto. + (gfc_allocate_using_malloc): Ditto. + (gfc_call_free): Ditto. + (gfc_deallocate_with_status): Ditto. + (gfc_deallocate_scalar_with_status): 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. + 2011-10-10 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/50564 diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 8f8dd7d4c35..57c01148fff 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -639,7 +639,7 @@ gfc_builtin_function (tree decl) #define ATTR_CONST_NOTHROW_LIST (ECF_NOTHROW | ECF_CONST) static void -gfc_define_builtin (const char *name, tree type, int code, +gfc_define_builtin (const char *name, tree type, enum built_in_function code, const char *library_name, int attr) { tree decl; @@ -654,8 +654,7 @@ gfc_define_builtin (const char *name, tree type, int code, DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), NULL, DECL_ATTRIBUTES (decl)); - built_in_decls[code] = decl; - implicit_built_in_decls[code] = decl; + set_builtin_decl (code, decl, true); } @@ -1006,7 +1005,7 @@ gfc_init_builtin_functions (void) size_type_node, NULL_TREE); gfc_define_builtin ("__builtin_malloc", ftype, BUILT_IN_MALLOC, "malloc", ATTR_NOTHROW_LEAF_LIST); - DECL_IS_MALLOC (built_in_decls[BUILT_IN_MALLOC]) = 1; + DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_MALLOC)) = 1; ftype = build_function_type_list (pvoid_type_node, size_type_node, pvoid_type_node, @@ -1122,7 +1121,7 @@ gfc_init_builtin_functions (void) gfc_define_builtin ("__builtin_trap", builtin_types[BT_FN_VOID], BUILT_IN_TRAP, NULL, ATTR_NOTHROW_LEAF_LIST); - TREE_THIS_VOLATILE (built_in_decls[BUILT_IN_TRAP]) = 1; + TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1; gfc_define_builtin ("__emutls_get_address", builtin_types[BT_FN_PTR_PTR], diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index b7556704ca1..585dc438d63 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -1458,8 +1458,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)); bound = build_int_cst (size_type_node, n * size); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, - tmp, init, bound); + builtin_decl_explicit (BUILT_IN_MEMCPY), + 3, tmp, init, bound); gfc_add_expr_to_block (&body, tmp); *poffset = fold_build2_loc (input_location, PLUS_EXPR, @@ -6633,7 +6633,7 @@ duplicate_allocatable (tree dest, tree src, tree type, int rank, gfc_add_expr_to_block (&block, tmp); } - tmp = built_in_decls[BUILT_IN_MEMCPY]; + tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); tmp = build_call_expr_loc (input_location, tmp, 3, dest, src, size); } @@ -6657,7 +6657,7 @@ duplicate_allocatable (tree dest, tree src, tree type, int rank, /* We know the temporary and the value will be the same length, so can use memcpy. */ - tmp = built_in_decls[BUILT_IN_MEMCPY]; + tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); tmp = build_call_expr_loc (input_location, tmp, 3, gfc_conv_descriptor_data_get (dest), gfc_conv_descriptor_data_get (src), size); @@ -7413,7 +7413,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, in the array reference - (*desc.data)[<element>]. */ gfc_init_block (&realloc_block); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_REALLOC], 2, + builtin_decl_explicit (BUILT_IN_REALLOC), 2, fold_convert (pvoid_type_node, array1), size2); gfc_conv_descriptor_data_set (&realloc_block, @@ -7429,8 +7429,8 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, /* Malloc expression. */ gfc_init_block (&alloc_block); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MALLOC], 1, - size2); + builtin_decl_explicit (BUILT_IN_MALLOC), + 1, size2); gfc_conv_descriptor_data_set (&alloc_block, desc, tmp); tmp = gfc_conv_descriptor_dtype (desc); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 4526aaabb3a..b7460b779e2 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4989,7 +4989,7 @@ create_main_function (tree fndecl) { /* Per F2008, 8.5.1 END of the main program implies a SYNC MEMORY. */ - tmp = built_in_decls [BUILT_IN_SYNC_SYNCHRONIZE]; + tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); tmp = build_call_expr_loc (input_location, tmp, 0); gfc_add_expr_to_block (&body, tmp); diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 131927ce2a6..ca0523fedca 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1124,22 +1124,22 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) switch (kind) { case 0: - fndecl = built_in_decls[BUILT_IN_POWIF]; + fndecl = builtin_decl_explicit (BUILT_IN_POWIF); break; case 1: - fndecl = built_in_decls[BUILT_IN_POWI]; + fndecl = builtin_decl_explicit (BUILT_IN_POWI); break; case 2: - fndecl = built_in_decls[BUILT_IN_POWIL]; + fndecl = builtin_decl_explicit (BUILT_IN_POWIL); break; case 3: /* Use the __builtin_powil() only if real(kind=16) is actually the C long double type. */ if (!gfc_real16_is_float128) - fndecl = built_in_decls[BUILT_IN_POWIL]; + fndecl = builtin_decl_explicit (BUILT_IN_POWIL); break; default: @@ -3855,7 +3855,8 @@ fill_with_spaces (tree start, tree type, tree size) /* For a simple char type, we can call memset(). */ if (compare_tree_int (TYPE_SIZE_UNIT (type), 1) == 0) return build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMSET], 3, start, + builtin_decl_explicit (BUILT_IN_MEMSET), + 3, start, build_int_cst (gfc_get_int_type (gfc_c_int_kind), lang_hooks.to_target_charset (' ')), size); @@ -4015,13 +4016,13 @@ gfc_trans_string_copy (stmtblock_t * block, tree dlength, tree dest, cond2 = fold_build2_loc (input_location, GE_EXPR, boolean_type_node, slen, dlen); tmp2 = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMMOVE], - 3, dest, src, dlen); + builtin_decl_explicit (BUILT_IN_MEMMOVE), + 3, dest, src, dlen); /* Else copy and pad with spaces. */ tmp3 = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMMOVE], - 3, dest, src, slen); + builtin_decl_explicit (BUILT_IN_MEMMOVE), + 3, dest, src, slen); tmp4 = fold_build_pointer_plus_loc (input_location, dest, slen); tmp4 = fill_with_spaces (tmp4, chartype, @@ -5816,8 +5817,8 @@ gfc_trans_zero_assign (gfc_expr * expr) /* Construct call to __builtin_memset. */ tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMSET], - 3, dest, integer_zero_node, len); + builtin_decl_explicit (BUILT_IN_MEMSET), + 3, dest, integer_zero_node, len); return fold_convert (void_type_node, tmp); } @@ -5845,7 +5846,8 @@ gfc_build_memcpy_call (tree dst, tree src, tree len) /* Construct call to __builtin_memcpy. */ tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, dst, src, len); + builtin_decl_explicit (BUILT_IN_MEMCPY), + 3, dst, src, len); return fold_convert (void_type_node, tmp); } @@ -6056,8 +6058,8 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block, } tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MALLOC], 1, - size_in_bytes); + builtin_decl_explicit (BUILT_IN_MALLOC), + 1, size_in_bytes); tmp = fold_convert (TREE_TYPE (lse.expr), tmp); gfc_add_modify (block, lse.expr, tmp); if (expr1->ts.type == BT_CHARACTER && expr1->ts.deferred) @@ -6083,8 +6085,8 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block, build_empty_stmt (input_location)); gfc_add_expr_to_block (block, tmp); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_REALLOC], 2, - fold_convert (pvoid_type_node, lse.expr), + builtin_decl_explicit (BUILT_IN_REALLOC), + 2, fold_convert (pvoid_type_node, lse.expr), size_in_bytes); tmp = fold_convert (TREE_TYPE (lse.expr), tmp); gfc_add_modify (block, lse.expr, tmp); diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index c47e678dfa7..ed18bfa6bde 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -139,7 +139,7 @@ static tree builtin_decl_for_precision (enum built_in_function base_built_in, int precision) { - int i = END_BUILTINS; + enum built_in_function i = END_BUILTINS; gfc_intrinsic_map_t *m; for (m = gfc_intrinsic_map; m->double_built_in != base_built_in ; m++) @@ -158,7 +158,7 @@ builtin_decl_for_precision (enum built_in_function base_built_in, return m->real16_decl; } - return (i == END_BUILTINS ? NULL_TREE : built_in_decls[i]); + return (i == END_BUILTINS ? NULL_TREE : builtin_decl_explicit (i)); } @@ -679,26 +679,28 @@ gfc_build_intrinsic_lib_fndecls (void) m->id != GFC_ISYM_NONE || m->double_built_in != END_BUILTINS; m++) { if (m->float_built_in != END_BUILTINS) - m->real4_decl = built_in_decls[m->float_built_in]; + m->real4_decl = builtin_decl_explicit (m->float_built_in); if (m->complex_float_built_in != END_BUILTINS) - m->complex4_decl = built_in_decls[m->complex_float_built_in]; + m->complex4_decl = builtin_decl_explicit (m->complex_float_built_in); if (m->double_built_in != END_BUILTINS) - m->real8_decl = built_in_decls[m->double_built_in]; + m->real8_decl = builtin_decl_explicit (m->double_built_in); if (m->complex_double_built_in != END_BUILTINS) - m->complex8_decl = built_in_decls[m->complex_double_built_in]; + m->complex8_decl = builtin_decl_explicit (m->complex_double_built_in); /* If real(kind=10) exists, it is always long double. */ if (m->long_double_built_in != END_BUILTINS) - m->real10_decl = built_in_decls[m->long_double_built_in]; + m->real10_decl = builtin_decl_explicit (m->long_double_built_in); if (m->complex_long_double_built_in != END_BUILTINS) - m->complex10_decl = built_in_decls[m->complex_long_double_built_in]; + m->complex10_decl + = builtin_decl_explicit (m->complex_long_double_built_in); if (!gfc_real16_is_float128) { if (m->long_double_built_in != END_BUILTINS) - m->real16_decl = built_in_decls[m->long_double_built_in]; + m->real16_decl = builtin_decl_explicit (m->long_double_built_in); if (m->complex_long_double_built_in != END_BUILTINS) - m->complex16_decl = built_in_decls[m->complex_long_double_built_in]; + m->complex16_decl + = builtin_decl_explicit (m->complex_long_double_built_in); } else if (quad_decls[m->double_built_in] != NULL_TREE) { @@ -2210,7 +2212,8 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op) if (FLOAT_TYPE_P (TREE_TYPE (mvar))) { isnan = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_ISNAN], 1, mvar); + builtin_decl_explicit (BUILT_IN_ISNAN), + 1, mvar); tmp = fold_build2_loc (input_location, TRUTH_OR_EXPR, boolean_type_node, tmp, fold_convert (boolean_type_node, isnan)); @@ -4087,17 +4090,17 @@ gfc_conv_intrinsic_leadz (gfc_se * se, gfc_expr * expr) if (argsize <= INT_TYPE_SIZE) { arg_type = unsigned_type_node; - func = built_in_decls[BUILT_IN_CLZ]; + func = builtin_decl_explicit (BUILT_IN_CLZ); } else if (argsize <= LONG_TYPE_SIZE) { arg_type = long_unsigned_type_node; - func = built_in_decls[BUILT_IN_CLZL]; + func = builtin_decl_explicit (BUILT_IN_CLZL); } else if (argsize <= LONG_LONG_TYPE_SIZE) { arg_type = long_long_unsigned_type_node; - func = built_in_decls[BUILT_IN_CLZLL]; + func = builtin_decl_explicit (BUILT_IN_CLZLL); } else { @@ -4136,7 +4139,7 @@ gfc_conv_intrinsic_leadz (gfc_se * se, gfc_expr * expr) where ULL_MAX is the largest value that a ULL_MAX can hold (0xFFFFFFFFFFFFFFFF for a 64-bit long long type), and ULLSIZE is the bit-size of the long long type (64 in this example). */ - tree ullsize, ullmax, tmp1, tmp2; + tree ullsize, ullmax, tmp1, tmp2, btmp; ullsize = build_int_cst (result_type, LONG_LONG_TYPE_SIZE); ullmax = fold_build1_loc (input_location, BIT_NOT_EXPR, @@ -4154,16 +4157,14 @@ gfc_conv_intrinsic_leadz (gfc_se * se, gfc_expr * expr) tmp1 = fold_build2_loc (input_location, RSHIFT_EXPR, arg_type, arg, ullsize); tmp1 = fold_convert (long_long_unsigned_type_node, tmp1); + btmp = builtin_decl_explicit (BUILT_IN_CLZLL); tmp1 = fold_convert (result_type, - build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_CLZLL], - 1, tmp1)); + build_call_expr_loc (input_location, btmp, 1, tmp1)); tmp2 = fold_convert (long_long_unsigned_type_node, arg); + btmp = builtin_decl_explicit (BUILT_IN_CLZLL); tmp2 = fold_convert (result_type, - build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_CLZLL], - 1, tmp2)); + build_call_expr_loc (input_location, btmp, 1, tmp2)); tmp2 = fold_build2_loc (input_location, PLUS_EXPR, result_type, tmp2, ullsize); @@ -4206,17 +4207,17 @@ gfc_conv_intrinsic_trailz (gfc_se * se, gfc_expr *expr) if (argsize <= INT_TYPE_SIZE) { arg_type = unsigned_type_node; - func = built_in_decls[BUILT_IN_CTZ]; + func = builtin_decl_explicit (BUILT_IN_CTZ); } else if (argsize <= LONG_TYPE_SIZE) { arg_type = long_unsigned_type_node; - func = built_in_decls[BUILT_IN_CTZL]; + func = builtin_decl_explicit (BUILT_IN_CTZL); } else if (argsize <= LONG_LONG_TYPE_SIZE) { arg_type = long_long_unsigned_type_node; - func = built_in_decls[BUILT_IN_CTZLL]; + func = builtin_decl_explicit (BUILT_IN_CTZLL); } else { @@ -4250,7 +4251,7 @@ gfc_conv_intrinsic_trailz (gfc_se * se, gfc_expr *expr) where ULL_MAX is the largest value that a ULL_MAX can hold (0xFFFFFFFFFFFFFFFF for a 64-bit long long type), and ULLSIZE is the bit-size of the long long type (64 in this example). */ - tree ullsize, ullmax, tmp1, tmp2; + tree ullsize, ullmax, tmp1, tmp2, btmp; ullsize = build_int_cst (result_type, LONG_LONG_TYPE_SIZE); ullmax = fold_build1_loc (input_location, BIT_NOT_EXPR, @@ -4265,18 +4266,16 @@ gfc_conv_intrinsic_trailz (gfc_se * se, gfc_expr *expr) tmp1 = fold_build2_loc (input_location, RSHIFT_EXPR, arg_type, arg, ullsize); tmp1 = fold_convert (long_long_unsigned_type_node, tmp1); + btmp = builtin_decl_explicit (BUILT_IN_CTZLL); tmp1 = fold_convert (result_type, - build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_CTZLL], - 1, tmp1)); + build_call_expr_loc (input_location, btmp, 1, tmp1)); tmp1 = fold_build2_loc (input_location, PLUS_EXPR, result_type, tmp1, ullsize); tmp2 = fold_convert (long_long_unsigned_type_node, arg); + btmp = builtin_decl_explicit (BUILT_IN_CTZLL); tmp2 = fold_convert (result_type, - build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_CTZLL], - 1, tmp2)); + build_call_expr_loc (input_location, btmp, 1, tmp2)); trailz = fold_build3_loc (input_location, COND_EXPR, result_type, cond, tmp1, tmp2); @@ -4312,17 +4311,23 @@ gfc_conv_intrinsic_popcnt_poppar (gfc_se * se, gfc_expr *expr, int parity) if (argsize <= INT_TYPE_SIZE) { arg_type = unsigned_type_node; - func = built_in_decls[parity ? BUILT_IN_PARITY : BUILT_IN_POPCOUNT]; + func = builtin_decl_explicit (parity + ? BUILT_IN_PARITY + : BUILT_IN_POPCOUNT); } else if (argsize <= LONG_TYPE_SIZE) { arg_type = long_unsigned_type_node; - func = built_in_decls[parity ? BUILT_IN_PARITYL : BUILT_IN_POPCOUNTL]; + func = builtin_decl_explicit (parity + ? BUILT_IN_PARITYL + : BUILT_IN_POPCOUNTL); } else if (argsize <= LONG_LONG_TYPE_SIZE) { arg_type = long_long_unsigned_type_node; - func = built_in_decls[parity ? BUILT_IN_PARITYLL : BUILT_IN_POPCOUNTLL]; + func = builtin_decl_explicit (parity + ? BUILT_IN_PARITYLL + : BUILT_IN_POPCOUNTLL); } else { @@ -4335,7 +4340,9 @@ gfc_conv_intrinsic_popcnt_poppar (gfc_se * se, gfc_expr *expr, int parity) as 'long long'. */ gcc_assert (argsize == 2 * LONG_LONG_TYPE_SIZE); - func = built_in_decls[parity ? BUILT_IN_PARITYLL : BUILT_IN_POPCOUNTLL]; + func = builtin_decl_explicit (parity + ? BUILT_IN_PARITYLL + : BUILT_IN_POPCOUNTLL); /* Convert it to an integer, and store into a variable. */ utype = gfc_build_uint_type (argsize); @@ -4588,7 +4595,8 @@ gfc_conv_intrinsic_isnan (gfc_se * se, gfc_expr * expr) gfc_conv_intrinsic_function_args (se, expr, &arg, 1); se->expr = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_ISNAN], 1, arg); + builtin_decl_explicit (BUILT_IN_ISNAN), + 1, arg); STRIP_TYPE_NOPS (se->expr); se->expr = fold_convert (gfc_typenode_for_spec (&expr->ts), se->expr); } @@ -5498,7 +5506,7 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) /* Use memcpy to do the transfer. */ tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, tmp, fold_convert (pvoid_type_node, source), @@ -5543,7 +5551,7 @@ scalar_transfer: gfc_add_modify (&block, tmpdecl, fold_convert (TREE_TYPE (ptr), tmp)); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, fold_convert (pvoid_type_node, tmpdecl), fold_convert (pvoid_type_node, ptr), extent); @@ -5568,7 +5576,7 @@ scalar_transfer: /* Use memcpy to do the transfer. */ tmp = gfc_build_addr_expr (NULL_TREE, tmpdecl); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, fold_convert (pvoid_type_node, tmp), fold_convert (pvoid_type_node, ptr), extent); @@ -6009,7 +6017,8 @@ gfc_conv_intrinsic_repeat (gfc_se * se, gfc_expr * expr) tmp = fold_build_pointer_plus_loc (input_location, fold_convert (pvoid_type_node, dest), tmp); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMMOVE], 3, tmp, src, + builtin_decl_explicit (BUILT_IN_MEMMOVE), + 3, tmp, src, fold_build2_loc (input_location, MULT_EXPR, size_type_node, slen, fold_convert (size_type_node, diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index cfe8612dfc9..a41e97bdadf 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -249,7 +249,8 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) gfc_conv_descriptor_data_set (&cond_block, dest, ptr); call = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, ptr, + builtin_decl_explicit (BUILT_IN_MEMCPY), + 3, ptr, fold_convert (pvoid_type_node, gfc_conv_descriptor_data_get (src)), size); @@ -300,7 +301,7 @@ gfc_omp_clause_assign_op (tree clause ATTRIBUTE_UNUSED, tree dest, tree src) size, esize); size = gfc_evaluate_now (fold_convert (size_type_node, size), &block); call = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, fold_convert (pvoid_type_node, gfc_conv_descriptor_data_get (dest)), fold_convert (pvoid_type_node, @@ -1273,7 +1274,7 @@ gfc_trans_omp_atomic (gfc_code *code) static tree gfc_trans_omp_barrier (void) { - tree decl = built_in_decls [BUILT_IN_GOMP_BARRIER]; + tree decl = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER); return build_call_expr_loc (input_location, decl, 0); } @@ -1547,7 +1548,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, static tree gfc_trans_omp_flush (void) { - tree decl = built_in_decls [BUILT_IN_SYNC_SYNCHRONIZE]; + tree decl = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); return build_call_expr_loc (input_location, decl, 0); } @@ -1738,14 +1739,14 @@ gfc_trans_omp_task (gfc_code *code) static tree gfc_trans_omp_taskwait (void) { - tree decl = built_in_decls [BUILT_IN_GOMP_TASKWAIT]; + tree decl = builtin_decl_explicit (BUILT_IN_GOMP_TASKWAIT); return build_call_expr_loc (input_location, decl, 0); } static tree gfc_trans_omp_taskyield (void) { - tree decl = built_in_decls [BUILT_IN_GOMP_TASKYIELD]; + tree decl = builtin_decl_explicit (BUILT_IN_GOMP_TASKYIELD); return build_call_expr_loc (input_location, decl, 0); } diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 8e43f4de1e7..c71eeec400f 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -602,7 +602,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) if (gfc_option.coarray == GFC_FCOARRAY_LIB && !error_stop) { /* Per F2008, 8.5.1 STOP implies a SYNC MEMORY. */ - tmp = built_in_decls [BUILT_IN_SYNC_SYNCHRONIZE]; + tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); tmp = build_call_expr_loc (input_location, tmp, 0); gfc_add_expr_to_block (&se.pre, tmp); @@ -774,7 +774,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) image control statements SYNC IMAGES and SYNC ALL. */ if (gfc_option.coarray == GFC_FCOARRAY_LIB) { - tmp = built_in_decls [BUILT_IN_SYNC_SYNCHRONIZE]; + tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); tmp = build_call_expr_loc (input_location, tmp, 0); gfc_add_expr_to_block (&se.pre, tmp); } @@ -5076,7 +5076,7 @@ gfc_trans_allocate (gfc_code * code) slen); dlen = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, stat, @@ -5251,7 +5251,7 @@ gfc_trans_deallocate (gfc_code *code) slen); dlen = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MEMCPY], 3, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); tmp = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, astat, diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 764bdf42e45..0176aece2b8 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -512,7 +512,7 @@ gfc_trans_runtime_check (bool error, bool once, tree cond, stmtblock_t * pblock, tree gfc_call_malloc (stmtblock_t * block, tree type, tree size) { - tree tmp, msg, malloc_result, null_result, res; + tree tmp, msg, malloc_result, null_result, res, malloc_tree; stmtblock_t block2; size = gfc_evaluate_now (size, block); @@ -529,10 +529,11 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size) size = fold_build2_loc (input_location, MAX_EXPR, size_type_node, size, build_int_cst (size_type_node, 1)); + malloc_tree = builtin_decl_explicit (BUILT_IN_MALLOC); gfc_add_modify (&block2, res, fold_convert (prvoid_type_node, build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MALLOC], 1, size))); + malloc_tree, 1, size))); /* Optionally check whether malloc was successful. */ if (gfc_option.rtcheck & GFC_RTCHECK_MEM) @@ -604,7 +605,7 @@ gfc_allocate_using_malloc (stmtblock_t * block, tree pointer, gfc_add_modify (block, pointer, fold_convert (TREE_TYPE (pointer), build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_MALLOC], 1, + builtin_decl_explicit (BUILT_IN_MALLOC), 1, fold_build2_loc (input_location, MAX_EXPR, size_type_node, size, build_int_cst (size_type_node, 1))))); @@ -783,7 +784,8 @@ gfc_call_free (tree var) cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, var, build_int_cst (pvoid_type_node, 0)); call = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_FREE], 1, var); + builtin_decl_explicit (BUILT_IN_FREE), + 1, var); tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, call, build_empty_stmt (input_location)); gfc_add_expr_to_block (&block, tmp); @@ -871,8 +873,8 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail, /* When POINTER is not NULL, we free it. */ gfc_start_block (&non_null); tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_FREE], 1, - fold_convert (pvoid_type_node, pointer)); + builtin_decl_explicit (BUILT_IN_FREE), 1, + fold_convert (pvoid_type_node, pointer)); gfc_add_expr_to_block (&non_null, tmp); if (status != NULL_TREE && !integer_zerop (status)) @@ -968,8 +970,8 @@ gfc_deallocate_scalar_with_status (tree pointer, tree status, bool can_fail, } tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_FREE], 1, - fold_convert (pvoid_type_node, pointer)); + builtin_decl_explicit (BUILT_IN_FREE), 1, + fold_convert (pvoid_type_node, pointer)); gfc_add_expr_to_block (&non_null, tmp); if (status != NULL_TREE && !integer_zerop (status)) @@ -1026,7 +1028,7 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size) /* Call realloc and check the result. */ tmp = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_REALLOC], 2, + builtin_decl_explicit (BUILT_IN_REALLOC), 2, fold_convert (pvoid_type_node, mem), size); gfc_add_modify (block, res, fold_convert (type, tmp)); null_result = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, @@ -1593,7 +1595,8 @@ gfc_unlikely (tree cond) cond = fold_convert (long_integer_type_node, cond); tmp = build_zero_cst (long_integer_type_node); cond = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); + builtin_decl_explicit (BUILT_IN_EXPECT), + 2, cond, tmp); cond = fold_convert (boolean_type_node, cond); return cond; } @@ -1609,7 +1612,8 @@ gfc_likely (tree cond) cond = fold_convert (long_integer_type_node, cond); tmp = build_one_cst (long_integer_type_node); cond = build_call_expr_loc (input_location, - built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); + builtin_decl_explicit (BUILT_IN_EXPECT), + 2, cond, tmp); cond = fold_convert (boolean_type_node, cond); return cond; } diff --git a/gcc/function.c b/gcc/function.c index ae9b535550d..c5ede62ca06 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3635,7 +3635,7 @@ gimplify_parameters (void) DECL_IGNORED_P (addr) = 0; local = build_fold_indirect_ref (addr); - t = built_in_decls[BUILT_IN_ALLOCA_WITH_ALIGN]; + t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN); t = build_call_expr (t, 1, DECL_SIZE_UNIT (parm), size_int (DECL_ALIGN (parm))); diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index 5c05f842c4c..fd03ba4702b 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -169,7 +169,7 @@ lower_function_body (void) and insert. */ disp_var = create_tmp_var (ptr_type_node, "setjmpvar"); arg = build_addr (disp_label, current_function_decl); - t = implicit_built_in_decls[BUILT_IN_SETJMP_DISPATCHER]; + t = builtin_decl_implicit (BUILT_IN_SETJMP_DISPATCHER); x = gimple_build_call (t, 1, arg); gimple_call_set_lhs (x, disp_var); @@ -861,7 +861,7 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) /* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert. */ arg = build_addr (next_label, current_function_decl); - t = implicit_built_in_decls[BUILT_IN_SETJMP_SETUP]; + t = builtin_decl_implicit (BUILT_IN_SETJMP_SETUP); g = gimple_build_call (t, 2, gimple_call_arg (stmt, 0), arg); gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); @@ -886,7 +886,7 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) /* Build '__builtin_setjmp_receiver (NEXT_LABEL)' and insert. */ arg = build_addr (next_label, current_function_decl); - t = implicit_built_in_decls[BUILT_IN_SETJMP_RECEIVER]; + t = builtin_decl_implicit (BUILT_IN_SETJMP_RECEIVER); g = gimple_build_call (t, 1, arg); gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 9713218fa10..2c9ba1d78aa 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1109,12 +1109,12 @@ build_stack_save_restore (gimple *save, gimple *restore) { tree tmp_var; - *save = gimple_build_call (implicit_built_in_decls[BUILT_IN_STACK_SAVE], 0); + *save = gimple_build_call (builtin_decl_implicit (BUILT_IN_STACK_SAVE), 0); tmp_var = create_tmp_var (ptr_type_node, "saved_stack"); gimple_call_set_lhs (*save, tmp_var); *restore - = gimple_build_call (implicit_built_in_decls[BUILT_IN_STACK_RESTORE], + = gimple_build_call (builtin_decl_implicit (BUILT_IN_STACK_RESTORE), 1, tmp_var); } @@ -1329,7 +1329,7 @@ gimplify_vla_decl (tree decl, gimple_seq *seq_p) SET_DECL_VALUE_EXPR (decl, t); DECL_HAS_VALUE_EXPR_P (decl) = 1; - t = built_in_decls[BUILT_IN_ALLOCA_WITH_ALIGN]; + t = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN); t = build_call_expr (t, 2, DECL_SIZE_UNIT (decl), size_int (DECL_ALIGN (decl))); /* The call has been built for a variable-sized object. */ @@ -3211,7 +3211,7 @@ gimplify_modify_expr_to_memcpy (tree *expr_p, tree size, bool want_value, to_ptr = build_fold_addr_expr_loc (loc, to); gimplify_arg (&to_ptr, seq_p, loc); - t = implicit_built_in_decls[BUILT_IN_MEMCPY]; + t = builtin_decl_implicit (BUILT_IN_MEMCPY); gs = gimple_build_call (t, 3, to_ptr, from_ptr, size); @@ -3258,7 +3258,7 @@ gimplify_modify_expr_to_memset (tree *expr_p, tree size, bool want_value, to_ptr = build_fold_addr_expr_loc (loc, to); gimplify_arg (&to_ptr, seq_p, loc); - t = implicit_built_in_decls[BUILT_IN_MEMSET]; + t = builtin_decl_implicit (BUILT_IN_MEMSET); gs = gimple_build_call (t, 3, to_ptr, integer_zero_node, size); @@ -4681,7 +4681,7 @@ gimplify_variable_sized_compare (tree *expr_p) arg = SUBSTITUTE_PLACEHOLDER_IN_EXPR (arg, op0); src = build_fold_addr_expr_loc (loc, op1); dest = build_fold_addr_expr_loc (loc, op0); - t = implicit_built_in_decls[BUILT_IN_MEMCMP]; + t = builtin_decl_implicit (BUILT_IN_MEMCMP); t = build_call_expr_loc (loc, t, 3, dest, src, arg); expr @@ -7980,24 +7980,24 @@ gimplify_function_tree (tree fndecl) tree tmp_var; gimple call; - x = implicit_built_in_decls[BUILT_IN_RETURN_ADDRESS]; + x = builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS); call = gimple_build_call (x, 1, integer_zero_node); tmp_var = create_tmp_var (ptr_type_node, "return_addr"); gimple_call_set_lhs (call, tmp_var); gimplify_seq_add_stmt (&cleanup, call); - x = implicit_built_in_decls[BUILT_IN_PROFILE_FUNC_EXIT]; + x = builtin_decl_implicit (BUILT_IN_PROFILE_FUNC_EXIT); call = gimple_build_call (x, 2, build_fold_addr_expr (current_function_decl), tmp_var); gimplify_seq_add_stmt (&cleanup, call); tf = gimple_build_try (seq, cleanup, GIMPLE_TRY_FINALLY); - x = implicit_built_in_decls[BUILT_IN_RETURN_ADDRESS]; + x = builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS); call = gimple_build_call (x, 1, integer_zero_node); tmp_var = create_tmp_var (ptr_type_node, "return_addr"); gimple_call_set_lhs (call, tmp_var); gimplify_seq_add_stmt (&body, call); - x = implicit_built_in_decls[BUILT_IN_PROFILE_FUNC_ENTER]; + x = builtin_decl_implicit (BUILT_IN_PROFILE_FUNC_ENTER); call = gimple_build_call (x, 2, build_fold_addr_expr (current_function_decl), tmp_var); diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 3802fa8e463..db0fdb31b9b 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,13 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * gofrontend/gogo-tree.cc (define_builtin): Delete old interface + with two parallel arrays to hold standard builtin declarations, + and replace it with a function based interface that can support + creating builtins on the fly in the future. Change all uses, and + poison the old names. Make sure 0 is not a legitimate builtin + index. + (Gogo::make_trampoline(tree): Ditto. + 2011-08-24 Roberto Lublinerman <rluble@gmail.com> * lang.opt: Add fgo-optimize-. diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index 49a0ba40bbd..6cfc0124604 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -69,8 +69,7 @@ define_builtin(built_in_function bcode, const char* name, const char* libname, libname, NULL_TREE); if (const_p) TREE_READONLY(decl) = 1; - built_in_decls[bcode] = decl; - implicit_built_in_decls[bcode] = decl; + set_builtin_decl (bcode, decl, true); builtin_functions[name] = decl; if (libname != NULL) { @@ -2311,14 +2310,13 @@ Gogo::make_trampoline(tree fnaddr, tree closure, source_location location) x = save_expr(x); // Initialize the trampoline. - tree ini = build_call_expr(implicit_built_in_decls[BUILT_IN_INIT_TRAMPOLINE], + tree ini = build_call_expr(builtin_decl_implicit(BUILT_IN_INIT_TRAMPOLINE), 3, x, fnaddr, closure); // On some targets the trampoline address needs to be adjusted. For // example, when compiling in Thumb mode on the ARM, the address // needs to have the low bit set. - x = build_call_expr(implicit_built_in_decls[BUILT_IN_ADJUST_TRAMPOLINE], - 1, x); + x = build_call_expr(builtin_decl_explicit(BUILT_IN_ADJUST_TRAMPOLINE), 1, x); x = fold_convert(TREE_TYPE(fnaddr), x); return build2(COMPOUND_EXPR, TREE_TYPE(x), ini, x); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 5f14cd8787f..dfb6500541c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,19 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * class.c (build_static_field_ref): Delete old interface with two + parallel arrays to hold standard builtin declarations, and replace + it with a function based interface that can support creating + builtins on the fly in the future. Change all uses, and poison + the old names. Make sure 0 is not a legitimate builtin index. + * decl.c (java_init_decl_processing): Ditto. + * except.c (compareAndSwapLong_builtin): Ditto. + (compareAndSwapObject_builtin): Ditto. + (putVolatile_builtin): Ditto. + (define_builtin): Ditto. + (check_for_builtin): Ditto. + * expr.c (rewrite_arglist_getcaller): Ditto. + (expand_java_field_op): Ditto. + 2011-08-24 Joseph Myers <joseph@codesourcery.com> * Make-lang.in (CFLAGS-java/jcf-io.o, CFLAGS-java/jcf-path.o): diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 1e94bcab4d2..5ab345dc472 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -324,13 +324,13 @@ compareAndSwapInt_builtin (tree method_return_type ATTRIBUTE_UNUSED, || flag_use_atomic_builtins) { tree addr, stmt; + enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4; UNMARSHAL5 (orig_call); (void) value_type; /* Avoid set but not used warning. */ addr = build_addr_sum (int_type_node, obj_arg, offset_arg); - stmt = build_call_expr - (built_in_decls[BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4], - 3, addr, expected_arg, value_arg); + stmt = build_call_expr (builtin_decl_explicit (fncode), + 3, addr, expected_arg, value_arg); return build_check_this (stmt, this_arg); } @@ -351,13 +351,13 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED, but not the multi-word versions. */ { tree addr, stmt; + enum built_in_function fncode = BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8; UNMARSHAL5 (orig_call); (void) value_type; /* Avoid set but not used warning. */ addr = build_addr_sum (long_type_node, obj_arg, offset_arg); - stmt = build_call_expr - (built_in_decls[BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8], - 3, addr, expected_arg, value_arg); + stmt = build_call_expr (builtin_decl_explicit (fncode), + 3, addr, expected_arg, value_arg); return build_check_this (stmt, this_arg); } @@ -373,7 +373,7 @@ compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, || flag_use_atomic_builtins) { tree addr, stmt; - int builtin; + enum built_in_function builtin; UNMARSHAL5 (orig_call); builtin = (POINTER_SIZE == 32 @@ -381,7 +381,7 @@ compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, : BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8); addr = build_addr_sum (value_type, obj_arg, offset_arg); - stmt = build_call_expr (built_in_decls[builtin], + stmt = build_call_expr (builtin_decl_explicit (builtin), 3, addr, expected_arg, value_arg); return build_check_this (stmt, this_arg); @@ -401,7 +401,7 @@ putVolatile_builtin (tree method_return_type ATTRIBUTE_UNUSED, = fold_convert (build_pointer_type (build_type_variant (value_type, 0, 1)), addr); - stmt = build_call_expr (built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE], 0); + stmt = build_call_expr (builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE), 0); modify_stmt = fold_build2 (MODIFY_EXPR, value_type, build_java_indirect_ref (value_type, addr, flag_check_references), @@ -425,8 +425,7 @@ getVolatile_builtin (tree method_return_type ATTRIBUTE_UNUSED, = fold_convert (build_pointer_type (build_type_variant (method_return_type, 0, 1)), addr); - stmt = build_call_expr (built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE], 0); - + stmt = build_call_expr (builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE), 0); tmp = build_decl (BUILTINS_LOCATION, VAR_DECL, NULL, method_return_type); DECL_IGNORED_P (tmp) = 1; DECL_ARTIFICIAL (tmp) = 1; @@ -483,8 +482,7 @@ define_builtin (enum built_in_function val, if (flags & BUILTIN_CONST) TREE_READONLY (decl) = 1; - implicit_built_in_decls[val] = decl; - built_in_decls[val] = decl; + set_builtin_decl (val, decl, true); } @@ -627,7 +625,7 @@ check_for_builtin (tree method, tree call) with the BC-ABI. */ if (flag_indirect_dispatch) return call; - fn = built_in_decls[java_builtins[i].builtin_code]; + fn = builtin_decl_explicit (java_builtins[i].builtin_code); if (fn == NULL_TREE) return call; return java_build_function_call_expr (fn, call); diff --git a/gcc/java/class.c b/gcc/java/class.c index 3bb5ff44f6e..ac69319349a 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1266,7 +1266,7 @@ build_static_field_ref (tree fdecl) int cpool_index = alloc_constant_fieldref (output_class, fdecl); tree cache_entry = build_fieldref_cache_entry (cpool_index, fdecl); tree test - = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, + = build_call_expr (builtin_decl_implicit (BUILT_IN_EXPECT), 2, build2 (EQ_EXPR, boolean_type_node, cache_entry, null_pointer_node), boolean_false_node); diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 179a2c3e9aa..1e1db76dc3b 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1135,7 +1135,7 @@ java_init_decl_processing (void) initialize_builtins (); - soft_fmod_node = built_in_decls[BUILT_IN_FMOD]; + soft_fmod_node = builtin_decl_explicit (BUILT_IN_FMOD); parse_version (); } diff --git a/gcc/java/except.c b/gcc/java/except.c index f5e5bb9e664..ff9a1063e37 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -520,8 +520,8 @@ expand_end_java_handler (struct eh_range *range) type = throwable_type_node; eh_type = prepare_eh_table_type (type); - x = build_call_expr (built_in_decls[BUILT_IN_EH_POINTER], - 1, integer_zero_node); + x = build_call_expr (builtin_decl_explicit (BUILT_IN_EH_POINTER), + 1, integer_zero_node); x = build2 (MODIFY_EXPR, void_type_node, exc_obj, x); tsi_link_after (&stmts_i, x, TSI_CONTINUE_LINKING); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index ec2d9b65d0a..d38311726d3 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -2073,7 +2073,7 @@ static void rewrite_arglist_getcaller (VEC(tree,gc) **arglist) { tree retaddr - = build_call_expr (built_in_decls[BUILT_IN_RETURN_ADDRESS], + = build_call_expr (builtin_decl_explicit (BUILT_IN_RETURN_ADDRESS), 1, integer_zero_node); DECL_UNINLINABLE (current_function_decl) = 1; @@ -2933,8 +2933,10 @@ expand_java_field_op (int is_static, int is_putting, int field_ref_index) field_ref, new_value); if (TREE_THIS_VOLATILE (field_decl)) - java_add_stmt - (build_call_expr (built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE], 0)); + { + tree sync = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); + java_add_stmt (build_call_expr (sync, 0)); + } java_add_stmt (modify_expr); } @@ -2952,8 +2954,10 @@ expand_java_field_op (int is_static, int is_putting, int field_ref_index) java_add_stmt (modify_expr); if (TREE_THIS_VOLATILE (field_decl)) - java_add_stmt - (build_call_expr (built_in_decls[BUILT_IN_SYNC_SYNCHRONIZE], 0)); + { + tree sync = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); + java_add_stmt (build_call_expr (sync, 0)); + } push_value (temp); } diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 1f203a1a1b3..e350fd83b05 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,11 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * lto-lang.c (def_builtin_1): Delete old interface with two + parallel arrays to hold standard builtin declarations, and replace + it with a function based interface that can support creating + builtins on the fly in the future. Change all uses, and poison + the old names. Make sure 0 is not a legitimate builtin index. + 2011-10-02 Andi Kleen <ak@linux.intel.com> * lto-object.c (lto_obj_add_section_data): Add list. diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index d469fb93b6a..4a5f6fe8ab5 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -499,9 +499,7 @@ def_builtin_1 (enum built_in_function fncode, const char *name, add_builtin_function (libname, libtype, fncode, fnclass, NULL, fnattrs); - built_in_decls[(int) fncode] = decl; - if (implicit_p) - implicit_built_in_decls[(int) fncode] = decl; + set_builtin_decl (fncode, decl, implicit_p); } diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index c31ba7fb6a6..e195ed5dd1b 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,14 @@ +2011-10-11 Michael Meissner <meissner@linux.vnet.ibm.com> + + * objc-next-runtime-abi-01.c (objc_build_exc_ptr): Delete old + interface with two parallel arrays to hold standard builtin + declarations, and replace it with a function based interface that + can support creating builtins on the fly in the future. Change + all uses, and poison the old names. Make sure 0 is not a + legitimate builtin index. + * objc-next-runtime-abi-02.c (objc_build_exc_ptr): Ditto. + * objc-gnu-runtime-abi-01.c (objc_build_exc_ptr): Ditto. + 2011-07-19 Richard Guenther <rguenther@suse.de> * objc-next-runtime-abi-02.c (objc_v2_build_ivar_ref): diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index fef5355c6a6..f136828f60a 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -2226,7 +2226,7 @@ static tree objc_build_exc_ptr (struct objc_try_context **x ATTRIBUTE_UNUSED) { tree t; - t = built_in_decls[BUILT_IN_EH_POINTER]; + t = builtin_decl_explicit (BUILT_IN_EH_POINTER); t = build_call_expr (t, 1, integer_zero_node); return fold_convert (objc_object_type, t); } diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 6183a21e5e8..c1e60b392d5 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -2919,7 +2919,7 @@ objc_build_exc_ptr (struct objc_try_context **cur_try_context) else { tree t; - t = built_in_decls[BUILT_IN_EH_POINTER]; + t = builtin_decl_explicit (BUILT_IN_EH_POINTER); t = build_call_expr (t, 1, integer_zero_node); return fold_convert (objc_object_type, t); } diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 9ef08f01576..56df2afaf0c 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -3676,7 +3676,7 @@ static tree objc_build_exc_ptr (struct objc_try_context **x ATTRIBUTE_UNUSED) { tree t; - t = built_in_decls[BUILT_IN_EH_POINTER]; + t = builtin_decl_explicit (BUILT_IN_EH_POINTER); t = build_call_expr (t, 1, integer_zero_node); return fold_convert (objc_object_type, t); } diff --git a/gcc/omp-low.c b/gcc/omp-low.c index fbbef9c785c..05a3493e95f 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2059,7 +2059,7 @@ scan_omp (gimple_seq body, omp_context *ctx) static tree build_omp_barrier (void) { - return build_call_expr (built_in_decls[BUILT_IN_GOMP_BARRIER], 0); + return build_call_expr (builtin_decl_explicit (BUILT_IN_GOMP_BARRIER), 0); } /* If a context was created for STMT when it was scanned, return it. */ @@ -2300,7 +2300,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (c_kind != OMP_CLAUSE_FIRSTPRIVATE || !is_task_ctx (ctx)) { gimple stmt; - tree tmp; + tree tmp, atmp; ptr = DECL_VALUE_EXPR (new_var); gcc_assert (TREE_CODE (ptr) == INDIRECT_REF); @@ -2309,8 +2309,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, x = TYPE_SIZE_UNIT (TREE_TYPE (new_var)); /* void *tmp = __builtin_alloca */ - stmt - = gimple_build_call (built_in_decls[BUILT_IN_ALLOCA], 1, x); + atmp = builtin_decl_explicit (BUILT_IN_ALLOCA); + stmt = gimple_build_call (atmp, 1, x); tmp = create_tmp_var_raw (ptr_type_node, NULL); gimple_add_tmp_var (tmp); gimple_call_set_lhs (stmt, tmp); @@ -2354,8 +2354,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, } else { - x = build_call_expr_loc (clause_loc, - built_in_decls[BUILT_IN_ALLOCA], 1, x); + tree atmp = builtin_decl_explicit (BUILT_IN_ALLOCA); + x = build_call_expr_loc (clause_loc, atmp, 1, x); } x = fold_convert_loc (clause_loc, TREE_TYPE (new_var), x); @@ -2493,7 +2493,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, but it certainly is to C++ operator=. */ if (copyin_seq) { - x = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); + x = build_call_expr (builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM), + 0); x = build2 (NE_EXPR, boolean_type_node, x, build_int_cst (TREE_TYPE (x), 0)); x = build3 (COND_EXPR, void_type_node, x, copyin_seq, NULL); @@ -2688,12 +2689,14 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) } } - stmt = gimple_build_call (built_in_decls[BUILT_IN_GOMP_ATOMIC_START], 0); + stmt = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ATOMIC_START), + 0); gimple_seq_add_stmt (stmt_seqp, stmt); gimple_seq_add_seq (stmt_seqp, sub_seq); - stmt = gimple_build_call (built_in_decls[BUILT_IN_GOMP_ATOMIC_END], 0); + stmt = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ATOMIC_END), + 0); gimple_seq_add_stmt (stmt_seqp, stmt); } @@ -2917,7 +2920,8 @@ expand_parallel_call (struct omp_region *region, basic_block bb, tree t, t1, t2, val, cond, c, clauses; gimple_stmt_iterator gsi; gimple stmt; - int start_ix; + enum built_in_function start_ix; + int start_ix2; location_t clause_loc; VEC(tree,gc) *args; @@ -2932,10 +2936,11 @@ expand_parallel_call (struct omp_region *region, basic_block bb, { case GIMPLE_OMP_FOR: gcc_assert (region->inner->sched_kind != OMP_CLAUSE_SCHEDULE_AUTO); - start_ix = BUILT_IN_GOMP_PARALLEL_LOOP_STATIC_START - + (region->inner->sched_kind - == OMP_CLAUSE_SCHEDULE_RUNTIME - ? 3 : region->inner->sched_kind); + start_ix2 = ((int)BUILT_IN_GOMP_PARALLEL_LOOP_STATIC_START + + (region->inner->sched_kind + == OMP_CLAUSE_SCHEDULE_RUNTIME + ? 3 : region->inner->sched_kind)); + start_ix = (enum built_in_function)start_ix2; break; case GIMPLE_OMP_SECTIONS: start_ix = BUILT_IN_GOMP_PARALLEL_SECTIONS_START; @@ -3057,7 +3062,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb, VEC_splice (tree, args, ws_args); t = build_call_expr_loc_vec (UNKNOWN_LOCATION, - built_in_decls[start_ix], args); + builtin_decl_explicit (start_ix), args); force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); @@ -3073,7 +3078,8 @@ expand_parallel_call (struct omp_region *region, basic_block bb, false, GSI_CONTINUE_LINKING); t = build_call_expr_loc (gimple_location (entry_stmt), - built_in_decls[BUILT_IN_GOMP_PARALLEL_END], 0); + builtin_decl_explicit (BUILT_IN_GOMP_PARALLEL_END), + 0); force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); } @@ -3125,7 +3131,8 @@ expand_task_call (basic_block bb, gimple entry_stmt) else t3 = build_fold_addr_expr_loc (loc, t); - t = build_call_expr (built_in_decls[BUILT_IN_GOMP_TASK], 7, t1, t2, t3, + t = build_call_expr (builtin_decl_explicit (BUILT_IN_GOMP_TASK), + 7, t1, t2, t3, gimple_omp_task_arg_size (entry_stmt), gimple_omp_task_arg_align (entry_stmt), cond, flags); @@ -3150,7 +3157,7 @@ maybe_catch_exception (gimple_seq body) if (lang_hooks.eh_protect_cleanup_actions != NULL) decl = lang_hooks.eh_protect_cleanup_actions (); else - decl = built_in_decls[BUILT_IN_TRAP]; + decl = builtin_decl_explicit (BUILT_IN_TRAP); g = gimple_build_eh_must_not_throw (decl); g = gimple_build_try (body, gimple_seq_alloc_with_stmt (g), @@ -3297,10 +3304,10 @@ optimize_omp_library_calls (gimple entry_stmt) { basic_block bb; gimple_stmt_iterator gsi; - tree thr_num_id - = DECL_ASSEMBLER_NAME (built_in_decls [BUILT_IN_OMP_GET_THREAD_NUM]); - tree num_thr_id - = DECL_ASSEMBLER_NAME (built_in_decls [BUILT_IN_OMP_GET_NUM_THREADS]); + tree thr_num_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM); + tree thr_num_id = DECL_ASSEMBLER_NAME (thr_num_tree); + tree num_thr_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS); + tree num_thr_id = DECL_ASSEMBLER_NAME (num_thr_tree); bool untied_task = (gimple_code (entry_stmt) == GIMPLE_OMP_TASK && find_omp_clause (gimple_omp_task_clauses (entry_stmt), OMP_CLAUSE_UNTIED) != NULL); @@ -3325,10 +3332,10 @@ optimize_omp_library_calls (gimple entry_stmt) during the execution of the task region. */ if (untied_task) continue; - built_in = built_in_decls [BUILT_IN_OMP_GET_THREAD_NUM]; + built_in = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM); } else if (DECL_NAME (decl) == num_thr_id) - built_in = built_in_decls [BUILT_IN_OMP_GET_NUM_THREADS]; + built_in = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS); else continue; @@ -3812,7 +3819,7 @@ expand_omp_for_generic (struct omp_region *region, { /* In a combined parallel loop, emit a call to GOMP_loop_foo_next. */ - t = build_call_expr (built_in_decls[next_fn], 2, + t = build_call_expr (builtin_decl_explicit (next_fn), 2, build_fold_addr_expr (istart0), build_fold_addr_expr (iend0)); } @@ -3848,34 +3855,36 @@ expand_omp_for_generic (struct omp_region *region, if (fd->chunk_size) { t = fold_convert (fd->iter_type, fd->chunk_size); - t = build_call_expr (built_in_decls[start_fn], 6, - t0, t1, t2, t, t3, t4); + t = build_call_expr (builtin_decl_explicit (start_fn), + 6, t0, t1, t2, t, t3, t4); } else - t = build_call_expr (built_in_decls[start_fn], 5, - t0, t1, t2, t3, t4); + t = build_call_expr (builtin_decl_explicit (start_fn), + 5, t0, t1, t2, t3, t4); } else { tree t5; tree c_bool_type; + tree bfn_decl; /* The GOMP_loop_ull_*start functions have additional boolean argument, true for < loops and false for > loops. In Fortran, the C bool type can be different from boolean_type_node. */ - c_bool_type = TREE_TYPE (TREE_TYPE (built_in_decls[start_fn])); + bfn_decl = builtin_decl_explicit (start_fn); + c_bool_type = TREE_TYPE (TREE_TYPE (bfn_decl)); t5 = build_int_cst (c_bool_type, fd->loop.cond_code == LT_EXPR ? 1 : 0); if (fd->chunk_size) { + tree bfn_decl = builtin_decl_explicit (start_fn); t = fold_convert (fd->iter_type, fd->chunk_size); - t = build_call_expr (built_in_decls[start_fn], 7, - t5, t0, t1, t2, t, t3, t4); + t = build_call_expr (bfn_decl, 7, t5, t0, t1, t2, t, t3, t4); } else - t = build_call_expr (built_in_decls[start_fn], 6, - t5, t0, t1, t2, t3, t4); + t = build_call_expr (builtin_decl_explicit (start_fn), + 6, t5, t0, t1, t2, t3, t4); } } if (TREE_TYPE (t) != boolean_type_node) @@ -4031,7 +4040,7 @@ expand_omp_for_generic (struct omp_region *region, /* Emit code to get the next parallel iteration in L2_BB. */ gsi = gsi_start_bb (l2_bb); - t = build_call_expr (built_in_decls[next_fn], 2, + t = build_call_expr (builtin_decl_explicit (next_fn), 2, build_fold_addr_expr (istart0), build_fold_addr_expr (iend0)); t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, @@ -4046,9 +4055,9 @@ expand_omp_for_generic (struct omp_region *region, /* Add the loop cleanup function. */ gsi = gsi_last_bb (exit_bb); if (gimple_omp_return_nowait_p (gsi_stmt (gsi))) - t = built_in_decls[BUILT_IN_GOMP_LOOP_END_NOWAIT]; + t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT); else - t = built_in_decls[BUILT_IN_GOMP_LOOP_END]; + t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END); stmt = gimple_build_call (t, 0); gsi_insert_after (&gsi, stmt, GSI_SAME_STMT); gsi_remove (&gsi, true); @@ -4169,12 +4178,12 @@ expand_omp_for_static_nochunk (struct omp_region *region, gsi = gsi_last_bb (entry_bb); gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_FOR); - t = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_NUM_THREADS], 0); + t = build_call_expr (builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS), 0); t = fold_convert (itype, t); nthreads = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT); - t = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); + t = build_call_expr (builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM), 0); t = fold_convert (itype, t); threadid = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT); @@ -4391,12 +4400,12 @@ expand_omp_for_static_chunk (struct omp_region *region, struct omp_for_data *fd) si = gsi_last_bb (entry_bb); gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_FOR); - t = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_NUM_THREADS], 0); + t = build_call_expr (builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS), 0); t = fold_convert (itype, t); nthreads = force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); - t = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); + t = build_call_expr (builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM), 0); t = fold_convert (itype, t); threadid = force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); @@ -4658,14 +4667,14 @@ expand_omp_for (struct omp_region *region) fn_index = (fd.sched_kind == OMP_CLAUSE_SCHEDULE_RUNTIME) ? 3 : fd.sched_kind; fn_index += fd.have_ordered * 4; - start_ix = BUILT_IN_GOMP_LOOP_STATIC_START + fn_index; - next_ix = BUILT_IN_GOMP_LOOP_STATIC_NEXT + fn_index; + start_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_START) + fn_index; + next_ix = ((int)BUILT_IN_GOMP_LOOP_STATIC_NEXT) + fn_index; if (fd.iter_type == long_long_unsigned_type_node) { - start_ix += BUILT_IN_GOMP_LOOP_ULL_STATIC_START - - BUILT_IN_GOMP_LOOP_STATIC_START; - next_ix += BUILT_IN_GOMP_LOOP_ULL_STATIC_NEXT - - BUILT_IN_GOMP_LOOP_STATIC_NEXT; + start_ix += ((int)BUILT_IN_GOMP_LOOP_ULL_STATIC_START + - (int)BUILT_IN_GOMP_LOOP_STATIC_START); + next_ix += ((int)BUILT_IN_GOMP_LOOP_ULL_STATIC_NEXT + - (int)BUILT_IN_GOMP_LOOP_STATIC_NEXT); } expand_omp_for_generic (region, &fd, (enum built_in_function) start_ix, (enum built_in_function) next_ix); @@ -4778,13 +4787,13 @@ expand_omp_sections (struct omp_region *region) call GOMP_sections_start. */ t = build_int_cst (unsigned_type_node, exit_reachable ? len - 1 : len); - u = built_in_decls[BUILT_IN_GOMP_SECTIONS_START]; + u = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_START); stmt = gimple_build_call (u, 1, t); } else { /* Otherwise, call GOMP_sections_next. */ - u = built_in_decls[BUILT_IN_GOMP_SECTIONS_NEXT]; + u = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_NEXT); stmt = gimple_build_call (u, 0); } gimple_call_set_lhs (stmt, vin); @@ -4866,16 +4875,19 @@ expand_omp_sections (struct omp_region *region) VEC_free (tree, heap, label_vec); si = gsi_start_bb (default_bb); - stmt = gimple_build_call (built_in_decls[BUILT_IN_TRAP], 0); + stmt = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0); gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING); if (exit_reachable) { + tree bfn_decl; + /* Code to get the next section goes in L1_BB. */ si = gsi_last_bb (l1_bb); gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_CONTINUE); - stmt = gimple_build_call (built_in_decls[BUILT_IN_GOMP_SECTIONS_NEXT], 0); + bfn_decl = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_NEXT); + stmt = gimple_build_call (bfn_decl, 0); gimple_call_set_lhs (stmt, vnext); gsi_insert_after (&si, stmt, GSI_SAME_STMT); gsi_remove (&si, true); @@ -4885,9 +4897,9 @@ expand_omp_sections (struct omp_region *region) /* Cleanup function replaces GIMPLE_OMP_RETURN in EXIT_BB. */ si = gsi_last_bb (l2_bb); if (gimple_omp_return_nowait_p (gsi_stmt (si))) - t = built_in_decls[BUILT_IN_GOMP_SECTIONS_END_NOWAIT]; + t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END_NOWAIT); else - t = built_in_decls[BUILT_IN_GOMP_SECTIONS_END]; + t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END); stmt = gimple_build_call (t, 0); gsi_insert_after (&si, stmt, GSI_SAME_STMT); gsi_remove (&si, true); @@ -4995,7 +5007,7 @@ expand_omp_atomic_fetch_op (basic_block load_bb, tree addr, tree loaded_val, tree stored_val, int index) { - enum built_in_function oldbase, newbase; + enum built_in_function oldbase, newbase, tmpbase; tree decl, itype, call; direct_optab optab, oldoptab, newoptab; tree lhs, rhs; @@ -5085,7 +5097,9 @@ expand_omp_atomic_fetch_op (basic_block load_bb, else return false; - decl = built_in_decls[(need_new ? newbase : oldbase) + index + 1]; + tmpbase = ((enum built_in_function) + ((need_new ? newbase : oldbase) + index + 1)); + decl = builtin_decl_explicit (tmpbase); if (decl == NULL_TREE) return false; itype = TREE_TYPE (TREE_TYPE (decl)); @@ -5166,8 +5180,11 @@ expand_omp_atomic_pipeline (basic_block load_bb, basic_block store_bb, basic_block loop_header = single_succ (load_bb); gimple phi, stmt; edge e; + enum built_in_function fncode; - cmpxchg = built_in_decls[BUILT_IN_SYNC_VAL_COMPARE_AND_SWAP_N + index + 1]; + fncode = (enum built_in_function)((int)BUILT_IN_SYNC_VAL_COMPARE_AND_SWAP_N + + index + 1); + cmpxchg = builtin_decl_explicit (fncode); if (cmpxchg == NULL_TREE) return false; type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (addr))); @@ -5355,7 +5372,7 @@ expand_omp_atomic_mutex (basic_block load_bb, basic_block store_bb, si = gsi_last_bb (load_bb); gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_ATOMIC_LOAD); - t = built_in_decls[BUILT_IN_GOMP_ATOMIC_START]; + t = builtin_decl_explicit (BUILT_IN_GOMP_ATOMIC_START); t = build_call_expr (t, 0); force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); @@ -5370,7 +5387,7 @@ expand_omp_atomic_mutex (basic_block load_bb, basic_block store_bb, stored_val); gsi_insert_before (&si, stmt, GSI_SAME_STMT); - t = built_in_decls[BUILT_IN_GOMP_ATOMIC_END]; + t = builtin_decl_explicit (BUILT_IN_GOMP_ATOMIC_END); t = build_call_expr (t, 0); force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); gsi_remove (&si, true); @@ -5806,7 +5823,7 @@ lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p) gimple call, cond; tree lhs, decl; - decl = built_in_decls[BUILT_IN_GOMP_SINGLE_START]; + decl = builtin_decl_explicit (BUILT_IN_GOMP_SINGLE_START); lhs = create_tmp_var (TREE_TYPE (TREE_TYPE (decl)), NULL); call = gimple_build_call (decl, 0); gimple_call_set_lhs (call, lhs); @@ -5855,7 +5872,7 @@ lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p) static void lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx) { - tree ptr_type, t, l0, l1, l2; + tree ptr_type, t, l0, l1, l2, bfn_decl; gimple_seq copyin_seq; location_t loc = gimple_location (single_stmt); @@ -5868,7 +5885,8 @@ lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx) l1 = create_artificial_label (loc); l2 = create_artificial_label (loc); - t = build_call_expr_loc (loc, built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_START], 0); + bfn_decl = builtin_decl_explicit (BUILT_IN_GOMP_SINGLE_COPY_START); + t = build_call_expr_loc (loc, bfn_decl, 0); t = fold_convert_loc (loc, ptr_type, t); gimplify_assign (ctx->receiver_decl, t, pre_p); @@ -5887,8 +5905,8 @@ lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx) ©in_seq, ctx); t = build_fold_addr_expr_loc (loc, ctx->sender_decl); - t = build_call_expr_loc (loc, built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_END], - 1, t); + bfn_decl = builtin_decl_explicit (BUILT_IN_GOMP_SINGLE_COPY_END); + t = build_call_expr_loc (loc, bfn_decl, 1, t); gimplify_and_add (t, pre_p); t = build_and_jump (&l2); @@ -5955,7 +5973,7 @@ lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx) static void lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx) { - tree block, lab = NULL, x; + tree block, lab = NULL, x, bfn_decl; gimple stmt = gsi_stmt (*gsi_p), bind; location_t loc = gimple_location (stmt); gimple_seq tseq; @@ -5967,7 +5985,8 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx) bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt), block); - x = build_call_expr_loc (loc, built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); + bfn_decl = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM); + x = build_call_expr_loc (loc, bfn_decl, 0); x = build2 (EQ_EXPR, boolean_type_node, x, integer_zero_node); x = build3 (COND_EXPR, void_type_node, x, NULL, build_and_jump (&lab)); tseq = NULL; @@ -6006,7 +6025,8 @@ lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx) bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt), block); - x = gimple_build_call (built_in_decls[BUILT_IN_GOMP_ORDERED_START], 0); + x = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ORDERED_START), + 0); gimple_bind_add_stmt (bind, x); lower_omp (gimple_omp_body (stmt), ctx); @@ -6014,7 +6034,7 @@ lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple_bind_add_seq (bind, gimple_omp_body (stmt)); gimple_omp_set_body (stmt, NULL); - x = gimple_build_call (built_in_decls[BUILT_IN_GOMP_ORDERED_END], 0); + x = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ORDERED_END), 0); gimple_bind_add_stmt (bind, x); gimple_bind_add_stmt (bind, gimple_build_omp_return (true)); @@ -6080,19 +6100,19 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx) else decl = (tree) n->value; - lock = built_in_decls[BUILT_IN_GOMP_CRITICAL_NAME_START]; + lock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_NAME_START); lock = build_call_expr_loc (loc, lock, 1, build_fold_addr_expr_loc (loc, decl)); - unlock = built_in_decls[BUILT_IN_GOMP_CRITICAL_NAME_END]; + unlock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_NAME_END); unlock = build_call_expr_loc (loc, unlock, 1, build_fold_addr_expr_loc (loc, decl)); } else { - lock = built_in_decls[BUILT_IN_GOMP_CRITICAL_START]; + lock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_START); lock = build_call_expr_loc (loc, lock, 0); - unlock = built_in_decls[BUILT_IN_GOMP_CRITICAL_END]; + unlock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_END); unlock = build_call_expr_loc (loc, unlock, 0); } diff --git a/gcc/system.h b/gcc/system.h index 7c006faaafe..e86f7ba7a4f 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -882,6 +882,9 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; TARGET_HANDLE_OFAST TARGET_OPTION_OPTIMIZATION \ TARGET_IRA_COVER_CLASSES TARGET_HELP +/* Arrays that were deleted in favor of a functional interface. */ + #pragma GCC poison built_in_decls implicit_built_in_decls + /* Hooks into libgcc2. */ #pragma GCC poison LIBGCC2_DOUBLE_TYPE_SIZE LIBGCC2_WORDS_BIG_ENDIAN \ LIBGCC2_FLOAT_WORDS_BIG_ENDIAN diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 1b2a588ee2e..0547fcf147f 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -956,7 +956,7 @@ expand_complex_libcall (gimple_stmt_iterator *gsi, tree ar, tree ai, (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); else gcc_unreachable (); - fn = built_in_decls[bcode]; + fn = builtin_decl_explicit (bcode); stmt = gimple_build_call (fn, 4, ar, ai, br, bi); gimple_call_set_lhs (stmt, lhs); diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 2b88b8647fa..f751d8d98a2 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -2934,7 +2934,7 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map) Resolve this by expanding the resx node to an abort. */ - fn = implicit_built_in_decls[BUILT_IN_TRAP]; + fn = builtin_decl_implicit (BUILT_IN_TRAP); x = gimple_build_call (fn, 0); gsi_insert_before (&gsi, x, GSI_SAME_STMT); @@ -2991,7 +2991,7 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map) edge_iterator ei; tree dst_nr = build_int_cst (integer_type_node, dst_r->index); - fn = implicit_built_in_decls[BUILT_IN_EH_COPY_VALUES]; + fn = builtin_decl_implicit (BUILT_IN_EH_COPY_VALUES); src_nr = build_int_cst (integer_type_node, src_r->index); x = gimple_build_call (fn, 2, dst_nr, src_nr); gsi_insert_before (&gsi, x, GSI_SAME_STMT); @@ -3026,13 +3026,13 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map) with no arguments for C++ and Java. Check for that. */ if (src_r->use_cxa_end_cleanup) { - fn = implicit_built_in_decls[BUILT_IN_CXA_END_CLEANUP]; + fn = builtin_decl_implicit (BUILT_IN_CXA_END_CLEANUP); x = gimple_build_call (fn, 0); gsi_insert_before (&gsi, x, GSI_SAME_STMT); } else { - fn = implicit_built_in_decls[BUILT_IN_EH_POINTER]; + fn = builtin_decl_implicit (BUILT_IN_EH_POINTER); src_nr = build_int_cst (integer_type_node, src_r->index); x = gimple_build_call (fn, 1, src_nr); var = create_tmp_var (ptr_type_node, NULL); @@ -3040,7 +3040,7 @@ lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map) gimple_call_set_lhs (x, var); gsi_insert_before (&gsi, x, GSI_SAME_STMT); - fn = implicit_built_in_decls[BUILT_IN_UNWIND_RESUME]; + fn = builtin_decl_implicit (BUILT_IN_UNWIND_RESUME); x = gimple_build_call (fn, 1, var); gsi_insert_before (&gsi, x, GSI_SAME_STMT); } @@ -3206,7 +3206,7 @@ lower_eh_dispatch (basic_block src, gimple stmt) } else { - fn = implicit_built_in_decls[BUILT_IN_EH_FILTER]; + fn = builtin_decl_implicit (BUILT_IN_EH_FILTER); x = gimple_build_call (fn, 1, build_int_cst (integer_type_node, region_nr)); filter = create_tmp_var (TREE_TYPE (TREE_TYPE (fn)), NULL); @@ -3232,7 +3232,7 @@ lower_eh_dispatch (basic_block src, gimple stmt) edge b_e = BRANCH_EDGE (src); edge f_e = FALLTHRU_EDGE (src); - fn = implicit_built_in_decls[BUILT_IN_EH_FILTER]; + fn = builtin_decl_implicit (BUILT_IN_EH_FILTER); x = gimple_build_call (fn, 1, build_int_cst (integer_type_node, region_nr)); filter = create_tmp_var (TREE_TYPE (TREE_TYPE (fn)), NULL); diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c index c6f3914bd7e..f046363c3d4 100644 --- a/gcc/tree-emutls.c +++ b/gcc/tree-emutls.c @@ -387,8 +387,8 @@ emutls_common_1 (tree tls_decl, tree control_decl, tree *pstmts) word_type_node = lang_hooks.types.type_for_mode (word_mode, 1); - x = build_call_expr (built_in_decls[BUILT_IN_EMUTLS_REGISTER_COMMON], 4, - build_fold_addr_expr (control_decl), + x = build_call_expr (builtin_decl_explicit (BUILT_IN_EMUTLS_REGISTER_COMMON), + 4, build_fold_addr_expr (control_decl), fold_convert (word_type_node, DECL_SIZE_UNIT (tls_decl)), build_int_cst (word_type_node, @@ -623,7 +623,7 @@ lower_emutls_function_body (struct cgraph_node *node) push_cfun (DECL_STRUCT_FUNCTION (node->decl)); d.cfun_node = node; - d.builtin_decl = built_in_decls[BUILT_IN_EMUTLS_GET_ADDRESS]; + d.builtin_decl = builtin_decl_explicit (BUILT_IN_EMUTLS_GET_ADDRESS); /* This is where we introduce the declaration to the IL and so we have to create a node for it. */ d.builtin_node = cgraph_get_create_node (d.builtin_decl); diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index fd633b4d320..810b974b256 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -289,7 +289,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, mem = force_gimple_operand (addr_base, &stmts, true, NULL); gimple_seq_add_seq (&stmt_list, stmts); - fn = build_fold_addr_expr (implicit_built_in_decls [BUILT_IN_MEMSET]); + fn = build_fold_addr_expr (builtin_decl_implicit (BUILT_IN_MEMSET)); fn_call = gimple_build_call (fn, 3, mem, integer_zero_node, nb_bytes); gimple_seq_add_stmt (&stmt_list, fn_call); gsi_insert_seq_after (&bsi, stmt_list, GSI_CONTINUE_LINKING); diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index ef51ff48882..ae3a8dd609f 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -1811,8 +1811,8 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p, x = get_frame_field (info, target_context, field, &wi->gsi); x = build_addr (x, target_context); x = gsi_gimplify_val (info, x, &wi->gsi); - call = gimple_build_call (implicit_built_in_decls[BUILT_IN_NONLOCAL_GOTO], 2, - build_addr (new_label, target_context), x); + call = gimple_build_call (builtin_decl_implicit (BUILT_IN_NONLOCAL_GOTO), + 2, build_addr (new_label, target_context), x); gsi_replace (&wi->gsi, call, false); /* We have handled all of STMT's operands, no need to keep going. */ @@ -1924,7 +1924,7 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data) /* Do machine-specific ugliness. Normally this will involve computing extra alignment, but it can really be anything. */ - builtin = implicit_built_in_decls[BUILT_IN_ADJUST_TRAMPOLINE]; + builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE); call = gimple_build_call (builtin, 1, x); x = init_tmp_var_with_call (info, &wi->gsi, call); @@ -2399,7 +2399,7 @@ finalize_nesting_tree_1 (struct nesting_info *root) root->frame_decl, field, NULL_TREE); arg1 = build_addr (x, context); - x = implicit_built_in_decls[BUILT_IN_INIT_TRAMPOLINE]; + x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE); stmt = gimple_build_call (x, 3, arg1, arg2, arg3); gimple_seq_add_stmt (&stmt_list, stmt); } diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index e207e232e01..31c31c141c9 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2175,7 +2175,7 @@ optimize_stdarg_builtin (gimple call) case BUILT_IN_VA_START: if (!va_list_simple_ptr || targetm.expand_builtin_va_start != NULL - || built_in_decls[BUILT_IN_NEXT_ARG] == NULL) + || builtin_decl_explicit_p (BUILT_IN_NEXT_ARG)) return NULL_TREE; if (gimple_call_num_args (call) != 2) @@ -2188,7 +2188,7 @@ optimize_stdarg_builtin (gimple call) return NULL_TREE; lhs = build_fold_indirect_ref_loc (loc, lhs); - rhs = build_call_expr_loc (loc, built_in_decls[BUILT_IN_NEXT_ARG], + rhs = build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_NEXT_ARG), 1, integer_zero_node); rhs = fold_convert_loc (loc, TREE_TYPE (lhs), rhs); return build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, rhs); diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index de782c9be9f..1db93a65a65 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -1595,7 +1595,8 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2) if (!is_gimple_val (ptr1)) ptr1 = force_gimple_operand_gsi (gsi_p, ptr1, true, NULL_TREE, true, GSI_SAME_STMT); - gimple_call_set_fndecl (stmt2, built_in_decls [BUILT_IN_MEMCPY]); + gimple_call_set_fndecl (stmt2, + builtin_decl_explicit (BUILT_IN_MEMCPY)); gimple_call_set_arg (stmt2, 0, ptr1); gimple_call_set_arg (stmt2, 1, new_str_cst); gimple_call_set_arg (stmt2, 2, diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index c5ad1c4765f..264d97bc1b5 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -1117,7 +1117,7 @@ issue_prefetch_ref (struct mem_ref *ref, unsigned unroll_factor, unsigned ahead) NULL, true, GSI_SAME_STMT); } /* Create the prefetch instruction. */ - prefetch = gimple_build_call (built_in_decls[BUILT_IN_PREFETCH], + prefetch = gimple_build_call (builtin_decl_explicit (BUILT_IN_PREFETCH), 3, addr, write_p, local); gsi_insert_before (&bsi, prefetch, GSI_SAME_STMT); } @@ -1909,7 +1909,7 @@ tree_ssa_prefetch_arrays (void) initialize_original_copy_tables (); - if (!built_in_decls[BUILT_IN_PREFETCH]) + if (!builtin_decl_explicit_p (BUILT_IN_PREFETCH)) { tree type = build_function_type_list (void_type_node, const_ptr_type_node, NULL_TREE); @@ -1917,7 +1917,7 @@ tree_ssa_prefetch_arrays (void) BUILT_IN_PREFETCH, BUILT_IN_NORMAL, NULL, NULL_TREE); DECL_IS_NOVOPS (decl) = true; - built_in_decls[BUILT_IN_PREFETCH] = decl; + set_builtin_decl (BUILT_IN_PREFETCH, decl, false); } /* We assume that size of cache line is a power of two, so verify this diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index ed99802b3b2..02d91ca8bbd 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1805,9 +1805,9 @@ execute_optimize_bswap (void) if (sizeof (HOST_WIDEST_INT) < 8) return 0; - bswap32_p = (built_in_decls[BUILT_IN_BSWAP32] + bswap32_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP32) && optab_handler (bswap_optab, SImode) != CODE_FOR_nothing); - bswap64_p = (built_in_decls[BUILT_IN_BSWAP64] + bswap64_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP64) && (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing || (bswap32_p && word_mode == SImode))); @@ -1818,13 +1818,13 @@ execute_optimize_bswap (void) assumes that the return and argument type are the same. */ if (bswap32_p) { - tree fndecl = built_in_decls[BUILT_IN_BSWAP32]; + tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32); bswap32_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); } if (bswap64_p) { - tree fndecl = built_in_decls[BUILT_IN_BSWAP64]; + tree fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64); bswap64_type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); } @@ -1858,14 +1858,14 @@ execute_optimize_bswap (void) case 32: if (bswap32_p) { - fndecl = built_in_decls[BUILT_IN_BSWAP32]; + fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32); bswap_type = bswap32_type; } break; case 64: if (bswap64_p) { - fndecl = built_in_decls[BUILT_IN_BSWAP64]; + fndecl = builtin_decl_explicit (BUILT_IN_BSWAP64); bswap_type = bswap64_type; } break; diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index d997c73451e..697340f535a 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -397,7 +397,7 @@ get_string_length (strinfo si) callee = gimple_call_fndecl (stmt); gcc_assert (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL); lhs = gimple_call_lhs (stmt); - gcc_assert (implicit_built_in_decls[BUILT_IN_STRCPY] != NULL_TREE); + gcc_assert (builtin_decl_implicit_p (BUILT_IN_STRCPY)); /* unshare_strinfo is intentionally not called here. The (delayed) transformation of strcpy or strcat into stpcpy is done at the place of the former strcpy/strcat call and so can affect all the strinfos @@ -409,7 +409,7 @@ get_string_length (strinfo si) case BUILT_IN_STRCAT: case BUILT_IN_STRCAT_CHK: gsi = gsi_for_stmt (stmt); - fn = implicit_built_in_decls[BUILT_IN_STRLEN]; + fn = builtin_decl_implicit (BUILT_IN_STRLEN); gcc_assert (lhs == NULL_TREE); lhs_var = create_tmp_var (TREE_TYPE (TREE_TYPE (fn)), NULL); add_referenced_var (lhs_var); @@ -434,9 +434,9 @@ get_string_length (strinfo si) case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: if (gimple_call_num_args (stmt) == 2) - fn = implicit_built_in_decls[BUILT_IN_STPCPY]; + fn = builtin_decl_implicit (BUILT_IN_STPCPY); else - fn = built_in_decls[BUILT_IN_STPCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_STPCPY_CHK); gcc_assert (lhs == NULL_TREE); if (dump_file && (dump_flags & TDF_DETAILS) != 0) { @@ -1070,8 +1070,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) { case BUILT_IN_STRCPY: case BUILT_IN_STRCPY_CHK: - if (implicit_built_in_decls[BUILT_IN_STPCPY] == NULL_TREE - || lhs != NULL_TREE) + if (lhs != NULL_TREE || !builtin_decl_implicit_p (BUILT_IN_STPCPY)) return; break; case BUILT_IN_STPCPY: @@ -1154,12 +1153,12 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) switch (bcode) { case BUILT_IN_STRCPY: - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); if (lhs) VEC_replace (int, ssa_ver_to_stridx, SSA_NAME_VERSION (lhs), didx); break; case BUILT_IN_STRCPY_CHK: - fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); if (lhs) VEC_replace (int, ssa_ver_to_stridx, SSA_NAME_VERSION (lhs), didx); break; @@ -1167,7 +1166,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) /* This would need adjustment of the lhs (subtract one), or detection that the trailing '\0' doesn't need to be written, if it will be immediately overwritten. - fn = built_in_decls[BUILT_IN_MEMPCPY]; */ + fn = builtin_decl_explicit (BUILT_IN_MEMPCPY); */ if (lhs) { dsi->endptr = lhs; @@ -1178,7 +1177,7 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi) /* This would need adjustment of the lhs (subtract one), or detection that the trailing '\0' doesn't need to be written, if it will be immediately overwritten. - fn = built_in_decls[BUILT_IN_MEMPCPY_CHK]; */ + fn = builtin_decl_explicit (BUILT_IN_MEMPCPY_CHK); */ if (lhs) { dsi->endptr = lhs; @@ -1400,8 +1399,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) with length endptr - p if we need to compute the length later on. Don't do this transformation if we don't need it. */ - if (implicit_built_in_decls[BUILT_IN_STPCPY] != NULL_TREE - && lhs == NULL_TREE) + if (builtin_decl_implicit_p (BUILT_IN_STPCPY) && lhs == NULL_TREE) { if (didx == 0) { @@ -1460,8 +1458,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) else { dsi->length = NULL; - if (implicit_built_in_decls[BUILT_IN_STPCPY] != NULL_TREE - && lhs == NULL_TREE) + if (lhs == NULL_TREE && builtin_decl_implicit_p (BUILT_IN_STPCPY)) dsi->dont_invalidate = true; } @@ -1481,15 +1478,15 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi) { case BUILT_IN_STRCAT: if (srclen != NULL_TREE) - fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; + fn = builtin_decl_implicit (BUILT_IN_MEMCPY); else - fn = implicit_built_in_decls[BUILT_IN_STRCPY]; + fn = builtin_decl_implicit (BUILT_IN_STRCPY); break; case BUILT_IN_STRCAT_CHK: if (srclen != NULL_TREE) - fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_MEMCPY_CHK); else - fn = built_in_decls[BUILT_IN_STRCPY_CHK]; + fn = builtin_decl_explicit (BUILT_IN_STRCPY_CHK); objsz = gimple_call_arg (stmt, 2); break; default: diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 0a79a249151..db2bb376432 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -1049,7 +1049,7 @@ streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in) { if (fcode >= END_BUILTINS) fatal_error ("machine independent builtin code out of range"); - result = built_in_decls[fcode]; + result = builtin_decl_explicit (fcode); gcc_assert (result); } else if (fclass == BUILT_IN_MD) diff --git a/gcc/tree.c b/gcc/tree.c index 03edb9c0324..64c49688575 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -4656,10 +4656,9 @@ free_lang_data_in_decl (tree decl) && DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) == BLOCK) { - /* Strip builtins from the translation-unit BLOCK. We still have - targets without builtin_decl support and also builtins are - shared nodes and thus we can't use TREE_CHAIN in multiple - lists. */ + /* Strip builtins from the translation-unit BLOCK. We still have targets + without builtin_decl_explicit support and also builtins are shared + nodes and thus we can't use TREE_CHAIN in multiple lists. */ tree *nextp = &BLOCK_VARS (DECL_INITIAL (decl)); while (*nextp) { @@ -6942,9 +6941,9 @@ iterative_hash_expr (const_tree t, hashval_t val) or front end builtins, since the function code is overloaded in those cases. */ if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL - && built_in_decls[DECL_FUNCTION_CODE (t)]) + && builtin_decl_explicit_p (DECL_FUNCTION_CODE (t))) { - t = built_in_decls[DECL_FUNCTION_CODE (t)]; + t = builtin_decl_explicit (DECL_FUNCTION_CODE (t)); code = TREE_CODE (t); } /* FALL THROUGH */ @@ -9429,8 +9428,7 @@ local_define_builtin (const char *name, tree type, enum built_in_function code, DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), NULL, DECL_ATTRIBUTES (decl)); - built_in_decls[code] = decl; - implicit_built_in_decls[code] = decl; + set_builtin_decl (code, decl, true); } /* Call this function after instantiating all builtins that the language @@ -9442,22 +9440,22 @@ build_common_builtin_nodes (void) { tree tmp, ftype; - if (built_in_decls[BUILT_IN_MEMCPY] == NULL - || built_in_decls[BUILT_IN_MEMMOVE] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY) + || !builtin_decl_explicit_p (BUILT_IN_MEMMOVE)) { ftype = build_function_type_list (ptr_type_node, ptr_type_node, const_ptr_type_node, size_type_node, NULL_TREE); - if (built_in_decls[BUILT_IN_MEMCPY] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_MEMCPY)) local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY, "memcpy", ECF_NOTHROW | ECF_LEAF); - if (built_in_decls[BUILT_IN_MEMMOVE] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_MEMMOVE)) local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE, "memmove", ECF_NOTHROW | ECF_LEAF); } - if (built_in_decls[BUILT_IN_MEMCMP] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_MEMCMP)) { ftype = build_function_type_list (integer_type_node, const_ptr_type_node, const_ptr_type_node, size_type_node, @@ -9466,7 +9464,7 @@ build_common_builtin_nodes (void) "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF); } - if (built_in_decls[BUILT_IN_MEMSET] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_MEMSET)) { ftype = build_function_type_list (ptr_type_node, ptr_type_node, integer_type_node, @@ -9475,7 +9473,7 @@ build_common_builtin_nodes (void) "memset", ECF_NOTHROW | ECF_LEAF); } - if (built_in_decls[BUILT_IN_ALLOCA] == NULL) + if (!builtin_decl_explicit_p (BUILT_IN_ALLOCA)) { ftype = build_function_type_list (ptr_type_node, size_type_node, NULL_TREE); @@ -9492,8 +9490,8 @@ build_common_builtin_nodes (void) /* If we're checking the stack, `alloca' can throw. */ if (flag_stack_check) { - TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA]) = 0; - TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA_WITH_ALIGN]) = 0; + TREE_NOTHROW (builtin_decl_explicit (BUILT_IN_ALLOCA)) = 0; + TREE_NOTHROW (builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN)) = 0; } ftype = build_function_type_list (void_type_node, @@ -9560,7 +9558,7 @@ build_common_builtin_nodes (void) ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), ECF_NORETURN); - if (built_in_decls[BUILT_IN_RETURN_ADDRESS] == NULL_TREE) + if (builtin_decl_explicit (BUILT_IN_RETURN_ADDRESS) == NULL_TREE) { ftype = build_function_type_list (ptr_type_node, integer_type_node, NULL_TREE); @@ -9570,16 +9568,16 @@ build_common_builtin_nodes (void) ECF_NOTHROW); } - if (built_in_decls[BUILT_IN_PROFILE_FUNC_ENTER] == NULL_TREE - || built_in_decls[BUILT_IN_PROFILE_FUNC_EXIT] == NULL_TREE) + if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER) + || !builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT)) { ftype = build_function_type_list (void_type_node, ptr_type_node, ptr_type_node, NULL_TREE); - if (built_in_decls[BUILT_IN_PROFILE_FUNC_ENTER] == NULL_TREE) + if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_ENTER)) local_define_builtin ("__cyg_profile_func_enter", ftype, BUILT_IN_PROFILE_FUNC_ENTER, "__cyg_profile_func_enter", 0); - if (built_in_decls[BUILT_IN_PROFILE_FUNC_EXIT] == NULL_TREE) + if (!builtin_decl_explicit_p (BUILT_IN_PROFILE_FUNC_EXIT)) local_define_builtin ("__cyg_profile_func_exit", ftype, BUILT_IN_PROFILE_FUNC_EXIT, "__cyg_profile_func_exit", 0); diff --git a/gcc/tree.h b/gcc/tree.h index 534fcd6a219..18fdd07fe4e 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -335,10 +335,6 @@ extern const char * built_in_names[(int) END_BUILTINS]; #define CASE_FLT_FN(FN) case FN: case FN##F: case FN##L #define CASE_FLT_FN_REENT(FN) case FN##_R: case FN##F_R: case FN##L_R #define CASE_INT_FN(FN) case FN: case FN##L: case FN##LL - -/* An array of _DECL trees for the above. */ -extern GTY(()) tree built_in_decls[(int) END_BUILTINS]; -extern GTY(()) tree implicit_built_in_decls[(int) END_BUILTINS]; /* In an OMP_CLAUSE node. */ @@ -5918,4 +5914,94 @@ is_lang_specific (tree t) /* In gimple-low.c. */ extern bool block_may_fallthru (const_tree); + +/* Functional interface to the builtin functions. */ + +/* The builtin_info structure holds the FUNCTION_DECL of the standard builtin + function, and a flag that says if the function is available implicitly, or + whether the user has to code explicit calls to __builtin_<xxx>. */ + +typedef struct GTY(()) builtin_info_type_d { + tree decl[(int)END_BUILTINS]; + bool implicit_p[(int)END_BUILTINS]; +} builtin_info_type; + +extern GTY(()) builtin_info_type builtin_info; + +/* Valid builtin number. */ +#define BUILTIN_VALID_P(FNCODE) \ + (IN_RANGE ((int)FNCODE, ((int)BUILT_IN_NONE) + 1, ((int) END_BUILTINS) - 1)) + +/* Return the tree node for an explicit standard builtin function or NULL. */ +static inline tree +builtin_decl_explicit (enum built_in_function fncode) +{ + gcc_checking_assert (BUILTIN_VALID_P (fncode)); + + return builtin_info.decl[(size_t)fncode]; +} + +/* Return the tree node for an implicit builtin function or NULL. */ +static inline tree +builtin_decl_implicit (enum built_in_function fncode) +{ + size_t uns_fncode = (size_t)fncode; + gcc_checking_assert (BUILTIN_VALID_P (fncode)); + + if (!builtin_info.implicit_p[uns_fncode]) + return NULL_TREE; + + return builtin_info.decl[uns_fncode]; +} + +/* Set explicit builtin function nodes and whether it is an implicit + function. */ + +static inline void +set_builtin_decl (enum built_in_function fncode, tree decl, bool implicit_p) +{ + size_t ufncode = (size_t)fncode; + + gcc_checking_assert (BUILTIN_VALID_P (fncode) + && (decl != NULL_TREE || !implicit_p)); + + builtin_info.decl[ufncode] = decl; + builtin_info.implicit_p[ufncode] = implicit_p; +} + +/* Set the implicit flag for a builtin function. */ + +static inline void +set_builtin_decl_implicit_p (enum built_in_function fncode, bool implicit_p) +{ + size_t uns_fncode = (size_t)fncode; + + gcc_checking_assert (BUILTIN_VALID_P (fncode) + && builtin_info.decl[uns_fncode] != NULL_TREE); + + builtin_info.implicit_p[uns_fncode] = implicit_p; +} + +/* Return whether the standard builtin function can be used as an explicit + function. */ + +static inline bool +builtin_decl_explicit_p (enum built_in_function fncode) +{ + gcc_checking_assert (BUILTIN_VALID_P (fncode)); + return (builtin_info.decl[(size_t)fncode] != NULL_TREE); +} + +/* Return whether the standard builtin function can be used implicitly. */ + +static inline bool +builtin_decl_implicit_p (enum built_in_function fncode) +{ + size_t uns_fncode = (size_t)fncode; + + gcc_checking_assert (BUILTIN_VALID_P (fncode)); + return (builtin_info.decl[uns_fncode] != NULL_TREE + && builtin_info.implicit_p[uns_fncode]); +} + #endif /* GCC_TREE_H */ |