New jit API entrypoint: gcc_jit_context_compile_to_file
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 20 Jan 2015 01:32:48 +0000 (01:32 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 20 Jan 2015 01:32:48 +0000 (01:32 +0000)
commitfdce7209c23212b50f08604f242e9bbb5281818b
tree474c9e2fbfe804a349ce0083fd02f728b0475514
parentcb22ab4164a2140fa7ec38cd929d464224d9c222
New jit API entrypoint: gcc_jit_context_compile_to_file

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

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

From-SVN: r219876
29 files changed:
gcc/jit/ChangeLog
gcc/jit/docs/_build/texinfo/libgccjit.texi
gcc/jit/docs/cp/topics/compilation.rst [new file with mode: 0644]
gcc/jit/docs/cp/topics/index.rst
gcc/jit/docs/cp/topics/results.rst [deleted file]
gcc/jit/docs/examples/emit-alphabet.bf [new file with mode: 0644]
gcc/jit/docs/examples/tut05-bf.c [new file with mode: 0644]
gcc/jit/docs/internals/test-hello-world.exe.log.txt
gcc/jit/docs/intro/index.rst
gcc/jit/docs/intro/tutorial05.rst [new file with mode: 0644]
gcc/jit/docs/topics/compilation.rst [new file with mode: 0644]
gcc/jit/docs/topics/index.rst
gcc/jit/docs/topics/results.rst [deleted file]
gcc/jit/jit-playback.c
gcc/jit/jit-playback.h
gcc/jit/jit-recording.c
gcc/jit/jit-recording.h
gcc/jit/libgccjit++.h
gcc/jit/libgccjit.c
gcc/jit/libgccjit.h
gcc/jit/libgccjit.map
gcc/jit/notes.txt
gcc/testsuite/ChangeLog
gcc/testsuite/jit.dg/harness.h
gcc/testsuite/jit.dg/jit.exp
gcc/testsuite/jit.dg/test-compile-to-assembler.c [new file with mode: 0644]
gcc/testsuite/jit.dg/test-compile-to-dynamic-library.c [new file with mode: 0644]
gcc/testsuite/jit.dg/test-compile-to-executable.c [new file with mode: 0644]
gcc/testsuite/jit.dg/test-compile-to-object.c [new file with mode: 0644]