3.2.4.6 Comparisons

C++ Function: gccjit::rvalue gccjit::context::new_comparison (enum gcc_jit_comparison, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)

Build a boolean rvalue out of the comparison of two other rvalues.

Parameter loc is optional.

This is a thin wrapper around the C API’s gcc_jit_context_new_comparison() and the available kinds of comparison are documented there.

There are shorter ways to spell the various specific kinds of binary operation:

C++ Function: gccjit::rvalue gccjit::context::new_eq (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)
C++ Function: gccjit::rvalue gccjit::context::new_ne (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)
C++ Function: gccjit::rvalue gccjit::context::new_lt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)
C++ Function: gccjit::rvalue gccjit::context::new_le (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)
C++ Function: gccjit::rvalue gccjit::context::new_gt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)
C++ Function: gccjit::rvalue gccjit::context::new_ge (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc)

The most concise way to spell them is with overloaded operators:

C++ Function: gccjit::rvalue operator== (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = (a == ctxt.zero (t_int));
C++ Function: gccjit::rvalue operator!= (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = (i != j);
C++ Function: gccjit::rvalue operator< (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = i < n;
C++ Function: gccjit::rvalue operator<= (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = i <= n;
C++ Function: gccjit::rvalue operator> (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = (ch > limit);
C++ Function: gccjit::rvalue operator>= (gccjit::rvalue a, gccjit::rvalue b)
gccjit::rvalue cond = (score >= ctxt.new_rvalue (t_int, 100));