@@ -1,3 +1,9 @@
+2014-02-14 David Malcolm <dmalcolm@redhat.com>
+
+ * libgccjit++.h (gccjit::type::zero): New method.
+ (gccjit::type::one): New method.
+ (gccjit::function::add_call): New family of overloaded methods.
+
2014-02-13 David Malcolm <dmalcolm@redhat.com>
* libgccjit.h (gcc_jit_context_get_builtin_function): New.
@@ -259,6 +259,9 @@ namespace gccjit
type get_pointer ();
+ // Shortcuts for getting values of numeric types:
+ rvalue zero ();
+ rvalue one ();
};
class function : public object
@@ -311,6 +314,20 @@ namespace gccjit
void add_return (rvalue rvalue,
location loc = location ());
+ /* A way to add a function call to the body of a function being
+ defined, with various numbers of args. */
+ rvalue add_call (function other,
+ location loc = location ());
+ rvalue add_call (function other,
+ rvalue arg0,
+ location loc = location ());
+ rvalue add_call (function other,
+ rvalue arg0, rvalue arg1,
+ location loc = location ());
+ rvalue add_call (function other,
+ rvalue arg0, rvalue arg1, rvalue arg2,
+ location loc = location ());
+
/* A series of overloaded operator () with various numbers of arguments
for a very terse way of creating a call to this function. The call
is created within the same context as the function itself, which may
@@ -991,6 +1008,18 @@ type::get_pointer ()
return type (gcc_jit_type_get_pointer (get_inner_type ()));
}
+inline rvalue
+type::zero ()
+{
+ return get_context ().new_rvalue (*this, 0);
+}
+
+inline rvalue
+type::one ()
+{
+ return get_context ().new_rvalue (*this, 1);
+}
+
// class function
inline function::function () : object (NULL) {}
inline function::function (gcc_jit_function *inner)
@@ -1136,6 +1165,42 @@ function::add_return (rvalue rvalue,
}
inline rvalue
+function::add_call (function other,
+ location loc)
+{
+ rvalue c = get_context ().new_call (other, loc);
+ add_eval (c);
+ return c;
+}
+inline rvalue
+function::add_call (function other,
+ rvalue arg0,
+ location loc)
+{
+ rvalue c = get_context ().new_call (other, arg0, loc);
+ add_eval (c);
+ return c;
+}
+inline rvalue
+function::add_call (function other,
+ rvalue arg0, rvalue arg1,
+ location loc)
+{
+ rvalue c = get_context ().new_call (other, arg0, arg1, loc);
+ add_eval (c);
+ return c;
+}
+inline rvalue
+function::add_call (function other,
+ rvalue arg0, rvalue arg1, rvalue arg2,
+ location loc)
+{
+ rvalue c = get_context ().new_call (other, arg0, arg1, arg2, loc);
+ add_eval (c);
+ return c;
+}
+
+inline rvalue
function::operator() (location loc)
{
return get_context ().new_call (*this, loc);
@@ -1,3 +1,10 @@
+2014-02-14 David Malcolm <dmalcolm@redhat.com>
+
+ * jit.dg/test-operator-overloading.cc (make_test_quadratic): Use
+ the new "zero" and "one" methods of gccjit::type.
+ * jit.dg/test-quadratic.cc (make_test_quadratic): Use the new
+ "add_call" method of gccjit::function.
+
2014-02-13 David Malcolm <dmalcolm@redhat.com>
* jit.dg/harness.h (CHECK_DOUBLE_VALUE): New macro.
@@ -253,11 +253,11 @@ make_test_quadratic (quadratic_test &testcase)
test_quadratic.add_assignment (*r1, minus_b / two_a);
/* "return 1;" */
- test_quadratic.add_return (testcase.ctxt.one (testcase.int_type));
+ test_quadratic.add_return (testcase.int_type.one ());
/* else return 0; */
test_quadratic.place_forward_label (on_negative_discriminant);
- test_quadratic.add_return (testcase.ctxt.zero (testcase.int_type));
+ test_quadratic.add_return (testcase.int_type.zero ());
/* Verify that output stream operator << works. */
std::ostringstream os;
@@ -208,8 +208,7 @@ make_test_quadratic (quadratic_test &testcase)
test_quadratic.add_assignment (q.access_field (testcase.c), c);
/* calc_discriminant (&q); */
gccjit::rvalue address_of_q = q.get_address ();
- test_quadratic.add_eval (
- testcase.ctxt.new_call (testcase.calc_discriminant, address_of_q));
+ test_quadratic.add_call (testcase.calc_discriminant, address_of_q);
gccjit::label on_positive_discriminant
= test_quadratic.new_forward_label ("positive_discriminant");