diff options
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. |