diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-12-01 17:52:03 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-12-01 17:52:03 +0000 |
commit | 56dea35f948f84bff37051141893e1d237c3d0f9 (patch) | |
tree | e01e97dd200d920f68a44c0ffbf55499ae2b1fe5 /gcc/jit | |
parent | 52b9468f1575b87e490cc3fdcff4c51f25fb49c1 (diff) | |
download | gcc-56dea35f948f84bff37051141893e1d237c3d0f9.zip gcc-56dea35f948f84bff37051141893e1d237c3d0f9.tar.gz gcc-56dea35f948f84bff37051141893e1d237c3d0f9.tar.bz2 |
Move gcc_jit_result implementation to a new files jit-result.{h|c}
gcc/jit/ChangeLog:
* Make-lang.in (jit_OBJS): Add jit/jit-result.o.
* jit-playback.c: Include new header jit-result.h.
(gcc::jit::result::result): Move to new file jit-result.c.
(gcc::jit::result::~result): Likewise.
(gcc::jit::playback::result): Likewise.
* jit-recording.h (class gcc::jit::result): Move to new
header jit-result.h.
* jit-result.c: New file, to contain...
(gcc::jit::result::result): Move here from jit-playback.c,
removing erroneous "playback" namespace from comment.
(gcc::jit::result::~result): Likewise.
(gcc::jit::playback::result): Likewise.
* jit-result.h: New file, to contain...
(class gcc::jit::result): Move from jit-recording.h.
* libgccjit.c: Include jit-result.h.
(gcc_jit_result_get_code): Update comment to reflect move
of implementation.
(gcc_jit_result_release): Likewise.
From-SVN: r218236
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/jit/Make-lang.in | 1 | ||||
-rw-r--r-- | gcc/jit/jit-playback.c | 43 | ||||
-rw-r--r-- | gcc/jit/jit-recording.h | 15 | ||||
-rw-r--r-- | gcc/jit/jit-result.c | 73 | ||||
-rw-r--r-- | gcc/jit/jit-result.h | 47 | ||||
-rw-r--r-- | gcc/jit/libgccjit.c | 6 |
7 files changed, 146 insertions, 60 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 210dcb0..455ba59 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,5 +1,26 @@ 2014-12-01 David Malcolm <dmalcolm@redhat.com> + * Make-lang.in (jit_OBJS): Add jit/jit-result.o. + * jit-playback.c: Include new header jit-result.h. + (gcc::jit::result::result): Move to new file jit-result.c. + (gcc::jit::result::~result): Likewise. + (gcc::jit::playback::result): Likewise. + * jit-recording.h (class gcc::jit::result): Move to new + header jit-result.h. + * jit-result.c: New file, to contain... + (gcc::jit::result::result): Move here from jit-playback.c, + removing erroneous "playback" namespace from comment. + (gcc::jit::result::~result): Likewise. + (gcc::jit::playback::result): Likewise. + * jit-result.h: New file, to contain... + (class gcc::jit::result): Move from jit-recording.h. + * libgccjit.c: Include jit-result.h. + (gcc_jit_result_get_code): Update comment to reflect move + of implementation. + (gcc_jit_result_release): Likewise. + +2014-12-01 David Malcolm <dmalcolm@redhat.com> + PR jit/63854 * docs/examples/tut04-toyvm/toyvm.c (toyvm_compiled_function): New typedef. diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index 167fcad..e88fd00 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -64,6 +64,7 @@ jit_OBJS = attribs.o \ jit/libgccjit.o \ jit/jit-recording.o \ jit/jit-playback.o \ + jit/jit-result.o \ jit/jit-builtins.o # Use strict warnings for this front end. diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 584a8e6..cd124eb 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "jit-common.h" #include "jit-playback.h" +#include "jit-result.h" /* gcc::jit::playback::context::build_cast uses the convert.h API, @@ -1951,48 +1952,6 @@ add_error_va (location *loc, const char *fmt, va_list ap) fmt, ap); } -/* Constructor for gcc::jit::playback::result. */ - -result:: -result(void *dso_handle) - : m_dso_handle(dso_handle) -{ -} - -/* gcc::jit::playback::result's destructor. - - Called implicitly by gcc_jit_result_release. */ - -result::~result() -{ - dlclose (m_dso_handle); -} - -/* Attempt to locate the given function by name within the - playback::result, using dlsym. - - Implements the post-error-checking part of - gcc_jit_result_get_code. */ - -void * -result:: -get_code (const char *funcname) -{ - void *code; - const char *error; - - /* Clear any existing error. */ - dlerror (); - - code = dlsym (m_dso_handle, funcname); - - if ((error = dlerror()) != NULL) { - fprintf(stderr, "%s\n", error); - } - - return code; -} - /* Dealing with the linemap API. */ /* Construct a playback::location for a recording::location, if it diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 9b2cfc6..1b0ef91 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -1576,21 +1576,6 @@ private: } // namespace gcc::jit::recording -/* The result of JIT-compilation. */ -class result -{ -public: - result(void *dso_handle); - - virtual ~result(); - - void * - get_code (const char *funcname); - -private: - void *m_dso_handle; -}; - } // namespace gcc::jit } // namespace gcc diff --git a/gcc/jit/jit-result.c b/gcc/jit/jit-result.c new file mode 100644 index 0000000..9e1e6d8 --- /dev/null +++ b/gcc/jit/jit-result.c @@ -0,0 +1,73 @@ +/* Internals of libgccjit: implementation of gcc_jit_result + 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/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "jit-result.h" + +namespace gcc { +namespace jit { + +/* Constructor for gcc::jit::result. */ + +result:: +result(void *dso_handle) + : m_dso_handle(dso_handle) +{ +} + +/* gcc::jit::result's destructor. + + Called implicitly by gcc_jit_result_release. */ + +result::~result() +{ + dlclose (m_dso_handle); +} + +/* Attempt to locate the given function by name within the + playback::result, using dlsym. + + Implements the post-error-checking part of + gcc_jit_result_get_code. */ + +void * +result:: +get_code (const char *funcname) +{ + void *code; + const char *error; + + /* Clear any existing error. */ + dlerror (); + + code = dlsym (m_dso_handle, funcname); + + if ((error = dlerror()) != NULL) { + fprintf(stderr, "%s\n", error); + } + + return code; +} + +} // namespace gcc::jit + +} // namespace gcc diff --git a/gcc/jit/jit-result.h b/gcc/jit/jit-result.h new file mode 100644 index 0000000..60d6930 --- /dev/null +++ b/gcc/jit/jit-result.h @@ -0,0 +1,47 @@ +/* Internals of libgccjit: implementation of gcc_jit_result + 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_RESULT_H +#define JIT_RESULT_H + +namespace gcc { + +namespace jit { + +/* The result of JIT-compilation. */ +class result +{ +public: + result(void *dso_handle); + + virtual ~result(); + + void * + get_code (const char *funcname); + +private: + void *m_dso_handle; +}; + +} // namespace gcc::jit + +} // namespace gcc + +#endif /* JIT_RESULT_H */ diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 7bc9209..42769e8 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "libgccjit.h" #include "jit-common.h" #include "jit-recording.h" +#include "jit-result.h" /* The opaque types used by the public API are actually subclasses of the gcc::jit::recording classes. */ @@ -2047,8 +2048,7 @@ gcc_jit_context_get_first_error (gcc_jit_context *ctxt) /* Public entrypoint. See description in libgccjit.h. After error-checking, the real work is done by the - gcc::jit::playback::result::get_code method in - jit-playback.c. */ + gcc::jit::result::get_code method in jit-result.c. */ void * gcc_jit_result_get_code (gcc_jit_result *result, @@ -2063,7 +2063,7 @@ gcc_jit_result_get_code (gcc_jit_result *result, /* Public entrypoint. See description in libgccjit.h. After error-checking, this is essentially a wrapper around the - destructor for gcc::jit::playback::result in jit-playback.c. */ + destructor for gcc::jit::result in jit-result.c. */ void gcc_jit_result_release (gcc_jit_result *result) |