aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2007-02-10 11:19:10 -0800
committerAlexandre Oliva <aoliva@gcc.gnu.org>2007-02-10 19:19:10 +0000
commit8893239dc4ed32bd3bb4e00d6e43b859554ab82a (patch)
tree19408e7a99094abe8a3e2baccde7b48302195b0a /gcc/expr.c
parentba9652fcb40c232e43a5d2e96843847932e3784b (diff)
downloadgcc-8893239dc4ed32bd3bb4e00d6e43b859554ab82a.zip
gcc-8893239dc4ed32bd3bb4e00d6e43b859554ab82a.tar.gz
gcc-8893239dc4ed32bd3bb4e00d6e43b859554ab82a.tar.bz2
Makefile.in (libgcc-support, [...]): Add emutls.c.
gcc/ChangeLog: * Makefile.in (libgcc-support, libgcc.mvars): Add emutls.c. * builtin-types.def (BT_WORD): Make unsigned. (BT_FN_VOID_PTR_WORD_WORD_PTR): New. * builtins.def (BUILT_IN_EMUTLS_GET_ADDRESS): New. (BUILT_IN_EMUTLS_REGISTER_COMMON): New. * c-decl.c (grokdeclarator): Don't error if !have_tls. * c-parser.c (c_parser_omp_threadprivate): Likewise. * dwarf2out.c (loc_descriptor_from_tree_1): Don't do anything for emulated tls. * expr.c (emutls_var_address): New. (expand_expr_real_1): Expand emulated tls. (expand_expr_addr_expr_1): Likewise. * libgcc-std.ver: Add __emutls_get_address, __emutls_register_common. * output.h (emutls_finish): Declare. * toplev.c (compile_file): Call it. * tree-ssa-address.c (gen_addr_rtx): Check for const-ness of the address before wrapping in CONST. * varasm.c (emutls_htab, emutls_object_type): New. (EMUTLS_VAR_PREFIX, EMUTLS_TMPL_PREFIX): New. (get_emutls_object_name, get_emutls_object_type): New. (get_emutls_init_templ_addr, emutls_decl): New. (emutls_common_1, emutls_finish): New. (assemble_variable): When emulating tls, swap decls; generate constructor for the emutls objects. (do_assemble_alias): When emulating tls, swap decl and target name. (default_encode_section_info): Don't add SYMBOL_FLAG_TLS_SHIFT for emulated tls. * varpool.c (decide_is_variable_needed): Look at force_output. Recurse for emulated tls. (cgraph_varpool_remove_unreferenced_decls): Remove checks redundant with decide_is_variable_needed. * emutls.c: New file. * config/sparc/sol2.h (ASM_DECLARE_OBJECT_NAME): Only emit tls_object for real tls. gcc/cp/ChangeLog: * decl.c (grokvardecl): Don't error if !have_tls. (grokdeclarator): Likewise. * parser.c (cp_parser_omp_threadprivate): Likewise. gcc/fortran/ChangeLog: * f95-lang.c (gfc_init_builtin_functions): Add __emutls_get_address and __emutls_register_common. * openmp.c (gfc_match_omp_threadprivate): Don't error if !have_tls. * trans-common.c (build_common_decl): Don't check have_tls. * trans-decl.c (gfc_finish_var_decl): Likewise. * types.def (BT_WORD, BT_FN_PTR_PTR): New. (BT_FN_VOID_PTR_WORD_WORD_PTR): New. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_tls): Redefine to mean non-emulated tls. * gcc.dg/tls/alias-1.c: Remove tls requirement. * gcc.dg/tls/asm-1.c, gcc.dg/tls/debug-1.c, gcc.dg/tls/diag-1.c, gcc.dg/tls/diag-2.c, gcc.dg/tls/diag-3.c, gcc.dg/tls/diag-4.c, gcc.dg/tls/diag-5.c, gcc.dg/tls/init-1.c, gcc.dg/tls/nonpic-1.c, gcc.dg/tls/opt-10.c, gcc.dg/tls/opt-5.c, gcc.dg/tls/opt-6.c, gcc.dg/tls/opt-8.c, gcc.dg/tls/opt-9.c, gcc.dg/tls/pic-1.c, gcc.dg/tls/struct-1.c, gcc.dg/tls/trivial.c: Likewise. From-SVN: r121800
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index a04e931..09a6789 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6421,6 +6421,19 @@ highest_pow2_factor_for_target (tree target, tree exp)
return MAX (factor, target_align);
}
+/* Return &VAR expression for emulated thread local VAR. */
+
+static tree
+emutls_var_address (tree var)
+{
+ tree emuvar = emutls_decl (var);
+ tree fn = built_in_decls [BUILT_IN_EMUTLS_GET_ADDRESS];
+ tree arg = build_fold_addr_expr_with_type (emuvar, ptr_type_node);
+ tree arglist = build_tree_list (NULL_TREE, arg);
+ tree call = build_function_call_expr (fn, arglist);
+ return fold_convert (build_pointer_type (TREE_TYPE (var)), call);
+}
+
/* Expands variable VAR. */
void
@@ -6549,6 +6562,18 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enum machine_mode tmode,
inner = TREE_OPERAND (exp, 0);
break;
+ case VAR_DECL:
+ /* TLS emulation hook - replace __thread VAR's &VAR with
+ __emutls_get_address (&_emutls.VAR). */
+ if (! targetm.have_tls
+ && TREE_CODE (exp) == VAR_DECL
+ && DECL_THREAD_LOCAL_P (exp))
+ {
+ exp = emutls_var_address (exp);
+ return expand_expr (exp, target, tmode, modifier);
+ }
+ /* Fall through. */
+
default:
/* If the object is a DECL, then expand it for its rtl. Don't bypass
expand_expr, as that can have various side effects; LABEL_DECLs for
@@ -6924,6 +6949,16 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
&& (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
layout_decl (exp, 0);
+ /* TLS emulation hook - replace __thread vars with
+ *__emutls_get_address (&_emutls.var). */
+ if (! targetm.have_tls
+ && TREE_CODE (exp) == VAR_DECL
+ && DECL_THREAD_LOCAL_P (exp))
+ {
+ exp = build_fold_indirect_ref (emutls_var_address (exp));
+ return expand_expr_real_1 (exp, target, tmode, modifier, NULL);
+ }
+
/* ... fall through ... */
case FUNCTION_DECL: