libgccjit: Make new_array_type take unsigned long
Checks
Commit Message
Hi.
This patches update gcc_jit_context_new_array_type to take the size as
an unsigned long instead of a int, to allow creating bigger array
types.
I haven't written the ChangeLog yet because I wasn't sure it's allowed
to change the type of a function like that.
If it isn't, what would you suggest?
Thanks.
Comments
On Thu, 2023-12-07 at 17:29 -0500, Antoni Boucher wrote:
> Hi.
> This patches update gcc_jit_context_new_array_type to take the size
> as
> an unsigned long instead of a int, to allow creating bigger array
> types.
>
> I haven't written the ChangeLog yet because I wasn't sure it's
> allowed
> to change the type of a function like that.
> If it isn't, what would you suggest?
We've kept ABI compatibility all the way back to the version in GCC 5,
so it seems a shame to break ABI.
How about a new API entrypoint:
gcc_jit_context_new_array_type_unsigned_long
whilst keeping the old one.
Then everything internally can use "unsigned long"; we just keep the
old entrypoint accepting int (which internally promotes the arg to
unsigned long, if positive, sharing all the implementation).
Alternatively, I think there may be a way to do this with symbol
versioning:
https://gcc.gnu.org/wiki/SymbolVersioning
see e.g. Section 3.7 of Ulrich Drepper's "How To Write Shared
Libraries", but I'm a bit wary of cross-platform compatibility with
that.
Dave
Thanks for the review.
Here's the updated patch.
On Thu, 2023-12-07 at 20:04 -0500, David Malcolm wrote:
> On Thu, 2023-12-07 at 17:29 -0500, Antoni Boucher wrote:
> > Hi.
> > This patches update gcc_jit_context_new_array_type to take the size
> > as
> > an unsigned long instead of a int, to allow creating bigger array
> > types.
> >
> > I haven't written the ChangeLog yet because I wasn't sure it's
> > allowed
> > to change the type of a function like that.
> > If it isn't, what would you suggest?
>
> We've kept ABI compatibility all the way back to the version in GCC
> 5,
> so it seems a shame to break ABI.
>
> How about a new API entrypoint:
> gcc_jit_context_new_array_type_unsigned_long
> whilst keeping the old one.
>
> Then everything internally can use "unsigned long"; we just keep the
> old entrypoint accepting int (which internally promotes the arg to
> unsigned long, if positive, sharing all the implementation).
>
> Alternatively, I think there may be a way to do this with symbol
> versioning:
> https://gcc.gnu.org/wiki/SymbolVersioning
> see e.g. Section 3.7 of Ulrich Drepper's "How To Write Shared
> Libraries", but I'm a bit wary of cross-platform compatibility with
> that.
>
> Dave
>
>
I had forgotten to add the doc since there is now a new API.
Here it is.
On Wed, 2024-02-21 at 19:45 -0500, Antoni Boucher wrote:
> Thanks for the review.
>
> Here's the updated patch.
>
> On Thu, 2023-12-07 at 20:04 -0500, David Malcolm wrote:
> > On Thu, 2023-12-07 at 17:29 -0500, Antoni Boucher wrote:
> > > Hi.
> > > This patches update gcc_jit_context_new_array_type to take the
> > > size
> > > as
> > > an unsigned long instead of a int, to allow creating bigger array
> > > types.
> > >
> > > I haven't written the ChangeLog yet because I wasn't sure it's
> > > allowed
> > > to change the type of a function like that.
> > > If it isn't, what would you suggest?
> >
> > We've kept ABI compatibility all the way back to the version in GCC
> > 5,
> > so it seems a shame to break ABI.
> >
> > How about a new API entrypoint:
> > gcc_jit_context_new_array_type_unsigned_long
> > whilst keeping the old one.
> >
> > Then everything internally can use "unsigned long"; we just keep
> > the
> > old entrypoint accepting int (which internally promotes the arg to
> > unsigned long, if positive, sharing all the implementation).
> >
> > Alternatively, I think there may be a way to do this with symbol
> > versioning:
> > https://gcc.gnu.org/wiki/SymbolVersioning
> > see e.g. Section 3.7 of Ulrich Drepper's "How To Write Shared
> > Libraries", but I'm a bit wary of cross-platform compatibility with
> > that.
> >
> > Dave
> >
> >
>
From 59b7e8af99d5f680e6d622631b1b75609fe1b982 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Sat, 4 Mar 2023 00:44:49 -0500
Subject: [PATCH] libgccjit: Make new_array_type take unsigned long
---
gcc/jit/jit-playback.cc | 2 +-
gcc/jit/jit-playback.h | 2 +-
gcc/jit/jit-recording.cc | 6 +++---
gcc/jit/jit-recording.h | 8 ++++----
gcc/jit/libgccjit.cc | 2 +-
gcc/jit/libgccjit.h | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
@@ -326,7 +326,7 @@ playback::type *
playback::context::
new_array_type (playback::location *loc,
playback::type *element_type,
- int num_elements)
+ unsigned long num_elements)
{
gcc_assert (element_type);
@@ -69,7 +69,7 @@ public:
type *
new_array_type (location *loc,
type *element_type,
- int num_elements);
+ unsigned long num_elements);
field *
new_field (location *loc,
@@ -840,7 +840,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)
+ unsigned long num_elements)
{
if (struct_ *s = element_type->dyn_cast_struct ())
if (!s->get_fields ())
@@ -3113,7 +3113,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);
}
@@ -3129,7 +3129,7 @@ recording::array_type::write_reproducer (reproducer &r)
" 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",
+ " %li); /* int num_elements */\n",
id,
r.get_identifier (get_context ()),
r.get_identifier (m_loc),
@@ -91,7 +91,7 @@ public:
type *
new_array_type (location *loc,
type *element_type,
- int num_elements);
+ unsigned long num_elements);
field *
new_field (location *loc,
@@ -859,7 +859,7 @@ class array_type : public type
array_type (context *ctxt,
location *loc,
type *element_type,
- int num_elements)
+ unsigned long num_elements)
: type (ctxt),
m_loc (loc),
m_element_type (element_type),
@@ -873,7 +873,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; }
+ unsigned long num_elements () { return m_num_elements; }
bool is_signed () const final override { return false; }
void replay_into (replayer *) final override;
@@ -885,7 +885,7 @@ class array_type : public type
private:
location *m_loc;
type *m_element_type;
- int m_num_elements;
+ unsigned long m_num_elements;
};
class function_type : public type
@@ -766,7 +766,7 @@ gcc_jit_type *
gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
gcc_jit_location *loc,
gcc_jit_type *element_type,
- int num_elements)
+ unsigned long num_elements)
{
RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context");
JIT_LOG_FUNC (ctxt->get_logger ());
@@ -661,7 +661,7 @@ extern gcc_jit_type *
gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
gcc_jit_location *loc,
gcc_jit_type *element_type,
- int num_elements);
+ unsigned long num_elements);
/* Struct-handling. */
--
2.43.0