Commit Graph

113 Commits

Author SHA1 Message Date
David Malcolm 51c5c6b5d8 PR jit/65691: Fix copy&paste error in docs
gcc/jit/ChangeLog:
	PR jit/65691
	* docs/cp/topics/expressions.rst (Simple expressions): Fix copy
	and paste error in description of gccjit::context::one.
	* docs/topics/expressions.rst (Simple expressions): Likewise in
	description of gcc_jit_context_one.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r221959
2015-04-09 19:54:49 +00:00
Uros Bizjak f40fd89585 jit-recording.c (dump::write): Also check vasprintf return value.
* jit-recording.c (dump::write): Also check vasprintf return value.
	(recording::context::add_error_va): Ditto.
	(recording::string::from_printf): Ditto.

From-SVN: r221426
2015-03-13 19:09:12 +01:00
David Malcolm 18eb0d1324 jit docs: Add "Packaging notes" section
gcc/jit/ChangeLog:
	* docs/internals/index.rst (Packaging notes): New section.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r221425
2015-03-13 17:23:37 +00:00
David Malcolm 7ef9618369 jit documentation fixes
gcc/jit/ChangeLog:
	* docs/cp/intro/tutorial03.rst: Add missing arguments to
	gccjit::block::end_with_conditional call.  Add on_true/on_false
	comments.  Tweak the wording.
	* docs/intro/tutorial03.rst: Add missing arguments to
	gcc_jit_block_end_with_conditional call.  Add some clarifying
	comments.
	* docs/topics/compilation.rst: Tweak the wording to avoid an
	ambiguous use of "this".
	* docs/topics/contexts.rst: Fix a typo.
	* docs/topics/expressions.rst (GCC_JIT_BINARY_OP_MINUS): Remove
	a stray backtick.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r221218
2015-03-05 15:38:15 +00:00
Thomas Schwinge 56a9f6bcf9 [PR libgomp/64625] Remove __OFFLOAD_TABLE__ variable/formal parameter.
Fixup for r219836: adjust builtin function prototypes.

	PR libgomp/64625
	gcc/
	* omp-builtins.def (BUILT_IN_GOACC_DATA_START): Specify as
	BT_FN_VOID_INT_SIZE_PTR_PTR_PTR, not
	BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR.
	(BUILT_IN_GOACC_ENTER_EXIT_DATA, BUILT_IN_GOACC_UPDATE): Specify as
	BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_INT_INT_VAR, not
	BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR_INT_INT_VAR.
	(BUILT_IN_GOACC_PARALLEL): Specify as
	BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR, not
	BT_FN_VOID_INT_OMPFN_PTR_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR.
	* builtin-types.def
	(BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR_INT_INT_VAR)
	(BT_FN_VOID_INT_OMPFN_PTR_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR):
	Remove function types.
	(BT_FN_VOID_INT_SIZE_PTR_PTR_PTR)
	(BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_INT_INT_VAR)
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR):
	New function types.
	gcc/ada/
	* gcc-interface/utils.c (DEF_FUNCTION_TYPE_VAR_8)
	(DEF_FUNCTION_TYPE_VAR_12): Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
	gcc/c-family/
	* c-common.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12):
	Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
	gcc/fortran/
	* f95-lang.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12):
	Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
	* types.def (BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR_INT_INT_VAR)
	(BT_FN_VOID_INT_OMPFN_PTR_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR):
	Remove function types.
	(BT_FN_VOID_INT_SIZE_PTR_PTR_PTR)
	(BT_FN_VOID_INT_SIZE_PTR_PTR_PTR_INT_INT_VAR)
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR):
	New function types.
	gcc/jit/
	* jit-builtins.c (DEF_FUNCTION_TYPE_VAR_8)
	(DEF_FUNCTION_TYPE_VAR_12): Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
	* jit-builtins.h (DEF_FUNCTION_TYPE_VAR_8)
	(DEF_FUNCTION_TYPE_VAR_12): Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
	gcc/lto/
	* lto-lang.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12):
	Remove macros.
	(DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.

From-SVN: r220944
2015-02-24 18:00:36 +01:00
David Malcolm a4be4e91d2 More fixes for update_web_docs_svn for jit docs (PR jit/64257)
gcc/jit/ChangeLog:
	PR jit/64257
	* docs/conf.py (html_theme): Change from 'pyramid'
	to 'sphinxdoc'.

maintainer-scripts/ChangeLog:
	PR jit/64257
	* update_web_docs_svn: Update build of jit docs to use EPEL6
	variant install of sphinx 1.0.8, rather than 0.6.6.

From-SVN: r220412
2015-02-04 19:11:48 +00:00
David Malcolm f435bff380 jit: fix typo in docs
gcc/jit/ChangeLog:
	* docs/topics/contexts.rst (gcc_jit_context_acquire): Fix
	typo.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r220408
2015-02-04 14:47:08 +00:00
David Malcolm 0ed4f01761 jit: option-logging
gcc/jit/ChangeLog:
	* jit-logging.h (gcc::jit::log_user::log): Make const.
	* jit-recording.c (gcc::jit::recording::context::set_str_option):
	Log the new value of the option.
	(gcc::jit::recording::context::set_int_option): Likewise.
	(gcc::jit::recording::context::set_bool_option): Likewise.
	(gcc::jit::recording::context::compile): Log the value of all
	options.
	(gcc::jit::recording::context::compile_to_file): Likewise.
	(gcc::jit::recording::context::log_all_options): New function.
	(gcc::jit::recording::context::log_str_option): New function.
	(gcc::jit::recording::context::log_int_option): New function.
	(gcc::jit::recording::context::log_bool_option): New function.
	* jit-recording.h (gcc::jit::recording::context::log_all_options):
	New function.
	(gcc::jit::recording::context::log_str_option): New function.
	(gcc::jit::recording::context::log_int_option): New function.
	(gcc::jit::recording::context::log_bool_option): New function.
	* docs/internals/test-hello-world.exe.log.txt: Update for above
	changes.

From-SVN: r220375
2015-02-03 19:28:24 +00:00
David Malcolm 2cb844ce9c PR jit/64810: driver, arm, jit: configure-time default options
gcc/ChangeLog:
	PR jit/64810
	* Makefile.in (GCC_OBJS): Add gcc-main.o.
	* gcc-main.c: New file, containing "main" taken from gcc.c.
	* gcc.c (do_self_spec): Free decoded_options.
	(class driver): Move declaration to gcc.h.
	(main): Move declaration and implementation to new file
	gcc-main.c.
	(driver_get_configure_time_options): New function.
	* gcc.h (class driver): Move this declaration here, from
	gcc.c.
	(driver_get_configure_time_options): New declaration.

gcc/jit/ChangeLog:
	PR jit/64810
	* Make-lang.in (jit_OBJS): Add jit/jit-spec.o and gcc.o.
	(LIBGCCJIT_FILENAME): Add EXTRA_GCC_OBJS.
	* jit-playback.c: Include gcc.h.
	(gcc::jit::playback::context::compile): Move mutex acquisition
	to before the call to make_fake_args.
	(append_arg_from_driver): New function.
	(gcc::jit::playback::context::make_fake_args): On the first call,
	call into driver_get_configure_time_options to get configure-time
	default options and cache them.  Add them to the args for
	toplev::main.
	* jit-spec.c: New source file.
	* docs/internals/test-hello-world.exe.log.txt: Update to reflect
	above changes.

From-SVN: r220373
2015-02-03 17:19:58 +00:00
David Malcolm 16a71c501a PR jit/64810: support DImode on arm
gcc/jit/ChangeLog:
	PR jit/64810
	* dummy-frontend.c (jit_langhook_type_for_mode): Support
	TYPE_MODE (long_long_integer_type_node).

From-SVN: r220347
2015-02-02 15:21:16 +00:00
David Malcolm 53c04ec92a toplev: gcc version information for jit
gcc/ChangeLog:
	* toplev.c (print_version): Add param "show_global_state", and
	only print GGC and plugin information if it is true.
	(init_asm_output): Pass in "true" for the new param when calling
	print_version.
	(process_options): Likewise.
	(toplev::main): Likewise.
	* toplev.h (print_version): Add new param to decl.

gcc/jit/ChangeLog:
	* docs/internals/test-hello-world.exe.log.txt: Add example version
	lines.
	* jit-common.h (gcc::jit::dump::get_file): New accessor.
	* jit-logging.c: Include toplev.h.
	(gcc::jit::logger::logger): Log the GCC version.
	* jit-recording.c: Include toplev.h.
	(gcc:jit::recording::context::dump_reproducer_to_file): Log the
	GCC version.

From-SVN: r220190
2015-01-27 20:19:36 +00:00
David Malcolm dc44ee3aef Fix gcc_jit_context_get_last_error docs
gcc/jit/ChangeLog:
	* docs/topics/compilation.rst (gcc_jit_result_get_code): Fix typo.
	* docs/topics/contexts.rst (gcc_jit_context_get_last_error): The
	error buffer is only valid until the next call to the context.
	* libgccjit.h (gcc_jit_context_get_first_error): Reword the
	comment to omit mention of compiling.
	(gcc_jit_context_get_last_error): The error buffer is only valid
	until the next call to the context.

From-SVN: r220145
2015-01-27 00:11:21 +00:00
David Malcolm 3349605dc7 PR jit/64708: remove libgccjit.so from COMPILERS
gcc/jit/ChangeLog:
	PR jit/64708
	* config-lang.in (compilers): Drop "libgccjit.so".

From-SVN: r220133
2015-01-26 20:30:12 +00:00
David Malcolm 6fc2d0f362 PR jit/64721: toplev: don't install signal-handlers when running within libgccjit
gcc/ChangeLog:
	PR jit/64721
	* main.c (main): Construct toplev instances with init_signals=true.
	* toplev.c (general_init): Add param "init_signals", and use it to
	conditionalize the calls to signal and host_hooks.extra_signals.
	(toplev::toplev): Add param "init_signals".
	(toplev::main): When invoking general_init, pass m_init_signals
	to control whether signal-handlers are installed.
	* toplev.h (toplev::toplev): Add param "init_signals".
	(toplev::m_init_signals): New field.

gcc/jit/ChangeLog:
	PR jit/64721
	* jit-playback.c (gcc::jit::playback::context::compile): Construct
	toplev instances with init_signals=false.

From-SVN: r220045
2015-01-23 16:28:14 +00:00
David Malcolm fdce7209c2 New jit API entrypoint: gcc_jit_context_compile_to_file
gcc/jit/ChangeLog:
	* docs/cp/topics/results.rst: Rename to...
	* docs/cp/topics/compilation.rst: ...this, and add section on
	ahead-of-time compilation.
	* docs/cp/topics/index.rst: Update for renaming of results.rst
	to compilation.rst.
	* docs/examples/emit-alphabet.bf: New file, a sample "brainf"
	script.
	* docs/examples/tut05-bf.c: New file, implementing a compiler
	for "brainf".
	* docs/internals/test-hello-world.exe.log.txt: Update to reflect
	changes to logger output.
	* docs/intro/index.rst: Add tutorial05.rst
	* docs/intro/tutorial05.rst: New file.
	* docs/topics/results.rst: Rename to...
	* docs/topics/compilation.rst: ...this, and add section on
	ahead-of-time compilation.
	* docs/topics/index.rst: Update for renaming of results.rst to
	compilation.rst.
	* jit-playback.c (gcc::jit::playback::context::compile): Convert
	return type from result * to void.  Move the code to convert to
	dso and dlopen the result to a new pure virtual "postprocess"
	method.
	(gcc::jit::playback::compile_to_memory::compile_to_memory): New
	function.
	(gcc::jit::playback::compile_to_memory::postprocess): New
	function, based on playback::context::compile.
	(gcc::jit::playback::compile_to_file::compile_to_file): New
	function.
	(gcc::jit::playback::compile_to_file::postprocess): New function.
	(gcc::jit::playback::compile_to_file::copy_file): New function.
	(gcc::jit::playback::context::convert_to_dso): Move internals
	to...
	(gcc::jit::playback::context::invoke_driver): New method.  Add
	"-shared" and "-c" options to driver's argv as needed.
	* jit-playback.h: Include "timevar.h".
	(gcc::jit::playback::context::compile): Convert return type from
	result * to void.
	(gcc::jit::playback::context::postprocess): New pure virtual
	function, making this an abstract base class.
	(gcc::jit::playback::context::get_tempdir): New accessor.
	(gcc::jit::playback::context::invoke_driver): New function.
	(class gcc::jit::playback::compile_to_memory): New subclass of
	playback::context.
	(class gcc::jit::playback::compile_to_file): Likewise.
	* jit-recording.c (gcc::jit::recording::context::compile): Use a
	playback::compile_to_memory, and extract its result.
	(gcc::jit::recording::context::compile_to_file): New function.
	* jit-recording.h (gcc::jit::recording::context::compile_to_file):
	New function.
	* libgccjit++.h (gccjit::context::compile_to_file): New method.
	* libgccjit.c (gcc_jit_context_compile): Update log message to
	clarify that this is an in-memory compile.
	(gcc_jit_context_compile_to_file): New function.
	* libgccjit.h (gcc_jit_context): Clarify that you can compile
	a context more than once, and that you can compile to a file
	as well as to memory.
	(gcc_jit_result): Clarify that this is the result of an
	in-memory compilation.
	(gcc_jit_context_compile): Clarify that you can compile, and that
	this is an in-memory compilation.
	(enum gcc_jit_output_kind): New enum.
	(gcc_jit_context_compile_to_file): New function.
	(gcc_jit_context_enable_dump): Clarify comment to cover both forms
	of compilation.
	* libgccjit.map (gcc_jit_context_compile_to_file): New API
	entrypoint.
	* notes.txt: Update to show the playback::context::postprocess
	virtual function.

gcc/testsuite/ChangeLog:
	* jit.dg/harness.h: Include <unistd.h>.
	(CHECK_NO_ERRORS): New.
	(verify_code): Wrap prototype in #ifndef TEST_COMPILING_TO_FILE.
	(test_jit): Support new macro TEST_COMPILING_TO_FILE for exercising
	gcc_jit_context_compile_to_file.
	* jit.dg/jit.exp (fixed_host_execute): Fix the code for passing on
	args to the spawned executable.
	(jit-expand-vars): New function.
	(jit-exe-params): New variable.
	(dg-jit-set-exe-params): New function.
	(jit-dg-test): Detect testcases that use
	jit-verify-compile-to-file and call jit-setup-compile-to-file.
	Set arguments of spawned process to jit-exe-params.
	(jit-get-output-filename): New function.
	(jit-setup-compile-to-file): New function.
	(jit-verify-compile-to-file): New function.
	(jit-run-executable): New function.
	(jit-verify-executable): New function.
	* jit.dg/test-compile-to-assembler.c: New testcase.
	* jit.dg/test-compile-to-dynamic-library.c: New testcase.
	* jit.dg/test-compile-to-executable.c: New testcase.
	* jit.dg/test-compile-to-object.c: New testcase.

From-SVN: r219876
2015-01-20 01:32:48 +00:00
David Malcolm 450e225b58 jit: fix crash in memento_of_new_string_literal::make_debug_string
gcc/jit/ChangeLog:
	* jit-recording.c
	(gcc::jit::recording::memento_of_new_string_literal::make_debug_string):
	Add missing format string.

From-SVN: r219851
2015-01-19 17:16:37 +00:00
David Malcolm 499de348e9 Parallelize the jit testsuite
gcc/jit/ChangeLog:
	* Make-lang.in (lang_checks_parallelized): Add "check-jit".
	(check_jit_parallelize): Set this to an arbitrary value (10).

From-SVN: r219774
2015-01-16 21:30:26 +00:00
Jakub Jelinek e989e68d93 jit-builtins.h (DEF_FUNCTION_TYPE_VAR_5): Fix spelling of last argument.
* jit-builtins.h (DEF_FUNCTION_TYPE_VAR_5): Fix spelling of
	last argument.
	(DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12): Define and
	undef afterwards.
	* jit-builtins.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12):
	Likewise.
