PR bootstrap/66085
[official-gcc.git] / gcc / jit / ChangeLog
blob6c6d0a879de4df8d30bc8aa868c3349e32c90c3b
1 2015-04-27  Jim Wilson  <jim.wilson@linaro.org>
3         * Make-lang.in (jit.mostlyclean): Remove shared libraries and object
4         files.
6 2015-04-09  David Malcolm  <dmalcolm@redhat.com>
8         PR jit/65691
9         * docs/cp/topics/expressions.rst (Simple expressions): Fix copy
10         and paste error in description of gccjit::context::one.
11         * docs/topics/expressions.rst (Simple expressions): Likewise in
12         description of gcc_jit_context_one.
13         * docs/_build/texinfo/libgccjit.texi: Regenerate.
15 2015-03-13  Uros Bizjak  <ubizjak@gmail.com>
17         * jit-recording.c (dump::write): Also check vasprintf return value.
18         (recording::context::add_error_va): Ditto.
19         (recording::string::from_printf): Ditto.
21 2015-03-13  David Malcolm  <dmalcolm@redhat.com>
23         * docs/internals/index.rst (Packaging notes): New section.
24         * docs/_build/texinfo/libgccjit.texi: Regenerate.
26 2015-03-05  David Malcolm  <dmalcolm@redhat.com>
28         * docs/cp/intro/tutorial03.rst: Add missing arguments to
29         gccjit::block::end_with_conditional call.  Add on_true/on_false
30         comments.  Tweak the wording.
31         * docs/intro/tutorial03.rst: Add missing arguments to
32         gcc_jit_block_end_with_conditional call.  Add some clarifying
33         comments.
34         * docs/topics/compilation.rst: Tweak the wording to avoid an
35         ambiguous use of "this".
36         * docs/topics/contexts.rst: Fix a typo.
37         * docs/topics/expressions.rst (GCC_JIT_BINARY_OP_MINUS): Remove
38         a stray backtick.
39         * docs/_build/texinfo/libgccjit.texi: Regenerate.
41 2015-02-24  Thomas Schwinge  <thomas@codesourcery.com>
43         PR libgomp/64625
44         * jit-builtins.c (DEF_FUNCTION_TYPE_VAR_8)
45         (DEF_FUNCTION_TYPE_VAR_12): Remove macros.
46         (DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
47         * jit-builtins.h (DEF_FUNCTION_TYPE_VAR_8)
48         (DEF_FUNCTION_TYPE_VAR_12): Remove macros.
49         (DEF_FUNCTION_TYPE_VAR_7, DEF_FUNCTION_TYPE_VAR_11): New macros.
51 2015-02-04  David Malcolm  <dmalcolm@redhat.com>
53         PR jit/64257
54         * docs/conf.py (html_theme): Change from 'pyramid'
55         to 'sphinxdoc'.
57 2015-02-04  David Malcolm  <dmalcolm@redhat.com>
59         * docs/topics/contexts.rst (gcc_jit_context_acquire): Fix
60         typo.
61         * docs/_build/texinfo/libgccjit.texi: Regenerate.
63 2015-02-03  David Malcolm  <dmalcolm@redhat.com>
65         * jit-logging.h (gcc::jit::log_user::log): Make const.
66         * jit-recording.c (gcc::jit::recording::context::set_str_option):
67         Log the new value of the option.
68         (gcc::jit::recording::context::set_int_option): Likewise.
69         (gcc::jit::recording::context::set_bool_option): Likewise.
70         (gcc::jit::recording::context::compile): Log the value of all
71         options.
72         (gcc::jit::recording::context::compile_to_file): Likewise.
73         (gcc::jit::recording::context::log_all_options): New function.
74         (gcc::jit::recording::context::log_str_option): New function.
75         (gcc::jit::recording::context::log_int_option): New function.
76         (gcc::jit::recording::context::log_bool_option): New function.
77         * jit-recording.h (gcc::jit::recording::context::log_all_options):
78         New function.
79         (gcc::jit::recording::context::log_str_option): New function.
80         (gcc::jit::recording::context::log_int_option): New function.
81         (gcc::jit::recording::context::log_bool_option): New function.
82         * docs/internals/test-hello-world.exe.log.txt: Update for above
83         changes.
84         * docs/_build/texinfo/libgccjit.texi: Regenerate.
86 2015-02-03  David Malcolm  <dmalcolm@redhat.com>
88         PR jit/64810
89         * Make-lang.in (jit_OBJS): Add jit/jit-spec.o and gcc.o.
90         (LIBGCCJIT_FILENAME): Add EXTRA_GCC_OBJS.
91         * jit-playback.c: Include gcc.h.
92         (gcc::jit::playback::context::compile): Move mutex acquisition
93         to before the call to make_fake_args.
94         (append_arg_from_driver): New function.
95         (gcc::jit::playback::context::make_fake_args): On the first call,
96         call into driver_get_configure_time_options to get configure-time
97         default options and cache them.  Add them to the args for
98         toplev::main.
99         * jit-spec.c: New source file.
100         * docs/internals/test-hello-world.exe.log.txt: Update to reflect
101         above changes.
102         * docs/_build/texinfo/libgccjit.texi: Regenerate.
104 2015-02-02  David Malcolm  <dmalcolm@redhat.com>
106         PR jit/64810
107         * dummy-frontend.c (jit_langhook_type_for_mode): Support
108         TYPE_MODE (long_long_integer_type_node).
110 2015-01-27  David Malcolm  <dmalcolm@redhat.com>
112         * docs/internals/test-hello-world.exe.log.txt: Add example version
113         lines.
114         * docs/_build/texinfo/libgccjit.texi: Regenerate.
115         * jit-common.h (gcc::jit::dump::get_file): New accessor.
116         * jit-logging.c: Include toplev.h.
117         (gcc::jit::logger::logger): Log the GCC version.
118         * jit-recording.c: Include toplev.h.
119         (gcc:jit::recording::context::dump_reproducer_to_file): Log the
120         GCC version.
122 2015-01-26  David Malcolm  <dmalcolm@redhat.com>
124         * docs/topics/compilation.rst (gcc_jit_result_get_code): Fix typo.
125         * docs/topics/contexts.rst (gcc_jit_context_get_last_error): The
126         error buffer is only valid until the next call to the context.
127         * docs/_build/texinfo/libgccjit.texi: Regenerate.
128         * libgccjit.h (gcc_jit_context_get_first_error): Reword the
129         comment to omit mention of compiling.
130         (gcc_jit_context_get_last_error): The error buffer is only valid
131         until the next call to the context.
133 2015-01-26  David Malcolm  <dmalcolm@redhat.com>
135         PR jit/64708
136         * config-lang.in (compilers): Drop "libgccjit.so".
138 2015-01-23  David Malcolm  <dmalcolm@redhat.com>
140         PR jit/64721
141         * jit-playback.c (gcc::jit::playback::context::compile): Construct
142         toplev instances with init_signals=false.
144 2015-01-19  David Malcolm  <dmalcolm@redhat.com>
146         * docs/cp/topics/results.rst: Rename to...
147         * docs/cp/topics/compilation.rst: ...this, and add section on
148         ahead-of-time compilation.
149         * docs/cp/topics/index.rst: Update for renaming of results.rst
150         to compilation.rst.
151         * docs/examples/emit-alphabet.bf: New file, a sample "brainf"
152         script.
153         * docs/examples/tut05-bf.c: New file, implementing a compiler
154         for "brainf".
155         * docs/internals/test-hello-world.exe.log.txt: Update to reflect
156         changes to logger output.
157         * docs/intro/index.rst: Add tutorial05.rst
158         * docs/intro/tutorial05.rst: New file.
159         * docs/topics/results.rst: Rename to...
160         * docs/topics/compilation.rst: ...this, and add section on
161         ahead-of-time compilation.
162         * docs/topics/index.rst: Update for renaming of results.rst to
163         compilation.rst.
164         * docs/_build/texinfo/libgccjit.texi: Regenerate.
165         * jit-playback.c (gcc::jit::playback::context::compile): Convert
166         return type from result * to void.  Move the code to convert to
167         dso and dlopen the result to a new pure virtual "postprocess"
168         method.
169         (gcc::jit::playback::compile_to_memory::compile_to_memory): New
170         function.
171         (gcc::jit::playback::compile_to_memory::postprocess): New
172         function, based on playback::context::compile.
173         (gcc::jit::playback::compile_to_file::compile_to_file): New
174         function.
175         (gcc::jit::playback::compile_to_file::postprocess): New function.
176         (gcc::jit::playback::compile_to_file::copy_file): New function.
177         (gcc::jit::playback::context::convert_to_dso): Move internals
178         to...
179         (gcc::jit::playback::context::invoke_driver): New method.  Add
180         "-shared" and "-c" options to driver's argv as needed.
181         * jit-playback.h: Include "timevar.h".
182         (gcc::jit::playback::context::compile): Convert return type from
183         result * to void.
184         (gcc::jit::playback::context::postprocess): New pure virtual
185         function, making this an abstract base class.
186         (gcc::jit::playback::context::get_tempdir): New accessor.
187         (gcc::jit::playback::context::invoke_driver): New function.
188         (class gcc::jit::playback::compile_to_memory): New subclass of
189         playback::context.
190         (class gcc::jit::playback::compile_to_file): Likewise.
191         * jit-recording.c (gcc::jit::recording::context::compile): Use a
192         playback::compile_to_memory, and extract its result.
193         (gcc::jit::recording::context::compile_to_file): New function.
194         * jit-recording.h (gcc::jit::recording::context::compile_to_file):
195         New function.
196         * libgccjit++.h (gccjit::context::compile_to_file): New method.
197         * libgccjit.c (gcc_jit_context_compile): Update log message to
198         clarify that this is an in-memory compile.
199         (gcc_jit_context_compile_to_file): New function.
200         * libgccjit.h (gcc_jit_context): Clarify that you can compile
201         a context more than once, and that you can compile to a file
202         as well as to memory.
203         (gcc_jit_result): Clarify that this is the result of an
204         in-memory compilation.
205         (gcc_jit_context_compile): Clarify that you can compile, and that
206         this is an in-memory compilation.
207         (enum gcc_jit_output_kind): New enum.
208         (gcc_jit_context_compile_to_file): New function.
209         (gcc_jit_context_enable_dump): Clarify comment to cover both forms
210         of compilation.
211         * libgccjit.map (gcc_jit_context_compile_to_file): New API
212         entrypoint.
213         * notes.txt: Update to show the playback::context::postprocess
214         virtual function.
216 2015-01-19  David Malcolm  <dmalcolm@redhat.com>
218         * jit-recording.c
219         (gcc::jit::recording::memento_of_new_string_literal::make_debug_string):
220         Add missing format string.
222 2015-01-16  David Malcolm  <dmalcolm@redhat.com>
224         * Make-lang.in (lang_checks_parallelized): Add "check-jit".
225         (check_jit_parallelize): Set this to an arbitrary value (10).
227 2015-01-16  Jakub Jelinek  <jakub@redhat.com>
229         * jit-builtins.h (DEF_FUNCTION_TYPE_VAR_5): Fix spelling of
230         last argument.
231         (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12): Define and
232         undef afterwards.
233         * jit-builtins.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12):
234         Likewise.
236 2015-01-15  Richard Sandiford  <richard.sandiford@arm.com>
238         Update copyright years in docs/.
240 2015-01-15  David Malcolm  <dmalcolm@redhat.com>
242         * libgccjit.c (gcc_jit_block_add_assignment_op): Check that the
243         lvalue and the rvalue are of compatible type.
245 2015-01-13  David Malcolm  <dmalcolm@redhat.com>
247         * docs/cp/topics/contexts.rst (Debugging): Add
248         gccjit::context::dump_reproducer_to_file.
249         * docs/internals/index.rst (Design notes): New section,
250         discussing input validation and
251         gcc_jit_context_dump_reproducer_to_file.
252         * docs/topics/contexts.rst (Debugging): Add
253         gcc_jit_context_dump_reproducer_to_file.
254         * docs/_build/texinfo/libgccjit.texi: Regenerate.
255         * jit-common.h (gcc::jit::dump::get_context): New accessor.
256         * jit-recording.c: Include "hash-map.h".
257         Within namespace ::gcc::jit...
258         (dump::write): Flush each line.
259         (dump::make_location): Pass false for new param "created_by_user".
260         (class allocator): New class.
261         (allocator::~allocator): New function.
262         (allocator::xstrdup_printf): New function.
263         (allocator::xstrdup_printf_va): New function.
264         (class reproducer): New subclass of dump.
265         (reproducer::reproducer): New function.
266         (reproducer::write_params): New function.
267         (reproducer::write_args): New function.
268         (reproducer::make_identifier): New function.
269         (reproducer::make_tmp_identifier): New function.
270         (reproducer::get_identifier): New pair of functions.
271         (reproducer::get_identifier_as_rvalue): New function.
272         (reproducer::get_identifier_as_lvalue): New function.
273         (reproducer::get_identifier_as_type): New function.
274         (reproducer::xstrdup_printf): New function.
275         (recording::context::context): Initialize m_toplevel_ctxt.
276         (recording::context::new_location): Add param created_by_user.
277         (str_option_reproducer_strings): New table of strings.
278         (int_option_reproducer_strings): Likewise.
279         (bool_option_reproducer_strings): Likewise.
280         (get_type_enum_strings): Likewise.
281         (names_of_function_kinds): Likewise.
282         (global_kind_reproducer_strings): Likewise.
283         (unary_op_reproducer_strings): Likewise.
284         (binary_op_reproducer_strings): Likewise.
285         (comparison_reproducer_strings): Likewise.
286         Within namespace ::gcc::jit::recording::...
287         (context::dump_reproducer_to_file): New function.
288         (string::write_reproducer): Likewise.
289         (location::write_reproducer): Likewise.
290         (type::access_as_type): Likewise.
291         (memento_of_get_type::write_reproducer): Likewise.
292         (memento_of_get_pointer::write_reproducer): Likewise.
293         (memento_of_get_const::write_reproducer): Likewise.
294         (memento_of_get_volatile::write_reproducer): Likewise.
295         (array_type::write_reproducer): Likewise.
296         (function_type::write_reproducer): Likewise.
297         (function_type::write_deferred_reproducer): Likewise.
298         (field::write_reproducer): Likewise.
299         (struct_::access_as_type): Likewise.
300         (struct_::write_reproducer): Likewise.
301         (union_::write_reproducer): Likewise.
302         (fields::write_reproducer): Likewise.
303         (rvalue::access_as_rvalue): Likewise.
304         (lvalue::access_as_rvalue): Likewise.
305         (lvalue::access_as_lvalue): Likewise.
306         (param::access_as_rvalue): Likewise.
307         (param::access_as_lvalue): Likewise.
308         (param::write_reproducer): Likewise.
309         (function::write_reproducer): Likewise.
310         (block::write_reproducer): Likewise.
311         (global::write_reproducer): Likewise.
312         (memento_of_new_rvalue_from_const <int>::write_reproducer):
313         Likewise.
314         (memento_of_new_rvalue_from_const <long>::write_reproducer):
315         Likewise.
316         (memento_of_new_rvalue_from_const <double>::write_reproducer):
317         Likewise.
318         (memento_of_new_rvalue_from_const <void *>::write_reproducer):
319         Likewise.
320         (memento_of_new_string_literal::write_reproducer): Likewise.
321         (unary_op::write_reproducer): Likewise.
322         (binary_op::write_reproducer): Likewise.
323         (comparison::write_reproducer): Likewise.
324         (cast::write_reproducer): Likewise.
325         (call::write_reproducer): Likewise.
326         (call_through_ptr::write_reproducer): Likewise.
327         (array_access::write_reproducer): Likewise.
328         (access_field_of_lvalue::write_reproducer): Likewise.
329         (access_field_rvalue::write_reproducer): Likewise.
330         (dereference_field_rvalue::write_reproducer): Likewise.
331         (dereference_rvalue::write_reproducer): Likewise.
332         (get_address_of_lvalue::write_reproducer): Likewise.
333         (local::write_reproducer): Likewise.
334         (eval::write_reproducer): Likewise.
335         (assignment::write_reproducer): Likewise.
336         (assignment_op::write_reproducer): Likewise.
337         (comment::write_reproducer): Likewise.
338         (conditional::write_reproducer): Likewise.
339         (jump::write_reproducer): Likewise.
340         (return_::write_reproducer): Likewise.
341         * jit-recording.h (gcc::jit::reproducer): New forward declararion.
342         Within namespace ::gcc::jit::recording::...
343         (context::new_location): Add "created_by_user" param.
344         (context::dump_reproducer_to_file): New method.
345         (context::m_toplevel_ctxt): New field.
346         (memento::write_reproducer): New pure virtual function.
347         (memento::dyn_cast_location): New virtual function.
348         (string::write_reproducer):
349         (location::location): Add "created_by_user" param.
350         (location::dyn_cast_location): New function.
351         (location::created_by_user): New accessor.
352         (location::write_reproducer): New function.
353         (location::m_created_by_user): New field.
354         (type::access_as_type): New virtual function.
355         (location::write_reproducer): Likewise.
356         (type::access_as_type): Likewise.
357         (memento_of_get_type::write_reproducer): Likewise.
358         (memento_of_get_pointer::write_reproducer): Likewise.
359         (memento_of_get_const::write_reproducer): Likewise.
360         (memento_of_get_volatile::write_reproducer): Likewise.
361         (array_type::write_reproducer): Likewise.
362         (function_type::write_reproducer): Likewise.
363         (function_type::write_deferred_reproducer): Likewise.
364         (field::write_reproducer): Likewise.
365         (struct_::access_as_type): Likewise.
366         (struct_::write_reproducer): Likewise.
367         (union_::write_reproducer): Likewise.
368         (union_::m_fields): Remove stray unused field.
369         (fields::length): New accessor.
370         (fields::get_field): New accessor.
371         (fields::write_reproducer): New function.
372         (rvalue::access_as_rvalue): Likewise.
373         (lvalue::access_as_rvalue): Likewise.
374         (lvalue::access_as_lvalue): Likewise.
375         (param::access_as_rvalue): Likewise.
376         (param::access_as_lvalue): Likewise.
377         (param::write_reproducer): Likewise.
378         (function::write_reproducer): Likewise.
379         (block::write_reproducer): Likewise.
380         (global::write_reproducer): Likewise.
381         (memento_of_new_rvalue_from_const <HOST_TYPE>::write_reproducer):
382         Likewise.
383         (memento_of_new_string_literal::write_reproducer): Likewise.
384         (unary_op::write_reproducer): Likewise.
385         (binary_op::write_reproducer): Likewise.
386         (comparison::write_reproducer): Likewise.
387         (cast::write_reproducer): Likewise.
388         (call::write_reproducer): Likewise.
389         (call_through_ptr::write_reproducer): Likewise.
390         (array_access::write_reproducer): Likewise.
391         (access_field_of_lvalue::write_reproducer): Likewise.
392         (access_field_rvalue::write_reproducer): Likewise.
393         (dereference_field_rvalue::write_reproducer): Likewise.
394         (dereference_rvalue::write_reproducer): Likewise.
395         (get_address_of_lvalue::write_reproducer): Likewise.
396         (local::write_reproducer): Likewise.
397         (eval::write_reproducer): Likewise.
398         (assignment::write_reproducer): Likewise.
399         (assignment_op::write_reproducer): Likewise.
400         (comment::write_reproducer): Likewise.
401         (conditional::write_reproducer): Likewise.
402         (jump::write_reproducer): Likewise.
403         (return_::write_reproducer): Likewise.
404         * libgccjit++.h (gccjit::context::dump_reproducer_to_file): New.
405         * libgccjit.c (gcc_jit_context_new_location): Pass "true" as
406         param "created_by_user".
407         (gcc_jit_context_dump_reproducer_to_file): New API entrypoint.
408         * libgccjit.h (gcc_jit_context_dump_reproducer_to_file): New API
409         entrypoint.
410         * libgccjit.map (gcc_jit_context_dump_reproducer_to_file): New API
411         entrypoint.
413 2015-01-12  David Malcolm  <dmalcolm@redhat.com>
415         * jit-recording.c (class gcc::jit::rvalue_usage_validator): New.
416         (gcc::jit::rvalue_usage_validator::rvalue_usage_validator): New
417         ctor.
418         (gcc::jit::rvalue_usage_validator::visit): New function.
419         (gcc::jit::recording::rvalue::verify_valid_within_stmt): New
420         function.
421         (gcc::jit::recording::rvalue::set_scope): New function.
422         (gcc::jit::recording::function::function): Call set_scope on each
423         param, issuing errors for any params that already have a function.
424         (gcc::jit::recording::block::add_eval): Return the new statement;
425         update the comment given that some error-checking now happens after
426         this returns.
427         (gcc::jit::recording::block::add_assignment): Likewise.
428         (gcc::jit::recording::block::add_assignment_op): Likewise.
429         (gcc::jit::recording::block::add_comment): Likewise.
430         (gcc::jit::recording::block::end_with_conditional): Likewise.
431         (gcc::jit::recording::block::end_with_jump): Likewise.
432         (gcc::jit::recording::block::end_with_return): Likewise.
433         (gcc::jit::recording::block::validate): Add a comment.
434         (gcc::jit::recording::unary_op::visit_children): New function.
435         (gcc::jit::recording::binary_op::visit_children): New function.
436         (gcc::jit::recording::comparison::visit_children): New function.
437         (gcc::jit::recording::cast::visit_children): New function.
438         (gcc::jit::recording::call::visit_children): New function.
439         (gcc::jit::recording::call_through_ptr::visit_children): New function.
440         (gcc::jit::recording::array_access::visit_children): New function.
441         (gcc::jit::recording::access_field_of_lvalue::visit_children): New
442         function.
443         (gcc::jit::recording::access_field_rvalue::visit_children): New
444         function.
445         (gcc::jit::recording::dereference_field_rvalue::visit_children):
446         New function.
447         (gcc::jit::recording::dereference_rvalue::visit_children): New
448         function.
449         (gcc::jit::recording::get_address_of_lvalue::visit_children): New
450         function.
451         * jit-recording.h: Within namespace gcc::jit::recording...
452         (class rvalue_visitor): New.
453         (rvalue::rvalue): Initialize m_scope.
454         (rvalue::get_loc): New accessor.
455         (rvalue::verify_valid_within_stmt): New function.
456         (rvalue::visit_children): New pure virtual function.
457         (rvalue::set_scope): New function.
458         (rvalue::get_scope): New function.
459         (rvalue::dyn_cast_param): New function.
460         (rvalue::m_scope): New field.
461         (param::visit_children): New empty function.
462         (param::dyn_cast_param): New function.
463         (function::get_loc): New function.
464         (block::add_eval): Return the new statement.
465         (block::add_assignment): Likewise.
466         (block::add_assignment_op): Likewise.
467         (block::add_comment): Likewise.
468         (block::end_with_conditional): Likewise.
469         (block::end_with_jump): Likewise.
470         (block::end_with_return): Likewise.
471         (global::visit_children): New function.
472         (memento_of_new_rvalue_from_const<HOST_TYPE>::visit_children):
473         New function.
474         (memento_of_new_string_literal::visit_children): New function.
475         (unary_op::visit_children): New function.
476         (binary_op::visit_children): New function.
477         (comparison::visit_children): New function.
478         (cast::visit_children): New function.
479         (call::visit_children): New function.
480         (call_through_ptr::visit_children): New function.
481         (array_access::visit_children): New function.
482         (access_field_of_lvalue::visit_children): New function.
483         (access_field_rvalue::visit_children): New function.
484         (dereference_field_rvalue::visit_children): New function.
485         (dereference_rvalue::visit_children): New function.
486         (get_address_of_lvalue::visit_children): New function.
487         (local::local): Call set_scope.
488         (local::visit_children): New function.
489         (statement::get_block): Make public.
490         * libgccjit.c (RETURN_VAL_IF_FAIL_PRINTF5): New macro.
491         (RETURN_NULL_IF_FAIL_PRINTF5): New macro.
492         (gcc_jit_context_new_function): Verify that each param has
493         not yet been used for creating another function.
494         (gcc_jit_block_add_eval): After creating the stmt, verify
495         that the rvalue expression tree is valid to use within it.
496         (gcc_jit_block_add_assignment): Likewise for the lvalue and
497         rvalue expression trees.
498         (gcc_jit_block_add_assignment_op): Likewise.
499         (gcc_jit_block_end_with_conditional): Likewise for the boolval
500         expression tree.
501         (gcc_jit_block_end_with_return): Likewise for the rvalue
502         expression tree.
503         (gcc_jit_block_end_with_void_return): Remove return of "void",
504         now that block::end_with_return is now non-void.
506 2015-01-12  David Malcolm  <dmalcolm@redhat.com>
508         * jit-playback.c (gcc::jit::playback::context::read_dump_file):
509         Add missing fclose on error-handling path.
511 2015-01-12  David Malcolm  <dmalcolm@redhat.com>
513         * docs/cp/topics/expressions.rst (Global variables): Add
514         enum gcc_jit_global_kind param to gccjit::context::new_global.
515         * docs/topics/expressions.rst (Global variables): Likewise.
516         Document the new enum.
517         * docs/topics/results.rst (Compilation results): Document
518         globals-handling.
519         * docs/_build/texinfo/libgccjit.texi: Regenerate.
520         * dummy-frontend.c (jit_langhook_write_globals): Call into the
521         playback context's write_global_decls_1 and write_global_decls_2
522         before and after calling symtab->finalize_compilation_unit ().
523         * jit-playback.c: Include "debug.h".
524         (gcc::jit::playback::context::new_global): Add "kind" param and
525         use it to set TREE_PUBLIC, TREE_STATIC and DECL_EXTERNAL on the
526         underlying VAR_DECL.  Call varpool_node::get_create on the
527         VAR_DECL, and add it to m_globals.
528         (gcc::jit::playback::context::write_global_decls_1): New function.
529         (gcc::jit::playback::context::write_global_decls_2): New function.
530         * jit-playback.h (gcc::jit::playback::context::context): Call
531         create on m_globals.
532         (gcc::jit::playback::context::new_global): Add "kind" param.
533         (gcc::jit::playback::context::write_global_decls_1): New function.
534         (gcc::jit::playback::context::write_global_decls_2): New function.
535         (gcc::jit::playback::context::m_globals): New field.
536         * jit-recording.c (gcc::jit::recording::context::context):
537         Initialize m_globals.
538         (gcc::jit::recording::context::new_global): Add param "kind".
539         Add the new global to m_globals.
540         (gcc::jit::recording::context::dump_to_file): Dump the globals.
541         (gcc::jit::recording::global::replay_into): Add field m_kind.
542         (gcc::jit::recording::global::write_to_dump): New override.
543         * jit-recording.h (gcc::jit::recording::context::new_global): Add
544         param "kind".
545         (gcc::jit::recording::context::m_globals): New field.
546         (gcc::jit::recording::global::global): Add param kind.
547         (gcc::jit::recording::global::write_to_dump): New override.
548         (gcc::jit::recording::global::m_kind): New field.
549         * jit-result.c (gcc::jit::result::get_global): New function.
550         * jit-result.h (gcc::jit::result::get_global): New function.
551         * libgccjit++.h (gccjit::context::new_global): Add "kind" param.
552         * libgccjit.c (gcc_jit_context_new_global): Likewise.
553         (gcc_jit_result_get_global): New API entrypoint.
554         * libgccjit.h (gcc_jit_result_get_global): New API entrypoint.
555         (enum gcc_jit_global_kind): New enum.
556         (gcc_jit_context_new_global): API change: add "kind" param.
557         * libgccjit.map (gcc_jit_result_get_global): New symbol.
559 2015-01-09  David Malcolm  <dmalcolm@redhat.com>
561         * dummy-frontend.c: Include "fixed-value.h", "alias.h", "flags.h",
562         "symtab.h", "inchash.h".  Move include of "hash-set.h" much
563         earlier.
564         * jit-builtins.c: Remove redundant includes of "opts.h" and
565         "tree.h".
566         * jit-common.h: Include "hash-set.h", "input.h", "vec.h",
567         "double-int.h", "alias.h", "flags.h", "symtab.h", "inchash.h".
568         * jit-playback.c: Include "hashtab.h", "machmode.h", "input.h",
569         "statistics.h", "vec.h", "double-int.h", "real.h",
570         "fixed-value.h", "alias.h", "flags.h", "symtab.h", "tree-core.h",
571         "inchash.h", "fold-const.h".  Move include of "hash-set.h" to
572         earlier.
573         * jit-recording.c: Remove redundant includes of "opts.h" and
574         "tree.h".
576 2015-01-09  David Malcolm  <dmalcolm@redhat.com>
578         * docs/cp/topics/expressions.rst (Simple expressions): Use
579         ":c:type:" for C types.  Document new overload of
580         gcc::jit::context::new_rvalue.
581         * docs/topics/expressions.rst (Simple expressions): Use
582         ":c:type:" for C types.  Document new entrypoint
583         gcc_jit_context_new_rvalue_from_long.
584         * docs/_build/texinfo/libgccjit.texi: Regenerate.
585         * jit-playback.c: Within namespace gcc::jit::playback...
586         (context::new_rvalue_from_int): Eliminate in favor of...
587         (context::new_rvalue_from_const <int>): ...this.
588         (context::new_rvalue_from_double): Eliminate in favor of...
589         (context::new_rvalue_from_const <double>): ...this.
590         (context::new_rvalue_from_const <long>): New.
591         (context::new_rvalue_from_ptr): Eliminate in favor of...
592         (context::new_rvalue_from_const <void *>): ...this.
593         * jit-playback.h: Within namespace gcc::jit::playback...
594         (context::new_rvalue_from_int): Eliminate in favor of...
595         (context::new_rvalue_from_const <HOST_TYPE>): ...this.
596         (context::new_rvalue_from_double): Likewise.
597         (context::new_rvalue_from_ptr): Likewise.
598         * jit-recording.c: Within namespace gcc::jit::recording...
599         (context::new_rvalue_from_int): Eliminate.
600         (context::new_rvalue_from_double): Likewise.
601         (context::new_rvalue_from_ptr): Likewise.
602         (class memento_of_new_rvalue_from_const <int>):
603         Add explicit specialization.
604         (class memento_of_new_rvalue_from_const <long>):
605         Likewise.
606         (class memento_of_new_rvalue_from_const <double>):
607         Likewise.
608         (class memento_of_new_rvalue_from_const <void *>):
609         Likewise.
610         (memento_of_new_rvalue_from_int::replay_into):
611         Generalize into...
612         (memento_of_new_rvalue_from_const <HOST_TYPE>::replay_into):
613         ...this...
614         (memento_of_new_rvalue_from_double::replay_into):
615         ...allowing this...
616         (memento_of_new_rvalue_from_ptr::replay_into):
617         ...and this to be deleted.
618         (memento_of_new_rvalue_from_int::make_debug_string):
619         Convert to...
620         (memento_of_new_rvalue_from_const <int>::make_debug_string):
621         ...this.
622         (memento_of_new_rvalue_from_double::make_debug_string):
623         Convert to...
624         (memento_of_new_rvalue_from_const <double>::make_debug_string):
625         ...this.
626         (memento_of_new_rvalue_from_ptr::make_debug_string)
627         Convert to...
628         (memento_of_new_rvalue_from_const <void *>::make_debug_string):
629         ...this.
630         (memento_of_new_rvalue_from_const <long>::make_debug_string):
631         New function.
632         * jit-recording.h: Within namespace gcc::jit::recording...
633         (context::new_rvalue_from_int): Eliminate.
634         (context::new_rvalue_from_double): Likewise.
635         (context::new_rvalue_from_ptr): Likewise, all in favor of...
636         (context::new_rvalue_from_const <HOST_TYPE>): New family of
637         methods.
638         (class memento_of_new_rvalue_from_int): Eliminate.
639         (class memento_of_new_rvalue_from_double): Likewise.
640         (class memento_of_new_rvalue_from_ptr): Likewise.
641         (class memento_of_new_rvalue_from_const <HOST_TYPE>): New family
642         of rvalue subclasses.
643         * libgccjit++.h (gccjit::context::new_rvalue): New overload, for
644         "long".
645         * libgccjit.c (gcc_jit_context_new_rvalue_from_int): Update for
646         rewriting of recording::context::new_rvalue_from_int to
647         recording::context::new_rvalue_from_const <int>.
648         (gcc_jit_context_new_rvalue_from_long): New API entrypoint.
649         (gcc_jit_context_new_rvalue_from_double): Update for
650         rewriting of recording::context::new_rvalue_from_double to
651         recording::context::new_rvalue_from_const <double>.
652         (gcc_jit_context_new_rvalue_from_ptr): Update for
653         rewriting of recording::context::new_rvalue_from_ptr to
654         recording::context::new_rvalue_from_const <void *>.
655         * libgccjit.h (gcc_jit_context_new_rvalue_from_long): New API
656         entrypoint.
657         * libgccjit.map (gcc_jit_context_new_rvalue_from_long): Likewise.
659 2015-01-09  David Malcolm  <dmalcolm@redhat.com>
661         PR jit/64206
662         * docs/internals/test-hello-world.exe.log.txt: Update, the log now
663         shows tempdir creation/cleanup.
664         * docs/_build/texinfo/libgccjit.texi: Regenerate.
665         * jit-logging.h (class gcc::jit::log_user): Add gcc::jit::tempdir
666         to the list of subclasses in the comment.
667         * jit-playback.c (gcc::jit::playback::context::context): Add a
668         comment clarifying when the tempdir gets cleaned up.
669         (gcc::jit::playback::context::compile): Pass the context's logger,
670         if any, to the tempdir.
671         (gcc::jit::playback::context::dlopen_built_dso): When creating the
672         gcc::jit::result, if GCC_JIT_BOOL_OPTION_DEBUGINFO is set, hand
673         over ownership of the tempdir to it.
674         * jit-result.c: Include "jit-tempdir.h".
675         (gcc::jit::result::result): Add tempdir param, saving it as
676         m_tempdir.
677         (gcc::jit::result::~result): Delete m_tempdir.
678         * jit-result.h (gcc::jit::result::result): Add tempdir param.
679         (gcc::jit::result::m_tempdir): New field.
680         * jit-tempdir.c (gcc::jit::tempdir::tempdir): Add logger param;
681         add JIT_LOG_SCOPE.
682         (gcc::jit::tempdir::create): Add JIT_LOG_SCOPE to log entry/exit,
683         and log m_path_template and m_path_tempdir.
684         (gcc::jit::tempdir::~tempdir): Add JIT_LOG_SCOPE to log
685         entry/exit, and log the unlink and rmdir calls.
686         * jit-tempdir.h: Include "jit-logging.h".
687         (class gcc::jit::tempdir): Make this be a subclass of log_user.
688         (gcc::jit::tempdir::tempdir): Add logger param.
689         * notes.txt: Update to show the two possible places where the
690         tempdir can be cleaned up.
692 2015-01-08  David Malcolm  <dmalcolm@redhat.com>
694         * libgccjit.h (struct gcc_jit_context): Rewrite the descriptive
695         comment.
697 2015-01-08  David Malcolm  <dmalcolm@redhat.com>
699         * docs/topics/contexts.rst (Error-handling): Document new
700         entrypoint gcc_jit_context_get_last_error.
701         * docs/_build/texinfo/libgccjit.texi: Regenerate.
702         * jit-recording.c (gcc::jit::recording::context::context):
703         Initialize new fields "m_last_error_str" and
704         "m_owns_last_error_str".
705         (gcc::jit::recording::context::~context): Clean up
706         m_last_error_str, if needed.
707         (gcc::jit::recording::context::add_error_va): Update
708         m_last_error_str and m_owns_last_error_str, freeing the old
709         value if appropriate.
710         (gcc::jit::recording::context::get_last_error): New function.
711         * jit-recording.h (gcc::jit::recording::context::get_last_error):
712         New function.
713         (gcc::jit::recording::context): New fields m_last_error_str and
714         m_owns_last_error_str.
715         * libgccjit.c (gcc_jit_context_get_last_error): New function.
716         * libgccjit.h (gcc_jit_context_get_last_error): New declaration.
717         * libgccjit.map (gcc_jit_context_get_last_error): New function.
719 2015-01-08  David Malcolm  <dmalcolm@redhat.com>
721         * Make-lang.in (jit_OBJS): Add jit/jit-logging.o.
722         * docs/internals/index.rst (Overview of code structure): Mention
723         gcc_jit_context_set_logfile, and embed the example logfile.
724         * docs/internals/test-hello-world.exe.log.txt: New file: example
725         of a logfile.
726         * docs/topics/contexts.rst (Debugging): Add documentation
727         for gcc_jit_context_set_logfile.
728         * docs/_build/texinfo/libgccjit.texi: Regenerate.
729         * dummy-frontend.c: Include "jit-logging.h".
730         (jit_langhook_init): Assert that there is an active playback
731         context.  If it has a logger, log entry/exit to this function.
732         (jit_langhook_write_globals): Likewise.
733         * jit-common.h (gcc::jit::logger): New forward declaration.
734         * jit-logging.c: New file.
735         * jit-logging.h: New file.
736         * jit-playback.c: Include "jit-logging.h".
737         (gcc::jit::playback::context::context): Initialize the log_user
738         base class from the recording context's logger (if any).  Use
739         JIT_LOG_SCOPE to log entry/exit from the function body.
740         (gcc::jit::playback::context::~context): Use JIT_LOG_SCOPE to
741         log entry/exit from the function body.
742         (gcc::jit::playback::build_stmt_list): Likewise.
743         (gcc::jit::playback::function::postprocess): Likewise.
744         (gcc::jit::playback::context::compile): Likewise.  Log the
745         entry/exit to toplev::main and toplev::finalize.  Log the
746         fake argv passed to toplev::main.
747         (gcc::jit::playback::context::acquire_mutex): Use JIT_LOG_SCOPE to
748         log entry/exit from the function body.
749         (gcc::jit::playback::context::release_mutex): Likewise.
750         (gcc::jit::playback::context::make_fake_args): Likewise.
751         (gcc::jit::playback::context::extract_any_requested_dumps):
752         Likewise.
753         (gcc::jit::playback::context::convert_to_dso): Likewise. Also,
754         log the arguments that the driver is invoked with.
755         (gcc::jit::playback::context::dlopen_built_dso): Likewise.  Pass
756         the logger to the result object.
757         (gcc::jit::playback::context::replay): Use JIT_LOG_SCOPE to
758         log entry/exit from the function body.
759         (gcc::jit::playback::context::dump_generated_code): Likewise.
760         (gcc::jit::playback::context::handle_locations): Likewise.
761         * jit-playback.h (gcc::jit::playback::context): Make this be
762         a subclass of gcc::jit::log_user.
763         * jit-recording.c: Include "jit-logging.h".
764         (gcc::jit::recording::context::context: Initialize the logger to
765         NULL for root contexts, or to the parent's logger for child
766         contexts.
767         (gcc::jit::recording::context::~context): Use JIT_LOG_SCOPE to
768         log entry/exit from the function body.
769         (gcc::jit::recording::context::replay_into): Likewise.
770         (gcc::jit::recording::context::disassociate_from_playback):
771         Likewise.
772         (gcc::jit::recording::context::compile): Likewise.
773         (recording::context::add_error_va): Likewise.  Also, log the
774         error.
775         (gcc::jit::recording::context::validate): Use JIT_LOG_SCOPE to
776         log entry/exit from the function body.
777         * jit-recording.h: Include "jit-logging.h".
778         (gcc::jit::recording::context): Make this be a subclass of
779         gcc::jit::log_user.
780         * jit-result.c: Include "jit-common.h" and "jit-logging.h".
781         (gcc::jit::result::result): Add logger param, recording it.
782         Use JIT_LOG_SCOPE to log entry/exit from the function body.
783         (gcc::jit::result::~result(): Use JIT_LOG_SCOPE to
784         log entry/exit from the function body.
785         (gcc::jit::result::get_code): Likewise.
786         * jit-result.h (gcc::jit::result): Make this be a subclass of
787         gcc::jit::log_user.
788         (gcc::jit::result::result): Add logger parameter.
789         * libgccjit++.h (gccjit::context::set_logfile): New function.
790         * libgccjit.c: Include "jit-logging.h".
791         (gcc_jit_context_acquire): Log the context.
792         (gcc_jit_context_release): Use JIT_LOG_FUNC to
793         log entry/exit from the function body, and log the context.
794         (gcc_jit_context_new_child_context): Likewise, logging both
795         contexts.
796         (gcc_jit_context_new_location): Use JIT_LOG_FUNC to
797         log entry/exit from the function body.
798         (gcc_jit_context_get_type): Likewise.
799         (gcc_jit_context_get_int_type): Likewise.
800         (gcc_jit_context_new_array_type): Likewise.
801         (gcc_jit_context_new_field): Likewise.
802         (gcc_jit_context_new_struct_type): Likewise.
803         (gcc_jit_context_new_opaque_struct): Likewise.
804         (gcc_jit_struct_set_fields): Likewise.
805         (gcc_jit_context_new_union_type): Likewise.
806         (gcc_jit_context_new_function_ptr_type): Likewise.
807         (gcc_jit_context_new_param): Likewise.
808         (gcc_jit_context_new_function): Likewise.
809         (gcc_jit_context_get_builtin_function): Likewise.
810         (gcc_jit_function_get_param): Likewise.
811         (gcc_jit_function_dump_to_dot): Likewise.
812         (gcc_jit_function_new_block): Likewise.
813         (gcc_jit_context_new_global): Likewise.
814         (gcc_jit_context_new_rvalue_from_int): Likewise.
815         (gcc_jit_context_zero): Likewise.
816         (gcc_jit_context_one): Likewise.
817         (gcc_jit_context_new_rvalue_from_double): Likewise.
818         (gcc_jit_context_new_rvalue_from_ptr): Likewise.
819         (gcc_jit_context_null): Likewise.
820         (gcc_jit_context_new_string_literal): Likewise.
821         (gcc_jit_context_new_unary_op): Likewise.
822         (gcc_jit_context_new_binary_op): Likewise.
823         (gcc_jit_context_new_comparison): Likewise.
824         (gcc_jit_context_new_call): Likewise.
825         (gcc_jit_context_new_call_through_ptr): Likewise.
826         (gcc_jit_context_new_cast): Likewise.
827         (gcc_jit_context_new_array_access): Likewise.
828         (gcc_jit_lvalue_access_field): Likewise.
829         (gcc_jit_rvalue_access_field): Likewise.
830         (gcc_jit_rvalue_dereference_field): Likewise.
831         (gcc_jit_rvalue_dereference): Likewise.
832         (gcc_jit_lvalue_get_address): Likewise.
833         (gcc_jit_function_new_local): Likewise.
834         (gcc_jit_block_add_eval): Likewise.
835         (gcc_jit_block_add_assignment): Likewise.
836         (gcc_jit_block_add_assignment_op): Likewise.
837         (gcc_jit_block_end_with_conditional): Likewise.
838         (gcc_jit_block_add_comment): Likewise.
839         (gcc_jit_block_end_with_jump): Likewise.
840         (gcc_jit_block_end_with_return): Likewise.
841         (gcc_jit_block_end_with_void_return): Likewise.
842         (gcc_jit_context_set_str_option): Likewise.
843         (gcc_jit_context_set_int_option): Likewise.
844         (gcc_jit_context_set_bool_option): Likewise.
845         (gcc_jit_context_enable_dump): Likewise.
846         (gcc_jit_context_compile): Likewise.  Also log the context,
847         and the result.
848         (gcc_jit_context_dump_to_file): Likewise.
849         (gcc_jit_context_set_logfile): New function.
850         (gcc_jit_context_get_first_error): Use JIT_LOG_FUNC to
851         log entry/exit from the function body.
852         (gcc_jit_result_get_code): Likewise.  Also log the fnname)
853         and the ptr to be returned.
854         (gcc_jit_result_release): Likewise.  Also log the result.
855         * libgccjit.h: Include <stdio.h>, since we need FILE *.
856         (gcc_jit_context_set_logfile): New declaration.
857         * libgccjit.map (gcc_jit_context_set_logfile): New.
859 2015-01-07  David Malcolm  <dmalcolm@redhat.com>
861         * jit-recording.h (gcc::jit::recording::type::is_void): New
862         virtual function.
863         (gcc::jit::recording::memento_of_get_type::is_void): New
864         function, overriding default implementation.
865         * libgccjit.c (gcc_jit_rvalue_dereference): Verify that
866         the underlying type is not "void".
868 2015-01-07  David Malcolm  <dmalcolm@redhat.com>
870         * docs/topics/expressions.rst (Unary Operations): Add
871         GCC_JIT_UNARY_OP_ABS.
872         * jit-playback.c (gcc::jit::playback::context::new_unary_op):
873         Likewise.
874         * jit-recording.c (unary_op_strings): Likewise.
875         * libgccjit.c (gcc_jit_context_new_unary_op): Update checking
876         of "op" to reflect addition of GCC_JIT_UNARY_OP_ABS.
877         * libgccjit.h (enum gcc_jit_unary_op): Add GCC_JIT_UNARY_OP_ABS.
878         * docs/_build/texinfo/libgccjit.texi: Regenerate.
880 2015-01-07  David Malcolm  <dmalcolm@redhat.com>
882         * jit-recording.h (gcc::jit::recording::memento_of_get_type): Fix
883         typo in comment.
885 2015-01-07  David Malcolm  <dmalcolm@redhat.com>
887         * TODO.rst (Test suite): Remove item about running C++ testcases.
888         * docs/internals/index.rst (Working on the JIT library): Add
889         "c++" to the enabled languages in the suggested "configure"
890         invocation, and add a description of why this is necessary.
891         * docs/_build/texinfo/libgccjit.texi: Regenerate.
893 2015-01-07  David Malcolm  <dmalcolm@redhat.com>
895         * docs/internals/index.rst: Update to reflect that built
896         testcases are now test-foo.c.exe, rather than test-foo.exe.
897         * docs/_build/texinfo/libgccjit.texi: Regenerate.
899 2015-01-05  Jakub Jelinek  <jakub@redhat.com>
901         Update copyright years.
903 2014-12-19  David Malcolm  <dmalcolm@redhat.com>
905         * jit-playback.c (gcc::jit::playback::context::build_cast): In
906         case BOOLEAN_TYPE, don't assume that the source expression is
907         of type "int".
909 2014-12-19  David Malcolm  <dmalcolm@redhat.com>
911         * jit-recording.c (gcc::jit::recording::context::context): When
912         copying string options from a parent context, take a copy of the
913         underlying buffers, rather than simply copying the pointer.
915 2014-12-19  David Malcolm  <dmalcolm@redhat.com>
917         * jit-recording.c (gcc::jit::recording::context::set_str_option):
918         Handle NULL.
920 2014-12-11  David Malcolm  <dmalcolm@redhat.com>
922         * docs/cp/topics/contexts.rst (gccjit::context::set_str_option):
923         Document new function.
924         * docs/_build/texinfo/libgccjit.texi: Regenerate.
926 2014-12-10  Ulrich Drepper  <drepper@gmail.com>
928         Minor interface cleanups of libgccjit
929         * jit-playback.c (convert_to_dso): Use auto_vec instead
930         of automatic array to build up command line.
931         * jit-recording.c (recording::context::set_str_option):
932         Make copy of the string.
933         (recording::context::~context): Free string options.
934         * jit-recording.h (recording::context): Adjust type
935         of m_str_options member.
936         * libgccjit.h: Adjust comment about
937         gcc_jit_context_set_str_option parameter being used after
938         the call.
939         Update comment now that all interfaces are copy strings
940         if necessary.
941         * libgccjit++.h (gccjit::context): Add set_str_option
942         member function.
944 2014-12-10  David Malcolm  <dmalcolm@redhat.com>
946         * docs/cp/index.rst: New file.
947         * docs/cp/intro/index.rst: New file.
948         * docs/cp/intro/tutorial01.rst: New file.
949         * docs/cp/intro/tutorial02.rst: New file.
950         * docs/cp/intro/tutorial03.rst: New file.
951         * docs/cp/intro/tutorial04.rst: New file.
952         * docs/cp/topics/contexts.rst: New file.
953         * docs/cp/topics/expressions.rst: New file.
954         * docs/cp/topics/functions.rst: New file.
955         * docs/cp/topics/index.rst: New file.
956         * docs/cp/topics/locations.rst: New file.
957         * docs/cp/topics/objects.rst: New file.
958         * docs/cp/topics/results.rst: New file.
959         * docs/cp/topics/types.rst: New file.
960         * docs/examples/tut01-hello-world.cc: New file.
961         * docs/examples/tut02-square.c: Fix missing newline in output.
962         * docs/examples/tut02-square.cc: New file.
963         * docs/examples/tut03-sum-of-squares.cc: New file.
964         * docs/examples/tut04-toyvm/toyvm.cc: New file.
965         * docs/index.rst: Move summary to above the table of contents.
966         Add text about the C vs C++ APIs.
967         * docs/topics/contexts.rst: Fix a typo.
969         * docs/_build/texinfo/libgccjit.texi: Regenerate.
970         * docs/_build/texinfo/factorial1.png: New file.
971         * docs/_build/texinfo/sum-of-squares1.png: New file.
973 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
975         * docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Move
976         logic for determine "funcname" to new function...
977         (get_function_name): ...here, adding logic to skip any leading
978         path from the filename.
979         (toyvm_function_parse): Use the filename for fn_filename, rather
980         than "name", so that the debugger can locate the source .toy
981         file.
982         (toyvm_function_parse): Don't fclose a NULL FILE *.
984 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
986         PR jit/63854
987         * docs/internals/index.rst (Running under valgrind): New
988         subsection.
989         (docs/_build/texinfo/libgccjit.texi): Regenerate.
991 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
993         PR jit/64206
994         * Make-lang.in (jit_OBJS): Add jit/jit-tempdir.o.
995         * jit-common.h (gcc::jit::tempdir): New forward decl.
996         * jit-playback.c: Include jit-tempdir.h.
997         (gcc::jit::playback::context::context): Initialize m_tempdir.
998         (gcc::jit::playback::context::~context): Move tempdir
999         cleanup to new file jit-tempdir.c
1000         (make_tempdir_path_template): Move to new file jit-tempdir.c.
1001         (gcc::jit::playback::context::compile): Move tempdir creation
1002         to new tempdir object in new file jit-tempdir.c.
1003         (gcc::jit::playback::context::make_fake_args): Get path from
1004         tempdir object rather than from member data.
1005         (gcc::jit::playback::context::convert_to_dso): Likewise.
1006         (gcc::jit::playback::context::dlopen_built_dso): Likewise.
1007         (gcc::jit::playback::context::dump_generated_code): Likewise.
1008         (gcc::jit::playback::context::get_path_c_file): New function.
1009         (gcc::jit::playback::context::get_path_s_file): New function.
1010         (gcc::jit::playback::context::get_path_so_file): New function.
1011         * jit-playback.h (gcc::jit::playback::context::get_path_c_file):
1012         New function.
1013         (gcc::jit::playback::context::get_path_s_file): New function.
1014         (gcc::jit::playback::context::get_path_so_file): New function.
1015         (gcc::jit::playback::context): Move fields "m_path_template",
1016         "m_path_tempdir", "m_path_c_file", "m_path_s_file",
1017         "m_path_so_file" to new jit::tempdir class; add field "m_tempdir".
1018         * jit-tempdir.c: New file.
1019         * jit-tempdir.h: New file.
1021 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
1023         * jit-playback.c (gcc::jit::playback::context::compile): Acquire the
1024         mutex here, immediately before using toplev, and release it here, on
1025         each exit path after acquisition.
1026         (jit_mutex): Move this variable here, from jit-recording.c.
1027         (gcc::jit::playback::context::acquire_mutex): New function, based on
1028         code in jit-recording.c.
1029         (gcc::jit::playback::context::release_mutex): Likewise.
1030         * jit-playback.h (gcc::jit::playback::context::acquire_mutex): New
1031         function.
1032         (gcc::jit::playback::context::release_mutex): New function.
1033         * jit-recording.c (jit_mutex): Move this variable to jit-playback.c.
1034         (gcc::jit::recording::context::compile): Move mutex-handling from
1035         here into jit-playback.c's gcc::jit::playback::context::compile.
1036         * notes.txt: Update to show the new locations of ACQUIRE_MUTEX
1037         and RELEASE_MUTEX.
1039 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
1041         * jit-playback.c (gcc::jit::playback::context::compile): Move the
1042         dlopen code into...
1043         (gcc::jit::playback::context::dlopen_built_dso): ...this new
1044         function.
1045         * jit-playback.h (gcc::jit::playback::context::dlopen_built_dso):
1046         New function.
1048 2014-12-09  David Malcolm  <dmalcolm@redhat.com>
1050         PR jit/64166
1051         * docs/topics/contexts.rst (Debugging): Add description of
1052         gcc_jit_context_enable_dump.
1053         * docs/_build/texinfo/libgccjit.texi: Regenerate.
1054         * jit-playback.c: Include context.h.
1055         (class auto_argvec): New class.
1056         (auto_argvec::~auto_argvec): New function.
1057         (gcc::jit::playback::context::compile): Convert fake_args to be
1058         an auto_argvec, so that it can contain dynamically-allocated
1059         strings.   Construct a vec of all requested dumps, and pass it to
1060         make_fake_args.  Extract requested dumps between the calls to
1061         toplev::main and toplev::finalize.
1062         (gcc::jit::playback::context::make_fake_args): Convert param
1063         "argvec" to be a vec <char *>, and gain a "requested_dumps"
1064         param.  Convert to dynamically-allocated arg strings by converting
1065         ADD_ARG to take a copy of the arg, and add ADD_ARG_TAKE_OWNERSHIP
1066         for args that are already a copy.  Add args for all requested dumps.
1067         (gcc::jit::playback::context::extract_any_requested_dumps): New
1068         function.
1069         (gcc::jit::playback::context::read_dump_file): New function.
1070         * jit-playback.h (gcc::jit::playback::context::make_fake_args):
1071         Convert param "argvec" to be a vec <char *>, and gain a
1072         "requested_dumps" param.
1073         (gcc::jit::playback::context::extract_any_requested_dumps): New
1074         function.
1075         (gcc::jit::playback::context::read_dump_file): New function.
1076         * jit-recording.c (gcc::jit::recording::context::enable_dump): New
1077         function.
1078         (gcc::jit::recording::context::get_all_requested_dumps): New
1079         function.
1080         * jit-recording.h (gcc::jit::recording::requested_dump): New
1081         struct.
1082         (gcc::jit::recording::context::enable_dump): New function.
1083         (gcc::jit::recording::context::get_all_requested_dumps): New
1084         function.
1085         (gcc::jit::recording::context::m_requested_dumps): New field.
1086         * libgccjit.c (gcc_jit_context_enable_dump): New API entrypoint.
1087         * libgccjit.h (gcc_jit_context_enable_dump): New API entrypoint.
1088         * libgccjit.map (gcc_jit_context_enable_dump): New API entrypoint.
1090 2014-12-08  David Malcolm  <dmalcolm@redhat.com>
1092         * libgccjit++.h: Indent the forward declarations of the classes to
1093         show the inheritance hierarchy.
1095 2014-12-08  David Malcolm  <dmalcolm@redhat.com>
1097         * notes.txt: Show the beginning and ending of
1098         recording::context::compile vs playback::context::compile.  Show
1099         the creation and unlinking of the tempdir.  Show toplev::finalize.
1100         Move "RELEASE MUTEX" to the correct location.  Show
1101         gcc_jit_result_release, and indicate where the
1102         dlopen/dlsym/dlclose occur.
1104 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1106         * docs/examples/tut02-square.c (main): Release the context
1107         earlier, to show that this is possible.  Update error-handling
1108         to avoid a double-release of the context, and to avoid
1109         releasing a NULL result.
1110         * docs/intro/tutorial02.rst: Discuss gcc_jit_context_release.
1111         * docs/topics/functions.rst (GCC_JIT_FUNCTION_EXPORTED): Emphasize
1112         * docs/topics/results.rst (gcc_jit_result): Mention that this
1113         controls the lifetimes of machine code functions.
1114         (gcc_jit_result_get_code): Spell out the requirements for this
1115         to succeed, and the lifetime of the result.
1116         (gcc_jit_result_release): Mention that this invalidates any code
1117         that was obtained from the result.
1118         * docs/_build/texinfo/libgccjit.texi: Regenerate.
1120 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1122         PR jit/64018
1123         * docs/intro/tutorial02.rst: Spell out lifetime of generated code.
1124         Add description of error-handling, taken in part from...
1125         * docs/topics/contexts.rst (Error-handling): Expand, and move some
1126         content to tutorial02.rst.
1127         * docs/_build/texinfo/libgccjit.texi: Regenerate.
1129 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1131         PR jit/64020
1132         * docs/topics/types.rst (Standard types) Add new enum values to
1133         the table of enum gcc_jit_types: GCC_JIT_TYPE_COMPLEX_FLOAT,
1134         GCC_JIT_TYPE_COMPLEX_DOUBLE, GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.
1135         Widen the left-hand column so that
1136         GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE will fit.
1137         * docs/_build/texinfo/libgccjit.texi: Regenerate.
1139         * jit-builtins.c: Include stringpool.h and jit-playback.h.
1140         Move everything out of the gcc::jit::recording namespace into
1141         just gcc::jit.
1142         (struct builtin_data): Add fields "fnclass", "attr", and
1143         "implicit_p".
1144         (DEF_BUILTIN): Update macro so populate the new fields.
1145         (builtins_manager::builtins_manager): Update for move out of
1146         recording namespace.  Initialize the m_attributes array.
1147         (builtins_manager::get_builtin_function): Likewise.
1148         (builtins_manager::get_builtin_function_by_id): New function.
1149         (builtins_manager::make_builtin_function): Update for move out of
1150         recording namespace.  Add fix for PR jit/64020 by detecting
1151         specific builtin ids and having them ensure that builtins for
1152         other ids are created as necessary.
1153         (builtins_manager::get_type): Update for move out of recording
1154         namespace.
1155         (builtins_manager::make_type): Likewise.  Add some missing
1156         #undefs.
1157         (builtins_manager::make_primitive_type): Update for move out of
1158         recording namespace.  Implement the three BT_COMPLEX_ cases and
1159         BT_DOUBLE_PTR.
1160         (builtins_manager::make_fn_type): Update for move out of recording
1161         namespace.
1162         (builtins_manager::make_ptr_type): Likewise.
1163         (builtins_manager::finish_playback): New function.
1164         (builtins_manager::get_class): New function.
1165         (builtins_manager::implicit_p): New function.
1166         (builtins_manager::get_attrs_tree): Two new functions.
1167         (builtins_manager::make_attrs_tree): New function.
1169         * jit-builtins.h: Move everything out of the gcc::jit::recording
1170         namespace into just gcc::jit.
1171         (enum built_in_attribute): New.
1172         (builtins_manager::builtins_manager): Update decl for namespace
1173         change.
1174         (builtins_manager::get_builtin_function): Likewise.
1175         (builtins_manager::get_class): New.
1176         (builtins_manager::implicit_p): New.
1177         (builtins_manager::get_attrs_tree): Two new functions.
1178         (builtins_manager::make_attrs_tree): New function.
1179         (builtins_manager::finish_playback): New.
1180         (builtins_manager::get_builtin_function_by_id): New.
1181         (builtins_manager::make_builtin_function): Update decl for
1182         namespace change.
1183         (builtins_manager::get_type): Likewise.
1184         (builtins_manager::make_type): Likewise.
1185         (builtins_manager::make_primitive_type): Likewise.
1186         (builtins_manager::make_fn_type): Likewise.
1187         (builtins_manager::make_ptr_type): Likewise.
1188         (builtins_manager): Likewise for fields.  Add new field
1189         "m_attributes".
1191         * jit-common.h (NUM_GCC_JIT_TYPES): Update.
1192         (builtins_manager): Update forward decl to reflect namespace
1193         change.
1195         * jit-playback.c: Include attribs.h and jit-builtins.h.
1196         (gcc::jit::playback::context::get_tree_node_for_type): Add cases
1197         for the new COMPLEX_ types.
1198         (gcc::jit::playback::context::new_function): If creating a
1199         builtin, set the DECL_BUILT_IN_CLASS and attributes on the fndecl,
1200         and call set_builtin_decl.
1201         (gcc::jit::playback::context::replay): If we have a
1202         builtins_manager, call its finish_playback method when we're done.
1204         * jit-playback.h:
1205         (gcc::jit::playback::context::get_builtins_manager): New function.
1207         * jit-recording.c
1208         (gcc::jit::recording::context::get_builtins_manager): New function.
1209         (gcc::jit::recording::get_builtin_function): Use
1210         get_builtins_manager, in case we're a child context.
1211         (gcc::jit::recording::memento_of_get_type::dereference): Add the
1212         COMPLEX_ types.
1213         (gcc::jit::recording::memento_of_get_type::is_int): Likewise.
1214         (gcc::jit::recording::memento_of_get_type::is_float): Likewise.
1215         (gcc::jit::recording::memento_of_get_type::is_bool): Likewise.
1216         (get_type_strings): Likewise.
1218         * jit-recording.h
1219         (gcc::jit::recording::context::get_builtins_manager): New.
1221         * libgccjit.h (enum gcc_jit_types): Add
1222         GCC_JIT_TYPE_COMPLEX_FLOAT, GCC_JIT_TYPE_COMPLEX_DOUBLE,
1223         GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE.
1225 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1227         * jit-builtins.c
1228         (gcc::jit::recording::builtins_manager::get_builtin_function):
1229         Check for NULL return from make_builtin_function.
1230         (gcc::jit::recording::builtins_manager::make_builtin_function):
1231         Check for NULL return from get_type.
1233 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1235         * jit-playback.c (gcc::jit::playback::context::compile): Move DSO
1236         creation code into...
1237         (gcc::jit::playback::context::convert_to_dso): New function.
1238         * jit-playback.h (gcc::jit::playback::context::convert_to_dso):
1239         New function.
1241 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1243         * jit-playback.c (gcc::jit::playback::context::compile): Use an
1244         auto_vec<const char *> rather than a const char *[20] for the
1245         top-level argv, and move the logic to build it to...
1246         (gcc::jit::playback::context::make_fake_args): New function.
1247         * jit-playback.h (gcc::jit::playback::context::make_fake_args):
1248         New function.
1250 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1252         * Make-lang.in (jit_OBJS): Add jit/jit-result.o.
1253         * jit-playback.c: Include new header jit-result.h.
1254         (gcc::jit::result::result): Move to new file jit-result.c.
1255         (gcc::jit::result::~result): Likewise.
1256         (gcc::jit::playback::result): Likewise.
1257         * jit-recording.h (class gcc::jit::result): Move to new
1258         header jit-result.h.
1259         * jit-result.c: New file, to contain...
1260         (gcc::jit::result::result): Move here from jit-playback.c,
1261         removing erroneous "playback" namespace from comment.
1262         (gcc::jit::result::~result): Likewise.
1263         (gcc::jit::playback::result): Likewise.
1264         * jit-result.h: New file, to contain...
1265         (class gcc::jit::result): Move from jit-recording.h.
1266         * libgccjit.c: Include jit-result.h.
1267         (gcc_jit_result_get_code): Update comment to reflect move
1268         of implementation.
1269         (gcc_jit_result_release): Likewise.
1271 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1273         PR jit/63854
1274         * docs/examples/tut04-toyvm/toyvm.c
1275         (toyvm_compiled_function): New typedef.
1276         (toyvm_compiled_func) Rename to...
1277         (toyvm_compiled_code) ...this.
1278         (struct toyvm_compiled_function): New struct.
1279         (toyvm_function_compile): Return a toyvm_compiled_function *
1280         rather than a toyvm_compiled_func, so that the caller can fully
1281         clean things up.  Free "funcname".
1282         (test_script): Update for change to toyvm_function_compile.
1283         Clean up the toyvm_compiled_function.
1284         (main): Likewise.
1285         (docs/intro/tutorial04.rst): Update to reflect the above changes,
1286         and to better spell out the lifetime of the compiled code.
1288 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1290         PR jit/63854
1291         * jit-builtins.c
1292         (gcc::jit::recording::builtins_manager::make_fn_type): Call the
1293         context's new_function_type method, rather than directly creating
1294         a function_type instance.
1295         * jit-recording.c
1296         (gcc::jit::recording::context::new_function_type): New method,
1297         adapted from part of...
1298         (gcc::jit::recording::context::new_function_ptr_type): ...this.
1299         Update to call new_function_type.
1300         * jit-recording.h
1301         (gcc::jit::recording::context::new_function_type): New method.
1303 2014-12-01  David Malcolm  <dmalcolm@redhat.com>
1305         PR jit/63969
1306         * jit-playback.c: Ensure that ctxt_progname is non-NULL.
1308 2014-11-19  David Malcolm  <dmalcolm@redhat.com>
1310         PR jit/63854
1311         * jit-playback.c (gcc::jit::playback::compound_type::set_fields):
1312         Convert param from const vec<playback::field *> & to
1313         const auto_vec<playback::field *> *.
1314         (gcc::jit::playback::context::new_function_type): Convert param
1315         "param_types" from vec<type *> * to const auto_vec<type *> *.
1316         (gcc::jit::playback::context::new_function): Convert param
1317         "params" from vec<param *> * to const auto_vec<param *> *.
1318         (gcc::jit::playback::context::build_call): Convert param "args"
1319         from vec<rvalue *> to const auto_vec<rvalue *> *.
1320         (gcc::jit::playback::context::new_call): Likewise.
1321         (gcc::jit::playback::context::new_call_through_ptr): Likewise.
1322         (wrapper_finalizer): New function.
1323         (gcc::jit::playback::wrapper::operator new): Call the finalizer
1324         variant of ggc_internal_cleared_alloc, supplying
1325         wrapper_finalizer.
1326         (gcc::jit::playback::function::finalizer): New.
1327         (gcc::jit::playback::block::finalizer): New.
1328         (gcc::jit::playback::source_file::finalizer): New.
1329         (gcc::jit::playback::source_line::finalizer): New.
1331         * jit-playback.h
1332         (gcc::jit::playback::context::new_function_type): Convert param
1333         "param_types" from vec<type *> * to const auto_vec<type *> *.
1334         (gcc::jit::playback::context::new_function): Convert param
1335         "params" from vec<param *> * to const auto_vec<param *> *.
1336         (gcc::jit::playback::context::new_call): Convert param
1337         "args" from vec<rvalue *> to const auto_vec<rvalue *> *.
1338         (gcc::jit::playback::context::new_call_through_ptr): Likewise.
1339         (gcc::jit::playback::context::build_call): Likewise.
1340         (gcc::jit::playback::context): Convert fields "m_functions",
1341         "m_source_files", "m_cached_locations" from vec to auto_vec.
1342         (gcc::jit::playback::wrapper::finalizer): New virtual function.
1343         (gcc::jit::playback::compound_type::set_fields): Convert param fro
1344         const vec<playback::field *> & to
1345         const auto_vec<playback::field *> *.
1346         (gcc::jit::playback::function::finalizer): New.
1347         (gcc::jit::playback::block::finalizer): New.
1348         (gcc::jit::playback::source_file::finalizer): New.
1349         (gcc::jit::playback::source_line::finalizer): New.
1351         * jit-recording.c
1352         (gcc::jit::recording::function_type::replay_into): Convert local
1353         from a vec into an auto_vec.
1354         (gcc::jit::recording::fields::replay_into): Likewise.
1355         (gcc::jit::recording::function::replay_into): Likewise.
1356         (gcc::jit::recording::call::replay_into): Likewise.
1357         (gcc::jit::recording::call_through_ptr::replay_into): Likewise.
1359         * jit-recording.h (gcc::jit::recording::context): Convert fields
1360         "m_mementos", "m_compound_types", "m_functions" from vec<> to
1361         auto_vec <>.
1362         (gcc::jit::recording::function_type::get_param_types): Convert
1363         return type from vec<type *> to const vec<type *> &.
1364         (gcc::jit::recording::function_type): Convert field
1365         "m_param_types" from a vec<> to an auto_vec<>.
1366         (gcc::jit::recording::fields): Likewise for field "m_fields".
1367         (gcc::jit::recording::function::get_params): Convert return type
1368         from vec <param *> to const vec<param *> &.
1369         (gcc::jit::recording::function): Convert fields "m_params",
1370         "m_locals", "m_blocks" from vec<> to auto_vec<>.
1371         (gcc::jit::recording::block): Likewise for field "m_statements".
1372         vec<> to auto_vec<>.
1373         (gcc::jit::recording::call): Likewise for field "m_args".
1374         (gcc::jit::recording::call_through_ptr): Likewise.
1376 2014-11-19  David Malcolm  <dmalcolm@redhat.com>
1378         PR jit/63854
1379         * jit-recording.c (recording::function::validate): Convert
1380         "worklist" from vec<> to autovec<> to fix a leak.
1382 2014-11-11  David Malcolm  <dmalcolm@redhat.com>
1384         * ChangeLog.jit: New.
1385         * ChangeLog: New.
1386         * Make-lang.in: New.
1387         * TODO.rst: New.
1388         * config-lang.in: New.
1389         * docs/Makefile: New.
1390         * docs/_build/texinfo/Makefile: New.
1391         * docs/_build/texinfo/factorial.png: New.
1392         * docs/_build/texinfo/libgccjit.texi: New.
1393         * docs/_build/texinfo/sum-of-squares.png: New.
1394         * docs/conf.py: New.
1395         * docs/examples/tut01-hello-world.c: New.
1396         * docs/examples/tut02-square.c: New.
1397         * docs/examples/tut03-sum-of-squares.c: New.
1398         * docs/examples/tut04-toyvm/Makefile: New.
1399         * docs/examples/tut04-toyvm/factorial.toy: New.
1400         * docs/examples/tut04-toyvm/fibonacci.toy: New.
1401         * docs/examples/tut04-toyvm/toyvm.c: New.
1402         * docs/index.rst: New.
1403         * docs/internals/index.rst: New.
1404         * docs/intro/factorial.png: New.
1405         * docs/intro/index.rst: New.
1406         * docs/intro/sum-of-squares.png: New.
1407         * docs/intro/tutorial01.rst: New.
1408         * docs/intro/tutorial02.rst: New.
1409         * docs/intro/tutorial03.rst: New.
1410         * docs/intro/tutorial04.rst: New.
1411         * docs/topics/contexts.rst: New.
1412         * docs/topics/expressions.rst: New.
1413         * docs/topics/functions.rst: New.
1414         * docs/topics/index.rst: New.
1415         * docs/topics/locations.rst: New.
1416         * docs/topics/objects.rst: New.
1417         * docs/topics/results.rst: New.
1418         * docs/topics/types.rst: New.
1419         * dummy-frontend.c: New.
1420         * jit-builtins.c: New.
1421         * jit-builtins.h: New.
1422         * jit-common.h: New.
1423         * jit-playback.c: New.
1424         * jit-playback.h: New.
1425         * jit-recording.c: New.
1426         * jit-recording.h: New.
1427         * libgccjit++.h: New.
1428         * libgccjit.c: New.
1429         * libgccjit.h: New.
1430         * libgccjit.map: New.
1431         * notes.txt: New.
1433 2013-07-26  David Malcolm  <dmalcolm@redhat.com>
1435         * Initial creation
1437 Copyright (C) 2013-2015 Free Software Foundation, Inc.
1439 Copying and distribution of this file, with or without modification,
1440 are permitted in any medium without royalty provided the copyright
1441 notice and this notice are preserved.