diff mbox

[jit] Add some methods to the C++ wrapper API.

Message ID 1391718594-6019-1-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Feb. 6, 2014, 8:29 p.m. UTC
Committed to branch dmalcolm/jit:

gcc/jit/
	* libgccjit++.h: Include <ostream> rather than <iostream>, since
	the former gets us std::ostream, and the latter may introduce
	startup-time overhead for constructing std::cout et al.
	(gccjit::context::new_child_context): New.
	(gccjit::context::release): New.
	(gccjit::context::compile): New.
	(gccjit::context::set_int_option): New.
	(gccjit::context::set_bool_option): New.
---
 gcc/jit/ChangeLog.jit | 11 +++++++++++
 gcc/jit/libgccjit++.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 59 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index be96ff7..6950b13 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,3 +1,14 @@ 
+2014-02-06  David Malcolm  <dmalcolm@redhat.com>
+
+	* libgccjit++.h: Include <ostream> rather than <iostream>, since
+	the former gets us std::ostream, and the latter may introduce
+	startup-time overhead for constructing std::cout et al.
+	(gccjit::context::new_child_context): New.
+	(gccjit::context::release): New.
+	(gccjit::context::compile): New.
+	(gccjit::context::set_int_option): New.
+	(gccjit::context::set_bool_option): New.
+
 2014-02-03  David Malcolm  <dmalcolm@redhat.com>
 
 	* libgccjit.h (struct gcc_jit_object): New.
diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h
index 79abcd1..b7f5d4b 100644
--- a/gcc/jit/libgccjit++.h
+++ b/gcc/jit/libgccjit++.h
@@ -5,7 +5,7 @@ 
 
 #include "libgccjit.h"
 
-#include <iostream>
+#include <ostream>
 #include <vector>
 
 /****************************************************************************
@@ -31,6 +31,18 @@  namespace gccjit
     context ();
     context (gcc_jit_context *ctxt);
 
+    gccjit::context new_child_context ();
+
+    void release ();
+
+    gcc_jit_result *compile ();
+
+    void set_int_option (enum gcc_jit_int_option opt,
+			 int value);
+
+    void set_bool_option (enum gcc_jit_bool_option opt,
+			  int value);
+
     location
     new_location (const char *filename,
 		  int line,
@@ -295,6 +307,41 @@  inline context context::acquire ()
 inline context::context () : m_inner_ctxt (NULL) {}
 inline context::context (gcc_jit_context *inner) : m_inner_ctxt (inner) {}
 
+inline gccjit::context
+context::new_child_context ()
+{
+  return context (gcc_jit_context_new_child_context (m_inner_ctxt));
+}
+
+inline void
+context::release ()
+{
+  gcc_jit_context_release (m_inner_ctxt);
+  m_inner_ctxt = NULL;
+}
+
+inline gcc_jit_result *
+context::compile ()
+{
+  return gcc_jit_context_compile (m_inner_ctxt);
+}
+
+inline void
+context::set_int_option (enum gcc_jit_int_option opt,
+			 int value)
+{
+  gcc_jit_context_set_int_option (m_inner_ctxt, opt, value);
+
+}
+
+inline void
+context::set_bool_option (enum gcc_jit_bool_option opt,
+			  int value)
+{
+  gcc_jit_context_set_bool_option (m_inner_ctxt, opt, value);
+
+}
+
 inline location
 context::new_location (const char *filename,
 		       int line,