public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC_JIT_BINARY_OP_LOGICAL_AND eager or lazy? and GCCJIT vs GNU C semantics....
@ 2015-01-01  0:00 Basile Starynkevitch
  2015-01-01  0:00 ` Basile Starynkevitch
  0 siblings, 1 reply; 2+ messages in thread
From: Basile Starynkevitch @ 2015-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm, jit

Hello David and list,

I a a bit confused by the document.... Is

GCC_JIT_BINARY_OP_LOGICAL_AND a lazy operation like in C, or is it 
eager? It is documented as

    Logical AND; analogous to:

    (EXPR_A)  &&  (EXPR_B)

    in C.

So I guess that it is lazy. In other words, if EXPR_A is non-null, 
EXPR_B is not even evaluated....

But I am not sure.... Perhaps we should state the laziness in the 
documentation.

Also, do we have a ternary conditional operator, like Cond?Then:Else in 
C? Apparently not
and that surprises me if GCC_JIT_BINARY_OP_LOGICAL_AND is lazy like && 
is in C.

At last, do we have a comma operator?

Or do we have a statement-expr like thing? 
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

All these could be useful in a Scheme like client (for BEGIN in Scheme, 
or PROGN in Lisp) using GCCJIT. Of course, this can be avoided by 
forcing the GCCJIT client to emit much lower-level things. But in that 
case, we should not even admit a function call as a gcc_jit_rvalue... 
(and restrict function calls to be the last statement of basic blocks).

My implicit feeling (but I might be very wrong) is that everything which 
is expressible in GNU C (this includes most GCC language extension of C) 
for GCC
should be easily (and "naturally") done in GCCJIT, but perhaps I don't 
understand the philosophy of GCCJIT yet.... I'm implicitly wishing that 
the semantics of programs built with GCCJIT would be very close to the 
semantics of GCC GNU C language (i.e. gcc -std=gnuc11....)
  Then, it might be the case that we don't have any way to declare a 
thread local variable, or atomic variables....

Cheers.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

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

* Re: GCC_JIT_BINARY_OP_LOGICAL_AND eager or lazy? and GCCJIT vs GNU C semantics....
  2015-01-01  0:00 GCC_JIT_BINARY_OP_LOGICAL_AND eager or lazy? and GCCJIT vs GNU C semantics Basile Starynkevitch
@ 2015-01-01  0:00 ` Basile Starynkevitch
  0 siblings, 0 replies; 2+ messages in thread
From: Basile Starynkevitch @ 2015-01-01  0:00 UTC (permalink / raw)
  To: jit

On 07/16/2015 12:33, Basile Starynkevitch wrote:
>
> GCC_JIT_BINARY_OP_LOGICAL_AND a lazy operation like in C, or is it 
> eager? It is documented as
>
>    Logical AND; analogous to:
>
>    (EXPR_A)  &&  (EXPR_B)
>
>    in C.
>
> So I guess that it is lazy. In other words, if EXPR_A is non-null, 
> EXPR_B is not even evaluated....

It looks to be translated with

     case GCC_JIT_BINARY_OP_LOGICAL_AND:
       node_a = as_truth_value (node_a, loc);
       node_b = as_truth_value (node_b, loc);
       inner_op = TRUTH_ANDIF_EXPR;
       break;

in file jit/jit-playback.c near line 2941 in function 
playback::context::new_binary_op

so given the name TRUTH_ANDIF_EXPR I guess that the operation 
GCC_JIT_BINARY_OP_LOGICAL_AND is indeed lazy.

Cheers.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

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

end of thread, other threads:[~2015-07-16 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01  0:00 GCC_JIT_BINARY_OP_LOGICAL_AND eager or lazy? and GCCJIT vs GNU C semantics Basile Starynkevitch
2015-01-01  0:00 ` Basile Starynkevitch

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).