aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/trans.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-05-27 11:34:35 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-05-27 11:34:35 +0000
commitb9778c45fc1cd361c3012e30aeb02b53cb3e531c (patch)
tree2727797e25c51e698f4e66bd2459562c7f4b288a /gcc/ada/gcc-interface/trans.c
parentb4c056d2df1264bad4f837b4ec743461f68edff1 (diff)
downloadgcc-b9778c45fc1cd361c3012e30aeb02b53cb3e531c.zip
gcc-b9778c45fc1cd361c3012e30aeb02b53cb3e531c.tar.gz
gcc-b9778c45fc1cd361c3012e30aeb02b53cb3e531c.tar.bz2
ada-builtin-types.def: New file.
* gcc-interface/ada-builtin-types.def: New file. * gcc-interface/ada-builtins.def: Likewise. * gcc-interface/ada-tree.h (BUILT_IN_LIKELY): New macro. (BUILT_IN_UNLIKELY): Likewise. * gcc-interface/trans.c (independent_iterations_p): Initialize the auto-vector to 16 elements. (Call_to_gnu): Remove local variable and change the vector of actual parameters to an auto-vector. Do not convert actual parameters to the argument type for front-end built-in functions. Add support for front-end built-in functions. (build_noreturn_cond): Use internal instead of built-in function. * gcc-interface/utils.c (c_builtin_type): Include ada-builtin-types.def (install_builtin_function_types): Likewise. (install_builtin_functions): Include ada-builtins.def first. From-SVN: r271658
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r--gcc/ada/gcc-interface/trans.c77
1 files changed, 56 insertions, 21 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 2efc800..59c4c07 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -3307,7 +3307,7 @@ independent_iterations_p (tree stmt_list)
{
tree_stmt_iterator tsi;
bitmap params = BITMAP_GGC_ALLOC();
- auto_vec<tree> rhs;
+ auto_vec<tree, 16> rhs;
tree iter;
int i;
@@ -5029,8 +5029,10 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
tree gnu_subprog_type = TREE_TYPE (gnu_subprog);
/* The return type of the FUNCTION_TYPE. */
tree gnu_result_type = TREE_TYPE (gnu_subprog_type);
- tree gnu_subprog_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_subprog);
- vec<tree, va_gc> *gnu_actual_vec = NULL;
+ const bool frontend_builtin
+ = (TREE_CODE (gnu_subprog) == FUNCTION_DECL
+ && DECL_BUILT_IN_CLASS (gnu_subprog) == BUILT_IN_FRONTEND);
+ auto_vec<tree, 16> gnu_actual_vec;
tree gnu_name_list = NULL_TREE;
tree gnu_stmt_list = NULL_TREE;
tree gnu_after_list = NULL_TREE;
@@ -5487,16 +5489,56 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
build_int_cst (type_for_size, 0),
false);
}
- else
+
+ /* If this is a front-end built-in function, there is no need to
+ convert to the type used to pass the argument. */
+ else if (!frontend_builtin)
gnu_actual = convert (DECL_ARG_TYPE (gnu_formal), gnu_actual);
}
- vec_safe_push (gnu_actual_vec, gnu_actual);
+ gnu_actual_vec.safe_push (gnu_actual);
+ }
+
+ if (frontend_builtin)
+ {
+ tree pred_cst = build_int_cst (integer_type_node, PRED_BUILTIN_EXPECT);
+ enum internal_fn icode = IFN_BUILTIN_EXPECT;
+
+ switch (DECL_FUNCTION_CODE (gnu_subprog))
+ {
+ case BUILT_IN_EXPECT:
+ break;
+ case BUILT_IN_LIKELY:
+ gnu_actual_vec.safe_push (boolean_true_node);
+ break;
+ case BUILT_IN_UNLIKELY:
+ gnu_actual_vec.safe_push (boolean_false_node);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+
+ gnu_actual_vec.safe_push (pred_cst);
+
+ gnu_call
+ = build_call_expr_internal_loc_array (UNKNOWN_LOCATION,
+ icode,
+ gnu_result_type,
+ gnu_actual_vec.length (),
+ gnu_actual_vec.begin ());
+ }
+ else
+ {
+ gnu_call
+ = build_call_array_loc (UNKNOWN_LOCATION,
+ gnu_result_type,
+ build_unary_op (ADDR_EXPR, NULL_TREE,
+ gnu_subprog),
+ gnu_actual_vec.length (),
+ gnu_actual_vec.begin ());
+ CALL_EXPR_BY_DESCRIPTOR (gnu_call) = by_descriptor;
}
- gnu_call
- = build_call_vec (gnu_result_type, gnu_subprog_addr, gnu_actual_vec);
- CALL_EXPR_BY_DESCRIPTOR (gnu_call) = by_descriptor;
set_expr_location_from_node (gnu_call, gnat_node);
/* If we have created a temporary for the return value, initialize it. */
@@ -6320,24 +6362,17 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
The compiler will automatically predict the last edge leading to a call
to a noreturn function as very unlikely taken. This function makes it
- possible to expand the prediction to predecessors in case the condition
+ possible to extend the prediction to predecessors in case the condition
is made up of several short-circuit operators. */
static tree
build_noreturn_cond (tree cond)
{
- tree fn = builtin_decl_explicit (BUILT_IN_EXPECT);
- tree arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn));
- tree pred_type = TREE_VALUE (arg_types);
- tree expected_type = TREE_VALUE (TREE_CHAIN (arg_types));
-
- tree t = build_call_expr (fn, 3,
- fold_convert (pred_type, cond),
- build_int_cst (expected_type, 0),
- build_int_cst (integer_type_node,
- PRED_NORETURN));
-
- return build1 (NOP_EXPR, boolean_type_node, t);
+ tree pred_cst = build_int_cst (integer_type_node, PRED_NORETURN);
+ return
+ build_call_expr_internal_loc (UNKNOWN_LOCATION, IFN_BUILTIN_EXPECT,
+ boolean_type_node, 3, cond,
+ boolean_false_node, pred_cst);
}
/* Subroutine of gnat_to_gnu to translate GNAT_RANGE, a node representing a