diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-09 20:10:11 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-09 20:10:11 +0000 |
commit | feea5a1ffb846e07cc669e37fbb89991114bc589 (patch) | |
tree | 61e9e361de747f905be63bd0d96940d2f0d1c39b /gcc/jit/jit-recording.h | |
parent | 9c4a0128012b7201df41c6608d47bb666216f876 (diff) | |
download | gcc-feea5a1ffb846e07cc669e37fbb89991114bc589.tar.gz |
New jit API entrypoint: gcc_jit_context_new_rvalue_from_long
gcc/jit/ChangeLog:
* docs/cp/topics/expressions.rst (Simple expressions): Use
":c:type:" for C types. Document new overload of
gcc::jit::context::new_rvalue.
* docs/topics/expressions.rst (Simple expressions): Use
":c:type:" for C types. Document new entrypoint
gcc_jit_context_new_rvalue_from_long.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* jit-playback.c: Within namespace gcc::jit::playback...
(context::new_rvalue_from_int): Eliminate in favor of...
(context::new_rvalue_from_const <int>): ...this.
(context::new_rvalue_from_double): Eliminate in favor of...
(context::new_rvalue_from_const <double>): ...this.
(context::new_rvalue_from_const <long>): New.
(context::new_rvalue_from_ptr): Eliminate in favor of...
(context::new_rvalue_from_const <void *>): ...this.
* jit-playback.h: Within namespace gcc::jit::playback...
(context::new_rvalue_from_int): Eliminate in favor of...
(context::new_rvalue_from_const <HOST_TYPE>): ...this.
(context::new_rvalue_from_double): Likewise.
(context::new_rvalue_from_ptr): Likewise.
* jit-recording.c: Within namespace gcc::jit::recording...
(context::new_rvalue_from_int): Eliminate.
(context::new_rvalue_from_double): Likewise.
(context::new_rvalue_from_ptr): Likewise.
(class memento_of_new_rvalue_from_const <int>):
Add explicit specialization.
(class memento_of_new_rvalue_from_const <long>):
Likewise.
(class memento_of_new_rvalue_from_const <double>):
Likewise.
(class memento_of_new_rvalue_from_const <void *>):
Likewise.
(memento_of_new_rvalue_from_int::replay_into):
Generalize into...
(memento_of_new_rvalue_from_const <HOST_TYPE>::replay_into):
...this...
(memento_of_new_rvalue_from_double::replay_into):
...allowing this...
(memento_of_new_rvalue_from_ptr::replay_into):
...and this to be deleted.
(memento_of_new_rvalue_from_int::make_debug_string):
Convert to...
(memento_of_new_rvalue_from_const <int>::make_debug_string):
...this.
(memento_of_new_rvalue_from_double::make_debug_string):
Convert to...
(memento_of_new_rvalue_from_const <double>::make_debug_string):
...this.
(memento_of_new_rvalue_from_ptr::make_debug_string)
Convert to...
(memento_of_new_rvalue_from_const <void *>::make_debug_string):
...this.
(memento_of_new_rvalue_from_const <long>::make_debug_string):
New function.
* jit-recording.h: Within namespace gcc::jit::recording...
(context::new_rvalue_from_int): Eliminate.
(context::new_rvalue_from_double): Likewise.
(context::new_rvalue_from_ptr): Likewise, all in favor of...
(context::new_rvalue_from_const <HOST_TYPE>): New family of
methods.
(class memento_of_new_rvalue_from_int): Eliminate.
(class memento_of_new_rvalue_from_double): Likewise.
(class memento_of_new_rvalue_from_ptr): Likewise.
(class memento_of_new_rvalue_from_const <HOST_TYPE>): New family
of rvalue subclasses.
* libgccjit++.h (gccjit::context::new_rvalue): New overload, for
"long".
* libgccjit.c (gcc_jit_context_new_rvalue_from_int): Update for
rewriting of recording::context::new_rvalue_from_int to
recording::context::new_rvalue_from_const <int>.
(gcc_jit_context_new_rvalue_from_long): New API entrypoint.
(gcc_jit_context_new_rvalue_from_double): Update for
rewriting of recording::context::new_rvalue_from_double to
recording::context::new_rvalue_from_const <double>.
(gcc_jit_context_new_rvalue_from_ptr): Update for
rewriting of recording::context::new_rvalue_from_ptr to
recording::context::new_rvalue_from_const <void *>.
* libgccjit.h (gcc_jit_context_new_rvalue_from_long): New API
entrypoint.
* libgccjit.map (gcc_jit_context_new_rvalue_from_long): Likewise.
gcc/testsuite/ChangeLog:
* jit.dg/all-non-failing-tests.h: Add test-constants.c.
* jit.dg/test-combination.c (create_code): Likewise.
(verify_code): Likewise.
* jit.dg/test-constants.c: New test case.
* jit.dg/test-threads.c: Add test-constants.c.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219401 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/jit/jit-recording.h')
-rw-r--r-- | gcc/jit/jit-recording.h | 85 |
1 files changed, 28 insertions, 57 deletions
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 94179938d41..8d154874366 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -135,17 +135,10 @@ public: type *type, const char *name); + template <typename HOST_TYPE> rvalue * - new_rvalue_from_int (type *numeric_type, - int value); - - rvalue * - new_rvalue_from_double (type *numeric_type, - double value); - - rvalue * - new_rvalue_from_ptr (type *pointer_type, - void *value); + new_rvalue_from_const (type *type, + HOST_TYPE value); rvalue * new_string_literal (const char *value); @@ -1073,14 +1066,15 @@ private: string *m_name; }; -class memento_of_new_rvalue_from_int : public rvalue +template <typename HOST_TYPE> +class memento_of_new_rvalue_from_const : public rvalue { public: - memento_of_new_rvalue_from_int (context *ctxt, - location *loc, - type *numeric_type, - int value) - : rvalue (ctxt, loc, numeric_type), + memento_of_new_rvalue_from_const (context *ctxt, + location *loc, + type *type, + HOST_TYPE value) + : rvalue (ctxt, loc, type), m_value (value) {} void replay_into (replayer *r); @@ -1089,47 +1083,7 @@ private: string * make_debug_string (); private: - int m_value; -}; - -class memento_of_new_rvalue_from_double : public rvalue -{ -public: - memento_of_new_rvalue_from_double (context *ctxt, - location *loc, - type *numeric_type, - double value) - : rvalue (ctxt, loc, numeric_type), - m_value (value) - {} - - void replay_into (replayer *); - -private: - string * make_debug_string (); - -private: - double m_value; -}; - -class memento_of_new_rvalue_from_ptr : public rvalue -{ -public: - memento_of_new_rvalue_from_ptr (context *ctxt, - location *loc, - type *pointer_type, - void *value) - : rvalue (ctxt, loc, pointer_type), - m_value (value) - {} - - void replay_into (replayer *); - -private: - string * make_debug_string (); - -private: - void *m_value; + HOST_TYPE m_value; }; class memento_of_new_string_literal : public rvalue @@ -1605,6 +1559,23 @@ private: } // namespace gcc::jit::recording +/* Create a recording::memento_of_new_rvalue_from_const instance and add + it to this context's list of mementos. + + Implements the post-error-checking part of + gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */ + +template <typename HOST_TYPE> +recording::rvalue * +recording::context::new_rvalue_from_const (recording::type *type, + HOST_TYPE value) +{ + recording::rvalue *result = + new memento_of_new_rvalue_from_const <HOST_TYPE> (this, NULL, type, value); + record (result); + return result; +} + } // namespace gcc::jit } // namespace gcc |