public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* libgccjit: Clarifying the permitted type conversions
@ 2020-07-09 14:15 Alex Coplan
  2020-07-21  8:27 ` Alex Coplan
  2020-07-22  8:45 ` [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions) Andrea Corallo
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Coplan @ 2020-07-09 14:15 UTC (permalink / raw)
  To: jit; +Cc: David Malcolm, nd

Hello,

I have some questions about the type conversions allowed by the
libgccjit interface.

Firstly, I believe it is the case that the intent is that all implicit
conversions are forbidden. Is this correct?

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
}

Is this intended behaviour? If so, does the documentation need to be
updated here? If not, perhaps there are some checks missing in the
libgccjit interface?

Many thanks,
Alex

[0] : https://gcc.gnu.org/onlinedocs/jit/topics/expressions.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: libgccjit: Clarifying the permitted type conversions
  2020-07-09 14:15 libgccjit: Clarifying the permitted type conversions Alex Coplan
@ 2020-07-21  8:27 ` Alex Coplan
  2020-07-22  8:45 ` [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions) Andrea Corallo
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Coplan @ 2020-07-21  8:27 UTC (permalink / raw)
  To: jit; +Cc: nd

Gentle ping.

> -----Original Message-----
> From: Jit <jit-bounces@gcc.gnu.org> On Behalf Of Alex Coplan
> Sent: 09 July 2020 15:15
> To: jit@gcc.gnu.org
> Cc: nd <nd@arm.com>
> Subject: libgccjit: Clarifying the permitted type conversions
> 
> Hello,
> 
> I have some questions about the type conversions allowed by the
> libgccjit interface.
> 
> Firstly, I believe it is the case that the intent is that all implicit
> conversions are forbidden. Is this correct?
> 
> 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
> }
> 
> Is this intended behaviour? If so, does the documentation need to be
> updated here? If not, perhaps there are some checks missing in the
> libgccjit interface?
> 
> Many thanks,
> Alex
> 
> [0] : https://gcc.gnu.org/onlinedocs/jit/topics/expressions.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions)
  2020-07-09 14:15 libgccjit: Clarifying the permitted type conversions Alex Coplan
  2020-07-21  8:27 ` Alex Coplan
@ 2020-07-22  8:45 ` Andrea Corallo
  2020-08-06  7:40   ` [PATCH] libgccjit: Improve doc and comments regarding type casts Andrea Corallo
  1 sibling, 1 reply; 5+ messages in thread
From: Andrea Corallo @ 2020-07-22  8:45 UTC (permalink / raw)
  To: Alex Coplan; +Cc: jit, nd, David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgccjit-improve-documentation-on-type-conversions.patch --]
[-- Type: text/x-diff, Size: 3931 bytes --]

From 914b9e86808c947d4bb2b06c6960fd8031125f67 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <andrea.corallo@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.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
---
 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,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libgccjit: Improve doc and comments regarding type casts
  2020-07-22  8:45 ` [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions) Andrea Corallo
@ 2020-08-06  7:40   ` Andrea Corallo
  2020-09-09  7:56     ` Andrea Corallo
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Corallo @ 2020-08-06  7:40 UTC (permalink / raw)
  To: David Malcolm via Jit; +Cc: jit, nd, gcc-patches, Alex Coplan

Andrea Corallo <andrea.corallo@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.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
>
> From 914b9e86808c947d4bb2b06c6960fd8031125f67 Mon Sep 17 00:00:00 2001
> From: Andrea Corallo <andrea.corallo@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.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
> ---
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libgccjit: Improve doc and comments regarding type casts
  2020-08-06  7:40   ` [PATCH] libgccjit: Improve doc and comments regarding type casts Andrea Corallo
@ 2020-09-09  7:56     ` Andrea Corallo
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Corallo @ 2020-09-09  7:56 UTC (permalink / raw)
  To: David Malcolm via Jit; +Cc: nd, gcc-patches

Andrea Corallo <andrea.corallo@arm.com> writes:

> Andrea Corallo <andrea.corallo@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.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
>>
>> From 914b9e86808c947d4bb2b06c6960fd8031125f67 Mon Sep 17 00:00:00 2001
>> From: Andrea Corallo <andrea.corallo@arm.com>
>> Date: Tue, 21 Jul 2020 20:12:23 +0200
>> Subject: [PATCH] libgccjit: improve documentation on type conversions

[...]

> Ping
>
> Thanks
>   Andrea

Ping

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-09  7:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 14:15 libgccjit: Clarifying the permitted type conversions Alex Coplan
2020-07-21  8:27 ` Alex Coplan
2020-07-22  8:45 ` [PATCH] libgccjit: Improve doc and comments regarding type casts (Was: Clarifying the permitted type conversions) Andrea Corallo
2020-08-06  7:40   ` [PATCH] libgccjit: Improve doc and comments regarding type casts Andrea Corallo
2020-09-09  7:56     ` Andrea Corallo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).