diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-10-04 13:41:01 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-10-04 13:41:01 +0000 |
commit | 6069fe72870e410c08570e94ce2b141c6bc88219 (patch) | |
tree | 5a934460e85fcef8a36ea6e8242e0d10b59be28e /gcc/jit/jit-recording.h | |
parent | 4f15b6a282bc4c11ee8b32dac4f05aab10ce3e10 (diff) | |
download | gcc-6069fe72870e410c08570e94ce2b141c6bc88219.zip gcc-6069fe72870e410c08570e94ce2b141c6bc88219.tar.gz gcc-6069fe72870e410c08570e94ce2b141c6bc88219.tar.bz2 |
jit: implement gcc_jit_context_new_rvalue_from_vector
This patch implements a new API entrypoint:
/* Build a vector rvalue from an array of elements.
"vec_type" should be a vector type, created using gcc_jit_type_get_vector.
This API entrypoint was added in LIBGCCJIT_ABI_10; you can test for its
presence using
#ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector
*/
extern gcc_jit_rvalue *
gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt,
gcc_jit_location *loc,
gcc_jit_type *vec_type,
size_t num_elements,
gcc_jit_rvalue **elements);
gcc/jit/ChangeLog:
* docs/cp/topics/expressions.rst (Vector expressions): New
section.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_10): New ABI tag.
* docs/topics/expressions.rst (Vector expressions): New section.
* docs/topics/types.rst (gcc_jit_type_get_vector): Add link to
gcc_jit_context_new_rvalue_from_vector.
* jit-common.h (gcc::jit:recording::vector_type): New forward
decl.
* jit-playback.c
(gcc::jit::playback::context::new_rvalue_from_vector): New method.
* jit-playback.h
(gcc::jit::playback::context::new_rvalue_from_vector): New method.
* jit-recording.c: In namespace gcc::jit::
(class comma_separated_string): New class.
(comma_separated_string::comma_separated_string): New ctor,
adapted from recording::call::make_debug_string.
(comma_separated_string::~comma_separated_string): New dtor.
In namespace gcc::jit::recording::
(context::new_rvalue_from_vector): New method.
(type::get_vector): Update for renaming of memento_of_get_vector.
(class memento_of_get_vector): Rename to...
(class vector_type): ..this.
(memento_of_new_rvalue_from_vector::memento_of_new_rvalue_from_vector):
New ctor.
(memento_of_new_rvalue_from_vector::replay_into): New method.
(memento_of_new_rvalue_from_vector::visit_children): New method.
(memento_of_new_rvalue_from_vector::make_debug_string): New
method.
(memento_of_new_rvalue_from_vector::write_reproducer): New method.
(call::make_debug_string): Split out arg-printing code into ctor
for comma_separated_string.
* jit-recording.h: In namespace gcc::jit::recording::
(context::new_rvalue_from_vector): New method.
(type::dyn_cast_vector_type): New virtual function.
(class memento_of_get_vector): Rename to...
(class vector_type): ...this.
(vector_type::unqualified): Remove this vfunc override in favor
of...
(vector_type::get_element_type): ...this new method.
(vector_type::get_num_units): New method.
(vector_type::dyn_cast_vector_type): New vfunc override.
(class memento_of_new_rvalue_from_vector): New class.
* libgccjit++.h (gccjit::context::new_rvalue): Add overload for
vector of rvalue.
* libgccjit.c (gcc_jit_context_new_binary_op): Strip off type
qualifications when checking that both operands have same type.
(gcc_jit_context_new_rvalue_from_vector): New API entrypoint.
* libgccjit.h
(LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector): New
macro.
(gcc_jit_context_new_rvalue_from_vector): New API entrypoint.
* libgccjit.map (LIBGCCJIT_ABI_10): New ABI tag.
gcc/testsuite/ChangeLog:
* jit.dg/test-expressions.c (make_test_of_vectors): New function.
(create_code): Call it.
* jit.dg/test-vector-rvalues.cc: New test case.
From-SVN: r253409
Diffstat (limited to 'gcc/jit/jit-recording.h')
-rw-r--r-- | gcc/jit/jit-recording.h | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 9123645..6a3fd5d 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -149,6 +149,11 @@ public: new_string_literal (const char *value); rvalue * + new_rvalue_from_vector (location *loc, + vector_type *type, + rvalue **elements); + + rvalue * new_unary_op (location *loc, enum gcc_jit_unary_op op, type *result_type, @@ -486,6 +491,7 @@ public: virtual function_type *dyn_cast_function_type () { return NULL; } virtual function_type *as_a_function_type() { gcc_unreachable (); return NULL; } virtual struct_ *dyn_cast_struct () { return NULL; } + virtual vector_type *dyn_cast_vector_type () { return NULL; } /* Is it typesafe to copy to this type from rtype? */ virtual bool accepts_writes_from (type *rtype) @@ -690,15 +696,18 @@ private: }; /* Result of "gcc_jit_type_get_vector". */ -class memento_of_get_vector : public decorated_type +class vector_type : public decorated_type { public: - memento_of_get_vector (type *other_type, size_t num_units) + vector_type (type *other_type, size_t num_units) : decorated_type (other_type), m_num_units (num_units) {} - /* Strip off the alignment, giving the underlying type. */ - type *unqualified () FINAL OVERRIDE { return m_other_type; } + size_t get_num_units () const { return m_num_units; } + + vector_type *dyn_cast_vector_type () FINAL OVERRIDE { return this; } + + type *get_element_type () { return m_other_type; } void replay_into (replayer *) FINAL OVERRIDE; @@ -1358,6 +1367,31 @@ private: string *m_value; }; +class memento_of_new_rvalue_from_vector : public rvalue +{ +public: + memento_of_new_rvalue_from_vector (context *ctxt, + location *loc, + vector_type *type, + rvalue **elements); + + void replay_into (replayer *r) FINAL OVERRIDE; + + void visit_children (rvalue_visitor *) 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_PRIMARY; + } + +private: + vector_type *m_vector_type; + auto_vec<rvalue *> m_elements; +}; + class unary_op : public rvalue { public: |