public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [jit] Pass std::vector by reference within the C++ wrapper API
@ 2014-02-10 16:18 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2014-02-10 16:18 UTC (permalink / raw)
  To: jit, gcc-patches; +Cc: David Malcolm

Committed to branch dmalcolm/jit:

gcc/jit/
	* libgccjit++.h (gccjit::context::new_struct_type): Pass std::vector
	"fields" argument by reference rather than by value.
	(gccjit::context::new_function): Likewise, for "params" arg.
	(gccjit::context::new_call): Likewise, for "args" arg.

gcc/testsuite/
	* jit.dg/test-quadratic.cc (make_test_quadratic): Update for
	change to gccjit::context::new_call to pass args by reference
	rather than by value.
---
 gcc/jit/ChangeLog.jit                  |  7 +++++++
 gcc/jit/libgccjit++.h                  | 12 ++++++------
 gcc/testsuite/ChangeLog.jit            |  6 ++++++
 gcc/testsuite/jit.dg/test-quadratic.cc |  3 ++-
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index e1e908f..8f1083a 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,5 +1,12 @@
 2014-02-10  David Malcolm  <dmalcolm@redhat.com>
 
+	* libgccjit++.h (gccjit::context::new_struct_type): Pass std::vector
+	"fields" argument by reference rather than by value.
+	(gccjit::context::new_function): Likewise, for "params" arg.
+	(gccjit::context::new_call): Likewise, for "args" arg.
+
+2014-02-10  David Malcolm  <dmalcolm@redhat.com>
+
 	* libgccjit++.h (gccjit::context::new_location): Update filename
 	arg from a const char * to a const std::string &.
 	(gccjit::context::new_field): Likewise for "name" arg.
diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h
index 1579979..ae55058 100644
--- a/gcc/jit/libgccjit++.h
+++ b/gcc/jit/libgccjit++.h
@@ -88,7 +88,7 @@ namespace gccjit
 		     location loc = location ());
 
     type new_struct_type (const std::string &name,
-			  std::vector<field> fields,
+			  std::vector<field> &fields,
 			  location loc = location ());
 
     param new_param (type type_,
@@ -98,7 +98,7 @@ namespace gccjit
     function new_function (enum gcc_jit_function_kind kind,
 			   type return_type,
 			   const std::string &name,
-			   std::vector<param> params,
+			   std::vector<param> &params,
 			   int is_variadic,
 			   location loc = location ());
 
@@ -127,7 +127,7 @@ namespace gccjit
 			   location loc = location ());
 
     rvalue new_call (function func,
-		     std::vector<rvalue> args,
+		     std::vector<rvalue> &args,
 		     location loc = location ());
 
     lvalue new_array_access (rvalue ptr,
@@ -343,7 +343,7 @@ context::new_field (type type_, const std::string &name, location loc)
 
 inline type
 context::new_struct_type (const std::string &name,
-			  std::vector<field> fields,
+			  std::vector<field> &fields,
 			  location loc)
 {
   /* Treat std::vector as an array, relying on it not being resized: */
@@ -376,7 +376,7 @@ inline function
 context::new_function (enum gcc_jit_function_kind kind,
 		       type return_type,
 		       const std::string &name,
-		       std::vector<param> params,
+		       std::vector<param> &params,
 		       int is_variadic,
 		       location loc)
 {
@@ -490,7 +490,7 @@ context::new_comparison (enum gcc_jit_comparison op,
 
 inline rvalue
 context::new_call (function func,
-		   std::vector<rvalue> args,
+		   std::vector<rvalue> &args,
 		   location loc)
 {
   /* Treat std::vector as an array, relying on it not being resized: */
diff --git a/gcc/testsuite/ChangeLog.jit b/gcc/testsuite/ChangeLog.jit
index 3db5cf5..79d2096 100644
--- a/gcc/testsuite/ChangeLog.jit
+++ b/gcc/testsuite/ChangeLog.jit
@@ -1,3 +1,9 @@
+2014-02-10  David Malcolm  <dmalcolm@redhat.com>
+
+	* jit.dg/test-quadratic.cc (make_test_quadratic): Update for
+	change to gccjit::context::new_call to pass args by reference
+	rather than by value.
+
 2014-02-03  David Malcolm  <dmalcolm@redhat.com>
 
 	* jit.dg/harness.h (check_string_value): Add a forward declaration,
diff --git a/gcc/testsuite/jit.dg/test-quadratic.cc b/gcc/testsuite/jit.dg/test-quadratic.cc
index 52ae92e..75725c0 100644
--- a/gcc/testsuite/jit.dg/test-quadratic.cc
+++ b/gcc/testsuite/jit.dg/test-quadratic.cc
@@ -247,11 +247,12 @@ make_test_quadratic (quadratic_test &testcase)
   /* double s = sqrt (q.discriminant); */
   gccjit::lvalue s = test_quadratic.new_local (testcase.numeric_type, "s");
   gccjit::rvalue discriminant_of_q = q.access_field (testcase.discriminant);
+  std::vector<gccjit::rvalue> args_to_sqrt_call (1, discriminant_of_q);
   test_quadratic.add_assignment (
     s,
     testcase.ctxt.new_call (
       testcase.sqrt,
-      std::vector<gccjit::rvalue> (1, discriminant_of_q)));
+      args_to_sqrt_call));
 
   gccjit::rvalue minus_b =
     testcase.ctxt.new_unary_op (
-- 
1.7.11.7

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

only message in thread, other threads:[~2014-02-10 16:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-10 16:18 [jit] Pass std::vector by reference within the 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).