diff options
author | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-11-11 21:55:52 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-11-11 21:55:52 +0000 |
commit | 35485da996c21efc9a574520a737e10fcbeab654 (patch) | |
tree | 50dc30071e711da437584255821706cc0e1ef426 /gcc/jit/dummy-frontend.c | |
parent | 970a9caa49aff82c46a9d9f96410653ac9a588f7 (diff) | |
download | gcc-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/dummy-frontend.c')
-rw-r--r-- | gcc/jit/dummy-frontend.c | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c new file mode 100644 index 0000000..7e3abda --- /dev/null +++ b/gcc/jit/dummy-frontend.c @@ -0,0 +1,252 @@ +/* jit.c -- Dummy "frontend" for use during JIT-compilation. + Copyright (C) 2013-2014 Free Software Foundation, Inc. + +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/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "opts.h" +#include "signop.h" +#include "tree-core.h" +#include "stor-layout.h" +#include "tree.h" +#include "debug.h" +#include "langhooks.h" +#include "langhooks-def.h" +#include "hash-map.h" +#include "is-a.h" +#include "plugin-api.h" +#include "vec.h" +#include "hashtab.h" +#include "hash-set.h" +#include "machmode.h" +#include "tm.h" +#include "hard-reg-set.h" +#include "function.h" +#include "ipa-ref.h" +#include "dumpfile.h" +#include "cgraph.h" + +#include "jit-common.h" +#include "jit-playback.h" + +#include <mpfr.h> + +/* Language-dependent contents of a type. */ + +struct GTY(()) lang_type +{ + char dummy; +}; + +/* Language-dependent contents of a decl. */ + +struct GTY((variable_size)) lang_decl +{ + char dummy; +}; + +/* Language-dependent contents of an identifier. This must include a + tree_identifier. */ + +struct GTY(()) lang_identifier +{ + struct tree_identifier common; +}; + +/* The resulting tree type. */ + +union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), + chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) +lang_tree_node +{ + union tree_node GTY((tag ("0"), + desc ("tree_node_structure (&%h)"))) generic; + struct lang_identifier GTY((tag ("1"))) identifier; +}; + +/* We don't use language_function. */ + +struct GTY(()) language_function +{ + int dummy; +}; + +/* GC-marking callback for use from jit_root_tab. + + If there's an active playback context, call its marking method + so that it can mark any pointers it references. */ + +static void my_ggc_walker (void *) +{ + if (gcc::jit::active_playback_ctxt) + gcc::jit::active_playback_ctxt->gt_ggc_mx (); +} + +const char *dummy; + +struct ggc_root_tab jit_root_tab[] = + { + { + &dummy, 1, 0, my_ggc_walker, NULL + }, + LAST_GGC_ROOT_TAB + }; + +/* Language hooks. */ + +static bool +jit_langhook_init (void) +{ + static bool registered_root_tab = false; + if (!registered_root_tab) + { + ggc_register_root_tab (jit_root_tab); + registered_root_tab = true; + } + + build_common_tree_nodes (false, false); + + /* I don't know why this has to be done explicitly. */ + void_list_node = build_tree_list (NULL_TREE, void_type_node); + + build_common_builtin_nodes (); + + /* The default precision for floating point numbers. This is used + for floating point constants with abstract type. This may + eventually be controllable by a command line option. */ + mpfr_set_default_prec (256); + + return true; +} + +static void +jit_langhook_parse_file (void) +{ + /* Replay the activity by the client, recorded on the context. */ + gcc_assert (gcc::jit::active_playback_ctxt); + gcc::jit::active_playback_ctxt->replay (); +} + +static tree +jit_langhook_type_for_mode (enum machine_mode mode, int unsignedp) +{ + if (mode == TYPE_MODE (float_type_node)) + return float_type_node; + + if (mode == TYPE_MODE (double_type_node)) + return double_type_node; + + if (mode == TYPE_MODE (integer_type_node)) + return unsignedp ? unsigned_type_node : integer_type_node; + + if (mode == TYPE_MODE (long_integer_type_node)) + return unsignedp ? long_unsigned_type_node : long_integer_type_node; + + if (COMPLEX_MODE_P (mode)) + { + if (mode == TYPE_MODE (complex_float_type_node)) + return complex_float_type_node; + if (mode == TYPE_MODE (complex_double_type_node)) + return complex_double_type_node; + if (mode == TYPE_MODE (complex_long_double_type_node)) + return complex_long_double_type_node; + if (mode == TYPE_MODE (complex_integer_type_node) && !unsignedp) + return complex_integer_type_node; + } + + /* gcc_unreachable */ + return NULL; +} + +static tree +jit_langhook_type_for_size (unsigned int bits ATTRIBUTE_UNUSED, + int unsignedp ATTRIBUTE_UNUSED) +{ + gcc_unreachable (); + return NULL; +} + +/* Record a builtin function. We just ignore builtin functions. */ + +static tree +jit_langhook_builtin_function (tree decl) +{ + return decl; +} + +static bool +jit_langhook_global_bindings_p (void) +{ + gcc_unreachable (); + return true; +} + +static tree +jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED) +{ + gcc_unreachable (); +} + +static tree +jit_langhook_getdecls (void) +{ + return NULL; +} + +static void +jit_langhook_write_globals (void) +{ + /* This is the hook that runs the middle and backends: */ + symtab->finalize_compilation_unit (); +} + +#undef LANG_HOOKS_NAME +#define LANG_HOOKS_NAME "libgccjit" + +#undef LANG_HOOKS_INIT +#define LANG_HOOKS_INIT jit_langhook_init + +#undef LANG_HOOKS_PARSE_FILE +#define LANG_HOOKS_PARSE_FILE jit_langhook_parse_file + +#undef LANG_HOOKS_TYPE_FOR_MODE +#define LANG_HOOKS_TYPE_FOR_MODE jit_langhook_type_for_mode + +#undef LANG_HOOKS_TYPE_FOR_SIZE +#define LANG_HOOKS_TYPE_FOR_SIZE jit_langhook_type_for_size + +#undef LANG_HOOKS_BUILTIN_FUNCTION +#define LANG_HOOKS_BUILTIN_FUNCTION jit_langhook_builtin_function + +#undef LANG_HOOKS_GLOBAL_BINDINGS_P +#define LANG_HOOKS_GLOBAL_BINDINGS_P jit_langhook_global_bindings_p + +#undef LANG_HOOKS_PUSHDECL +#define LANG_HOOKS_PUSHDECL jit_langhook_pushdecl + +#undef LANG_HOOKS_GETDECLS +#define LANG_HOOKS_GETDECLS jit_langhook_getdecls + +#undef LANG_HOOKS_WRITE_GLOBALS +#define LANG_HOOKS_WRITE_GLOBALS jit_langhook_write_globals + +struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; + +#include "gt-jit-dummy-frontend.h" +#include "gtype-jit.h" |