@@ -334,6 +343,8 @@ builtins_manager::make_type (enum jit_bu
 #undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_FUNCTION_TYPE_VAR_4
 #undef DEF_FUNCTION_TYPE_VAR_5
+#undef DEF_FUNCTION_TYPE_VAR_8
+#undef DEF_FUNCTION_TYPE_VAR_12
 #undef DEF_POINTER_TYPE
 
     default:

From-SVN: r219744
2015-01-16 15:38:14 +01:00
Richard Sandiford 179ed8f5e2 2015-01-15 Richard Sandiford <richard.sandiford@arm.com>
Update copyright years in docs/.

From-SVN: r219693
2015-01-15 22:15:47 +00:00
David Malcolm 96a8798199 jit: prevent ICE with type mismatch in gcc_jit_block_add_assignment_op
gcc/jit/ChangeLog:
	* libgccjit.c (gcc_jit_block_add_assignment_op): Check that the
	lvalue and the rvalue are of compatible type.

gcc/testsuite/ChangeLog:
	* jit.dg/test-error-mismatching-types-in-assignment-op.c: New
	test case.

From-SVN: r219681
2015-01-15 19:36:42 +00:00
David Malcolm 86d0ac8876 jit: New API entrypoint: gcc_jit_context_dump_reproducer_to_file
gcc/jit/ChangeLog:
	* docs/cp/topics/contexts.rst (Debugging): Add
	gccjit::context::dump_reproducer_to_file.
	* docs/internals/index.rst (Design notes): New section,
	discussing input validation and
	gcc_jit_context_dump_reproducer_to_file.
	* docs/topics/contexts.rst (Debugging): Add
	gcc_jit_context_dump_reproducer_to_file.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* jit-common.h (gcc::jit::dump::get_context): New accessor.
	* jit-recording.c: Include "hash-map.h".
	Within namespace ::gcc::jit...
	(dump::write): Flush each line.
	(dump::make_location): Pass false for new param "created_by_user".
	(class allocator): New class.
	(allocator::~allocator): New function.
	(allocator::xstrdup_printf): New function.
	(allocator::xstrdup_printf_va): New function.
	(class reproducer): New subclass of dump.
	(reproducer::reproducer): New function.
	(reproducer::write_params): New function.
	(reproducer::write_args): New function.
	(reproducer::make_identifier): New function.
	(reproducer::make_tmp_identifier): New function.
	(reproducer::get_identifier): New pair of functions.
	(reproducer::get_identifier_as_rvalue): New function.
	(reproducer::get_identifier_as_lvalue): New function.
	(reproducer::get_identifier_as_type): New function.
	(reproducer::xstrdup_printf): New function.
	(recording::context::context): Initialize m_toplevel_ctxt.
	(recording::context::new_location): Add param created_by_user.
	(str_option_reproducer_strings): New table of strings.
	(int_option_reproducer_strings): Likewise.
	(bool_option_reproducer_strings): Likewise.
	(get_type_enum_strings): Likewise.
	(names_of_function_kinds): Likewise.
	(global_kind_reproducer_strings): Likewise.
	(unary_op_reproducer_strings): Likewise.
	(binary_op_reproducer_strings): Likewise.
	(comparison_reproducer_strings): Likewise.
	Within namespace ::gcc::jit::recording::...
	(context::dump_reproducer_to_file): New function.
	(string::write_reproducer): Likewise.
	(location::write_reproducer): Likewise.
	(type::access_as_type): Likewise.
	(memento_of_get_type::write_reproducer): Likewise.
	(memento_of_get_pointer::write_reproducer): Likewise.
	(memento_of_get_const::write_reproducer): Likewise.
	(memento_of_get_volatile::write_reproducer): Likewise.
	(array_type::write_reproducer): Likewise.
	(function_type::write_reproducer): Likewise.
	(function_type::write_deferred_reproducer): Likewise.
	(field::write_reproducer): Likewise.
	(struct_::access_as_type): Likewise.
	(struct_::write_reproducer): Likewise.
	(union_::write_reproducer): Likewise.
	(fields::write_reproducer): Likewise.
	(rvalue::access_as_rvalue): Likewise.
	(lvalue::access_as_rvalue): Likewise.
	(lvalue::access_as_lvalue): Likewise.
	(param::access_as_rvalue): Likewise.
	(param::access_as_lvalue): Likewise.
	(param::write_reproducer): Likewise.
	(function::write_reproducer): Likewise.
	(block::write_reproducer): Likewise.
	(global::write_reproducer): Likewise.
	(memento_of_new_rvalue_from_const <int>::write_reproducer):
	Likewise.
	(memento_of_new_rvalue_from_const <long>::write_reproducer):
	Likewise.
	(memento_of_new_rvalue_from_const <double>::write_reproducer):
	Likewise.
	(memento_of_new_rvalue_from_const <void *>::write_reproducer):
	Likewise.
	(memento_of_new_string_literal::write_reproducer): Likewise.
	(unary_op::write_reproducer): Likewise.
	(binary_op::write_reproducer): Likewise.
	(comparison::write_reproducer): Likewise.
	(cast::write_reproducer): Likewise.
	(call::write_reproducer): Likewise.
	(call_through_ptr::write_reproducer): Likewise.
	(array_access::write_reproducer): Likewise.
	(access_field_of_lvalue::write_reproducer): Likewise.
	(access_field_rvalue::write_reproducer): Likewise.
	(dereference_field_rvalue::write_reproducer): Likewise.
	(dereference_rvalue::write_reproducer): Likewise.
	(get_address_of_lvalue::write_reproducer): Likewise.
	(local::write_reproducer): Likewise.
	(eval::write_reproducer): Likewise.
	(assignment::write_reproducer): Likewise.
	(assignment_op::write_reproducer): Likewise.
	(comment::write_reproducer): Likewise.
	(conditional::write_reproducer): Likewise.
	(jump::write_reproducer): Likewise.
	(return_::write_reproducer): Likewise.
	* jit-recording.h (gcc::jit::reproducer): New forward declararion.
	Within namespace ::gcc::jit::recording::...
	(context::new_location): Add "created_by_user" param.
	(context::dump_reproducer_to_file): New method.
	(context::m_toplevel_ctxt): New field.
	(memento::write_reproducer): New pure virtual function.
	(memento::dyn_cast_location): New virtual function.
	(string::write_reproducer):
	(location::location): Add "created_by_user" param.
	(location::dyn_cast_location): New function.
	(location::created_by_user): New accessor.
	(location::write_reproducer): New function.
	(location::m_created_by_user): New field.
	(type::access_as_type): New virtual function.
	(location::write_reproducer): Likewise.
	(type::access_as_type): Likewise.
	(memento_of_get_type::write_reproducer): Likewise.
	(memento_of_get_pointer::write_reproducer): Likewise.
	(memento_of_get_const::write_reproducer): Likewise.
	(memento_of_get_volatile::write_reproducer): Likewise.
	(array_type::write_reproducer): Likewise.
	(function_type::write_reproducer): Likewise.
	(function_type::write_deferred_reproducer): Likewise.
	(field::write_reproducer): Likewise.
	(struct_::access_as_type): Likewise.
	(struct_::write_reproducer): Likewise.
	(union_::write_reproducer): Likewise.
	(union_::m_fields): Remove stray unused field.
	(fields::length): New accessor.
	(fields::get_field): New accessor.
	(fields::write_reproducer): New function.
	(rvalue::access_as_rvalue): Likewise.
	(lvalue::access_as_rvalue): Likewise.
	(lvalue::access_as_lvalue): Likewise.
	(param::access_as_rvalue): Likewise.
	(param::access_as_lvalue): Likewise.
	(param::write_reproducer): Likewise.
	(function::write_reproducer): Likewise.
	(block::write_reproducer): Likewise.
	(global::write_reproducer): Likewise.
	(memento_of_new_rvalue_from_const <HOST_TYPE>::write_reproducer):
	Likewise.
	(memento_of_new_string_literal::write_reproducer): Likewise.
	(unary_op::write_reproducer): Likewise.
	(binary_op::write_reproducer): Likewise.
	(comparison::write_reproducer): Likewise.
	(cast::write_reproducer): Likewise.
	(call::write_reproducer): Likewise.
	(call_through_ptr::write_reproducer): Likewise.
	(array_access::write_reproducer): Likewise.
	(access_field_of_lvalue::write_reproducer): Likewise.
	(access_field_rvalue::write_reproducer): Likewise.
	(dereference_field_rvalue::write_reproducer): Likewise.
	(dereference_rvalue::write_reproducer): Likewise.
	(get_address_of_lvalue::write_reproducer): Likewise.
	(local::write_reproducer): Likewise.
	(eval::write_reproducer): Likewise.
	(assignment::write_reproducer): Likewise.
	(assignment_op::write_reproducer): Likewise.
	(comment::write_reproducer): Likewise.
	(conditional::write_reproducer): Likewise.
	(jump::write_reproducer): Likewise.
	(return_::write_reproducer): Likewise.
	* libgccjit++.h (gccjit::context::dump_reproducer_to_file): New.
	* libgccjit.c (gcc_jit_context_new_location): Pass "true" as
	param "created_by_user".
	(gcc_jit_context_dump_reproducer_to_file): New API entrypoint.
	* libgccjit.h (gcc_jit_context_dump_reproducer_to_file): New API
	entrypoint.
	* libgccjit.map (gcc_jit_context_dump_reproducer_to_file): New API
	entrypoint.

gcc/testsuite/ChangeLog:
	* jit.dg/harness.h (set_up_logging): Move string concatenation
	into...
	(concat_strings): New function.
	(dump_reproducer): New function.
	(test_jit): Call dump_reproducer.
	* jit.dg/jit.exp (is_testcase_meant_to_generate_a_reproducer): New
	function.
	(jit-dg-test): Delete any generated reproducer from previous runs.
	Verify that a generated reproducer was created, and verify that it
	compiles.
	* jit.dg/test-nested-contexts.c (main): Call
	gcc_jit_context_dump_reproducer_to_file.

From-SVN: r219564
2015-01-13 22:14:46 +00:00
David Malcolm f6f2b01933 libgccjit: detect various kinds of errors relating to params and locals
gcc/jit/ChangeLog:
	* jit-recording.c (class gcc::jit::rvalue_usage_validator): New.
	(gcc::jit::rvalue_usage_validator::rvalue_usage_validator): New
	ctor.
	(gcc::jit::rvalue_usage_validator::visit): New function.
	(gcc::jit::recording::rvalue::verify_valid_within_stmt): New
	function.
	(gcc::jit::recording::rvalue::set_scope): New function.
	(gcc::jit::recording::function::function): Call set_scope on each
	param, issuing errors for any params that already have a function.
	(gcc::jit::recording::block::add_eval): Return the new statement;
	update the comment given that some error-checking now happens after
	this returns.
	(gcc::jit::recording::block::add_assignment): Likewise.
	(gcc::jit::recording::block::add_assignment_op): Likewise.
	(gcc::jit::recording::block::add_comment): Likewise.
	(gcc::jit::recording::block::end_with_conditional): Likewise.
	(gcc::jit::recording::block::end_with_jump): Likewise.
	(gcc::jit::recording::block::end_with_return): Likewise.
	(gcc::jit::recording::block::validate): Add a comment.
	(gcc::jit::recording::unary_op::visit_children): New function.
	(gcc::jit::recording::binary_op::visit_children): New function.
	(gcc::jit::recording::comparison::visit_children): New function.
	(gcc::jit::recording::cast::visit_children): New function.
	(gcc::jit::recording::call::visit_children): New function.
	(gcc::jit::recording::call_through_ptr::visit_children): New function.
	(gcc::jit::recording::array_access::visit_children): New function.
	(gcc::jit::recording::access_field_of_lvalue::visit_children): New
	function.
	(gcc::jit::recording::access_field_rvalue::visit_children): New
	function.
	(gcc::jit::recording::dereference_field_rvalue::visit_children):
	New function.
	(gcc::jit::recording::dereference_rvalue::visit_children): New
	function.
	(gcc::jit::recording::get_address_of_lvalue::visit_children): New
	function.
	* jit-recording.h: Within namespace gcc::jit::recording...
	(class rvalue_visitor): New.
	(rvalue::rvalue): Initialize m_scope.
	(rvalue::get_loc): New accessor.
	(rvalue::verify_valid_within_stmt): New function.
	(rvalue::visit_children): New pure virtual function.
	(rvalue::set_scope): New function.
	(rvalue::get_scope): New function.
	(rvalue::dyn_cast_param): New function.
	(rvalue::m_scope): New field.
	(param::visit_children): New empty function.
	(param::dyn_cast_param): New function.
	(function::get_loc): New function.
	(block::add_eval): Return the new statement.
	(block::add_assignment): Likewise.
	(block::add_assignment_op): Likewise.
	(block::add_comment): Likewise.
	(block::end_with_conditional): Likewise.
	(block::end_with_jump): Likewise.
	(block::end_with_return): Likewise.
	(global::visit_children): New function.
	(memento_of_new_rvalue_from_const<HOST_TYPE>::visit_children):
	New function.
	(memento_of_new_string_literal::visit_children): New function.
	(unary_op::visit_children): New function.
	(binary_op::visit_children): New function.
	(comparison::visit_children): New function.
	(cast::visit_children): New function.
	(call::visit_children): New function.
	(call_through_ptr::visit_children): New function.
	(array_access::visit_children): New function.
	(access_field_of_lvalue::visit_children): New function.
	(access_field_rvalue::visit_children): New function.
	(dereference_field_rvalue::visit_children): New function.
	(dereference_rvalue::visit_children): New function.
	(get_address_of_lvalue::visit_children): New function.
	(local::local): Call set_scope.
	(local::visit_children): New function.
	(statement::get_block): Make public.
	* libgccjit.c (RETURN_VAL_IF_FAIL_PRINTF5): New macro.
	(RETURN_NULL_IF_FAIL_PRINTF5): New macro.
	(gcc_jit_context_new_function): Verify that each param has
	not yet been used for creating another function.
	(gcc_jit_block_add_eval): After creating the stmt, verify
	that the rvalue expression tree is valid to use within it.
	(gcc_jit_block_add_assignment): Likewise for the lvalue and
	rvalue expression trees.
	(gcc_jit_block_add_assignment_op): Likewise.
	(gcc_jit_block_end_with_conditional): Likewise for the boolval
	expression tree.
	(gcc_jit_block_end_with_return): Likewise for the rvalue
	expression tree.
	(gcc_jit_block_end_with_void_return): Remove return of "void",
	now that block::end_with_return is now non-void.

gcc/testsuite/ChangeLog:
	* jit.dg/test-error-local-used-from-other-function.c: New test
	case.
	* jit.dg/test-error-param-reuse.c: New test case.
	* jit.dg/test-error-param-sharing.c: New test case.
	* jit.dg/test-error-param-used-from-other-function.c: New test
	case.
	* jit.dg/test-error-param-used-without-a-function.c: New test
	case.

From-SVN: r219498
2015-01-12 22:25:37 +00:00
David Malcolm 1c35cc2c75 jit-playback.c: fix missing fclose
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::read_dump_file):
	Add missing fclose on error-handling path.

