GCC Middle and Back End API Reference
tree-emutls.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "tree.h"
#include "gimple.h"
#include "tree-pass.h"
#include "ssa.h"
#include "cgraph.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "varasm.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
#include "langhooks.h"
#include "tree-iterator.h"
#include "gimplify.h"
#include "diagnostic-core.h"
Include dependency graph for tree-emutls.cc:

Data Structures

struct  tls_var_data
struct  lower_emutls_data


#define EMUTLS_SEPARATOR   "."


static tree prefix_name (const char *prefix, tree name)
static tree get_emutls_object_name (tree name)
tree default_emutls_var_fields (tree type, tree *name)
tree default_emutls_var_init (tree to, tree decl, tree proxy)
static tree get_emutls_object_type (void)
static tree get_emutls_init_templ_addr (tree decl)
static tree new_emutls_decl (tree decl, tree alias_of)
static void emutls_common_1 (tree tls_decl, tree control_decl, tree *pstmts)
static tree gen_emutls_addr (tree decl, struct lower_emutls_data *d, bool for_debug)
static tree lower_emutls_2 (tree *ptr, int *walk_subtrees, void *)
static tree lower_emutls_1 (tree *ptr, int *walk_subtrees, void *cb_data)
static void lower_emutls_stmt (gimple *stmt, struct lower_emutls_data *d)
static void lower_emutls_phi_arg (gphi *phi, unsigned int i, struct lower_emutls_data *d)
bool reset_access (varpool_node *const &, tls_var_data *data, void *)
static void clear_access_vars (void)
static void lower_emutls_function_body (struct cgraph_node *node)
static bool create_emultls_var (varpool_node *var, void *data)
static unsigned int ipa_lower_emutls (void)
simple_ipa_opt_passmake_pass_ipa_lower_emutls (gcc::context *ctxt)


static hash_map< varpool_node *, tls_var_data > * tls_map = NULL
static tree emutls_object_type

Macro Definition Documentation


#define EMUTLS_SEPARATOR   "."

Function Documentation

◆ clear_access_vars()

static void clear_access_vars ( void )
Clear the access variables, in order to begin a new block.   

References NULL, reset_access(), and tls_map.

Referenced by lower_emutls_function_body().

◆ create_emultls_var()

static bool create_emultls_var ( varpool_node * var,
void * data )
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::alias, symtab_node::analyzed, tls_var_data::control_var, symtab_node::decl, DECL_HAS_VALUE_EXPR_P, emutls_common_1(), varpool_node::get(), varpool_node::get_alias_target(), ggc_alloc(), new_emutls_decl(), NULL, SET_DECL_VALUE_EXPR, and tls_map.

Referenced by ipa_lower_emutls().

◆ default_emutls_var_fields()

tree default_emutls_var_fields ( tree type,
tree * name )
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 build_decl(), DECL_CHAIN, DECL_CONTEXT, get_identifier(), ggc_alloc(), ptr_type_node, type(), lang_hooks_for_types::type_for_mode, lang_hooks::types, UNKNOWN_LOCATION, and word_mode.

◆ default_emutls_var_init()

tree default_emutls_var_init ( tree to,
tree decl,
tree proxy )
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(), DECL_ALIGN_UNIT, DECL_CHAIN, DECL_SIZE_UNIT, fold_convert, ggc_alloc(), constructor_elt::index, null_pointer_node, TREE_TYPE, TYPE_FIELDS, constructor_elt::value, and vec_alloc().

◆ emutls_common_1()

static void emutls_common_1 ( tree tls_decl,
tree control_decl,
tree * pstmts )
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_fold_addr_expr, build_int_cst(), builtin_decl_explicit(), DECL_ALIGN_UNIT, DECL_COMMON, DECL_INITIAL, DECL_SIZE_UNIT, error_mark_node, fold_convert, get_emutls_init_templ_addr(), ggc_alloc(), targetm, lang_hooks_for_types::type_for_mode, lang_hooks::types, and word_mode.

