[PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions)
Andrea Corallo
andrea.corallo@arm.com
Wed Jul 22 08:45:20 GMT 2020
Alex Coplan <Alex.Coplan@arm.com> writes:
> Secondly, I wanted to clarify the situation with respect to explicit
> casts; that is, those conversions allowed by gcc_jit_context_new_cast().
> The docs [0] say:
>
> Currently only a limited set of conversions are possible:
> - int <-> float
> - int <-> bool
> - P* <-> Q*, for pointer types P and Q
>
> However, empirically (at least on aarch64), libgccjit appears to allow
> me to compile casts between any pair of types in the following set
> without any complaint:
>
> {
> SIGNED_CHAR,
> UNSIGNED_CHAR,
> SHORT,
> UNSIGNED_SHORT,
> INT,
> UNSIGNED_INT,
> LONG,
> UNSIGNED_LONG,
> LONG_LONG,
> UNSIGNED_LONG_LONG
> }
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.corallo@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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libgccjit-improve-documentation-on-type-conversions.patch
Type: text/x-diff
Size: 3932 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/jit/attachments/20200722/0fff0314/attachment-0001.bin>
More information about the Jit
mailing list