From-SVN: r219487
2015-01-12 19:57:05 +00:00
David Malcolm 791cfef8e7 jit: API change to gcc_jit_context_new_global
gcc/jit/ChangeLog:
	* docs/cp/topics/expressions.rst (Global variables): Add
	enum gcc_jit_global_kind param to gccjit::context::new_global.
	* docs/topics/expressions.rst (Global variables): Likewise.
	Document the new enum.
	* docs/topics/results.rst (Compilation results): Document
	globals-handling.
	* dummy-frontend.c (jit_langhook_write_globals): Call into the
	playback context's write_global_decls_1 and write_global_decls_2
	before and after calling symtab->finalize_compilation_unit ().
	* jit-playback.c: Include "debug.h".
	(gcc::jit::playback::context::new_global): Add "kind" param and
	use it to set TREE_PUBLIC, TREE_STATIC and DECL_EXTERNAL on the
	underlying VAR_DECL.  Call varpool_node::get_create on the
	VAR_DECL, and add it to m_globals.
	(gcc::jit::playback::context::write_global_decls_1): New function.
	(gcc::jit::playback::context::write_global_decls_2): New function.
	* jit-playback.h (gcc::jit::playback::context::context): Call
	create on m_globals.
	(gcc::jit::playback::context::new_global): Add "kind" param.
	(gcc::jit::playback::context::write_global_decls_1): New function.
	(gcc::jit::playback::context::write_global_decls_2): New function.
	(gcc::jit::playback::context::m_globals): New field.
	* jit-recording.c (gcc::jit::recording::context::context):
	Initialize m_globals.
	(gcc::jit::recording::context::new_global): Add param "kind".
	Add the new global to m_globals.
	(gcc::jit::recording::context::dump_to_file): Dump the globals.
	(gcc::jit::recording::global::replay_into): Add field m_kind.
	(gcc::jit::recording::global::write_to_dump): New override.
	* jit-recording.h (gcc::jit::recording::context::new_global): Add
	param "kind".
	(gcc::jit::recording::context::m_globals): New field.
	(gcc::jit::recording::global::global): Add param kind.
	(gcc::jit::recording::global::write_to_dump): New override.
	(gcc::jit::recording::global::m_kind): New field.
	* jit-result.c (gcc::jit::result::get_global): New function.
	* jit-result.h (gcc::jit::result::get_global): New function.
	* libgccjit++.h (gccjit::context::new_global): Add "kind" param.
	* libgccjit.c (gcc_jit_context_new_global): Likewise.
	(gcc_jit_result_get_global): New API entrypoint.
	* libgccjit.h (gcc_jit_result_get_global): New API entrypoint.
	(enum gcc_jit_global_kind): New enum.
	(gcc_jit_context_new_global): API change: add "kind" param.
	* libgccjit.map (gcc_jit_result_get_global): New symbol.

