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