aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/ChangeLog68
-rw-r--r--gcc/jit/docs/topics/compatibility.rst15
-rw-r--r--gcc/jit/docs/topics/contexts.rst16
-rw-r--r--gcc/jit/docs/topics/types.rst26
-rw-r--r--gcc/jit/dummy-frontend.cc83
-rw-r--r--gcc/jit/jit-common.h17
-rw-r--r--gcc/jit/jit-playback.cc48
-rw-r--r--gcc/jit/jit-playback.h7
-rw-r--r--gcc/jit/jit-recording.cc95
-rw-r--r--gcc/jit/jit-recording.h27
-rw-r--r--gcc/jit/libgccjit.cc22
-rw-r--r--gcc/jit/libgccjit.exports20
-rw-r--r--gcc/jit/libgccjit.h24
-rw-r--r--gcc/jit/libgccjit.map10
14 files changed, 430 insertions, 48 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index 1577ea0..2e2230c 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,3 +1,71 @@
+2025-10-20 Antoni Boucher <bouanto@zoho.com>
+
+ * docs/topics/compatibility.rst (LIBGCCJIT_ABI_37): New ABI tag.
+ * docs/topics/types.rst: Document
+ gcc_jit_context_new_array_type_u64.
+ * jit-playback.cc (new_array_type): Change num_elements type to
+ uint64_t.
+ * jit-playback.h (new_array_type): Change num_elements type to
+ uint64_t.
+ * jit-recording.cc (recording::context::new_array_type): Change
+ num_elements type to uint64_t.
+ (recording::array_type::make_debug_string): Use uint64_t
+ format.
+ (recording::array_type::write_reproducer): Switch to
+ gcc_jit_context_new_array_type_u64.
+ * jit-recording.h (class array_type): Change num_elements type
+ to uint64_t.
+ (new_array_type): Change num_elements type to uint64_t.
+ (num_elements): Change return type to uint64_t.
+ * libgccjit.cc (gcc_jit_context_new_array_type_u64):
+ New function.
+ * libgccjit.h (gcc_jit_context_new_array_type_u64):
+ New function.
+ * libgccjit.exports: New function.
+ * libgccjit.map: New function.
+
+2025-10-20 Antoni Boucher <bouanto@zoho.com>
+
+ * jit-playback.cc (add_error, add_error_va): Send DK_ERROR to
+ add_error_va.
+ (add_diagnostic): Call add_diagnostic instead of add_error.
+ * jit-recording.cc (DEFINE_DIAGNOSTIC_KIND): New define.
+ (recording::context::add_diagnostic): New function.
+ (recording::context::add_error): Send DK_ERROR to add_error_va.
+ (recording::context::add_error_va): New parameter diagnostic_kind.
+ * jit-recording.h (add_diagnostic): New function.
+ (add_error_va): New parameter diagnostic_kind.
+ * libgccjit.cc (jit_error): Send DK_ERROR to add_error_va.
+
+2025-10-20 Antoni Boucher <bouanto@zoho.com>
+
+ PR jit/105827
+ * dummy-frontend.cc: Fix lang_tree_node.
+ * jit-common.h: New function (jit_tree_chain_next) used by
+ lang_tree_node.
+
+2025-10-20 Antoni Boucher <bouanto@zoho.com>
+
+ PR jit/117886
+ * dummy-frontend.cc: Support some missing types.
+ * jit-playback.h (get_abort_on_unsupported_target_builtin): New
+ function.
+ * jit-recording.cc (get_abort_on_unsupported_target_builtin,
+ set_abort_on_unsupported_target_builtin): New functions.
+ * jit-recording.h (get_abort_on_unsupported_target_builtin,
+ set_abort_on_unsupported_target_builtin): New functions.
+ (m_abort_on_unsupported_target_builtin): New field.
+ * libgccjit.cc
+ (gcc_jit_context_set_abort_on_unsupported_target_builtin): New
+ function.
+ * libgccjit.h
+ (gcc_jit_context_set_abort_on_unsupported_target_builtin): New
+ function.
+ * libgccjit.exports (LIBGCCJIT_ABI_36): New ABI tag.
+ * libgccjit.map (LIBGCCJIT_ABI_36): New ABI tag.
+ * docs/topics/compatibility.rst (LIBGCCJIT_ABI_36): New ABI tag.
+ * docs/topics/contexts.rst: Document new function.
+
2025-10-08 Antoni Boucher <bouanto@zoho.com>
PR jit/112466
diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst
index 19be33e..1f8c4d9 100644
--- a/gcc/jit/docs/topics/compatibility.rst
+++ b/gcc/jit/docs/topics/compatibility.rst
@@ -466,3 +466,18 @@ information:
* :func:`gcc_jit_target_info_cpu_supports`
* :func:`gcc_jit_target_info_arch`
* :func:`gcc_jit_target_info_supports_target_dependent_type`
+
+.. _LIBGCCJIT_ABI_36:
+
+``LIBGCCJIT_ABI_36``
+--------------------
+``LIBGCCJIT_ABI_36`` covers the addition of
+
+ * :func:`gcc_jit_context_set_abort_on_unsupported_target_builtin`
+
+.. _LIBGCCJIT_ABI_37:
+
+``LIBGCCJIT_ABI_37``
+--------------------
+``LIBGCCJIT_ABI_37`` covers the addition of
+:func:`gcc_jit_context_new_array_type_u64`
diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst
index f821e9c..2229dc7 100644
--- a/gcc/jit/docs/topics/contexts.rst
+++ b/gcc/jit/docs/topics/contexts.rst
@@ -509,6 +509,22 @@ Boolean options
#ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_bool_print_errors_to_stderr
+.. function:: void \
+ gcc_jit_context_set_abort_on_unsupported_target_builtin (gcc_jit_context *ctxt)
+
+ By default, libgccjit will silently ignore when a target builtin has an
+ unsupported type.
+
+ This entrypoint can be used to make it abort when the specified context
+ encounters such a target builtin.
+
+ This entrypoint was added in :ref:`LIBGCCJIT_ABI_36`; you can test for
+ its presence using
+
+ .. code-block:: c
+
+ #ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_abort_on_unsupported_target_builtin
+
Integer options
***************
diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst
index e699ee5..ae4d7d4 100644
--- a/gcc/jit/docs/topics/types.rst
+++ b/gcc/jit/docs/topics/types.rst
@@ -119,6 +119,14 @@ Standard types
-
* - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE`
-
+ * - :c:data:`GCC_JIT_TYPE_FLOAT16`
+ -
+ * - :c:data:`GCC_JIT_TYPE_FLOAT32`
+ -
+ * - :c:data:`GCC_JIT_TYPE_FLOAT64`
+ -
+ * - :c:data:`GCC_JIT_TYPE_FLOAT128`
+ -
* - :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR`
- C type: ``(const char *)``
* - :c:data:`GCC_JIT_TYPE_SIZE_T`
@@ -163,6 +171,24 @@ Pointers, `const`, and `volatile`
Given non-`void` type "T", get type "T[N]" (for a constant N).
.. function:: gcc_jit_type *\
+ gcc_jit_context_new_array_type_u64 (gcc_jit_context *ctxt, \
+ gcc_jit_location *loc, \
+ gcc_jit_type *element_type, \
+ uint64_t num_elements)
+
+ Given non-`void` type "T", get type "T[N]" (for a constant N).
+
+ This is the same as gcc_jit_context_new_array_type, but the type of
+ ``num_elements` different and thus allows creating bigger array types.
+
+ This API entrypoint was added in :ref:`LIBGCCJIT_ABI_37`; you can test
+ for its presence using
+
+ .. code-block:: c
+
+ #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_array_type_u64
+
+.. function:: gcc_jit_type *\
gcc_jit_type_get_aligned (gcc_jit_type *type, \
size_t alignment_in_bytes)
diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc
index 3ffca92..0668d67 100644
--- a/gcc/jit/dummy-frontend.cc
+++ b/gcc/jit/dummy-frontend.cc
@@ -956,13 +956,15 @@ struct GTY(()) lang_identifier
/* The resulting tree type. */
+/* See lang_tree_node in gcc/c/c-decl.cc. */
union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
- chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
-lang_tree_node
-{
- union tree_node GTY((tag ("0"),
- desc ("tree_node_structure (&%h)"))) generic;
- struct lang_identifier GTY((tag ("1"))) identifier;
+ chain_next ("(union lang_tree_node *) jit_tree_chain_next (&%h.generic)")))
+ lang_tree_node
+ {
+ union tree_node GTY ((tag ("0"),
+ desc ("tree_node_structure (&%h)")))
+ generic;
+ struct lang_identifier GTY ((tag ("1"))) identifier;
};
/* We don't use language_function. */
@@ -1170,6 +1172,9 @@ jit_langhook_type_for_mode (machine_mode mode, int unsignedp)
recording::type* tree_type_to_jit_type (tree type)
{
+ gcc_assert (gcc::jit::active_playback_ctxt);
+ gcc::jit::playback::context* ctxt = gcc::jit::active_playback_ctxt;
+
if (TREE_CODE (type) == VECTOR_TYPE)
{
tree inner_type = TREE_TYPE (type);
@@ -1190,12 +1195,6 @@ recording::type* tree_type_to_jit_type (tree type)
// FIXME: wrong type.
return new recording::memento_of_get_type (&target_builtins_ctxt,
GCC_JIT_TYPE_VOID);
- /* TODO: Remove when we add support for sized floating-point types. */
- for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
- if (type == FLOATN_NX_TYPE_NODE (i))
- // FIXME: wrong type.
- return new recording::memento_of_get_type (&target_builtins_ctxt,
- GCC_JIT_TYPE_VOID);
if (type == void_type_node)
return new recording::memento_of_get_type (&target_builtins_ctxt,
GCC_JIT_TYPE_VOID);
@@ -1261,6 +1260,26 @@ recording::type* tree_type_to_jit_type (tree type)
else if (type == bfloat16_type_node)
return new recording::memento_of_get_type (&target_builtins_ctxt,
GCC_JIT_TYPE_BFLOAT16);
+ else if (type == float16_type_node)
+ {
+ return new recording::memento_of_get_type (&target_builtins_ctxt,
+ GCC_JIT_TYPE_FLOAT16);
+ }
+ else if (type == float32_type_node)
+ {
+ return new recording::memento_of_get_type (&target_builtins_ctxt,
+ GCC_JIT_TYPE_FLOAT32);
+ }
+ else if (type == float64_type_node)
+ {
+ return new recording::memento_of_get_type (&target_builtins_ctxt,
+ GCC_JIT_TYPE_FLOAT64);
+ }
+ else if (type == float128_type_node)
+ {
+ return new recording::memento_of_get_type (&target_builtins_ctxt,
+ GCC_JIT_TYPE_FLOAT128);
+ }
else if (type == dfloat128_type_node)
// FIXME: wrong type.
return new recording::memento_of_get_type (&target_builtins_ctxt,
@@ -1282,6 +1301,39 @@ recording::type* tree_type_to_jit_type (tree type)
return nullptr;
return element_type->get_pointer ();
}
+ else if (type == unsigned_intTI_type_node)
+ return new recording::memento_of_get_type (&target_builtins_ctxt,
+ GCC_JIT_TYPE_UINT128_T);
+ else if (INTEGRAL_TYPE_P (type))
+ {
+ unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
+ return target_builtins_ctxt.get_int_type (size, TYPE_UNSIGNED (type));
+ }
+ else if (SCALAR_FLOAT_TYPE_P (type))
+ {
+ unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
+ enum gcc_jit_types type;
+ switch (size)
+ {
+ case 2:
+ type = GCC_JIT_TYPE_BFLOAT16;
+ break;
+ case 4:
+ type = GCC_JIT_TYPE_FLOAT;
+ break;
+ case 8:
+ type = GCC_JIT_TYPE_DOUBLE;
+ break;
+ default:
+ if (ctxt->get_abort_on_unsupported_target_builtin ())
+ {
+ fprintf (stderr, "Unexpected float size: %d\n", size);
+ abort ();
+ }
+ return NULL;
+ }
+ return new recording::memento_of_get_type (&target_builtins_ctxt, type);
+ }
else
{
// Attempt to find an unqualified type when the current type has qualifiers.
@@ -1301,6 +1353,13 @@ recording::type* tree_type_to_jit_type (tree type)
}
}
}
+
+ if (ctxt->get_abort_on_unsupported_target_builtin ())
+ {
+ fprintf (stderr, "Unknown type:\n");
+ debug_tree (type);
+ abort ();
+ }
}
return NULL;
diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h
index 845726b..e32bd88 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_BFLOAT16 + 1;
+const int NUM_GCC_JIT_TYPES = GCC_JIT_TYPE_FLOAT128 + 1;
/* This comment is included by the docs.
@@ -93,6 +93,21 @@ const int NUM_GCC_JIT_TYPES = GCC_JIT_TYPE_BFLOAT16 + 1;
End of comment for inclusion in the docs. */
+/* See c_tree_chain_next in gcc/c-family/c-common.h. */
+static inline tree
+jit_tree_chain_next (tree t)
+{
+ /* TREE_CHAIN of a type is TYPE_STUB_DECL, which is different
+ kind of object, never a long chain of nodes. Prefer
+ TYPE_NEXT_VARIANT for types. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPE_COMMON))
+ return TYPE_NEXT_VARIANT (t);
+ /* Otherwise, if there is TREE_CHAIN, return it. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_COMMON))
+ return TREE_CHAIN (t);
+ return NULL;
+}
+
namespace gcc {
namespace jit {
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 291ddeb..00d5e72 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -295,6 +295,39 @@ get_tree_node_for_type (enum gcc_jit_types type_)
return double_type_node;
case GCC_JIT_TYPE_LONG_DOUBLE:
return long_double_type_node;
+ case GCC_JIT_TYPE_FLOAT16:
+ if (float16_type_node == NULL || TYPE_PRECISION (float16_type_node) != 16)
+ {
+ add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
+ type_);
+ return NULL;
+ }
+ return float16_type_node;
+ case GCC_JIT_TYPE_FLOAT32:
+ if (float32_type_node == NULL || TYPE_PRECISION (float32_type_node) != 32)
+ {
+ add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
+ type_);
+ return NULL;
+ }
+ return float32_type_node;
+ case GCC_JIT_TYPE_FLOAT64:
+ if (float64_type_node == NULL || TYPE_PRECISION (float64_type_node) != 64)
+ {
+ add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
+ type_);
+ return NULL;
+ }
+ return float64_type_node;
+ case GCC_JIT_TYPE_FLOAT128:
+ if (float128_type_node == NULL
+ || TYPE_PRECISION (float128_type_node) != 128)
+ {
+ add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
+ type_);
+ return NULL;
+ }
+ return float128_type_node;
case GCC_JIT_TYPE_SIZE_T:
return size_type_node;
@@ -344,7 +377,7 @@ playback::type *
playback::context::
new_array_type (playback::location *loc,
playback::type *element_type,
- int num_elements)
+ uint64_t num_elements)
{
gcc_assert (element_type);
@@ -3871,7 +3904,7 @@ add_error (location *loc, const char *fmt, ...)
va_list ap;
va_start (ap, fmt);
m_recording_ctxt->add_error_va (loc ? loc->get_recording_loc () : NULL,
- fmt, ap);
+ diagnostics::kind::error, fmt, ap);
va_end (ap);
}
@@ -3883,13 +3916,12 @@ playback::context::
add_error_va (location *loc, const char *fmt, va_list ap)
{
m_recording_ctxt->add_error_va (loc ? loc->get_recording_loc () : NULL,
- fmt, ap);
+ diagnostics::kind::error, fmt, ap);
}
-/* Report a diagnostic up to the jit context as an error,
- so that the compilation is treated as a failure.
- For now, any kind of diagnostic is treated as an error by the jit
- API. */
+/* Report a diagnostic up to the jit context, so that the
+ compilation is treated as a failure if the diagnostic
+ is an error. */
void
playback::context::
@@ -3914,7 +3946,7 @@ add_diagnostic (const char *text,
false);
}
- m_recording_ctxt->add_error (rec_loc, "%s", text);
+ m_recording_ctxt->add_diagnostic (rec_loc, diagnostic.m_kind, "%s", text);
}
/* Dealing with the linemap API. */
diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index 07dab6f..f2ff4f7 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -88,7 +88,7 @@ public:
type *
new_array_type (location *loc,
type *element_type,
- int num_elements);
+ uint64_t num_elements);
field *
new_field (location *loc,
@@ -340,6 +340,11 @@ public:
return info;
}
+ bool get_abort_on_unsupported_target_builtin () const
+ {
+ return m_recording_ctxt->get_abort_on_unsupported_target_builtin ();
+ }
+
private:
void dump_generated_code ();
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index 2f4ecc3..6816a71 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -847,7 +847,7 @@ recording::context::get_int_type (int num_bytes, int is_signed)
recording::type *
recording::context::new_array_type (recording::location *loc,
recording::type *element_type,
- int num_elements)
+ uint64_t num_elements)
{
if (struct_ *s = element_type->dyn_cast_struct ())
if (!s->get_fields ())
@@ -1498,6 +1498,18 @@ recording::context::set_output_ident (const char *ident)
record (memento);
}
+bool
+recording::context::get_abort_on_unsupported_target_builtin ()
+{
+ return m_abort_on_unsupported_target_builtin;
+}
+
+void
+recording::context::set_abort_on_unsupported_target_builtin ()
+{
+ m_abort_on_unsupported_target_builtin = true;
+}
+
/* Set the given integer option for this context, or add an error if
it's not recognized.
@@ -1717,11 +1729,21 @@ recording::context::populate_target_info ()
it to stderr, and add it to the context. */
void
+recording::context::add_diagnostic (location *loc,
+ diagnostics::kind diagnostic_kind, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ add_error_va (loc, diagnostic_kind, fmt, ap);
+ va_end (ap);
+}
+
+void
recording::context::add_error (location *loc, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
- add_error_va (loc, fmt, ap);
+ add_error_va (loc, diagnostics::kind::error, fmt, ap);
va_end (ap);
}
@@ -1729,7 +1751,8 @@ recording::context::add_error (location *loc, const char *fmt, ...)
it to stderr, and add it to the context. */
void
-recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
+recording::context::add_error_va (location *loc,
+ diagnostics::kind diagnostic_kind, const char *fmt, va_list ap)
{
int len;
char *malloced_msg;
@@ -1750,7 +1773,9 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
has_ownership = true;
}
if (get_logger ())
- get_logger ()->log ("error %i: %s", m_error_count, errmsg);
+ get_logger ()->log ("%s %i: %s",
+ diagnostics::get_text_for_kind (diagnostic_kind),
+ m_error_count, errmsg);
const char *ctxt_progname =
get_str_option (GCC_JIT_STR_OPTION_PROGNAME);
@@ -1762,13 +1787,15 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
if (print_errors_to_stderr)
{
if (loc)
- fprintf (stderr, "%s: %s: error: %s\n",
+ fprintf (stderr, "%s: %s: %s: %s\n",
ctxt_progname,
loc->get_debug_string (),
+ diagnostics::get_text_for_kind (diagnostic_kind),
errmsg);
else
- fprintf (stderr, "%s: error: %s\n",
+ fprintf (stderr, "%s: %s: %s\n",
ctxt_progname,
+ diagnostics::get_text_for_kind (diagnostic_kind),
errmsg);
}
@@ -1784,7 +1811,8 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap)
m_last_error_str = const_cast <char *> (errmsg);
m_owns_last_error_str = has_ownership;
- m_error_count++;
+ if (diagnostic_kind == diagnostics::kind::error)
+ m_error_count++;
}
/* Get the message for the first error that occurred on this context, or
@@ -2634,6 +2662,18 @@ recording::memento_of_get_type::get_size ()
m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
size = GET_MODE_PRECISION (m).to_constant ();
break;
+ case GCC_JIT_TYPE_FLOAT16:
+ size = 16;
+ break;
+ case GCC_JIT_TYPE_FLOAT32:
+ size = 32;
+ break;
+ case GCC_JIT_TYPE_FLOAT64:
+ size = 64;
+ break;
+ case GCC_JIT_TYPE_FLOAT128:
+ size = 128;
+ break;
case GCC_JIT_TYPE_SIZE_T:
size = MAX_BITS_PER_WORD;
break;
@@ -2690,6 +2730,10 @@ recording::memento_of_get_type::dereference ()
case GCC_JIT_TYPE_BFLOAT16:
case GCC_JIT_TYPE_DOUBLE:
case GCC_JIT_TYPE_LONG_DOUBLE:
+ case GCC_JIT_TYPE_FLOAT16:
+ case GCC_JIT_TYPE_FLOAT32:
+ case GCC_JIT_TYPE_FLOAT64:
+ case GCC_JIT_TYPE_FLOAT128:
case GCC_JIT_TYPE_COMPLEX_FLOAT:
case GCC_JIT_TYPE_COMPLEX_DOUBLE:
case GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE:
@@ -2755,6 +2799,10 @@ recording::memento_of_get_type::is_int () const
case GCC_JIT_TYPE_BFLOAT16:
case GCC_JIT_TYPE_DOUBLE:
case GCC_JIT_TYPE_LONG_DOUBLE:
+ case GCC_JIT_TYPE_FLOAT16:
+ case GCC_JIT_TYPE_FLOAT32:
+ case GCC_JIT_TYPE_FLOAT64:
+ case GCC_JIT_TYPE_FLOAT128:
return false;
case GCC_JIT_TYPE_CONST_CHAR_PTR:
@@ -2814,6 +2862,10 @@ recording::memento_of_get_type::is_signed () const
case GCC_JIT_TYPE_BFLOAT16:
case GCC_JIT_TYPE_DOUBLE:
case GCC_JIT_TYPE_LONG_DOUBLE:
+ case GCC_JIT_TYPE_FLOAT16:
+ case GCC_JIT_TYPE_FLOAT32:
+ case GCC_JIT_TYPE_FLOAT64:
+ case GCC_JIT_TYPE_FLOAT128:
case GCC_JIT_TYPE_CONST_CHAR_PTR:
@@ -2874,6 +2926,10 @@ recording::memento_of_get_type::is_float () const
case GCC_JIT_TYPE_BFLOAT16:
case GCC_JIT_TYPE_DOUBLE:
case GCC_JIT_TYPE_LONG_DOUBLE:
+ case GCC_JIT_TYPE_FLOAT16:
+ case GCC_JIT_TYPE_FLOAT32:
+ case GCC_JIT_TYPE_FLOAT64:
+ case GCC_JIT_TYPE_FLOAT128:
return true;
case GCC_JIT_TYPE_CONST_CHAR_PTR:
@@ -2938,6 +2994,10 @@ recording::memento_of_get_type::is_bool () const
case GCC_JIT_TYPE_BFLOAT16:
case GCC_JIT_TYPE_DOUBLE:
case GCC_JIT_TYPE_LONG_DOUBLE:
+ case GCC_JIT_TYPE_FLOAT16:
+ case GCC_JIT_TYPE_FLOAT32:
+ case GCC_JIT_TYPE_FLOAT64:
+ case GCC_JIT_TYPE_FLOAT128:
return false;
case GCC_JIT_TYPE_CONST_CHAR_PTR:
@@ -3015,8 +3075,11 @@ static const char * const get_type_strings[] = {
"__int32_t", /* GCC_JIT_TYPE_INT32_T */
"__int64_t", /* GCC_JIT_TYPE_INT64_T */
"__int128_t", /* GCC_JIT_TYPE_INT128_T */
-
- "bfloat16", /* GCC_JIT_TYPE_BFLOAT16 */
+ "bfloat16", /* GCC_JIT_TYPE_BFLOAT16 */
+ "_Float16", /* GCC_JIT_TYPE_FLOAT16 */
+ "_Float32", /* GCC_JIT_TYPE_FLOAT32 */
+ "_Float64", /* GCC_JIT_TYPE_FLOAT64 */
+ "__float128", /* GCC_JIT_TYPE_FLOAT128 */
};
/* Implementation of recording::memento::make_debug_string for
@@ -3063,6 +3126,10 @@ static const char * const get_type_enum_strings[] = {
"GCC_JIT_TYPE_INT64_T",
"GCC_JIT_TYPE_INT128_T",
"GCC_JIT_TYPE_BFLOAT16",
+ "GCC_JIT_TYPE_FLOAT16",
+ "GCC_JIT_TYPE_FLOAT32",
+ "GCC_JIT_TYPE_FLOAT64",
+ "GCC_JIT_TYPE_FLOAT128",
};
void
@@ -3363,7 +3430,7 @@ recording::string *
recording::array_type::make_debug_string ()
{
return string::from_printf (m_ctxt,
- "%s[%d]",
+ "%s[%ld]",
m_element_type->get_debug_string (),
m_num_elements);
}
@@ -3376,10 +3443,10 @@ recording::array_type::write_reproducer (reproducer &r)
{
const char *id = r.make_identifier (this, "array_type");
r.write (" gcc_jit_type *%s =\n"
- " gcc_jit_context_new_array_type (%s,\n"
- " %s, /* gcc_jit_location *loc */\n"
- " %s, /* gcc_jit_type *element_type */\n"
- " %i); /* int num_elements */\n",
+ " gcc_jit_context_new_array_type_u64 (%s,\n"
+ " %s, /* gcc_jit_location *loc */\n"
+ " %s, /* gcc_jit_type *element_type */\n"
+ " %li); /* int num_elements */\n",
id,
r.get_identifier (get_context ()),
r.get_identifier (m_loc),
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 4d41faa..08de684 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "jit-common.h"
#include "jit-logging.h"
#include "jit-target.h"
+#include "diagnostic-core.h"
#include "libgccjit.h"
#include <string>
@@ -105,7 +106,7 @@ public:
type *
new_array_type (location *loc,
type *element_type,
- int num_elements);
+ uint64_t num_elements);
field *
new_field (location *loc,
@@ -270,6 +271,12 @@ public:
void
set_output_ident (const char *output_ident);
+ bool
+ get_abort_on_unsupported_target_builtin ();
+
+ void
+ set_abort_on_unsupported_target_builtin ();
+
void
set_int_option (enum gcc_jit_int_option opt,
int value);
@@ -340,12 +347,19 @@ public:
}
void
+ add_diagnostic (location *loc, enum diagnostics::kind diagnostic_kind,
+ const char *fmt, ...)
+ GNU_PRINTF (4, 5);
+
+ void
add_error (location *loc, const char *fmt, ...)
GNU_PRINTF(3, 4);
void
- add_error_va (location *loc, const char *fmt, va_list ap)
- GNU_PRINTF(3, 0);
+ add_error_va (location *loc, enum diagnostics::kind diagnostic_kind,
+ const char *fmt,
+ va_list ap)
+ GNU_PRINTF (4, 0);
const char *
get_first_error () const;
@@ -424,6 +438,7 @@ private:
type *m_FILE_type;
bool m_populated_target_info = false;
+ bool m_abort_on_unsupported_target_builtin = false;
builtins_manager *m_builtins_manager; // lazily created
@@ -1030,7 +1045,7 @@ class array_type : public type
array_type (context *ctxt,
location *loc,
type *element_type,
- int num_elements)
+ uint64_t num_elements)
: type (ctxt),
m_loc (loc),
m_element_type (element_type),
@@ -1063,7 +1078,7 @@ class array_type : public type
bool is_bool () const final override { return false; }
type *is_pointer () final override { return NULL; }
type *is_array () final override { return m_element_type; }
- int num_elements () { return m_num_elements; }
+ uint64_t num_elements () { return m_num_elements; }
bool is_signed () const final override { return false; }
void replay_into (replayer *) final override;
@@ -1075,7 +1090,7 @@ class array_type : public type
private:
location *m_loc;
type *m_element_type;
- int m_num_elements;
+ uint64_t m_num_elements;
};
class function_type : public type
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index 3336944..3fc96fb 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -342,7 +342,7 @@ jit_error (gcc::jit::recording::context *ctxt,
va_start (ap, fmt);
if (ctxt)
- ctxt->add_error_va (loc, fmt, ap);
+ ctxt->add_error_va (loc, diagnostics::kind::error, fmt, ap);
else
{
/* No context? Send to stderr. */
@@ -784,11 +784,21 @@ gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
gcc_jit_type *element_type,
int num_elements)
{
+ RETURN_NULL_IF_FAIL (num_elements >= 0, ctxt, NULL, "negative size");
+ return gcc_jit_context_new_array_type_u64 (ctxt, loc, element_type,
+ (uint64_t) num_elements);
+}
+
+gcc_jit_type *
+gcc_jit_context_new_array_type_u64 (gcc_jit_context *ctxt,
+ gcc_jit_location *loc,
+ gcc_jit_type *element_type,
+ uint64_t num_elements)
+{
RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context");
JIT_LOG_FUNC (ctxt->get_logger ());
/* LOC can be NULL. */
RETURN_NULL_IF_FAIL (element_type, ctxt, loc, "NULL type");
- RETURN_NULL_IF_FAIL (num_elements >= 0, ctxt, NULL, "negative size");
RETURN_NULL_IF_FAIL (!element_type->is_void (), ctxt, loc,
"void type for elements");
@@ -3951,6 +3961,14 @@ gcc_jit_target_info_supports_target_dependent_type (gcc_jit_target_info *info,
!= info->m_supported_target_dependent_types.end ();
}
+void
+gcc_jit_context_set_abort_on_unsupported_target_builtin (gcc_jit_context *ctxt)
+{
+ RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context");
+
+ ctxt->set_abort_on_unsupported_target_builtin ();
+}
+
/* Public entrypoint. See description in libgccjit.h.
After error-checking, the real work is done by the
diff --git a/gcc/jit/libgccjit.exports b/gcc/jit/libgccjit.exports
index 26dc634..17864c7 100644
--- a/gcc/jit/libgccjit.exports
+++ b/gcc/jit/libgccjit.exports
@@ -239,16 +239,28 @@ _gcc_jit_global_set_readonly
# LIBGCCJIT_ABI_30
_gcc_jit_context_convert_vector
-# LIBGCCJIT_ABI_31
+# LIBGCCJIT_ABI_31
_gcc_jit_context_new_vector_access
_gcc_jit_context_new_rvalue_vector_perm
-# LIBGCCJIT_ABI_32
+# LIBGCCJIT_ABI_32
_gcc_jit_context_get_target_builtin_function
-# LIBGCCJIT_ABI_33
+# LIBGCCJIT_ABI_33
_gcc_jit_function_new_temp
-# LIBGCCJIT_ABI_34
+# LIBGCCJIT_ABI_34
_gcc_jit_context_set_output_ident
+# LIBGCCJIT_ABI_35
+_gcc_jit_context_get_target_info
+_gcc_jit_target_info_release
+_gcc_jit_target_info_cpu_supports
+_gcc_jit_target_info_arch
+_gcc_jit_target_info_supports_target_dependent_type
+
+# LIBGCCJIT_ABI_36
+_gcc_jit_context_set_abort_on_unsupported_target_builtin
+
+# LIBGCCJIT_ABI_37
+_gcc_jit_context_new_array_type_u64
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index a585510..1cc5e6a 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#ifndef LIBGCCJIT_H
#define LIBGCCJIT_H
+#include <stdint.h>
#include <stdio.h>
#ifdef __has_include
#if __has_include (<sys/types.h>)
@@ -618,6 +619,10 @@ enum gcc_jit_types
GCC_JIT_TYPE_INT128_T,
GCC_JIT_TYPE_BFLOAT16,
+ GCC_JIT_TYPE_FLOAT16,
+ GCC_JIT_TYPE_FLOAT32,
+ GCC_JIT_TYPE_FLOAT64,
+ GCC_JIT_TYPE_FLOAT128,
};
extern gcc_jit_type *
@@ -676,6 +681,20 @@ gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
gcc_jit_type *element_type,
int num_elements);
+/* Given type "T", get type "T[N]" (for a constant N).
+
+ This API entrypoint was added in LIBGCCJIT_ABI_37; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_array_type_u64
+*/
+extern gcc_jit_type *
+gcc_jit_context_new_array_type_u64 (gcc_jit_context *ctxt,
+ gcc_jit_location *loc,
+ gcc_jit_type *element_type,
+ uint64_t num_elements);
+
+#define LIBGCCJIT_HAVE_gcc_jit_context_new_array_type_u64
+
/* Struct-handling. */
/* Create a field, for use within a struct or union. */
@@ -2216,6 +2235,11 @@ gcc_jit_context_set_output_ident (gcc_jit_context *ctxt,
#define LIBGCCJIT_HAVE_gcc_jit_context_set_output_ident
+extern void
+gcc_jit_context_set_abort_on_unsupported_target_builtin (gcc_jit_context *ctxt);
+
+#define LIBGCCJIT_HAVE_gcc_jit_context_set_abort_on_unsupported_target_builtin
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map
index 4662ca4..4d767f4 100644
--- a/gcc/jit/libgccjit.map
+++ b/gcc/jit/libgccjit.map
@@ -334,3 +334,13 @@ LIBGCCJIT_ABI_35 {
gcc_jit_target_info_arch;
gcc_jit_target_info_supports_target_dependent_type;
} LIBGCCJIT_ABI_34;
+
+LIBGCCJIT_ABI_36 {
+ global:
+ gcc_jit_context_set_abort_on_unsupported_target_builtin;
+} LIBGCCJIT_ABI_35;
+
+LIBGCCJIT_ABI_37 {
+ global:
+ gcc_jit_context_new_array_type_u64;
+} LIBGCCJIT_ABI_36;