public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [jit] Add more syntactic sugar to C++ wrapper API
@ 2014-01-01  0:00 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2014-01-01  0:00 UTC (permalink / raw)
  To: jit, gcc-patches; +Cc: David Malcolm

Committed to branch dmalcolm/jit:

gcc/jit/
	* libgccjit++.h (gccjit::function::operator()): Add overload for
	a call with 3 arguments.
	(gccjit::block::add_call): Likewise for 4 arguments.
	(gccjit::rvalue::cast_to): New method.
	(gccjit::rvalue::operator[]): New methods.
---
 gcc/jit/ChangeLog.jit |  8 ++++++++
 gcc/jit/libgccjit++.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index f2fea8c..dd4bf84 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,3 +1,11 @@
+2014-03-03  David Malcolm  <dmalcolm@redhat.com>
+
+	* libgccjit++.h (gccjit::function::operator()): Add overload for
+	a call with 3 arguments.
+	(gccjit::block::add_call): Likewise for 4 arguments.
+	(gccjit::rvalue::cast_to): New method.
+	(gccjit::rvalue::operator[]): New methods.
+
 2014-02-28  David Malcolm  <dmalcolm@redhat.com>
 
 	* libgccjit.c (gcc_jit_context_new_binary_op): Check that the
diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h
index b77e82f..e7ff5ea 100644
--- a/gcc/jit/libgccjit++.h
+++ b/gcc/jit/libgccjit++.h
@@ -310,6 +310,8 @@ namespace gccjit
 		       location loc = location ());
     rvalue operator() (rvalue arg0, rvalue arg1,
 		       location loc = location ());
+    rvalue operator() (rvalue arg0, rvalue arg1, rvalue arg2,
+		       location loc = location ());
   };
 
   class block : public object
@@ -347,6 +349,9 @@ namespace gccjit
     rvalue add_call (function other,
 		     rvalue arg0, rvalue arg1, rvalue arg2,
 		     location loc = location ());
+    rvalue add_call (function other,
+		     rvalue arg0, rvalue arg1, rvalue arg2, rvalue arg3,
+		     location loc = location ());
 
     void add_comment (const std::string &text,
 		      location loc = location ());
@@ -381,7 +386,14 @@ namespace gccjit
 			      location loc = location ());
 
     lvalue dereference (location loc = location ());
- };
+
+    rvalue cast_to (type type_,
+		    location loc = location ());
+
+    /* Array access.  */
+    lvalue operator[] (rvalue index);
+    lvalue operator[] (int index);
+  };
 
   class lvalue : public rvalue
   {
@@ -1249,6 +1261,16 @@ block::add_call (function other,
 }
 
 inline rvalue
+block::add_call (function other,
+		 rvalue arg0, rvalue arg1, rvalue arg2, rvalue arg3,
+		 location loc)
+{
+  rvalue c = get_context ().new_call (other, arg0, arg1, arg2, arg3, loc);
+  add_eval (c);
+  return c;
+}
+
+inline rvalue
 function::operator() (location loc)
 {
   return get_context ().new_call (*this, loc);
@@ -1269,6 +1291,14 @@ function::operator() (rvalue arg0, rvalue arg1,
 				  arg0, arg1,
 				  loc);
 }
+inline rvalue
+function::operator() (rvalue arg0, rvalue arg1, rvalue arg2,
+		      location loc)
+{
+  return get_context ().new_call (*this,
+				  arg0, arg1, arg2,
+				  loc);
+}
 
 // class block
 inline block::block () : object (NULL) {}
@@ -1327,6 +1357,29 @@ rvalue::dereference (location loc)
 					     loc.get_inner_location ()));
 }
 
+inline rvalue
+rvalue::cast_to (type type_,
+		 location loc)
+{
+  return get_context ().new_cast (*this, type_, loc);
+}
+
+inline lvalue
+rvalue::operator[] (rvalue index)
+{
+  return get_context ().new_array_access (*this, index);
+}
+
+inline lvalue
+rvalue::operator[] (int index)
+{
+  context ctxt = get_context ();
+  type int_t = ctxt.get_int_type <int> ();
+  return ctxt.new_array_access (*this,
+				ctxt.new_rvalue (int_t,
+						 index));
+}
+
 // class lvalue : public rvalue
 inline lvalue::lvalue () : rvalue () {}
 inline lvalue::lvalue (gcc_jit_lvalue *inner)
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-03 18:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-01  0:00 [jit] Add more syntactic sugar to C++ wrapper API David Malcolm

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