1*ec02198aSmrg.. Copyright (C) 2014-2020 Free Software Foundation, Inc.
263d1a8abSmrg   Originally contributed by David Malcolm <dmalcolm@redhat.com>
363d1a8abSmrg
463d1a8abSmrg   This is free software: you can redistribute it and/or modify it
563d1a8abSmrg   under the terms of the GNU General Public License as published by
663d1a8abSmrg   the Free Software Foundation, either version 3 of the License, or
763d1a8abSmrg   (at your option) any later version.
863d1a8abSmrg
963d1a8abSmrg   This program is distributed in the hope that it will be useful, but
1063d1a8abSmrg   WITHOUT ANY WARRANTY; without even the implied warranty of
1163d1a8abSmrg   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1263d1a8abSmrg   General Public License for more details.
1363d1a8abSmrg
1463d1a8abSmrg   You should have received a copy of the GNU General Public License
1563d1a8abSmrg   along with this program.  If not, see
1663d1a8abSmrg   <http://www.gnu.org/licenses/>.
1763d1a8abSmrg
1863d1a8abSmrg.. default-domain:: cpp
1963d1a8abSmrg
2063d1a8abSmrgExpressions
2163d1a8abSmrg===========
2263d1a8abSmrg
2363d1a8abSmrgRvalues
2463d1a8abSmrg-------
2563d1a8abSmrg.. class:: gccjit::rvalue
2663d1a8abSmrg
2763d1a8abSmrgA :class:`gccjit::rvalue` is an expression that can be computed.  It is a
2863d1a8abSmrgsubclass of :class:`gccjit::object`, and is a thin wrapper around
2963d1a8abSmrg:c:type:`gcc_jit_rvalue *` from the C API.
3063d1a8abSmrg
3163d1a8abSmrgIt can be simple, e.g.:
3263d1a8abSmrg
3363d1a8abSmrg  * an integer value e.g. `0` or `42`
3463d1a8abSmrg  * a string literal e.g. `"Hello world"`
3563d1a8abSmrg  * a variable e.g. `i`.  These are also lvalues (see below).
3663d1a8abSmrg
3763d1a8abSmrgor compound e.g.:
3863d1a8abSmrg
3963d1a8abSmrg  * a unary expression e.g. `!cond`
4063d1a8abSmrg  * a binary expression e.g. `(a + b)`
4163d1a8abSmrg  * a function call e.g. `get_distance (&player_ship, &target)`
4263d1a8abSmrg  * etc.
4363d1a8abSmrg
4463d1a8abSmrgEvery rvalue has an associated type, and the API will check to ensure
4563d1a8abSmrgthat types match up correctly (otherwise the context will emit an error).
4663d1a8abSmrg
4763d1a8abSmrg.. function:: gccjit::type gccjit::rvalue::get_type ()
4863d1a8abSmrg
4963d1a8abSmrg  Get the type of this rvalue.
5063d1a8abSmrg
5163d1a8abSmrg
5263d1a8abSmrgSimple expressions
5363d1a8abSmrg******************
5463d1a8abSmrg
5563d1a8abSmrg.. function:: gccjit::rvalue \
5663d1a8abSmrg              gccjit::context::new_rvalue (gccjit::type numeric_type, \
5763d1a8abSmrg                                           int value) const
5863d1a8abSmrg
5963d1a8abSmrg   Given a numeric type (integer or floating point), build an rvalue for
6063d1a8abSmrg   the given constant :c:type:`int` value.
6163d1a8abSmrg
6263d1a8abSmrg.. function:: gccjit::rvalue \
6363d1a8abSmrg              gccjit::context::new_rvalue (gccjit::type numeric_type, \
6463d1a8abSmrg                                           long value) const
6563d1a8abSmrg
6663d1a8abSmrg   Given a numeric type (integer or floating point), build an rvalue for
6763d1a8abSmrg   the given constant :c:type:`long` value.
6863d1a8abSmrg
6963d1a8abSmrg.. function::  gccjit::rvalue \
7063d1a8abSmrg               gccjit::context::zero (gccjit::type numeric_type) const
7163d1a8abSmrg
7263d1a8abSmrg   Given a numeric type (integer or floating point), get the rvalue for
7363d1a8abSmrg   zero.  Essentially this is just a shortcut for:
7463d1a8abSmrg
7563d1a8abSmrg   .. code-block:: c++
7663d1a8abSmrg
7763d1a8abSmrg      ctxt.new_rvalue (numeric_type, 0)
7863d1a8abSmrg
7963d1a8abSmrg.. function::  gccjit::rvalue \
8063d1a8abSmrg               gccjit::context::one (gccjit::type numeric_type) const
8163d1a8abSmrg
8263d1a8abSmrg   Given a numeric type (integer or floating point), get the rvalue for
8363d1a8abSmrg   one.  Essentially this is just a shortcut for:
8463d1a8abSmrg
8563d1a8abSmrg   .. code-block:: c++
8663d1a8abSmrg
8763d1a8abSmrg      ctxt.new_rvalue (numeric_type, 1)
8863d1a8abSmrg
8963d1a8abSmrg.. function::  gccjit::rvalue \
9063d1a8abSmrg               gccjit::context::new_rvalue (gccjit::type numeric_type, \
9163d1a8abSmrg                                            double value) const
9263d1a8abSmrg
9363d1a8abSmrg   Given a numeric type (integer or floating point), build an rvalue for
9463d1a8abSmrg   the given constant :c:type:`double` value.
9563d1a8abSmrg
9663d1a8abSmrg.. function:: gccjit::rvalue \
9763d1a8abSmrg              gccjit::context::new_rvalue (gccjit::type pointer_type, \
9863d1a8abSmrg                                           void *value) const
9963d1a8abSmrg
10063d1a8abSmrg   Given a pointer type, build an rvalue for the given address.
10163d1a8abSmrg
10263d1a8abSmrg.. function:: gccjit::rvalue \
10363d1a8abSmrg              gccjit::context::new_rvalue (const std::string &value) const
10463d1a8abSmrg
10563d1a8abSmrg   Generate an rvalue of type :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR` for
10663d1a8abSmrg   the given string.  This is akin to a string literal.
10763d1a8abSmrg
108c7a68eb7SmrgVector expressions
109c7a68eb7Smrg******************
110c7a68eb7Smrg
111c7a68eb7Smrg.. function:: gccjit::rvalue \
112c7a68eb7Smrg	      gccjit::context::new_rvalue (gccjit::type vector_type, \
113c7a68eb7Smrg	                                   std::vector<gccjit::rvalue> elements) const
114c7a68eb7Smrg
115c7a68eb7Smrg   Given a vector type, and a vector of scalar rvalue elements, generate a
116c7a68eb7Smrg   vector rvalue.
117c7a68eb7Smrg
118c7a68eb7Smrg   The number of elements needs to match that of the vector type.
11963d1a8abSmrg
12063d1a8abSmrgUnary Operations
12163d1a8abSmrg****************
12263d1a8abSmrg
12363d1a8abSmrg.. function:: gccjit::rvalue  \
12463d1a8abSmrg              gccjit::context::new_unary_op (enum gcc_jit_unary_op, \
12563d1a8abSmrg                                             gccjit::type result_type, \
12663d1a8abSmrg                                             gccjit::rvalue rvalue, \
12763d1a8abSmrg                                             gccjit::location loc)
12863d1a8abSmrg
12963d1a8abSmrg   Build a unary operation out of an input rvalue.
13063d1a8abSmrg
13163d1a8abSmrg   Parameter ``loc`` is optional.
13263d1a8abSmrg
13363d1a8abSmrg   This is a thin wrapper around the C API's
13463d1a8abSmrg   :c:func:`gcc_jit_context_new_unary_op` and the available unary
13563d1a8abSmrg   operations are documented there.
13663d1a8abSmrg
13763d1a8abSmrgThere are shorter ways to spell the various specific kinds of unary
13863d1a8abSmrgoperation:
13963d1a8abSmrg
14063d1a8abSmrg.. function:: gccjit::rvalue \
14163d1a8abSmrg              gccjit::context::new_minus (gccjit::type result_type, \
14263d1a8abSmrg                                          gccjit::rvalue a, \
14363d1a8abSmrg                                          gccjit::location loc)
14463d1a8abSmrg
14563d1a8abSmrg   Negate an arithmetic value; for example:
14663d1a8abSmrg
14763d1a8abSmrg   .. code-block:: c++
14863d1a8abSmrg
14963d1a8abSmrg      gccjit::rvalue negpi = ctxt.new_minus (t_double, pi);
15063d1a8abSmrg
15163d1a8abSmrg   builds the equivalent of this C expression:
15263d1a8abSmrg
15363d1a8abSmrg   .. code-block:: c
15463d1a8abSmrg
15563d1a8abSmrg      -pi
15663d1a8abSmrg
15763d1a8abSmrg.. function:: gccjit::rvalue \
15863d1a8abSmrg              new_bitwise_negate (gccjit::type result_type, \
15963d1a8abSmrg                                  gccjit::rvalue a, \
16063d1a8abSmrg                                  gccjit::location loc)
16163d1a8abSmrg
16263d1a8abSmrg   Bitwise negation of an integer value (one's complement); for example:
16363d1a8abSmrg
16463d1a8abSmrg   .. code-block:: c++
16563d1a8abSmrg
16663d1a8abSmrg      gccjit::rvalue mask = ctxt.new_bitwise_negate (t_int, a);
16763d1a8abSmrg
16863d1a8abSmrg   builds the equivalent of this C expression:
16963d1a8abSmrg
17063d1a8abSmrg   .. code-block:: c
17163d1a8abSmrg
17263d1a8abSmrg      ~a
17363d1a8abSmrg
17463d1a8abSmrg.. function:: gccjit::rvalue \
17563d1a8abSmrg              new_logical_negate (gccjit::type result_type, \
17663d1a8abSmrg                                  gccjit::rvalue a, \
17763d1a8abSmrg                                  gccjit::location loc)
17863d1a8abSmrg
17963d1a8abSmrg   Logical negation of an arithmetic or pointer value; for example:
18063d1a8abSmrg
18163d1a8abSmrg   .. code-block:: c++
18263d1a8abSmrg
18363d1a8abSmrg      gccjit::rvalue guard = ctxt.new_logical_negate (t_bool, cond);
18463d1a8abSmrg
18563d1a8abSmrg   builds the equivalent of this C expression:
18663d1a8abSmrg
18763d1a8abSmrg   .. code-block:: c
18863d1a8abSmrg
18963d1a8abSmrg      !cond
19063d1a8abSmrg
19163d1a8abSmrg
19263d1a8abSmrgThe most concise way to spell them is with overloaded operators:
19363d1a8abSmrg
19463d1a8abSmrg.. function:: gccjit::rvalue operator- (gccjit::rvalue a)
19563d1a8abSmrg
19663d1a8abSmrg   .. code-block:: c++
19763d1a8abSmrg
19863d1a8abSmrg     gccjit::rvalue negpi = -pi;
19963d1a8abSmrg
20063d1a8abSmrg
20163d1a8abSmrg.. function:: gccjit::rvalue operator~ (gccjit::rvalue a)
20263d1a8abSmrg
20363d1a8abSmrg   .. code-block:: c++
20463d1a8abSmrg
20563d1a8abSmrg      gccjit::rvalue mask = ~a;
20663d1a8abSmrg
20763d1a8abSmrg.. function:: gccjit::rvalue operator! (gccjit::rvalue a)
20863d1a8abSmrg
20963d1a8abSmrg   .. code-block:: c++
21063d1a8abSmrg
21163d1a8abSmrg      gccjit::rvalue guard = !cond;
21263d1a8abSmrg
21363d1a8abSmrg
21463d1a8abSmrgBinary Operations
21563d1a8abSmrg*****************
21663d1a8abSmrg
21763d1a8abSmrg.. function:: gccjit::rvalue\
21863d1a8abSmrg              gccjit::context::new_binary_op (enum gcc_jit_binary_op, \
21963d1a8abSmrg                                              gccjit::type result_type, \
22063d1a8abSmrg                                              gccjit::rvalue a, \
22163d1a8abSmrg                                              gccjit::rvalue b, \
22263d1a8abSmrg                                              gccjit::location loc)
22363d1a8abSmrg
22463d1a8abSmrg   Build a binary operation out of two constituent rvalues.
22563d1a8abSmrg
22663d1a8abSmrg   Parameter ``loc`` is optional.
22763d1a8abSmrg
22863d1a8abSmrg   This is a thin wrapper around the C API's
22963d1a8abSmrg   :c:func:`gcc_jit_context_new_binary_op` and the available binary
23063d1a8abSmrg   operations are documented there.
23163d1a8abSmrg
23263d1a8abSmrgThere are shorter ways to spell the various specific kinds of binary
23363d1a8abSmrgoperation:
23463d1a8abSmrg
23563d1a8abSmrg.. function:: gccjit::rvalue \
23663d1a8abSmrg              gccjit::context::new_plus (gccjit::type result_type, \
23763d1a8abSmrg                                         gccjit::rvalue a, gccjit::rvalue b, \
23863d1a8abSmrg                                         gccjit::location loc)
23963d1a8abSmrg
24063d1a8abSmrg.. function:: gccjit::rvalue \
24163d1a8abSmrg              gccjit::context::new_minus (gccjit::type result_type, \
24263d1a8abSmrg                                          gccjit::rvalue a, gccjit::rvalue b, \
24363d1a8abSmrg                                          gccjit::location loc)
24463d1a8abSmrg
24563d1a8abSmrg.. function:: gccjit::rvalue \
24663d1a8abSmrg              gccjit::context::new_mult (gccjit::type result_type, \
24763d1a8abSmrg                                         gccjit::rvalue a, gccjit::rvalue b, \
24863d1a8abSmrg                                         gccjit::location loc)
24963d1a8abSmrg
25063d1a8abSmrg.. function:: gccjit::rvalue \
25163d1a8abSmrg              gccjit::context::new_divide (gccjit::type result_type, \
25263d1a8abSmrg                                           gccjit::rvalue a, gccjit::rvalue b, \
25363d1a8abSmrg                                           gccjit::location loc)
25463d1a8abSmrg
25563d1a8abSmrg.. function:: gccjit::rvalue \
25663d1a8abSmrg              gccjit::context::new_modulo (gccjit::type result_type, \
25763d1a8abSmrg                                           gccjit::rvalue a, gccjit::rvalue b, \
25863d1a8abSmrg                                           gccjit::location loc)
25963d1a8abSmrg
26063d1a8abSmrg.. function:: gccjit::rvalue \
26163d1a8abSmrg              gccjit::context::new_bitwise_and (gccjit::type result_type, \
26263d1a8abSmrg                                                gccjit::rvalue a, gccjit::rvalue b, \
26363d1a8abSmrg                                                gccjit::location loc)
26463d1a8abSmrg
26563d1a8abSmrg.. function:: gccjit::rvalue \
26663d1a8abSmrg              gccjit::context::new_bitwise_xor (gccjit::type result_type, \
26763d1a8abSmrg                                                gccjit::rvalue a, gccjit::rvalue b, \
26863d1a8abSmrg                                                gccjit::location loc)
26963d1a8abSmrg
27063d1a8abSmrg.. function:: gccjit::rvalue \
27163d1a8abSmrg              gccjit::context::new_bitwise_or (gccjit::type result_type, \
27263d1a8abSmrg                                               gccjit::rvalue a, gccjit::rvalue b, \
27363d1a8abSmrg                                               gccjit::location loc)
27463d1a8abSmrg
27563d1a8abSmrg.. function:: gccjit::rvalue \
27663d1a8abSmrg              gccjit::context::new_logical_and (gccjit::type result_type, \
27763d1a8abSmrg                                                gccjit::rvalue a, gccjit::rvalue b, \
27863d1a8abSmrg                                                gccjit::location loc)
27963d1a8abSmrg
28063d1a8abSmrg.. function:: gccjit::rvalue \
28163d1a8abSmrg              gccjit::context::new_logical_or (gccjit::type result_type, \
28263d1a8abSmrg                                               gccjit::rvalue a, gccjit::rvalue b, \
28363d1a8abSmrg                                               gccjit::location loc)
28463d1a8abSmrg
28563d1a8abSmrgThe most concise way to spell them is with overloaded operators:
28663d1a8abSmrg
28763d1a8abSmrg.. function:: gccjit::rvalue operator+ (gccjit::rvalue a, gccjit::rvalue b)
28863d1a8abSmrg
28963d1a8abSmrg   .. code-block:: c++
29063d1a8abSmrg
29163d1a8abSmrg      gccjit::rvalue sum = a + b;
29263d1a8abSmrg
29363d1a8abSmrg.. function:: gccjit::rvalue operator- (gccjit::rvalue a, gccjit::rvalue b)
29463d1a8abSmrg
29563d1a8abSmrg   .. code-block:: c++
29663d1a8abSmrg
29763d1a8abSmrg      gccjit::rvalue diff = a - b;
29863d1a8abSmrg
29963d1a8abSmrg.. function:: gccjit::rvalue operator* (gccjit::rvalue a, gccjit::rvalue b)
30063d1a8abSmrg
30163d1a8abSmrg   .. code-block:: c++
30263d1a8abSmrg
30363d1a8abSmrg      gccjit::rvalue prod = a * b;
30463d1a8abSmrg
30563d1a8abSmrg.. function:: gccjit::rvalue operator/ (gccjit::rvalue a, gccjit::rvalue b)
30663d1a8abSmrg
30763d1a8abSmrg   .. code-block:: c++
30863d1a8abSmrg
30963d1a8abSmrg      gccjit::rvalue result = a / b;
31063d1a8abSmrg
31163d1a8abSmrg.. function:: gccjit::rvalue operator% (gccjit::rvalue a, gccjit::rvalue b)
31263d1a8abSmrg
31363d1a8abSmrg   .. code-block:: c++
31463d1a8abSmrg
31563d1a8abSmrg      gccjit::rvalue mod = a % b;
31663d1a8abSmrg
31763d1a8abSmrg.. function:: gccjit::rvalue operator& (gccjit::rvalue a, gccjit::rvalue b)
31863d1a8abSmrg
31963d1a8abSmrg   .. code-block:: c++
32063d1a8abSmrg
32163d1a8abSmrg      gccjit::rvalue x = a & b;
32263d1a8abSmrg
32363d1a8abSmrg.. function:: gccjit::rvalue operator^ (gccjit::rvalue a, gccjit::rvalue b)
32463d1a8abSmrg
32563d1a8abSmrg   .. code-block:: c++
32663d1a8abSmrg
32763d1a8abSmrg      gccjit::rvalue x = a ^ b;
32863d1a8abSmrg
32963d1a8abSmrg.. function:: gccjit::rvalue operator| (gccjit::rvalue a, gccjit::rvalue b)
33063d1a8abSmrg
33163d1a8abSmrg   .. code-block:: c++
33263d1a8abSmrg
33363d1a8abSmrg      gccjit::rvalue x = a | b;
33463d1a8abSmrg
33563d1a8abSmrg.. function:: gccjit::rvalue operator&& (gccjit::rvalue a, gccjit::rvalue b)
33663d1a8abSmrg
33763d1a8abSmrg   .. code-block:: c++
33863d1a8abSmrg
33963d1a8abSmrg      gccjit::rvalue cond = a && b;
34063d1a8abSmrg
34163d1a8abSmrg.. function:: gccjit::rvalue operator|| (gccjit::rvalue a, gccjit::rvalue b)
34263d1a8abSmrg
34363d1a8abSmrg   .. code-block:: c++
34463d1a8abSmrg
34563d1a8abSmrg      gccjit::rvalue cond = a || b;
34663d1a8abSmrg
34763d1a8abSmrgThese can of course be combined, giving a terse way to build compound
34863d1a8abSmrgexpressions:
34963d1a8abSmrg
35063d1a8abSmrg   .. code-block:: c++
35163d1a8abSmrg
35263d1a8abSmrg      gccjit::rvalue discriminant = (b * b) - (four * a * c);
35363d1a8abSmrg
35463d1a8abSmrg
35563d1a8abSmrgComparisons
35663d1a8abSmrg***********
35763d1a8abSmrg
35863d1a8abSmrg.. function:: gccjit::rvalue \
35963d1a8abSmrg              gccjit::context::new_comparison (enum gcc_jit_comparison,\
36063d1a8abSmrg                                               gccjit::rvalue a, \
36163d1a8abSmrg                                               gccjit::rvalue b, \
36263d1a8abSmrg                                               gccjit::location loc)
36363d1a8abSmrg
36463d1a8abSmrg   Build a boolean rvalue out of the comparison of two other rvalues.
36563d1a8abSmrg
36663d1a8abSmrg   Parameter ``loc`` is optional.
36763d1a8abSmrg
36863d1a8abSmrg   This is a thin wrapper around the C API's
36963d1a8abSmrg   :c:func:`gcc_jit_context_new_comparison` and the available kinds
37063d1a8abSmrg   of comparison are documented there.
37163d1a8abSmrg
37263d1a8abSmrgThere are shorter ways to spell the various specific kinds of binary
37363d1a8abSmrgoperation:
37463d1a8abSmrg
37563d1a8abSmrg.. function:: gccjit::rvalue \
37663d1a8abSmrg              gccjit::context::new_eq (gccjit::rvalue a, gccjit::rvalue b, \
37763d1a8abSmrg                                       gccjit::location loc)
37863d1a8abSmrg
37963d1a8abSmrg.. function:: gccjit::rvalue \
38063d1a8abSmrg              gccjit::context::new_ne (gccjit::rvalue a, gccjit::rvalue b, \
38163d1a8abSmrg                                       gccjit::location loc)
38263d1a8abSmrg
38363d1a8abSmrg.. function:: gccjit::rvalue \
38463d1a8abSmrg              gccjit::context::new_lt (gccjit::rvalue a, gccjit::rvalue b, \
38563d1a8abSmrg                                       gccjit::location loc)
38663d1a8abSmrg
38763d1a8abSmrg.. function:: gccjit::rvalue \
38863d1a8abSmrg              gccjit::context::new_le (gccjit::rvalue a, gccjit::rvalue b, \
38963d1a8abSmrg                                       gccjit::location loc)
39063d1a8abSmrg
39163d1a8abSmrg.. function:: gccjit::rvalue \
39263d1a8abSmrg              gccjit::context::new_gt (gccjit::rvalue a, gccjit::rvalue b, \
39363d1a8abSmrg                                       gccjit::location loc)
39463d1a8abSmrg
39563d1a8abSmrg.. function:: gccjit::rvalue \
39663d1a8abSmrg              gccjit::context::new_ge (gccjit::rvalue a, gccjit::rvalue b, \
39763d1a8abSmrg                                       gccjit::location loc)
39863d1a8abSmrg
39963d1a8abSmrgThe most concise way to spell them is with overloaded operators:
40063d1a8abSmrg
40163d1a8abSmrg.. function:: gccjit::rvalue \
40263d1a8abSmrg              operator== (gccjit::rvalue a, gccjit::rvalue b)
40363d1a8abSmrg
40463d1a8abSmrg   .. code-block:: c++
40563d1a8abSmrg
40663d1a8abSmrg      gccjit::rvalue cond = (a == ctxt.zero (t_int));
40763d1a8abSmrg
40863d1a8abSmrg.. function:: gccjit::rvalue \
40963d1a8abSmrg              operator!= (gccjit::rvalue a, gccjit::rvalue b)
41063d1a8abSmrg
41163d1a8abSmrg   .. code-block:: c++
41263d1a8abSmrg
41363d1a8abSmrg      gccjit::rvalue cond = (i != j);
41463d1a8abSmrg
41563d1a8abSmrg.. function:: gccjit::rvalue \
41663d1a8abSmrg              operator< (gccjit::rvalue a, gccjit::rvalue b)
41763d1a8abSmrg
41863d1a8abSmrg   .. code-block:: c++
41963d1a8abSmrg
42063d1a8abSmrg      gccjit::rvalue cond = i < n;
42163d1a8abSmrg
42263d1a8abSmrg.. function:: gccjit::rvalue \
42363d1a8abSmrg              operator<= (gccjit::rvalue a, gccjit::rvalue b)
42463d1a8abSmrg
42563d1a8abSmrg   .. code-block:: c++
42663d1a8abSmrg
42763d1a8abSmrg      gccjit::rvalue cond = i <= n;
42863d1a8abSmrg
42963d1a8abSmrg.. function:: gccjit::rvalue \
43063d1a8abSmrg              operator> (gccjit::rvalue a, gccjit::rvalue b)
43163d1a8abSmrg
43263d1a8abSmrg   .. code-block:: c++
43363d1a8abSmrg
43463d1a8abSmrg      gccjit::rvalue cond = (ch > limit);
43563d1a8abSmrg
43663d1a8abSmrg.. function:: gccjit::rvalue \
43763d1a8abSmrg              operator>= (gccjit::rvalue a, gccjit::rvalue b)
43863d1a8abSmrg
43963d1a8abSmrg   .. code-block:: c++
44063d1a8abSmrg
44163d1a8abSmrg      gccjit::rvalue cond = (score >= ctxt.new_rvalue (t_int, 100));
44263d1a8abSmrg
44363d1a8abSmrg.. TODO: beyond this point
44463d1a8abSmrg
44563d1a8abSmrgFunction calls
44663d1a8abSmrg**************
44763d1a8abSmrg.. function:: gcc_jit_rvalue *\
44863d1a8abSmrg              gcc_jit_context_new_call (gcc_jit_context *ctxt,\
44963d1a8abSmrg                                        gcc_jit_location *loc,\
45063d1a8abSmrg                                        gcc_jit_function *func,\
45163d1a8abSmrg                                        int numargs , gcc_jit_rvalue **args)
45263d1a8abSmrg
45363d1a8abSmrg   Given a function and the given table of argument rvalues, construct a
45463d1a8abSmrg   call to the function, with the result as an rvalue.
45563d1a8abSmrg
45663d1a8abSmrg   .. note::
45763d1a8abSmrg
45863d1a8abSmrg      :func:`gccjit::context::new_call` merely builds a
45963d1a8abSmrg      :class:`gccjit::rvalue` i.e. an expression that can be evaluated,
46063d1a8abSmrg      perhaps as part of a more complicated expression.
46163d1a8abSmrg      The call *won't* happen unless you add a statement to a function
46263d1a8abSmrg      that evaluates the expression.
46363d1a8abSmrg
46463d1a8abSmrg      For example, if you want to call a function and discard the result
46563d1a8abSmrg      (or to call a function with ``void`` return type), use
46663d1a8abSmrg      :func:`gccjit::block::add_eval`:
46763d1a8abSmrg
46863d1a8abSmrg      .. code-block:: c++
46963d1a8abSmrg
47063d1a8abSmrg         /* Add "(void)printf (arg0, arg1);".  */
47163d1a8abSmrg         block.add_eval (ctxt.new_call (printf_func, arg0, arg1));
47263d1a8abSmrg
473c7a68eb7SmrgFunction pointers
474c7a68eb7Smrg*****************
475c7a68eb7Smrg
476c7a68eb7Smrg.. function:: gccjit::rvalue \
477c7a68eb7Smrg	      gccjit::function::get_address (gccjit::location loc)
478c7a68eb7Smrg
479c7a68eb7Smrg   Get the address of a function as an rvalue, of function pointer
480c7a68eb7Smrg   type.
481c7a68eb7Smrg
48263d1a8abSmrgType-coercion
48363d1a8abSmrg*************
48463d1a8abSmrg
48563d1a8abSmrg.. function:: gccjit::rvalue \
48663d1a8abSmrg              gccjit::context::new_cast (gccjit::rvalue rvalue,\
48763d1a8abSmrg                                         gccjit::type type, \
48863d1a8abSmrg                                         gccjit::location loc)
48963d1a8abSmrg
49063d1a8abSmrg   Given an rvalue of T, construct another rvalue of another type.
49163d1a8abSmrg
49263d1a8abSmrg   Currently only a limited set of conversions are possible:
49363d1a8abSmrg
49463d1a8abSmrg     * int <-> float
49563d1a8abSmrg     * int <-> bool
49663d1a8abSmrg     * P*  <-> Q*, for pointer types P and Q
49763d1a8abSmrg
49863d1a8abSmrgLvalues
49963d1a8abSmrg-------
50063d1a8abSmrg
50163d1a8abSmrg.. class:: gccjit::lvalue
50263d1a8abSmrg
50363d1a8abSmrgAn lvalue is something that can of the *left*-hand side of an assignment:
50463d1a8abSmrga storage area (such as a variable).  It is a subclass of
50563d1a8abSmrg:class:`gccjit::rvalue`, where the rvalue is computed by reading from the
50663d1a8abSmrgstorage area.
50763d1a8abSmrg
50863d1a8abSmrgIt iss a thin wrapper around :c:type:`gcc_jit_lvalue *` from the C API.
50963d1a8abSmrg
51063d1a8abSmrg.. function:: gccjit::rvalue \
51163d1a8abSmrg              gccjit::lvalue::get_address (gccjit::location loc)
51263d1a8abSmrg
51363d1a8abSmrg   Take the address of an lvalue; analogous to:
51463d1a8abSmrg
51563d1a8abSmrg   .. code-block:: c
51663d1a8abSmrg
51763d1a8abSmrg     &(EXPR)
51863d1a8abSmrg
51963d1a8abSmrg   in C.
52063d1a8abSmrg
52163d1a8abSmrg   Parameter "loc" is optional.
52263d1a8abSmrg
52363d1a8abSmrgGlobal variables
52463d1a8abSmrg****************
52563d1a8abSmrg
52663d1a8abSmrg.. function:: gccjit::lvalue \
52763d1a8abSmrg              gccjit::context::new_global (enum gcc_jit_global_kind,\
52863d1a8abSmrg                                           gccjit::type type, \
52963d1a8abSmrg                                           const char *name, \
53063d1a8abSmrg                                           gccjit::location loc)
53163d1a8abSmrg
53263d1a8abSmrg   Add a new global variable of the given type and name to the context.
53363d1a8abSmrg
53463d1a8abSmrg   This is a thin wrapper around :c:func:`gcc_jit_context_new_global` from
53563d1a8abSmrg   the C API; the "kind" parameter has the same meaning as there.
53663d1a8abSmrg
53763d1a8abSmrgWorking with pointers, structs and unions
53863d1a8abSmrg-----------------------------------------
53963d1a8abSmrg
54063d1a8abSmrg.. function:: gccjit::lvalue \
54163d1a8abSmrg              gccjit::rvalue::dereference (gccjit::location loc)
54263d1a8abSmrg
54363d1a8abSmrg   Given an rvalue of pointer type ``T *``, dereferencing the pointer,
54463d1a8abSmrg   getting an lvalue of type ``T``.  Analogous to:
54563d1a8abSmrg
54663d1a8abSmrg   .. code-block:: c++
54763d1a8abSmrg
54863d1a8abSmrg     *(EXPR)
54963d1a8abSmrg
55063d1a8abSmrg   in C.
55163d1a8abSmrg
55263d1a8abSmrg   Parameter "loc" is optional.
55363d1a8abSmrg
55463d1a8abSmrgIf you don't need to specify the location, this can also be expressed using
55563d1a8abSmrgan overloaded operator:
55663d1a8abSmrg
55763d1a8abSmrg.. function:: gccjit::lvalue \
55863d1a8abSmrg              gccjit::rvalue::operator* ()
55963d1a8abSmrg
56063d1a8abSmrg   .. code-block:: c++
56163d1a8abSmrg
56263d1a8abSmrg      gccjit::lvalue content = *ptr;
56363d1a8abSmrg
56463d1a8abSmrgField access is provided separately for both lvalues and rvalues:
56563d1a8abSmrg
56663d1a8abSmrg.. function:: gccjit::lvalue \
56763d1a8abSmrg              gccjit::lvalue::access_field (gccjit::field field, \
56863d1a8abSmrg                                            gccjit::location loc)
56963d1a8abSmrg
57063d1a8abSmrg   Given an lvalue of struct or union type, access the given field,
57163d1a8abSmrg   getting an lvalue of the field's type.  Analogous to:
57263d1a8abSmrg
57363d1a8abSmrg   .. code-block:: c++
57463d1a8abSmrg
57563d1a8abSmrg      (EXPR).field = ...;
57663d1a8abSmrg
57763d1a8abSmrg   in C.
57863d1a8abSmrg
57963d1a8abSmrg.. function:: gccjit::rvalue \
58063d1a8abSmrg              gccjit::rvalue::access_field (gccjit::field field, \
58163d1a8abSmrg                                            gccjit::location loc)
58263d1a8abSmrg
58363d1a8abSmrg   Given an rvalue of struct or union type, access the given field
58463d1a8abSmrg   as an rvalue.  Analogous to:
58563d1a8abSmrg
58663d1a8abSmrg   .. code-block:: c++
58763d1a8abSmrg
58863d1a8abSmrg      (EXPR).field
58963d1a8abSmrg
59063d1a8abSmrg   in C.
59163d1a8abSmrg
59263d1a8abSmrg.. function:: gccjit::lvalue \
59363d1a8abSmrg              gccjit::rvalue::dereference_field (gccjit::field field, \
59463d1a8abSmrg                                                 gccjit::location loc)
59563d1a8abSmrg
59663d1a8abSmrg   Given an rvalue of pointer type ``T *`` where T is of struct or union
59763d1a8abSmrg   type, access the given field as an lvalue.  Analogous to:
59863d1a8abSmrg
59963d1a8abSmrg   .. code-block:: c++
60063d1a8abSmrg
60163d1a8abSmrg      (EXPR)->field
60263d1a8abSmrg
60363d1a8abSmrg   in C, itself equivalent to ``(*EXPR).FIELD``.
60463d1a8abSmrg
60563d1a8abSmrg.. function:: gccjit::lvalue \
60663d1a8abSmrg              gccjit::context::new_array_access (gccjit::rvalue ptr, \
60763d1a8abSmrg                                                 gccjit::rvalue index, \
60863d1a8abSmrg                                                 gccjit::location loc)
60963d1a8abSmrg
61063d1a8abSmrg   Given an rvalue of pointer type ``T *``, get at the element `T` at
61163d1a8abSmrg   the given index, using standard C array indexing rules i.e. each
61263d1a8abSmrg   increment of ``index`` corresponds to ``sizeof(T)`` bytes.
61363d1a8abSmrg   Analogous to:
61463d1a8abSmrg
61563d1a8abSmrg   .. code-block:: c++
61663d1a8abSmrg
61763d1a8abSmrg      PTR[INDEX]
61863d1a8abSmrg
61963d1a8abSmrg   in C (or, indeed, to ``PTR + INDEX``).
62063d1a8abSmrg
62163d1a8abSmrg   Parameter "loc" is optional.
62263d1a8abSmrg
62363d1a8abSmrgFor array accesses where you don't need to specify a :class:`gccjit::location`,
62463d1a8abSmrgtwo overloaded operators are available:
62563d1a8abSmrg
62663d1a8abSmrg    gccjit::lvalue gccjit::rvalue::operator[] (gccjit::rvalue index)
62763d1a8abSmrg
62863d1a8abSmrg    .. code-block:: c++
62963d1a8abSmrg
63063d1a8abSmrg       gccjit::lvalue element = array[idx];
63163d1a8abSmrg
63263d1a8abSmrg    gccjit::lvalue gccjit::rvalue::operator[] (int index)
63363d1a8abSmrg
63463d1a8abSmrg    .. code-block:: c++
63563d1a8abSmrg
63663d1a8abSmrg       gccjit::lvalue element = array[0];
637