diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-01-12 17:14:02 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-01-12 17:14:02 +0000 |
commit | 791cfef8e7553e4939a1ed095e25414f6dc713d6 (patch) | |
tree | 062ae8773efd3200e81a237028025864147648c8 /gcc/jit/libgccjit.h | |
parent | 6c0fcb81dad4c8f2f9c687a40627db0442a475f4 (diff) | |
download | gcc-791cfef8e7553e4939a1ed095e25414f6dc713d6.zip gcc-791cfef8e7553e4939a1ed095e25414f6dc713d6.tar.gz gcc-791cfef8e7553e4939a1ed095e25414f6dc713d6.tar.bz2 |
jit: API change to gcc_jit_context_new_global
gcc/jit/ChangeLog:
* docs/cp/topics/expressions.rst (Global variables): Add
enum gcc_jit_global_kind param to gccjit::context::new_global.
* docs/topics/expressions.rst (Global variables): Likewise.
Document the new enum.
* docs/topics/results.rst (Compilation results): Document
globals-handling.
* dummy-frontend.c (jit_langhook_write_globals): Call into the
playback context's write_global_decls_1 and write_global_decls_2
before and after calling symtab->finalize_compilation_unit ().
* jit-playback.c: Include "debug.h".
(gcc::jit::playback::context::new_global): Add "kind" param and
use it to set TREE_PUBLIC, TREE_STATIC and DECL_EXTERNAL on the
underlying VAR_DECL. Call varpool_node::get_create on the
VAR_DECL, and add it to m_globals.
(gcc::jit::playback::context::write_global_decls_1): New function.
(gcc::jit::playback::context::write_global_decls_2): New function.
* jit-playback.h (gcc::jit::playback::context::context): Call
create on m_globals.
(gcc::jit::playback::context::new_global): Add "kind" param.
(gcc::jit::playback::context::write_global_decls_1): New function.
(gcc::jit::playback::context::write_global_decls_2): New function.
(gcc::jit::playback::context::m_globals): New field.
* jit-recording.c (gcc::jit::recording::context::context):
Initialize m_globals.
(gcc::jit::recording::context::new_global): Add param "kind".
Add the new global to m_globals.
(gcc::jit::recording::context::dump_to_file): Dump the globals.
(gcc::jit::recording::global::replay_into): Add field m_kind.
(gcc::jit::recording::global::write_to_dump): New override.
* jit-recording.h (gcc::jit::recording::context::new_global): Add
param "kind".
(gcc::jit::recording::context::m_globals): New field.
(gcc::jit::recording::global::global): Add param kind.
(gcc::jit::recording::global::write_to_dump): New override.
(gcc::jit::recording::global::m_kind): New field.
* jit-result.c (gcc::jit::result::get_global): New function.
* jit-result.h (gcc::jit::result::get_global): New function.
* libgccjit++.h (gccjit::context::new_global): Add "kind" param.
* libgccjit.c (gcc_jit_context_new_global): Likewise.
(gcc_jit_result_get_global): New API entrypoint.
* libgccjit.h (gcc_jit_result_get_global): New API entrypoint.
(enum gcc_jit_global_kind): New enum.
(gcc_jit_context_new_global): API change: add "kind" param.
* libgccjit.map (gcc_jit_result_get_global): New symbol.
gcc/testsuite/ChangeLog:
* jit.dg/test-array-as-pointer.c (create_code): Update call
to gcc_jit_context_new_global by setting "kind" to
GCC_JIT_GLOBAL_IMPORTED.
* jit.dg/test-error-array-as-pointer.c: Likewise.
* jit.dg/test-expressions.c (make_test_of_get_address): Likewise.
* jit.dg/test-fuzzer.c (make_random_global): Likewise, but
setting kind to GCC_JIT_GLOBAL_EXPORTED.
* jit.dg/test-using-global.c (the_global): Rename to...
(imported_global): ...this.
(create_code): Update to test the three kinds of global.
(verify_code): Likewise.
From-SVN: r219480
Diffstat (limited to 'gcc/jit/libgccjit.h')
-rw-r--r-- | gcc/jit/libgccjit.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 92eed37..41c76ea 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -299,6 +299,13 @@ extern void * gcc_jit_result_get_code (gcc_jit_result *result, const char *funcname); +/* Locate a given global within the built machine code. + It must have been created using GCC_JIT_GLOBAL_EXPORTED. + This is a ptr to the global, so e.g. for an int this is an int *. */ +extern void * +gcc_jit_result_get_global (gcc_jit_result *result, + const char *name); + /* Once we're done with the code, this unloads the built .so file. This cleans up the result; after calling this, it's no longer valid to use the result. */ @@ -606,10 +613,26 @@ gcc_jit_block_get_function (gcc_jit_block *block); /********************************************************************** lvalues, rvalues and expressions. **********************************************************************/ +enum gcc_jit_global_kind +{ + /* Global is defined by the client code and visible + by name outside of this JIT context via gcc_jit_result_get_global. */ + GCC_JIT_GLOBAL_EXPORTED, + + /* Global is defined by the client code, but is invisible + outside of this JIT context. Analogous to a "static" global. */ + GCC_JIT_GLOBAL_INTERNAL, + + /* Global is not defined by the client code; we're merely + referring to it. Analogous to using an "extern" global from a + header file. */ + GCC_JIT_GLOBAL_IMPORTED +}; extern gcc_jit_lvalue * gcc_jit_context_new_global (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_global_kind kind, gcc_jit_type *type, const char *name); |