aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/docs/topics/functions.rst
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2020-05-26 09:28:16 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2020-05-26 18:00:46 -0400
commitbf40f0ba95037f235b007a55a7682646a0578b26 (patch)
tree7d94d8725092b5961d9d641b62a141da11cc6ad4 /gcc/jit/docs/topics/functions.rst
parent56f03cd12be26828788a27f6f3c250041a958e45 (diff)
downloadgcc-bf40f0ba95037f235b007a55a7682646a0578b26.zip
gcc-bf40f0ba95037f235b007a55a7682646a0578b26.tar.gz
gcc-bf40f0ba95037f235b007a55a7682646a0578b26.tar.bz2
jit: fix missing types for builtins [PR 95306]
PR jit/95306 reports that attempts to use builtins __builtin_sadd_overflow" and "__builtin_memcpy" via gcc_jit_context_get_builtin_function lead to inscrutable error messages of the form: unimplemented primitive type for builtin: 42 and: unimplemented primitive type for builtin: 38 The root cause is that jit-builtins.c only implements a subset of the types defined via DEF_PRIMITIVE_TYPE in builtin-types.def. This patch: - implements enough types to enable the above two builtins to be referenced - documents gcc_jit_context_get_builtin_function, and notes the limitation that not all types are supported (supporting some of them would take a lot of extra work) - improves the error message for the unsupported cases - adds a testcase for __builtin_memcpy. This required jit_langhook_global_bindings_p to be implemented (otherwise the assertion there failed deep inside "expand" on the builtin) - adds test coverage for the above gcc/jit/ChangeLog: PR jit/95306 * docs/topics/functions.rst (gcc_jit_context_get_builtin_function): Document. * docs/_build/texinfo/libgccjit.texi: Regenerate. * dummy-frontend.c (jit_langhook_global_bindings_p): Remove gcc_unreachable. * jit-builtins.c (type_names): New array. (get_string_for_type_id): New function. (gcc::jit::builtins_manager::make_primitive_type): Show name of type in error messages. Update cases to reflect the order in builtin-types.def. Implement cases for BT_INT8, BT_INT16, BT_UINT8, BT_CONST_PTR, BT_VOLATILE_PTR, BT_INT_PTR, BT_FLOAT_PTR, BT_CONST_DOUBLE_PTR, BT_SIZE, BT_CONST_SIZE. gcc/testsuite/ChangeLog: PR jit/95306 * jit.dg/all-non-failing-tests.h: Add test-builtin-memcpy.c and test-pr95306-builtin-types.c. * jit.dg/test-builtin-memcpy.c: New test. * jit.dg/test-error-gcc_jit_context_get_builtin_function-unimplemented-type.c: New test. * jit.dg/test-pr95306-builtin-types.c: New test.
Diffstat (limited to 'gcc/jit/docs/topics/functions.rst')
-rw-r--r--gcc/jit/docs/topics/functions.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/jit/docs/topics/functions.rst b/gcc/jit/docs/topics/functions.rst
index 29ce96c..eb40d64 100644
--- a/gcc/jit/docs/topics/functions.rst
+++ b/gcc/jit/docs/topics/functions.rst
@@ -125,6 +125,21 @@ Functions
gcc_jit_context_get_builtin_function (gcc_jit_context *ctxt,\
const char *name)
+ Get the :type:`gcc_jit_function` for the built-in function with the
+ given name. For example:
+
+ .. code-block:: c
+
+ gcc_jit_function *fn
+ = gcc_jit_context_get_builtin_function (ctxt, "__builtin_memcpy");
+
+ .. note:: Due to technical limitations with how libgccjit interacts with
+ the insides of GCC, not all built-in functions are supported. More
+ precisely, not all types are supported for parameters of built-in
+ functions from libgccjit. Attempts to get a built-in function that
+ uses such a parameter will lead to an error being emitted within
+ the context.
+
.. function:: gcc_jit_object *\
gcc_jit_function_as_object (gcc_jit_function *func)