aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/jit-common.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@gcc.gnu.org>2014-11-11 21:55:52 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2014-11-11 21:55:52 +0000
commit35485da996c21efc9a574520a737e10fcbeab654 (patch)
tree50dc30071e711da437584255821706cc0e1ef426 /gcc/jit/jit-common.h
parent970a9caa49aff82c46a9d9f96410653ac9a588f7 (diff)
downloadgcc-35485da996c21efc9a574520a737e10fcbeab654.zip
gcc-35485da996c21efc9a574520a737e10fcbeab654.tar.gz
gcc-35485da996c21efc9a574520a737e10fcbeab654.tar.bz2
Merger of dmalcolm/jit branch from git
ChangeLog: * ChangeLog.jit: New. * MAINTAINERS (Various Maintainers): Add myself as jit maintainer. contrib/ChangeLog: * ChangeLog.jit: New. * jit-coverage-report.py: New file: a script to print crude code-coverage information for the libgccjit API. gcc/ChangeLog: * ChangeLog.jit: New. * Makefile.in (doc_build_sys): New variable, set to "sphinx" if sphinx is installed, falling back to "texinfo" otherwise. (FULL_DRIVER_NAME): New variable, adapted from the install-driver target. New target, a symlink within the builddir, linked to "xgcc", for use when running the JIT library from the builddir. (MOSTLYCLEANFILES): Add FULL_DRIVER_NAME. (install-driver): Use $(FULL_DRIVER_NAME) rather than spelling it out. * configure.ac (doc_build_sys): New variable, set to "sphinx" if sphinx is installed, falling back to "texinfo" otherwise. (GCC_DRIVER_NAME): Generate a gcc-driver-name.h file containing GCC_DRIVER_NAME for the benefit of jit/internal-api.c. * configure: Regenerate. * doc/install.texi (--enable-host-shared): Specify that this is required when building libgccjit. (Tools/packages necessary for modifying GCC): Add Sphinx. * timevar.def (TV_JIT_REPLAY): New. (TV_ASSEMBLE): New. (TV_LINK): New. (TV_LOAD): New. gcc/java/ChangeLog: * gcc/ChangeLog.jit: New. gcc/jit/ChangeLog: * ChangeLog.jit: New. * ChangeLog: New. * Make-lang.in: New. * TODO.rst: New. * config-lang.in: New. * docs/Makefile: New. * docs/_build/texinfo/Makefile: New. * docs/_build/texinfo/factorial.png: New. * docs/_build/texinfo/libgccjit.texi: New. * docs/_build/texinfo/sum-of-squares.png: New. * docs/conf.py: New. * docs/examples/tut01-hello-world.c: New. * docs/examples/tut02-square.c: New. * docs/examples/tut03-sum-of-squares.c: New. * docs/examples/tut04-toyvm/Makefile: New. * docs/examples/tut04-toyvm/factorial.toy: New. * docs/examples/tut04-toyvm/fibonacci.toy: New. * docs/examples/tut04-toyvm/toyvm.c: New. * docs/index.rst: New. * docs/internals/index.rst: New. * docs/intro/factorial.png: New. * docs/intro/index.rst: New. * docs/intro/sum-of-squares.png: New. * docs/intro/tutorial01.rst: New. * docs/intro/tutorial02.rst: New. * docs/intro/tutorial03.rst: New. * docs/intro/tutorial04.rst: New. * docs/topics/contexts.rst: New. * docs/topics/expressions.rst: New. * docs/topics/functions.rst: New. * docs/topics/index.rst: New. * docs/topics/locations.rst: New. * docs/topics/objects.rst: New. * docs/topics/results.rst: New. * docs/topics/types.rst: New. * dummy-frontend.c: New. * jit-builtins.c: New. * jit-builtins.h: New. * jit-common.h: New. * jit-playback.c: New. * jit-playback.h: New. * jit-recording.c: New. * jit-recording.h: New. * libgccjit++.h: New. * libgccjit.c: New. * libgccjit.h: New. * libgccjit.map: New. * notes.txt: New. gcc/testsuite/ChangeLog: * ChangeLog.jit: New. * jit.dg/all-non-failing-tests.h: New. * jit.dg/harness.h: New. * jit.dg/jit.exp: New. * jit.dg/test-accessing-struct.c: New. * jit.dg/test-accessing-union.c: New. * jit.dg/test-array-as-pointer.c: New. * jit.dg/test-arrays.c: New. * jit.dg/test-calling-external-function.c: New. * jit.dg/test-calling-function-ptr.c: New. * jit.dg/test-combination.c: New. * jit.dg/test-dot-product.c: New. * jit.dg/test-empty.c: New. * jit.dg/test-error-accessing-field-in-other-struct.c: New. * jit.dg/test-error-adding-to-terminated-block.c: New. * jit.dg/test-error-array-as-pointer.c: New. * jit.dg/test-error-bad-cast.c: New. * jit.dg/test-error-block-in-wrong-function.c: New. * jit.dg/test-error-call-through-ptr-with-mismatching-args.c: New. * jit.dg/test-error-call-through-ptr-with-non-function.c: New. * jit.dg/test-error-call-through-ptr-with-non-pointer.c: New. * jit.dg/test-error-call-through-ptr-with-not-enough-args.c: New. * jit.dg/test-error-call-through-ptr-with-too-many-args.c: New. * jit.dg/test-error-call-with-mismatching-args.c: New. * jit.dg/test-error-call-with-not-enough-args.c: New. * jit.dg/test-error-call-with-too-many-args.c: New. * jit.dg/test-error-dereference-field-of-non-pointer.c: New. * jit.dg/test-error-dereference-read-of-non-pointer.c: New. * jit.dg/test-error-get-type-bad-enum.c: New. * jit.dg/test-error-index-not-a-numeric-type.c: New. * jit.dg/test-error-mismatching-types-in-assignment.c: New. * jit.dg/test-error-mismatching-types-in-call.c: New. * jit.dg/test-error-missing-return.c: New. * jit.dg/test-error-new-binary-op-bad-op.c: New. * jit.dg/test-error-new-function-bad-kind.c: New. * jit.dg/test-error-new-unary-op-bad-op.c: New. * jit.dg/test-error-null-passed-to-api.c: New. * jit.dg/test-error-return-within-void-function.c: New. * jit.dg/test-error-unreachable-block.c: New. * jit.dg/test-error-unterminated-block.c: New. * jit.dg/test-error-value-not-a-numeric-type.c: New. * jit.dg/test-expressions.c: New. * jit.dg/test-factorial.c: New. * jit.dg/test-fibonacci.c: New. * jit.dg/test-functions.c: New. * jit.dg/test-fuzzer.c: New. * jit.dg/test-hello-world.c: New. * jit.dg/test-linked-list.c: New. * jit.dg/test-long-names.c: New. * jit.dg/test-nested-contexts.c: New. * jit.dg/test-nested-loops.c: New. * jit.dg/test-operator-overloading.cc: New. * jit.dg/test-quadratic.c: New. * jit.dg/test-quadratic.cc: New. * jit.dg/test-reading-struct.c: New. * jit.dg/test-string-literal.c: New. * jit.dg/test-sum-of-squares.c: New. * jit.dg/test-threads.c: New. * jit.dg/test-types.c: New. * jit.dg/test-using-global.c: New. * jit.dg/test-volatile.c: New. include/ChangeLog: * ChangeLog.jit: New. libbacktrace/ChangeLog: * ChangeLog.jit: New. libcpp/ChangeLog: * ChangeLog.jit: New. libdecnumber/ChangeLog: * ChangeLog.jit: New. libiberty/ChangeLog: * ChangeLog.jit: New. zlib/ChangeLog: * ChangeLog.jit: New. From-SVN: r217374
Diffstat (limited to 'gcc/jit/jit-common.h')
-rw-r--r--gcc/jit/jit-common.h182
1 files changed, 182 insertions, 0 deletions
diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h
new file mode 100644
index 0000000..58e4a8c
--- /dev/null
+++ b/gcc/jit/jit-common.h
@@ -0,0 +1,182 @@
+/* Core of implementation of libgccjit.so
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef JIT_COMMON_H
+#define JIT_COMMON_H
+
+#include "libgccjit.h"
+
+#include "tree.h"
+#include "tree-iterator.h"
+
+#ifdef GCC_VERSION
+#if GCC_VERSION >= 4001
+#define GNU_PRINTF(M, N) __attribute__ ((format (gnu_printf, (M), (N))))
+#else
+#define GNU_PRINTF(M, N)
+#endif
+#endif
+
+const int NUM_GCC_JIT_TYPES = GCC_JIT_TYPE_FILE_PTR + 1;
+
+/* This comment is included by the docs.
+
+ In order to allow jit objects to be usable outside of a compile
+ whilst working with the existing structure of GCC's code the
+ C API is implemented in terms of a gcc::jit::recording::context,
+ which records the calls made to it.
+
+ When a gcc_jit_context is compiled, the recording context creates a
+ playback context. The playback context invokes the bulk of the GCC
+ code, and within the "frontend" parsing hook, plays back the recorded
+ API calls, creating GCC tree objects.
+
+ So there are two parallel families of classes: those relating to
+ recording, and those relating to playback:
+
+ * Visibility: recording objects are exposed back to client code,
+ whereas playback objects are internal to the library.
+
+ * Lifetime: recording objects have a lifetime equal to that of the
+ recording context that created them, whereas playback objects only
+ exist within the frontend hook.
+
+ * Memory allocation: recording objects are allocated by the recording
+ context, and automatically freed by it when the context is released,
+ whereas playback objects are allocated within the GC heap, and
+ garbage-collected; they can own GC-references.
+
+ * Integration with rest of GCC: recording objects are unrelated to the
+ rest of GCC, whereas playback objects are wrappers around "tree"
+ instances. Hence you can't ask a recording rvalue or lvalue what its
+ type is, whereas you can for a playback rvalue of lvalue (since it
+ can work with the underlying GCC tree nodes).
+
+ * Instancing: There can be multiple recording contexts "alive" at once
+ (albeit it only one compiling at once), whereas there can only be one
+ playback context alive at one time (since it interacts with the GC).
+
+ Ultimately if GCC could support multiple GC heaps and contexts, and
+ finer-grained initialization, then this recording vs playback
+ distinction could be eliminated.
+
+ During a playback, we associate objects from the recording with
+ their counterparts during this playback. For simplicity, we store this
+ within the recording objects, as ``void *m_playback_obj``, casting it to
+ the appropriate playback object subclass. For these casts to make
+ sense, the two class hierarchies need to have the same structure.
+
+ Note that the playback objects that ``m_playback_obj`` points to are
+ GC-allocated, but the recording objects don't own references:
+ these associations only exist within a part of the code where
+ the GC doesn't collect, and are set back to NULL before the GC can
+ run.
+
+ End of comment for inclusion in the docs. */
+
+namespace gcc {
+
+namespace jit {
+
+class result;
+class dump;
+
+namespace recording {
+
+ /* Recording types. */
+
+ /* Indentation indicates inheritance: */
+ class context;
+ class builtins_manager; // declared within jit-builtins.h
+ class memento;
+ class string;
+ class location;
+ class type;
+ class function_type;
+ class compound_type;
+ class struct_;
+ class union_;
+ class field;
+ class fields;
+ class function;
+ class block;
+ class rvalue;
+ class lvalue;
+ class local;
+ class global;
+ class param;
+ class statement;
+
+ /* End of recording types. */
+}
+
+namespace playback {
+ /* Playback types. */
+
+ /* Indentation indicates inheritance: */
+ class context;
+ class wrapper;
+ class type;
+ class compound_type;
+ class field;
+ class function;
+ class block;
+ class rvalue;
+ class lvalue;
+ class param;
+ class source_file;
+ class source_line;
+ class location;
+
+ /* End of playback types. */
+}
+
+typedef playback::context replayer;
+
+class dump
+{
+public:
+ dump (recording::context &ctxt,
+ const char *filename,
+ bool update_locations);
+ ~dump ();
+
+ void write (const char *fmt, ...)
+ GNU_PRINTF(2, 3);
+
+ bool update_locations () const { return m_update_locations; }
+
+ recording::location *
+ make_location () const;
+
+private:
+ recording::context &m_ctxt;
+ const char *m_filename;
+ bool m_update_locations;
+ int m_line;
+ int m_column;
+ FILE *m_file;
+};
+
+} // namespace gcc::jit
+
+} // namespace gcc
+
+#endif /* JIT_COMMON_H */