gcc/testsuite/ChangeLog:
	* jit.dg/test-array-as-pointer.c (create_code): Update call
	to gcc_jit_context_new_global by setting "kind" to
	GCC_JIT_GLOBAL_IMPORTED.
	* jit.dg/test-error-array-as-pointer.c: Likewise.
	* jit.dg/test-expressions.c (make_test_of_get_address): Likewise.
	* jit.dg/test-fuzzer.c (make_random_global): Likewise, but
	setting kind to GCC_JIT_GLOBAL_EXPORTED.
	* jit.dg/test-using-global.c (the_global): Rename to...
	(imported_global): ...this.
	(create_code): Update to test the three kinds of global.
	(verify_code): Likewise.

From-SVN: r219480
2015-01-12 17:14:02 +00:00
David Malcolm 860e981ce9 Fix the jit build after header flattening of r219402
gcc/jit/ChangeLog:
	* dummy-frontend.c: Include "fixed-value.h", "alias.h", "flags.h",
	"symtab.h", "inchash.h".  Move include of "hash-set.h" much
	earlier.
	* jit-builtins.c: Remove redundant includes of "opts.h" and
	"tree.h".
	* jit-common.h: Include "hash-set.h", "input.h", "vec.h",
	"double-int.h", "alias.h", "flags.h", "symtab.h", "inchash.h".
	* jit-playback.c: Include "hashtab.h", "machmode.h", "input.h",
	"statistics.h", "vec.h", "double-int.h", "real.h",
	"fixed-value.h", "alias.h", "flags.h", "symtab.h", "tree-core.h",
	"inchash.h", "fold-const.h".  Move include of "hash-set.h" to
	earlier.
	* jit-recording.c: Remove redundant includes of "opts.h" and
	"tree.h".

From-SVN: r219411
2015-01-09 21:45:33 +00:00
David Malcolm ccce3b2ac3 New jit API entrypoint: gcc_jit_context_new_rvalue_from_long
gcc/jit/ChangeLog:
	* docs/cp/topics/expressions.rst (Simple expressions): Use
	":c:type:" for C types.  Document new overload of
	gcc::jit::context::new_rvalue.
	* docs/topics/expressions.rst (Simple expressions): Use
	":c:type:" for C types.  Document new entrypoint
	gcc_jit_context_new_rvalue_from_long.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* jit-playback.c: Within namespace gcc::jit::playback...
	(context::new_rvalue_from_int): Eliminate in favor of...
	(context::new_rvalue_from_const <int>): ...this.
	(context::new_rvalue_from_double): Eliminate in favor of...
	(context::new_rvalue_from_const <double>): ...this.
	(context::new_rvalue_from_const <long>): New.
	(context::new_rvalue_from_ptr): Eliminate in favor of...
	(context::new_rvalue_from_const <void *>): ...this.
	* jit-playback.h: Within namespace gcc::jit::playback...
	(context::new_rvalue_from_int): Eliminate in favor of...
	(context::new_rvalue_from_const <HOST_TYPE>): ...this.
	(context::new_rvalue_from_double): Likewise.
	(context::new_rvalue_from_ptr): Likewise.
	* jit-recording.c: Within namespace gcc::jit::recording...
	(context::new_rvalue_from_int): Eliminate.
	(context::new_rvalue_from_double): Likewise.
	(context::new_rvalue_from_ptr): Likewise.
	(class memento_of_new_rvalue_from_const <int>):
	Add explicit specialization.
	(class memento_of_new_rvalue_from_const <long>):
	Likewise.
	(class memento_of_new_rvalue_from_const <double>):
	Likewise.
	(class memento_of_new_rvalue_from_const <void *>):
	Likewise.
	(memento_of_new_rvalue_from_int::replay_into):
	Generalize into...
	(memento_of_new_rvalue_from_const <HOST_TYPE>::replay_into):
	...this...
	(memento_of_new_rvalue_from_double::replay_into):
	...allowing this...
	(memento_of_new_rvalue_from_ptr::replay_into):
	...and this to be deleted.
	(memento_of_new_rvalue_from_int::make_debug_string):
	Convert to...
	(memento_of_new_rvalue_from_const <int>::make_debug_string):
	...this.
	(memento_of_new_rvalue_from_double::make_debug_string):
	Convert to...
	(memento_of_new_rvalue_from_const <double>::make_debug_string):
	...this.
	(memento_of_new_rvalue_from_ptr::make_debug_string)
	Convert to...
	(memento_of_new_rvalue_from_const <void *>::make_debug_string):
	...this.
	(memento_of_new_rvalue_from_const <long>::make_debug_string):
	New function.
	* jit-recording.h: Within namespace gcc::jit::recording...
	(context::new_rvalue_from_int): Eliminate.
	(context::new_rvalue_from_double): Likewise.
	(context::new_rvalue_from_ptr): Likewise, all in favor of...
	(context::new_rvalue_from_const <HOST_TYPE>): New family of
	methods.
	(class memento_of_new_rvalue_from_int): Eliminate.
	(class memento_of_new_rvalue_from_double): Likewise.
	(class memento_of_new_rvalue_from_ptr): Likewise.
	(class memento_of_new_rvalue_from_const <HOST_TYPE>): New family
	of rvalue subclasses.
	* libgccjit++.h (gccjit::context::new_rvalue): New overload, for
	"long".
	* libgccjit.c (gcc_jit_context_new_rvalue_from_int): Update for
	rewriting of recording::context::new_rvalue_from_int to
	recording::context::new_rvalue_from_const <int>.
	(gcc_jit_context_new_rvalue_from_long): New API entrypoint.
	(gcc_jit_context_new_rvalue_from_double): Update for
	rewriting of recording::context::new_rvalue_from_double to
	recording::context::new_rvalue_from_const <double>.
	(gcc_jit_context_new_rvalue_from_ptr): Update for
	rewriting of recording::context::new_rvalue_from_ptr to
	recording::context::new_rvalue_from_const <void *>.
	* libgccjit.h (gcc_jit_context_new_rvalue_from_long): New API
	entrypoint.
	* libgccjit.map (gcc_jit_context_new_rvalue_from_long): Likewise.

