aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/jit')
-rw-r--r--gcc/jit/docs/topics/compatibility.rst9
-rw-r--r--gcc/jit/docs/topics/expressions.rst21
-rw-r--r--gcc/jit/jit-playback.h6
-rw-r--r--gcc/jit/jit-recording.c21
-rw-r--r--gcc/jit/jit-recording.h5
-rw-r--r--gcc/jit/libgccjit.c13
-rw-r--r--gcc/jit/libgccjit.h14
-rw-r--r--gcc/jit/libgccjit.map5
8 files changed, 90 insertions, 4 deletions
diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst
index 2ad6e42..c6c14f0 100644
--- a/gcc/jit/docs/topics/compatibility.rst
+++ b/gcc/jit/docs/topics/compatibility.rst
@@ -293,3 +293,12 @@ entrypoints:
thread-local storage model of a variable:
* :func:`gcc_jit_lvalue_set_tls_model`
+
+.. _LIBGCCJIT_ABI_18:
+
+``LIBGCCJIT_ABI_18``
+-----------------------
+``LIBGCCJIT_ABI_18`` covers the addition of an API entrypoint to set the link
+section of a variable:
+
+ * :func:`gcc_jit_lvalue_set_link_section`
diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst
index 386b80d..280e0ea 100644
--- a/gcc/jit/docs/topics/expressions.rst
+++ b/gcc/jit/docs/topics/expressions.rst
@@ -576,6 +576,27 @@ where the rvalue is computed by reading from the storage area.
#ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model
+.. function:: void
+ gcc_jit_lvalue_set_link_section (gcc_jit_lvalue *lvalue,
+ const char *section_name)
+
+ Set the link section of a variable.
+ The parameter ``section_name`` must be non-NULL and must contain the
+ leading dot. Analogous to:
+
+ .. code-block:: c
+
+ int variable __attribute__((section(".section")));
+
+ in C.
+
+ This entrypoint was added in :ref:`LIBGCCJIT_ABI_18`; you can test for
+ its presence using
+
+ .. code-block:: c
+
+ #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section
+
Global variables
****************
diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index c9839c2..21ddffb 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -681,6 +681,12 @@ public:
set_decl_tls_model (as_tree (), tls_model);
}
+ void
+ set_link_section (const char* name)
+ {
+ set_decl_section_name (as_tree (), name);
+ }
+
private:
bool mark_addressable (location *loc);
};
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index 5ba35bd..b424079 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -3724,6 +3724,11 @@ recording::lvalue::set_tls_model (enum gcc_jit_tls_model model)
m_tls_model = model;
}
+void recording::lvalue::set_link_section (const char *name)
+{
+ m_link_section = new_string (name);
+}
+
/* The implementation of class gcc::jit::recording::param. */
/* Implementation of pure virtual hook recording::memento::replay_into
@@ -4568,8 +4573,8 @@ static const enum tls_model tls_models[] = {
void
recording::global::replay_into (replayer *r)
{
- playback::lvalue *global = m_initializer
- ? r->new_global_initialized (playback_location (r, m_loc),
+ playback::lvalue *global = m_initializer
+ ? r->new_global_initialized (playback_location (r, m_loc),
m_kind,
m_type->playback_type (),
m_type->dereference ()->get_size (),
@@ -4577,13 +4582,17 @@ recording::global::replay_into (replayer *r)
/ m_type->dereference ()->get_size (),
m_initializer,
playback_string (m_name))
- : r->new_global (playback_location (r, m_loc),
+ : r->new_global (playback_location (r, m_loc),
m_kind,
m_type->playback_type (),
playback_string (m_name));
+
if (m_tls_model != GCC_JIT_TLS_MODEL_NONE)
global->set_tls_model (recording::tls_models[m_tls_model]);
+ if (m_link_section != NULL)
+ global->set_link_section (m_link_section->c_str ());
+
set_playback_obj (global);
}
@@ -4713,6 +4722,12 @@ recording::global::write_reproducer (reproducer &r)
id,
tls_model_enum_strings[m_tls_model]);
+ if (m_link_section != NULL)
+ r.write (" gcc_jit_lvalue_set_link_section (%s, /* gcc_jit_lvalue *lvalue */\n"
+ " \"%s\"); /* */\n",
+ id,
+ m_link_section->c_str ());
+
if (m_initializer)
switch (m_type->dereference ()->get_size ())
{
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 72fa30c..cedb247 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -1133,7 +1133,8 @@ public:
location *loc,
type *type_)
: rvalue (ctxt, loc, type_),
- m_tls_model (GCC_JIT_TLS_MODEL_NONE)
+ m_tls_model (GCC_JIT_TLS_MODEL_NONE),
+ m_link_section (NULL)
{}
playback::lvalue *
@@ -1156,9 +1157,11 @@ public:
virtual const char *access_as_lvalue (reproducer &r);
virtual bool is_global () const { return false; }
void set_tls_model (enum gcc_jit_tls_model model);
+ void set_link_section (const char *name);
protected:
enum gcc_jit_tls_model m_tls_model;
+ string *m_link_section;
};
class param : public lvalue
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 7ccb76a..59cef61 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -2238,6 +2238,19 @@ gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,
/* Public entrypoint. See description in libgccjit.h.
After error-checking, the real work is done by the
+ gcc::jit::recording::lvalue::set_link_section method in jit-recording.c. */
+
+void
+gcc_jit_lvalue_set_link_section (gcc_jit_lvalue *lvalue,
+ const char *section_name)
+{
+ RETURN_IF_FAIL (section_name, NULL, NULL, "NULL section_name");
+ lvalue->set_link_section (section_name);
+}
+
+/* Public entrypoint. See description in libgccjit.h.
+
+ After error-checking, the real work is done by the
gcc::jit::recording::function::new_local method in jit-recording.c. */
gcc_jit_lvalue *
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 5aa2e40..024c8d7 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -1110,6 +1110,20 @@ extern void
gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,
enum gcc_jit_tls_model model);
+#define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section
+
+/* Set the link section of a global variable; analogous to:
+ __attribute__((section(".section_name")))
+ in C.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_18; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section
+*/
+extern void
+gcc_jit_lvalue_set_link_section (gcc_jit_lvalue *lvalue,
+ const char *section_name);
+
extern gcc_jit_lvalue *
gcc_jit_function_new_local (gcc_jit_function *func,
gcc_jit_location *loc,
diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map
index 98d693f..b176711 100644
--- a/gcc/jit/libgccjit.map
+++ b/gcc/jit/libgccjit.map
@@ -231,3 +231,8 @@ LIBGCCJIT_ABI_17 {
global:
gcc_jit_lvalue_set_tls_model;
} LIBGCCJIT_ABI_16;
+
+LIBGCCJIT_ABI_18 {
+ global:
+ gcc_jit_lvalue_set_link_section;
+} LIBGCCJIT_ABI_17;