diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-05-20 19:12:49 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-05-20 19:12:49 +0000 |
commit | 15c671a79ca66df5b1de70dd1a0b78414fe003ef (patch) | |
tree | f210624d9cf8816cc56a0800f0429cd6e558a371 /gcc/jit/libgccjit.c | |
parent | dfbdde160f9970aea0bfc6c9d2005d911de6b593 (diff) | |
download | gcc-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/libgccjit.c')
-rw-r--r-- | gcc/jit/libgccjit.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 02ff50c..c2c6aeb 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -2950,3 +2950,23 @@ gcc_jit_timer_print (gcc_jit_timer *timer, timer->start (TV_TOTAL); timer->push (TV_JIT_CLIENT_CODE); } + +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is effectively done by the + gcc::jit::base_call::set_require_tail_call setter in jit-recording.h. */ + +void +gcc_jit_rvalue_set_bool_require_tail_call (gcc_jit_rvalue *rvalue, + int require_tail_call) +{ + RETURN_IF_FAIL (rvalue, NULL, NULL, "NULL call"); + JIT_LOG_FUNC (rvalue->get_context ()->get_logger ()); + + /* Verify that it's a call. */ + gcc::jit::recording::base_call *call = rvalue->dyn_cast_base_call (); + RETURN_IF_FAIL_PRINTF1 (call, NULL, NULL, "not a call: %s", + rvalue->get_debug_string ()); + + call->set_require_tail_call (require_tail_call); +} |