gcc/testsuite/ChangeLog:
	* jit.dg/all-non-failing-tests.h: Add test-constants.c.
	* jit.dg/test-combination.c (create_code): Likewise.
	(verify_code): Likewise.
	* jit.dg/test-constants.c: New test case.
	* jit.dg/test-threads.c: Add test-constants.c.

From-SVN: r219401
2015-01-09 20:10:11 +00:00
David Malcolm d2286af3d3 PR jit/64206: delay cleanup of tempdir if the user has requested debuginfo
gcc/jit/ChangeLog:
	PR jit/64206
	* docs/internals/test-hello-world.exe.log.txt: Update, the log now
	shows tempdir creation/cleanup.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* jit-logging.h (class gcc::jit::log_user): Add gcc::jit::tempdir
	to the list of subclasses in the comment.
	* jit-playback.c (gcc::jit::playback::context::context): Add a
	comment clarifying when the tempdir gets cleaned up.
	(gcc::jit::playback::context::compile): Pass the context's logger,
	if any, to the tempdir.
	(gcc::jit::playback::context::dlopen_built_dso): When creating the
	gcc::jit::result, if GCC_JIT_BOOL_OPTION_DEBUGINFO is set, hand
	over ownership of the tempdir to it.
	* jit-result.c: Include "jit-tempdir.h".
	(gcc::jit::result::result): Add tempdir param, saving it as
	m_tempdir.
	(gcc::jit::result::~result): Delete m_tempdir.
	* jit-result.h (gcc::jit::result::result): Add tempdir param.
	(gcc::jit::result::m_tempdir): New field.
	* jit-tempdir.c (gcc::jit::tempdir::tempdir): Add logger param;
	add JIT_LOG_SCOPE.
	(gcc::jit::tempdir::create): Add JIT_LOG_SCOPE to log entry/exit,
	and log m_path_template and m_path_tempdir.
	(gcc::jit::tempdir::~tempdir): Add JIT_LOG_SCOPE to log
	entry/exit, and log the unlink and rmdir calls.
	* jit-tempdir.h: Include "jit-logging.h".
	(class gcc::jit::tempdir): Make this be a subclass of log_user.
	(gcc::jit::tempdir::tempdir): Add logger param.
	* notes.txt: Update to show the two possible places where the
	tempdir can be cleaned up.

From-SVN: r219395
2015-01-09 17:01:04 +00:00
David Malcolm 7c8db13ee3 libgccjit.h: Fix description of struct gcc_jit_context
gcc/jit/ChangeLog:
	* libgccjit.h (struct gcc_jit_context): Rewrite the descriptive
	comment.

From-SVN: r219366
2015-01-08 22:08:41 +00:00
David Malcolm 303e1d56c6 jit: New API entrypoint: gcc_jit_context_get_last_error
gcc/jit/ChangeLog:
	* docs/topics/contexts.rst (Error-handling): Document new
	entrypoint gcc_jit_context_get_last_error.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* jit-recording.c (gcc::jit::recording::context::context):
	Initialize new fields "m_last_error_str" and
	"m_owns_last_error_str".
	(gcc::jit::recording::context::~context): Clean up
	m_last_error_str, if needed.
	(gcc::jit::recording::context::add_error_va): Update
	m_last_error_str and m_owns_last_error_str, freeing the old
	value if appropriate.
	(gcc::jit::recording::context::get_last_error): New function.
	* jit-recording.h (gcc::jit::recording::context::get_last_error):
	New function.
	(gcc::jit::recording::context): New fields m_last_error_str and
	m_owns_last_error_str.
	* libgccjit.c (gcc_jit_context_get_last_error): New function.
	* libgccjit.h (gcc_jit_context_get_last_error): New declaration.
	* libgccjit.map (gcc_jit_context_get_last_error): New function.

gcc/testsuite/ChangeLog:
	* jit.dg/test-error-block-in-wrong-function.c (verify_code):
	Verify the result of gcc_jit_context_get_last_error.
	* jit.dg/test-error-null-passed-to-api.c (verify_code): Likewise.

From-SVN: r219363
2015-01-08 21:52:35 +00:00
David Malcolm eb4c16eb84 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
2015-01-08 19:41:07 +00:00
David Malcolm c211cd236c jit: Add checking for dereference of void *
gcc/jit/ChangeLog:
	* jit-recording.h (gcc::jit::recording::type::is_void): New
	virtual function.
	(gcc::jit::recording::memento_of_get_type::is_void): New
	function, overriding default implementation.
	* libgccjit.c (gcc_jit_rvalue_dereference): Verify that
	the underlying type is not "void".

gcc/testsuite/ChangeLog:
	* jit.dg/test-error-dereferencing-void-ptr.c: New test case.

From-SVN: r219333
2015-01-08 01:08:19 +00:00
David Malcolm 18146f456f API extension: add GCC_JIT_UNARY_OP_ABS to enum gcc_jit_unary_op
gcc/jit/ChangeLog:
	* docs/topics/expressions.rst (Unary Operations): Add
	GCC_JIT_UNARY_OP_ABS.
	* jit-playback.c (gcc::jit::playback::context::new_unary_op):
	Likewise.
	* jit-recording.c (unary_op_strings): Likewise.
	* libgccjit.c (gcc_jit_context_new_unary_op): Update checking
	of "op" to reflect addition of GCC_JIT_UNARY_OP_ABS.
	* libgccjit.h (enum gcc_jit_unary_op): Add GCC_JIT_UNARY_OP_ABS.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
	* jit.dg/test-expressions.c (make_tests_of_unary_ops): Add test of
	GCC_JIT_UNARY_OP_ABS.
	(verify_unary_ops): Likewise.

From-SVN: r219321
2015-01-07 20:40:46 +00:00
David Malcolm 11af98ff71 Fix typo in jit-recording.h
gcc/jit/ChangeLog:
	* jit-recording.h (gcc::jit::recording::memento_of_get_type): Fix
	typo in comment.

From-SVN: r219319
2015-01-07 19:52:46 +00:00
David Malcolm 433d16df13 jit.exp: support C++ testcases
gcc/jit/ChangeLog:
	* TODO.rst (Test suite): Remove item about running C++ testcases.
	* docs/internals/index.rst (Working on the JIT library): Add
	"c++" to the enabled languages in the suggested "configure"
	invocation, and add a description of why this is necessary.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
	* jit.dg/jit.exp: Load wrapper.exp with %{tool} set to "g++"
	rather than "jit".  Load g++.exp, and call g++_init.
	Run test-*.cc files within the testsuite and *.cc files within
	docs/examples.
	(jit-dg-test): Drop the addition of -fgnu89-inline to
	DEFAULT_CFLAGS in favor of adding it to additional_flags, only
	doing it when compiling C testcases (since g++ does not handle
	it).  Reset "orig_environment_saved" so that LD_LIBRARY_PATH
	is restored to the value after g++_init ran, rather than the
	value before g++_init ran.  Return a list of
	$comp_output $output_file, as dg-test assumes.

From-SVN: r219318
2015-01-07 19:19:10 +00:00
David Malcolm 50bb6c8e11 jit.exp: Don't drop the extension from the testcase when naming executable
gcc/jit/ChangeLog:
	* docs/internals/index.rst: Update to reflect that built
	testcases are now test-foo.c.exe, rather than test-foo.exe.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
	* jit.dg/jit.exp (jit-dg-test): Remove "rootname" call when
	generating name of built executable.

From-SVN: r219312
2015-01-07 15:35:19 +00:00
Jakub Jelinek 1e3b6a3dbc Update copyright years.
From-SVN: r219189
2015-01-05 13:36:59 +01:00
David Malcolm e8af59bc73 Fix casting non-"int" to bool.
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::build_cast): In
	case BOOLEAN_TYPE, don't assume that the source expression is
	of type "int".

gcc/testsuite/ChangeLog:
	* jit.dg/test-expressions.c (make_tests_of_casts): Add tests of
	casting between "long" and "bool".
	(verify_casts): Verify these new test cases.

From-SVN: r218977
2014-12-19 20:34:39 +00:00
David Malcolm 5afd44e33b Fix issue with string options and nested gcc_jit_contexts
gcc/jit/ChangeLog:
	* jit-recording.c (gcc::jit::recording::context::context): When
	copying string options from a parent context, take a copy of the
	underlying buffers, rather than simply copying the pointer.

From-SVN: r218972
2014-12-19 20:11:16 +00:00
David Malcolm 1f0858d762 Handle NULL in gcc_jit_context_set_str_option
gcc/jit/ChangeLog:
	* jit-recording.c (gcc::jit::recording::context::set_str_option):
	Handle NULL.

