diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-09-27 15:30:10 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-09-27 15:30:10 +0200 |
commit | dce81a1a59f9663eb72e722e17f490adc3f5a2d6 (patch) | |
tree | b7ac095e3e844e739365675e99f4e724059e2a38 /gcc/varasm.c | |
parent | 0e9e1e0a42eff5ec265470b7e8928cb3b3ad2d70 (diff) | |
download | gcc-dce81a1a59f9663eb72e722e17f490adc3f5a2d6.zip gcc-dce81a1a59f9663eb72e722e17f490adc3f5a2d6.tar.gz gcc-dce81a1a59f9663eb72e722e17f490adc3f5a2d6.tar.bz2 |
extend.texi (tls_model): Document.
* doc/extend.texi (tls_model): Document.
* varasm.c (decl_tls_model): New.
* c-common.c (handle_tls_model_attribute): New.
(c_common_attribute_table): Add tls_model.
* config/alpha/alpha.c (alpha_encode_section_info): Use
decl_tls_model.
* flags.h (enum tls_model, flag_tls_default): Move...
* tree.h (enum tls_model, flag_tls_default): ...here.
(decl_tls_model): New prototype.
* config/ia64/ia64.c (ia64_encode_section_info): Likewise.
* config/i386/i386.c (ix86_encode_section_info): Likewise.
* config/i386/i386.md (tls_global_dynamic, tls_local_dynamic_base):
Allow !flag_pic.
From-SVN: r57588
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 0ff605f..d24e914 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4726,6 +4726,52 @@ init_varasm_once () const_alias_set = new_alias_set (); } +enum tls_model +decl_tls_model (decl) + tree decl; +{ + enum tls_model kind; + tree attr = lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)); + bool is_local; + + if (attr) + { + attr = TREE_VALUE (TREE_VALUE (attr)); + if (TREE_CODE (attr) != STRING_CST) + abort (); + if (!strcmp (TREE_STRING_POINTER (attr), "local-exec")) + kind = TLS_MODEL_LOCAL_EXEC; + else if (!strcmp (TREE_STRING_POINTER (attr), "initial-exec")) + kind = TLS_MODEL_INITIAL_EXEC; + else if (!strcmp (TREE_STRING_POINTER (attr), "local-dynamic")) + kind = optimize ? TLS_MODEL_LOCAL_DYNAMIC : TLS_MODEL_GLOBAL_DYNAMIC; + else if (!strcmp (TREE_STRING_POINTER (attr), "global-dynamic")) + kind = TLS_MODEL_GLOBAL_DYNAMIC; + else + abort (); + return kind; + } + + is_local = (*targetm.binds_local_p) (decl); + if (!flag_pic) + { + if (is_local) + kind = TLS_MODEL_LOCAL_EXEC; + else + kind = TLS_MODEL_INITIAL_EXEC; + } + /* Local dynamic is inefficient when we're not combining the + parts of the address. */ + else if (optimize && is_local) + kind = TLS_MODEL_LOCAL_DYNAMIC; + else + kind = TLS_MODEL_GLOBAL_DYNAMIC; + if (kind < flag_tls_default) + kind = flag_tls_default; + + return kind; +} + /* Select a set of attributes for section NAME based on the properties of DECL and whether or not RELOC indicates that DECL's initializer might contain runtime relocations. |