GCC Middle and Back End API Reference
|
Data Structures | |
struct | lower_emutls_data |
Functions | |
static tree | prefix_name () |
static tree | get_emutls_object_name () |
tree | default_emutls_var_fields () |
tree | default_emutls_var_init () |
static tree | get_emutls_object_type () |
static tree | get_emutls_init_templ_addr () |
static tree | new_emutls_decl () |
static unsigned int | emutls_index () |
static tree | emutls_decl () |
static void | emutls_common_1 () |
static tree | gen_emutls_addr () |
static tree | lower_emutls_1 () |
static void | lower_emutls_stmt () |
static void | lower_emutls_phi_arg () |
static void | clear_access_vars () |
static void | lower_emutls_function_body () |
static bool | create_emultls_var () |
static unsigned int | ipa_lower_emutls () |
static bool | gate_emutls () |
simple_ipa_opt_pass * | make_pass_ipa_lower_emutls () |
Variables | |
static varpool_node_set | tls_vars |
static vec< varpool_node_ptr > | control_vars |
static vec< tree > | access_vars |
static tree | emutls_object_type |
|
inlinestatic |
Clear the ACCESS_VARS array, in order to begin a new block.
References memset().
Referenced by lower_emutls_function_body().
|
static |
Create emutls variable for VAR, DATA is pointer to static ctor body we can add constructors to. Callback for varpool_for_variable_and_aliases.
References symtab_node_base::alias, symtab_node_base::analyzed, symtab_node_base::decl, emutls_common_1(), new_emutls_decl(), varpool_node::symbol, varpool_alias_target(), and varpool_get_node().
Referenced by ipa_lower_emutls().
tree default_emutls_var_fields | ( | ) |
Create the fields of the type for the control variables. Ordinarily this must match struct __emutls_object defined in emutls.c. However this is a target hook so that VxWorks can define its own layout.
References get_identifier(), type(), lang_hooks_for_types::type_for_mode, lang_hooks::types, and word_mode.
tree default_emutls_var_init | ( | ) |
Initialize emulated tls object TO, which refers to TLS variable DECL and is initialized by PROXY. As above, this is the default implementation of a target hook overridden by VxWorks.
References build_constructor(), build_int_cst(), constructor_elt_d::index, constructor_elt_d::value, and vec_alloc().
|
static |
Generate a call statement to initialize CONTROL_DECL for TLS_DECL. This only needs to happen for TLS COMMON variables; non-COMMON variables can be initialized statically. Insert the generated call statement at the end of PSTMTS.
References append_to_statement_list(), build_call_expr(), build_int_cst(), builtin_decl_explicit(), get_emutls_init_templ_addr(), lang_hooks_for_types::type_for_mode, lang_hooks::types, and word_mode.
Referenced by create_emultls_var().
|
static |
Look up the control variable for the TLS variable DECL.
References symtab_node_base::decl, emutls_index(), and varpool_node::symbol.
Referenced by ipa_lower_emutls().
|
static |
Look up the index of the TLS variable DECL. This index can then be used in both the control_vars and access_vars arrays.
References varpool_node_set_iterator::index, varpool_get_node(), and varpool_node_set_find().
Referenced by emutls_decl(), and gen_emutls_addr().
|
static |
If the target supports TLS natively, we need do nothing here.
References targetm.
|
static |
Given a TLS variable DECL, return an SSA_NAME holding its address. Append any new computation statements required to D->SEQ.
References lower_emutls_data::bb, lower_emutls_data::bb_freq, build_pointer_type(), lower_emutls_data::builtin_decl, lower_emutls_data::builtin_node, lower_emutls_data::cfun_node, cgraph_create_edge(), basic_block_def::count, create_tmp_var(), symtab_node_base::decl, emutls_index(), gimple_build_call(), gimple_call_set_lhs(), gimple_seq_add_stmt(), gimple_set_location(), ipa_record_reference(), IPA_REF_ADDR, lower_emutls_data::loc, make_ssa_name(), lower_emutls_data::seq, and varpool_node::symbol.
Referenced by lower_emutls_1().
|
static |
Create a read-only variable like DECL, with the same DECL_INITIAL. This will be used for initializing the emulated tls data area.
References build_string(), make_decl_one_only(), prefix_name(), strlen(), targetm, varpool_add_new_variable(), and varpool_node_for_decl().
Referenced by emutls_common_1(), and new_emutls_decl().
|
static |
Create an identifier for the struct __emutls_object, given an identifier of the DECL_ASSEMBLY_NAME of the original object.
References prefix_name(), and targetm.
Referenced by ipa_lower_emutls(), and new_emutls_decl().
|
static |
Create the structure for struct __emutls_object. This should match the structure at the top of emutls.c, modulo the union there.
References emutls_object_type, get_identifier(), layout_type(), lang_hooks_for_types::make_type, targetm, type(), and lang_hooks::types.
Referenced by new_emutls_decl().
|
static |
Main entry point to the tls lowering pass.
References symtab_node_base::alias, alias_pairs, symtab_node_base::analyzed, cgraph_build_static_cdtor(), create_emultls_var(), symtab_node_base::decl, alias_pair::decl, symtab_node_base::definition, dump_file, emutls_decl(), free_varpool_node_set(), get_emutls_object_name(), lower_emutls_function_body(), cgraph_node::lowered, varpool_node_set_def::nodes, varpool_node::symbol, alias_pair::target, varpool_for_node_and_aliases(), varpool_node_set_add(), varpool_node_set_new(), and varpool_variable_node().
|
static |
Callback for walk_gimple_op. D = WI->INFO is a struct lower_emutls_data. Given an operand *PTR within D->STMT, if the operand references a TLS variable, then lower the reference to a call to the runtime. Insert any new statements required into D->SEQ; the caller is responsible for placing those appropriately.
References build_int_cst(), walk_stmt_info::changed, create_tmp_var(), gen_emutls_addr(), gimple_assign_set_lhs(), gimple_seq_add_stmt(), gimple_set_location(), walk_stmt_info::info, lower_emutls_data::loc, make_ssa_name(), lower_emutls_data::seq, and walk_stmt_info::val_only.
Referenced by lower_emutls_phi_arg(), and lower_emutls_stmt().
|
static |
Lower the entire function NODE.
References lower_emutls_data::bb, lower_emutls_data::bb_freq, lower_emutls_data::builtin_decl, builtin_decl_explicit(), lower_emutls_data::builtin_node, lower_emutls_data::cfun_node, cgraph_get_create_node(), clear_access_vars(), compute_call_stmt_bb_frequency(), current_function_decl, symtab_node_base::decl, gimple_seq_empty_p(), gsi_commit_edge_inserts(), gsi_end_p(), gsi_insert_seq_before(), gsi_insert_seq_on_edge(), gsi_next(), GSI_SAME_STMT, gsi_start_bb(), gsi_start_phis(), gsi_stmt(), lower_emutls_phi_arg(), lower_emutls_stmt(), phi_nodes(), pop_cfun(), basic_block_def::preds, push_cfun(), lower_emutls_data::seq, and cgraph_node::symbol.
Referenced by ipa_lower_emutls().
|
static |
Lower the I'th operand of PHI.
References walk_stmt_info::changed, phi_arg_d::def, gimple_phi_arg(), phi_arg_d::imm_use, walk_stmt_info::info, link_imm_use_stmt(), lower_emutls_data::loc, phi_arg_d::locus, lower_emutls_1(), memset(), and walk_stmt_info::val_only.
Referenced by lower_emutls_function_body().
|
static |
Lower all of the operands of STMT.
References walk_stmt_info::changed, gimple_location(), walk_stmt_info::info, lower_emutls_data::loc, lower_emutls_1(), memset(), update_stmt(), walk_stmt_info::val_only, and walk_gimple_op().
Referenced by lower_emutls_function_body().
simple_ipa_opt_pass* make_pass_ipa_lower_emutls | ( | ) |
|
static |
Create and return the control variable for the TLS variable DECL.
References build_string(), get_emutls_init_templ_addr(), get_emutls_object_name(), get_emutls_object_type(), make_decl_one_only(), record_references_in_initializer(), strlen(), targetm, TLS_MODEL_EMULATED, varpool_add_new_variable(), varpool_create_variable_alias(), varpool_node_for_asm(), and varpool_node_for_decl().
Referenced by create_emultls_var().
|
static |
Create an IDENTIFIER_NODE by prefixing PREFIX to the IDENTIFIER_NODE NAME's name.
References get_identifier(), memcpy(), and strlen().
Referenced by get_emutls_init_templ_addr(), and get_emutls_object_name().
For the current basic block, an SSA_NAME that has computed the address of the TLS variable at the corresponding index.
|
static |
|
static |
The type of the control structure, shared with the emutls.c runtime.
Referenced by get_emutls_object_type().
|
static |
@verbatim Lower TLS operations to emulation functions.
Copyright (C) 2006-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
Whenever a target does not support thread-local storage (TLS) natively, we can emulate it with some run-time support in libgcc. This will in turn rely on "keyed storage" a-la pthread_key_create; essentially all thread libraries provide such functionality. In order to coordinate with the libgcc runtime, each TLS variable is described by a "control variable". This control variable records the required size, alignment, and initial value of the TLS variable for instantiation at runtime. It also stores an integer token to be used by the runtime to find the address of the variable within each thread. On the compiler side, this means that we need to replace all instances of "tls_var" in the code with "*__emutls_get_addr(&control_var)". We also need to eliminate "tls_var" from the symbol table and introduce "control_var". We used to perform all of the transformations during conversion to rtl, and the variable substitutions magically within assemble_variable. However, this late fiddling of the symbol table conflicts with LTO and whole-program compilation. Therefore we must now make all the changes to the symbol table early in the GIMPLE optimization path, before we write things out to LTO intermediate files.
These two vectors, once fully populated, are kept in lock-step so that the index of a TLS variable equals the index of its control variable in the other vector.