From-SVN: r218969
2014-12-19 19:33:29 +00:00
David Malcolm 7b31ff5e79 Move changelog entries from r218617 from gcc/ChangeLog to gcc/jit/ChangeLog
From-SVN: r218637
2014-12-11 17:55:22 +00:00
David Malcolm 35291c7dda Document gccjit::context::set_str_option
gcc/jit/ChangeLog:
	* docs/cp/topics/contexts.rst (gccjit::context::set_str_option):
	Document new function.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r218636
2014-12-11 17:50:56 +00:00
David Malcolm 29df5715c0 Document libgccjit++.h
gcc/jit/ChangeLog:
	* docs/cp/index.rst: New file.
	* docs/cp/intro/index.rst: New file.
	* docs/cp/intro/tutorial01.rst: New file.
	* docs/cp/intro/tutorial02.rst: New file.
	* docs/cp/intro/tutorial03.rst: New file.
	* docs/cp/intro/tutorial04.rst: New file.
	* docs/cp/topics/contexts.rst: New file.
	* docs/cp/topics/expressions.rst: New file.
	* docs/cp/topics/functions.rst: New file.
	* docs/cp/topics/index.rst: New file.
	* docs/cp/topics/locations.rst: New file.
	* docs/cp/topics/objects.rst: New file.
	* docs/cp/topics/results.rst: New file.
	* docs/cp/topics/types.rst: New file.
	* docs/examples/tut01-hello-world.cc: New file.
	* docs/examples/tut02-square.c: Fix missing newline in output.
	* docs/examples/tut02-square.cc: New file.
	* docs/examples/tut03-sum-of-squares.cc: New file.
	* docs/examples/tut04-toyvm/toyvm.cc: New file.
	* docs/index.rst: Move summary to above the table of contents.
	Add text about the C vs C++ APIs.
	* docs/topics/contexts.rst: Fix a typo.

	* docs/_build/texinfo/libgccjit.texi: Regenerate.
	* docs/_build/texinfo/factorial1.png: New file.
	* docs/_build/texinfo/sum-of-squares1.png: New file.

From-SVN: r218588
2014-12-10 18:25:58 +00:00
David Malcolm 5cd614cecc toyvm.c: use correct path in debuginfo
gcc/jit/ChangeLog:
	* docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Move
	logic for determine "funcname" to new function...
	(get_function_name): ...here, adding logic to skip any leading
	path from the filename.
	(toyvm_function_parse): Use the filename for fn_filename, rather
	than "name", so that the debugger can locate the source .toy
	file.
	(toyvm_function_parse): Don't fclose a NULL FILE *.

From-SVN: r218540
2014-12-09 20:55:18 +00:00
David Malcolm 2712de7892 PR jit/63854: Document how to run the jit testsuite under valgrind
gcc/jit/ChangeLog:
	PR jit/63854
	* docs/internals/index.rst (Running under valgrind): New
	subsection.
	(docs/_build/texinfo/libgccjit.texi): Regenerate.

From-SVN: r218538
2014-12-09 20:46:33 +00:00
David Malcolm d1e5f2c7e2 Add jit-tempdir.{c|h}
gcc/jit/ChangeLog:
        PR jit/64206
	* Make-lang.in (jit_OBJS): Add jit/jit-tempdir.o.
	* jit-common.h (gcc::jit::tempdir): New forward decl.
	* jit-playback.c: Include jit-tempdir.h.
	(gcc::jit::playback::context::context): Initialize m_tempdir.
	(gcc::jit::playback::context::~context): Move tempdir
	cleanup to new file jit-tempdir.c
	(make_tempdir_path_template): Move to new file jit-tempdir.c.
	(gcc::jit::playback::context::compile): Move tempdir creation
	to new tempdir object in new file jit-tempdir.c.
	(gcc::jit::playback::context::make_fake_args): Get path from
	tempdir object rather than from member data.
	(gcc::jit::playback::context::convert_to_dso): Likewise.
	(gcc::jit::playback::context::dlopen_built_dso): Likewise.
	(gcc::jit::playback::context::dump_generated_code): Likewise.
	(gcc::jit::playback::context::get_path_c_file): New function.
	(gcc::jit::playback::context::get_path_s_file): New function.
	(gcc::jit::playback::context::get_path_so_file): New function.
	* jit-playback.h (gcc::jit::playback::context::get_path_c_file):
	New function.
	(gcc::jit::playback::context::get_path_s_file): New function.
	(gcc::jit::playback::context::get_path_so_file): New function.
	(gcc::jit::playback::context): Move fields "m_path_template",
	"m_path_tempdir", "m_path_c_file", "m_path_s_file",
	"m_path_so_file" to new jit::tempdir class; add field "m_tempdir".
	* jit-tempdir.c: New file.
	* jit-tempdir.h: New file.

From-SVN: r218533
2014-12-09 20:00:07 +00:00
David Malcolm 82e0c91499 Fix bogus ChangeLog entry from r218521
In r218521 I erroneously added the entries meant for gcc/jit/ChangeLog
to gcc/ChangeLog instead.

Move them to the correct ChangeLog file.

Sorry for the noise.

From-SVN: r218529
2014-12-09 19:03:19 +00:00
David Malcolm 38771e4e1f Guard less code with the JIT mutex
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::compile): Acquire the
	mutex here, immediately before using toplev, and release it here, on
	each exit path after acquisition.
	(jit_mutex): Move this variable here, from jit-recording.c.
	(gcc::jit::playback::context::acquire_mutex): New function, based on
	code in jit-recording.c.
	(gcc::jit::playback::context::release_mutex): Likewise.
	* jit-playback.h (gcc::jit::playback::context::acquire_mutex): New
	function.
	(gcc::jit::playback::context::release_mutex): New function.
	* jit-recording.c (jit_mutex): Move this variable to jit-playback.c.
	(gcc::jit::recording::context::compile): Move mutex-handling from
	here into jit-playback.c's gcc::jit::playback::context::compile.
	* notes.txt: Update to show the new locations of ACQUIRE_MUTEX
	and RELEASE_MUTEX.

From-SVN: r218528
2014-12-09 18:51:04 +00:00
David Malcolm 38f4f64124 jit-playback.c: Move dlopen code into a new function
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::compile): Move the
	dlopen code into...
	(gcc::jit::playback::context::dlopen_built_dso): ...this new
	function.
	* jit-playback.h (gcc::jit::playback::context::dlopen_built_dso):
	New function.

From-SVN: r218527
2014-12-09 18:40:40 +00:00
David Malcolm 53b730ff90 libgccjit++.h: use indentation to show inheritance
gcc/jit/ChangeLog:
	* libgccjit++.h: Indent the forward declarations of the classes to
	show the inheritance hierarchy.

From-SVN: r218489
2014-12-08 19:05:01 +00:00
David Malcolm 0f37944592 Make jit/notes.txt better reflect current status quo
gcc/jit/ChangeLog:
	* notes.txt: Show the beginning and ending of
	recording::context::compile vs playback::context::compile.  Show
	the creation and unlinking of the tempdir.  Show toplev::finalize.
	Move "RELEASE MUTEX" to the correct location.  Show
	gcc_jit_result_release, and indicate where the
	dlopen/dlsym/dlclose occur.

From-SVN: r218488
2014-12-08 18:56:21 +00:00
David Malcolm 81ba15f105 Improvements to documentation of gcc_jit_context_release
gcc/jit/ChangeLog:
	* docs/examples/tut02-square.c (main): Release the context
	earlier, to show that this is possible.  Update error-handling
	to avoid a double-release of the context, and to avoid
	releasing a NULL result.
	* docs/intro/tutorial02.rst: Discuss gcc_jit_context_release.
	* docs/topics/functions.rst (GCC_JIT_FUNCTION_EXPORTED): Emphasize
	* docs/topics/results.rst (gcc_jit_result): Mention that this
	controls the lifetimes of machine code functions.
	(gcc_jit_result_get_code): Spell out the requirements for this
	to succeed, and the lifetime of the result.
	(gcc_jit_result_release): Mention that this invalidates any code
	that was obtained from the result.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r218245
2014-12-01 18:53:44 +00:00
David Malcolm e250f0dcfe PR jit/64018: Add description of error-handling to the JIT tutorial
gcc/jit/ChangeLog:
	PR jit/64018
	* docs/intro/tutorial02.rst: Spell out lifetime of generated code.
	Add description of error-handling, taken in part from...
	* docs/topics/contexts.rst (Error-handling): Expand, and move some
	content to tutorial02.rst.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r218243
