diff options
author | Antoni Boucher <bouanto@zoho.com> | 2023-11-16 10:59:22 -0500 |
---|---|---|
committer | Antoni Boucher <bouanto@zoho.com> | 2024-07-05 09:46:04 -0400 |
commit | 1c314247aab43aaa278ecc51d666f8c5896d8bbb (patch) | |
tree | 89eebdb9757010aa9e3085fd70a21d781b1e083c /gcc/jit | |
parent | 4da5dc4be81b2797943fea44b0d40ac04700baee (diff) | |
download | gcc-1c314247aab43aaa278ecc51d666f8c5896d8bbb.zip gcc-1c314247aab43aaa278ecc51d666f8c5896d8bbb.tar.gz gcc-1c314247aab43aaa278ecc51d666f8c5896d8bbb.tar.bz2 |
libgccjit: Add support for the type bfloat16
gcc/jit/ChangeLog:
PR jit/112574
* docs/topics/types.rst: Document GCC_JIT_TYPE_BFLOAT16.
* jit-common.h: Update NUM_GCC_JIT_TYPES.
* jit-playback.cc (get_tree_node_for_type): Support bfloat16.
* jit-recording.cc (recording::memento_of_get_type::get_size,
recording::memento_of_get_type::dereference,
recording::memento_of_get_type::is_int,
recording::memento_of_get_type::is_signed,
recording::memento_of_get_type::is_float,
recording::memento_of_get_type::is_bool): Support bfloat16.
* libgccjit.h (enum gcc_jit_types): Add GCC_JIT_TYPE_BFLOAT16.
gcc/testsuite/ChangeLog:
PR jit/112574
* jit.dg/all-non-failing-tests.h: New test test-bfloat16.c.
* jit.dg/test-types.c: Test GCC_JIT_TYPE_BFLOAT16.
* jit.dg/test-bfloat16.c: New test.
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/docs/topics/types.rst | 2 | ||||
-rw-r--r-- | gcc/jit/jit-common.h | 2 | ||||
-rw-r--r-- | gcc/jit/jit-playback.cc | 6 | ||||
-rw-r--r-- | gcc/jit/jit-recording.cc | 11 | ||||
-rw-r--r-- | gcc/jit/libgccjit.h | 4 |
5 files changed, 23 insertions, 2 deletions
diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst index bb51f03..6a7a352 100644 --- a/gcc/jit/docs/topics/types.rst +++ b/gcc/jit/docs/topics/types.rst @@ -113,6 +113,8 @@ Standard types - C99's ``__int128_t`` * - :c:data:`GCC_JIT_TYPE_FLOAT` - + * - :c:data:`GCC_JIT_TYPE_BFLOAT16` + - C's ``__bfloat16`` * - :c:data:`GCC_JIT_TYPE_DOUBLE` - * - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE` diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h index 1e33587..afb4176 100644 --- a/gcc/jit/jit-common.h +++ b/gcc/jit/jit-common.h @@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. If not see #endif #endif -const int NUM_GCC_JIT_TYPES = GCC_JIT_TYPE_INT128_T + 1; +const int NUM_GCC_JIT_TYPES = GCC_JIT_TYPE_BFLOAT16 + 1; /* This comment is included by the docs. diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index b3f54da..1b5445d 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -281,6 +281,12 @@ get_tree_node_for_type (enum gcc_jit_types type_) case GCC_JIT_TYPE_FLOAT: return float_type_node; + case GCC_JIT_TYPE_BFLOAT16: +#ifndef HAVE_BFmode + add_error (NULL, "gcc_jit_types value unsupported on this target: %i", + type_); +#endif + return bfloat16_type_node; case GCC_JIT_TYPE_DOUBLE: return double_type_node; case GCC_JIT_TYPE_LONG_DOUBLE: diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 43a6795..cc7f529 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -2418,6 +2418,10 @@ recording::memento_of_get_type::get_size () m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE); size = GET_MODE_PRECISION (m).to_constant (); break; +#ifdef HAVE_BFmode + case GCC_JIT_TYPE_BFLOAT16: + return GET_MODE_UNIT_SIZE (BFmode); +#endif case GCC_JIT_TYPE_DOUBLE: m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE); size = GET_MODE_PRECISION (m).to_constant (); @@ -2479,6 +2483,7 @@ recording::memento_of_get_type::dereference () case GCC_JIT_TYPE_INT64_T: case GCC_JIT_TYPE_INT128_T: case GCC_JIT_TYPE_FLOAT: + case GCC_JIT_TYPE_BFLOAT16: case GCC_JIT_TYPE_DOUBLE: case GCC_JIT_TYPE_LONG_DOUBLE: case GCC_JIT_TYPE_COMPLEX_FLOAT: @@ -2543,6 +2548,7 @@ recording::memento_of_get_type::is_int () const return true; case GCC_JIT_TYPE_FLOAT: + case GCC_JIT_TYPE_BFLOAT16: case GCC_JIT_TYPE_DOUBLE: case GCC_JIT_TYPE_LONG_DOUBLE: return false; @@ -2601,6 +2607,7 @@ recording::memento_of_get_type::is_signed () const case GCC_JIT_TYPE_UINT128_T: case GCC_JIT_TYPE_FLOAT: + case GCC_JIT_TYPE_BFLOAT16: case GCC_JIT_TYPE_DOUBLE: case GCC_JIT_TYPE_LONG_DOUBLE: @@ -2660,6 +2667,7 @@ recording::memento_of_get_type::is_float () const return false; case GCC_JIT_TYPE_FLOAT: + case GCC_JIT_TYPE_BFLOAT16: case GCC_JIT_TYPE_DOUBLE: case GCC_JIT_TYPE_LONG_DOUBLE: return true; @@ -2723,6 +2731,7 @@ recording::memento_of_get_type::is_bool () const return false; case GCC_JIT_TYPE_FLOAT: + case GCC_JIT_TYPE_BFLOAT16: case GCC_JIT_TYPE_DOUBLE: case GCC_JIT_TYPE_LONG_DOUBLE: return false; @@ -2803,6 +2812,7 @@ static const char * const get_type_strings[] = { "__int64_t", /* GCC_JIT_TYPE_INT64_T */ "__int128_t", /* GCC_JIT_TYPE_INT128_T */ + "bfloat16", /* GCC_JIT_TYPE_BFLOAT16 */ }; /* Implementation of recording::memento::make_debug_string for @@ -2848,6 +2858,7 @@ static const char * const get_type_enum_strings[] = { "GCC_JIT_TYPE_INT32_T", "GCC_JIT_TYPE_INT64_T", "GCC_JIT_TYPE_INT128_T", + "GCC_JIT_TYPE_BFLOAT16", }; void diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index c82a4be..1d5be27 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -604,7 +604,9 @@ enum gcc_jit_types GCC_JIT_TYPE_INT16_T, GCC_JIT_TYPE_INT32_T, GCC_JIT_TYPE_INT64_T, - GCC_JIT_TYPE_INT128_T + GCC_JIT_TYPE_INT128_T, + + GCC_JIT_TYPE_BFLOAT16, }; extern gcc_jit_type * |