diff options
author | Richard Henderson <rth@redhat.com> | 2002-05-21 18:11:29 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2002-05-21 18:11:29 -0700 |
commit | 3d78f2e96e29feaff7046c22fdc97aa58bee9688 (patch) | |
tree | 1d3e8e4b6c824cf31a86c19bd79a5a7767a5a468 /gcc/varasm.c | |
parent | f5eb2fc83e49d200496a62d29b3236c6cfd76a91 (diff) | |
download | gcc-3d78f2e96e29feaff7046c22fdc97aa58bee9688.zip gcc-3d78f2e96e29feaff7046c22fdc97aa58bee9688.tar.gz gcc-3d78f2e96e29feaff7046c22fdc97aa58bee9688.tar.bz2 |
c-common.h (enum rid): Add RID_THREAD.
* c-common.h (enum rid): Add RID_THREAD.
* c-decl.c (start_decl): Do not set DECL_COMMON for tls variables.
(grokdeclarator): Grok __thread.
* c-parse.in (reswords): Add __thread.
(rid_to_yy): Add RID_THREAD.
* cp/lex.c (rid_to_yy): Add RID_THREAD.
* tree.h (DECL_THREAD_LOCAL): New.
(struct tree_decl): Add thread_local_flag.
* print-tree.c (print_node): Dump DECL_THREAD_LOCAL.
* tree.c (staticp): TLS variables are not static.
* target-def.h (TARGET_HAVE_TLS): New.
* target.h (have_tls): New.
* output.h (SECTION_TLS): New.
* varasm.c (assemble_variable): TLS variables can't be common for now.
(default_section_type_flags): Handle .tdata and .tbss.
(default_elf_asm_named_section): Handle SECTION_TLS.
(categorize_decl_for_section): Handle DECL_THREAD_LOCAL.
* flags.h (flag_tls_default): Declare.
* toplev.c (flag_tls_default): Define.
(display_help): Display help for it.
(decode_f_option): Set it.
* doc/extend.texi (Thread-Local): New node describing language-level
thread-local storage.
* doc/invoke.texi (-ftls-model): Document.
* fixinc/inclhack.def (thread_keyword): New.
* fixinc/fixincl.x: Rebuild.
From-SVN: r53715
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 47e652e..3165b92 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1586,19 +1586,28 @@ assemble_variable (decl, top_level, at_end, dont_output_data) /* Handle uninitialized definitions. */ - if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node -#if defined ASM_EMIT_BSS - || (flag_zero_initialized_in_bss - && initializer_zerop (DECL_INITIAL (decl))) -#endif - ) - /* If the target can't output uninitialized but not common global data - in .bss, then we have to use .data. */ -#if ! defined ASM_EMIT_BSS - && DECL_COMMON (decl) + /* If the decl has been given an explicit section name, then it + isn't common, and shouldn't be handled as such. */ + if (DECL_SECTION_NAME (decl) || dont_output_data) + ; + /* We don't implement common thread-local data at present. */ + else if (DECL_THREAD_LOCAL (decl)) + { + if (DECL_COMMON (decl)) + sorry ("thread-local COMMON data not implemented"); + } +#ifndef ASM_EMIT_BSS + /* If the target can't output uninitialized but not common global data + in .bss, then we have to use .data. */ + /* ??? We should handle .bss via select_section mechanisms rather than + via special target hooks. That would eliminate this special case. */ + else if (!DECL_COMMON (decl)) + ; #endif - && DECL_SECTION_NAME (decl) == NULL_TREE - && ! dont_output_data) + else if (DECL_INITIAL (decl) == 0 + || DECL_INITIAL (decl) == error_mark_node + || (flag_zero_initialized_in_bss + && initializer_zerop (DECL_INITIAL (decl)))) { unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1); unsigned HOST_WIDE_INT rounded = size; @@ -5101,9 +5110,14 @@ default_section_type_flags (decl, name, reloc) || strncmp (name, ".gnu.linkonce.b.", 16) == 0 || strcmp (name, ".sbss") == 0 || strncmp (name, ".sbss.", 6) == 0 - || strncmp (name, ".gnu.linkonce.sb.", 17) == 0) + || strncmp (name, ".gnu.linkonce.sb.", 17) == 0 + || strcmp (name, ".tbss") == 0) flags |= SECTION_BSS; + if (strcmp (name, ".tdata") == 0 + || strcmp (name, ".tbss") == 0) + flags |= SECTION_TLS; + return flags; } @@ -5146,6 +5160,8 @@ default_elf_asm_named_section (name, flags) *f++ = 'M'; if (flags & SECTION_STRINGS) *f++ = 'S'; + if (flags & SECTION_TLS) + *f++ = 'T'; *f = '\0'; if (flags & SECTION_BSS) @@ -5353,8 +5369,17 @@ categorize_decl_for_section (decl, reloc) else ret = SECCAT_RODATA; + /* There are no read-only thread-local sections. */ + if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl)) + { + if (ret == SECCAT_BSS) + ret = SECCAT_TBSS; + else + ret = SECCAT_TDATA; + } + /* If the target uses small data sections, select it. */ - if ((*targetm.in_small_data_p) (decl)) + else if ((*targetm.in_small_data_p) (decl)) { if (ret == SECCAT_BSS) ret = SECCAT_SBSS; |