Andrea Corallo <andrea.cora...@arm.com> writes: > Hi Alex, > > Looking at the code I believe all these casts are meant to be supported > (read your intuition was correct). > > Also IMO source of confusion is that the doc is mentioning 'int' and > 'float' but I believe would be better to have like 'integral' and > 'floating-point' to clearly disambiguates with respect to the C > types. > > AFAIU the set of supported casts should be like: > > integral <-> integral > floating-point <-> floating-point > integral <-> floating-point > integral <-> bool > P* <-> Q* for pointer types P and Q. > > I'd propose to install the following patch to make doc and comments > homogeneous at documenting what do we accept, and I guess we should just > consider bugs if some of these conversions is not handled correctly or > leads to ICE. > > Bests > > Andrea > > gcc/jit/ChangeLog > > 2020-07-21 Andrea Corallo <andrea.cora...@arm.com> > > * docs/_build/texinfo/libgccjit.texi (Type-coercion): Improve doc > on allowed type casting. > * docs/topics/expressions.rst (gccjit::context::new_cast) > (gcc_jit_context_new_cast): Likewise. > * libgccjit.c: Improve comment on allowed type casting. > * libgccjit.h: Likewise > > From 914b9e86808c947d4bb2b06c6960fd8031125f67 Mon Sep 17 00:00:00 2001 > From: Andrea Corallo <andrea.cora...@arm.com> > Date: Tue, 21 Jul 2020 20:12:23 +0200 > Subject: [PATCH] libgccjit: improve documentation on type conversions > > gcc/jit/ChangeLog > > 2020-07-21 Andrea Corallo <andrea.cora...@arm.com> > > * docs/_build/texinfo/libgccjit.texi (Type-coercion): Improve doc > on allowed type casting. > * docs/topics/expressions.rst (gccjit::context::new_cast) > (gcc_jit_context_new_cast): Likewise. > * libgccjit.c: Improve comment on allowed type casting. > * libgccjit.h: Likewise > --- > gcc/jit/docs/_build/texinfo/libgccjit.texi | 30 +++++++++++++++------- > gcc/jit/docs/topics/expressions.rst | 8 +++--- > gcc/jit/libgccjit.c | 8 +++--- > gcc/jit/libgccjit.h | 7 +++-- > 4 files changed, 36 insertions(+), 17 deletions(-) > > diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi > b/gcc/jit/docs/_build/texinfo/libgccjit.texi > index 1e14be010426..b170f24d1bb1 100644 > --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi > +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi > @@ -6685,13 +6685,19 @@ Currently only a limited set of conversions are > possible: > @itemize * > > @item > -int <-> float > +integral <-> integral > > @item > -int <-> bool > +floating-point <-> floating-point > > @item > -P* <-> Q*, for pointer types P and Q > +integral <-> floating-point > + > +@item > +integral <-> bool > + > +@item > +P* <-> Q* for pointer types P and Q > @end itemize > @end quotation > @end deffn > @@ -12964,14 +12970,20 @@ Currently only a limited set of conversions are > possible: > > @itemize * > > -@item > -int <-> float > +@item > +integral <-> integral > > -@item > -int <-> bool > +@item > +floating-point <-> floating-point > > -@item > -P* <-> Q*, for pointer types P and Q > +@item > +integral <-> floating-point > + > +@item > +integral <-> bool > + > +@item > +P* <-> Q*, for pointer types P and Q > @end itemize > @end quotation > @end deffn > diff --git a/gcc/jit/docs/topics/expressions.rst > b/gcc/jit/docs/topics/expressions.rst > index d783ceea51a8..051cee5db211 100644 > --- a/gcc/jit/docs/topics/expressions.rst > +++ b/gcc/jit/docs/topics/expressions.rst > @@ -504,9 +504,11 @@ Type-coercion > > Currently only a limited set of conversions are possible: > > - * int <-> float > - * int <-> bool > - * P* <-> Q*, for pointer types P and Q > + * integral <-> integral > + * floating-point <-> floating-point > + * integral <-> floating-point > + * integral <-> bool > + * P* <-> Q* for pointer types P and Q > > Lvalues > ------- > diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c > index 3d04f6db3aff..403233d5577a 100644 > --- a/gcc/jit/libgccjit.c > +++ b/gcc/jit/libgccjit.c > @@ -1629,9 +1629,11 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context > *ctxt, > > We only permit these kinds of cast: > > - int <-> float > - int <-> bool > - P* <-> Q* for pointer types P and Q. */ > + integral <-> integral > + floating-point <-> floating-point > + integral <-> floating-point > + integral <-> bool > + P* <-> Q* for pointer types P and Q. */ > > static bool > is_valid_cast (gcc::jit::recording::type *src_type, > diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h > index 1c5a12e9c015..228befa896d7 100644 > --- a/gcc/jit/libgccjit.h > +++ b/gcc/jit/libgccjit.h > @@ -996,8 +996,11 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context > *ctxt, > /* Type-coercion. > > Currently only a limited set of conversions are possible: > - int <-> float > - int <-> bool */ > + integral <-> integral > + floating-point <-> floating-point > + integral <-> floating-point > + integral <-> bool > + P* <-> Q* for pointer types P and Q. */ > extern gcc_jit_rvalue * > gcc_jit_context_new_cast (gcc_jit_context *ctxt, > gcc_jit_location *loc,
Ping Thanks Andrea