From 47ee1b7c10f2aa90645b0d2a94926fa2a674450c Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 10 Aug 2017 00:18:19 +0000 Subject: jit: add gcc_jit_type_get_vector gcc/jit/ChangeLog: * docs/cp/topics/types.rst (Vector types): New section. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_8): New tag. * docs/topics/types.rst (gcc_jit_context_get_type): Fix typo in example. (Vector types): New section. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::type::get_vector): New method. * jit-playback.h (gcc::jit::playback::type::get_vector): New method. * jit-recording.c: In namespace gcc::jit::recording:: (type::get_vector): New method. (memento_of_get_aligned::write_reproducer): Fix typo in leading comment. (memento_of_get_vector::replay_into): New method. (memento_of_get_vector::make_debug_string): New method. (memento_of_get_vector::write_reproducer): New method. * jit-recording.h: In namespace gcc::jit::recording:: (type::get_vector): New method. (class memento_of_get_vector): New class. * libgccjit++.h (gccjit::type::get_vector): New method. * libgccjit.c (gcc_jit_type_get_vector): New public entrypoint. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_type_get_vector): New define. (gcc_jit_type_get_vector): New decl. * libgccjit.map (LIBGCCJIT_ABI_8): New ABI tag. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add note about test-vector-types.cc. * jit.dg/test-error-gcc_jit_type_get_vector-bad-type.c: New test case. * jit.dg/test-error-gcc_jit_type_get_vector-non-power-of-two.c: New test case. * jit.dg/test-vector-types.cc: New test case. From-SVN: r251018 --- gcc/jit/libgccjit.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gcc/jit/libgccjit.c') diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 9b003e3..6e352c6 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -2994,3 +2994,31 @@ gcc_jit_type_get_aligned (gcc_jit_type *type, return (gcc_jit_type *)type->get_aligned (alignment_in_bytes); } + +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the + gcc::jit::recording::type::get_vector method, in + jit-recording.c. */ + +gcc_jit_type * +gcc_jit_type_get_vector (gcc_jit_type *type, size_t num_units) +{ + RETURN_NULL_IF_FAIL (type, NULL, NULL, "NULL type"); + + gcc::jit::recording::context *ctxt = type->m_ctxt; + + JIT_LOG_FUNC (ctxt->get_logger ()); + + RETURN_NULL_IF_FAIL_PRINTF1 + (type->is_int () || type->is_float (), ctxt, NULL, + "type is not integral or floating point: %s", + type->get_debug_string ()); + + RETURN_NULL_IF_FAIL_PRINTF1 + (pow2_or_zerop (num_units), ctxt, NULL, + "num_units not a power of two: %zi", + num_units); + + return (gcc_jit_type *)type->get_vector (num_units); +} -- cgit v1.1