aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/jit-playback.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-05-20 19:12:49 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-05-20 19:12:49 +0000
commit15c671a79ca66df5b1de70dd1a0b78414fe003ef (patch)
treef210624d9cf8816cc56a0800f0429cd6e558a371 /gcc/jit/jit-playback.c
parentdfbdde160f9970aea0bfc6c9d2005d911de6b593 (diff)
downloadgcc-15c671a79ca66df5b1de70dd1a0b78414fe003ef.zip
gcc-15c671a79ca66df5b1de70dd1a0b78414fe003ef.tar.gz
gcc-15c671a79ca66df5b1de70dd1a0b78414fe003ef.tar.bz2
jit: implement gcc_jit_rvalue_set_bool_require_tail_call
This implements the libgccjit support for must-tail-call via a new: gcc_jit_rvalue_set_bool_require_tail_call API entrypoint. (I didn't implement a wrapper for this within the C++ bindings) gcc/jit/ChangeLog: * docs/topics/compatibility.rst: Add LIBGCCJIT_ABI_6. * docs/topics/expressions.rst (Function calls): Add documentation of gcc_jit_rvalue_set_bool_require_tail_call. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-common.h (gcc::jit::recording::base_call): Add forward decl. * jit-playback.c: Within namespace gcc::jit::playback... (context::build_call) Add "require_tail_call" param and use it to set CALL_EXPR_MUST_TAIL_CALL. (context::new_call): Add "require_tail_call" param. (context::new_call_through_ptr): Likewise. * jit-playback.h: Within namespace gcc::jit::playback... (context::new_call: Add "require_tail_call" param. (context::new_call_through_ptr): Likewise. (context::build_call): Likewise. * jit-recording.c: Within namespace gcc::jit::recording... (base_call::base_call): New constructor. (base_call::write_reproducer_tail_call): New method. (call::call): Update for inheritance from base_call. (call::replay_into): Provide m_require_tail_call to call to new_call. (call::write_reproducer): Call write_reproducer_tail_call. (call_through_ptr::call_through_ptr): Update for inheritance from base_call. (call_through_ptr::replay_into): Provide m_require_tail_call to call to new_call_through_ptr. (recording::call_through_ptr::write_reproducer): Call write_reproducer_tail_call. * jit-recording.h: Within namespace gcc::jit::recording... (rvalue::dyn_cast_base_call): New virtual function. (class base_call): New subclass of class rvalue. (class call): Inherit from base_call rather than directly from rvalue, moving get_precedence and m_args to base_call. (class call_through_ptr): Likewise. * libgccjit.c (gcc_jit_rvalue_set_bool_require_tail_call): New function. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_rvalue_set_bool_require_tail_call): New macro. (gcc_jit_rvalue_set_bool_require_tail_call): New function. * libgccjit.map (LIBGCCJIT_ABI_6): New. (gcc_jit_rvalue_set_bool_require_tail_call): Add. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-factorial-must-tail-call.c. * jit.dg/test-error-impossible-must-tail-call.c: New test case. * jit.dg/test-factorial-must-tail-call.c: New test case. From-SVN: r236531
Diffstat (limited to 'gcc/jit/jit-playback.c')
-rw-r--r--gcc/jit/jit-playback.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 156448d..c9f4084 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -854,7 +854,8 @@ playback::rvalue *
playback::context::
build_call (location *loc,
tree fn_ptr,
- const auto_vec<rvalue *> *args)
+ const auto_vec<rvalue *> *args,
+ bool require_tail_call)
{
vec<tree, va_gc> *tree_args;
vec_alloc (tree_args, args->length ());
@@ -868,9 +869,13 @@ build_call (location *loc,
tree fn_type = TREE_TYPE (fn);
tree return_type = TREE_TYPE (fn_type);
- return new rvalue (this,
- build_call_vec (return_type,
- fn_ptr, tree_args));
+ tree call = build_call_vec (return_type,
+ fn_ptr, tree_args);
+
+ if (require_tail_call)
+ CALL_EXPR_MUST_TAIL_CALL (call) = 1;
+
+ return new rvalue (this, call);
/* see c-typeck.c: build_function_call
which calls build_function_call_vec
@@ -890,7 +895,8 @@ playback::rvalue *
playback::context::
new_call (location *loc,
function *func,
- const auto_vec<rvalue *> *args)
+ const auto_vec<rvalue *> *args,
+ bool require_tail_call)
{
tree fndecl;
@@ -902,7 +908,7 @@ new_call (location *loc,
tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
- return build_call (loc, fn, args);
+ return build_call (loc, fn, args, require_tail_call);
}
/* Construct a playback::rvalue instance (wrapping a tree) for a
@@ -912,12 +918,13 @@ playback::rvalue *
playback::context::
new_call_through_ptr (location *loc,
rvalue *fn_ptr,
- const auto_vec<rvalue *> *args)
+ const auto_vec<rvalue *> *args,
+ bool require_tail_call)
{
gcc_assert (fn_ptr);
tree t_fn_ptr = fn_ptr->as_tree ();
- return build_call (loc, t_fn_ptr, args);
+ return build_call (loc, t_fn_ptr, args, require_tail_call);
}
/* Construct a tree for a cast. */