+enum tls_model
+decl_tls_model (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;
+}
+
+enum symbol_visibility
+decl_visibility (tree decl)
+{
+ tree attr = lookup_attribute ("visibility", DECL_ATTRIBUTES (decl));
+
+ if (attr)
+ {
+ const char *which = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)));
+
+ if (strcmp (which, "default") == 0)
+ return VISIBILITY_DEFAULT;
+ if (strcmp (which, "internal") == 0)
+ return VISIBILITY_INTERNAL;
+ if (strcmp (which, "hidden") == 0)
+ return VISIBILITY_HIDDEN;
+ if (strcmp (which, "protected") == 0)
+ return VISIBILITY_PROTECTED;
+
+ abort ();
+ }
+
+ return VISIBILITY_DEFAULT;
+}
+