2014-12-01 18:47:31 +00:00
David Malcolm eeafb31957 PR jit/64020: Fixes to handling of builtins
PR jit/64020
	* docs/topics/types.rst (Standard types) Add new enum values to
	the table of enum gcc_jit_types: GCC_JIT_TYPE_COMPLEX_FLOAT,
	GCC_JIT_TYPE_COMPLEX_DOUBLE, GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.
	Widen the left-hand column so that
	GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE will fit.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

	* jit-builtins.c: Include stringpool.h and jit-playback.h.
	Move everything out of the gcc::jit::recording namespace into
	just gcc::jit.
	(struct builtin_data): Add fields "fnclass", "attr", and
	"implicit_p".
	(DEF_BUILTIN): Update macro so populate the new fields.
	(builtins_manager::builtins_manager): Update for move out of
	recording namespace.  Initialize the m_attributes array.
	(builtins_manager::get_builtin_function): Likewise.
	(builtins_manager::get_builtin_function_by_id): New function.
	(builtins_manager::make_builtin_function): Update for move out of
	recording namespace.  Add fix for PR jit/64020 by detecting
	specific builtin ids and having them ensure that builtins for
	other ids are created as necessary.
	(builtins_manager::get_type): Update for move out of recording
	namespace.
	(builtins_manager::make_type): Likewise.  Add some missing
	#undefs.
	(builtins_manager::make_primitive_type): Update for move out of
	recording namespace.  Implement the three BT_COMPLEX_ cases and
	BT_DOUBLE_PTR.
	(builtins_manager::make_fn_type): Update for move out of recording
	namespace.
	(builtins_manager::make_ptr_type): Likewise.
	(builtins_manager::finish_playback): New function.
	(builtins_manager::get_class): New function.
	(builtins_manager::implicit_p): New function.
	(builtins_manager::get_attrs_tree): Two new functions.
	(builtins_manager::make_attrs_tree): New function.

	* jit-builtins.h: Move everything out of the gcc::jit::recording
	namespace into just gcc::jit.
	(enum built_in_attribute): New.
	(builtins_manager::builtins_manager): Update decl for namespace
	change.
	(builtins_manager::get_builtin_function): Likewise.
	(builtins_manager::get_class): New.
	(builtins_manager::implicit_p): New.
	(builtins_manager::get_attrs_tree): Two new functions.
	(builtins_manager::make_attrs_tree): New function.
	(builtins_manager::finish_playback): New.
	(builtins_manager::get_builtin_function_by_id): New.
	(builtins_manager::make_builtin_function): Update decl for
	namespace change.
	(builtins_manager::get_type): Likewise.
	(builtins_manager::make_type): Likewise.
	(builtins_manager::make_primitive_type): Likewise.
	(builtins_manager::make_fn_type): Likewise.
	(builtins_manager::make_ptr_type): Likewise.
	(builtins_manager): Likewise for fields.  Add new field
	"m_attributes".

	* jit-common.h (NUM_GCC_JIT_TYPES): Update.
	(builtins_manager): Update forward decl to reflect namespace
	change.

	* jit-playback.c: Include attribs.h and jit-builtins.h.
	(gcc::jit::playback::context::get_tree_node_for_type): Add cases
	for the new COMPLEX_ types.
	(gcc::jit::playback::context::new_function): If creating a
	builtin, set the DECL_BUILT_IN_CLASS and attributes on the fndecl,
	and call set_builtin_decl.
	(gcc::jit::playback::context::replay): If we have a
	builtins_manager, call its finish_playback method when we're done.

	* jit-playback.h:
	(gcc::jit::playback::context::get_builtins_manager): New function.

	* jit-recording.c
	(gcc::jit::recording::context::get_builtins_manager): New function.
	(gcc::jit::recording::get_builtin_function): Use
	get_builtins_manager, in case we're a child context.
	(gcc::jit::recording::memento_of_get_type::dereference): Add the
	COMPLEX_ types.
	(gcc::jit::recording::memento_of_get_type::is_int): Likewise.
	(gcc::jit::recording::memento_of_get_type::is_float): Likewise.
	(gcc::jit::recording::memento_of_get_type::is_bool): Likewise.
	(get_type_strings): Likewise.

	* jit-recording.h
	(gcc::jit::recording::context::get_builtins_manager): New.

	* libgccjit.h (enum gcc_jit_types): Add
	GCC_JIT_TYPE_COMPLEX_FLOAT, GCC_JIT_TYPE_COMPLEX_DOUBLE,
	GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.

From-SVN: r218240
2014-12-01 18:23:37 +00:00
David Malcolm 23844fd730 jit-builtins.c: Fix segfault on unsupported builtins
gcc/jit/ChangeLog:
	* jit-builtins.c
	(gcc::jit::recording::builtins_manager::get_builtin_function):
	Check for NULL return from make_builtin_function.
	(gcc::jit::recording::builtins_manager::make_builtin_function):
	Check for NULL return from get_type.

From-SVN: r218239
2014-12-01 18:16:37 +00:00
David Malcolm c6760a1317 jit-playback: Move dso-creation into its own function
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::compile): Move DSO
	creation code into...
	(gcc::jit::playback::context::convert_to_dso): New function.
	* jit-playback.h (gcc::jit::playback::context::convert_to_dso):
	New function.

From-SVN: r218238
2014-12-01 18:02:45 +00:00
David Malcolm 8f50ee3cbe jit-playback: Move argv-creation to its own function
gcc/jit/ChangeLog:
	* jit-playback.c (gcc::jit::playback::context::compile): Use an
	auto_vec<const char *> rather than a const char *[20] for the
	top-level argv, and move the logic to build it to...
	(gcc::jit::playback::context::make_fake_args): New function.
	* jit-playback.h (gcc::jit::playback::context::make_fake_args):
	New function.

From-SVN: r218237
2014-12-01 17:56:34 +00:00
David Malcolm 56dea35f94 Move gcc_jit_result implementation to a new files jit-result.{h|c}
gcc/jit/ChangeLog:
	* Make-lang.in (jit_OBJS): Add jit/jit-result.o.
	* jit-playback.c: Include new header jit-result.h.
	(gcc::jit::result::result): Move to new file jit-result.c.
	(gcc::jit::result::~result): Likewise.
	(gcc::jit::playback::result): Likewise.
	* jit-recording.h (class gcc::jit::result): Move to new
	header jit-result.h.
	* jit-result.c: New file, to contain...
	(gcc::jit::result::result): Move here from jit-playback.c,
	removing erroneous "playback" namespace from comment.
	(gcc::jit::result::~result): Likewise.
	(gcc::jit::playback::result): Likewise.
	* jit-result.h: New file, to contain...
	(class gcc::jit::result): Move from jit-recording.h.
	* libgccjit.c: Include jit-result.h.
	(gcc_jit_result_get_code): Update comment to reflect move
	of implementation.
	(gcc_jit_result_release): Likewise.

From-SVN: r218236
2014-12-01 17:52:03 +00:00
David Malcolm 52b9468f15 PR jit/63854: Fix leaks in toyvm.c
gcc/jit/ChangeLog:
	PR jit/63854
	* docs/examples/tut04-toyvm/toyvm.c
	(toyvm_compiled_function): New typedef.
	(toyvm_compiled_func) Rename to...
	(toyvm_compiled_code) ...this.
	(struct toyvm_compiled_function): New struct.
	(toyvm_function_compile): Return a toyvm_compiled_function *
	rather than a toyvm_compiled_func, so that the caller can fully
	clean things up.  Free "funcname".
	(test_script): Update for change to toyvm_function_compile.
	Clean up the toyvm_compiled_function.
	(main): Likewise.
	(docs/intro/tutorial04.rst): Update to reflect the above changes,
	and to better spell out the lifetime of the compiled code.

From-SVN: r218234
2014-12-01 17:40:03 +00:00
David Malcolm c8d19a6934 PR jit/63854: Fix leak within jit-builtins.c
gcc/jit/ChangeLog:
	PR jit/63854
	* jit-builtins.c
	(gcc::jit::recording::builtins_manager::make_fn_type): Call the
	context's new_function_type method, rather than directly creating
	a function_type instance.
	* jit-recording.c
	(gcc::jit::recording::context::new_function_type): New method,
	adapted from part of...
	(gcc::jit::recording::context::new_function_ptr_type): ...this.
	Update to call new_function_type.
	* jit-recording.h
	(gcc::jit::recording::context::new_function_type): New method.

From-SVN: r218231
2014-12-01 17:22:19 +00:00
David Malcolm c985705ae9 PR jit/63969: Fix segfault in error-handling when driver isn't found
gcc/jit/ChangeLog:
	PR jit/63969
	* jit-playback.c: Ensure that ctxt_progname is non-NULL.

gcc/testsuite/ChangeLog:
	PR jit/63969
	* jit.dg/harness.h (CHECK_STRING_STARTS_WITH): New.
	(check_string_starts_with): New.
	* jit.dg/test-error-pr63969-missing-driver.c: New.

From-SVN: r218226
2014-12-01 15:58:11 +00:00
David Malcolm b957b2e025 PR jit/63854: Fix leaking vec in jit
gcc/jit/ChangeLog:
	PR jit/63854
	* jit-playback.c (gcc::jit::playback::compound_type::set_fields):
	Convert param from const vec<playback::field *> & to
	const auto_vec<playback::field *> *.
	(gcc::jit::playback::context::new_function_type): Convert param
	"param_types" from vec<type *> * to const auto_vec<type *> *.
	(gcc::jit::playback::context::new_function): Convert param
	"params" from vec<param *> * to const auto_vec<param *> *.
	(gcc::jit::playback::context::build_call): Convert param "args"
	from vec<rvalue *> to const auto_vec<rvalue *> *.
	(gcc::jit::playback::context::new_call): Likewise.
	(gcc::jit::playback::context::new_call_through_ptr): Likewise.
	(wrapper_finalizer): New function.
	(gcc::jit::playback::wrapper::operator new): Call the finalizer
	variant of ggc_internal_cleared_alloc, supplying
	wrapper_finalizer.
	(gcc::jit::playback::function::finalizer): New.
	(gcc::jit::playback::block::finalizer): New.
	(gcc::jit::playback::source_file::finalizer): New.
	(gcc::jit::playback::source_line::finalizer): New.

	* jit-playback.h
	(gcc::jit::playback::context::new_function_type): Convert param
	"param_types" from vec<type *> * to const auto_vec<type *> *.
	(gcc::jit::playback::context::new_function): Convert param
	"params" from vec<param *> * to const auto_vec<param *> *.
	(gcc::jit::playback::context::new_call): Convert param
	"args" from vec<rvalue *> to const auto_vec<rvalue *> *.
	(gcc::jit::playback::context::new_call_through_ptr): Likewise.
	(gcc::jit::playback::context::build_call): Likewise.
	(gcc::jit::playback::context): Convert fields "m_functions",
	"m_source_files", "m_cached_locations" from vec to auto_vec.
	(gcc::jit::playback::wrapper::finalizer): New virtual function.
	(gcc::jit::playback::compound_type::set_fields): Convert param fro
	const vec<playback::field *> & to
	const auto_vec<playback::field *> *.
	(gcc::jit::playback::function::finalizer): New.
	(gcc::jit::playback::block::finalizer): New.
	(gcc::jit::playback::source_file::finalizer): New.
	(gcc::jit::playback::source_line::finalizer): New.

	* jit-recording.c
	(gcc::jit::recording::function_type::replay_into): Convert local
	from a vec into an auto_vec.
	(gcc::jit::recording::fields::replay_into): Likewise.
	(gcc::jit::recording::function::replay_into): Likewise.
	(gcc::jit::recording::call::replay_into): Likewise.
	(gcc::jit::recording::call_through_ptr::replay_into): Likewise.

	* jit-recording.h (gcc::jit::recording::context): Convert fields
	"m_mementos", "m_compound_types", "m_functions" from vec<> to
	auto_vec <>.
	(gcc::jit::recording::function_type::get_param_types): Convert
	return type from vec<type *> to const vec<type *> &.
	(gcc::jit::recording::function_type): Convert field
	"m_param_types" from a vec<> to an auto_vec<>.
	(gcc::jit::recording::fields): Likewise for field "m_fields".
	(gcc::jit::recording::function::get_params): Convert return type
	from vec <param *> to const vec<param *> &.
	(gcc::jit::recording::function): Convert fields "m_params",
	"m_locals", "m_blocks" from vec<> to auto_vec<>.
	(gcc::jit::recording::block): Likewise for field "m_statements".
	vec<> to auto_vec<>.
	(gcc::jit::recording::call): Likewise for field "m_args".
	(gcc::jit::recording::call_through_ptr): Likewise.