Referenced by create_emultls_var().

◆ gen_emutls_addr()

◆ get_emutls_init_templ_addr()

◆ get_emutls_object_name()

static tree get_emutls_object_name ( tree name)
Create an identifier for the struct __emutls_object, given an identifier
of the DECL_ASSEMBLY_NAME of the original object.   

References EMUTLS_SEPARATOR, prefix_name(), and targetm.

Referenced by ipa_lower_emutls(), and new_emutls_decl().

◆ get_emutls_object_type()

static tree get_emutls_object_type ( void )
Create the structure for struct __emutls_object.  This should match the
structure at the top of emutls.c, modulo the union there.   

References build_decl(), emutls_object_type, get_identifier(), ggc_alloc(), layout_type(), lang_hooks_for_types::make_type, NULL, targetm, type(), TYPE_FIELDS, TYPE_NAME, lang_hooks::types, and UNKNOWN_LOCATION.

Referenced by new_emutls_decl().

◆ ipa_lower_emutls()

◆ lower_emutls_1()

static tree lower_emutls_1 ( tree * ptr,
int * walk_subtrees,
void * cb_data )
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 build2(), build_int_cst(), create_tmp_var, DECL_THREAD_LOCAL_P, error_mark_node, EXPR_P, gen_emutls_addr(), ggc_alloc(), gimple_assign_set_lhs(), gimple_build_assign(), gimple_debug_bind_reset_value(), gimple_seq_add_stmt(), gimple_set_location(), is_gimple_debug(), is_gimple_min_invariant(), lower_emutls_data::loc, lower_emutls_1(), lower_emutls_2(), make_ssa_name(), NULL, NULL_TREE, lower_emutls_data::seq, TREE_CODE, TREE_OPERAND, TREE_TYPE, unshare_expr(), update_stmt(), and walk_tree.

Referenced by lower_emutls_1(), lower_emutls_phi_arg(), and lower_emutls_stmt().

◆ lower_emutls_2()

static tree lower_emutls_2 ( tree * ptr,
int * walk_subtrees,
void *  )
Callback for lower_emutls_1, return non-NULL if there is any TLS
VAR_DECL in the subexpressions.   

References DECL_THREAD_LOCAL_P, EXPR_P, ggc_alloc(), NULL_TREE, and VAR_P.

Referenced by lower_emutls_1().

◆ lower_emutls_function_body()

◆ lower_emutls_phi_arg()

static void lower_emutls_phi_arg ( gphi * phi,
unsigned int i,
struct lower_emutls_data * d )

◆ lower_emutls_stmt()

static void lower_emutls_stmt ( gimple * stmt,
struct lower_emutls_data * d )

◆ make_pass_ipa_lower_emutls()

simple_ipa_opt_pass * make_pass_ipa_lower_emutls ( gcc::context * ctxt)
IPA Passes  

References ggc_alloc().

◆ new_emutls_decl()

◆ prefix_name()

static tree prefix_name ( const char * prefix,
tree name )
Create an IDENTIFIER_NODE by prefixing PREFIX to the

References alloca, get_identifier(), ggc_alloc(), and IDENTIFIER_POINTER.

Referenced by get_emutls_init_templ_addr(), and get_emutls_object_name().

◆ reset_access()

bool reset_access ( varpool_node *const & ,
tls_var_data * data,
void *  )
Reset access variable for a given TLS variable data DATA.   

References NULL.

Referenced by clear_access_vars().

Variable Documentation

◆ emutls_object_type

tree emutls_object_type
The type of the control structure, shared with the emutls.c runtime.   

Referenced by get_emutls_object_type().

◆ tls_map

hash_map<varpool_node *, tls_var_data>* tls_map = NULL
TLS map accesses mapping between a TLS varpool node and a pair
made by control variable and access variable.   

Referenced by clear_access_vars(), create_emultls_var(), gen_emutls_addr(), and ipa_lower_emutls().