aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorMichael Meissner <meissner@linux.vnet.ibm.com>2011-10-11 19:55:09 +0000
committerMichael Meissner <meissner@gcc.gnu.org>2011-10-11 19:55:09 +0000
commite79983f458034c3061645a4c4ff83c9c4d9019b9 (patch)
tree304b794b6f6f0af1f79b00f4166b897337141fac /gcc/fortran
parentf0286f957326b588ba6f49d1fed0c14c19033830 (diff)
downloadgcc-e79983f458034c3061645a4c4ff83c9c4d9019b9.zip
gcc-e79983f458034c3061645a4c4ff83c9c4d9019b9.tar.gz
gcc-e79983f458034c3061645a4c4ff83c9c4d9019b9.tar.bz2
Convert standard builtin functions from being arrays to using a functional interface
From-SVN: r179820
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog34
-rw-r--r--gcc/fortran/f95-lang.c9
-rw-r--r--gcc/fortran/trans-array.c14
-rw-r--r--gcc/fortran/trans-decl.c2
-rw-r--r--gcc/fortran/trans-expr.c34
-rw-r--r--gcc/fortran/trans-intrinsic.c89
-rw-r--r--gcc/fortran/trans-openmp.c13
-rw-r--r--gcc/fortran/trans-stmt.c8
-rw-r--r--gcc/fortran/trans.c26
9 files changed, 139 insertions, 90 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 34c688b..029edf2 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 8f8dd7d..57c0114 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 b755670..585dc43 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 4526aaa..b7460b7 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 131927c..ca0523f 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 c47e678..ed18bfa 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 cfe8612..a41e97b 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 8e43f4d..c71eeec 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 764bdf4..0176aec 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;
}