From-SVN: r217808
2014-11-19 20:31:52 +00:00
David Malcolm 79cafc7ae4 PR jit/63854: Fix leak of worklist within jit-recording.c
gcc/jit/ChangeLog:
	PR jit/63854
	* jit-recording.c (recording::function::validate): Convert
	"worklist" from vec<> to autovec<> to fix a leak.

From-SVN: r217802
2014-11-19 20:10:00 +00:00
David Malcolm 35485da996 Merger of dmalcolm/jit branch from git
ChangeLog:
	* ChangeLog.jit: New.
	* MAINTAINERS (Various Maintainers): Add myself as jit maintainer.

contrib/ChangeLog:
	* ChangeLog.jit: New.
	* jit-coverage-report.py: New file: a script to print crude
	code-coverage information for the libgccjit API.

gcc/ChangeLog:
	* ChangeLog.jit: New.
	* Makefile.in (doc_build_sys): New variable, set to "sphinx" if
	sphinx is installed, falling back to "texinfo" otherwise.
	(FULL_DRIVER_NAME): New variable, adapted from the
	install-driver target.  New target, a symlink within the builddir,
	linked to "xgcc", for use when running the JIT library from the
	builddir.
	(MOSTLYCLEANFILES): Add FULL_DRIVER_NAME.
	(install-driver): Use $(FULL_DRIVER_NAME) rather than spelling it
	out.
	* configure.ac (doc_build_sys): New variable, set to "sphinx" if
	sphinx is installed, falling back to "texinfo" otherwise.
	(GCC_DRIVER_NAME): Generate a gcc-driver-name.h file containing
	GCC_DRIVER_NAME for the benefit of jit/internal-api.c.
	* configure: Regenerate.
	* doc/install.texi (--enable-host-shared): Specify that this is
	required when building libgccjit.
	(Tools/packages necessary for modifying GCC): Add Sphinx.
	* timevar.def (TV_JIT_REPLAY): New.
	(TV_ASSEMBLE): New.
	(TV_LINK): New.
	(TV_LOAD): New.

gcc/java/ChangeLog:
	* gcc/ChangeLog.jit: New.

gcc/jit/ChangeLog:
	* ChangeLog.jit: New.
	* ChangeLog: New.
	* Make-lang.in: New.
	* TODO.rst: New.
	* config-lang.in: New.
	* docs/Makefile: New.
	* docs/_build/texinfo/Makefile: New.
	* docs/_build/texinfo/factorial.png: New.
	* docs/_build/texinfo/libgccjit.texi: New.
	* docs/_build/texinfo/sum-of-squares.png: New.
	* docs/conf.py: New.
	* docs/examples/tut01-hello-world.c: New.
	* docs/examples/tut02-square.c: New.
	* docs/examples/tut03-sum-of-squares.c: New.
	* docs/examples/tut04-toyvm/Makefile: New.
	* docs/examples/tut04-toyvm/factorial.toy: New.
	* docs/examples/tut04-toyvm/fibonacci.toy: New.
	* docs/examples/tut04-toyvm/toyvm.c: New.
	* docs/index.rst: New.
	* docs/internals/index.rst: New.
	* docs/intro/factorial.png: New.
	* docs/intro/index.rst: New.
	* docs/intro/sum-of-squares.png: New.
	* docs/intro/tutorial01.rst: New.
	* docs/intro/tutorial02.rst: New.
	* docs/intro/tutorial03.rst: New.
	* docs/intro/tutorial04.rst: New.
	* docs/topics/contexts.rst: New.
	* docs/topics/expressions.rst: New.
	* docs/topics/functions.rst: New.
	* docs/topics/index.rst: New.
	* docs/topics/locations.rst: New.
	* docs/topics/objects.rst: New.
	* docs/topics/results.rst: New.
	* docs/topics/types.rst: New.
	* dummy-frontend.c: New.
	* jit-builtins.c: New.
	* jit-builtins.h: New.
	* jit-common.h: New.
	* jit-playback.c: New.
	* jit-playback.h: New.
	* jit-recording.c: New.
	* jit-recording.h: New.
	* libgccjit++.h: New.
	* libgccjit.c: New.
	* libgccjit.h: New.
	* libgccjit.map: New.
	* notes.txt: New.

gcc/testsuite/ChangeLog:
	* ChangeLog.jit: New.
	* jit.dg/all-non-failing-tests.h: New.
	* jit.dg/harness.h: New.
	* jit.dg/jit.exp: New.
	* jit.dg/test-accessing-struct.c: New.
	* jit.dg/test-accessing-union.c: New.
	* jit.dg/test-array-as-pointer.c: New.
	* jit.dg/test-arrays.c: New.
	* jit.dg/test-calling-external-function.c: New.
	* jit.dg/test-calling-function-ptr.c: New.
	* jit.dg/test-combination.c: New.
	* jit.dg/test-dot-product.c: New.
	* jit.dg/test-empty.c: New.
	* jit.dg/test-error-accessing-field-in-other-struct.c: New.
	* jit.dg/test-error-adding-to-terminated-block.c: New.
	* jit.dg/test-error-array-as-pointer.c: New.
	* jit.dg/test-error-bad-cast.c: New.
	* jit.dg/test-error-block-in-wrong-function.c: New.
	* jit.dg/test-error-call-through-ptr-with-mismatching-args.c: New.
	* jit.dg/test-error-call-through-ptr-with-non-function.c: New.
	* jit.dg/test-error-call-through-ptr-with-non-pointer.c: New.
	* jit.dg/test-error-call-through-ptr-with-not-enough-args.c: New.
	* jit.dg/test-error-call-through-ptr-with-too-many-args.c: New.
	* jit.dg/test-error-call-with-mismatching-args.c: New.
	* jit.dg/test-error-call-with-not-enough-args.c: New.
	* jit.dg/test-error-call-with-too-many-args.c: New.
	* jit.dg/test-error-dereference-field-of-non-pointer.c: New.
	* jit.dg/test-error-dereference-read-of-non-pointer.c: New.
	* jit.dg/test-error-get-type-bad-enum.c: New.
	* jit.dg/test-error-index-not-a-numeric-type.c: New.
	* jit.dg/test-error-mismatching-types-in-assignment.c: New.
	* jit.dg/test-error-mismatching-types-in-call.c: New.
	* jit.dg/test-error-missing-return.c: New.
	* jit.dg/test-error-new-binary-op-bad-op.c: New.
	* jit.dg/test-error-new-function-bad-kind.c: New.
	* jit.dg/test-error-new-unary-op-bad-op.c: New.
	* jit.dg/test-error-null-passed-to-api.c: New.
	* jit.dg/test-error-return-within-void-function.c: New.
	* jit.dg/test-error-unreachable-block.c: New.
	* jit.dg/test-error-unterminated-block.c: New.
	* jit.dg/test-error-value-not-a-numeric-type.c: New.
	* jit.dg/test-expressions.c: New.
	* jit.dg/test-factorial.c: New.
	* jit.dg/test-fibonacci.c: New.
	* jit.dg/test-functions.c: New.
	* jit.dg/test-fuzzer.c: New.
	* jit.dg/test-hello-world.c: New.
	* jit.dg/test-linked-list.c: New.
	* jit.dg/test-long-names.c: New.
	* jit.dg/test-nested-contexts.c: New.
	* jit.dg/test-nested-loops.c: New.
	* jit.dg/test-operator-overloading.cc: New.
	* jit.dg/test-quadratic.c: New.
	* jit.dg/test-quadratic.cc: New.
	* jit.dg/test-reading-struct.c: New.
	* jit.dg/test-string-literal.c: New.
	* jit.dg/test-sum-of-squares.c: New.
	* jit.dg/test-threads.c: New.
	* jit.dg/test-types.c: New.
	* jit.dg/test-using-global.c: New.
	* jit.dg/test-volatile.c: New.

include/ChangeLog:
	* ChangeLog.jit: New.

libbacktrace/ChangeLog:
	* ChangeLog.jit: New.

libcpp/ChangeLog:
	* ChangeLog.jit: New.

libdecnumber/ChangeLog:
	* ChangeLog.jit: New.

libiberty/ChangeLog:
	* ChangeLog.jit: New.

zlib/ChangeLog:
	* ChangeLog.jit: New.

From-SVN: r217374
2014-11-11 21:55:52 +00:00