aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/jit-recording.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-09-27 23:57:35 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-09-27 23:57:35 +0000
commit15a65e63a471bd12dd92a0451b6b7800e93cd1f1 (patch)
treeeec3c9737eac82b39d96eb745dceee94e4ff259d /gcc/jit/jit-recording.h
parenta509c571eae4cb1ab3e79c044d93b1d79bde0798 (diff)
downloadgcc-15a65e63a471bd12dd92a0451b6b7800e93cd1f1.zip
gcc-15a65e63a471bd12dd92a0451b6b7800e93cd1f1.tar.gz
gcc-15a65e63a471bd12dd92a0451b6b7800e93cd1f1.tar.bz2
jit: implement gcc_jit_function_get_address
gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst (Function pointers): New section. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_9): New tag. * docs/topics/expressions.rst (Function pointers): New section. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-common.h (class gcc::jit::recording::function_pointer): New forward decl. * jit-playback.c (gcc::jit::playback::function::get_address): New method. * jit-playback.h (gcc::jit::playback::function::get_address): New method decl. * jit-recording.c: Within namespace gcc::jit::recording... (function::function): Initialize new field "m_fn_ptr_type". (function::get_address): New method. (function_pointer::replay_into): New method. (function_pointer::visit_children): New method. (function_pointer::make_debug_string): New method. (function_pointer::write_reproducer): New method. * jit-recording.h: Within namespace gcc::jit::recording... (function::get_address): New method. (function): Add field "m_fn_ptr_type". (class function_pointer): New subclass of rvalue. * libgccjit++.h (gccjit::function::get_address): New method. * libgccjit.c (gcc_jit_function_get_address): New function. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_function_get_address): New macro. (gcc_jit_function_get_address): New API entrypoint. * libgccjit.map (LIBGCCJIT_ABI_9): New tag. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-returning-function-ptr.c. * jit.dg/test-returning-function-ptr.c: New test case. From-SVN: r253244
Diffstat (limited to 'gcc/jit/jit-recording.h')
-rw-r--r--gcc/jit/jit-recording.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 248765d..8918124 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -1145,6 +1145,8 @@ public:
void dump_to_dot (const char *path);
+ rvalue *get_address (location *loc);
+
private:
string * make_debug_string () FINAL OVERRIDE;
void write_reproducer (reproducer &r) FINAL OVERRIDE;
@@ -1159,6 +1161,7 @@ private:
enum built_in_function m_builtin_id;
auto_vec<local *> m_locals;
auto_vec<block *> m_blocks;
+ type *m_fn_ptr_type;
};
class block : public memento
@@ -1699,6 +1702,32 @@ private:
lvalue *m_lvalue;
};
+class function_pointer : public rvalue
+{
+public:
+ function_pointer (context *ctxt,
+ location *loc,
+ function *fn,
+ type *type)
+ : rvalue (ctxt, loc, type),
+ m_fn (fn) {}
+
+ void replay_into (replayer *r) FINAL OVERRIDE;
+
+ void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
+
+private:
+ string * make_debug_string () FINAL OVERRIDE;
+ void write_reproducer (reproducer &r) FINAL OVERRIDE;
+ enum precedence get_precedence () const FINAL OVERRIDE
+ {
+ return PRECEDENCE_UNARY;
+ }
+
+private:
+ function *m_fn;
+};
+
class local : public lvalue
{
public: