1.. Copyright (C) 2014-2020 Free Software Foundation, Inc.
2   Originally contributed by David Malcolm <dmalcolm@redhat.com>
3
4   This is free software: you can redistribute it and/or modify it
5   under the terms of the GNU General Public License as published by
6   the Free Software Foundation, either version 3 of the License, or
7   (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   General Public License for more details.
13
14   You should have received a copy of the GNU General Public License
15   along with this program.  If not, see
16   <http://www.gnu.org/licenses/>.
17
18.. default-domain:: cpp
19
20Compiling a context
21===================
22
23Once populated, a :class:`gccjit::context` can be compiled to
24machine code, either in-memory via :func:`gccjit::context::compile` or
25to disk via :func:`gccjit::context::compile_to_file`.
26
27You can compile a context multiple times (using either form of
28compilation), although any errors that occur on the context will
29prevent any future compilation of that context.
30
31In-memory compilation
32*********************
33
34.. function:: gcc_jit_result *\
35              gccjit::context::compile ()
36
37   This calls into GCC and builds the code, returning a
38   `gcc_jit_result *`.
39
40   This is a thin wrapper around the
41   :c:func:`gcc_jit_context_compile` API entrypoint.
42
43Ahead-of-time compilation
44*************************
45
46Although libgccjit is primarily aimed at just-in-time compilation, it
47can also be used for implementing more traditional ahead-of-time
48compilers, via the :func:`gccjit::context::compile_to_file` method.
49
50.. function:: void \
51              gccjit::context::compile_to_file (enum gcc_jit_output_kind,\
52                                                const char *output_path)
53
54   Compile the :class:`gccjit::context` to a file of the given
55   kind.
56
57   This is a thin wrapper around the
58   :c:func:`gcc_jit_context_compile_to_file` API entrypoint.
59