diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-01-09 20:10:11 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-01-09 20:10:11 +0000 |
commit | ccce3b2ac3c9352501278d36b3c79f049234870b (patch) | |
tree | 61e9e361de747f905be63bd0d96940d2f0d1c39b /gcc/jit/jit-playback.c | |
parent | 486b97f297eb20c5b72140ea257ff63143a69ab7 (diff) | |
download | gcc-ccce3b2ac3c9352501278d36b3c79f049234870b.zip gcc-ccce3b2ac3c9352501278d36b3c79f049234870b.tar.gz gcc-ccce3b2ac3c9352501278d36b3c79f049234870b.tar.bz2 |
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.
From-SVN: r219401
Diffstat (limited to 'gcc/jit/jit-playback.c')
-rw-r--r-- | gcc/jit/jit-playback.c | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 4019778..9c3bc17 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -486,12 +486,25 @@ new_global (location *loc, return new lvalue (this, inner); } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Implementation of the various + gcc::jit::playback::context::new_rvalue_from_const <HOST_TYPE> + methods. + Each of these constructs a playback::rvalue instance (wrapping a tree). -playback::rvalue * -playback::context:: -new_rvalue_from_int (type *type, - int value) + These specializations are required to be in the same namespace + as the template, hence we now have to enter the gcc::jit::playback + namespace. */ + +namespace playback +{ + +/* Specialization of making an rvalue from a const, for host <int>. */ + +template <> +rvalue * +context:: +new_rvalue_from_const <int> (type *type, + int value) { // FIXME: type-checking, or coercion? tree inner_type = type->as_tree (); @@ -509,12 +522,37 @@ new_rvalue_from_int (type *type, } } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Specialization of making an rvalue from a const, for host <long>. */ -playback::rvalue * -playback::context:: -new_rvalue_from_double (type *type, - double value) +template <> +rvalue * +context:: +new_rvalue_from_const <long> (type *type, + long value) +{ + // FIXME: type-checking, or coercion? + tree inner_type = type->as_tree (); + if (INTEGRAL_TYPE_P (inner_type)) + { + tree inner = build_int_cst (inner_type, value); + return new rvalue (this, inner); + } + else + { + REAL_VALUE_TYPE real_value; + real_from_integer (&real_value, VOIDmode, value, SIGNED); + tree inner = build_real (inner_type, real_value); + return new rvalue (this, inner); + } +} + +/* Specialization of making an rvalue from a const, for host <double>. */ + +template <> +rvalue * +context:: +new_rvalue_from_const <double> (type *type, + double value) { // FIXME: type-checking, or coercion? tree inner_type = type->as_tree (); @@ -539,12 +577,13 @@ new_rvalue_from_double (type *type, return new rvalue (this, inner); } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Specialization of making an rvalue from a const, for host <void *>. */ -playback::rvalue * -playback::context:: -new_rvalue_from_ptr (type *type, - void *value) +template <> +rvalue * +context:: +new_rvalue_from_const <void *> (type *type, + void *value) { tree inner_type = type->as_tree (); /* FIXME: how to ensure we have a wide enough type? */ @@ -552,6 +591,12 @@ new_rvalue_from_ptr (type *type, return new rvalue (this, inner); } +/* We're done implementing the specializations of + gcc::jit::playback::context::new_rvalue_from_const <T> + so we can exit the gcc::jit::playback namespace. */ + +} // namespace playback + /* Construct a playback::rvalue instance (wrapping a tree). */ playback::rvalue * |