diff options
author | Antoni Boucher <bouanto@zoho.com> | 2022-04-12 17:16:45 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2022-04-12 17:16:45 -0400 |
commit | af80ea97b61847d91da0d303e85faed437059092 (patch) | |
tree | 88bd7c9a068ead6db362db4dc97907fe76d68669 /gcc/jit/libgccjit.cc | |
parent | 791a968630b3846b614a435b9a75a52f29147a08 (diff) | |
download | gcc-af80ea97b61847d91da0d303e85faed437059092.zip gcc-af80ea97b61847d91da0d303e85faed437059092.tar.gz gcc-af80ea97b61847d91da0d303e85faed437059092.tar.bz2 |
libgccjit: Add support for sized integer types, including 128-bit integers [PR95325]
gcc/jit/
PR target/95325
* docs/_build/texinfo/libgccjit.texi: Regenerate
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_20): New ABI tag.
* docs/topics/types.rst: Add documentation for the new types
GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T, GCC_JIT_TYPE_INT16_T,
GCC_JIT_TYPE_INT32_T, GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T and
new functions (gcc_jit_compatible_types, gcc_jit_type_get_size).
* jit-builtins.cc: Add support for BT_UINT128.
* jit-common.h: Update the value of NUM_GCC_JIT_TYPES.
* jit-playback.cc: Add support for the sized integer types.
* jit-recording.cc: Add support for the sized integer types.
* jit-recording.h: Add support for comparing integer types
and new function (is_signed).
* libgccjit.cc (gcc_jit_compatible_types): New.
(gcc_jit_type_get_size) New.
* libgccjit.h: New enum variants for gcc_jit_types
(GCC_JIT_TYPE_UINT8_T, GCC_JIT_TYPE_UINT16_T,
GCC_JIT_TYPE_UINT32_T, GCC_JIT_TYPE_UINT64_T,
GCC_JIT_TYPE_UINT128_T, GCC_JIT_TYPE_INT8_T,
GCC_JIT_TYPE_INT16_T, GCC_JIT_TYPE_INT32_T,
GCC_JIT_TYPE_INT64_T, GCC_JIT_TYPE_INT128_T) and new functions
(gcc_jit_compatible_types, gcc_jit_type_get_size).
* libgccjit.map (LIBGCCJIT_ABI_20): New ABI tag.
gcc/testsuite/
PR target/95325
* jit.dg/test-types.c: Add tests for sized integer types.
Diffstat (limited to 'gcc/jit/libgccjit.cc')
-rw-r--r-- | gcc/jit/libgccjit.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 4c352e8..44395d7 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -352,6 +352,17 @@ compatible_types (gcc::jit::recording::type *ltype, return ltype->accepts_writes_from (rtype); } +/* Public entrypoint wrapping compatible_types. */ + +int +gcc_jit_compatible_types (gcc_jit_type *ltype, + gcc_jit_type *rtype) +{ + RETURN_VAL_IF_FAIL (ltype, 0, NULL, NULL, "NULL ltype"); + RETURN_VAL_IF_FAIL (rtype, 0, NULL, NULL, "NULL rtype"); + return compatible_types (ltype, rtype); +} + /* Public entrypoint for acquiring a gcc_jit_context. Note that this creates a new top-level context; contrast with gcc_jit_context_new_child_context below. @@ -456,7 +467,7 @@ gcc_jit_context_get_type (gcc_jit_context *ctxt, JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_PRINTF1 ( (type >= GCC_JIT_TYPE_VOID - && type <= GCC_JIT_TYPE_FILE_PTR), + && type < NUM_GCC_JIT_TYPES), ctxt, NULL, "unrecognized value for enum gcc_jit_types: %i", type); @@ -526,6 +537,22 @@ gcc_jit_type_get_volatile (gcc_jit_type *type) /* Public entrypoint. See description in libgccjit.h. After error-checking, the real work is done by the + gcc::jit::recording::type::get_size method, in + jit-recording.cc. */ + +ssize_t +gcc_jit_type_get_size (gcc_jit_type *type) +{ + RETURN_VAL_IF_FAIL (type, -1, NULL, NULL, "NULL type"); + RETURN_VAL_IF_FAIL + (type->is_int (), -1, NULL, NULL, + "only getting the size of an integer type is supported for now"); + return type->get_size (); +} + +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the gcc::jit::recording::type::is_array method, in jit-recording.cc. */ @@ -2119,7 +2146,8 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt, RETURN_NULL_IF_FAIL (a, ctxt, loc, "NULL a"); RETURN_NULL_IF_FAIL (b, ctxt, loc, "NULL b"); RETURN_NULL_IF_FAIL_PRINTF4 ( - a->get_type ()->unqualified () == b->get_type ()->unqualified (), + compatible_types (a->get_type ()->unqualified (), + b->get_type ()->unqualified ()), ctxt, loc, "mismatching types for binary op:" " a: %s (type: %s) b: %s (type: %s)", |