summaryrefslogtreecommitdiff
path: root/gcc/jit/jit-recording.h
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-20 19:12:49 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-05-20 19:12:49 +0000
commit9954d2306dfc918e8d3b2af592fedc2d943617c0 (patch)
treef210624d9cf8816cc56a0800f0429cd6e558a371 /gcc/jit/jit-recording.h
parent869bb2b63aa98a57409c46a2a42790742f50887d (diff)
downloadgcc-9954d2306dfc918e8d3b2af592fedc2d943617c0.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236531 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/jit/jit-recording.h')
-rw-r--r--gcc/jit/jit-recording.h46
1 files changed, 33 insertions, 13 deletions
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 1c3e7634209..0e3511c6a1c 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -960,8 +960,9 @@ public:
void set_scope (function *scope);
function *get_scope () const { return m_scope; }
- /* Dynamic cast. */
+ /* Dynamic casts. */
virtual param *dyn_cast_param () { return NULL; }
+ virtual base_call *dyn_cast_base_call () { return NULL; }
virtual const char *access_as_rvalue (reproducer &r);
@@ -1418,7 +1419,36 @@ private:
rvalue *m_rvalue;
};
-class call : public rvalue
+class base_call : public rvalue
+{
+ public:
+ base_call (context *ctxt,
+ location *loc,
+ type *type_,
+ int numargs,
+ rvalue **args);
+
+ enum precedence get_precedence () const FINAL OVERRIDE
+ {
+ return PRECEDENCE_POSTFIX;
+ }
+
+ base_call *dyn_cast_base_call () FINAL OVERRIDE { return this; }
+
+ void set_require_tail_call (bool require_tail_call)
+ {
+ m_require_tail_call = require_tail_call;
+ }
+
+ protected:
+ void write_reproducer_tail_call (reproducer &r, const char *id);
+
+ protected:
+ auto_vec<rvalue *> m_args;
+ bool m_require_tail_call;
+};
+
+class call : public base_call
{
public:
call (context *ctxt,
@@ -1434,17 +1464,12 @@ public:
private:
string * make_debug_string () FINAL OVERRIDE;
void write_reproducer (reproducer &r) FINAL OVERRIDE;
- enum precedence get_precedence () const FINAL OVERRIDE
- {
- return PRECEDENCE_POSTFIX;
- }
private:
function *m_func;
- auto_vec<rvalue *> m_args;
};
-class call_through_ptr : public rvalue
+class call_through_ptr : public base_call
{
public:
call_through_ptr (context *ctxt,
@@ -1460,14 +1485,9 @@ public:
private:
string * make_debug_string () FINAL OVERRIDE;
void write_reproducer (reproducer &r) FINAL OVERRIDE;
- enum precedence get_precedence () const FINAL OVERRIDE
- {
- return PRECEDENCE_POSTFIX;
- }
private:
rvalue *m_fn_ptr;
- auto_vec<rvalue *> m_args;
};
class array_access : public lvalue