public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [jit] Add gcc_jit_function_get_param
@ 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 (gcc_jit_function_get_param): New.
	* libgccjit.map (gcc_jit_function_get_param): New.
	* libgccjit.c (gcc_jit_function_get_param): New.
	* libgccjit++.h (gccjit::function::get_param): New.
---
 gcc/jit/ChangeLog.jit |  7 +++++++
 gcc/jit/libgccjit++.h |  9 +++++++++
 gcc/jit/libgccjit.c   | 17 +++++++++++++++++
 gcc/jit/libgccjit.h   |  3 +++
 gcc/jit/libgccjit.map |  1 +
 5 files changed, 37 insertions(+)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index 8b3c947..001cefb 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 (gcc_jit_function_get_param): New.
+	* libgccjit.map (gcc_jit_function_get_param): New.
+	* libgccjit.c (gcc_jit_function_get_param): New.
+	* libgccjit++.h (gccjit::function::get_param): New.
+
+2014-02-10  David Malcolm  <dmalcolm@redhat.com>
+
 	* libgccjit++.h (gccjit::object::get_inner_object): Make const.
 	(gccjit::location::get_inner_location): Likewise.
 	(gccjit::field::get_inner_field): Likewise.
diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h
index f3c26ee..74c02ea 100644
--- a/gcc/jit/libgccjit++.h
+++ b/gcc/jit/libgccjit++.h
@@ -259,6 +259,8 @@ namespace gccjit
 
     gcc_jit_function *get_inner_function () const;
 
+    param get_param (int index);
+
     label new_forward_label ();
     label new_forward_label (const std::string &name);
 
@@ -970,6 +972,13 @@ function::get_inner_function () const
   return reinterpret_cast<gcc_jit_function *> (get_inner_object ());
 }
 
+inline param
+function::get_param (int index)
+{
+  return param (gcc_jit_function_get_param (get_inner_function (),
+					    index));
+}
+
 inline label
 function::new_forward_label ()
 {
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 3f39984..da1afdc 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -397,6 +397,23 @@ gcc_jit_function_as_object (gcc_jit_function *func)
   return static_cast <gcc_jit_object *> (func->as_object ());
 }
 
+gcc_jit_param *
+gcc_jit_function_get_param (gcc_jit_function *func, int index)
+{
+  RETURN_NULL_IF_FAIL (func, NULL, "NULL function");
+  gcc::jit::recording::context *ctxt = func->m_ctxt;
+  RETURN_NULL_IF_FAIL (index >= 0, ctxt, "negative index");
+  int num_params = func->get_params ().length ();
+  RETURN_NULL_IF_FAIL_PRINTF3 (index < num_params,
+			       ctxt,
+			       "index of %d is too large (%s has %d params)",
+			       index,
+			       func->get_debug_string (),
+			       num_params);
+
+  return static_cast <gcc_jit_param *> (func->get_param (index));
+}
+
 gcc_jit_label*
 gcc_jit_function_new_forward_label (gcc_jit_function *func,
 				    const char *name)
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index e0161ba..03e9ff8 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -435,6 +435,9 @@ gcc_jit_context_new_function (gcc_jit_context *ctxt,
 extern gcc_jit_object *
 gcc_jit_function_as_object (gcc_jit_function *func);
 
+extern gcc_jit_param *
+gcc_jit_function_get_param (gcc_jit_function *func, int index);
+
 /* Create a label, to be placed later.
 
    The name can be NULL, or you can give it a meaningful name, which
diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map
index 6dc700d..45b2a2f 100644
--- a/gcc/jit/libgccjit.map
+++ b/gcc/jit/libgccjit.map
@@ -39,6 +39,7 @@
     gcc_jit_function_add_label;
     gcc_jit_function_add_return;
     gcc_jit_function_as_object;
+    gcc_jit_function_get_param;
     gcc_jit_function_new_forward_label;
     gcc_jit_function_new_local;
     gcc_jit_function_new_loop;
-- 
1.7.11.7

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

only message in thread, other threads:[~2014-02-10 20:10 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 gcc_jit_function_get_param 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).