aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/jit-playback.h
AgeCommit message (Collapse)AuthorFilesLines
2020-03-23libgccjit: handle long literals in playback::context::new_string_literalAndreaCorallo1-1/+0
gcc/jit/ChangeLog 2020-03-23 Andrea Corallo <andrea.corallo@arm.com> * jit-playback.h (gcc::jit::playback::context m_recording_ctxt): Remove m_char_array_type_node field. * jit-playback.c (playback::context::context) Remove m_char_array_type_node from member initializer list. (playback::context::new_string_literal) Fix logic to handle string length > 200. gcc/testsuite/ChangeLog 2020-03-23 Andrea Corallo <andrea.corallo@arm.com> * jit.dg/all-non-failing-tests.h: Add test-long-string-literal.c. * jit.dg/test-long-string-literal.c: New testcase.
2020-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r279813
2019-07-04introduce gcc_jit_context_new_bitfieldAndrea Corallo1-1/+10
gcc/jit/ChangeLog: 2019-07-04 Andrea Corallo <andrea.corallo@arm.com> * docs/topics/compatibility.rst (LIBGCCJIT_ABI_12): New ABI tag. * docs/topics/types.rst: Add gcc_jit_context_new_bitfield. * jit-common.h (namespace recording): Add class bitfield. * jit-playback.c: (DECL_C_BIT_FIELD, SET_DECL_C_BIT_FIELD): Add macros. (playback::context::new_bitfield): New method. (playback::compound_type::set_fields): Add bitfield support. (playback::lvalue::mark_addressable): Was jit_mark_addressable make this a method of lvalue plus return a bool to communicate success. (playback::lvalue::get_address): Check for jit_mark_addressable return value. * jit-playback.h (new_bitfield): New method. (class bitfield): New class. (class lvalue): Add jit_mark_addressable method. * jit-recording.c (recording::context::new_bitfield): New method. (recording::bitfield::replay_into): New method. (recording::bitfield::write_to_dump): Likewise. (recording::bitfield::make_debug_string): Likewise. (recording::bitfield::write_reproducer): Likewise. * jit-recording.h (class context): Add new_bitfield method. (class field): Make it derivable by class bitfield. (class bitfield): Add new class. * libgccjit++.h (class context): Add new_bitfield method. * libgccjit.c (struct gcc_jit_bitfield): New structure. (gcc_jit_context_new_bitfield): New function. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_context_new_bitfield) New macro. (gcc_jit_context_new_bitfield): New function. * libgccjit.map (LIBGCCJIT_ABI_12) New ABI tag. gcc/testsuite/ChangeLog: 2019-07-04 Andrea Corallo <andrea.corallo@arm.com> * jit.dg/all-non-failing-tests.h: Add test-accessing-bitfield.c. * jit.dg/test-accessing-bitfield.c: New testcase. * jit.dg/test-error-gcc_jit_context_new_bitfield-invalid-type.c: Likewise. * jit.dg/test-error-gcc_jit_context_new_bitfield-invalid-width.c: Likewise. * jit.dg/test-error-gcc_jit_lvalue_get_address-bitfield.c: Likewise. From-SVN: r273086
2019-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r267494
2018-11-13Eliminate source_location in favor of location_tDavid Malcolm1-1/+1
Historically GCC used location_t, while libcpp used source_location. This inconsistency has been annoying me for a while, so this patch removes source_location in favor of location_t throughout (as the latter is shorter). gcc/ChangeLog: * builtins.c: Replace "source_location" with "location_t". * diagnostic-show-locus.c: Likewise. * diagnostic.c: Likewise. * dumpfile.c: Likewise. * gcc-rich-location.h: Likewise. * genmatch.c: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * input.c: Likewise. * input.h: Likewise. Eliminate the typedef. * omp-expand.c: Likewise. * selftest.h: Likewise. * substring-locations.h (get_source_location_for_substring): Rename to.. (get_location_within_string): ...this. * tree-cfg.c: Replace "source_location" with "location_t". * tree-cfgcleanup.c: Likewise. * tree-diagnostic.c: Likewise. * tree-into-ssa.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-phinodes.h: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa.c: Likewise. * tree-ssa.h: Likewise. * tree-vect-loop-manip.c: Likewise. gcc/c-family/ChangeLog: * c-common.c (c_get_substring_location): Update for renaming of get_source_location_for_substring to get_location_within_string. * c-lex.c: Replace "source_location" with "location_t". * c-opts.c: Likewise. * c-ppoutput.c: Likewise. gcc/c/ChangeLog: * c-decl.c: Replace "source_location" with "location_t". * c-tree.h: Likewise. * c-typeck.c: Likewise. * gimple-parser.c: Likewise. gcc/cp/ChangeLog: * call.c: Replace "source_location" with "location_t". * cp-tree.h: Likewise. * cvt.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * typeck.c: Likewise. gcc/fortran/ChangeLog: * cpp.c: Replace "source_location" with "location_t". * gfortran.h: Likewise. gcc/go/ChangeLog: * go-gcc-diagnostics.cc: Replace "source_location" with "location_t". * go-gcc.cc: Likewise. * go-linemap.cc: Likewise. * go-location.h: Likewise. * gofrontend/README: Likewise. gcc/jit/ChangeLog: * jit-playback.c: Replace "source_location" with "location_t". gcc/testsuite/ChangeLog: * g++.dg/plugin/comment_plugin.c: Replace "source_location" with "location_t". * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise. libcc1/ChangeLog: * libcc1plugin.cc: Replace "source_location" with "location_t". (plugin_context::get_source_location): Rename to... (plugin_context::get_location_t): ...this. * libcp1plugin.cc: Likewise. libcpp/ChangeLog: * charset.c: Replace "source_location" with "location_t". * directives-only.c: Likewise. * directives.c: Likewise. * errors.c: Likewise. * expr.c: Likewise. * files.c: Likewise. * include/cpplib.h: Likewise. Rename MAX_SOURCE_LOCATION to MAX_LOCATION_T. * include/line-map.h: Likewise. * init.c: Likewise. * internal.h: Likewise. * lex.c: Likewise. * line-map.c: Likewise. * location-example.txt: Likewise. * macro.c: Likewise. * pch.c: Likewise. * traditional.c: Likewise. From-SVN: r266085
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-10-04jit: implement gcc_jit_context_new_rvalue_from_vectorDavid Malcolm1-0/+5
This patch implements a new API entrypoint: /* Build a vector rvalue from an array of elements. "vec_type" should be a vector type, created using gcc_jit_type_get_vector. This API entrypoint was added in LIBGCCJIT_ABI_10; you can test for its presence using #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector */ extern gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt, gcc_jit_location *loc, gcc_jit_type *vec_type, size_t num_elements, gcc_jit_rvalue **elements); gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst (Vector expressions): New section. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_10): New ABI tag. * docs/topics/expressions.rst (Vector expressions): New section. * docs/topics/types.rst (gcc_jit_type_get_vector): Add link to gcc_jit_context_new_rvalue_from_vector. * jit-common.h (gcc::jit:recording::vector_type): New forward decl. * jit-playback.c (gcc::jit::playback::context::new_rvalue_from_vector): New method. * jit-playback.h (gcc::jit::playback::context::new_rvalue_from_vector): New method. * jit-recording.c: In namespace gcc::jit:: (class comma_separated_string): New class. (comma_separated_string::comma_separated_string): New ctor, adapted from recording::call::make_debug_string. (comma_separated_string::~comma_separated_string): New dtor. In namespace gcc::jit::recording:: (context::new_rvalue_from_vector): New method. (type::get_vector): Update for renaming of memento_of_get_vector. (class memento_of_get_vector): Rename to... (class vector_type): ..this. (memento_of_new_rvalue_from_vector::memento_of_new_rvalue_from_vector): New ctor. (memento_of_new_rvalue_from_vector::replay_into): New method. (memento_of_new_rvalue_from_vector::visit_children): New method. (memento_of_new_rvalue_from_vector::make_debug_string): New method. (memento_of_new_rvalue_from_vector::write_reproducer): New method. (call::make_debug_string): Split out arg-printing code into ctor for comma_separated_string. * jit-recording.h: In namespace gcc::jit::recording:: (context::new_rvalue_from_vector): New method. (type::dyn_cast_vector_type): New virtual function. (class memento_of_get_vector): Rename to... (class vector_type): ...this. (vector_type::unqualified): Remove this vfunc override in favor of... (vector_type::get_element_type): ...this new method. (vector_type::get_num_units): New method. (vector_type::dyn_cast_vector_type): New vfunc override. (class memento_of_new_rvalue_from_vector): New class. * libgccjit++.h (gccjit::context::new_rvalue): Add overload for vector of rvalue. * libgccjit.c (gcc_jit_context_new_binary_op): Strip off type qualifications when checking that both operands have same type. (gcc_jit_context_new_rvalue_from_vector): New API entrypoint. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector): New macro. (gcc_jit_context_new_rvalue_from_vector): New API entrypoint. * libgccjit.map (LIBGCCJIT_ABI_10): New ABI tag. gcc/testsuite/ChangeLog: * jit.dg/test-expressions.c (make_test_of_vectors): New function. (create_code): Call it. * jit.dg/test-vector-rvalues.cc: New test case. From-SVN: r253409
2017-09-27jit: implement gcc_jit_function_get_addressDavid Malcolm1-0/+3
gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst (Function pointers): New section. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_9): New tag. * docs/topics/expressions.rst (Function pointers): New section. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-common.h (class gcc::jit::recording::function_pointer): New forward decl. * jit-playback.c (gcc::jit::playback::function::get_address): New method. * jit-playback.h (gcc::jit::playback::function::get_address): New method decl. * jit-recording.c: Within namespace gcc::jit::recording... (function::function): Initialize new field "m_fn_ptr_type". (function::get_address): New method. (function_pointer::replay_into): New method. (function_pointer::visit_children): New method. (function_pointer::make_debug_string): New method. (function_pointer::write_reproducer): New method. * jit-recording.h: Within namespace gcc::jit::recording... (function::get_address): New method. (function): Add field "m_fn_ptr_type". (class function_pointer): New subclass of rvalue. * libgccjit++.h (gccjit::function::get_address): New method. * libgccjit.c (gcc_jit_function_get_address): New function. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_function_get_address): New macro. (gcc_jit_function_get_address): New API entrypoint. * libgccjit.map (LIBGCCJIT_ABI_9): New tag. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-returning-function-ptr.c. * jit.dg/test-returning-function-ptr.c: New test case. From-SVN: r253244
2017-08-10jit: add gcc_jit_type_get_vectorDavid Malcolm1-0/+1
gcc/jit/ChangeLog: * docs/cp/topics/types.rst (Vector types): New section. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_8): New tag. * docs/topics/types.rst (gcc_jit_context_get_type): Fix typo in example. (Vector types): New section. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::type::get_vector): New method. * jit-playback.h (gcc::jit::playback::type::get_vector): New method. * jit-recording.c: In namespace gcc::jit::recording:: (type::get_vector): New method. (memento_of_get_aligned::write_reproducer): Fix typo in leading comment. (memento_of_get_vector::replay_into): New method. (memento_of_get_vector::make_debug_string): New method. (memento_of_get_vector::write_reproducer): New method. * jit-recording.h: In namespace gcc::jit::recording:: (type::get_vector): New method. (class memento_of_get_vector): New class. * libgccjit++.h (gccjit::type::get_vector): New method. * libgccjit.c (gcc_jit_type_get_vector): New public entrypoint. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_type_get_vector): New define. (gcc_jit_type_get_vector): New decl. * libgccjit.map (LIBGCCJIT_ABI_8): New ABI tag. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add note about test-vector-types.cc. * jit.dg/test-error-gcc_jit_type_get_vector-bad-type.c: New test case. * jit.dg/test-error-gcc_jit_type_get_vector-non-power-of-two.c: New test case. * jit.dg/test-vector-types.cc: New test case. From-SVN: r251018
2017-04-24types.rst (gccjit::type::get_const): Remove comment.David Malcolm1-0/+2
gcc_jit_type_get_aligned gcc/jit/ChangeLog: * docs/cp/topics/types.rst (gccjit::type::get_const): Remove comment. (gccjit::type::get_aligned): Add. * docs/topics/compatibility.rst: Add LIBGCCJIT_ABI_7. * docs/topics/types.rst: Add gcc_jit_type_get_aligned. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::type::get_aligned): New method. * jit-playback.h (gcc::jit::playback::type::get_aligned): New method. * jit-recording.c: Within namespace gcc::jit::recording... (type::get_aligned): New method. (memento_of_get_aligned::replay_into): New method. (memento_of_get_aligned::make_debug_string): New method. (memento_of_get_aligned::write_reproducer): New method. * jit-recording.h: Within namespace gcc::jit::recording... (type::get_aligned): New method. (type::accepts_writes_from): Strip off qualifications from this when comparing pointer equality. (decorated_type): New subclass of type, subsuming the commonality between memento_of_get_const and memento_of_get_volatile. (memento_of_get_const): Make a subclass of decorated_type, rather than type. (memento_of_get_volatile): Likewise. (memento_of_get_aligned): Likewise. * libgccjit++.h: Within namespace gccjit... (type::get_const): New method. (type::get_aligned): New method. * libgccjit.c (gcc_jit_type_get_aligned): New function. * libgccjit.h (gcc_jit_type_get_aligned): New decl. * libgccjit.map (LIBGCCJIT_ABI_7): New (gcc_jit_type_get_aligned): Add. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-alignment.c. * jit.dg/test-alignment.c: New test case. * jit.dg/test-alignment.cc: New test case. * jit.dg/test-error-gcc_jit_type_get_aligned-non-power-of-two.c: New test case. From-SVN: r247111
2017-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r243994
2016-05-20jit: implement gcc_jit_rvalue_set_bool_require_tail_callDavid Malcolm1-3/+6
This implements the libgccjit support for must-tail-call via a new: gcc_jit_rvalue_set_bool_require_tail_call API entrypoint. (I didn't implement a wrapper for this within the C++ bindings) gcc/jit/ChangeLog: * docs/topics/compatibility.rst: Add LIBGCCJIT_ABI_6. * docs/topics/expressions.rst (Function calls): Add documentation of gcc_jit_rvalue_set_bool_require_tail_call. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-common.h (gcc::jit::recording::base_call): Add forward decl. * jit-playback.c: Within namespace gcc::jit::playback... (context::build_call) Add "require_tail_call" param and use it to set CALL_EXPR_MUST_TAIL_CALL. (context::new_call): Add "require_tail_call" param. (context::new_call_through_ptr): Likewise. * jit-playback.h: Within namespace gcc::jit::playback... (context::new_call: Add "require_tail_call" param. (context::new_call_through_ptr): Likewise. (context::build_call): Likewise. * jit-recording.c: Within namespace gcc::jit::recording... (base_call::base_call): New constructor. (base_call::write_reproducer_tail_call): New method. (call::call): Update for inheritance from base_call. (call::replay_into): Provide m_require_tail_call to call to new_call. (call::write_reproducer): Call write_reproducer_tail_call. (call_through_ptr::call_through_ptr): Update for inheritance from base_call. (call_through_ptr::replay_into): Provide m_require_tail_call to call to new_call_through_ptr. (recording::call_through_ptr::write_reproducer): Call write_reproducer_tail_call. * jit-recording.h: Within namespace gcc::jit::recording... (rvalue::dyn_cast_base_call): New virtual function. (class base_call): New subclass of class rvalue. (class call): Inherit from base_call rather than directly from rvalue, moving get_precedence and m_args to base_call. (class call_through_ptr): Likewise. * libgccjit.c (gcc_jit_rvalue_set_bool_require_tail_call): New function. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_rvalue_set_bool_require_tail_call): New macro. (gcc_jit_rvalue_set_bool_require_tail_call): New function. * libgccjit.map (LIBGCCJIT_ABI_6): New. (gcc_jit_rvalue_set_bool_require_tail_call): Add. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-factorial-must-tail-call.c. * jit.dg/test-error-impossible-must-tail-call.c: New test case. * jit.dg/test-factorial-must-tail-call.c: New test case. From-SVN: r236531
2016-05-17jit: gcc diagnostics are jit errorsDavid Malcolm1-0/+7
libgccjit performs numerous checks at the API boundary, but if these succeed, it ignores errors and other diagnostics emitted within the core of gcc, and treats the compile of a gcc_jit_context as having succeeded. This patch ensures that if any diagnostics are emitted, they are visible from the libgccjit API, and that the the context is flagged as having failed. For now any kind of diagnostic is treated as a jit error, so warnings and notes also count as errors. gcc/jit/ChangeLog: * dummy-frontend.c: Include diagnostic.h. (jit_begin_diagnostic): New function. (jit_end_diagnostic): New function. (jit_langhook_init): Register jit_begin_diagnostic and jit_end_diagnostic with the global_dc. * jit-playback.c: Include diagnostic.h. (gcc::jit::playback::context::add_diagnostic): New method. * jit-playback.h (struct diagnostic_context): Add forward declaration. (gcc::jit::playback::context::add_diagnostic): New method. gcc/testsuite/ChangeLog: * jit.dg/test-error-array-bounds.c: New test case. From-SVN: r236342
2016-05-13jit: use FINAL and OVERRIDE throughoutDavid Malcolm1-6/+6
Mark most virtual functions in gcc/jit as being FINAL OVERRIDE. gcc::jit::recording::lvalue::access_as_rvalue is the sole OVERRIDE that isn't a FINAL. gcc/jit/ChangeLog: * jit-playback.h: Within namespace gcc:jit::playback... (compile_to_memory::postprocess): Mark with FINAL OVERRIDE. (compile_to_file::postprocess): Likewise. (function::finalizer): Likewise. (block::finalizer): Likewise. (source_file::finalizer): Likewise. (source_line::finalizer): Likewise. * jit-recording.c (gcc::jit::rvalue_usage_validator):: Likewise. * jit-recording.h: Within namespace gcc::jit::recording... (string::replay_into): Mark with FINAL OVERRIDE. (string::make_debug_string): Likewise. (string::write_reproducer): Likewise. (location::replay_into): Likewise. (location::dyn_cast_location): Likewise. (location::make_debug_string): Likewise. (location::write_reproducer): Likewise. (memento_of_get_type::dereference): Likewise. (memento_of_get_type::accepts_writes_from): Likewise. (memento_of_get_type::is_int): Likewise. (memento_of_get_type::is_float): Likewise. (memento_of_get_type::is_bool): Likewise. (memento_of_get_type::is_pointer): Likewise. (memento_of_get_type::is_array): Likewise. (memento_of_get_type::is_void): Likewise. (memento_of_get_type::replay_into): Likewise. (memento_of_get_type::make_debug_string): Likewise. (memento_of_get_type::write_reproducer): Likewise. (memento_of_get_pointer::dereference): Likewise. (memento_of_get_pointer::accepts_writes_from): Likewise. (memento_of_get_pointer::replay_into): Likewise. (memento_of_get_pointer::is_int): Likewise. (memento_of_get_pointer::is_float): Likewise. (memento_of_get_pointer::is_bool): Likewise. (memento_of_get_pointer::is_pointer): Likewise. (memento_of_get_pointer::is_array): Likewise. (memento_of_get_pointer::make_debug_string): Likewise. (memento_of_get_pointer::write_reproducer): Likewise. (memento_of_get_const::dereference): Likewise. (memento_of_get_const::accepts_writes_from): Likewise. (memento_of_get_const::unqualified): Likewise. (memento_of_get_const::is_int): Likewise. (memento_of_get_const::is_float): Likewise. (memento_of_get_const::is_bool): Likewise. (memento_of_get_const::is_pointer): Likewise. (memento_of_get_const::is_array): Likewise. (memento_of_get_const::void replay_into): Likewise; (memento_of_get_const::make_debug_string): Likewise. (memento_of_get_const::write_reproducer): Likewise. (memento_of_get_volatile::dereference): Likewise. (memento_of_get_volatile::unqualified): Likewise. (memento_of_get_volatile::is_int): Likewise. (memento_of_get_volatile::is_float): Likewise. (memento_of_get_volatile::is_bool): Likewise. (memento_of_get_volatile::is_pointer): Likewise. (memento_of_get_volatile::is_array): Likewise. (memento_of_get_volatile::replay_into): Likewise; (memento_of_get_volatile::make_debug_string): Likewise. (memento_of_get_volatile::write_reproducer): Likewise. (array_type::dereference): Likewise. (array_type::is_int): Likewise. (array_type::is_float): Likewise. (array_type::is_bool): Likewise. (array_type::is_pointer): Likewise. (array_type::is_array): Likewise. (array_type::replay_into): Likewise; (array_type::make_debug_string): Likewise. (array_type::write_reproducer): Likewise. (function_type::dereference): Likewise. (function_type::function_dyn_cast_function_type): Likewise. (function_type::function_as_a_function_type): Likewise. (function_type::is_int): Likewise. (function_type::is_float): Likewise. (function_type::is_bool): Likewise. (function_type::is_pointer): Likewise. (function_type::is_array): Likewise. (function_type::replay_into): Likewise; (function_type::make_debug_string): Likewise. (function_type::write_reproducer): Likewise. (field::replay_into): Likewise; (field::write_to_dump): Likewise. (field::make_debug_string): Likewise. (field::write_reproducer): Likewise. (compound_type::dereference): Likewise. (compound_type::is_int): Likewise. (compound_type::is_float): Likewise. (compound_type::is_bool): Likewise. (compound_type::is_pointer): Likewise. (compound_type::is_array): Likewise. (compound_type::has_known_size): Likewise. (struct_::dyn_cast_struct): Likewise. (struct_::replay_into): Likewise. (struct_::access_as_type): Likewise. (struct_::make_debug_string): Likewise. (struct_::write_reproducer): Likewise. (fields::replay_into): Likewise. (fields::write_to_dump): Likewise. (fields::make_debug_string): Likewise. (fields::write_reproducer): Likewise. (union_::replay_into): Likewise. (union_::make_debug_string): Likewise. (union_::write_reproducer): Likewise. (lvalue::access_as_rvalue): Mark with OVERRIDE. (param::replay_into): Mark with FINAL OVERRIDE. (param::visit_children): Likewise. (param::dyn_cast_param): Likewise. (param::access_as_rvalue): Likewise. (param::access_as_lvalue): Likewise. (param::make_debug_string): Likewise. (param::write_reproducer): Likewise. (param::get_precedence): Likewise. (function::replay_into): Likewise. (function::write_to_dump): Likewise. (function::make_debug_string): Likewise. (function::write_reproducer): Likewise. (block::write_to_dump): Likewise. (block::make_debug_string): Likewise. (block::write_reproducer): Likewise. (block::replay_into): Likewise. (global::replay_into): Likewise; (global::visit_children): Likewise. (global::write_to_dump): Likewise. (global::make_debug_string): Likewise. (global::write_reproducer): Likewise. (global::get_precedence): Likewise. (memento_of_new_rvalue_from_const::replay_into): Likewise. (memento_of_new_rvalue_from_const::visit_children): Likewise. (memento_of_new_rvalue_from_const::is_constant): Likewise. (memento_of_new_rvalue_from_const::get_wide_int): Likewise. (memento_of_new_rvalue_from_const::make_debug_string): Likewise. (memento_of_new_rvalue_from_const::write_reproducer): Likewise. (memento_of_new_rvalue_from_const::get_precedence): Likewise. (memento_of_new_string_literal::replay_into): Likewise. (memento_of_new_string_literal::visit_children): Likewise. (memento_of_new_string_literal::make_debug_string): Likewise. (memento_of_new_string_literal::write_reproducer): Likewise. (memento_of_new_string_literal::get_precedence): Likewise. (unary_op::replay_into): Likewise. (unary_op::visit_children): Likewise. (unary_op::make_debug_string): Likewise. (unary_op::write_reproducer): Likewise. (unary_op::get_precedence): Likewise. (binary_op::replay_into): Likewise. (binary_op::visit_children): Likewise. (binary_op::make_debug_string): Likewise. (binary_op::write_reproducer): Likewise. (binary_op::get_precedence): Likewise. (comparison::replay_into): Likewise. (comparison::visit_children): Likewise. (comparison::make_debug_string): Likewise. (comparison::write_reproducer): Likewise. (comparison::get_precedence): Likewise. (cast::replay_into): Likewise. (cast::visit_children): Likewise. (cast::make_debug_string): Likewise. (cast::write_reproducer): Likewise. (cast::get_precedence): Likewise. (call::replay_into): Likewise. (call::visit_children): Likewise. (call::make_debug_string): Likewise. (call::write_reproducer): Likewise. (call::get_precedence): Likewise. (call_through_ptr::replay_into): Likewise. (call_through_ptr::visit_children): Likewise. (call_through_ptr::make_debug_string): Likewise. (call_through_ptr::write_reproducer): Likewise. (call_through_ptr::get_precedence): Likewise. (array_access::replay_into): Likewise. (array_access::visit_children): Likewise. (array_access::make_debug_string): Likewise. (array_access::write_reproducer): Likewise. (array_access::get_precedence): Likewise. (access_field_of_lvalue::replay_into): Likewise. (access_field_of_lvalue::visit_children): Likewise. (access_field_of_lvalue::make_debug_string): Likewise. (access_field_of_lvalue::write_reproducer): Likewise. (access_field_of_lvalue::get_precedence): Likewise. (access_field_rvalue::replay_into): Likewise. (access_field_rvalue::visit_children): Likewise. (access_field_rvalue::make_debug_string): Likewise. (access_field_rvalue::write_reproducer): Likewise. (access_field_rvalue::get_precedence): Likewise. (dereference_field_rvalue::replay_into): Likewise. (dereference_field_rvalue::visit_children): Likewise. (dereference_field_rvalue::make_debug_string): Likewise. (dereference_field_rvalue::write_reproducer): Likewise. (dereference_field_rvalue::get_precedence): Likewise. (dereference_rvalue::replay_into): Likewise. (dereference_rvalue::visit_children): Likewise. (dereference_rvalue::make_debug_string): Likewise. (dereference_rvalue::write_reproducer): Likewise. (dereference_rvalue::get_precedence): Likewise. (get_address_of_lvalue::replay_into): Likewise. (get_address_of_lvalue::visit_children): Likewise. (get_address_of_lvalue::make_debug_string): Likewise. (get_address_of_lvalue::write_reproducer): Likewise. (get_address_of_lvalue::get_precedence): Likewise. (local::replay_into): Likewise. (local::visit_children): Likewise. (local::write_to_dump): Likewise. (local::make_debug_string): Likewise. (local::write_reproducer): Likewise. (local::get_precedence): Likewise. (statement::write_to_dump): Likewise. (eval::replay_into): Likewise. (eval::make_debug_string): Likewise. (eval::write_reproducer): Likewise. (assignment::replay_into): Likewise. (assignment::make_debug_string): Likewise. (assignment::write_reproducer): Likewise. (assignment_op::replay_into): Likewise. (assignment_op::make_debug_string): Likewise. (assignment_op::write_reproducer): Likewise. (comment::replay_into): Likewise. (comment::make_debug_string): Likewise. (comment::write_reproducer): Likewise. (conditional::replay_into): Likewise. (conditional::get_successor_blocks): Likewise. (conditional::make_debug_string): Likewise. (conditional::write_reproducer): Likewise. (jump::replay_into): Likewise. (jump::get_successor_blocks): Likewise. (jump::make_debug_string): Likewise. (jump::write_reproducer): Likewise. (return_::replay_into): Likewise. (return_::get_successor_blocks): Likewise. (return_::make_debug_string): Likewise. (return_::write_reproducer): Likewise. (case_::replay_into): Likewise. (case_::write_reproducer): Likewise. (case_::make_debug_string): Likewise. (switch_::replay_into): Likewise. (switch_::get_successor_blocks): Likewise. (switch_::make_debug_string): Likewise. (switch_::write_reproducer): Likewise. From-SVN: r236223
2016-01-04Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r232055
2015-08-25Support embedding the driver in-process within libgccjitDavid Malcolm1-0/+14
gcc/ChangeLog: * gcc-main.c (main): Add params to driver ctor. * gcc.c (class env_manager): New. (env): New global. (env_manager::init): New. (env_manager::get): New. (env_manager::xput): New. (env_manager::restore): New. Poison getenv and putenv. (DEFAULT_TARGET_SYSTEM_ROOT): New. (target_system_root): Update initialization to use DEFAULT_TARGET_SYSTEM_ROOT. (struct spec_list): Add field "default_ptr". (INIT_STATIC_SPEC): Initialize new field "default_ptr". (init_spec): Likewise. (set_spec): Clear field "default_ptr". (read_specs): Free "spec" and "buffer". (xputenv): Reimplement in terms of env_manager. (process_command): Replace ::getenv calls with calls to the env_manager singleton. (process_brace_body): Free string in three places. (driver::driver): New. (driver::~driver): New. (used_arg): Convert from a function to... (class used_arg_t): ...this class, and... (used_arg): ...this new global instance. (used_arg_t::finalize): New function. (getenv_spec_function): Add "const" to local "value". Replace ::getenv call with call to the env_manager singleton. (path_prefix_reset): New function. (driver::finalize): New function. * gcc.h (driver::driver): New. (driver::~driver): New. (driver::finalize): New. gcc/jit/ChangeLog: * docs/cp/topics/contexts.rst (gccjit::context::set_bool_use_external_driver): New. * docs/internals/test-hello-world.exe.log.txt: Update. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_5): New. * docs/topics/contexts.rst (gcc_jit_context_set_bool_use_external_driver): New. * jit-common.h (enum inner_bool_option): Add INNER_BOOL_OPTION_USE_EXTERNAL_DRIVER. * jit-playback.c (gcc_driver_name): New global. (gcc:jit::playback::context::invoke_driver): Split out second half into... (gcc::jit::playback::context::invoke_embedded_driver): ...this new function, and... (gcc::jit::playback::context::invoke_external_driver): ...this new function. * jit-playback.h (gcc::jit::playback::context::get_inner_bool_option): New. (gcc::jit::playback::context::invoke_embedded_driver): New. (gcc::jit::playback::context::invoke_external_driver): New. * jit-recording.c (inner_bool_option_reproducer_strings): Add entry for INNER_BOOL_OPTION_USE_EXTERNAL_DRIVER. * libgccjit++.h (gccjit::context::set_bool_use_external_driver): New. * libgccjit.c (gcc_jit_context_set_bool_use_external_driver): New. * libgccjit.h (gcc_jit_context_set_bool_use_external_driver): New. (LIBGCCJIT_HAVE_gcc_jit_context_set_bool_use_external_driver): New. * libgccjit.map (LIBGCCJIT_ABI_5): New. * notes.txt: Show invocation of embedded copy of driver. * docs/internals/test-hello-world.exe.log.txt: Update gcc/testsuite/ChangeLog: * jit.dg/test-error-pr63969-missing-driver.c: Add call to gcc_jit_context_set_bool_use_external_driver. From-SVN: r227188
2015-08-03Refactoring of timevar APIDavid Malcolm1-0/+2
gcc/ChangeLog: * main.c (main): Pass in NULL for toplev's external_timer. * timevar.c: Include coretypes.h. (class timer::named_items): New. (timer::named_items::named_items): New. (timer::named_items::~named_items): New. (timer::named_items::push): New. (timer::named_items::pop): New. (timer::named_items::print): New. (timer::timer): Initialize field "m_jit_client_items". (timer::~timer): New. (timer::push): Move bulk of implementation to... (timer::push_internal): ...here. New function. (timer::pop): Move bulk of implementation to... (timer::pop_internal): ...here. New function. (timer::push_client_item): New. (timer::pop_client_item): New. (timer::print_row): New function, taken from timer::print. (timer::print): Print "GCC items" header if we also have client items. Move row-printing to timer::print_row. Print any client items. (timer::get_topmost_item_name): New method. * timevar.def (TV_JIT_ACQUIRING_MUTEX): New. (TV_JIT_CLIENT_CODE): New. * timevar.h (timer::push_client_item): New declaration. (timer::pop_client_item): New declaration. (timer::get_topmost_item_name): New method. (timer::push_internal): New declaration. (timer::pop_internal): New declaration. (timer::print_row): New declaration. (timer::named_items): New declaration. (timer::m_jit_client_items): New field. (timer): Add friend class named_items. (auto_timevar::auto_timevar): Add timer param. (auto_timevar::~auto_timevar): Use field "m_timer". (auto_timevar::m_timer): New field. * toplev.c (initialize_rtl): Add g_timer as param when constructing auto_timevar instance. (toplev::toplev): Add "external_timer" param, and use it to initialize the "g_timer" global if non-NULL. (toplev::~toplev): If this created "g_timer", delete it. * toplev.h (toplev::toplev): Replace "use_TV_TOTAL" bool param with "external_timer" timer *. gcc/jit/ChangeLog: * docs/topics/compatibility.rst (LIBGCCJIT_ABI_4): New. * docs/topics/contexts.rst (GCC_JIT_BOOL_OPTION_DUMP_SUMMARY): We no longer show a profile. * docs/topics/index.rst (Topic Reference): Add performance.rst. * docs/topics/performance.rst: New file. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::context::compile): Add timer param when constructing the "toplev" instance. (gcc::jit::playback::context::acquire_mutex): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::make_fake_args): If we have a timer, add "-ftime-report". (gcc::jit::playback::context::invoke_driver): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::dlopen_built_dso): Likewise. * jit-playback.h (gcc::jit::playback::context::get_timer): New accessor. * jit-recording.c: Include timevar.h. (gcc::jit::recording::context::context): Initialize field "m_timer". * jit-recording.h: Add forward declaration of class timer. (gcc::jit::recording::context::set_timer): New method. (gcc::jit::recording::context::get_timer): New method. (gcc::jit::recording::context::m_timer): New field. * libgccjit++.h (gccjit::timer): New class. (gccjit::auto_time): New class. (gccjit::context::set_timer): New method. (gccjit::context::get_timer): New. (gccjit::timer::timer): New. (gccjit::timer::push): New. (gccjit::timer::pop): New. (timer::print): New. (timer::get_inner_timer): New. (timer::release): New. (auto_time::auto_time): New. (auto_time::~auto_time): New. * libgccjit.c: Include timevar.h. (struct gcc_jit_timer): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.h (LIBGCCJIT_HAVE_TIMING_API): New macro. (gcc_jit_timer): New typedef. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.map (LIBGCCJIT_ABI_4): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. gcc/testsuite/ChangeLog: * jit.dg/test-benchmark.c (test_jit): Add param "timer" and use it to push/pop timing items. (main): For each optimization level, create a gcc_jit_timer, and time all of the iteration within that level cumulatively. * jit.dg/test-error-gcc_jit_timer_pop-mismatch.c: New test case. * jit.dg/test-error-gcc_jit_timer_pop-too-many.c: New test case. From-SVN: r226530
2015-07-23jit: supply MULTILIB_DEFAULTS as arguments when invoking driverDavid Malcolm1-0/+3
gcc/jit/ChangeLog: * jit-playback.c (invoke_driver): Convert local "argvec" to an auto_argvec, so that it owns copies of the strings, rather than borrows them, updating ADD_ARG to use xstrdup and special-casing the NULL terminator to avoid xstrdup (NULL). Call add_multilib_driver_arguments at the front of the arguments. (MULTILIB_DEFAULTS): Provide a default definition. (multilib_defaults_raw): New constant array. (gcc::jit::playback::context::add_multilib_driver_arguments): New method. * jit-playback.h (gcc::jit::playback::context::add_multilib_driver_arguments): New method. * docs/internals/test-hello-world.exe.log.txt: Update. * docs/_build/texinfo/libgccjit.texi: Regenerate. From-SVN: r226126
2015-06-30jit: add switch statementsDavid Malcolm1-0/+21
gcc/ChangeLog: * typed-splay-tree.h: New file. gcc/jit/ChangeLog: * docs/cp/topics/functions.rst (Blocks): Add switch statements to list of ways to terminate a block. (gccjit::block::end_with_switch): Add function description. (gccjit::case_): Add class. (gccjit::context::new_case): Add function description. * docs/cp/topics/objects.rst: Add "case_" to class hierarchy. * docs/topics/compatibility.rst (LIBGCCJIT_ABI_3): New. * docs/topics/functions.rst (Blocks): Add switch statements to list of ways to terminate a block. (gcc_jit_block_end_with_switch): Add function description. (gcc_jit_case): Add type. (gcc_jit_context_new_case): Add function description. (gcc_jit_case_as_object): Add function description. * docs/topics/objects.rst: Add gcc_jit_case to class hierarchy. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-common.h (gcc::jit::recording::case_): Add forward decl. (gcc::jit::playback::case_): Add forward decl. * jit-playback.c (add_case): New function. (gcc::jit::playback::block::add_switch): New function. * jit-playback.h (gcc::jit::playback::case_): New struct. (gcc::jit::playback::block::get_function): New method. (gcc::jit::playback::block::add_switch): New method. * jit-recording.c: Within namespace gcc::jit... (recording::context::new_case): New method. (recording::function::validate): Update for change to get_successor_blocks. (recording::block::end_with_switch): New method. (recording::block::get_successor_blocks): Update to support an arbitrary number of successor blocks. (recording::block::dump_edges_to_dot): Likewise. (memento_of_new_rvalue_from_const <int>::get_wide_int): New. (memento_of_new_rvalue_from_const <long>::get_wide_int): New. (memento_of_new_rvalue_from_const <double>::get_wide_int): New. (memento_of_new_rvalue_from_const <void *>::get_wide_int): New. (recording::statement::get_successor_blocks): Update to support an arbitrary number of successor blocks. (recording::conditional::get_successor_blocks): Likewise. (recording::jump::get_successor_blocks): Likewise. (recording::return_::get_successor_blocks): Likewise. (recording::case_::write_reproducer): New. (recording::case_::make_debug_string): New. (recording::switch_::switch_): New. (recording::switch_::replay_into): New. (recording::switch_::get_successor_blocks): New. (recording::switch_::make_debug_string): New. (recording::switch_::write_reproducer): New. * jit-recording.h: Within namespace gcc::jit::recording... (context::new_case): New. (rvalue::is_constant): New. (rvalue::get_wide_int): New. (block::end_with_switch): New. (block::get_successor_blocks): Update to support an arbitrary number of successor blocks. (memento_of_new_rvalue_from_const::is_constant): New. (memento_of_new_rvalue_from_const::get_wide_int): New. (statement::get_successor_blocks): Update to support an arbitrary number of successor blocks. (conditional::get_successor_blocks): Likewise. (jump::get_successor_blocks): Likewise. (return_::get_successor_blocks): Likewise. (case_): New subclass of memento. (switch_): New subclass of statement. * libgccjit++.h (gccjit::case_): New subclass of gccjit::object. (gccjit::context::new_case): New method. (gccjit::block::end_with_switch): New method. (gccjit::case_::case): New ctors. (gccjit::case_::get_inner_case): New method. * libgccjit.c: Include "typed-splay-tree.h" (struct gcc_jit_case): New. (gcc_jit_context_new_case): New function. (gcc_jit_case_as_object): New function. (valid_dest_for_switch): New function. (valid_case_for_switch): New function. (class api_call_validator): New class. (class case_range_validator): New class. (case_range_validator::case_range_validator): New. (case_range_validator::validate): New. (case_range_validator::case_compare): New. (case_range_validator::get_wide_int): new. (gcc_jit_block_end_with_switch): New. * libgccjit.h: Add gcc_jit_case to class hierarchy comment. (gcc_jit_case): New typedef. (gcc_jit_context_new_case): New function. (gcc_jit_case_as_object): New function. (gcc_jit_block_end_with_switch): New function. (LIBGCCJIT_HAVE_SWITCH_STATEMENTS): New. * libgccjit.map: Add gcc_jit_block_end_with_switch, gcc_jit_case_as_object and gcc_jit_context_new_case. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-switch.c. * jit.dg/test-error-gcc_jit_block_end_with_switch-NULL-case.c: New testcase. * jit.dg/test-error-gcc_jit_block_end_with_switch-mismatching-case-type.c: New testcase. * jit.dg/test-error-gcc_jit_block_end_with_switch-overlapping-ranges.c: New testcase. * jit.dg/test-error-gcc_jit_context_new_case-non-const-label.c: New testcase. * jit.dg/test-error-gcc_jit_context_new_case-non-integer-type.c: New testcase. * jit.dg/test-error-gcc_jit_context_new_case-reversed-endpoints.c: New testcase. * jit.dg/test-switch.c: New testcase. * jit.dg/test-switch.cc: New testcase. From-SVN: r225207
2015-06-05Remove jit_langhook_post_compilation_parsing_cleanupsDavid Malcolm1-2/+0
gcc/jit/ChangeLog: * dummy-frontend.c (jit_langhook_post_compilation_parsing_cleanups): Remove. (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): Remove * jit-playback.c (gcc::jit::playback::context::new_global): Add call to varpool_node::finalize_decl. (gcc::jit::playback::context::finalize_global_decls): Remove. * jit-playback.h (gcc::jit::playback::context::finalize_global_decls): Remove. From-SVN: r224173
2015-06-05Fix build of jit after debug-early mergerDavid Malcolm1-3/+1
gcc/jit/ChangeLog: * dummy-frontend.c (jit_langhook_write_globals): Rename to... (jit_langhook_post_compilation_parsing_cleanups): ...this, and eliminate calls to finalize_compilation_unit and write_global_decls_2. (LANG_HOOKS_WRITE_GLOBALS): Rename to... (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): ...this and redirect from jit_langhook_write_globals to jit_langhook_post_compilation_parsing_cleanups. * jit-playback.c (gcc::jit::playback::context::write_global_decls_1): Rename to... (gcc::jit::playback::context::finalize_global_decls): ...this. (gcc::jit::playback::context::write_global_decls_1): Delete. * jit-playback.h (gcc::jit::playback::context::write_global_decls_1): Rename to... (gcc::jit::playback::context::finalize_global_decls): ...this. (gcc::jit::playback::context::write_global_decls_1): Delete. From-SVN: r224170
2015-01-20New jit API entrypoint: gcc_jit_context_compile_to_fileDavid Malcolm1-1/+53
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-12jit: API change to gcc_jit_context_new_globalDavid Malcolm1-0/+6
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-09New jit API entrypoint: gcc_jit_context_new_rvalue_from_longDavid Malcolm1-10/+3
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-08New jit API entrypoint: gcc_jit_context_set_logfileDavid Malcolm1-1/+1
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-05Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r219189
2014-12-09Add jit-tempdir.{c|h}David Malcolm1-10/+5
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-09Guard less code with the JIT mutexDavid Malcolm1-0/+3
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-09jit-playback.c: Move dlopen code into a new functionDavid Malcolm1-0/+3
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-09PR jit/64166: Add API entrypoint gcc_jit_context_enable_dumpDavid Malcolm1-2/+10
gcc/jit/ChangeLog: PR jit/64166 * docs/topics/contexts.rst (Debugging): Add description of gcc_jit_context_enable_dump. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c: Include context.h. (class auto_argvec): New class. (auto_argvec::~auto_argvec): New function. (gcc::jit::playback::context::compile): Convert fake_args to be an auto_argvec, so that it can contain dynamically-allocated strings. Construct a vec of all requested dumps, and pass it to make_fake_args. Extract requested dumps between the calls to toplev::main and toplev::finalize. (gcc::jit::playback::context::make_fake_args): Convert param "argvec" to be a vec <char *>, and gain a "requested_dumps" param. Convert to dynamically-allocated arg strings by converting ADD_ARG to take a copy of the arg, and add ADD_ARG_TAKE_OWNERSHIP for args that are already a copy. Add args for all requested dumps. (gcc::jit::playback::context::extract_any_requested_dumps): New function. (gcc::jit::playback::context::read_dump_file): New function. * jit-playback.h (gcc::jit::playback::context::make_fake_args): Convert param "argvec" to be a vec <char *>, and gain a "requested_dumps" param. (gcc::jit::playback::context::extract_any_requested_dumps): New function. (gcc::jit::playback::context::read_dump_file): New function. * jit-recording.c (gcc::jit::recording::context::enable_dump): New function. (gcc::jit::recording::context::get_all_requested_dumps): New function. * jit-recording.h (gcc::jit::recording::requested_dump): New struct. (gcc::jit::recording::context::enable_dump): New function. (gcc::jit::recording::context::get_all_requested_dumps): New function. (gcc::jit::recording::context::m_requested_dumps): New field. * libgccjit.c (gcc_jit_context_enable_dump): New API entrypoint. * libgccjit.h (gcc_jit_context_enable_dump): New API entrypoint. * libgccjit.map (gcc_jit_context_enable_dump): New API entrypoint. gcc/testsuite/ChangeLog: PR jit/64166 PR jit/64020 * jit.dg/harness.h (CHECK_STRING_CONTAINS): New macro. (check_string_contains): New function. * jit.dg/test-error-unrecognized-dump.c: New file. * jit.dg/test-functions.c (trig_sincos_dump): New variable. (trig_statistics_dump): New variable. (create_test_of_builtin_trig): Enable dumping of "sincos" and "statistics" into "trig_sincos_dump" and "trig_statistics_dump". (verify_test_of_builtin_trig): Verify the sincos and statistics dumps. * jit.dg/test-sum-of-squares.c (dump_vrp1): New variable. (create_code): Enable dumping of "tree-vrp1" into dump_vrp1. (verify_code): Verify the tree-vrp1 dump. From-SVN: r218521
2014-12-01PR jit/64020: Fixes to handling of builtinsDavid Malcolm1-0/+5
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-01jit-playback: Move dso-creation into its own functionDavid Malcolm1-0/+3
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-01jit-playback: Move argv-creation to its own functionDavid Malcolm1-0/+8
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-11-19PR jit/63854: Fix leaking vec in jitDavid Malcolm1-9/+18
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-11Merger of dmalcolm/jit branch from gitDavid Malcolm1-0/+564
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