diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-01-08 19:41:07 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-01-08 19:41:07 +0000 |
commit | eb4c16eb849c4c06009186a4df409186d46f5e8d (patch) | |
tree | fb0c1dc7bb71ee82c586ff5bfaf5f70fad96ddb7 | |
parent | efa7df3c625146460d7ec345d32a4efb42be871b (diff) | |
download | gcc-eb4c16eb849c4c06009186a4df409186d46f5e8d.zip gcc-eb4c16eb849c4c06009186a4df409186d46f5e8d.tar.gz gcc-eb4c16eb849c4c06009186a4df409186d46f5e8d.tar.bz2 |
New jit API entrypoint: gcc_jit_context_set_logfile
gcc/jit/ChangeLog:
* Make-lang.in (jit_OBJS): Add jit/jit-logging.o.
* docs/internals/index.rst (Overview of code structure): Mention
gcc_jit_context_set_logfile, and embed the example logfile.
* docs/internals/test-hello-world.exe.log.txt: New file: example
of a logfile.
* docs/topics/contexts.rst (Debugging): Add documentation
for gcc_jit_context_set_logfile.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
* dummy-frontend.c: Include "jit-logging.h".
(jit_langhook_init): Assert that there is an active playback
context. If it has a logger, log entry/exit to this function.
(jit_langhook_write_globals): Likewise.
* jit-common.h (gcc::jit::logger): New forward declaration.
* jit-logging.c: New file.
* jit-logging.h: New file.
* jit-playback.c: Include "jit-logging.h".
(gcc::jit::playback::context::context): Initialize the log_user
base class from the recording context's logger (if any). Use
JIT_LOG_SCOPE to log entry/exit from the function body.
(gcc::jit::playback::context::~context): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
(gcc::jit::playback::build_stmt_list): Likewise.
(gcc::jit::playback::function::postprocess): Likewise.
(gcc::jit::playback::context::compile): Likewise. Log the
entry/exit to toplev::main and toplev::finalize. Log the
fake argv passed to toplev::main.
(gcc::jit::playback::context::acquire_mutex): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
(gcc::jit::playback::context::release_mutex): Likewise.
(gcc::jit::playback::context::make_fake_args): Likewise.
(gcc::jit::playback::context::extract_any_requested_dumps):
Likewise.
(gcc::jit::playback::context::convert_to_dso): Likewise. Also,
log the arguments that the driver is invoked with.
(gcc::jit::playback::context::dlopen_built_dso): Likewise. Pass
the logger to the result object.
(gcc::jit::playback::context::replay): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
(gcc::jit::playback::context::dump_generated_code): Likewise.
(gcc::jit::playback::context::handle_locations): Likewise.
* jit-playback.h (gcc::jit::playback::context): Make this be
a subclass of gcc::jit::log_user.
* jit-recording.c: Include "jit-logging.h".
(gcc::jit::recording::context::context: Initialize the logger to
NULL for root contexts, or to the parent's logger for child
contexts.
(gcc::jit::recording::context::~context): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
(gcc::jit::recording::context::replay_into): Likewise.
(gcc::jit::recording::context::disassociate_from_playback):
Likewise.
(gcc::jit::recording::context::compile): Likewise.
(recording::context::add_error_va): Likewise. Also, log the
error.
(gcc::jit::recording::context::validate): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
* jit-recording.h: Include "jit-logging.h".
(gcc::jit::recording::context): Make this be a subclass of
gcc::jit::log_user.
* jit-result.c: Include "jit-common.h" and "jit-logging.h".
(gcc::jit::result::result): Add logger param, recording it.
Use JIT_LOG_SCOPE to log entry/exit from the function body.
(gcc::jit::result::~result(): Use JIT_LOG_SCOPE to
log entry/exit from the function body.
(gcc::jit::result::get_code): Likewise.
* jit-result.h (gcc::jit::result): Make this be a subclass of
gcc::jit::log_user.
(gcc::jit::result::result): Add logger parameter.
* libgccjit++.h (gccjit::context::set_logfile): New function.
* libgccjit.c: Include "jit-logging.h".
(gcc_jit_context_acquire): Log the context.
(gcc_jit_context_release): Use JIT_LOG_FUNC to
log entry/exit from the function body, and log the context.
(gcc_jit_context_new_child_context): Likewise, logging both
contexts.
(gcc_jit_context_new_location): Use JIT_LOG_FUNC to
log entry/exit from the function body.
(gcc_jit_context_get_type): Likewise.
(gcc_jit_context_get_int_type): Likewise.
(gcc_jit_context_new_array_type): Likewise.
(gcc_jit_context_new_field): Likewise.
(gcc_jit_context_new_struct_type): Likewise.
(gcc_jit_context_new_opaque_struct): Likewise.
(gcc_jit_struct_set_fields): Likewise.
(gcc_jit_context_new_union_type): Likewise.
(gcc_jit_context_new_function_ptr_type): Likewise.
(gcc_jit_context_new_param): Likewise.
(gcc_jit_context_new_function): Likewise.
(gcc_jit_context_get_builtin_function): Likewise.
(gcc_jit_function_get_param): Likewise.
(gcc_jit_function_dump_to_dot): Likewise.
(gcc_jit_function_new_block): Likewise.
(gcc_jit_context_new_global): Likewise.
(gcc_jit_context_new_rvalue_from_int): Likewise.
(gcc_jit_context_zero): Likewise.
(gcc_jit_context_one): Likewise.
(gcc_jit_context_new_rvalue_from_double): Likewise.
(gcc_jit_context_new_rvalue_from_ptr): Likewise.
(gcc_jit_context_null): Likewise.
(gcc_jit_context_new_string_literal): Likewise.
(gcc_jit_context_new_unary_op): Likewise.
(gcc_jit_context_new_binary_op): Likewise.
(gcc_jit_context_new_comparison): Likewise.
(gcc_jit_context_new_call): Likewise.
(gcc_jit_context_new_call_through_ptr): Likewise.
(gcc_jit_context_new_cast): Likewise.
(gcc_jit_context_new_array_access): Likewise.
(gcc_jit_lvalue_access_field): Likewise.
(gcc_jit_rvalue_access_field): Likewise.
(gcc_jit_rvalue_dereference_field): Likewise.
(gcc_jit_rvalue_dereference): Likewise.
(gcc_jit_lvalue_get_address): Likewise.
(gcc_jit_function_new_local): Likewise.
(gcc_jit_block_add_eval): Likewise.
(gcc_jit_block_add_assignment): Likewise.
(gcc_jit_block_add_assignment_op): Likewise.
(gcc_jit_block_end_with_conditional): Likewise.
(gcc_jit_block_add_comment): Likewise.
(gcc_jit_block_end_with_jump): Likewise.
(gcc_jit_block_end_with_return): Likewise.
(gcc_jit_block_end_with_void_return): Likewise.
(gcc_jit_context_set_str_option): Likewise.
(gcc_jit_context_set_int_option): Likewise.
(gcc_jit_context_set_bool_option): Likewise.
(gcc_jit_context_enable_dump): Likewise.
(gcc_jit_context_compile): Likewise. Also log the context,
and the result.
(gcc_jit_context_dump_to_file): Likewise.
(gcc_jit_context_set_logfile): New function.
(gcc_jit_context_get_first_error): Use JIT_LOG_FUNC to
log entry/exit from the function body.
(gcc_jit_result_get_code): Likewise. Also log the fnname)
and the ptr to be returned.
(gcc_jit_result_release): Likewise. Also log the result.
* libgccjit.h: Include <stdio.h>, since we need FILE *.
(gcc_jit_context_set_logfile): New declaration.
* libgccjit.map (gcc_jit_context_set_logfile): New.
gcc/testsuite/ChangeLog:
* jit.dg/harness.h (set_up_logging): New function.
(test_jit): Fail if gcc_jit_context_acquire fails. Call
set_up_logging on the context, so that every testcase is
logged to a particular file.
* jit.dg/test-nested-contexts.c (main): Open a logfile,
and call gcc_jit_context_set_logfile on the top-level context.
From-SVN: r219357
-rw-r--r-- | gcc/jit/ChangeLog | 140 | ||||
-rw-r--r-- | gcc/jit/Make-lang.in | 1 | ||||
-rw-r--r-- | gcc/jit/docs/_build/texinfo/libgccjit.texi | 941 | ||||
-rw-r--r-- | gcc/jit/docs/internals/index.rst | 9 | ||||
-rw-r--r-- | gcc/jit/docs/internals/test-hello-world.exe.log.txt | 126 | ||||
-rw-r--r-- | gcc/jit/docs/topics/contexts.rst | 50 | ||||
-rw-r--r-- | gcc/jit/dummy-frontend.c | 7 | ||||
-rw-r--r-- | gcc/jit/jit-common.h | 1 | ||||
-rw-r--r-- | gcc/jit/jit-logging.c | 168 | ||||
-rw-r--r-- | gcc/jit/jit-logging.h | 191 | ||||
-rw-r--r-- | gcc/jit/jit-playback.c | 36 | ||||
-rw-r--r-- | gcc/jit/jit-playback.h | 2 | ||||
-rw-r--r-- | gcc/jit/jit-recording.c | 16 | ||||
-rw-r--r-- | gcc/jit/jit-recording.h | 3 | ||||
-rw-r--r-- | gcc/jit/jit-result.c | 13 | ||||
-rw-r--r-- | gcc/jit/jit-result.h | 4 | ||||
-rw-r--r-- | gcc/jit/libgccjit++.h | 15 | ||||
-rw-r--r-- | gcc/jit/libgccjit.c | 133 | ||||
-rw-r--r-- | gcc/jit/libgccjit.h | 15 | ||||
-rw-r--r-- | gcc/jit/libgccjit.map | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/jit.dg/harness.h | 54 | ||||
-rw-r--r-- | gcc/testsuite/jit.dg/test-nested-contexts.c | 10 |
23 files changed, 1544 insertions, 401 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 01b3882..670f6a2 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,143 @@ +2015-01-08 David Malcolm <dmalcolm@redhat.com> + + * Make-lang.in (jit_OBJS): Add jit/jit-logging.o. + * docs/internals/index.rst (Overview of code structure): Mention + gcc_jit_context_set_logfile, and embed the example logfile. + * docs/internals/test-hello-world.exe.log.txt: New file: example + of a logfile. + * docs/topics/contexts.rst (Debugging): Add documentation + for gcc_jit_context_set_logfile. + * docs/_build/texinfo/libgccjit.texi: Regenerate. + * dummy-frontend.c: Include "jit-logging.h". + (jit_langhook_init): Assert that there is an active playback + context. If it has a logger, log entry/exit to this function. + (jit_langhook_write_globals): Likewise. + * jit-common.h (gcc::jit::logger): New forward declaration. + * jit-logging.c: New file. + * jit-logging.h: New file. + * jit-playback.c: Include "jit-logging.h". + (gcc::jit::playback::context::context): Initialize the log_user + base class from the recording context's logger (if any). Use + JIT_LOG_SCOPE to log entry/exit from the function body. + (gcc::jit::playback::context::~context): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + (gcc::jit::playback::build_stmt_list): Likewise. + (gcc::jit::playback::function::postprocess): Likewise. + (gcc::jit::playback::context::compile): Likewise. Log the + entry/exit to toplev::main and toplev::finalize. Log the + fake argv passed to toplev::main. + (gcc::jit::playback::context::acquire_mutex): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + (gcc::jit::playback::context::release_mutex): Likewise. + (gcc::jit::playback::context::make_fake_args): Likewise. + (gcc::jit::playback::context::extract_any_requested_dumps): + Likewise. + (gcc::jit::playback::context::convert_to_dso): Likewise. Also, + log the arguments that the driver is invoked with. + (gcc::jit::playback::context::dlopen_built_dso): Likewise. Pass + the logger to the result object. + (gcc::jit::playback::context::replay): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + (gcc::jit::playback::context::dump_generated_code): Likewise. + (gcc::jit::playback::context::handle_locations): Likewise. + * jit-playback.h (gcc::jit::playback::context): Make this be + a subclass of gcc::jit::log_user. + * jit-recording.c: Include "jit-logging.h". + (gcc::jit::recording::context::context: Initialize the logger to + NULL for root contexts, or to the parent's logger for child + contexts. + (gcc::jit::recording::context::~context): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + (gcc::jit::recording::context::replay_into): Likewise. + (gcc::jit::recording::context::disassociate_from_playback): + Likewise. + (gcc::jit::recording::context::compile): Likewise. + (recording::context::add_error_va): Likewise. Also, log the + error. + (gcc::jit::recording::context::validate): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + * jit-recording.h: Include "jit-logging.h". + (gcc::jit::recording::context): Make this be a subclass of + gcc::jit::log_user. + * jit-result.c: Include "jit-common.h" and "jit-logging.h". + (gcc::jit::result::result): Add logger param, recording it. + Use JIT_LOG_SCOPE to log entry/exit from the function body. + (gcc::jit::result::~result(): Use JIT_LOG_SCOPE to + log entry/exit from the function body. + (gcc::jit::result::get_code): Likewise. + * jit-result.h (gcc::jit::result): Make this be a subclass of + gcc::jit::log_user. + (gcc::jit::result::result): Add logger parameter. + * libgccjit++.h (gccjit::context::set_logfile): New function. + * libgccjit.c: Include "jit-logging.h". + (gcc_jit_context_acquire): Log the context. + (gcc_jit_context_release): Use JIT_LOG_FUNC to + log entry/exit from the function body, and log the context. + (gcc_jit_context_new_child_context): Likewise, logging both + contexts. + (gcc_jit_context_new_location): Use JIT_LOG_FUNC to + log entry/exit from the function body. + (gcc_jit_context_get_type): Likewise. + (gcc_jit_context_get_int_type): Likewise. + (gcc_jit_context_new_array_type): Likewise. + (gcc_jit_context_new_field): Likewise. + (gcc_jit_context_new_struct_type): Likewise. + (gcc_jit_context_new_opaque_struct): Likewise. + (gcc_jit_struct_set_fields): Likewise. + (gcc_jit_context_new_union_type): Likewise. + (gcc_jit_context_new_function_ptr_type): Likewise. + (gcc_jit_context_new_param): Likewise. + (gcc_jit_context_new_function): Likewise. + (gcc_jit_context_get_builtin_function): Likewise. + (gcc_jit_function_get_param): Likewise. + (gcc_jit_function_dump_to_dot): Likewise. + (gcc_jit_function_new_block): Likewise. + (gcc_jit_context_new_global): Likewise. + (gcc_jit_context_new_rvalue_from_int): Likewise. + (gcc_jit_context_zero): Likewise. + (gcc_jit_context_one): Likewise. + (gcc_jit_context_new_rvalue_from_double): Likewise. + (gcc_jit_context_new_rvalue_from_ptr): Likewise. + (gcc_jit_context_null): Likewise. + (gcc_jit_context_new_string_literal): Likewise. + (gcc_jit_context_new_unary_op): Likewise. + (gcc_jit_context_new_binary_op): Likewise. + (gcc_jit_context_new_comparison): Likewise. + (gcc_jit_context_new_call): Likewise. + (gcc_jit_context_new_call_through_ptr): Likewise. + (gcc_jit_context_new_cast): Likewise. + (gcc_jit_context_new_array_access): Likewise. + (gcc_jit_lvalue_access_field): Likewise. + (gcc_jit_rvalue_access_field): Likewise. + (gcc_jit_rvalue_dereference_field): Likewise. + (gcc_jit_rvalue_dereference): Likewise. + (gcc_jit_lvalue_get_address): Likewise. + (gcc_jit_function_new_local): Likewise. + (gcc_jit_block_add_eval): Likewise. + (gcc_jit_block_add_assignment): Likewise. + (gcc_jit_block_add_assignment_op): Likewise. + (gcc_jit_block_end_with_conditional): Likewise. + (gcc_jit_block_add_comment): Likewise. + (gcc_jit_block_end_with_jump): Likewise. + (gcc_jit_block_end_with_return): Likewise. + (gcc_jit_block_end_with_void_return): Likewise. + (gcc_jit_context_set_str_option): Likewise. + (gcc_jit_context_set_int_option): Likewise. + (gcc_jit_context_set_bool_option): Likewise. + (gcc_jit_context_enable_dump): Likewise. + (gcc_jit_context_compile): Likewise. Also log the context, + and the result. + (gcc_jit_context_dump_to_file): Likewise. + (gcc_jit_context_set_logfile): New function. + (gcc_jit_context_get_first_error): Use JIT_LOG_FUNC to + log entry/exit from the function body. + (gcc_jit_result_get_code): Likewise. Also log the fnname) + and the ptr to be returned. + (gcc_jit_result_release): Likewise. Also log the result. + * libgccjit.h: Include <stdio.h>, since we need FILE *. + (gcc_jit_context_set_logfile): New declaration. + * libgccjit.map (gcc_jit_context_set_logfile): New. + 2015-01-07 David Malcolm <dmalcolm@redhat.com> * jit-recording.h (gcc::jit::recording::type::is_void): New diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index a0c2bac..551b115 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -62,6 +62,7 @@ jit: $(LIBGCCJIT_FILENAME) \ jit_OBJS = attribs.o \ jit/dummy-frontend.o \ jit/libgccjit.o \ + jit/jit-logging.o \ jit/jit-recording.o \ jit/jit-playback.o \ jit/jit-result.o \ diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index ba64b92..cc40fd7 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -19,7 +19,7 @@ @copying @quotation -libgccjit 5.0.0 (experimental 20150107), January 07, 2015 +libgccjit 5.0.0 (experimental 20150108), January 08, 2015 David Malcolm @@ -4199,8 +4199,67 @@ were a source file. This may be of use in conjunction with code in a debugger. @end deffn +@geindex gcc_jit_context_set_logfile (C function) +@anchor{topics/contexts gcc_jit_context_set_logfile}@anchor{53} +@deffn {C Function} void gcc_jit_context_set_logfile (gcc_jit_context@w{ }*ctxt, FILE@w{ }*logfile, int@w{ }flags, int@w{ }verbosity) + +To help with debugging; enable ongoing logging of the context's +activity to the given file. + +For example, the following will enable logging to stderr. + +@example +gcc_jit_context_set_logfile (ctxt, stderr, 0, 0); +@end example + +@noindent + +Examples of information logged include: + + +@itemize * + +@item +API calls + +@item +the various steps involved within compilation + +@item +activity on any @pxref{16,,gcc_jit_result} instances created by +the context + +@item +activity within any child contexts +@end itemize + +An example of a log can be seen @pxref{54,,here}, +though the precise format and kinds of information logged is subject +to change. + +The caller remains responsible for closing @cite{logfile}, and it must not +be closed until all users are released. In particular, note that +child contexts and @pxref{16,,gcc_jit_result} instances created by +the context will use the logfile. + +There may a performance cost for logging. + +You can turn off logging on @cite{ctxt} by passing @cite{NULL} for @cite{logfile}. +Doing so only affects the context; it does not affect child contexts +or @pxref{16,,gcc_jit_result} instances already created by +the context. + +The parameters "flags" and "verbosity" are reserved for future +expansion, and must be zero for now. +@end deffn + +To contrast the above: @pxref{52,,gcc_jit_context_dump_to_file()} dumps the +current state of a context to the given path, whereas +@pxref{53,,gcc_jit_context_set_logfile()} enables on-going logging of +future activies on a context to the given @cite{FILE *}. + @geindex gcc_jit_context_enable_dump (C function) -@anchor{topics/contexts gcc_jit_context_enable_dump}@anchor{53} +@anchor{topics/contexts gcc_jit_context_enable_dump}@anchor{55} @deffn {C Function} void gcc_jit_context_enable_dump (gcc_jit_context@w{ }*ctxt, const char@w{ }*dumpname, char@w{ }**out_ptr) Enable the dumping of a specific set of internal state from the @@ -4254,7 +4313,7 @@ It exists primarily for writing the library's own test suite. @end deffn @node Options<2>,,Debugging,Compilation contexts -@anchor{topics/contexts options}@anchor{54} +@anchor{topics/contexts options}@anchor{56} @subsection Options @@ -4266,25 +4325,25 @@ It exists primarily for writing the library's own test suite. @end menu @node String Options,Boolean options,,Options<2> -@anchor{topics/contexts string-options}@anchor{55} +@anchor{topics/contexts string-options}@anchor{57} @subsubsection String Options @geindex gcc_jit_context_set_str_option (C function) -@anchor{topics/contexts gcc_jit_context_set_str_option}@anchor{56} +@anchor{topics/contexts gcc_jit_context_set_str_option}@anchor{58} @deffn {C Function} void gcc_jit_context_set_str_option (gcc_jit_context@w{ }*ctxt, enum gcc_jit_str_option@w{ }opt, const char@w{ }*value) Set a string option of the context. @geindex gcc_jit_str_option (C type) -@anchor{topics/contexts gcc_jit_str_option}@anchor{57} +@anchor{topics/contexts gcc_jit_str_option}@anchor{59} @deffn {C Type} enum gcc_jit_str_option @end deffn There is currently just one string option: @geindex GCC_JIT_STR_OPTION_PROGNAME (C macro) -@anchor{topics/contexts GCC_JIT_STR_OPTION_PROGNAME}@anchor{58} +@anchor{topics/contexts GCC_JIT_STR_OPTION_PROGNAME}@anchor{5a} @deffn {C Macro} GCC_JIT_STR_OPTION_PROGNAME The name of the program, for use as a prefix when printing error @@ -4293,7 +4352,7 @@ messages to stderr. If @cite{NULL}, or default, "libgccjit.so" is used. @end deffn @node Boolean options,Integer options,String Options,Options<2> -@anchor{topics/contexts boolean-options}@anchor{59} +@anchor{topics/contexts boolean-options}@anchor{5b} @subsubsection Boolean options @@ -4305,7 +4364,7 @@ Set a boolean option of the context. Zero is "false" (the default), non-zero is "true". @geindex gcc_jit_bool_option (C type) -@anchor{topics/contexts gcc_jit_bool_option}@anchor{5a} +@anchor{topics/contexts gcc_jit_bool_option}@anchor{5c} @deffn {C Type} enum gcc_jit_bool_option @end deffn @@ -4323,7 +4382,7 @@ location information for the code (by creating and passing in @end deffn @geindex GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE (C macro) -@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE}@anchor{5b} +@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE}@anchor{5d} @deffn {C Macro} GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE If true, @pxref{15,,gcc_jit_context_compile()} will dump its initial @@ -4420,7 +4479,7 @@ square: @end deffn @geindex GCC_JIT_BOOL_OPTION_DUMP_SUMMARY (C macro) -@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_SUMMARY}@anchor{5c} +@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_SUMMARY}@anchor{5e} @deffn {C Macro} GCC_JIT_BOOL_OPTION_DUMP_SUMMARY If true, @pxref{15,,gcc_jit_context_compile()} will print information to stderr @@ -4429,19 +4488,19 @@ the time taken and memory usage of each phase. @end deffn @geindex GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING (C macro) -@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING}@anchor{5d} +@anchor{topics/contexts GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING}@anchor{5f} @deffn {C Macro} GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING If true, @pxref{15,,gcc_jit_context_compile()} will dump copious amount of information on what it's doing to various files within a temporary directory. Use -@pxref{5e,,GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES} (see below) to +@pxref{60,,GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES} (see below) to see the results. The files are intended to be human-readable, but the exact files and their formats are subject to change. @end deffn @geindex GCC_JIT_BOOL_OPTION_SELFCHECK_GC (C macro) -@anchor{topics/contexts GCC_JIT_BOOL_OPTION_SELFCHECK_GC}@anchor{5f} +@anchor{topics/contexts GCC_JIT_BOOL_OPTION_SELFCHECK_GC}@anchor{61} @deffn {C Macro} GCC_JIT_BOOL_OPTION_SELFCHECK_GC If true, libgccjit will aggressively run its garbage collector, to @@ -4451,7 +4510,7 @@ used when running the selftest suite. @end deffn @geindex GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES (C macro) -@anchor{topics/contexts GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES}@anchor{5e} +@anchor{topics/contexts GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES}@anchor{60} @deffn {C Macro} GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES If true, the @pxref{8,,gcc_jit_context} will not clean up intermediate files @@ -4460,7 +4519,7 @@ written to the filesystem, and will display their location on stderr. @end deffn @node Integer options,,Boolean options,Options<2> -@anchor{topics/contexts integer-options}@anchor{60} +@anchor{topics/contexts integer-options}@anchor{62} @subsubsection Integer options @@ -4471,7 +4530,7 @@ written to the filesystem, and will display their location on stderr. Set an integer option of the context. @geindex gcc_jit_int_option (C type) -@anchor{topics/contexts gcc_jit_int_option}@anchor{61} +@anchor{topics/contexts gcc_jit_int_option}@anchor{63} @deffn {C Type} enum gcc_jit_int_option @end deffn @@ -4508,7 +4567,7 @@ The default value is 0 (unoptimized). @c <http://www.gnu.org/licenses/>. @node Objects,Types,Compilation contexts,Topic Reference -@anchor{topics/objects objects}@anchor{62}@anchor{topics/objects doc}@anchor{63} +@anchor{topics/objects objects}@anchor{64}@anchor{topics/objects doc}@anchor{65} @section Objects @@ -4568,7 +4627,7 @@ gcc_jit_object *obj = gcc_jit_type_as_object (int_type); The object "base class" has the following operations: @geindex gcc_jit_object_get_context (C function) -@anchor{topics/objects gcc_jit_object_get_context}@anchor{64} +@anchor{topics/objects gcc_jit_object_get_context}@anchor{66} @deffn {C Function} gcc_jit_context *gcc_jit_object_get_context (gcc_jit_object@w{ }*obj) Which context is "obj" within? @@ -4624,7 +4683,7 @@ object's context is released. @c <http://www.gnu.org/licenses/>. @node Types,Expressions,Objects,Topic Reference -@anchor{topics/types doc}@anchor{65}@anchor{topics/types types}@anchor{66} +@anchor{topics/types doc}@anchor{67}@anchor{topics/types types}@anchor{68} @section Types @@ -4661,7 +4720,7 @@ See @pxref{b,,gcc_jit_context_get_type()} for the available types. @item derived types can be accessed by using functions such as -@pxref{67,,gcc_jit_type_get_pointer()} and @pxref{68,,gcc_jit_type_get_const()}: +@pxref{69,,gcc_jit_type_get_pointer()} and @pxref{6a,,gcc_jit_type_get_const()}: @example gcc_jit_type *const_int_star = gcc_jit_type_get_pointer (gcc_jit_type_get_const (int_type)); @@ -4682,7 +4741,7 @@ by creating structures (see below). @end menu @node Standard types,Pointers const and volatile,,Types -@anchor{topics/types standard-types}@anchor{69} +@anchor{topics/types standard-types}@anchor{6b} @subsection Standard types @@ -4887,66 +4946,66 @@ C99's @code{_Complex long double} @end deffn @geindex gcc_jit_context_get_int_type (C function) -@anchor{topics/types gcc_jit_context_get_int_type}@anchor{6a} +@anchor{topics/types gcc_jit_context_get_int_type}@anchor{6c} @deffn {C Function} gcc_jit_type * gcc_jit_context_get_int_type (gcc_jit_context@w{ }*ctxt, int@w{ }num_bytes, int@w{ }is_signed) Access the integer type of the given size. @end deffn @node Pointers const and volatile,Structures and unions,Standard types,Types -@anchor{topics/types pointers-const-and-volatile}@anchor{6b} +@anchor{topics/types pointers-const-and-volatile}@anchor{6d} @subsection Pointers, @cite{const}, and @cite{volatile} @geindex gcc_jit_type_get_pointer (C function) -@anchor{topics/types gcc_jit_type_get_pointer}@anchor{67} +@anchor{topics/types gcc_jit_type_get_pointer}@anchor{69} @deffn {C Function} gcc_jit_type *gcc_jit_type_get_pointer (gcc_jit_type@w{ }*type) Given type "T", get type "T*". @end deffn @geindex gcc_jit_type_get_const (C function) -@anchor{topics/types gcc_jit_type_get_const}@anchor{68} +@anchor{topics/types gcc_jit_type_get_const}@anchor{6a} @deffn {C Function} gcc_jit_type *gcc_jit_type_get_const (gcc_jit_type@w{ }*type) Given type "T", get type "const T". @end deffn @geindex gcc_jit_type_get_volatile (C function) -@anchor{topics/types gcc_jit_type_get_volatile}@anchor{6c} +@anchor{topics/types gcc_jit_type_get_volatile}@anchor{6e} @deffn {C Function} gcc_jit_type *gcc_jit_type_get_volatile (gcc_jit_type@w{ }*type) Given type "T", get type "volatile T". @end deffn @geindex gcc_jit_context_new_array_type (C function) -@anchor{topics/types gcc_jit_context_new_array_type}@anchor{6d} +@anchor{topics/types gcc_jit_context_new_array_type}@anchor{6f} @deffn {C Function} gcc_jit_type * gcc_jit_context_new_array_type (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_type@w{ }*element_type, int@w{ }num_elements) Given type "T", get type "T[N]" (for a constant N). @end deffn @node Structures and unions,,Pointers const and volatile,Types -@anchor{topics/types structures-and-unions}@anchor{6e} +@anchor{topics/types structures-and-unions}@anchor{70} @subsection Structures and unions @geindex gcc_jit_struct (C type) -@anchor{topics/types gcc_jit_struct}@anchor{6f} +@anchor{topics/types gcc_jit_struct}@anchor{71} @deffn {C Type} gcc_jit_struct @end deffn A compound type analagous to a C @cite{struct}. @geindex gcc_jit_field (C type) -@anchor{topics/types gcc_jit_field}@anchor{70} +@anchor{topics/types gcc_jit_field}@anchor{72} @deffn {C Type} gcc_jit_field @end deffn -A field within a @pxref{6f,,gcc_jit_struct}. +A field within a @pxref{71,,gcc_jit_struct}. -You can model C @cite{struct} types by creating @pxref{6f,,gcc_jit_struct *} and -@pxref{70,,gcc_jit_field} instances, in either order: +You can model C @cite{struct} types by creating @pxref{71,,gcc_jit_struct *} and +@pxref{72,,gcc_jit_field} instances, in either order: @itemize * @@ -5003,21 +5062,21 @@ gcc_jit_struct_set_fields (node, NULL, 2, fields); @end itemize @geindex gcc_jit_context_new_field (C function) -@anchor{topics/types gcc_jit_context_new_field}@anchor{71} +@anchor{topics/types gcc_jit_context_new_field}@anchor{73} @deffn {C Function} gcc_jit_field * gcc_jit_context_new_field (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_type@w{ }*type, const char@w{ }*name) Construct a new field, with the given type and name. @end deffn @geindex gcc_jit_field_as_object (C function) -@anchor{topics/types gcc_jit_field_as_object}@anchor{72} +@anchor{topics/types gcc_jit_field_as_object}@anchor{74} @deffn {C Function} gcc_jit_object * gcc_jit_field_as_object (gcc_jit_field@w{ }*field) Upcast from field to object. @end deffn @geindex gcc_jit_context_new_struct_type (C function) -@anchor{topics/types gcc_jit_context_new_struct_type}@anchor{73} +@anchor{topics/types gcc_jit_context_new_struct_type}@anchor{75} @deffn {C Function} gcc_jit_struct *gcc_jit_context_new_struct_type (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, const char@w{ }*name, int@w{ }num_fields, gcc_jit_field@w{ }**fields) @quotation @@ -5027,24 +5086,24 @@ Construct a new struct type, with the given name and fields. @end deffn @geindex gcc_jit_context_new_opaque_struct (C function) -@anchor{topics/types gcc_jit_context_new_opaque_struct}@anchor{74} +@anchor{topics/types gcc_jit_context_new_opaque_struct}@anchor{76} @deffn {C Function} gcc_jit_struct * gcc_jit_context_new_opaque_struct (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, const char@w{ }*name) Construct a new struct type, with the given name, but without specifying the fields. The fields can be omitted (in which case the size of the struct is not known), or later specified using -@pxref{75,,gcc_jit_struct_set_fields()}. +@pxref{77,,gcc_jit_struct_set_fields()}. @end deffn @geindex gcc_jit_struct_as_type (C function) -@anchor{topics/types gcc_jit_struct_as_type}@anchor{76} +@anchor{topics/types gcc_jit_struct_as_type}@anchor{78} @deffn {C Function} gcc_jit_type * gcc_jit_struct_as_type (gcc_jit_struct@w{ }*struct_type) Upcast from struct to type. @end deffn @geindex gcc_jit_struct_set_fields (C function) -@anchor{topics/types gcc_jit_struct_set_fields}@anchor{75} +@anchor{topics/types gcc_jit_struct_set_fields}@anchor{77} @deffn {C Function} void gcc_jit_struct_set_fields (gcc_jit_struct@w{ }*struct_type, gcc_jit_location@w{ }*loc, int@w{ }num_fields, gcc_jit_field@w{ }**fields) Populate the fields of a formerly-opaque struct type. @@ -5070,7 +5129,7 @@ This can only be called once on a given struct type. @c <http://www.gnu.org/licenses/>. @node Expressions,Creating and using functions,Types,Topic Reference -@anchor{topics/expressions expressions}@anchor{77}@anchor{topics/expressions doc}@anchor{78} +@anchor{topics/expressions expressions}@anchor{79}@anchor{topics/expressions doc}@anchor{7a} @section Expressions @@ -5096,7 +5155,7 @@ Lvalues @node Rvalues,Lvalues,,Expressions -@anchor{topics/expressions rvalues}@anchor{79} +@anchor{topics/expressions rvalues}@anchor{7b} @subsection Rvalues @@ -5150,7 +5209,7 @@ Every rvalue has an associated type, and the API will check to ensure that types match up correctly (otherwise the context will emit an error). @geindex gcc_jit_rvalue_get_type (C function) -@anchor{topics/expressions gcc_jit_rvalue_get_type}@anchor{7a} +@anchor{topics/expressions gcc_jit_rvalue_get_type}@anchor{7c} @deffn {C Function} gcc_jit_type *gcc_jit_rvalue_get_type (gcc_jit_rvalue@w{ }*rvalue) Get the type of this rvalue. @@ -5174,7 +5233,7 @@ Upcast the given rvalue to be an object. @end menu @node Simple expressions,Unary Operations,,Rvalues -@anchor{topics/expressions simple-expressions}@anchor{7b} +@anchor{topics/expressions simple-expressions}@anchor{7d} @subsubsection Simple expressions @@ -5223,14 +5282,14 @@ the given constant value. @end deffn @geindex gcc_jit_context_new_rvalue_from_ptr (C function) -@anchor{topics/expressions gcc_jit_context_new_rvalue_from_ptr}@anchor{7c} +@anchor{topics/expressions gcc_jit_context_new_rvalue_from_ptr}@anchor{7e} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*pointer_type, void@w{ }*value) Given a pointer type, build an rvalue for the given address. @end deffn @geindex gcc_jit_context_null (C function) -@anchor{topics/expressions gcc_jit_context_null}@anchor{7d} +@anchor{topics/expressions gcc_jit_context_null}@anchor{7f} @deffn {C Function} gcc_jit_rvalue *gcc_jit_context_null (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*pointer_type) Given a pointer type, build an rvalue for @code{NULL}. Essentially this @@ -5244,7 +5303,7 @@ gcc_jit_context_new_rvalue_from_ptr (ctxt, pointer_type, NULL) @end deffn @geindex gcc_jit_context_new_string_literal (C function) -@anchor{topics/expressions gcc_jit_context_new_string_literal}@anchor{7e} +@anchor{topics/expressions gcc_jit_context_new_string_literal}@anchor{80} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_string_literal (gcc_jit_context@w{ }*ctxt, const char@w{ }*value) Generate an rvalue for the given NIL-terminated string, of type @@ -5252,19 +5311,19 @@ Generate an rvalue for the given NIL-terminated string, of type @end deffn @node Unary Operations,Binary Operations,Simple expressions,Rvalues -@anchor{topics/expressions unary-operations}@anchor{7f} +@anchor{topics/expressions unary-operations}@anchor{81} @subsubsection Unary Operations @geindex gcc_jit_context_new_unary_op (C function) -@anchor{topics/expressions gcc_jit_context_new_unary_op}@anchor{80} +@anchor{topics/expressions gcc_jit_context_new_unary_op}@anchor{82} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_unary_op (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, enum gcc_jit_unary_op@w{ }op, gcc_jit_type@w{ }*result_type, gcc_jit_rvalue@w{ }*rvalue) Build a unary operation out of an input rvalue. @end deffn @geindex gcc_jit_unary_op (C type) -@anchor{topics/expressions gcc_jit_unary_op}@anchor{81} +@anchor{topics/expressions gcc_jit_unary_op}@anchor{83} @deffn {C Type} enum gcc_jit_unary_op @end deffn @@ -5282,7 +5341,7 @@ C equivalent @item -@pxref{82,,GCC_JIT_UNARY_OP_MINUS} +@pxref{84,,GCC_JIT_UNARY_OP_MINUS} @tab @@ -5290,7 +5349,7 @@ C equivalent @item -@pxref{83,,GCC_JIT_UNARY_OP_BITWISE_NEGATE} +@pxref{85,,GCC_JIT_UNARY_OP_BITWISE_NEGATE} @tab @@ -5298,7 +5357,7 @@ C equivalent @item -@pxref{84,,GCC_JIT_UNARY_OP_LOGICAL_NEGATE} +@pxref{86,,GCC_JIT_UNARY_OP_LOGICAL_NEGATE} @tab @@ -5306,7 +5365,7 @@ C equivalent @item -@pxref{85,,GCC_JIT_UNARY_OP_ABS} +@pxref{87,,GCC_JIT_UNARY_OP_ABS} @tab @@ -5316,7 +5375,7 @@ C equivalent @geindex GCC_JIT_UNARY_OP_MINUS (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_MINUS}@anchor{82} +@anchor{topics/expressions GCC_JIT_UNARY_OP_MINUS}@anchor{84} @deffn {C Macro} GCC_JIT_UNARY_OP_MINUS Negate an arithmetic value; analogous to: @@ -5331,7 +5390,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_BITWISE_NEGATE (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_BITWISE_NEGATE}@anchor{83} +@anchor{topics/expressions GCC_JIT_UNARY_OP_BITWISE_NEGATE}@anchor{85} @deffn {C Macro} GCC_JIT_UNARY_OP_BITWISE_NEGATE Bitwise negation of an integer value (one's complement); analogous @@ -5347,7 +5406,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_LOGICAL_NEGATE (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_LOGICAL_NEGATE}@anchor{84} +@anchor{topics/expressions GCC_JIT_UNARY_OP_LOGICAL_NEGATE}@anchor{86} @deffn {C Macro} GCC_JIT_UNARY_OP_LOGICAL_NEGATE Logical negation of an arithmetic or pointer value; analogous to: @@ -5362,7 +5421,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_ABS (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_ABS}@anchor{85} +@anchor{topics/expressions GCC_JIT_UNARY_OP_ABS}@anchor{87} @deffn {C Macro} GCC_JIT_UNARY_OP_ABS Absolute value of an arithmetic expression; analogous to: @@ -5377,7 +5436,7 @@ in C. @end deffn @node Binary Operations,Comparisons,Unary Operations,Rvalues -@anchor{topics/expressions binary-operations}@anchor{86} +@anchor{topics/expressions binary-operations}@anchor{88} @subsubsection Binary Operations @@ -5389,7 +5448,7 @@ Build a binary operation out of two constituent rvalues. @end deffn @geindex gcc_jit_binary_op (C type) -@anchor{topics/expressions gcc_jit_binary_op}@anchor{87} +@anchor{topics/expressions gcc_jit_binary_op}@anchor{89} @deffn {C Type} enum gcc_jit_binary_op @end deffn @@ -5407,7 +5466,7 @@ C equivalent @item -@pxref{88,,GCC_JIT_BINARY_OP_PLUS} +@pxref{8a,,GCC_JIT_BINARY_OP_PLUS} @tab @@ -5423,7 +5482,7 @@ C equivalent @item -@pxref{89,,GCC_JIT_BINARY_OP_MULT} +@pxref{8b,,GCC_JIT_BINARY_OP_MULT} @tab @@ -5431,7 +5490,7 @@ C equivalent @item -@pxref{8a,,GCC_JIT_BINARY_OP_DIVIDE} +@pxref{8c,,GCC_JIT_BINARY_OP_DIVIDE} @tab @@ -5439,7 +5498,7 @@ C equivalent @item -@pxref{8b,,GCC_JIT_BINARY_OP_MODULO} +@pxref{8d,,GCC_JIT_BINARY_OP_MODULO} @tab @@ -5447,7 +5506,7 @@ C equivalent @item -@pxref{8c,,GCC_JIT_BINARY_OP_BITWISE_AND} +@pxref{8e,,GCC_JIT_BINARY_OP_BITWISE_AND} @tab @@ -5455,7 +5514,7 @@ C equivalent @item -@pxref{8d,,GCC_JIT_BINARY_OP_BITWISE_XOR} +@pxref{8f,,GCC_JIT_BINARY_OP_BITWISE_XOR} @tab @@ -5463,7 +5522,7 @@ C equivalent @item -@pxref{8e,,GCC_JIT_BINARY_OP_BITWISE_OR} +@pxref{90,,GCC_JIT_BINARY_OP_BITWISE_OR} @tab @@ -5471,7 +5530,7 @@ C equivalent @item -@pxref{8f,,GCC_JIT_BINARY_OP_LOGICAL_AND} +@pxref{91,,GCC_JIT_BINARY_OP_LOGICAL_AND} @tab @@ -5479,7 +5538,7 @@ C equivalent @item -@pxref{90,,GCC_JIT_BINARY_OP_LOGICAL_OR} +@pxref{92,,GCC_JIT_BINARY_OP_LOGICAL_OR} @tab @@ -5487,7 +5546,7 @@ C equivalent @item -@pxref{91,,GCC_JIT_BINARY_OP_LSHIFT} +@pxref{93,,GCC_JIT_BINARY_OP_LSHIFT} @tab @@ -5495,7 +5554,7 @@ C equivalent @item -@pxref{92,,GCC_JIT_BINARY_OP_RSHIFT} +@pxref{94,,GCC_JIT_BINARY_OP_RSHIFT} @tab @@ -5505,7 +5564,7 @@ C equivalent @geindex GCC_JIT_BINARY_OP_PLUS (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_PLUS}@anchor{88} +@anchor{topics/expressions GCC_JIT_BINARY_OP_PLUS}@anchor{8a} @deffn {C Macro} GCC_JIT_BINARY_OP_PLUS Addition of arithmetic values; analogous to: @@ -5518,7 +5577,7 @@ Addition of arithmetic values; analogous to: in C. -For pointer addition, use @pxref{93,,gcc_jit_context_new_array_access()}. +For pointer addition, use @pxref{95,,gcc_jit_context_new_array_access()}. @end deffn @@ -5536,7 +5595,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_MULT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_MULT}@anchor{89} +@anchor{topics/expressions GCC_JIT_BINARY_OP_MULT}@anchor{8b} @deffn {C Macro} GCC_JIT_BINARY_OP_MULT Multiplication of a pair of arithmetic values; analogous to: @@ -5551,7 +5610,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_DIVIDE (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_DIVIDE}@anchor{8a} +@anchor{topics/expressions GCC_JIT_BINARY_OP_DIVIDE}@anchor{8c} @deffn {C Macro} GCC_JIT_BINARY_OP_DIVIDE Quotient of division of arithmetic values; analogous to: @@ -5570,7 +5629,7 @@ a floating-point result type indicates floating-point division. @end deffn @geindex GCC_JIT_BINARY_OP_MODULO (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_MODULO}@anchor{8b} +@anchor{topics/expressions GCC_JIT_BINARY_OP_MODULO}@anchor{8d} @deffn {C Macro} GCC_JIT_BINARY_OP_MODULO Remainder of division of arithmetic values; analogous to: @@ -5585,7 +5644,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_AND (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_AND}@anchor{8c} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_AND}@anchor{8e} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_AND Bitwise AND; analogous to: @@ -5600,7 +5659,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_XOR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_XOR}@anchor{8d} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_XOR}@anchor{8f} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_XOR Bitwise exclusive OR; analogous to: @@ -5615,7 +5674,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_OR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_OR}@anchor{8e} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_OR}@anchor{90} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_OR Bitwise inclusive OR; analogous to: @@ -5630,7 +5689,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LOGICAL_AND (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_AND}@anchor{8f} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_AND}@anchor{91} @deffn {C Macro} GCC_JIT_BINARY_OP_LOGICAL_AND Logical AND; analogous to: @@ -5645,7 +5704,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LOGICAL_OR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_OR}@anchor{90} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_OR}@anchor{92} @deffn {C Macro} GCC_JIT_BINARY_OP_LOGICAL_OR Logical OR; analogous to: @@ -5660,7 +5719,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LSHIFT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LSHIFT}@anchor{91} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LSHIFT}@anchor{93} @deffn {C Macro} GCC_JIT_BINARY_OP_LSHIFT Left shift; analogous to: @@ -5675,7 +5734,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_RSHIFT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_RSHIFT}@anchor{92} +@anchor{topics/expressions GCC_JIT_BINARY_OP_RSHIFT}@anchor{94} @deffn {C Macro} GCC_JIT_BINARY_OP_RSHIFT Right shift; analogous to: @@ -5690,7 +5749,7 @@ in C. @end deffn @node Comparisons,Function calls,Binary Operations,Rvalues -@anchor{topics/expressions comparisons}@anchor{94} +@anchor{topics/expressions comparisons}@anchor{96} @subsubsection Comparisons @@ -5702,7 +5761,7 @@ Build a boolean rvalue out of the comparison of two other rvalues. @end deffn @geindex gcc_jit_comparison (C type) -@anchor{topics/expressions gcc_jit_comparison}@anchor{95} +@anchor{topics/expressions gcc_jit_comparison}@anchor{97} @deffn {C Type} enum gcc_jit_comparison @end deffn @@ -5768,12 +5827,12 @@ C equivalent @node Function calls,Type-coercion,Comparisons,Rvalues -@anchor{topics/expressions function-calls}@anchor{96} +@anchor{topics/expressions function-calls}@anchor{98} @subsubsection Function calls @geindex gcc_jit_context_new_call (C function) -@anchor{topics/expressions gcc_jit_context_new_call}@anchor{97} +@anchor{topics/expressions gcc_jit_context_new_call}@anchor{99} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_call (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_function@w{ }*func, int@w{ }numargs, gcc_jit_rvalue@w{ }**args) Given a function and the given table of argument rvalues, construct a @@ -5781,7 +5840,7 @@ call to the function, with the result as an rvalue. @cartouche @quotation Note -@pxref{97,,gcc_jit_context_new_call()} merely builds a +@pxref{99,,gcc_jit_context_new_call()} merely builds a @pxref{13,,gcc_jit_rvalue} i.e. an expression that can be evaluated, perhaps as part of a more complicated expression. The call @emph{won't} happen unless you add a statement to a function @@ -5789,7 +5848,7 @@ that evaluates the expression. For example, if you want to call a function and discard the result (or to call a function with @code{void} return type), use -@pxref{98,,gcc_jit_block_add_eval()}: +@pxref{9a,,gcc_jit_block_add_eval()}: @example /* Add "(void)printf (arg0, arg1);". */ @@ -5808,12 +5867,12 @@ gcc_jit_block_add_eval ( @end deffn @node Type-coercion,,Function calls,Rvalues -@anchor{topics/expressions type-coercion}@anchor{99} +@anchor{topics/expressions type-coercion}@anchor{9b} @subsubsection Type-coercion @geindex gcc_jit_context_new_cast (C function) -@anchor{topics/expressions gcc_jit_context_new_cast}@anchor{9a} +@anchor{topics/expressions gcc_jit_context_new_cast}@anchor{9c} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_cast (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue, gcc_jit_type@w{ }*type) Given an rvalue of T, construct another rvalue of another type. @@ -5838,7 +5897,7 @@ P* <-> Q*, for pointer types P and Q @end deffn @node Lvalues,Working with pointers structs and unions,Rvalues,Expressions -@anchor{topics/expressions lvalues}@anchor{9b} +@anchor{topics/expressions lvalues}@anchor{9d} @subsection Lvalues @@ -5852,21 +5911,21 @@ a storage area (such as a variable). It is also usable as an rvalue, where the rvalue is computed by reading from the storage area. @geindex gcc_jit_lvalue_as_object (C function) -@anchor{topics/expressions gcc_jit_lvalue_as_object}@anchor{9c} +@anchor{topics/expressions gcc_jit_lvalue_as_object}@anchor{9e} @deffn {C Function} gcc_jit_object * gcc_jit_lvalue_as_object (gcc_jit_lvalue@w{ }*lvalue) Upcast an lvalue to be an object. @end deffn @geindex gcc_jit_lvalue_as_rvalue (C function) -@anchor{topics/expressions gcc_jit_lvalue_as_rvalue}@anchor{9d} +@anchor{topics/expressions gcc_jit_lvalue_as_rvalue}@anchor{9f} @deffn {C Function} gcc_jit_rvalue * gcc_jit_lvalue_as_rvalue (gcc_jit_lvalue@w{ }*lvalue) Upcast an lvalue to be an rvalue. @end deffn @geindex gcc_jit_lvalue_get_address (C function) -@anchor{topics/expressions gcc_jit_lvalue_get_address}@anchor{9e} +@anchor{topics/expressions gcc_jit_lvalue_get_address}@anchor{a0} @deffn {C Function} gcc_jit_rvalue * gcc_jit_lvalue_get_address (gcc_jit_lvalue@w{ }*lvalue, gcc_jit_location@w{ }*loc) Take the address of an lvalue; analogous to: @@ -5886,24 +5945,24 @@ in C. @end menu @node Global variables,,,Lvalues -@anchor{topics/expressions global-variables}@anchor{9f} +@anchor{topics/expressions global-variables}@anchor{a1} @subsubsection Global variables @geindex gcc_jit_context_new_global (C function) -@anchor{topics/expressions gcc_jit_context_new_global}@anchor{a0} +@anchor{topics/expressions gcc_jit_context_new_global}@anchor{a2} @deffn {C Function} gcc_jit_lvalue * gcc_jit_context_new_global (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_type@w{ }*type, const char@w{ }*name) Add a new global variable of the given type and name to the context. @end deffn @node Working with pointers structs and unions,,Lvalues,Expressions -@anchor{topics/expressions working-with-pointers-structs-and-unions}@anchor{a1} +@anchor{topics/expressions working-with-pointers-structs-and-unions}@anchor{a3} @subsection Working with pointers, structs and unions @geindex gcc_jit_rvalue_dereference (C function) -@anchor{topics/expressions gcc_jit_rvalue_dereference}@anchor{a2} +@anchor{topics/expressions gcc_jit_rvalue_dereference}@anchor{a4} @deffn {C Function} gcc_jit_lvalue * gcc_jit_rvalue_dereference (gcc_jit_rvalue@w{ }*rvalue, gcc_jit_location@w{ }*loc) Given an rvalue of pointer type @code{T *}, dereferencing the pointer, @@ -5921,7 +5980,7 @@ in C. Field access is provided separately for both lvalues and rvalues. @geindex gcc_jit_lvalue_access_field (C function) -@anchor{topics/expressions gcc_jit_lvalue_access_field}@anchor{a3} +@anchor{topics/expressions gcc_jit_lvalue_access_field}@anchor{a5} @deffn {C Function} gcc_jit_lvalue * gcc_jit_lvalue_access_field (gcc_jit_lvalue@w{ }*struct_, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an lvalue of struct or union type, access the given field, @@ -5937,7 +5996,7 @@ in C. @end deffn @geindex gcc_jit_rvalue_access_field (C function) -@anchor{topics/expressions gcc_jit_rvalue_access_field}@anchor{a4} +@anchor{topics/expressions gcc_jit_rvalue_access_field}@anchor{a6} @deffn {C Function} gcc_jit_rvalue * gcc_jit_rvalue_access_field (gcc_jit_rvalue@w{ }*struct_, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an rvalue of struct or union type, access the given field @@ -5953,7 +6012,7 @@ in C. @end deffn @geindex gcc_jit_rvalue_dereference_field (C function) -@anchor{topics/expressions gcc_jit_rvalue_dereference_field}@anchor{a5} +@anchor{topics/expressions gcc_jit_rvalue_dereference_field}@anchor{a7} @deffn {C Function} gcc_jit_lvalue * gcc_jit_rvalue_dereference_field (gcc_jit_rvalue@w{ }*ptr, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an rvalue of pointer type @code{T *} where T is of struct or union @@ -5969,7 +6028,7 @@ in C, itself equivalent to @code{(*EXPR).FIELD}. @end deffn @geindex gcc_jit_context_new_array_access (C function) -@anchor{topics/expressions gcc_jit_context_new_array_access}@anchor{93} +@anchor{topics/expressions gcc_jit_context_new_array_access}@anchor{95} @deffn {C Function} gcc_jit_lvalue * gcc_jit_context_new_array_access (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*ptr, gcc_jit_rvalue@w{ }*index) Given an rvalue of pointer type @code{T *}, get at the element @cite{T} at @@ -6004,7 +6063,7 @@ in C (or, indeed, to @code{PTR + INDEX}). @c <http://www.gnu.org/licenses/>. @node Creating and using functions,Source Locations,Expressions,Topic Reference -@anchor{topics/functions doc}@anchor{a6}@anchor{topics/functions creating-and-using-functions}@anchor{a7} +@anchor{topics/functions doc}@anchor{a8}@anchor{topics/functions creating-and-using-functions}@anchor{a9} @section Creating and using functions @@ -6017,7 +6076,7 @@ in C (or, indeed, to @code{PTR + INDEX}). @end menu @node Params,Functions,,Creating and using functions -@anchor{topics/functions params}@anchor{a8} +@anchor{topics/functions params}@anchor{aa} @subsection Params @@ -6040,28 +6099,28 @@ Parameters are lvalues, and thus are also rvalues (and objects), so the following upcasts are available: @geindex gcc_jit_param_as_lvalue (C function) -@anchor{topics/functions gcc_jit_param_as_lvalue}@anchor{a9} +@anchor{topics/functions gcc_jit_param_as_lvalue}@anchor{ab} @deffn {C Function} gcc_jit_lvalue * gcc_jit_param_as_lvalue (gcc_jit_param@w{ }*param) Upcasting from param to lvalue. @end deffn @geindex gcc_jit_param_as_rvalue (C function) -@anchor{topics/functions gcc_jit_param_as_rvalue}@anchor{aa} +@anchor{topics/functions gcc_jit_param_as_rvalue}@anchor{ac} @deffn {C Function} gcc_jit_rvalue * gcc_jit_param_as_rvalue (gcc_jit_param@w{ }*param) Upcasting from param to rvalue. @end deffn @geindex gcc_jit_param_as_object (C function) -@anchor{topics/functions gcc_jit_param_as_object}@anchor{ab} +@anchor{topics/functions gcc_jit_param_as_object}@anchor{ad} @deffn {C Function} gcc_jit_object * gcc_jit_param_as_object (gcc_jit_param@w{ }*param) Upcasting from param to object. @end deffn @node Functions,Blocks,Params,Creating and using functions -@anchor{topics/functions functions}@anchor{ac} +@anchor{topics/functions functions}@anchor{ae} @subsection Functions @@ -6080,7 +6139,7 @@ creating ourselves, or one that we're referencing. Create a gcc_jit_function with the given name and parameters. @geindex gcc_jit_function_kind (C type) -@anchor{topics/functions gcc_jit_function_kind}@anchor{ad} +@anchor{topics/functions gcc_jit_function_kind}@anchor{af} @deffn {C Type} enum gcc_jit_function_kind @end deffn @@ -6090,7 +6149,7 @@ values: @quotation @geindex GCC_JIT_FUNCTION_EXPORTED (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_EXPORTED}@anchor{ae} +@anchor{topics/functions GCC_JIT_FUNCTION_EXPORTED}@anchor{b0} @deffn {C Macro} GCC_JIT_FUNCTION_EXPORTED Function is defined by the client code and visible @@ -6102,7 +6161,7 @@ for this function from a @pxref{16,,gcc_jit_result} via @end deffn @geindex GCC_JIT_FUNCTION_INTERNAL (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_INTERNAL}@anchor{af} +@anchor{topics/functions GCC_JIT_FUNCTION_INTERNAL}@anchor{b1} @deffn {C Macro} GCC_JIT_FUNCTION_INTERNAL Function is defined by the client code, but is invisible @@ -6110,7 +6169,7 @@ outside of the JIT. Analogous to a "static" function. @end deffn @geindex GCC_JIT_FUNCTION_IMPORTED (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_IMPORTED}@anchor{b0} +@anchor{topics/functions GCC_JIT_FUNCTION_IMPORTED}@anchor{b2} @deffn {C Macro} GCC_JIT_FUNCTION_IMPORTED Function is not defined by the client code; we're merely @@ -6119,7 +6178,7 @@ header file. @end deffn @geindex GCC_JIT_FUNCTION_ALWAYS_INLINE (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_ALWAYS_INLINE}@anchor{b1} +@anchor{topics/functions GCC_JIT_FUNCTION_ALWAYS_INLINE}@anchor{b3} @deffn {C Macro} GCC_JIT_FUNCTION_ALWAYS_INLINE Function is only ever inlined into other functions, and is @@ -6136,19 +6195,19 @@ same as GCC_JIT_FUNCTION_INTERNAL. @end deffn @geindex gcc_jit_context_get_builtin_function (C function) -@anchor{topics/functions gcc_jit_context_get_builtin_function}@anchor{b2} +@anchor{topics/functions gcc_jit_context_get_builtin_function}@anchor{b4} @deffn {C Function} gcc_jit_function *gcc_jit_context_get_builtin_function (gcc_jit_context@w{ }*ctxt, const char@w{ }*name) @end deffn @geindex gcc_jit_function_as_object (C function) -@anchor{topics/functions gcc_jit_function_as_object}@anchor{b3} +@anchor{topics/functions gcc_jit_function_as_object}@anchor{b5} @deffn {C Function} gcc_jit_object * gcc_jit_function_as_object (gcc_jit_function@w{ }*func) Upcasting from function to object. @end deffn @geindex gcc_jit_function_get_param (C function) -@anchor{topics/functions gcc_jit_function_get_param}@anchor{b4} +@anchor{topics/functions gcc_jit_function_get_param}@anchor{b6} @deffn {C Function} gcc_jit_param * gcc_jit_function_get_param (gcc_jit_function@w{ }*func, int@w{ }index) Get the param of the given index (0-based). @@ -6170,7 +6229,7 @@ name. @end deffn @node Blocks,Statements,Functions,Creating and using functions -@anchor{topics/functions blocks}@anchor{b5} +@anchor{topics/functions blocks}@anchor{b7} @subsection Blocks @@ -6193,7 +6252,7 @@ one function. @end deffn @geindex gcc_jit_function_new_block (C function) -@anchor{topics/functions gcc_jit_function_new_block}@anchor{b6} +@anchor{topics/functions gcc_jit_function_new_block}@anchor{b8} @deffn {C Function} gcc_jit_block * gcc_jit_function_new_block (gcc_jit_function@w{ }*func, const char@w{ }*name) Create a basic block of the given name. The name may be NULL, but @@ -6203,26 +6262,26 @@ messages. @end deffn @geindex gcc_jit_block_as_object (C function) -@anchor{topics/functions gcc_jit_block_as_object}@anchor{b7} +@anchor{topics/functions gcc_jit_block_as_object}@anchor{b9} @deffn {C Function} gcc_jit_object * gcc_jit_block_as_object (gcc_jit_block@w{ }*block) Upcast from block to object. @end deffn @geindex gcc_jit_block_get_function (C function) -@anchor{topics/functions gcc_jit_block_get_function}@anchor{b8} +@anchor{topics/functions gcc_jit_block_get_function}@anchor{ba} @deffn {C Function} gcc_jit_function * gcc_jit_block_get_function (gcc_jit_block@w{ }*block) Which function is this block within? @end deffn @node Statements,,Blocks,Creating and using functions -@anchor{topics/functions statements}@anchor{b9} +@anchor{topics/functions statements}@anchor{bb} @subsection Statements @geindex gcc_jit_block_add_eval (C function) -@anchor{topics/functions gcc_jit_block_add_eval}@anchor{98} +@anchor{topics/functions gcc_jit_block_add_eval}@anchor{9a} @deffn {C Function} void gcc_jit_block_add_eval (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue) Add evaluation of an rvalue, discarding the result @@ -6290,7 +6349,7 @@ gcc_jit_block_add_assignment_op ( Add a no-op textual comment to the internal representation of the code. It will be optimized away, but will be visible in the dumps -seen via @pxref{5b,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE} +seen via @pxref{5d,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE} and @pxref{1c,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE}, and thus may be of use when debugging how your project's internal representation gets converted to the libgccjit IR. @@ -6318,7 +6377,7 @@ block, boolval, on_true, and on_false must be non-NULL. @end deffn @geindex gcc_jit_block_end_with_jump (C function) -@anchor{topics/functions gcc_jit_block_end_with_jump}@anchor{ba} +@anchor{topics/functions gcc_jit_block_end_with_jump}@anchor{bc} @deffn {C Function} void gcc_jit_block_end_with_jump (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_block@w{ }*target) Terminate a block by adding a jump to the given target block. @@ -6333,7 +6392,7 @@ goto target; @end deffn @geindex gcc_jit_block_end_with_return (C function) -@anchor{topics/functions gcc_jit_block_end_with_return}@anchor{bb} +@anchor{topics/functions gcc_jit_block_end_with_return}@anchor{bd} @deffn {C Function} void gcc_jit_block_end_with_return (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue) Terminate a block by adding evaluation of an rvalue, returning the value. @@ -6348,7 +6407,7 @@ return expression; @end deffn @geindex gcc_jit_block_end_with_void_return (C function) -@anchor{topics/functions gcc_jit_block_end_with_void_return}@anchor{bc} +@anchor{topics/functions gcc_jit_block_end_with_void_return}@anchor{be} @deffn {C Function} void gcc_jit_block_end_with_void_return (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc) Terminate a block by adding a valueless return, for use within a function @@ -6381,7 +6440,7 @@ return; @c <http://www.gnu.org/licenses/>. @node Source Locations,Compilation results,Creating and using functions,Topic Reference -@anchor{topics/locations source-locations}@anchor{bd}@anchor{topics/locations doc}@anchor{be} +@anchor{topics/locations source-locations}@anchor{bf}@anchor{topics/locations doc}@anchor{c0} @section Source Locations @@ -6427,7 +6486,7 @@ location. @end menu @node Faking it,,,Source Locations -@anchor{topics/locations faking-it}@anchor{bf} +@anchor{topics/locations faking-it}@anchor{c1} @subsection Faking it @@ -6465,7 +6524,7 @@ file, giving you @emph{something} you can step through in the debugger. @c <http://www.gnu.org/licenses/>. @node Compilation results,,Source Locations,Topic Reference -@anchor{topics/results compilation-results}@anchor{c0}@anchor{topics/results doc}@anchor{c1} +@anchor{topics/results compilation-results}@anchor{c2}@anchor{topics/results doc}@anchor{c3} @section Compilation results @@ -6496,7 +6555,7 @@ Functions are looked up by name. For this to succeed, a function with a name matching @cite{funcname} must have been created on @cite{result}'s context (or a parent context) via a call to @pxref{11,,gcc_jit_context_new_function()} with @cite{kind} -@pxref{ae,,GCC_JIT_FUNCTION_EXPORTED}: +@pxref{b0,,GCC_JIT_FUNCTION_EXPORTED}: @example gcc_jit_context_new_function (ctxt, @@ -6553,7 +6612,7 @@ valid to use the result, or any code that was obtained by calling @c <http://www.gnu.org/licenses/>. @node C++ bindings for libgccjit,Internals,Topic Reference,Top -@anchor{cp/index c-bindings-for-libgccjit}@anchor{c2}@anchor{cp/index doc}@anchor{c3} +@anchor{cp/index c-bindings-for-libgccjit}@anchor{c4}@anchor{cp/index doc}@anchor{c5} @chapter C++ bindings for libgccjit @@ -6695,7 +6754,7 @@ Source Locations @node Tutorial<2>,Topic Reference<2>,,C++ bindings for libgccjit -@anchor{cp/intro/index doc}@anchor{c4}@anchor{cp/intro/index tutorial}@anchor{c5} +@anchor{cp/intro/index doc}@anchor{c6}@anchor{cp/intro/index tutorial}@anchor{c7} @section Tutorial @@ -6725,7 +6784,7 @@ Source Locations @end menu @node Tutorial part 1 "Hello world"<2>,Tutorial part 2 Creating a trivial machine code function<2>,,Tutorial<2> -@anchor{cp/intro/tutorial01 doc}@anchor{c6}@anchor{cp/intro/tutorial01 tutorial-part-1-hello-world}@anchor{c7} +@anchor{cp/intro/tutorial01 doc}@anchor{c8}@anchor{cp/intro/tutorial01 tutorial-part-1-hello-world}@anchor{c9} @subsection Tutorial part 1: "Hello world" @@ -6895,7 +6954,7 @@ hello world @c <http://www.gnu.org/licenses/>. @node Tutorial part 2 Creating a trivial machine code function<2>,Tutorial part 3 Loops and variables<2>,Tutorial part 1 "Hello world"<2>,Tutorial<2> -@anchor{cp/intro/tutorial02 doc}@anchor{c8}@anchor{cp/intro/tutorial02 tutorial-part-2-creating-a-trivial-machine-code-function}@anchor{c9} +@anchor{cp/intro/tutorial02 doc}@anchor{ca}@anchor{cp/intro/tutorial02 tutorial-part-2-creating-a-trivial-machine-code-function}@anchor{cb} @subsection Tutorial part 2: Creating a trivial machine code function @@ -6924,7 +6983,7 @@ All state associated with compilation is associated with a @code{gccjit::context}, which is a thin C++ wrapper around the C API's @pxref{8,,gcc_jit_context *}. -Create one using @pxref{ca,,gccjit;;context;;acquire()}: +Create one using @pxref{cc,,gccjit;;context;;acquire()}: @example gccjit::context ctxt; @@ -6937,7 +6996,7 @@ The JIT library has a system of types. It is statically-typed: every expression is of a specific type, fixed at compile-time. In our example, all of the expressions are of the C @cite{int} type, so let's obtain this from the context, as a @code{gccjit::type}, using -@pxref{cb,,gccjit;;context;;get_type()}: +@pxref{cd,,gccjit;;context;;get_type()}: @example gccjit::type int_type = ctxt.get_type (GCC_JIT_TYPE_INT); @@ -6950,7 +7009,7 @@ entity in the API is associated with a @code{gccjit::context}. Memory management is easy: all such "contextual" objects are automatically cleaned up for you when the context is released, using -@pxref{cc,,gccjit;;context;;release()}: +@pxref{ce,,gccjit;;context;;release()}: @example ctxt.release (); @@ -6983,7 +7042,7 @@ The C++ class hierarchy within the @code{gccjit} namespace looks like this: One thing you can do with a @code{gccjit::object} is to ask it for a human-readable description as a @code{std::string}, using -@pxref{cd,,gccjit;;object;;get_debug_string()}: +@pxref{cf,,gccjit;;object;;get_debug_string()}: @example printf ("obj: %s\n", obj.get_debug_string ().c_str ()); @@ -7003,7 +7062,7 @@ This is invaluable when debugging. Let's create the function. To do so, we first need to construct its single parameter, specifying its type and giving it a name, -using @pxref{ce,,gccjit;;context;;new_param()}: +using @pxref{d0,,gccjit;;context;;new_param()}: @example gccjit::param param_i = ctxt.new_param (int_type, "i"); @@ -7052,7 +7111,7 @@ gccjit::block block = func.new_block (); Our basic block is relatively simple: it immediately terminates by returning the value of an expression. -We can build the expression using @pxref{cf,,gccjit;;context;;new_binary_op()}: +We can build the expression using @pxref{d1,,gccjit;;context;;new_binary_op()}: @example gccjit::rvalue expr = @@ -7065,7 +7124,7 @@ gccjit::rvalue expr = A @code{gccjit::rvalue} is another example of a @code{gccjit::object} subclass. As before, we can print it with -@pxref{cd,,gccjit;;object;;get_debug_string()}. +@pxref{cf,,gccjit;;object;;get_debug_string()}. @example printf ("expr: %s\n", expr.get_debug_string ().c_str ()); @@ -7102,7 +7161,7 @@ block.end_with_return (expr); @noindent OK, we've populated the context. We can now compile it using -@pxref{d0,,gccjit;;context;;compile()}: +@pxref{d2,,gccjit;;context;;compile()}: @example gcc_jit_result *result; @@ -7152,12 +7211,12 @@ result: 25 @end menu @node Options<3>,Full example<3>,,Tutorial part 2 Creating a trivial machine code function<2> -@anchor{cp/intro/tutorial02 options}@anchor{d1} +@anchor{cp/intro/tutorial02 options}@anchor{d3} @subsubsection Options To get more information on what's going on, you can set debugging flags -on the context using @pxref{d2,,gccjit;;context;;set_bool_option()}. +on the context using @pxref{d4,,gccjit;;context;;set_bool_option()}. @c (I'm deliberately not mentioning @c :c:macro:`GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE` here since I think @@ -7229,7 +7288,7 @@ square: By default, no optimizations are performed, the equivalent of GCC's @cite{-O0} option. We can turn things up to e.g. @cite{-O3} by calling -@pxref{d3,,gccjit;;context;;set_int_option()} with +@pxref{d5,,gccjit;;context;;set_int_option()} with @pxref{1f,,GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL}: @example @@ -7263,7 +7322,7 @@ square: Naturally this has only a small effect on such a trivial function. @node Full example<3>,,Options<3>,Tutorial part 2 Creating a trivial machine code function<2> -@anchor{cp/intro/tutorial02 full-example}@anchor{d4} +@anchor{cp/intro/tutorial02 full-example}@anchor{d6} @subsubsection Full example @@ -7406,7 +7465,7 @@ result: 25 @c <http://www.gnu.org/licenses/>. @node Tutorial part 3 Loops and variables<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2>,Tutorial part 2 Creating a trivial machine code function<2>,Tutorial<2> -@anchor{cp/intro/tutorial03 tutorial-part-3-loops-and-variables}@anchor{d5}@anchor{cp/intro/tutorial03 doc}@anchor{d6} +@anchor{cp/intro/tutorial03 tutorial-part-3-loops-and-variables}@anchor{d7}@anchor{cp/intro/tutorial03 doc}@anchor{d8} @subsection Tutorial part 3: Loops and variables @@ -7530,7 +7589,7 @@ gccjit::function func = @end menu @node Expressions lvalues and rvalues<2>,Control flow<2>,,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 expressions-lvalues-and-rvalues}@anchor{d7} +@anchor{cp/intro/tutorial03 expressions-lvalues-and-rvalues}@anchor{d9} @subsubsection Expressions: lvalues and rvalues @@ -7603,7 +7662,7 @@ body of a function. Our new example has a new kind of expression: we have two local variables. We create them by calling -@pxref{d8,,gccjit;;function;;new_local()}, supplying a type and a name: +@pxref{da,,gccjit;;function;;new_local()}, supplying a type and a name: @example /* Build locals: */ @@ -7629,7 +7688,7 @@ Instead, having added the local to the function, we have to separately add an assignment of @cite{0} to @cite{local_i} at the beginning of the function. @node Control flow<2>,Visualizing the control flow graph<2>,Expressions lvalues and rvalues<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 control-flow}@anchor{d9} +@anchor{cp/intro/tutorial03 control-flow}@anchor{db} @subsubsection Control flow @@ -7668,8 +7727,8 @@ We now populate each block with statements. The entry block @cite{b_initial} consists of initializations followed by a jump to the conditional. We assign @cite{0} to @cite{i} and to @cite{sum}, using -@pxref{da,,gccjit;;block;;add_assignment()} to add -an assignment statement, and using @pxref{db,,gccjit;;context;;zero()} to get +@pxref{dc,,gccjit;;block;;add_assignment()} to add +an assignment statement, and using @pxref{dd,,gccjit;;context;;zero()} to get the constant value @cite{0} for the relevant type for the right-hand side of the assignment: @@ -7696,7 +7755,7 @@ C example. It contains a single statement: a conditional, which jumps to one of two destination blocks depending on a boolean @code{gccjit::rvalue}, in this case the comparison of @cite{i} and @cite{n}. -We could build the comparison using @pxref{dc,,gccjit;;context;;new_comparison()}: +We could build the comparison using @pxref{de,,gccjit;;context;;new_comparison()}: @example gccjit::rvalue guard = @@ -7707,7 +7766,7 @@ gccjit::rvalue guard = @noindent and can then use this to add @cite{b_loop_cond}'s sole statement, via -@pxref{dd,,gccjit;;block;;end_with_conditional()}: +@pxref{df,,gccjit;;block;;end_with_conditional()}: @example b_loop_cond.end_with_conditional (guard); @@ -7739,7 +7798,7 @@ Next, we populate the body of the loop. The C statement @cite{sum += i * i;} is an assignment operation, where an lvalue is modified "in-place". We use -@pxref{de,,gccjit;;block;;add_assignment_op()} to handle these operations: +@pxref{e0,,gccjit;;block;;add_assignment_op()} to handle these operations: @example /* sum += i * i */ @@ -7767,7 +7826,7 @@ b_loop_body.add_assignment_op (i, @cartouche @quotation Note For numeric constants other than 0 or 1, we could use -@pxref{df,,gccjit;;context;;new_rvalue()}, which has overloads +@pxref{e1,,gccjit;;context;;new_rvalue()}, which has overloads for both @code{int} and @code{double}. @end quotation @end cartouche @@ -7843,12 +7902,12 @@ result: 285 @noindent @node Visualizing the control flow graph<2>,Full example<4>,Control flow<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 visualizing-the-control-flow-graph}@anchor{e0} +@anchor{cp/intro/tutorial03 visualizing-the-control-flow-graph}@anchor{e2} @subsubsection Visualizing the control flow graph You can see the control flow graph of a function using -@pxref{e1,,gccjit;;function;;dump_to_dot()}: +@pxref{e3,,gccjit;;function;;dump_to_dot()}: @example func.dump_to_dot ("/tmp/sum-of-squares.dot"); @@ -7882,7 +7941,7 @@ install it with @cite{yum install python-xdot}): @end quotation @node Full example<4>,,Visualizing the control flow graph<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 full-example}@anchor{e2} +@anchor{cp/intro/tutorial03 full-example}@anchor{e4} @subsubsection Full example @@ -8065,7 +8124,7 @@ loop_test returned: 285 @c <http://www.gnu.org/licenses/>. @node Tutorial part 4 Adding JIT-compilation to a toy interpreter<2>,,Tutorial part 3 Loops and variables<2>,Tutorial<2> -@anchor{cp/intro/tutorial04 tutorial-part-4-adding-jit-compilation-to-a-toy-interpreter}@anchor{e3}@anchor{cp/intro/tutorial04 doc}@anchor{e4} +@anchor{cp/intro/tutorial04 tutorial-part-4-adding-jit-compilation-to-a-toy-interpreter}@anchor{e5}@anchor{cp/intro/tutorial04 doc}@anchor{e6} @subsection Tutorial part 4: Adding JIT-compilation to a toy interpreter @@ -8087,7 +8146,7 @@ to it. @end menu @node Our toy interpreter<2>,Compiling to machine code<2>,,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 our-toy-interpreter}@anchor{e5} +@anchor{cp/intro/tutorial04 our-toy-interpreter}@anchor{e7} @subsubsection Our toy interpreter @@ -8495,7 +8554,7 @@ toyvm_function::interpret (int arg, FILE *trace) @end quotation @node Compiling to machine code<2>,Setting things up<2>,Our toy interpreter<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 compiling-to-machine-code}@anchor{e6} +@anchor{cp/intro/tutorial04 compiling-to-machine-code}@anchor{e8} @subsubsection Compiling to machine code @@ -8575,7 +8634,7 @@ This means our compiler has the following state: @end quotation @node Setting things up<2>,Populating the function<2>,Compiling to machine code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 setting-things-up}@anchor{e7} +@anchor{cp/intro/tutorial04 setting-things-up}@anchor{e9} @subsubsection Setting things up @@ -8743,7 +8802,7 @@ We create the locals within the function. @end quotation @node Populating the function<2>,Verifying the control flow graph<2>,Setting things up<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 populating-the-function}@anchor{e8} +@anchor{cp/intro/tutorial04 populating-the-function}@anchor{ea} @subsubsection Populating the function @@ -8871,7 +8930,7 @@ stack into @code{y} instead erroneously assigned it to @code{x}, leaving @code{y uninitialized. To track this kind of thing down, we can use -@pxref{e9,,gccjit;;block;;add_comment()} to add descriptive comments +@pxref{eb,,gccjit;;block;;add_comment()} to add descriptive comments to the internal representation. This is invaluable when looking through the generated IR for, say @code{factorial}: @@ -9020,14 +9079,14 @@ to the next block. This is analogous to simply incrementing the program counter. @node Verifying the control flow graph<2>,Compiling the context<2>,Populating the function<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 verifying-the-control-flow-graph}@anchor{ea} +@anchor{cp/intro/tutorial04 verifying-the-control-flow-graph}@anchor{ec} @subsubsection Verifying the control flow graph Having finished looping over the blocks, the context is complete. As before, we can verify that the control flow and statements are sane by -using @pxref{e1,,gccjit;;function;;dump_to_dot()}: +using @pxref{e3,,gccjit;;function;;dump_to_dot()}: @example fn.dump_to_dot ("/tmp/factorial.dot"); @@ -9051,7 +9110,7 @@ errors in our compiler. @end quotation @node Compiling the context<2>,Single-stepping through the generated code<2>,Verifying the control flow graph<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 compiling-the-context}@anchor{eb} +@anchor{cp/intro/tutorial04 compiling-the-context}@anchor{ed} @subsubsection Compiling the context @@ -9088,7 +9147,7 @@ We can now run the result: @end quotation @node Single-stepping through the generated code<2>,Examining the generated code<2>,Compiling the context<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 single-stepping-through-the-generated-code}@anchor{ec} +@anchor{cp/intro/tutorial04 single-stepping-through-the-generated-code}@anchor{ee} @subsubsection Single-stepping through the generated code @@ -9102,14 +9161,14 @@ It's possible to debug the generated code. To do this we need to both: @item Set up source code locations for our statements, so that we can meaningfully step through the code. We did this above by -calling @pxref{ed,,gccjit;;context;;new_location()} and using the +calling @pxref{ef,,gccjit;;context;;new_location()} and using the results. @item Enable the generation of debugging information, by setting @pxref{42,,GCC_JIT_BOOL_OPTION_DEBUGINFO} on the @code{gccjit::context} via -@pxref{d2,,gccjit;;context;;set_bool_option()}: +@pxref{d4,,gccjit;;context;;set_bool_option()}: @example ctxt.set_bool_option (GCC_JIT_BOOL_OPTION_DEBUGINFO, 1); @@ -9181,14 +9240,14 @@ optimization level in a regular compiler. @end cartouche @node Examining the generated code<2>,Putting it all together<2>,Single-stepping through the generated code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 examining-the-generated-code}@anchor{ee} +@anchor{cp/intro/tutorial04 examining-the-generated-code}@anchor{f0} @subsubsection Examining the generated code How good is the optimized code? We can turn up optimizations, by calling -@pxref{d3,,gccjit;;context;;set_int_option()} with +@pxref{d5,,gccjit;;context;;set_int_option()} with @pxref{1f,,GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL}: @example @@ -9370,7 +9429,7 @@ Note that the stack pushing and popping have been eliminated, as has the recursive call (in favor of an iteration). @node Putting it all together<2>,Behind the curtain How does our code get optimized?<2>,Examining the generated code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 putting-it-all-together}@anchor{ef} +@anchor{cp/intro/tutorial04 putting-it-all-together}@anchor{f1} @subsubsection Putting it all together @@ -9403,7 +9462,7 @@ compiler result: 55 @noindent @node Behind the curtain How does our code get optimized?<2>,,Putting it all together<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 behind-the-curtain-how-does-our-code-get-optimized}@anchor{f0} +@anchor{cp/intro/tutorial04 behind-the-curtain-how-does-our-code-get-optimized}@anchor{f2} @subsubsection Behind the curtain: How does our code get optimized? @@ -9604,7 +9663,7 @@ representation: @code{initial}, @code{instr4} and @code{instr9}. @end menu @node Optimizing away stack manipulation<2>,Elimination of tail recursion<2>,,Behind the curtain How does our code get optimized?<2> -@anchor{cp/intro/tutorial04 optimizing-away-stack-manipulation}@anchor{f1} +@anchor{cp/intro/tutorial04 optimizing-away-stack-manipulation}@anchor{f3} @subsubsection Optimizing away stack manipulation @@ -9884,7 +9943,7 @@ instr9: @noindent @node Elimination of tail recursion<2>,,Optimizing away stack manipulation<2>,Behind the curtain How does our code get optimized?<2> -@anchor{cp/intro/tutorial04 elimination-of-tail-recursion}@anchor{f2} +@anchor{cp/intro/tutorial04 elimination-of-tail-recursion}@anchor{f4} @subsubsection Elimination of tail recursion @@ -9971,7 +10030,7 @@ instr9: @c <http://www.gnu.org/licenses/>. @node Topic Reference<2>,,Tutorial<2>,C++ bindings for libgccjit -@anchor{cp/topics/index doc}@anchor{f3}@anchor{cp/topics/index topic-reference}@anchor{f4} +@anchor{cp/topics/index doc}@anchor{f5}@anchor{cp/topics/index topic-reference}@anchor{f6} @section Topic Reference @@ -10055,22 +10114,22 @@ Source Locations @node Compilation contexts<2>,Objects<2>,,Topic Reference<2> -@anchor{cp/topics/contexts compilation-contexts}@anchor{f5}@anchor{cp/topics/contexts doc}@anchor{f6} +@anchor{cp/topics/contexts compilation-contexts}@anchor{f7}@anchor{cp/topics/contexts doc}@anchor{f8} @subsection Compilation contexts @geindex gccjit;;context (C++ class) -@anchor{cp/topics/contexts gccjit context}@anchor{f7} +@anchor{cp/topics/contexts gccjit context}@anchor{f9} @deffn {C++ Class} gccjit::context @end deffn -The top-level of the C++ API is the @pxref{f7,,gccjit;;context} type. +The top-level of the C++ API is the @pxref{f9,,gccjit;;context} type. -A @pxref{f7,,gccjit;;context} instance encapsulates the state of a +A @pxref{f9,,gccjit;;context} instance encapsulates the state of a compilation. You can set up options on it, and add types, functions and code. -Invoking @pxref{d0,,gccjit;;context;;compile()} on it gives you a +Invoking @pxref{d2,,gccjit;;context;;compile()} on it gives you a @pxref{16,,gcc_jit_result *}. It is a thin wrapper around the C API's @pxref{8,,gcc_jit_context *}. @@ -10085,7 +10144,7 @@ It is a thin wrapper around the C API's @pxref{8,,gcc_jit_context *}. @end menu @node Lifetime-management<2>,Thread-safety<2>,,Compilation contexts<2> -@anchor{cp/topics/contexts lifetime-management}@anchor{f8} +@anchor{cp/topics/contexts lifetime-management}@anchor{fa} @subsubsection Lifetime-management @@ -10094,16 +10153,16 @@ have their lifetime bounded by the context they are created within, and cleanup of such objects is done for you when the context is released. @geindex gccjit;;context;;acquire (C++ function) -@anchor{cp/topics/contexts gccjit context acquire}@anchor{ca} +@anchor{cp/topics/contexts gccjit context acquire}@anchor{cc} @deffn {C++ Function} gccjit::context gccjit::context::acquire () -This function acquires a new @pxref{f7,,gccjit;;context} instance, +This function acquires a new @pxref{f9,,gccjit;;context} instance, which is independent of any others that may be present within this process. @end deffn @geindex gccjit;;context;;release (C++ function) -@anchor{cp/topics/contexts gccjit context release}@anchor{cc} +@anchor{cp/topics/contexts gccjit context release}@anchor{ce} @deffn {C++ Function} void gccjit::context::release () This function releases all resources associated with the given context. @@ -10122,7 +10181,7 @@ ctxt.release (); @end deffn @geindex gccjit;;context;;new_child_context (C++ function) -@anchor{cp/topics/contexts gccjit context new_child_context}@anchor{f9} +@anchor{cp/topics/contexts gccjit context new_child_context}@anchor{fb} @deffn {C++ Function} gccjit::context gccjit::context::new_child_context () Given an existing JIT context, create a child context. @@ -10154,16 +10213,16 @@ there will likely be a performance hit for such nesting. @end deffn @node Thread-safety<2>,Error-handling<3>,Lifetime-management<2>,Compilation contexts<2> -@anchor{cp/topics/contexts thread-safety}@anchor{fa} +@anchor{cp/topics/contexts thread-safety}@anchor{fc} @subsubsection Thread-safety -Instances of @pxref{f7,,gccjit;;context} created via -@pxref{ca,,gccjit;;context;;acquire()} are independent from each other: +Instances of @pxref{f9,,gccjit;;context} created via +@pxref{cc,,gccjit;;context;;acquire()} are independent from each other: only one thread may use a given context at once, but multiple threads could each have their own contexts without needing locks. -Contexts created via @pxref{f9,,gccjit;;context;;new_child_context()} are +Contexts created via @pxref{fb,,gccjit;;context;;new_child_context()} are related to their parent context. They can be partitioned by their ultimate ancestor into independent "family trees". Only one thread within a process may use a given "family tree" of such contexts at once, @@ -10171,7 +10230,7 @@ and if you're using multiple threads you should provide your own locking around entire such context partitions. @node Error-handling<3>,Debugging<2>,Thread-safety<2>,Compilation contexts<2> -@anchor{cp/topics/contexts error-handling}@anchor{fb} +@anchor{cp/topics/contexts error-handling}@anchor{fd} @subsubsection Error-handling @@ -10184,10 +10243,10 @@ NULL. You don't have to check everywhere for NULL results, since the API gracefully handles a NULL being passed in for any argument. Errors are printed on stderr and can be queried using -@pxref{fc,,gccjit;;context;;get_first_error()}. +@pxref{fe,,gccjit;;context;;get_first_error()}. @geindex gccjit;;context;;get_first_error (C++ function) -@anchor{cp/topics/contexts gccjit context get_first_error__gccjit contextP}@anchor{fc} +@anchor{cp/topics/contexts gccjit context get_first_error__gccjit contextP}@anchor{fe} @deffn {C++ Function} const char* gccjit::context::get_first_error (gccjit::context* ctxt) Returns the first error message that occurred on the context. @@ -10199,18 +10258,18 @@ If no errors occurred, this will be NULL. @end deffn @node Debugging<2>,Options<4>,Error-handling<3>,Compilation contexts<2> -@anchor{cp/topics/contexts debugging}@anchor{fd} +@anchor{cp/topics/contexts debugging}@anchor{ff} @subsubsection Debugging @geindex gccjit;;context;;dump_to_file (C++ function) -@anchor{cp/topics/contexts gccjit context dump_to_file__ssCR i}@anchor{fe} +@anchor{cp/topics/contexts gccjit context dump_to_file__ssCR i}@anchor{100} @deffn {C++ Function} void gccjit::context::dump_to_file (const std::string& path, int update_locations) To help with debugging: dump a C-like representation to the given path, describing what's been set up on the context. -If "update_locations" is true, then also set up @pxref{ff,,gccjit;;location} +If "update_locations" is true, then also set up @pxref{101,,gccjit;;location} information throughout the context, pointing at the dump file as if it were a source file. This may be of use in conjunction with @code{GCCJIT::BOOL_OPTION_DEBUGINFO} to allow stepping through the @@ -10218,7 +10277,7 @@ code in a debugger. @end deffn @node Options<4>,,Debugging<2>,Compilation contexts<2> -@anchor{cp/topics/contexts options}@anchor{100} +@anchor{cp/topics/contexts options}@anchor{102} @subsubsection Options @@ -10230,28 +10289,28 @@ code in a debugger. @end menu @node String Options<2>,Boolean options<2>,,Options<4> -@anchor{cp/topics/contexts string-options}@anchor{101} +@anchor{cp/topics/contexts string-options}@anchor{103} @subsubsection String Options @geindex gccjit;;context;;set_str_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_str_option__enum cCP}@anchor{102} +@anchor{cp/topics/contexts gccjit context set_str_option__enum cCP}@anchor{104} @deffn {C++ Function} void gccjit::context::set_str_option (enum gcc_jit_str_option, const char* value) Set a string option of the context. This is a thin wrapper around the C API -@pxref{56,,gcc_jit_context_set_str_option()}; the options have the same +@pxref{58,,gcc_jit_context_set_str_option()}; the options have the same meaning. @end deffn @node Boolean options<2>,Integer options<2>,String Options<2>,Options<4> -@anchor{cp/topics/contexts boolean-options}@anchor{103} +@anchor{cp/topics/contexts boolean-options}@anchor{105} @subsubsection Boolean options @geindex gccjit;;context;;set_bool_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_bool_option__enum i}@anchor{d2} +@anchor{cp/topics/contexts gccjit context set_bool_option__enum i}@anchor{d4} @deffn {C++ Function} void gccjit::context::set_bool_option (enum gcc_jit_bool_option, int value) Set a boolean option of the context. @@ -10262,12 +10321,12 @@ meaning. @end deffn @node Integer options<2>,,Boolean options<2>,Options<4> -@anchor{cp/topics/contexts integer-options}@anchor{104} +@anchor{cp/topics/contexts integer-options}@anchor{106} @subsubsection Integer options @geindex gccjit;;context;;set_int_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_int_option__enum i}@anchor{d3} +@anchor{cp/topics/contexts gccjit context set_int_option__enum i}@anchor{d5} @deffn {C++ Function} void gccjit::context::set_int_option (enum gcc_jit_int_option, int value) Set an integer option of the context. @@ -10295,18 +10354,18 @@ meaning. @c <http://www.gnu.org/licenses/>. @node Objects<2>,Types<2>,Compilation contexts<2>,Topic Reference<2> -@anchor{cp/topics/objects objects}@anchor{105}@anchor{cp/topics/objects doc}@anchor{106} +@anchor{cp/topics/objects objects}@anchor{107}@anchor{cp/topics/objects doc}@anchor{108} @subsection Objects @geindex gccjit;;object (C++ class) -@anchor{cp/topics/objects gccjit object}@anchor{107} +@anchor{cp/topics/objects gccjit object}@anchor{109} @deffn {C++ Class} gccjit::object @end deffn Almost every entity in the API (with the exception of -@pxref{f7,,gccjit;;context} and @pxref{16,,gcc_jit_result *}) is a -"contextual" object, a @pxref{107,,gccjit;;object}. +@pxref{f9,,gccjit;;context} and @pxref{16,,gcc_jit_result *}) is a +"contextual" object, a @pxref{109,,gccjit;;object}. A JIT object: @@ -10316,7 +10375,7 @@ A JIT object: @itemize * @item -is associated with a @pxref{f7,,gccjit;;context}. +is associated with a @pxref{f9,,gccjit;;context}. @item is automatically cleaned up for you when its context is released so @@ -10342,17 +10401,17 @@ The C++ class hierarchy within the @code{gccjit} namespace looks like this: @noindent -The @pxref{107,,gccjit;;object} base class has the following operations: +The @pxref{109,,gccjit;;object} base class has the following operations: @geindex gccjit;;object;;get_context (C++ function) -@anchor{cp/topics/objects gccjit object get_contextC}@anchor{108} +@anchor{cp/topics/objects gccjit object get_contextC}@anchor{10a} @deffn {C++ Function} gccjit::context gccjit::object::get_context () const Which context is the obj within? @end deffn @geindex gccjit;;object;;get_debug_string (C++ function) -@anchor{cp/topics/objects gccjit object get_debug_stringC}@anchor{cd} +@anchor{cp/topics/objects gccjit object get_debug_stringC}@anchor{cf} @deffn {C++ Function} std::string gccjit::object::get_debug_string () const Generate a human-readable description for the given object. @@ -10392,16 +10451,16 @@ obj: 4.0 * (float)i @c <http://www.gnu.org/licenses/>. @node Types<2>,Expressions<2>,Objects<2>,Topic Reference<2> -@anchor{cp/topics/types doc}@anchor{109}@anchor{cp/topics/types types}@anchor{10a} +@anchor{cp/topics/types doc}@anchor{10b}@anchor{cp/topics/types types}@anchor{10c} @subsection Types @geindex gccjit;;type (C++ class) -@anchor{cp/topics/types gccjit type}@anchor{10b} +@anchor{cp/topics/types gccjit type}@anchor{10d} @deffn {C++ Class} gccjit::type gccjit::type represents a type within the library. It is a subclass -of @pxref{107,,gccjit;;object}. +of @pxref{109,,gccjit;;object}. @end deffn Types can be created in several ways: @@ -10411,7 +10470,7 @@ Types can be created in several ways: @item fundamental types can be accessed using -@pxref{cb,,gccjit;;context;;get_type()}: +@pxref{cd,,gccjit;;context;;get_type()}: @example gccjit::type int_type = ctxt.get_type (GCC_JIT_TYPE_INT); @@ -10431,7 +10490,7 @@ See @pxref{b,,gcc_jit_context_get_type()} for the available types. @item derived types can be accessed by using functions such as -@pxref{10c,,gccjit;;type;;get_pointer()} and @pxref{10d,,gccjit;;type;;get_const()}: +@pxref{10e,,gccjit;;type;;get_pointer()} and @pxref{10f,,gccjit;;type;;get_const()}: @example gccjit::type const_int_star = int_type.get_const ().get_pointer (); @@ -10452,12 +10511,12 @@ by creating structures (see below). @end menu @node Standard types<2>,Pointers const and volatile<2>,,Types<2> -@anchor{cp/topics/types standard-types}@anchor{10e} +@anchor{cp/topics/types standard-types}@anchor{110} @subsubsection Standard types @geindex gccjit;;context;;get_type (C++ function) -@anchor{cp/topics/types gccjit context get_type__enum}@anchor{cb} +@anchor{cp/topics/types gccjit context get_type__enum}@anchor{cd} @deffn {C++ Function} gccjit::type gccjit::context::get_type (enum gcc_jit_types) Access a specific type. This is a thin wrapper around @@ -10465,14 +10524,14 @@ Access a specific type. This is a thin wrapper around @end deffn @geindex gccjit;;context;;get_int_type (C++ function) -@anchor{cp/topics/types gccjit context get_int_type__s i}@anchor{10f} +@anchor{cp/topics/types gccjit context get_int_type__s i}@anchor{111} @deffn {C++ Function} gccjit::type gccjit::context::get_int_type (size_t num_bytes, int is_signed) Access the integer type of the given size. @end deffn @geindex gccjit;;context;;get_int_type<T> (C++ function) -@anchor{cp/topics/types gccjit context get_int_type T}@anchor{110} +@anchor{cp/topics/types gccjit context get_int_type T}@anchor{112} @deffn {C++ Function} gccjit::type gccjit::context::get_int_type<T> () Access the given integer type. For example, you could map the @@ -10486,12 +10545,12 @@ gccjit::type t = ctxt.get_int_type <unsigned short> (); @end deffn @node Pointers const and volatile<2>,Structures and unions<2>,Standard types<2>,Types<2> -@anchor{cp/topics/types pointers-const-and-volatile}@anchor{111} +@anchor{cp/topics/types pointers-const-and-volatile}@anchor{113} @subsubsection Pointers, @cite{const}, and @cite{volatile} @geindex gccjit;;type;;get_pointer (C++ function) -@anchor{cp/topics/types gccjit type get_pointer}@anchor{10c} +@anchor{cp/topics/types gccjit type get_pointer}@anchor{10e} @deffn {C++ Function} gccjit::type gccjit::type::get_pointer () Given type "T", get type "T*". @@ -10500,21 +10559,21 @@ Given type "T", get type "T*". @c FIXME: get_const doesn't seem to exist @geindex gccjit;;type;;get_const (C++ function) -@anchor{cp/topics/types gccjit type get_const}@anchor{10d} +@anchor{cp/topics/types gccjit type get_const}@anchor{10f} @deffn {C++ Function} gccjit::type gccjit::type::get_const () Given type "T", get type "const T". @end deffn @geindex gccjit;;type;;get_volatile (C++ function) -@anchor{cp/topics/types gccjit type get_volatile}@anchor{112} +@anchor{cp/topics/types gccjit type get_volatile}@anchor{114} @deffn {C++ Function} gccjit::type gccjit::type::get_volatile () Given type "T", get type "volatile T". @end deffn @geindex gccjit;;context;;new_array_type (C++ function) -@anchor{cp/topics/types gccjit context new_array_type__gccjit type i gccjit location}@anchor{113} +@anchor{cp/topics/types gccjit context new_array_type__gccjit type i gccjit location}@anchor{115} @deffn {C++ Function} gccjit::type gccjit::context::new_array_type (gccjit::type element_type, int num_elements, gccjit::location loc) Given type "T", get type "T[N]" (for a constant N). @@ -10522,31 +10581,31 @@ Param "loc" is optional. @end deffn @node Structures and unions<2>,,Pointers const and volatile<2>,Types<2> -@anchor{cp/topics/types structures-and-unions}@anchor{114} +@anchor{cp/topics/types structures-and-unions}@anchor{116} @subsubsection Structures and unions @geindex gccjit;;struct_ (C++ class) -@anchor{cp/topics/types gccjit struct_}@anchor{115} +@anchor{cp/topics/types gccjit struct_}@anchor{117} @deffn {C++ Class} gccjit::struct_ @end deffn A compound type analagous to a C @cite{struct}. -@pxref{115,,gccjit;;struct_} is a subclass of @pxref{10b,,gccjit;;type} (and thus -of @pxref{107,,gccjit;;object} in turn). +@pxref{117,,gccjit;;struct_} is a subclass of @pxref{10d,,gccjit;;type} (and thus +of @pxref{109,,gccjit;;object} in turn). @geindex gccjit;;field (C++ class) -@anchor{cp/topics/types gccjit field}@anchor{116} +@anchor{cp/topics/types gccjit field}@anchor{118} @deffn {C++ Class} gccjit::field @end deffn -A field within a @pxref{115,,gccjit;;struct_}. +A field within a @pxref{117,,gccjit;;struct_}. -@pxref{116,,gccjit;;field} is a subclass of @pxref{107,,gccjit;;object}. +@pxref{118,,gccjit;;field} is a subclass of @pxref{109,,gccjit;;object}. -You can model C @cite{struct} types by creating @pxref{115,,gccjit;;struct_} and -@pxref{116,,gccjit;;field} instances, in either order: +You can model C @cite{struct} types by creating @pxref{117,,gccjit;;struct_} and +@pxref{118,,gccjit;;field} instances, in either order: @itemize * @@ -10602,14 +10661,14 @@ node.set_fields (fields); @c FIXME: the above API doesn't seem to exist yet @geindex gccjit;;context;;new_field (C++ function) -@anchor{cp/topics/types gccjit context new_field__gccjit type cCP gccjit location}@anchor{117} +@anchor{cp/topics/types gccjit context new_field__gccjit type cCP gccjit location}@anchor{119} @deffn {C++ Function} gccjit::field gccjit::context::new_field (gccjit::type type, const char* name, gccjit::location loc) Construct a new field, with the given type and name. @end deffn @geindex gccjit;;context;;new_struct_type (C++ function) -@anchor{cp/topics/types gccjit context new_struct_type__ssCR std vector field R gccjit location}@anchor{118} +@anchor{cp/topics/types gccjit context new_struct_type__ssCR std vector field R gccjit location}@anchor{11a} @deffn {C++ Function} gccjit::struct_ gccjit::context::new_struct_type (const std::string& name, std::vector<field>& fields, gccjit::location loc) @quotation @@ -10619,13 +10678,13 @@ Construct a new struct type, with the given name and fields. @end deffn @geindex gccjit;;context;;new_opaque_struct (C++ function) -@anchor{cp/topics/types gccjit context new_opaque_struct__ssCR gccjit location}@anchor{119} +@anchor{cp/topics/types gccjit context new_opaque_struct__ssCR gccjit location}@anchor{11b} @deffn {C++ Function} gccjit::struct_ gccjit::context::new_opaque_struct (const std::string& name, gccjit::location loc) Construct a new struct type, with the given name, but without specifying the fields. The fields can be omitted (in which case the size of the struct is not known), or later specified using -@pxref{75,,gcc_jit_struct_set_fields()}. +@pxref{77,,gcc_jit_struct_set_fields()}. @end deffn @c Copyright (C) 2014 Free Software Foundation, Inc. @@ -10646,7 +10705,7 @@ size of the struct is not known), or later specified using @c <http://www.gnu.org/licenses/>. @node Expressions<2>,Creating and using functions<2>,Types<2>,Topic Reference<2> -@anchor{cp/topics/expressions expressions}@anchor{11a}@anchor{cp/topics/expressions doc}@anchor{11b} +@anchor{cp/topics/expressions expressions}@anchor{11c}@anchor{cp/topics/expressions doc}@anchor{11d} @subsection Expressions @@ -10672,17 +10731,17 @@ Lvalues @node Rvalues<2>,Lvalues<2>,,Expressions<2> -@anchor{cp/topics/expressions rvalues}@anchor{11c} +@anchor{cp/topics/expressions rvalues}@anchor{11e} @subsubsection Rvalues @geindex gccjit;;rvalue (C++ class) -@anchor{cp/topics/expressions gccjit rvalue}@anchor{11d} +@anchor{cp/topics/expressions gccjit rvalue}@anchor{11f} @deffn {C++ Class} gccjit::rvalue @end deffn -A @pxref{11d,,gccjit;;rvalue} is an expression that can be computed. It is a -subclass of @pxref{107,,gccjit;;object}, and is a thin wrapper around +A @pxref{11f,,gccjit;;rvalue} is an expression that can be computed. It is a +subclass of @pxref{109,,gccjit;;object}, and is a thin wrapper around @pxref{13,,gcc_jit_rvalue *} from the C API. It can be simple, e.g.: @@ -10728,7 +10787,7 @@ Every rvalue has an associated type, and the API will check to ensure that types match up correctly (otherwise the context will emit an error). @geindex gccjit;;rvalue;;get_type (C++ function) -@anchor{cp/topics/expressions gccjit rvalue get_type}@anchor{11e} +@anchor{cp/topics/expressions gccjit rvalue get_type}@anchor{120} @deffn {C++ Function} gccjit::type gccjit::rvalue::get_type () Get the type of this rvalue. @@ -10745,12 +10804,12 @@ Get the type of this rvalue. @end menu @node Simple expressions<2>,Unary Operations<2>,,Rvalues<2> -@anchor{cp/topics/expressions simple-expressions}@anchor{11f} +@anchor{cp/topics/expressions simple-expressions}@anchor{121} @subsubsection Simple expressions @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type iC}@anchor{df} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type iC}@anchor{e1} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type numeric_type, int value) const Given a numeric type (integer or floating point), build an rvalue for @@ -10758,7 +10817,7 @@ the given constant @code{int} value. @end deffn @geindex gccjit;;context;;zero (C++ function) -@anchor{cp/topics/expressions gccjit context zero__gccjit typeC}@anchor{db} +@anchor{cp/topics/expressions gccjit context zero__gccjit typeC}@anchor{dd} @deffn {C++ Function} gccjit::rvalue gccjit::context::zero (gccjit::type numeric_type) const Given a numeric type (integer or floating point), get the rvalue for @@ -10772,7 +10831,7 @@ ctxt.new_rvalue (numeric_type, 0) @end deffn @geindex gccjit;;context;;one (C++ function) -@anchor{cp/topics/expressions gccjit context one__gccjit typeC}@anchor{120} +@anchor{cp/topics/expressions gccjit context one__gccjit typeC}@anchor{122} @deffn {C++ Function} gccjit::rvalue gccjit::context::one (gccjit::type numeric_type) const Given a numeric type (integer or floating point), get the rvalue for @@ -10786,7 +10845,7 @@ ctxt.new_rvalue (numeric_type, 1) @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type doubleC}@anchor{121} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type doubleC}@anchor{123} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type numeric_type, double value) const Given a numeric type (integer or floating point), build an rvalue for @@ -10794,14 +10853,14 @@ the given constant value. @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type voidPC}@anchor{122} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type voidPC}@anchor{124} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type pointer_type, void* value) const Given a pointer type, build an rvalue for the given address. @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__ssCRC}@anchor{123} +@anchor{cp/topics/expressions gccjit context new_rvalue__ssCRC}@anchor{125} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (const std::string& value) const Generate an rvalue of type @code{GCC_JIT_TYPE_CONST_CHAR_PTR} for @@ -10809,12 +10868,12 @@ the given string. This is akin to a string literal. @end deffn @node Unary Operations<2>,Binary Operations<2>,Simple expressions<2>,Rvalues<2> -@anchor{cp/topics/expressions unary-operations}@anchor{124} +@anchor{cp/topics/expressions unary-operations}@anchor{126} @subsubsection Unary Operations @geindex gccjit;;context;;new_unary_op (C++ function) -@anchor{cp/topics/expressions gccjit context new_unary_op__enum gccjit type gccjit rvalue gccjit location}@anchor{125} +@anchor{cp/topics/expressions gccjit context new_unary_op__enum gccjit type gccjit rvalue gccjit location}@anchor{127} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_unary_op (enum gcc_jit_unary_op, gccjit::type result_type, gccjit::rvalue rvalue, gccjit::location loc) Build a unary operation out of an input rvalue. @@ -10822,7 +10881,7 @@ Build a unary operation out of an input rvalue. Parameter @code{loc} is optional. This is a thin wrapper around the C API's -@pxref{80,,gcc_jit_context_new_unary_op()} and the available unary +@pxref{82,,gcc_jit_context_new_unary_op()} and the available unary operations are documented there. @end deffn @@ -10830,7 +10889,7 @@ There are shorter ways to spell the various specific kinds of unary operation: @geindex gccjit;;context;;new_minus (C++ function) -@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit location}@anchor{126} +@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit location}@anchor{128} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_minus (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Negate an arithmetic value; for example: @@ -10851,7 +10910,7 @@ builds the equivalent of this C expression: @end deffn @geindex new_bitwise_negate (C++ function) -@anchor{cp/topics/expressions new_bitwise_negate__gccjit type gccjit rvalue gccjit location}@anchor{127} +@anchor{cp/topics/expressions new_bitwise_negate__gccjit type gccjit rvalue gccjit location}@anchor{129} @deffn {C++ Function} gccjit::rvalue new_bitwise_negate (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Bitwise negation of an integer value (one's complement); for example: @@ -10872,7 +10931,7 @@ builds the equivalent of this C expression: @end deffn @geindex new_logical_negate (C++ function) -@anchor{cp/topics/expressions new_logical_negate__gccjit type gccjit rvalue gccjit location}@anchor{128} +@anchor{cp/topics/expressions new_logical_negate__gccjit type gccjit rvalue gccjit location}@anchor{12a} @deffn {C++ Function} gccjit::rvalue new_logical_negate (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Logical negation of an arithmetic or pointer value; for example: @@ -10895,7 +10954,7 @@ builds the equivalent of this C expression: The most concise way to spell them is with overloaded operators: @geindex operator- (C++ function) -@anchor{cp/topics/expressions sub-operator__gccjit rvalue}@anchor{129} +@anchor{cp/topics/expressions sub-operator__gccjit rvalue}@anchor{12b} @deffn {C++ Function} gccjit::rvalue operator- (gccjit::rvalue a) @example @@ -10906,7 +10965,7 @@ gccjit::rvalue negpi = -pi; @end deffn @geindex operator~ (C++ function) -@anchor{cp/topics/expressions inv-operator__gccjit rvalue}@anchor{12a} +@anchor{cp/topics/expressions inv-operator__gccjit rvalue}@anchor{12c} @deffn {C++ Function} gccjit::rvalue operator~ (gccjit::rvalue a) @example @@ -10917,7 +10976,7 @@ gccjit::rvalue mask = ~a; @end deffn @geindex operator! (C++ function) -@anchor{cp/topics/expressions not-operator__gccjit rvalue}@anchor{12b} +@anchor{cp/topics/expressions not-operator__gccjit rvalue}@anchor{12d} @deffn {C++ Function} gccjit::rvalue operator! (gccjit::rvalue a) @example @@ -10928,12 +10987,12 @@ gccjit::rvalue guard = !cond; @end deffn @node Binary Operations<2>,Comparisons<2>,Unary Operations<2>,Rvalues<2> -@anchor{cp/topics/expressions binary-operations}@anchor{12c} +@anchor{cp/topics/expressions binary-operations}@anchor{12e} @subsubsection Binary Operations @geindex gccjit;;context;;new_binary_op (C++ function) -@anchor{cp/topics/expressions gccjit context new_binary_op__enum gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{cf} +@anchor{cp/topics/expressions gccjit context new_binary_op__enum gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{d1} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_binary_op (enum gcc_jit_binary_op, gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) Build a binary operation out of two constituent rvalues. @@ -10949,59 +11008,59 @@ There are shorter ways to spell the various specific kinds of binary operation: @geindex gccjit;;context;;new_plus (C++ function) -@anchor{cp/topics/expressions gccjit context new_plus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{12d} +@anchor{cp/topics/expressions gccjit context new_plus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{12f} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_plus (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_minus (C++ function) -@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{12e} +@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{130} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_minus (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_mult (C++ function) -@anchor{cp/topics/expressions gccjit context new_mult__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{12f} +@anchor{cp/topics/expressions gccjit context new_mult__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{131} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_mult (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_divide (C++ function) -@anchor{cp/topics/expressions gccjit context new_divide__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{130} +@anchor{cp/topics/expressions gccjit context new_divide__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{132} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_divide (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_modulo (C++ function) -@anchor{cp/topics/expressions gccjit context new_modulo__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{131} +@anchor{cp/topics/expressions gccjit context new_modulo__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{133} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_modulo (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_and (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{132} +@anchor{cp/topics/expressions gccjit context new_bitwise_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{134} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_and (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_xor (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_xor__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{133} +@anchor{cp/topics/expressions gccjit context new_bitwise_xor__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{135} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_xor (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_or (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{134} +@anchor{cp/topics/expressions gccjit context new_bitwise_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{136} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_or (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_logical_and (C++ function) -@anchor{cp/topics/expressions gccjit context new_logical_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{135} +@anchor{cp/topics/expressions gccjit context new_logical_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{137} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_logical_and (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_logical_or (C++ function) -@anchor{cp/topics/expressions gccjit context new_logical_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{136} +@anchor{cp/topics/expressions gccjit context new_logical_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{138} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_logical_or (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn The most concise way to spell them is with overloaded operators: @geindex operator+ (C++ function) -@anchor{cp/topics/expressions add-operator__gccjit rvalue gccjit rvalue}@anchor{137} +@anchor{cp/topics/expressions add-operator__gccjit rvalue gccjit rvalue}@anchor{139} @deffn {C++ Function} gccjit::rvalue operator+ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11012,7 +11071,7 @@ gccjit::rvalue sum = a + b; @end deffn @geindex operator- (C++ function) -@anchor{cp/topics/expressions sub-operator__gccjit rvalue gccjit rvalue}@anchor{138} +@anchor{cp/topics/expressions sub-operator__gccjit rvalue gccjit rvalue}@anchor{13a} @deffn {C++ Function} gccjit::rvalue operator- (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11023,7 +11082,7 @@ gccjit::rvalue diff = a - b; @end deffn @geindex operator* (C++ function) -@anchor{cp/topics/expressions mul-operator__gccjit rvalue gccjit rvalue}@anchor{139} +@anchor{cp/topics/expressions mul-operator__gccjit rvalue gccjit rvalue}@anchor{13b} @deffn {C++ Function} gccjit::rvalue operator* (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11034,7 +11093,7 @@ gccjit::rvalue prod = a * b; @end deffn @geindex operator/ (C++ function) -@anchor{cp/topics/expressions div-operator__gccjit rvalue gccjit rvalue}@anchor{13a} +@anchor{cp/topics/expressions div-operator__gccjit rvalue gccjit rvalue}@anchor{13c} @deffn {C++ Function} gccjit::rvalue operator/ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11045,7 +11104,7 @@ gccjit::rvalue result = a / b; @end deffn @geindex operator% (C++ function) -@anchor{cp/topics/expressions mod-operator__gccjit rvalue gccjit rvalue}@anchor{13b} +@anchor{cp/topics/expressions mod-operator__gccjit rvalue gccjit rvalue}@anchor{13d} @deffn {C++ Function} gccjit::rvalue operator% (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11056,7 +11115,7 @@ gccjit::rvalue mod = a % b; @end deffn @geindex operator& (C++ function) -@anchor{cp/topics/expressions and-operator__gccjit rvalue gccjit rvalue}@anchor{13c} +@anchor{cp/topics/expressions and-operator__gccjit rvalue gccjit rvalue}@anchor{13e} @deffn {C++ Function} gccjit::rvalue operator& (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11067,7 +11126,7 @@ gccjit::rvalue x = a & b; @end deffn @geindex operator^ (C++ function) -@anchor{cp/topics/expressions xor-operator__gccjit rvalue gccjit rvalue}@anchor{13d} +@anchor{cp/topics/expressions xor-operator__gccjit rvalue gccjit rvalue}@anchor{13f} @deffn {C++ Function} gccjit::rvalue operator^ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11078,7 +11137,7 @@ gccjit::rvalue x = a ^ b; @end deffn @geindex operator| (C++ function) -@anchor{cp/topics/expressions or-operator__gccjit rvalue gccjit rvalue}@anchor{13e} +@anchor{cp/topics/expressions or-operator__gccjit rvalue gccjit rvalue}@anchor{140} @deffn {C++ Function} gccjit::rvalue operator| (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11089,7 +11148,7 @@ gccjit::rvalue x = a | b; @end deffn @geindex operator&& (C++ function) -@anchor{cp/topics/expressions sand-operator__gccjit rvalue gccjit rvalue}@anchor{13f} +@anchor{cp/topics/expressions sand-operator__gccjit rvalue gccjit rvalue}@anchor{141} @deffn {C++ Function} gccjit::rvalue operator&& (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11100,7 +11159,7 @@ gccjit::rvalue cond = a && b; @end deffn @geindex operator|| (C++ function) -@anchor{cp/topics/expressions sor-operator__gccjit rvalue gccjit rvalue}@anchor{140} +@anchor{cp/topics/expressions sor-operator__gccjit rvalue gccjit rvalue}@anchor{142} @deffn {C++ Function} gccjit::rvalue operator|| (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11123,12 +11182,12 @@ gccjit::rvalue discriminant = (b * b) - (four * a * c); @end quotation @node Comparisons<2>,Function calls<2>,Binary Operations<2>,Rvalues<2> -@anchor{cp/topics/expressions comparisons}@anchor{141} +@anchor{cp/topics/expressions comparisons}@anchor{143} @subsubsection Comparisons @geindex gccjit;;context;;new_comparison (C++ function) -@anchor{cp/topics/expressions gccjit context new_comparison__enum gccjit rvalue gccjit rvalue gccjit location}@anchor{dc} +@anchor{cp/topics/expressions gccjit context new_comparison__enum gccjit rvalue gccjit rvalue gccjit location}@anchor{de} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_comparison (enum gcc_jit_comparison, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) Build a boolean rvalue out of the comparison of two other rvalues. @@ -11144,39 +11203,39 @@ There are shorter ways to spell the various specific kinds of binary operation: @geindex gccjit;;context;;new_eq (C++ function) -@anchor{cp/topics/expressions gccjit context new_eq__gccjit rvalue gccjit rvalue gccjit location}@anchor{142} +@anchor{cp/topics/expressions gccjit context new_eq__gccjit rvalue gccjit rvalue gccjit location}@anchor{144} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_eq (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_ne (C++ function) -@anchor{cp/topics/expressions gccjit context new_ne__gccjit rvalue gccjit rvalue gccjit location}@anchor{143} +@anchor{cp/topics/expressions gccjit context new_ne__gccjit rvalue gccjit rvalue gccjit location}@anchor{145} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_ne (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_lt (C++ function) -@anchor{cp/topics/expressions gccjit context new_lt__gccjit rvalue gccjit rvalue gccjit location}@anchor{144} +@anchor{cp/topics/expressions gccjit context new_lt__gccjit rvalue gccjit rvalue gccjit location}@anchor{146} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_lt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_le (C++ function) -@anchor{cp/topics/expressions gccjit context new_le__gccjit rvalue gccjit rvalue gccjit location}@anchor{145} +@anchor{cp/topics/expressions gccjit context new_le__gccjit rvalue gccjit rvalue gccjit location}@anchor{147} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_le (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_gt (C++ function) -@anchor{cp/topics/expressions gccjit context new_gt__gccjit rvalue gccjit rvalue gccjit location}@anchor{146} +@anchor{cp/topics/expressions gccjit context new_gt__gccjit rvalue gccjit rvalue gccjit location}@anchor{148} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_gt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_ge (C++ function) -@anchor{cp/topics/expressions gccjit context new_ge__gccjit rvalue gccjit rvalue gccjit location}@anchor{147} +@anchor{cp/topics/expressions gccjit context new_ge__gccjit rvalue gccjit rvalue gccjit location}@anchor{149} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_ge (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn The most concise way to spell them is with overloaded operators: @geindex operator== (C++ function) -@anchor{cp/topics/expressions eq-operator__gccjit rvalue gccjit rvalue}@anchor{148} +@anchor{cp/topics/expressions eq-operator__gccjit rvalue gccjit rvalue}@anchor{14a} @deffn {C++ Function} gccjit::rvalue operator== (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11187,7 +11246,7 @@ gccjit::rvalue cond = (a == ctxt.zero (t_int)); @end deffn @geindex operator!= (C++ function) -@anchor{cp/topics/expressions neq-operator__gccjit rvalue gccjit rvalue}@anchor{149} +@anchor{cp/topics/expressions neq-operator__gccjit rvalue gccjit rvalue}@anchor{14b} @deffn {C++ Function} gccjit::rvalue operator!= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11198,7 +11257,7 @@ gccjit::rvalue cond = (i != j); @end deffn @geindex operator< (C++ function) -@anchor{cp/topics/expressions lt-operator__gccjit rvalue gccjit rvalue}@anchor{14a} +@anchor{cp/topics/expressions lt-operator__gccjit rvalue gccjit rvalue}@anchor{14c} @deffn {C++ Function} gccjit::rvalue operator< (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11209,7 +11268,7 @@ gccjit::rvalue cond = i < n; @end deffn @geindex operator<= (C++ function) -@anchor{cp/topics/expressions lte-operator__gccjit rvalue gccjit rvalue}@anchor{14b} +@anchor{cp/topics/expressions lte-operator__gccjit rvalue gccjit rvalue}@anchor{14d} @deffn {C++ Function} gccjit::rvalue operator<= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11220,7 +11279,7 @@ gccjit::rvalue cond = i <= n; @end deffn @geindex operator> (C++ function) -@anchor{cp/topics/expressions gt-operator__gccjit rvalue gccjit rvalue}@anchor{14c} +@anchor{cp/topics/expressions gt-operator__gccjit rvalue gccjit rvalue}@anchor{14e} @deffn {C++ Function} gccjit::rvalue operator> (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11231,7 +11290,7 @@ gccjit::rvalue cond = (ch > limit); @end deffn @geindex operator>= (C++ function) -@anchor{cp/topics/expressions gte-operator__gccjit rvalue gccjit rvalue}@anchor{14d} +@anchor{cp/topics/expressions gte-operator__gccjit rvalue gccjit rvalue}@anchor{14f} @deffn {C++ Function} gccjit::rvalue operator>= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11244,12 +11303,12 @@ gccjit::rvalue cond = (score >= ctxt.new_rvalue (t_int, 100)); @c TODO: beyond this point @node Function calls<2>,Type-coercion<2>,Comparisons<2>,Rvalues<2> -@anchor{cp/topics/expressions function-calls}@anchor{14e} +@anchor{cp/topics/expressions function-calls}@anchor{150} @subsubsection Function calls @geindex gcc_jit_context_new_call (C++ function) -@anchor{cp/topics/expressions gcc_jit_context_new_call__gcc_jit_contextP gcc_jit_locationP gcc_jit_functionP i gcc_jit_rvaluePP}@anchor{14f} +@anchor{cp/topics/expressions gcc_jit_context_new_call__gcc_jit_contextP gcc_jit_locationP gcc_jit_functionP i gcc_jit_rvaluePP}@anchor{151} @deffn {C++ Function} gcc_jit_rvalue* gcc_jit_context_new_call (gcc_jit_context* ctxt, gcc_jit_location* loc, gcc_jit_function* func, int numargs, gcc_jit_rvalue** args) Given a function and the given table of argument rvalues, construct a @@ -11258,14 +11317,14 @@ call to the function, with the result as an rvalue. @cartouche @quotation Note @code{gccjit::context::new_call()} merely builds a -@pxref{11d,,gccjit;;rvalue} i.e. an expression that can be evaluated, +@pxref{11f,,gccjit;;rvalue} i.e. an expression that can be evaluated, perhaps as part of a more complicated expression. The call @emph{won't} happen unless you add a statement to a function that evaluates the expression. For example, if you want to call a function and discard the result (or to call a function with @code{void} return type), use -@pxref{150,,gccjit;;block;;add_eval()}: +@pxref{152,,gccjit;;block;;add_eval()}: @example /* Add "(void)printf (arg0, arg1);". */ @@ -11278,12 +11337,12 @@ block.add_eval (ctxt.new_call (printf_func, arg0, arg1)); @end deffn @node Type-coercion<2>,,Function calls<2>,Rvalues<2> -@anchor{cp/topics/expressions type-coercion}@anchor{151} +@anchor{cp/topics/expressions type-coercion}@anchor{153} @subsubsection Type-coercion @geindex gccjit;;context;;new_cast (C++ function) -@anchor{cp/topics/expressions gccjit context new_cast__gccjit rvalue gccjit type gccjit location}@anchor{152} +@anchor{cp/topics/expressions gccjit context new_cast__gccjit rvalue gccjit type gccjit location}@anchor{154} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_cast (gccjit::rvalue rvalue, gccjit::type type, gccjit::location loc) Given an rvalue of T, construct another rvalue of another type. @@ -11308,24 +11367,24 @@ P* <-> Q*, for pointer types P and Q @end deffn @node Lvalues<2>,Working with pointers structs and unions<2>,Rvalues<2>,Expressions<2> -@anchor{cp/topics/expressions lvalues}@anchor{153} +@anchor{cp/topics/expressions lvalues}@anchor{155} @subsubsection Lvalues @geindex gccjit;;lvalue (C++ class) -@anchor{cp/topics/expressions gccjit lvalue}@anchor{154} +@anchor{cp/topics/expressions gccjit lvalue}@anchor{156} @deffn {C++ Class} gccjit::lvalue @end deffn An lvalue is something that can of the @emph{left}-hand side of an assignment: a storage area (such as a variable). It is a subclass of -@pxref{11d,,gccjit;;rvalue}, where the rvalue is computed by reading from the +@pxref{11f,,gccjit;;rvalue}, where the rvalue is computed by reading from the storage area. It iss a thin wrapper around @pxref{24,,gcc_jit_lvalue *} from the C API. @geindex gccjit;;lvalue;;get_address (C++ function) -@anchor{cp/topics/expressions gccjit lvalue get_address__gccjit location}@anchor{155} +@anchor{cp/topics/expressions gccjit lvalue get_address__gccjit location}@anchor{157} @deffn {C++ Function} gccjit::rvalue gccjit::lvalue::get_address (gccjit::location loc) Take the address of an lvalue; analogous to: @@ -11347,24 +11406,24 @@ Parameter "loc" is optional. @end menu @node Global variables<2>,,,Lvalues<2> -@anchor{cp/topics/expressions global-variables}@anchor{156} +@anchor{cp/topics/expressions global-variables}@anchor{158} @subsubsection Global variables @geindex gccjit;;context;;new_global (C++ function) -@anchor{cp/topics/expressions gccjit context new_global__gccjit type cCP gccjit location}@anchor{157} +@anchor{cp/topics/expressions gccjit context new_global__gccjit type cCP gccjit location}@anchor{159} @deffn {C++ Function} gccjit::lvalue gccjit::context::new_global (gccjit::type type, const char* name, gccjit::location loc) Add a new global variable of the given type and name to the context. @end deffn @node Working with pointers structs and unions<2>,,Lvalues<2>,Expressions<2> -@anchor{cp/topics/expressions working-with-pointers-structs-and-unions}@anchor{158} +@anchor{cp/topics/expressions working-with-pointers-structs-and-unions}@anchor{15a} @subsubsection Working with pointers, structs and unions @geindex gccjit;;rvalue;;dereference (C++ function) -@anchor{cp/topics/expressions gccjit rvalue dereference__gccjit location}@anchor{159} +@anchor{cp/topics/expressions gccjit rvalue dereference__gccjit location}@anchor{15b} @deffn {C++ Function} gccjit::lvalue gccjit::rvalue::dereference (gccjit::location loc) Given an rvalue of pointer type @code{T *}, dereferencing the pointer, @@ -11397,7 +11456,7 @@ gccjit::lvalue content = *ptr; Field access is provided separately for both lvalues and rvalues: @geindex gccjit;;lvalue;;access_field (C++ function) -@anchor{cp/topics/expressions gccjit lvalue access_field__gccjit field gccjit location}@anchor{15a} +@anchor{cp/topics/expressions gccjit lvalue access_field__gccjit field gccjit location}@anchor{15c} @deffn {C++ Function} gccjit::lvalue gccjit::lvalue::access_field (gccjit::field field, gccjit::location loc) Given an lvalue of struct or union type, access the given field, @@ -11413,7 +11472,7 @@ in C. @end deffn @geindex gccjit;;rvalue;;access_field (C++ function) -@anchor{cp/topics/expressions gccjit rvalue access_field__gccjit field gccjit location}@anchor{15b} +@anchor{cp/topics/expressions gccjit rvalue access_field__gccjit field gccjit location}@anchor{15d} @deffn {C++ Function} gccjit::rvalue gccjit::rvalue::access_field (gccjit::field field, gccjit::location loc) Given an rvalue of struct or union type, access the given field @@ -11429,7 +11488,7 @@ in C. @end deffn @geindex gccjit;;rvalue;;dereference_field (C++ function) -@anchor{cp/topics/expressions gccjit rvalue dereference_field__gccjit field gccjit location}@anchor{15c} +@anchor{cp/topics/expressions gccjit rvalue dereference_field__gccjit field gccjit location}@anchor{15e} @deffn {C++ Function} gccjit::lvalue gccjit::rvalue::dereference_field (gccjit::field field, gccjit::location loc) Given an rvalue of pointer type @code{T *} where T is of struct or union @@ -11445,7 +11504,7 @@ in C, itself equivalent to @code{(*EXPR).FIELD}. @end deffn @geindex gccjit;;context;;new_array_access (C++ function) -@anchor{cp/topics/expressions gccjit context new_array_access__gccjit rvalue gccjit rvalue gccjit location}@anchor{15d} +@anchor{cp/topics/expressions gccjit context new_array_access__gccjit rvalue gccjit rvalue gccjit location}@anchor{15f} @deffn {C++ Function} gccjit::lvalue gccjit::context::new_array_access (gccjit::rvalue ptr, gccjit::rvalue index, gccjit::location loc) Given an rvalue of pointer type @code{T *}, get at the element @cite{T} at @@ -11464,7 +11523,7 @@ in C (or, indeed, to @code{PTR + INDEX}). Parameter "loc" is optional. @end deffn -For array accesses where you don't need to specify a @pxref{ff,,gccjit;;location}, +For array accesses where you don't need to specify a @pxref{101,,gccjit;;location}, two overloaded operators are available: @quotation @@ -11504,7 +11563,7 @@ gccjit::lvalue element = array[0]; @c <http://www.gnu.org/licenses/>. @node Creating and using functions<2>,Source Locations<2>,Expressions<2>,Topic Reference<2> -@anchor{cp/topics/functions doc}@anchor{15e}@anchor{cp/topics/functions creating-and-using-functions}@anchor{15f} +@anchor{cp/topics/functions doc}@anchor{160}@anchor{cp/topics/functions creating-and-using-functions}@anchor{161} @subsection Creating and using functions @@ -11517,36 +11576,36 @@ gccjit::lvalue element = array[0]; @end menu @node Params<2>,Functions<2>,,Creating and using functions<2> -@anchor{cp/topics/functions params}@anchor{160} +@anchor{cp/topics/functions params}@anchor{162} @subsubsection Params @geindex gccjit;;param (C++ class) -@anchor{cp/topics/functions gccjit param}@anchor{161} +@anchor{cp/topics/functions gccjit param}@anchor{163} @deffn {C++ Class} gccjit::param A @cite{gccjit::param} represents a parameter to a function. @end deffn @geindex gccjit;;context;;new_param (C++ function) -@anchor{cp/topics/functions gccjit context new_param__gccjit type cCP gccjit location}@anchor{ce} +@anchor{cp/topics/functions gccjit context new_param__gccjit type cCP gccjit location}@anchor{d0} @deffn {C++ Function} gccjit::param gccjit::context::new_param (gccjit::type type, const char* name, gccjit::location loc) In preparation for creating a function, create a new parameter of the given type and name. @end deffn -@pxref{161,,gccjit;;param} is a subclass of @pxref{154,,gccjit;;lvalue} (and thus -of @pxref{11d,,gccjit;;rvalue} and @pxref{107,,gccjit;;object}). It is a thin +@pxref{163,,gccjit;;param} is a subclass of @pxref{156,,gccjit;;lvalue} (and thus +of @pxref{11f,,gccjit;;rvalue} and @pxref{109,,gccjit;;object}). It is a thin wrapper around the C API's @pxref{25,,gcc_jit_param *}. @node Functions<2>,Blocks<2>,Params<2>,Creating and using functions<2> -@anchor{cp/topics/functions functions}@anchor{162} +@anchor{cp/topics/functions functions}@anchor{164} @subsubsection Functions @geindex gccjit;;function (C++ class) -@anchor{cp/topics/functions gccjit function}@anchor{163} +@anchor{cp/topics/functions gccjit function}@anchor{165} @deffn {C++ Class} gccjit::function A @cite{gccjit::function} represents a function - either one that we're @@ -11564,29 +11623,29 @@ This is a wrapper around the C API's @pxref{11,,gcc_jit_context_new_function()}. @end deffn @geindex gccjit;;context;;get_builtin_function (C++ function) -@anchor{cp/topics/functions gccjit context get_builtin_function__cCP}@anchor{164} +@anchor{cp/topics/functions gccjit context get_builtin_function__cCP}@anchor{166} @deffn {C++ Function} gccjit::function gccjit::context::get_builtin_function (const char* name) This is a wrapper around the C API's -@pxref{b2,,gcc_jit_context_get_builtin_function()}. +@pxref{b4,,gcc_jit_context_get_builtin_function()}. @end deffn @geindex gccjit;;function;;get_param (C++ function) -@anchor{cp/topics/functions gccjit function get_param__iC}@anchor{165} +@anchor{cp/topics/functions gccjit function get_param__iC}@anchor{167} @deffn {C++ Function} gccjit::param gccjit::function::get_param (int index) const Get the param of the given index (0-based). @end deffn @geindex gccjit;;function;;dump_to_dot (C++ function) -@anchor{cp/topics/functions gccjit function dump_to_dot__cCP}@anchor{e1} +@anchor{cp/topics/functions gccjit function dump_to_dot__cCP}@anchor{e3} @deffn {C++ Function} void gccjit::function::dump_to_dot (const char* path) Emit the function in graphviz format to the given path. @end deffn @geindex gccjit;;function;;new_local (C++ function) -@anchor{cp/topics/functions gccjit function new_local__gccjit type cCP gccjit location}@anchor{d8} +@anchor{cp/topics/functions gccjit function new_local__gccjit type cCP gccjit location}@anchor{da} @deffn {C++ Function} gccjit::lvalue gccjit::function::new_local (gccjit::type type, const char* name, gccjit::location loc) Create a new local variable within the function, of the given type and @@ -11594,19 +11653,19 @@ name. @end deffn @node Blocks<2>,Statements<2>,Functions<2>,Creating and using functions<2> -@anchor{cp/topics/functions blocks}@anchor{166} +@anchor{cp/topics/functions blocks}@anchor{168} @subsubsection Blocks @geindex gccjit;;block (C++ class) -@anchor{cp/topics/functions gccjit block}@anchor{167} +@anchor{cp/topics/functions gccjit block}@anchor{169} @deffn {C++ Class} gccjit::block A @cite{gccjit::block} represents a basic block within a function i.e. a sequence of statements with a single entry point and a single exit point. -@pxref{167,,gccjit;;block} is a subclass of @pxref{107,,gccjit;;object}. +@pxref{169,,gccjit;;block} is a subclass of @pxref{109,,gccjit;;object}. The first basic block that you create within a function will be the entrypoint. @@ -11619,7 +11678,7 @@ one function. @end deffn @geindex gccjit;;function;;new_block (C++ function) -@anchor{cp/topics/functions gccjit function new_block__cCP}@anchor{168} +@anchor{cp/topics/functions gccjit function new_block__cCP}@anchor{16a} @deffn {C++ Function} gccjit::block gccjit::function::new_block (const char* name) Create a basic block of the given name. The name may be NULL, but @@ -11629,12 +11688,12 @@ messages. @end deffn @node Statements<2>,,Blocks<2>,Creating and using functions<2> -@anchor{cp/topics/functions statements}@anchor{169} +@anchor{cp/topics/functions statements}@anchor{16b} @subsubsection Statements @geindex gccjit;;block;;add_eval (C++ function) -@anchor{cp/topics/functions gccjit block add_eval__gccjit rvalue gccjit location}@anchor{150} +@anchor{cp/topics/functions gccjit block add_eval__gccjit rvalue gccjit location}@anchor{152} @deffn {C++ Function} void gccjit::block::add_eval (gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, discarding the result @@ -11650,7 +11709,7 @@ This is equivalent to this C code: @end deffn @geindex gccjit;;block;;add_assignment (C++ function) -@anchor{cp/topics/functions gccjit block add_assignment__gccjit lvalue gccjit rvalue gccjit location}@anchor{da} +@anchor{cp/topics/functions gccjit block add_assignment__gccjit lvalue gccjit rvalue gccjit location}@anchor{dc} @deffn {C++ Function} void gccjit::block::add_assignment (gccjit::lvalue lvalue, gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, assigning the result to the given @@ -11666,7 +11725,7 @@ lvalue = rvalue; @end deffn @geindex gccjit;;block;;add_assignment_op (C++ function) -@anchor{cp/topics/functions gccjit block add_assignment_op__gccjit lvalue enum gccjit rvalue gccjit location}@anchor{de} +@anchor{cp/topics/functions gccjit block add_assignment_op__gccjit lvalue enum gccjit rvalue gccjit location}@anchor{e0} @deffn {C++ Function} void gccjit::block::add_assignment_op (gccjit::lvalue lvalue, enum gcc_jit_binary_op, gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, using the result to modify an @@ -11696,12 +11755,12 @@ loop_body.add_assignment_op ( @end deffn @geindex gccjit;;block;;add_comment (C++ function) -@anchor{cp/topics/functions gccjit block add_comment__cCP gccjit location}@anchor{e9} +@anchor{cp/topics/functions gccjit block add_comment__cCP gccjit location}@anchor{eb} @deffn {C++ Function} void gccjit::block::add_comment (const char* text, gccjit::location loc) Add a no-op textual comment to the internal representation of the code. It will be optimized away, but will be visible in the dumps -seen via @pxref{5b,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE} +seen via @pxref{5d,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE} and @pxref{1c,,GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE}, and thus may be of use when debugging how your project's internal representation gets converted to the libgccjit IR. @@ -11710,7 +11769,7 @@ Parameter "loc" is optional. @end deffn @geindex gccjit;;block;;end_with_conditional (C++ function) -@anchor{cp/topics/functions gccjit block end_with_conditional__gccjit rvalue gccjit block gccjit block gccjit location}@anchor{dd} +@anchor{cp/topics/functions gccjit block end_with_conditional__gccjit rvalue gccjit block gccjit block gccjit location}@anchor{df} @deffn {C++ Function} void gccjit::block::end_with_conditional (gccjit::rvalue boolval, gccjit::block on_true, gccjit::block on_false, gccjit::location loc) Terminate a block by adding evaluation of an rvalue, branching on the @@ -11731,7 +11790,7 @@ block, boolval, on_true, and on_false must be non-NULL. @end deffn @geindex gccjit;;block;;end_with_jump (C++ function) -@anchor{cp/topics/functions gccjit block end_with_jump__gccjit block gccjit location}@anchor{16a} +@anchor{cp/topics/functions gccjit block end_with_jump__gccjit block gccjit location}@anchor{16c} @deffn {C++ Function} void gccjit::block::end_with_jump (gccjit::block target, gccjit::location loc) Terminate a block by adding a jump to the given target block. @@ -11746,7 +11805,7 @@ goto target; @end deffn @geindex gccjit;;block;;end_with_return (C++ function) -@anchor{cp/topics/functions gccjit block end_with_return__gccjit rvalue gccjit location}@anchor{16b} +@anchor{cp/topics/functions gccjit block end_with_return__gccjit rvalue gccjit location}@anchor{16d} @deffn {C++ Function} void gccjit::block::end_with_return (gccjit::rvalue rvalue, gccjit::location loc) Terminate a block. @@ -11797,12 +11856,12 @@ return; @c <http://www.gnu.org/licenses/>. @node Source Locations<2>,Compilation results<2>,Creating and using functions<2>,Topic Reference<2> -@anchor{cp/topics/locations source-locations}@anchor{16c}@anchor{cp/topics/locations doc}@anchor{16d} +@anchor{cp/topics/locations source-locations}@anchor{16e}@anchor{cp/topics/locations doc}@anchor{16f} @subsection Source Locations @geindex gccjit;;location (C++ class) -@anchor{cp/topics/locations gccjit location}@anchor{ff} +@anchor{cp/topics/locations gccjit location}@anchor{101} @deffn {C++ Class} gccjit::location A @cite{gccjit::location} encapsulates a source code location, so that @@ -11813,10 +11872,10 @@ single-step through your language. @cite{gccjit::location} instances are optional: you can always omit them from any C++ API entrypoint accepting one. -You can construct them using @pxref{ed,,gccjit;;context;;new_location()}. +You can construct them using @pxref{ef,,gccjit;;context;;new_location()}. You need to enable @pxref{42,,GCC_JIT_BOOL_OPTION_DEBUGINFO} on the -@pxref{f7,,gccjit;;context} for these locations to actually be usable by +@pxref{f9,,gccjit;;context} for these locations to actually be usable by the debugger: @example @@ -11827,7 +11886,7 @@ ctxt.set_bool_option (GCC_JIT_BOOL_OPTION_DEBUGINFO, 1); @end deffn @geindex gccjit;;context;;new_location (C++ function) -@anchor{cp/topics/locations gccjit context new_location__cCP i i}@anchor{ed} +@anchor{cp/topics/locations gccjit context new_location__cCP i i}@anchor{ef} @deffn {C++ Function} gccjit::location gccjit::context::new_location (const char* filename, int line, int column) Create a @cite{gccjit::location} instance representing the given source @@ -11840,13 +11899,13 @@ location. @end menu @node Faking it<2>,,,Source Locations<2> -@anchor{cp/topics/locations faking-it}@anchor{16e} +@anchor{cp/topics/locations faking-it}@anchor{170} @subsubsection Faking it If you don't have source code for your internal representation, but need to debug, you can generate a C-like representation of the functions in -your context using @pxref{fe,,gccjit;;context;;dump_to_file()}: +your context using @pxref{100,,gccjit;;context;;dump_to_file()}: @example ctxt.dump_to_file ("/tmp/something.c", @@ -11878,27 +11937,27 @@ file, giving you @emph{something} you can step through in the debugger. @c <http://www.gnu.org/licenses/>. @node Compilation results<2>,,Source Locations<2>,Topic Reference<2> -@anchor{cp/topics/results compilation-results}@anchor{16f}@anchor{cp/topics/results doc}@anchor{170} +@anchor{cp/topics/results compilation-results}@anchor{171}@anchor{cp/topics/results doc}@anchor{172} @subsection Compilation results @geindex gcc_jit_result (C++ type) -@anchor{cp/topics/results gcc_jit_result}@anchor{171} +@anchor{cp/topics/results gcc_jit_result}@anchor{173} @deffn {C++ Type} gcc_jit_result A @cite{gcc_jit_result} encapsulates the result of compiling a context. @end deffn @geindex gccjit;;context;;compile (C++ function) -@anchor{cp/topics/results gccjit context compile}@anchor{d0} -@deffn {C++ Function} @pxref{171,,gcc_jit_result*} gccjit::context::compile () +@anchor{cp/topics/results gccjit context compile}@anchor{d2} +@deffn {C++ Function} @pxref{173,,gcc_jit_result*} gccjit::context::compile () This calls into GCC and builds the code, returning a @cite{gcc_jit_result *}. @end deffn @geindex gcc_jit_result_get_code (C++ function) -@anchor{cp/topics/results gcc_jit_result_get_code__gcc_jit_resultP cCP}@anchor{172} +@anchor{cp/topics/results gcc_jit_result_get_code__gcc_jit_resultP cCP}@anchor{174} @deffn {C++ Function} void* gcc_jit_result_get_code (gcc_jit_result* result, const char* funcname) Locate a given function within the built machine code. @@ -11907,7 +11966,7 @@ correct type before it can be called. @end deffn @geindex gcc_jit_result_release (C++ function) -@anchor{cp/topics/results gcc_jit_result_release__gcc_jit_resultP}@anchor{173} +@anchor{cp/topics/results gcc_jit_result_release__gcc_jit_resultP}@anchor{175} @deffn {C++ Function} void gcc_jit_result_release (gcc_jit_result* result) Once we're done with the code, this unloads the built .so file. @@ -11933,7 +11992,7 @@ valid to use the result. @c <http://www.gnu.org/licenses/>. @node Internals,Indices and tables,C++ bindings for libgccjit,Top -@anchor{internals/index internals}@anchor{174}@anchor{internals/index doc}@anchor{175} +@anchor{internals/index internals}@anchor{176}@anchor{internals/index doc}@anchor{177} @chapter Internals @@ -11946,7 +12005,7 @@ valid to use the result. @end menu @node Working on the JIT library,Running the test suite,,Internals -@anchor{internals/index working-on-the-jit-library}@anchor{176} +@anchor{internals/index working-on-the-jit-library}@anchor{178} @section Working on the JIT library @@ -11983,7 +12042,7 @@ gcc/libgccjit.so.0.0.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), Here's what those configuration options mean: @geindex command line option; --enable-host-shared -@anchor{internals/index cmdoption--enable-host-shared}@anchor{177} +@anchor{internals/index cmdoption--enable-host-shared}@anchor{179} @deffn {Option} --enable-host-shared Configuring with this option means that the compiler is built as @@ -11992,7 +12051,7 @@ but it necessary for a shared library. @end deffn @geindex command line option; --enable-languages=jit@comma{}c++ -@anchor{internals/index cmdoption--enable-languages}@anchor{178} +@anchor{internals/index cmdoption--enable-languages}@anchor{17a} @deffn {Option} --enable-languages=jit,c++ This specifies which frontends to build. The JIT library looks like @@ -12011,7 +12070,7 @@ c++: error trying to exec 'cc1plus': execvp: No such file or directory @end deffn @geindex command line option; --disable-bootstrap -@anchor{internals/index cmdoption--disable-bootstrap}@anchor{179} +@anchor{internals/index cmdoption--disable-bootstrap}@anchor{17b} @deffn {Option} --disable-bootstrap For hacking on the "jit" subdirectory, performing a full @@ -12021,7 +12080,7 @@ the compiler can still bootstrap itself. @end deffn @geindex command line option; --enable-checking=release -@anchor{internals/index cmdoption--enable-checking}@anchor{17a} +@anchor{internals/index cmdoption--enable-checking}@anchor{17c} @deffn {Option} --enable-checking=release The compile can perform extensive self-checking as it runs, useful when @@ -12032,7 +12091,7 @@ disable this self-checking. @end deffn @node Running the test suite,Environment variables,Working on the JIT library,Internals -@anchor{internals/index running-the-test-suite}@anchor{17b} +@anchor{internals/index running-the-test-suite}@anchor{17d} @section Running the test suite @@ -12095,7 +12154,7 @@ and once a test has been compiled, you can debug it directly: @end menu @node Running under valgrind,,,Running the test suite -@anchor{internals/index running-under-valgrind}@anchor{17c} +@anchor{internals/index running-under-valgrind}@anchor{17e} @subsection Running under valgrind @@ -12143,7 +12202,7 @@ When running under valgrind, it's best to have configured gcc with various known false positives. @node Environment variables,Overview of code structure,Running the test suite,Internals -@anchor{internals/index environment-variables}@anchor{17d} +@anchor{internals/index environment-variables}@anchor{17f} @section Environment variables @@ -12151,7 +12210,7 @@ When running client code against a locally-built libgccjit, three environment variables need to be set up: @geindex environment variable; LD_LIBRARY_PATH -@anchor{internals/index envvar-LD_LIBRARY_PATH}@anchor{17e} +@anchor{internals/index envvar-LD_LIBRARY_PATH}@anchor{180} @deffn {Environment Variable} LD_LIBRARY_PATH @quotation @@ -12173,7 +12232,7 @@ libgccjit.so.0.0.1: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), @end deffn @geindex environment variable; PATH -@anchor{internals/index envvar-PATH}@anchor{17f} +@anchor{internals/index envvar-PATH}@anchor{181} @deffn {Environment Variable} PATH The library uses a driver executable for converting from .s assembler @@ -12192,7 +12251,7 @@ of development. @end deffn @geindex environment variable; LIBRARY_PATH -@anchor{internals/index envvar-LIBRARY_PATH}@anchor{180} +@anchor{internals/index envvar-LIBRARY_PATH}@anchor{182} @deffn {Environment Variable} LIBRARY_PATH The driver executable invokes the linker, and the latter needs to locate @@ -12228,7 +12287,7 @@ hello world @noindent @node Overview of code structure,,Environment variables,Internals -@anchor{internals/index overview-of-code-structure}@anchor{181} +@anchor{internals/index overview-of-code-structure}@anchor{183} @section Overview of code structure @@ -12490,9 +12549,145 @@ these associations only exist within a part of the code where the GC doesn't collect, and are set back to NULL before the GC can run. @end quotation +@anchor{internals/index example-of-log-file}@anchor{54} +Another way to understand the structure of the code is to enable logging, +via @pxref{53,,gcc_jit_context_set_logfile()}. Here is an example of a log +generated via this call: + +@example +JIT: entering: gcc_jit_context_set_str_option +JIT: exiting: gcc_jit_context_set_str_option +JIT: entering: gcc_jit_context_set_int_option +JIT: exiting: gcc_jit_context_set_int_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_new_param +JIT: exiting: gcc_jit_context_new_param +JIT: entering: gcc_jit_context_new_function +JIT: exiting: gcc_jit_context_new_function +JIT: entering: gcc_jit_context_new_param +JIT: exiting: gcc_jit_context_new_param +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_new_function +JIT: exiting: gcc_jit_context_new_function +JIT: entering: gcc_jit_context_new_string_literal +JIT: exiting: gcc_jit_context_new_string_literal +JIT: entering: gcc_jit_function_new_block +JIT: exiting: gcc_jit_function_new_block +JIT: entering: gcc_jit_block_add_comment +JIT: exiting: gcc_jit_block_add_comment +JIT: entering: gcc_jit_context_new_call +JIT: exiting: gcc_jit_context_new_call +JIT: entering: gcc_jit_block_add_eval +JIT: exiting: gcc_jit_block_add_eval +JIT: entering: gcc_jit_block_end_with_void_return +JIT: exiting: gcc_jit_block_end_with_void_return +JIT: entering: gcc_jit_context_compile +JIT: compiling ctxt: 0x1283e20 +JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile() +JIT: entering: void gcc::jit::recording::context::validate() +JIT: exiting: void gcc::jit::recording::context::validate() +JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*) +JIT: exiting: gcc::jit::playback::context::context(gcc::jit::recording::context*) +JIT: entering: gcc::jit::result* gcc::jit::playback::context::compile() +JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: entering: void gcc::jit::playback::context::acquire_mutex() +JIT: exiting: void gcc::jit::playback::context::acquire_mutex() +JIT: entering: toplev::main +JIT: argv[0]: ./test-hello-world.c.exe +JIT: argv[1]: /tmp/libgccjit-CKq1M9/fake.c +JIT: argv[2]: -fPIC +JIT: argv[3]: -O3 +JIT: argv[4]: -g +JIT: argv[5]: -quiet +JIT: argv[6]: --param +JIT: argv[7]: ggc-min-expand=0 +JIT: argv[8]: --param +JIT: argv[9]: ggc-min-heapsize=0 +JIT: entering: bool jit_langhook_init() +JIT: exiting: bool jit_langhook_init() +JIT: entering: void gcc::jit::playback::context::replay() +JIT: entering: void gcc::jit::recording::context::replay_into(gcc::jit::replayer*) +JIT: exiting: void gcc::jit::recording::context::replay_into(gcc::jit::replayer*) +JIT: entering: void gcc::jit::recording::context::disassociate_from_playback() +JIT: exiting: void gcc::jit::recording::context::disassociate_from_playback() +JIT: entering: void gcc::jit::playback::context::handle_locations() +JIT: exiting: void gcc::jit::playback::context::handle_locations() +JIT: entering: void gcc::jit::playback::function::build_stmt_list() +JIT: exiting: void gcc::jit::playback::function::build_stmt_list() +JIT: entering: void gcc::jit::playback::function::build_stmt_list() +JIT: exiting: void gcc::jit::playback::function::build_stmt_list() +JIT: entering: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::function::postprocess() +JIT: entering: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::context::replay() +JIT: entering: void jit_langhook_write_globals() +JIT: exiting: void jit_langhook_write_globals() +JIT: exiting: toplev::main +JIT: entering: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*) +JIT: exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*) +JIT: entering: toplev::finalize +JIT: exiting: toplev::finalize +JIT: entering: void gcc::jit::playback::context::convert_to_dso(const char*) +JIT: argv[0]: x86_64-unknown-linux-gnu-gcc-5.0.0 +JIT: argv[1]: -shared +JIT: argv[2]: /tmp/libgccjit-CKq1M9/fake.s +JIT: argv[3]: -o +JIT: argv[4]: /tmp/libgccjit-CKq1M9/fake.so +JIT: argv[5]: -fno-use-linker-plugin +JIT: argv[6]: (null) +JIT: exiting: void gcc::jit::playback::context::convert_to_dso(const char*) +JIT: entering: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso() +JIT: entering: gcc::jit::result::result(gcc::jit::logger*, void*) +JIT: exiting: gcc::jit::result::result(gcc::jit::logger*, void*) +JIT: exiting: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso() +JIT: entering: void gcc::jit::playback::context::release_mutex() +JIT: exiting: void gcc::jit::playback::context::release_mutex() +JIT: exiting: gcc::jit::result* gcc::jit::playback::context::compile() +JIT: entering: gcc::jit::playback::context::~context() +JIT: exiting: gcc::jit::playback::context::~context() +JIT: exiting: gcc::jit::result* gcc::jit::recording::context::compile() +JIT: gcc_jit_context_compile: returning (gcc_jit_result *)0x12f75d0 +JIT: exiting: gcc_jit_context_compile +JIT: entering: gcc_jit_result_get_code +JIT: locating fnname: hello_world +JIT: entering: void* gcc::jit::result::get_code(const char*) +JIT: exiting: void* gcc::jit::result::get_code(const char*) +JIT: gcc_jit_result_get_code: returning (void *)0x7ff6b8cd87f0 +JIT: exiting: gcc_jit_result_get_code +JIT: entering: gcc_jit_context_release +JIT: deleting ctxt: 0x1283e20 +JIT: entering: gcc::jit::recording::context::~context() +JIT: exiting: gcc::jit::recording::context::~context() +JIT: exiting: gcc_jit_context_release +JIT: entering: gcc_jit_result_release +JIT: deleting result: 0x12f75d0 +JIT: entering: virtual gcc::jit::result::~result() +JIT: exiting: virtual gcc::jit::result::~result() +JIT: exiting: gcc_jit_result_release +JIT: gcc::jit::logger::~logger() + +@end example + +@noindent @node Indices and tables,Index,Internals,Top -@anchor{index indices-and-tables}@anchor{182} +@anchor{index indices-and-tables}@anchor{184} @unnumbered Indices and tables diff --git a/gcc/jit/docs/internals/index.rst b/gcc/jit/docs/internals/index.rst index 694f058..20ac337 100644 --- a/gcc/jit/docs/internals/index.rst +++ b/gcc/jit/docs/internals/index.rst @@ -268,3 +268,12 @@ Here is a high-level summary from ``jit-common.h``: .. include:: ../../jit-common.h :start-after: This comment is included by the docs. :end-before: End of comment for inclusion in the docs. */ + +.. _example-of-log-file: + +Another way to understand the structure of the code is to enable logging, +via :c:func:`gcc_jit_context_set_logfile`. Here is an example of a log +generated via this call: + +.. literalinclude:: test-hello-world.exe.log.txt + :lines: 1- diff --git a/gcc/jit/docs/internals/test-hello-world.exe.log.txt b/gcc/jit/docs/internals/test-hello-world.exe.log.txt new file mode 100644 index 0000000..a96d80f --- /dev/null +++ b/gcc/jit/docs/internals/test-hello-world.exe.log.txt @@ -0,0 +1,126 @@ +JIT: entering: gcc_jit_context_set_str_option +JIT: exiting: gcc_jit_context_set_str_option +JIT: entering: gcc_jit_context_set_int_option +JIT: exiting: gcc_jit_context_set_int_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_set_bool_option +JIT: exiting: gcc_jit_context_set_bool_option +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_new_param +JIT: exiting: gcc_jit_context_new_param +JIT: entering: gcc_jit_context_new_function +JIT: exiting: gcc_jit_context_new_function +JIT: entering: gcc_jit_context_new_param +JIT: exiting: gcc_jit_context_new_param +JIT: entering: gcc_jit_context_get_type +JIT: exiting: gcc_jit_context_get_type +JIT: entering: gcc_jit_context_new_function +JIT: exiting: gcc_jit_context_new_function +JIT: entering: gcc_jit_context_new_string_literal +JIT: exiting: gcc_jit_context_new_string_literal +JIT: entering: gcc_jit_function_new_block +JIT: exiting: gcc_jit_function_new_block +JIT: entering: gcc_jit_block_add_comment +JIT: exiting: gcc_jit_block_add_comment +JIT: entering: gcc_jit_context_new_call +JIT: exiting: gcc_jit_context_new_call +JIT: entering: gcc_jit_block_add_eval +JIT: exiting: gcc_jit_block_add_eval +JIT: entering: gcc_jit_block_end_with_void_return +JIT: exiting: gcc_jit_block_end_with_void_return +JIT: entering: gcc_jit_context_compile +JIT: compiling ctxt: 0x1283e20 +JIT: entering: gcc::jit::result* gcc::jit::recording::context::compile() +JIT: entering: void gcc::jit::recording::context::validate() +JIT: exiting: void gcc::jit::recording::context::validate() +JIT: entering: gcc::jit::playback::context::context(gcc::jit::recording::context*) +JIT: exiting: gcc::jit::playback::context::context(gcc::jit::recording::context*) +JIT: entering: gcc::jit::result* gcc::jit::playback::context::compile() +JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: entering: void gcc::jit::playback::context::acquire_mutex() +JIT: exiting: void gcc::jit::playback::context::acquire_mutex() +JIT: entering: toplev::main +JIT: argv[0]: ./test-hello-world.c.exe +JIT: argv[1]: /tmp/libgccjit-CKq1M9/fake.c +JIT: argv[2]: -fPIC +JIT: argv[3]: -O3 +JIT: argv[4]: -g +JIT: argv[5]: -quiet +JIT: argv[6]: --param +JIT: argv[7]: ggc-min-expand=0 +JIT: argv[8]: --param +JIT: argv[9]: ggc-min-heapsize=0 +JIT: entering: bool jit_langhook_init() +JIT: exiting: bool jit_langhook_init() +JIT: entering: void gcc::jit::playback::context::replay() +JIT: entering: void gcc::jit::recording::context::replay_into(gcc::jit::replayer*) +JIT: exiting: void gcc::jit::recording::context::replay_into(gcc::jit::replayer*) +JIT: entering: void gcc::jit::recording::context::disassociate_from_playback() +JIT: exiting: void gcc::jit::recording::context::disassociate_from_playback() +JIT: entering: void gcc::jit::playback::context::handle_locations() +JIT: exiting: void gcc::jit::playback::context::handle_locations() +JIT: entering: void gcc::jit::playback::function::build_stmt_list() +JIT: exiting: void gcc::jit::playback::function::build_stmt_list() +JIT: entering: void gcc::jit::playback::function::build_stmt_list() +JIT: exiting: void gcc::jit::playback::function::build_stmt_list() +JIT: entering: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::function::postprocess() +JIT: entering: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::function::postprocess() +JIT: exiting: void gcc::jit::playback::context::replay() +JIT: entering: void jit_langhook_write_globals() +JIT: exiting: void jit_langhook_write_globals() +JIT: exiting: toplev::main +JIT: entering: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*) +JIT: exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*) +JIT: entering: toplev::finalize +JIT: exiting: toplev::finalize +JIT: entering: void gcc::jit::playback::context::convert_to_dso(const char*) +JIT: argv[0]: x86_64-unknown-linux-gnu-gcc-5.0.0 +JIT: argv[1]: -shared +JIT: argv[2]: /tmp/libgccjit-CKq1M9/fake.s +JIT: argv[3]: -o +JIT: argv[4]: /tmp/libgccjit-CKq1M9/fake.so +JIT: argv[5]: -fno-use-linker-plugin +JIT: argv[6]: (null) +JIT: exiting: void gcc::jit::playback::context::convert_to_dso(const char*) +JIT: entering: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso() +JIT: entering: gcc::jit::result::result(gcc::jit::logger*, void*) +JIT: exiting: gcc::jit::result::result(gcc::jit::logger*, void*) +JIT: exiting: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso() +JIT: entering: void gcc::jit::playback::context::release_mutex() +JIT: exiting: void gcc::jit::playback::context::release_mutex() +JIT: exiting: gcc::jit::result* gcc::jit::playback::context::compile() +JIT: entering: gcc::jit::playback::context::~context() +JIT: exiting: gcc::jit::playback::context::~context() +JIT: exiting: gcc::jit::result* gcc::jit::recording::context::compile() +JIT: gcc_jit_context_compile: returning (gcc_jit_result *)0x12f75d0 +JIT: exiting: gcc_jit_context_compile +JIT: entering: gcc_jit_result_get_code +JIT: locating fnname: hello_world +JIT: entering: void* gcc::jit::result::get_code(const char*) +JIT: exiting: void* gcc::jit::result::get_code(const char*) +JIT: gcc_jit_result_get_code: returning (void *)0x7ff6b8cd87f0 +JIT: exiting: gcc_jit_result_get_code +JIT: entering: gcc_jit_context_release +JIT: deleting ctxt: 0x1283e20 +JIT: entering: gcc::jit::recording::context::~context() +JIT: exiting: gcc::jit::recording::context::~context() +JIT: exiting: gcc_jit_context_release +JIT: entering: gcc_jit_result_release +JIT: deleting result: 0x12f75d0 +JIT: entering: virtual gcc::jit::result::~result() +JIT: exiting: virtual gcc::jit::result::~result() +JIT: exiting: gcc_jit_result_release +JIT: gcc::jit::logger::~logger() diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index 626e7c8..6099c69 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -153,6 +153,56 @@ Debugging code in a debugger. .. function:: void\ + gcc_jit_context_set_logfile (gcc_jit_context *ctxt,\ + FILE *logfile,\ + int flags,\ + int verbosity) + + To help with debugging; enable ongoing logging of the context's + activity to the given file. + + For example, the following will enable logging to stderr. + + .. code-block:: c + + gcc_jit_context_set_logfile (ctxt, stderr, 0, 0); + + Examples of information logged include: + + * API calls + + * the various steps involved within compilation + + * activity on any :c:type:`gcc_jit_result` instances created by + the context + + * activity within any child contexts + + An example of a log can be seen :ref:`here <example-of-log-file>`, + though the precise format and kinds of information logged is subject + to change. + + The caller remains responsible for closing `logfile`, and it must not + be closed until all users are released. In particular, note that + child contexts and :c:type:`gcc_jit_result` instances created by + the context will use the logfile. + + There may a performance cost for logging. + + You can turn off logging on `ctxt` by passing `NULL` for `logfile`. + Doing so only affects the context; it does not affect child contexts + or :c:type:`gcc_jit_result` instances already created by + the context. + + The parameters "flags" and "verbosity" are reserved for future + expansion, and must be zero for now. + +To contrast the above: :c:func:`gcc_jit_context_dump_to_file` dumps the +current state of a context to the given path, whereas +:c:func:`gcc_jit_context_set_logfile` enables on-going logging of +future activies on a context to the given `FILE *`. + +.. function:: void\ gcc_jit_context_enable_dump (gcc_jit_context *ctxt,\ const char *dumpname, \ char **out_ptr) diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c index 9bea2c1..23883ad 100644 --- a/gcc/jit/dummy-frontend.c +++ b/gcc/jit/dummy-frontend.c @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "jit-common.h" +#include "jit-logging.h" #include "jit-playback.h" #include <mpfr.h> @@ -113,6 +114,9 @@ struct ggc_root_tab jit_root_tab[] = static bool jit_langhook_init (void) { + gcc_assert (gcc::jit::active_playback_ctxt); + JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ()); + static bool registered_root_tab = false; if (!registered_root_tab) { @@ -212,6 +216,9 @@ jit_langhook_getdecls (void) static void jit_langhook_write_globals (void) { + gcc_assert (gcc::jit::active_playback_ctxt); + JIT_LOG_SCOPE (gcc::jit::active_playback_ctxt->get_logger ()); + /* This is the hook that runs the middle and backends: */ symtab->finalize_compilation_unit (); } diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h index 4dd976e..80e1cbe 100644 --- a/gcc/jit/jit-common.h +++ b/gcc/jit/jit-common.h @@ -97,6 +97,7 @@ namespace jit { class result; class dump; +class logger; class builtins_manager; // declared within jit-builtins.h class tempdir; diff --git a/gcc/jit/jit-logging.c b/gcc/jit/jit-logging.c new file mode 100644 index 0000000..61b898b --- /dev/null +++ b/gcc/jit/jit-logging.c @@ -0,0 +1,168 @@ +/* Internals of libgccjit: logging + Copyright (C) 2014-2015 Free Software Foundation, Inc. + Contributed by David Malcolm <dmalcolm@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" + +#include "jit-logging.h" + +namespace gcc { + +namespace jit { + +/* Implementation of class gcc::jit::logger. */ + +/* The constructor for gcc::jit::logger, used by + gcc_jit_context_set_logfile. */ + +logger::logger (FILE *f_out, + int, /* flags */ + int /* verbosity */) : + m_refcount (0), + m_f_out (f_out), + m_indent_level (0), + m_log_refcount_changes (false) +{ +} + +/* The destructor for gcc::jit::logger, invoked via + the decref method when the refcount hits zero. + Note that we do not close the underlying FILE * (m_f_out). */ + +logger::~logger () +{ + /* This should be the last message emitted. */ + log ("%s", __PRETTY_FUNCTION__); + gcc_assert (m_refcount == 0); +} + +/* Increment the reference count of the gcc::jit::logger. */ + +void +logger::incref (const char *reason) +{ + m_refcount++; + if (m_log_refcount_changes) + log ("%s: reason: %s refcount now %i ", + __PRETTY_FUNCTION__, reason, m_refcount); +} + +/* Decrement the reference count of the gcc::jit::logger, + deleting it if nothing is referring to it. */ + +void +logger::decref (const char *reason) +{ + gcc_assert (m_refcount > 0); + --m_refcount; + if (m_log_refcount_changes) + log ("%s: reason: %s refcount now %i", + __PRETTY_FUNCTION__, reason, m_refcount); + if (0 == m_refcount) + delete this; +} + +/* Write a formatted message to the log, by calling the log_va method. */ + +void +logger::log (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + log_va (fmt, ap); + va_end (ap); +} + +/* Write an indented line to the log file. + + We explicitly flush after each line: if something crashes the process, + we want the logfile/stream to contain the most up-to-date hint about the + last thing that was happening, without it being hidden in an in-process + buffer. */ + +void +logger::log_va (const char *fmt, va_list ap) +{ + fprintf (m_f_out, "JIT: "); + for (int i = 0; i < m_indent_level; i++) + fputc (' ', m_f_out); + vfprintf (m_f_out, fmt, ap); + fprintf (m_f_out, "\n"); + fflush (m_f_out); +} + +/* Record the entry within a particular scope, indenting subsequent + log lines accordingly. */ + +void +logger::enter_scope (const char *scope_name) +{ + log ("entering: %s", scope_name); + m_indent_level += 1; +} + +/* Record the exit from a particular scope, restoring the indent level to + before the scope was entered. */ + +void +logger::exit_scope (const char *scope_name) +{ + if (m_indent_level) + m_indent_level -= 1; + else + log ("(mismatching indentation)"); + log ("exiting: %s", scope_name); +} + +/* Implementation of class gcc::jit::log_user. */ + +/* The constructor for gcc::jit::log_user. */ + +log_user::log_user (logger *logger) : m_logger (logger) +{ + if (m_logger) + m_logger->incref("log_user ctor"); +} + +/* The destructor for gcc::jit::log_user. */ + +log_user::~log_user () +{ + if (m_logger) + m_logger->decref("log_user dtor"); +} + +/* Set the logger for a gcc::jit::log_user, managing the reference counts + of the old and new logger (either of which might be NULL). */ + +void +log_user::set_logger (logger *logger) +{ + if (logger) + logger->incref ("log_user::set_logger"); + if (m_logger) + m_logger->decref ("log_user::set_logger"); + m_logger = logger; +} + +} // namespace gcc::jit + +} // namespace gcc diff --git a/gcc/jit/jit-logging.h b/gcc/jit/jit-logging.h new file mode 100644 index 0000000..581090c --- /dev/null +++ b/gcc/jit/jit-logging.h @@ -0,0 +1,191 @@ +/* Internals of libgccjit: logging + Copyright (C) 2014-2015 Free Software Foundation, Inc. + Contributed by David Malcolm <dmalcolm@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef JIT_LOGGING_H +#define JIT_LOGGING_H + +#include "jit-common.h" + +namespace gcc { + +namespace jit { + +/* A gcc::jit::logger encapsulates a logging stream: a way to send + lines of pertinent information to a FILE *. */ + +class logger +{ + public: + logger (FILE *f_out, int flags, int verbosity); + ~logger (); + + void incref (const char *reason); + void decref (const char *reason); + + void log (const char *fmt, ...) + GNU_PRINTF(2, 3); + void log_va (const char *fmt, va_list ap) + GNU_PRINTF(2, 0); + + void enter_scope (const char *scope_name); + void exit_scope (const char *scope_name); + +private: + int m_refcount; + FILE *m_f_out; + int m_indent_level; + bool m_log_refcount_changes; +}; + +/* The class gcc::jit::log_scope is an RAII-style class intended to make + it easy to notify a logger about entering and exiting the body of a + given function. */ + +class log_scope +{ +public: + log_scope (logger *logger, const char *name); + ~log_scope (); + + private: + logger *m_logger; + const char *m_name; +}; + +/* The constructor for gcc::jit::log_scope. + + The normal case is that the logger is NULL, in which case this should + be largely a no-op. + + If we do have a logger, notify it that we're entering the given scope. + We also need to hold a reference on it, to avoid a use-after-free + when logging the cleanup of the owner of the logger. */ + +inline +log_scope::log_scope (logger *logger, const char *name) : + m_logger (logger), + m_name (name) +{ + if (m_logger) + { + m_logger->incref ("log_scope ctor"); + m_logger->enter_scope (m_name); + } +} + +/* The destructor for gcc::jit::log_scope; essentially the opposite of + the constructor. */ + +inline +log_scope::~log_scope () +{ + if (m_logger) + { + m_logger->exit_scope (m_name); + m_logger->decref ("log_scope dtor"); + } +} + +/* A gcc::jit::log_user is something that potentially uses a + gcc::jit::logger (which could be NULL). + + It is the base class for each of: + + - class gcc::jit::recording::context + + - class gcc::jit::playback::context + + - class gcc::jit::result + + The log_user class keeps the reference-count of a logger up-to-date. */ + +class log_user +{ + public: + log_user (logger *logger); + ~log_user (); + + logger * get_logger () const { return m_logger; } + void set_logger (logger * logger); + + void log (const char *fmt, ...) + GNU_PRINTF(2, 3); + + void enter_scope (const char *scope_name); + void exit_scope (const char *scope_name); + + private: + logger *m_logger; +}; + +/* A shortcut for calling log from a context/result, handling the common + case where the underlying logger is NULL via a no-op. */ + +inline void +log_user::log (const char *fmt, ...) +{ + if (m_logger) + { + va_list ap; + va_start (ap, fmt); + m_logger->log_va (fmt, ap); + va_end (ap); + } +} + +/* A shortcut for recording entry into a scope from a context/result, + handling the common case where the underlying logger is NULL via + a no-op. */ + +inline void +log_user::enter_scope (const char *scope_name) +{ + if (m_logger) + m_logger->enter_scope (scope_name); +} + +/* A shortcut for recording exit from a scope from a context/result, + handling the common case where the underlying logger is NULL via + a no-op. */ + +inline void +log_user::exit_scope (const char *scope_name) +{ + if (m_logger) + m_logger->exit_scope (scope_name); +} + +} // namespace gcc::jit + +} // namespace gcc + +/* If the given logger is non-NULL, log entry/exit of this scope to + it, identifying it using __PRETTY_FUNCTION__. */ + +#define JIT_LOG_SCOPE(LOGGER) \ + gcc::jit::log_scope s (LOGGER, __PRETTY_FUNCTION__) + +/* If the given logger is non-NULL, log entry/exit of this scope to + it, identifying it using __func__. */ + +#define JIT_LOG_FUNC(LOGGER) \ + gcc::jit::log_scope s (LOGGER, __func__) + +#endif /* JIT_LOGGING_H */ diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 013ee0f..a8a281a 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "jit-common.h" +#include "jit-logging.h" #include "jit-playback.h" #include "jit-result.h" #include "jit-builtins.h" @@ -86,11 +87,13 @@ namespace jit { /* The constructor for gcc::jit::playback::context. */ playback::context::context (recording::context *ctxt) - : m_recording_ctxt (ctxt), + : log_user (ctxt->get_logger ()), + m_recording_ctxt (ctxt), m_tempdir (NULL), m_char_array_type_node (NULL), m_const_char_ptr (NULL) { + JIT_LOG_SCOPE (get_logger ()); m_functions.create (0); m_source_files.create (0); m_cached_locations.create (0); @@ -100,6 +103,7 @@ playback::context::context (recording::context *ctxt) playback::context::~context () { + JIT_LOG_SCOPE (get_logger ()); if (m_tempdir) delete m_tempdir; m_functions.release (); @@ -1219,6 +1223,8 @@ build_stmt_list () int i; block *b; + JIT_LOG_SCOPE (m_ctxt->get_logger ()); + FOR_EACH_VEC_ELT (m_blocks, i, b) { int j; @@ -1244,6 +1250,8 @@ void playback::function:: postprocess () { + JIT_LOG_SCOPE (m_ctxt->get_logger ()); + if (m_ctxt->get_bool_option (GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE)) debug_tree (m_stmt_list); @@ -1538,6 +1546,8 @@ result * playback::context:: compile () { + JIT_LOG_SCOPE (get_logger ()); + const char *ctxt_progname; result *result_obj = NULL; @@ -1572,8 +1582,13 @@ compile () /* This runs the compiler. */ toplev toplev (false); + enter_scope ("toplev::main"); + if (get_logger ()) + for (unsigned i = 0; i < fake_args.length (); i++) + get_logger ()->log ("argv[%i]: %s", i, fake_args[i]); toplev.main (fake_args.length (), const_cast <char **> (fake_args.address ())); + exit_scope ("toplev::main"); /* Extracting dumps makes use of the gcc::dump_manager, hence we need to do it between toplev::main (which creates the dump manager) @@ -1581,7 +1596,9 @@ compile () extract_any_requested_dumps (&requested_dumps); /* Clean up the compiler. */ + enter_scope ("toplev::finalize"); toplev.finalize (); + exit_scope ("toplev::finalize"); /* Ideally we would release the jit mutex here, but we can't yet since followup activities use timevars, which are global state. */ @@ -1622,6 +1639,7 @@ void playback::context::acquire_mutex () { /* Acquire the big GCC mutex. */ + JIT_LOG_SCOPE (get_logger ()); pthread_mutex_lock (&jit_mutex); gcc_assert (NULL == active_playback_ctxt); active_playback_ctxt = this; @@ -1633,6 +1651,7 @@ void playback::context::release_mutex () { /* Release the big GCC mutex. */ + JIT_LOG_SCOPE (get_logger ()); gcc_assert (active_playback_ctxt == this); active_playback_ctxt = NULL; pthread_mutex_unlock (&jit_mutex); @@ -1647,6 +1666,8 @@ make_fake_args (vec <char *> *argvec, const char *ctxt_progname, vec <recording::requested_dump> *requested_dumps) { + JIT_LOG_SCOPE (get_logger ()); + #define ADD_ARG(arg) argvec->safe_push (xstrdup (arg)) #define ADD_ARG_TAKE_OWNERSHIP(arg) argvec->safe_push (arg) @@ -1734,6 +1755,8 @@ void playback::context:: extract_any_requested_dumps (vec <recording::requested_dump> *requested_dumps) { + JIT_LOG_SCOPE (get_logger ()); + int i; recording::requested_dump *d; FOR_EACH_VEC_ELT (*requested_dumps, i, d) @@ -1819,6 +1842,7 @@ void playback::context:: convert_to_dso (const char *ctxt_progname) { + JIT_LOG_SCOPE (get_logger ()); /* Currently this lumps together both assembling and linking into TV_ASSEMBLE. */ auto_timevar assemble_timevar (TV_ASSEMBLE); @@ -1852,6 +1876,10 @@ convert_to_dso (const char *ctxt_progname) /* pex_one's error-handling requires pname to be non-NULL. */ gcc_assert (ctxt_progname); + if (get_logger ()) + for (unsigned i = 0; i < argvec.length (); i++) + get_logger ()->log ("argv[%i]: %s", i, argvec[i]); + errmsg = pex_one (PEX_SEARCH, /* int flags, */ gcc_driver_name, const_cast <char *const *> (argvec.address ()), @@ -1892,6 +1920,7 @@ result * playback::context:: dlopen_built_dso () { + JIT_LOG_SCOPE (get_logger ()); auto_timevar load_timevar (TV_LOAD); void *handle = NULL; const char *error = NULL; @@ -1906,7 +1935,7 @@ dlopen_built_dso () add_error (NULL, "%s", error); } if (handle) - result_obj = new result (handle); + result_obj = new result (get_logger (), handle); else result_obj = NULL; @@ -1923,6 +1952,7 @@ void playback::context:: replay () { + JIT_LOG_SCOPE (get_logger ()); /* Adapted from c-common.c:c_common_nodes_and_builtins. */ tree array_domain_type = build_index_type (size_int (200)); m_char_array_type_node @@ -1984,6 +2014,7 @@ void playback::context:: dump_generated_code () { + JIT_LOG_SCOPE (get_logger ()); char buf[4096]; size_t sz; FILE *f_in = fopen (get_path_s_file (), "r"); @@ -2069,6 +2100,7 @@ handle_locations () imposed by the linemap API. line_table is a global. */ + JIT_LOG_SCOPE (get_logger ()); int i; source_file *file; diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index 4d087de..3a03b3a 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -35,7 +35,7 @@ namespace jit { namespace playback { -class context +class context : public log_user { public: context (::gcc::jit::recording::context *ctxt); diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index dc7a7fb..a872063 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "jit-common.h" #include "jit-builtins.h" +#include "jit-logging.h" #include "jit-recording.h" #include "jit-playback.h" @@ -169,7 +170,8 @@ recording::playback_block (recording::block *b) gcc_jit_context_acquire and gcc_jit_context_new_child_context. */ recording::context::context (context *parent_ctxt) - : m_parent_ctxt (parent_ctxt), + : log_user (NULL), + m_parent_ctxt (parent_ctxt), m_error_count (0), m_first_error_str (NULL), m_owns_first_error_str (false), @@ -195,6 +197,7 @@ recording::context::context (context *parent_ctxt) memcpy (m_bool_options, parent_ctxt->m_bool_options, sizeof (m_bool_options)); + set_logger (parent_ctxt->get_logger ()); } else { @@ -211,6 +214,7 @@ recording::context::context (context *parent_ctxt) recording::context::~context () { + JIT_LOG_SCOPE (get_logger ()); int i; memento *m; FOR_EACH_VEC_ELT (m_mementos, i, m) @@ -245,6 +249,7 @@ recording::context::record (memento *m) void recording::context::replay_into (replayer *r) { + JIT_LOG_SCOPE (get_logger ()); int i; memento *m; @@ -302,6 +307,7 @@ recording::context::replay_into (replayer *r) void recording::context::disassociate_from_playback () { + JIT_LOG_SCOPE (get_logger ()); int i; memento *m; @@ -904,6 +910,8 @@ recording::context::enable_dump (const char *dumpname, result * recording::context::compile () { + JIT_LOG_SCOPE (get_logger ()); + validate (); if (errors_occurred ()) @@ -940,6 +948,8 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap) const char *errmsg; bool has_ownership; + JIT_LOG_SCOPE (get_logger ()); + vasprintf (&malloced_msg, fmt, ap); if (malloced_msg) { @@ -951,6 +961,8 @@ recording::context::add_error_va (location *loc, const char *fmt, va_list ap) errmsg = "out of memory generating error message"; has_ownership = false; } + if (get_logger ()) + get_logger ()->log ("error %i: %s", m_error_count, errmsg); const char *ctxt_progname = get_str_option (GCC_JIT_STR_OPTION_PROGNAME); @@ -1060,6 +1072,8 @@ recording::context::get_all_requested_dumps (vec <recording::requested_dump> *ou void recording::context::validate () { + JIT_LOG_SCOPE (get_logger ()); + if (m_parent_ctxt) m_parent_ctxt->validate (); diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 9034e11..dddf0db 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #define JIT_RECORDING_H #include "jit-common.h" +#include "jit-logging.h" namespace gcc { @@ -53,7 +54,7 @@ struct requested_dump }; /* A JIT-compilation context. */ -class context +class context : public log_user { public: context (context *parent_ctxt); diff --git a/gcc/jit/jit-result.c b/gcc/jit/jit-result.c index 532b302..67699e0 100644 --- a/gcc/jit/jit-result.c +++ b/gcc/jit/jit-result.c @@ -21,6 +21,9 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" + +#include "jit-common.h" +#include "jit-logging.h" #include "jit-result.h" namespace gcc { @@ -29,9 +32,11 @@ namespace jit { /* Constructor for gcc::jit::result. */ result:: -result(void *dso_handle) - : m_dso_handle(dso_handle) +result(logger *logger, void *dso_handle) : + log_user (logger), + m_dso_handle (dso_handle) { + JIT_LOG_SCOPE (get_logger ()); } /* gcc::jit::result's destructor. @@ -40,6 +45,8 @@ result(void *dso_handle) result::~result() { + JIT_LOG_SCOPE (get_logger ()); + dlclose (m_dso_handle); } @@ -53,6 +60,8 @@ void * result:: get_code (const char *funcname) { + JIT_LOG_SCOPE (get_logger ()); + void *code; const char *error; diff --git a/gcc/jit/jit-result.h b/gcc/jit/jit-result.h index b1a9631..59d28a1 100644 --- a/gcc/jit/jit-result.h +++ b/gcc/jit/jit-result.h @@ -26,10 +26,10 @@ namespace gcc { namespace jit { /* The result of JIT-compilation. */ -class result +class result : public log_user { public: - result(void *dso_handle); + result(logger *logger, void *dso_handle); virtual ~result(); diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h index d6631e5..600219c 100644 --- a/gcc/jit/libgccjit++.h +++ b/gcc/jit/libgccjit++.h @@ -102,6 +102,10 @@ namespace gccjit void dump_to_file (const std::string &path, bool update_locations); + void set_logfile (FILE *logfile, + int flags, + int verbosity); + void set_str_option (enum gcc_jit_str_option opt, const char *value); @@ -541,6 +545,17 @@ context::dump_to_file (const std::string &path, } inline void +context::set_logfile (FILE *logfile, + int flags, + int verbosity) +{ + gcc_jit_context_set_logfile (m_inner_ctxt, + logfile, + flags, + verbosity); +} + +inline void context::set_str_option (enum gcc_jit_str_option opt, const char *value) { diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 99b2d56..c0439617 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "libgccjit.h" #include "jit-common.h" +#include "jit-logging.h" #include "jit-recording.h" #include "jit-result.h" @@ -323,7 +324,9 @@ compatible_types (gcc::jit::recording::type *ltype, gcc_jit_context * gcc_jit_context_acquire (void) { - return new gcc_jit_context (NULL); + gcc_jit_context *ctxt = new gcc_jit_context (NULL); + ctxt->log ("new top-level ctxt: %p", (void *)ctxt); + return ctxt; } /* Public entrypoint for releasing a gcc_jit_context. @@ -333,6 +336,9 @@ gcc_jit_context_acquire (void) void gcc_jit_context_release (gcc_jit_context *ctxt) { + RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL ctxt"); + JIT_LOG_FUNC (ctxt->get_logger ()); + ctxt->log ("deleting ctxt: %p", (void *)ctxt); delete ctxt; } @@ -345,7 +351,12 @@ gcc_jit_context_release (gcc_jit_context *ctxt) gcc_jit_context * gcc_jit_context_new_child_context (gcc_jit_context *parent_ctxt) { - return new gcc_jit_context (parent_ctxt); + RETURN_NULL_IF_FAIL (parent_ctxt, NULL, NULL, "NULL parent ctxt"); + JIT_LOG_FUNC (parent_ctxt->get_logger ()); + parent_ctxt->log ("parent_ctxt: %p", (void *)parent_ctxt); + gcc_jit_context *child_ctxt = new gcc_jit_context (parent_ctxt); + child_ctxt->log ("new child_ctxt: %p", (void *)child_ctxt); + return child_ctxt; } /* Public entrypoint. See description in libgccjit.h. @@ -361,7 +372,7 @@ gcc_jit_context_new_location (gcc_jit_context *ctxt, int column) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); - + JIT_LOG_FUNC (ctxt->get_logger ()); return (gcc_jit_location *)ctxt->new_location (filename, line, column); } @@ -404,6 +415,7 @@ gcc_jit_context_get_type (gcc_jit_context *ctxt, enum gcc_jit_types type) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_PRINTF1 ( (type >= GCC_JIT_TYPE_VOID && type <= GCC_JIT_TYPE_FILE_PTR), @@ -425,6 +437,7 @@ gcc_jit_context_get_int_type (gcc_jit_context *ctxt, int num_bytes, int is_signed) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (num_bytes >= 0, ctxt, NULL, "negative size"); return (gcc_jit_type *)ctxt->get_int_type (num_bytes, is_signed); @@ -485,6 +498,7 @@ gcc_jit_context_new_array_type (gcc_jit_context *ctxt, int num_elements) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (element_type, ctxt, loc, "NULL type"); RETURN_NULL_IF_FAIL (num_elements >= 0, ctxt, NULL, "negative size"); @@ -507,6 +521,7 @@ gcc_jit_context_new_field (gcc_jit_context *ctxt, const char *name) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type"); RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); @@ -543,6 +558,7 @@ gcc_jit_context_new_struct_type (gcc_jit_context *ctxt, gcc_jit_field **fields) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); if (num_fields) @@ -578,6 +594,7 @@ gcc_jit_context_new_opaque_struct (gcc_jit_context *ctxt, const char *name) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); @@ -611,8 +628,9 @@ gcc_jit_struct_set_fields (gcc_jit_struct *struct_type, gcc_jit_field **fields) { RETURN_IF_FAIL (struct_type, NULL, loc, "NULL struct_type"); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = struct_type->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL_PRINTF1 ( NULL == struct_type->get_fields (), ctxt, loc, "%s already has had fields set", @@ -649,6 +667,7 @@ gcc_jit_context_new_union_type (gcc_jit_context *ctxt, gcc_jit_field **fields) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); if (num_fields) @@ -687,6 +706,7 @@ gcc_jit_context_new_function_ptr_type (gcc_jit_context *ctxt, int is_variadic) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (return_type, ctxt, loc, "NULL return_type"); RETURN_NULL_IF_FAIL ( @@ -720,6 +740,7 @@ gcc_jit_context_new_param (gcc_jit_context *ctxt, const char *name) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type"); RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); @@ -785,6 +806,7 @@ gcc_jit_context_new_function (gcc_jit_context *ctxt, int is_variadic) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL_PRINTF1 ( ((kind >= GCC_JIT_FUNCTION_EXPORTED) @@ -846,6 +868,7 @@ gcc_jit_context_get_builtin_function (gcc_jit_context *ctxt, const char *name) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (name, ctxt, NULL, "NULL name"); return static_cast <gcc_jit_function *> (ctxt->get_builtin_function (name)); @@ -876,6 +899,7 @@ gcc_jit_function_get_param (gcc_jit_function *func, int index) { RETURN_NULL_IF_FAIL (func, NULL, NULL, "NULL function"); gcc::jit::recording::context *ctxt = func->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (index >= 0, ctxt, NULL, "negative index"); int num_params = func->get_params ().length (); RETURN_NULL_IF_FAIL_PRINTF3 (index < num_params, @@ -900,6 +924,7 @@ gcc_jit_function_dump_to_dot (gcc_jit_function *func, { RETURN_IF_FAIL (func, NULL, NULL, "NULL function"); gcc::jit::recording::context *ctxt = func->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_IF_FAIL (path, ctxt, NULL, "NULL path"); func->dump_to_dot (path); @@ -916,6 +941,7 @@ gcc_jit_function_new_block (gcc_jit_function *func, const char *name) { RETURN_NULL_IF_FAIL (func, NULL, NULL, "NULL function"); + JIT_LOG_FUNC (func->get_context ()->get_logger ()); RETURN_NULL_IF_FAIL (func->get_kind () != GCC_JIT_FUNCTION_IMPORTED, func->get_context (), NULL, "cannot add block to an imported function"); @@ -965,6 +991,7 @@ gcc_jit_context_new_global (gcc_jit_context *ctxt, const char *name) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type"); RETURN_NULL_IF_FAIL (name, ctxt, loc, "NULL name"); @@ -1050,6 +1077,7 @@ gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt, int value) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); return (gcc_jit_rvalue *)ctxt->new_rvalue_from_int (numeric_type, value); @@ -1066,6 +1094,7 @@ gcc_jit_context_zero (gcc_jit_context *ctxt, gcc_jit_type *numeric_type) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); return gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 0); @@ -1082,6 +1111,7 @@ gcc_jit_context_one (gcc_jit_context *ctxt, gcc_jit_type *numeric_type) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); return gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 1); @@ -1099,6 +1129,7 @@ gcc_jit_context_new_rvalue_from_double (gcc_jit_context *ctxt, double value) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); return (gcc_jit_rvalue *)ctxt->new_rvalue_from_double (numeric_type, value); @@ -1116,6 +1147,7 @@ gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt, void *value) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (pointer_type, ctxt, NULL, "NULL type"); RETURN_NULL_IF_FAIL_PRINTF1 ( pointer_type->is_pointer (), @@ -1137,6 +1169,7 @@ gcc_jit_context_null (gcc_jit_context *ctxt, gcc_jit_type *pointer_type) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (pointer_type, ctxt, NULL, "NULL type"); RETURN_NULL_IF_FAIL_PRINTF1 ( pointer_type->is_pointer (), @@ -1158,6 +1191,7 @@ gcc_jit_context_new_string_literal (gcc_jit_context *ctxt, const char *value) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL (value, ctxt, NULL, "NULL value"); return (gcc_jit_rvalue *)ctxt->new_string_literal (value); @@ -1177,6 +1211,7 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt, gcc_jit_rvalue *rvalue) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL_PRINTF1 ( (op >= GCC_JIT_UNARY_OP_MINUS @@ -1215,6 +1250,7 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt, gcc_jit_rvalue *a, gcc_jit_rvalue *b) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL_PRINTF1 ( valid_binary_op_p (op), @@ -1250,6 +1286,7 @@ gcc_jit_context_new_comparison (gcc_jit_context *ctxt, gcc_jit_rvalue *a, gcc_jit_rvalue *b) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL_PRINTF1 ( (op >= GCC_JIT_COMPARISON_EQ @@ -1285,6 +1322,7 @@ gcc_jit_context_new_call (gcc_jit_context *ctxt, int numargs , gcc_jit_rvalue **args) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (func, ctxt, loc, "NULL function"); if (numargs) @@ -1357,6 +1395,7 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context *ctxt, int numargs, gcc_jit_rvalue **args) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (fn_ptr, ctxt, loc, "NULL fn_ptr"); if (numargs) @@ -1486,6 +1525,7 @@ gcc_jit_context_new_cast (gcc_jit_context *ctxt, gcc_jit_type *type) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue"); RETURN_NULL_IF_FAIL (type, ctxt, loc, "NULL type"); @@ -1513,6 +1553,7 @@ gcc_jit_context_new_array_access (gcc_jit_context *ctxt, gcc_jit_rvalue *index) { RETURN_NULL_IF_FAIL (ctxt, NULL, loc, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (ptr, ctxt, loc, "NULL ptr"); RETURN_NULL_IF_FAIL (index, ctxt, loc, "NULL index"); @@ -1572,8 +1613,9 @@ gcc_jit_lvalue_access_field (gcc_jit_lvalue *struct_, gcc_jit_field *field) { RETURN_NULL_IF_FAIL (struct_, NULL, loc, "NULL struct"); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = struct_->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (field, ctxt, loc, "NULL field"); RETURN_NULL_IF_FAIL_PRINTF1 (field->get_container (), field->m_ctxt, loc, "field %s has not been placed in a struct", @@ -1594,8 +1636,9 @@ gcc_jit_rvalue_access_field (gcc_jit_rvalue *struct_, gcc_jit_field *field) { RETURN_NULL_IF_FAIL (struct_, NULL, loc, "NULL struct"); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = struct_->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (field, ctxt, loc, "NULL field"); RETURN_NULL_IF_FAIL_PRINTF1 (field->get_container (), field->m_ctxt, loc, "field %s has not been placed in a struct", @@ -1616,6 +1659,7 @@ gcc_jit_rvalue_dereference_field (gcc_jit_rvalue *ptr, gcc_jit_field *field) { RETURN_NULL_IF_FAIL (ptr, NULL, loc, "NULL ptr"); + JIT_LOG_FUNC (ptr->get_context ()->get_logger ()); /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (field, NULL, loc, "NULL field"); gcc::jit::recording::type *underlying_type = @@ -1652,6 +1696,7 @@ gcc_jit_rvalue_dereference (gcc_jit_rvalue *rvalue, gcc_jit_location *loc) { RETURN_NULL_IF_FAIL (rvalue, NULL, loc, "NULL rvalue"); + JIT_LOG_FUNC (rvalue->get_context ()->get_logger ()); /* LOC can be NULL. */ gcc::jit::recording::type *underlying_type = @@ -1684,6 +1729,7 @@ gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, gcc_jit_location *loc) { RETURN_NULL_IF_FAIL (lvalue, NULL, loc, "NULL lvalue"); + JIT_LOG_FUNC (lvalue->get_context ()->get_logger ()); /* LOC can be NULL. */ return (gcc_jit_rvalue *)lvalue->get_address (loc); @@ -1701,8 +1747,9 @@ gcc_jit_function_new_local (gcc_jit_function *func, const char *name) { RETURN_NULL_IF_FAIL (func, NULL, loc, "NULL function"); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = func->m_ctxt; + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_NULL_IF_FAIL (func->get_kind () != GCC_JIT_FUNCTION_IMPORTED, ctxt, loc, "Cannot add locals to an imported function"); @@ -1723,8 +1770,9 @@ gcc_jit_block_add_eval (gcc_jit_block *block, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue"); return block->add_eval (loc, rvalue); @@ -1743,8 +1791,9 @@ gcc_jit_block_add_assignment (gcc_jit_block *block, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (lvalue, ctxt, loc, "NULL lvalue"); RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue"); RETURN_IF_FAIL_PRINTF4 ( @@ -1775,8 +1824,9 @@ gcc_jit_block_add_assignment_op (gcc_jit_block *block, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (lvalue, ctxt, loc, "NULL lvalue"); RETURN_IF_FAIL_PRINTF1 ( valid_binary_op_p (op), @@ -1814,8 +1864,9 @@ gcc_jit_block_end_with_conditional (gcc_jit_block *block, gcc_jit_block *on_false) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (boolval, ctxt, loc, "NULL boolval"); RETURN_IF_FAIL_PRINTF2 ( is_bool (boolval), ctxt, loc, @@ -1860,8 +1911,9 @@ gcc_jit_block_add_comment (gcc_jit_block *block, const char *text) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (text, ctxt, loc, "NULL text"); block->add_comment (loc, text); @@ -1879,8 +1931,9 @@ gcc_jit_block_end_with_jump (gcc_jit_block *block, gcc_jit_block *target) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ RETURN_IF_FAIL (target, ctxt, loc, "NULL target"); RETURN_IF_FAIL_PRINTF4 ( block->get_function () == target->get_function (), @@ -1908,8 +1961,9 @@ gcc_jit_block_end_with_return (gcc_jit_block *block, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ gcc::jit::recording::function *func = block->get_function (); RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue"); RETURN_IF_FAIL_PRINTF4 ( @@ -1938,8 +1992,9 @@ gcc_jit_block_end_with_void_return (gcc_jit_block *block, gcc_jit_location *loc) { RETURN_IF_NOT_VALID_BLOCK (block, loc); - /* LOC can be NULL. */ gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ gcc::jit::recording::function *func = block->get_function (); RETURN_IF_FAIL_PRINTF2 ( func->get_return_type () == ctxt->get_type (GCC_JIT_TYPE_VOID), @@ -1968,6 +2023,7 @@ gcc_jit_context_set_str_option (gcc_jit_context *ctxt, const char *value) { RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* opt is checked by the inner function. value can be NULL. */ @@ -1986,6 +2042,7 @@ gcc_jit_context_set_int_option (gcc_jit_context *ctxt, int value) { RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* opt is checked by the inner function. */ ctxt->set_int_option (opt, value); @@ -2003,6 +2060,7 @@ gcc_jit_context_set_bool_option (gcc_jit_context *ctxt, int value) { RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); /* opt is checked by the inner function. */ ctxt->set_bool_option (opt, value); @@ -2020,6 +2078,7 @@ gcc_jit_context_enable_dump (gcc_jit_context *ctxt, char **out_ptr) { RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_IF_FAIL (dumpname, ctxt, NULL, "NULL dumpname"); RETURN_IF_FAIL (out_ptr, ctxt, NULL, "NULL out_ptr"); @@ -2037,7 +2096,16 @@ gcc_jit_context_compile (gcc_jit_context *ctxt) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); - return (gcc_jit_result *)ctxt->compile (); + JIT_LOG_FUNC (ctxt->get_logger ()); + + ctxt->log ("compiling ctxt: %p", (void *)ctxt); + + gcc_jit_result *result = (gcc_jit_result *)ctxt->compile (); + + ctxt->log ("%s: returning (gcc_jit_result *)%p", + __func__, (void *)result); + + return result; } /* Public entrypoint. See description in libgccjit.h. @@ -2052,10 +2120,32 @@ gcc_jit_context_dump_to_file (gcc_jit_context *ctxt, int update_locations) { RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_IF_FAIL (path, ctxt, NULL, "NULL path"); ctxt->dump_to_file (path, update_locations); } +/* Public entrypoint. See description in libgccjit.h. */ + +void +gcc_jit_context_set_logfile (gcc_jit_context *ctxt, + FILE *logfile, + int flags, + int verbosity) +{ + RETURN_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + RETURN_IF_FAIL ((flags == 0), ctxt, NULL, "flags must be 0 for now"); + RETURN_IF_FAIL ((verbosity == 0), ctxt, NULL, "verbosity must be 0 for now"); + + gcc::jit::logger *logger; + if (logfile) + logger = new gcc::jit::logger (logfile, flags, verbosity); + else + logger = NULL; + ctxt->set_logger (logger); +} + /* Public entrypoint. See description in libgccjit.h. After error-checking, the real work is done by the @@ -2066,6 +2156,7 @@ const char * gcc_jit_context_get_first_error (gcc_jit_context *ctxt) { RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); return ctxt->get_first_error (); } @@ -2080,9 +2171,14 @@ gcc_jit_result_get_code (gcc_jit_result *result, const char *fnname) { RETURN_NULL_IF_FAIL (result, NULL, NULL, "NULL result"); + JIT_LOG_FUNC (result->get_logger ()); RETURN_NULL_IF_FAIL (fnname, NULL, NULL, "NULL fnname"); - return result->get_code (fnname); + result->log ("locating fnname: %s", fnname); + void *code = result->get_code (fnname); + result->log ("%s: returning (void *)%p", __func__, code); + + return code; } /* Public entrypoint. See description in libgccjit.h. @@ -2094,6 +2190,7 @@ void gcc_jit_result_release (gcc_jit_result *result) { RETURN_IF_FAIL (result, NULL, NULL, "NULL result"); - + JIT_LOG_FUNC (result->get_logger ()); + result->log ("deleting result: %p", (void *)result); delete result; } diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 2049795..91ca409 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see #ifndef LIBGCCJIT_H #define LIBGCCJIT_H +#include <stdio.h> + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -254,6 +256,19 @@ gcc_jit_context_dump_to_file (gcc_jit_context *ctxt, const char *path, int update_locations); +/* To help with debugging; enable ongoing logging of the context's + activity to the given FILE *. + + The caller remains responsible for closing "logfile". + + Params "flags" and "verbosity" are reserved for future use, and + must both be 0 for now. */ +extern void +gcc_jit_context_set_logfile (gcc_jit_context *ctxt, + FILE *logfile, + int flags, + int verbosity); + /* To be called after a compile, this gives the first error message that occurred on the context. diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index 600d397..267898c 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -65,6 +65,7 @@ gcc_jit_context_release; gcc_jit_context_set_bool_option; gcc_jit_context_set_int_option; + gcc_jit_context_set_logfile; gcc_jit_context_set_str_option; gcc_jit_context_zero; gcc_jit_field_as_object; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c67aa9..6ec4ba2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2015-01-08 David Malcolm <dmalcolm@redhat.com> + + * jit.dg/harness.h (set_up_logging): New function. + (test_jit): Fail if gcc_jit_context_acquire fails. Call + set_up_logging on the context, so that every testcase is + logged to a particular file. + * jit.dg/test-nested-contexts.c (main): Open a logfile, + and call gcc_jit_context_set_logfile on the top-level context. + 2015-01-08 Jakub Jelinek <jakub@redhat.com> PR target/64338 diff --git a/gcc/testsuite/jit.dg/harness.h b/gcc/testsuite/jit.dg/harness.h index fda797c..1252af5 100644 --- a/gcc/testsuite/jit.dg/harness.h +++ b/gcc/testsuite/jit.dg/harness.h @@ -251,15 +251,64 @@ static void set_options (gcc_jit_context *ctxt, const char *argv0) } #ifndef TEST_ESCHEWS_TEST_JIT +/* Set up logging to a logfile of the form "test-FOO.exe.log.txt". + + For example, + SRCDIR/gcc/testsuite/jit.dg/test-hello-world.c + is built as: + BUILDDIR/gcc/testsuite/jit/test-hello-world.c.exe + and is logged to + BUILDDIR/gcc/testsuite/jit/test-hello-world.c.exe.log.txt + + The logfile must be closed by the caller. + + Note that not every testcase enables logging. */ +static FILE * +set_up_logging (gcc_jit_context *ctxt, const char *argv0) +{ + const char *logfile_name_suffix = ".log.txt"; + char *logfile_name = NULL; + FILE *logfile = NULL; + + /* Build a logfile name of the form "test-FOO.exe.log.txt". */ + logfile_name = (char *)malloc (strlen (argv0) + + strlen (logfile_name_suffix) + + 1); + if (!logfile_name) + { + fail ("malloc failure"); + return NULL; + } + strcpy (logfile_name, argv0); + strcpy (logfile_name + strlen (argv0), logfile_name_suffix); + logfile_name[strlen (argv0) + strlen (logfile_name_suffix)] = '\0'; + + logfile = fopen (logfile_name, "w"); + CHECK_NON_NULL (logfile); + free (logfile_name); + + if (logfile) + gcc_jit_context_set_logfile (ctxt, logfile, 0, 0); + + return logfile; +} + /* Run one iteration of the test. */ static void test_jit (const char *argv0, void *user_data) { gcc_jit_context *ctxt; + FILE *logfile; gcc_jit_result *result; ctxt = gcc_jit_context_acquire (); - /* FIXME: error-handling */ + if (!ctxt) + { + fail ("gcc_jit_context_acquire failed"); + return; + } + + logfile = set_up_logging (ctxt, argv0); set_options (ctxt, argv0); @@ -275,6 +324,9 @@ test_jit (const char *argv0, void *user_data) /* Once we're done with the code, this unloads the built .so file: */ gcc_jit_result_release (result); + + if (logfile) + fclose (logfile); } #endif /* #ifndef TEST_ESCHEWS_TEST_JIT */ diff --git a/gcc/testsuite/jit.dg/test-nested-contexts.c b/gcc/testsuite/jit.dg/test-nested-contexts.c index 16bc63f..81b1bb2 100644 --- a/gcc/testsuite/jit.dg/test-nested-contexts.c +++ b/gcc/testsuite/jit.dg/test-nested-contexts.c @@ -532,6 +532,10 @@ main (int argc, char **argv) /* We do the whole thing multiple times to shake out state-management issues in the underlying code. */ + FILE *logfile = fopen ("test-nested-contexts.c.exe.log.txt", "w"); + if (!logfile) + fail ("error opening logfile"); + for (i = 1; i <= NUM_TOP_ITERATIONS; i++) { /* Create the top-level context. */ @@ -544,6 +548,9 @@ main (int argc, char **argv) memset (&top_level, 0, sizeof (top_level)); top_level.ctxt = gcc_jit_context_acquire (); + gcc_jit_context_set_logfile (top_level.ctxt, + logfile, + 0, 0); set_options (top_level.ctxt, argv[0]); make_types (&top_level); @@ -635,6 +642,9 @@ main (int argc, char **argv) gcc_jit_context_release (top_level.ctxt); } + if (logfile) + fclose (logfile); + totals (); return 0; |