diff options
author | Antoni Boucher <bouanto@zoho.com> | 2022-04-12 17:17:50 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2022-04-12 17:17:50 -0400 |
commit | 30f7c83e9cfe7c015448d72f63c4c39d14bc6de6 (patch) | |
tree | 9cb2b8d0acf1b0a5e779e85c1cd53ce8d17a270f /gcc/jit/jit-playback.cc | |
parent | af80ea97b61847d91da0d303e85faed437059092 (diff) | |
download | gcc-30f7c83e9cfe7c015448d72f63c4c39d14bc6de6.zip gcc-30f7c83e9cfe7c015448d72f63c4c39d14bc6de6.tar.gz gcc-30f7c83e9cfe7c015448d72f63c4c39d14bc6de6.tar.bz2 |
libgccjit: Add support for bitcasts [PR104071]
gcc/jit/
PR jit/104071
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_21): New ABI tag.
* docs/topics/expressions.rst: Add documentation for the
function gcc_jit_context_new_bitcast.
* jit-playback.cc: New function (new_bitcast).
* jit-playback.h: New function (new_bitcast).
* jit-recording.cc: New functions (new_bitcast,
bitcast::replay_into, bitcast::visit_children,
bitcast::make_debug_string, bitcast::write_reproducer).
* jit-recording.h: New class (bitcast) and new function
(new_bitcast, bitcast::replay_into, bitcast::visit_children,
bitcast::make_debug_string, bitcast::write_reproducer,
bitcast::get_precedence).
* libgccjit.cc: New function (gcc_jit_context_new_bitcast)
* libgccjit.h: New function (gcc_jit_context_new_bitcast)
* libgccjit.map (LIBGCCJIT_ABI_21): New ABI tag.
gcc/testsuite/
PR jit/104071
* jit.dg/all-non-failing-tests.h: Add new test-bitcast.
* jit.dg/test-bitcast.c: New test.
* jit.dg/test-error-bad-bitcast.c: New test.
* jit.dg/test-error-bad-bitcast2.c: New test.
gcc/
PR jit/104071
* toplev.cc: Call the new function tree_cc_finalize in
toplev::finalize.
* tree.cc: New functions (clear_nonstandard_integer_type_cache
and tree_cc_finalize) to clear the cache of non-standard integer
types to avoid having issues with some optimizations of
bitcast where the SSA_NAME will have a size of a cached
integer type that should have been invalidated, causing a
comparison of integer constant to fail.
* tree.h: New function (tree_cc_finalize).
Diffstat (limited to 'gcc/jit/jit-playback.cc')
-rw-r--r-- | gcc/jit/jit-playback.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 3133d30..b1e72fb 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -1422,6 +1422,36 @@ new_cast (playback::location *loc, return new rvalue (this, t_cast); } +/* Construct a playback::rvalue instance (wrapping a tree) for a + bitcast. */ + +playback::rvalue * +playback::context:: +new_bitcast (location *loc, + rvalue *expr, + type *type_) +{ + tree expr_size = TYPE_SIZE (expr->get_type ()->as_tree ()); + tree type_size = TYPE_SIZE (type_->as_tree ()); + tree t_expr = expr->as_tree (); + tree t_dst_type = type_->as_tree (); + if (expr_size != type_size) + { + active_playback_ctxt->add_error (loc, + "bitcast with types of different sizes"); + fprintf (stderr, "input expression (size: %ld):\n", + tree_to_uhwi (expr_size)); + debug_tree (t_expr); + fprintf (stderr, "requested type (size: %ld):\n", + tree_to_uhwi (type_size)); + debug_tree (t_dst_type); + } + tree t_bitcast = build1 (VIEW_CONVERT_EXPR, t_dst_type, t_expr); + if (loc) + set_tree_location (t_bitcast, loc); + return new rvalue (this, t_bitcast); +} + /* Construct a playback::lvalue instance (wrapping a tree) for an array access. */ |