diff options
Diffstat (limited to 'gcc/cp/mangle.c')
-rw-r--r-- | gcc/cp/mangle.c | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index eee44a1bae2..f448932e6ea 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3684,23 +3684,70 @@ mangle_conv_op_name_for_type (const tree type) return identifier; } -/* Return an identifier for the name of an initialization guard - variable for indicated VARIABLE. */ +/* Write out the appropriate string for this variable when generating + another mangled name based on this one. */ -tree -mangle_guard_variable (const tree variable) +static void +write_guarded_var_name (const tree variable) { - start_mangling (variable); - write_string ("_ZGV"); if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0) /* The name of a guard variable for a reference temporary should refer to the reference, not the temporary. */ write_string (IDENTIFIER_POINTER (DECL_NAME (variable)) + 4); else write_name (variable, /*ignore_local_scope=*/0); +} + +/* Return an identifier for the name of an initialization guard + variable for indicated VARIABLE. */ + +tree +mangle_guard_variable (const tree variable) +{ + start_mangling (variable); + write_string ("_ZGV"); + write_guarded_var_name (variable); + return finish_mangling_get_identifier (/*warn=*/false); +} + +/* Return an identifier for the name of a thread_local initialization + function for VARIABLE. */ + +tree +mangle_tls_init_fn (const tree variable) +{ + start_mangling (variable); + write_string ("_ZTH"); + write_guarded_var_name (variable); + return finish_mangling_get_identifier (/*warn=*/false); +} + +/* Return an identifier for the name of a thread_local wrapper + function for VARIABLE. */ + +#define TLS_WRAPPER_PREFIX "_ZTW" + +tree +mangle_tls_wrapper_fn (const tree variable) +{ + start_mangling (variable); + write_string (TLS_WRAPPER_PREFIX); + write_guarded_var_name (variable); return finish_mangling_get_identifier (/*warn=*/false); } +/* Return true iff FN is a thread_local wrapper function. */ + +bool +decl_tls_wrapper_p (const tree fn) +{ + if (TREE_CODE (fn) != FUNCTION_DECL) + return false; + tree name = DECL_NAME (fn); + return strncmp (IDENTIFIER_POINTER (name), TLS_WRAPPER_PREFIX, + strlen (TLS_WRAPPER_PREFIX)) == 0; +} + /* Return an identifier for the name of a temporary variable used to initialize a static reference. This isn't part of the ABI, but we might as well call them something readable. */ |