aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/libgccjit.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-08-03 20:14:21 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-08-03 20:14:21 +0000
commitafed345982d5923b04d41885e868c9ca345ff3f9 (patch)
treeb90c7df0235fa14daf2c76f22203ee08c2c32bcb /gcc/jit/libgccjit.h
parentef9da28d8fa1e2c0dc890f87374c0f21b18430c3 (diff)
downloadgcc-afed345982d5923b04d41885e868c9ca345ff3f9.zip
gcc-afed345982d5923b04d41885e868c9ca345ff3f9.tar.gz
gcc-afed345982d5923b04d41885e868c9ca345ff3f9.tar.bz2
Refactoring of timevar API
gcc/ChangeLog: * main.c (main): Pass in NULL for toplev's external_timer. * timevar.c: Include coretypes.h. (class timer::named_items): New. (timer::named_items::named_items): New. (timer::named_items::~named_items): New. (timer::named_items::push): New. (timer::named_items::pop): New. (timer::named_items::print): New. (timer::timer): Initialize field "m_jit_client_items". (timer::~timer): New. (timer::push): Move bulk of implementation to... (timer::push_internal): ...here. New function. (timer::pop): Move bulk of implementation to... (timer::pop_internal): ...here. New function. (timer::push_client_item): New. (timer::pop_client_item): New. (timer::print_row): New function, taken from timer::print. (timer::print): Print "GCC items" header if we also have client items. Move row-printing to timer::print_row. Print any client items. (timer::get_topmost_item_name): New method. * timevar.def (TV_JIT_ACQUIRING_MUTEX): New. (TV_JIT_CLIENT_CODE): New. * timevar.h (timer::push_client_item): New declaration. (timer::pop_client_item): New declaration. (timer::get_topmost_item_name): New method. (timer::push_internal): New declaration. (timer::pop_internal): New declaration. (timer::print_row): New declaration. (timer::named_items): New declaration. (timer::m_jit_client_items): New field. (timer): Add friend class named_items. (auto_timevar::auto_timevar): Add timer param. (auto_timevar::~auto_timevar): Use field "m_timer". (auto_timevar::m_timer): New field. * toplev.c (initialize_rtl): Add g_timer as param when constructing auto_timevar instance. (toplev::toplev): Add "external_timer" param, and use it to initialize the "g_timer" global if non-NULL. (toplev::~toplev): If this created "g_timer", delete it. * toplev.h (toplev::toplev): Replace "use_TV_TOTAL" bool param with "external_timer" timer *. gcc/jit/ChangeLog: * docs/topics/compatibility.rst (LIBGCCJIT_ABI_4): New. * docs/topics/contexts.rst (GCC_JIT_BOOL_OPTION_DUMP_SUMMARY): We no longer show a profile. * docs/topics/index.rst (Topic Reference): Add performance.rst. * docs/topics/performance.rst: New file. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::context::compile): Add timer param when constructing the "toplev" instance. (gcc::jit::playback::context::acquire_mutex): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::make_fake_args): If we have a timer, add "-ftime-report". (gcc::jit::playback::context::invoke_driver): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::dlopen_built_dso): Likewise. * jit-playback.h (gcc::jit::playback::context::get_timer): New accessor. * jit-recording.c: Include timevar.h. (gcc::jit::recording::context::context): Initialize field "m_timer". * jit-recording.h: Add forward declaration of class timer. (gcc::jit::recording::context::set_timer): New method. (gcc::jit::recording::context::get_timer): New method. (gcc::jit::recording::context::m_timer): New field. * libgccjit++.h (gccjit::timer): New class. (gccjit::auto_time): New class. (gccjit::context::set_timer): New method. (gccjit::context::get_timer): New. (gccjit::timer::timer): New. (gccjit::timer::push): New. (gccjit::timer::pop): New. (timer::print): New. (timer::get_inner_timer): New. (timer::release): New. (auto_time::auto_time): New. (auto_time::~auto_time): New. * libgccjit.c: Include timevar.h. (struct gcc_jit_timer): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.h (LIBGCCJIT_HAVE_TIMING_API): New macro. (gcc_jit_timer): New typedef. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.map (LIBGCCJIT_ABI_4): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. gcc/testsuite/ChangeLog: * jit.dg/test-benchmark.c (test_jit): Add param "timer" and use it to push/pop timing items. (main): For each optimization level, create a gcc_jit_timer, and time all of the iteration within that level cumulatively. * jit.dg/test-error-gcc_jit_timer_pop-mismatch.c: New test case. * jit.dg/test-error-gcc_jit_timer_pop-too-many.c: New test case. From-SVN: r226530
Diffstat (limited to 'gcc/jit/libgccjit.h')
-rw-r--r--gcc/jit/libgccjit.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 32f2a5d..88e4ff3 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -1266,6 +1266,90 @@ gcc_jit_context_enable_dump (gcc_jit_context *ctxt,
const char *dumpname,
char **out_ptr);
+/**********************************************************************
+ Timing support.
+ **********************************************************************/
+
+/* The timing API was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+#define LIBGCCJIT_HAVE_TIMING_API
+
+typedef struct gcc_jit_timer gcc_jit_timer;
+
+/* Create a gcc_jit_timer instance, and start timing.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+extern gcc_jit_timer *
+gcc_jit_timer_new (void);
+
+/* Release a gcc_jit_timer instance.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+extern void
+gcc_jit_timer_release (gcc_jit_timer *timer);
+
+/* Associate a gcc_jit_timer instance with a context.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+extern void
+gcc_jit_context_set_timer (gcc_jit_context *ctxt,
+ gcc_jit_timer *timer);
+
+/* Get the timer associated with a context (if any).
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+
+extern gcc_jit_timer *
+gcc_jit_context_get_timer (gcc_jit_context *ctxt);
+
+/* Push the given item onto the timing stack.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+
+extern void
+gcc_jit_timer_push (gcc_jit_timer *timer,
+ const char *item_name);
+
+/* Pop the top item from the timing stack.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+
+extern void
+gcc_jit_timer_pop (gcc_jit_timer *timer,
+ const char *item_name);
+
+/* Print timing information to the given stream about activity since
+ the timer was started.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_TIMING_API
+*/
+
+extern void
+gcc_jit_timer_print (gcc_jit_timer *timer,
+ FILE *f_out);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */