GCC Middle and Back End API Reference
vec.h File Reference

Go to the source code of this file.

Data Structures

struct  vec_prefix
struct  vl_embed
struct  vl_ptr
struct  va_heap
struct  va_gc
struct  va_gc_atomic
struct  va_stack
struct  vec< T, A, L >
struct  vnull
struct  vec< T, A, vl_embed >
struct  vec< T, A, vl_ptr >
struct  vec< T, va_gc, vl_ptr >

Functions

void ggc_free (void *)
size_t ggc_round_alloc_size (size_t requested_size)
void * ggc_realloc_stat (void *, size_t MEM_STAT_DECL)
void dump_vec_loc_statistics (void)
void register_stack_vec (void *)
int stack_vec_register_index (void *)
void unregister_stack_vec (unsigned)
template<typename T , typename A >
bool vec_safe_space ()
template<typename T , typename A >
unsigned vec_safe_length ()
template<typename T , typename A >
Tvec_safe_address ()
template<typename T , typename A >
bool vec_safe_is_empty ()
template<typename T , typename A >
bool vec_safe_reserve (vec< T, A, vl_embed > *&v, unsigned nelems, bool exact=false CXX_MEM_STAT_INFO)
template<typename T , typename A >
bool vec_safe_reserve_exact (vec< T, A, vl_embed > *&v, unsigned nelems CXX_MEM_STAT_INFO)
template<typename T , typename A >
void vec_alloc ()
template<typename T , typename A >
void vec_free ()
template<typename T , typename A >
void vec_safe_grow ()
template<typename T , typename A >
void vec_safe_grow_cleared ()
template<typename T , typename A >
bool vec_safe_iterate ()
template<typename T , typename A >
Tvec_safe_push ()
template<typename T , typename A >
void vec_safe_insert (vec< T, A, vl_embed > *&v, unsigned ix, const T &obj CXX_MEM_STAT_INFO)
template<typename T , typename A >
void vec_safe_truncate ()
template<typename T , typename A >
vec< T, A, vl_embed > * vec_safe_copy ()
template<typename T , typename A >
void vec_safe_splice (vec< T, A, vl_embed > *&dst, vec< T, A, vl_embed > *src CXX_MEM_STAT_INFO)
template<typename T >
void gt_ggc_mx ()
template<typename T , typename A >
void gt_pch_nx ()
template<typename T >
void vec_alloc ()
template<typename T >
void vec_check_alloc ()
template<typename T >
void vec_free ()

Variables

vnull vNULL

Function Documentation

void dump_vec_loc_statistics ( void  )
Templated vector type and associated interfaces.

   The interface functions are typesafe and use inline functions,
   sometimes backed by out-of-line generic functions.  The vectors are
   designed to interoperate with the GTY machinery.

   There are both 'index' and 'iterate' accessors.  The index accessor
   is implemented by operator[].  The iterator returns a boolean
   iteration condition and updates the iteration variable passed by
   reference.  Because the iterator will be inlined, the address-of
   can be optimized away.

   Each operation that increases the number of active elements is
   available in 'quick' and 'safe' variants.  The former presumes that
   there is sufficient allocated space for the operation to succeed
   (it dies if there is not).  The latter will reallocate the
   vector, if needed.  Reallocation causes an exponential increase in
   vector size.  If you know you will be adding N elements, it would
   be more efficient to use the reserve operation before adding the
   elements with the 'quick' operation.  This will ensure there are at
   least as many elements as you ask for, it will exponentially
   increase if there are too few spare slots.  If you want reserve a
   specific number of slots, but do not want the exponential increase
   (for instance, you know this is the last allocation), use the
   reserve_exact operation.  You can also create a vector of a
   specific size from the get go.

   You should prefer the push and pop operations, as they append and
   remove from the end of the vector. If you need to remove several
   items in one go, use the truncate operation.  The insert and remove
   operations allow you to change elements in the middle of the
   vector.  There are two remove operations, one which preserves the
   element ordering 'ordered_remove', and one which does not
   'unordered_remove'.  The latter function copies the end element
   into the removed slot, rather than invoke a memmove operation.  The
   'lower_bound' function will determine where to place an item in the
   array using insert that will maintain sorted order.

   Vectors are template types with three arguments: the type of the
   elements in the vector, the allocation strategy, and the physical
   layout to use

   Four allocation strategies are supported:

        - Heap: allocation is done using malloc/free.  This is the
          default allocation strategy.

        - Stack: allocation is done using alloca.

        - GC: allocation is done using ggc_alloc/ggc_free.

        - GC atomic: same as GC with the exception that the elements
          themselves are assumed to be of an atomic type that does
          not need to be garbage collected.  This means that marking
          routines do not need to traverse the array marking the
          individual elements.  This increases the performance of
          GC activities.

   Two physical layouts are supported:

        - Embedded: The vector is structured using the trailing array
          idiom.  The last member of the structure is an array of size
          1.  When the vector is initially allocated, a single memory
          block is created to hold the vector's control data and the
          array of elements.  These vectors cannot grow without
          reallocation (see discussion on embeddable vectors below).

        - Space efficient: The vector is structured as a pointer to an
          embedded vector.  This is the default layout.  It means that
          vectors occupy a single word of storage before initial
          allocation.  Vectors are allowed to grow (the internal
          pointer is reallocated but the main vector instance does not
          need to relocate).

   The type, allocation and layout are specified when the vector is
   declared.

   If you need to directly manipulate a vector, then the 'address'
   accessor will return the address of the start of the vector.  Also
   the 'space' predicate will tell you whether there is spare capacity
   in the vector.  You will not normally need to use these two functions.

   Notes on the different layout strategies

   * Embeddable vectors (vec<T, A, vl_embed>)
   
     These vectors are suitable to be embedded in other data
     structures so that they can be pre-allocated in a contiguous
     memory block.

     Embeddable vectors are implemented using the trailing array
     idiom, thus they are not resizeable without changing the address
     of the vector object itself.  This means you cannot have
     variables or fields of embeddable vector type -- always use a
     pointer to a vector.  The one exception is the final field of a
     structure, which could be a vector type.

     You will have to use the embedded_size & embedded_init calls to
     create such objects, and they will not be resizeable (so the
     'safe' allocation variants are not available).

     Properties of embeddable vectors:

          - The whole vector and control data are allocated in a single
            contiguous block.  It uses the trailing-vector idiom, so
            allocation must reserve enough space for all the elements
            in the vector plus its control data.
          - The vector cannot be re-allocated.
          - The vector cannot grow nor shrink.
          - No indirections needed for access/manipulation.
          - It requires 2 words of storage (prior to vector allocation).


   * Space efficient vector (vec<T, A, vl_ptr>)

     These vectors can grow dynamically and are allocated together
     with their control data.  They are suited to be included in data
     structures.  Prior to initial allocation, they only take a single
     word of storage.

     These vectors are implemented as a pointer to embeddable vectors.
     The semantics allow for this pointer to be NULL to represent
     empty vectors.  This way, empty vectors occupy minimal space in
     the structure containing them.

     Properties:

        - The whole vector and control data are allocated in a single
          contiguous block.
        - The whole vector may be re-allocated.
        - Vector data may grow and shrink.
        - Access and manipulation requires a pointer test and
          indirection.
        - It requires 1 word of storage (prior to vector allocation).

   An example of their use would be,

   struct my_struct {
     // A space-efficient vector of tree pointers in GC memory.
     vec<tree, va_gc, vl_ptr> v;
   };

   struct my_struct *s;

   if (s->v.length ()) { we have some contents }
   s->v.safe_push (decl); // append some decl onto the end
   for (ix = 0; s->v.iterate (ix, &elt); ix++)
     { do something with elt }
Support function for statistics.   
Dump per-site memory statistics.   

References add_statistics(), vec_descriptor::allocated, cmp_statistic(), vec_descriptor::file, vec_descriptor::function, vec_descriptor::line, vec_descriptor::peak, strstr(), vec_descriptor::times, times(), and vec_desc_hash.

Referenced by dump_memory_report().

void ggc_free ( void *  )
void* ggc_realloc_stat ( void *  ,
size_t  MEM_STAT_DECL 
)
size_t ggc_round_alloc_size ( size_t  requested_size)
template<typename T >
void gt_ggc_mx ( )
Garbage collection support for vec<T, A, vl_embed>.   

References gt_ggc_mx(), and T.

template<typename T , typename A >
void gt_pch_nx ( )
PCH support for vec<T, A, vl_embed>.   

References gt_pch_nx(), vec< T, A, vl_embed >::length(), and T.

void register_stack_vec ( void *  )
Helper functions to keep track of vectors allocated on the stack.   
int stack_vec_register_index ( void *  )
void unregister_stack_vec ( unsigned  )
template<typename T >
void vec_alloc ( )
inline
Allocate heap memory for pointer V and create the internal vector
   with space for NELEMS elements.  If NELEMS is 0, the internal
   vector is initialized to empty.   
template<typename T >
void vec_check_alloc ( )
inline
Conditionally allocate heap memory for VEC and its internal vector.   

References vec_alloc().

Referenced by add_comma_separated_to_vector().

template<typename T >
void vec_free ( )
inline
Free the heap memory allocated by vector V and set it to NULL.   
template<typename T , typename A >
T* vec_safe_address ( )
inline
If V is NULL, return NULL.  Otherwise, return V->address().   

References vec< T, A, vl_embed >::address().

Referenced by build_call_expr_loc_vec(), and ipa_record_reference().

template<typename T , typename A >
void vec_safe_grow ( )
inline
Grow V to length LEN.  Allocate it, if necessary.   

References len, vec< T, A, vl_embed >::quick_grow(), vec_safe_length(), and vec_safe_reserve_exact().

Referenced by ipa_record_reference(), unpack_value_fields(), and vec_safe_grow_cleared().

template<typename T , typename A >
void vec_safe_insert ( vec< T, A, vl_embed > *&  v,
unsigned  ix,
const T &obj  CXX_MEM_STAT_INFO 
)
inline
if V has no room for one more element, reallocate it.  Then call
   V->quick_insert(IX, OBJ).   

References vec< T, A, vl_embed >::quick_insert(), and vec_safe_reserve().

Referenced by get_section_anchor().

template<typename T , typename A >
unsigned vec_safe_length ( )
inline
If V is NULL, return 0.  Otherwise, return V->length().   

References vec< T, A, vl_embed >::length().

Referenced by add_cfis_to_fde(), add_ehspec_entry(), add_ttypes_entry(), addr_for_mem_ref(), adjust_insn(), array_value_type(), asan_add_global(), build_abbrev_table(), build_call_expr_loc_vec(), build_call_vec(), build_nt_call_vec(), cfi_row_equal_p(), cgraph_materialize_all_clones(), change_cfi_row(), compare_constant(), copy_constant(), copy_debug_stmt(), coverage_obj_finish(), dequeue_and_dump(), dump_block_node(), dump_generic_node(), dw2_output_call_site_table(), dw2_size_of_call_site_table(), dwarf2out_alloc_current_fde(), estimate_node_size_and_time(), expand_omp_taskreg(), expand_parallel_call(), expand_used_vars(), find_base_value(), fix_reg_equiv_init(), fold(), gen_eh_landing_pad(), gen_eh_region(), get_reg_known_equiv_p(), get_reg_known_value(), get_section_anchor(), get_strinfo(), gimple_build_asm_vec(), gimple_set_bb(), gimplify_init_constructor(), grow_reg_equivs(), init_ssa_renamer(), inline_node_removal_hook(), inline_summary_alloc(), inline_write_summary(), ipa_check_create_edge_args(), ipa_edge_args_info_available_for_edge_p(), ipa_edge_duplication_hook(), ipa_edge_removal_hook(), ipa_get_agg_replacements_for_node(), ipa_get_cs_argument_count(), ipa_node_removal_hook(), ipa_record_reference(), ipa_ref_list_first_reference(), ipa_ref_list_nreferences(), ipa_remove_all_references(), ipa_set_node_agg_value_chain(), ipa_write_jump_function(), label_to_block_fn(), lto_input_ts_binfo_tree_pointers(), move_block_to_fn(), move_linkage_attr(), optimize_compound_literals_in_ctor(), output_eh_regions(), output_fde(), output_macinfo(), output_node_opt_summary(), output_one_function_exception_table(), output_ssa_names(), output_struct_function_base(), print_node(), release_dead_ssa_names(), remove_unused_locals(), retry_incomplete_types(), same_die_p(), set_reg_known_equiv_p(), set_reg_known_value(), set_strinfo(), simple_cst_equal(), sjlj_build_landing_pads(), sjlj_output_call_site_table(), sjlj_size_of_call_site_table(), split_bbs_on_noreturn_calls(), split_function(), sra_initialize(), sra_modify_constructor_assign(), store_constructor(), streamer_pack_tree_bitfields(), strinfo_shared(), strlen_enter_block(), strlen_leave_block(), symtab_resolve_alias(), temp_slots_at_level(), update_clone_info(), update_row_reg_save(), vec_safe_grow(), vec_safe_grow_cleared(), and vec_safe_splice().

template<typename T , typename A >
T* vec_safe_push ( )
inline
If V has no room for one more element, reallocate it.  Then call
   V->quick_push(OBJ).   

References vec< T, A, vl_embed >::quick_push(), and vec_safe_reserve().

Referenced by account_size_time(), add_call_site(), add_cfi(), add_cfis_to_fde(), add_condition(), add_const_value_attribute(), add_dwarf_attr(), add_ehspec_entry(), add_enumerator_pubname(), add_forwarder_blocks(), add_local_decl(), add_name_and_src_coords_attributes(), add_pubname_string(), add_pubtype(), add_ssa_edge(), add_ttypes_entry(), append_entry_to_tmpl_value_parm_die_table(), assemble_alias(), build_translation_unit_decl(), connect_dest(), connect_src(), context_independent_aggregate_values(), create_specialized_node(), defer_location(), discover_loop(), dwarf2out_alloc_current_fde(), dwarf2out_define(), dwarf2out_end_source_file(), dwarf2out_start_source_file(), dwarf2out_undef(), estimate_local_effects(), fixup_loop_arrays_after_move(), flow_loops_find(), force_nonfallthru_and_redirect(), free_stmt_list(), gen_eh_landing_pad(), gen_eh_region(), gen_struct_or_union_type_die(), get_odr_type(), gimplify_asm_expr(), go_decl(), go_type_decl(), init_eh_for_function(), inline_read_section(), input_node_opt_summary(), ipa_modify_call_arguments(), loc_descriptor(), make_ssa_name_fn(), mem_loc_descriptor(), mudflap_enqueue_decl(), new_alias_set(), output_macinfo(), place_block_symbol(), place_field(), place_new_loop(), push_decl_scope(), push_dw_line_info_entry(), push_sleb128(), push_uleb128(), redirect_edge_var_map_add(), release_phi_node(), release_ssa_name(), remap_decls(), resolve_one_addr(), schedule_generic_params_dies_gen(), sdbout_global_decl(), self_referential_size(), set_cur_line_info_table(), split_function(), string_cst_pool_decl(), unpack_ts_translation_unit_decl_value_fields(), update_fence_and_insn(), update_stmt_operands(), used_types_insert(), and vt_add_function_parameter().

template<typename T , typename A >
bool vec_safe_reserve ( vec< T, A, vl_embed > *&  v,
unsigned  nelems,
bool  exact = false CXX_MEM_STAT_INFO 
)
inline
If V does not have space for NELEMS elements, call
   V->reserve(NELEMS, EXACT).   

References va_stack::reserve(), and vec_safe_space().

Referenced by add_dwarf_attr(), grow_reg_equivs(), redirect_edge_var_map_add(), redirect_edge_var_map_dup(), vec_alloc(), vec_safe_insert(), vec_safe_push(), and vec_safe_reserve_exact().

template<typename T , typename A >
bool vec_safe_reserve_exact ( vec< T, A, vl_embed > *&  v,
unsigned nelems  CXX_MEM_STAT_INFO 
)
inline

References vec_safe_reserve().

Referenced by vec_safe_grow(), and vec_safe_splice().

template<typename T , typename A >
bool vec_safe_space ( )
inline
Convenience wrapper functions to use when dealing with pointers to
   embedded vectors.  Some functionality for these vectors must be
   provided via free functions for these reasons:

        1- The pointer may be NULL (e.g., before initial allocation).

        2- When the vector needs to grow, it must be reallocated, so
           the pointer will change its value.

   Because of limitations with the current GC machinery, all vectors
   in GC memory *must* be pointers.   
If V contains no room for NELEMS elements, return false. Otherwise,
   return true.   

References vec< T, A, vl_embed >::space().

Referenced by vec_safe_reserve().

template<typename T , typename A >
void vec_safe_splice ( vec< T, A, vl_embed > *&  dst,
vec< T, A, vl_embed > *src  CXX_MEM_STAT_INFO 
)
inline
Copy the elements from SRC to the end of DST as if by memcpy.
   Reallocate DST, if necessary.   

References vec< T, A, vl_embed >::splice(), vec_safe_length(), and vec_safe_reserve_exact().

template<typename T , typename A >
void vec_safe_truncate ( )
inline
If V is NULL, do nothing.  Otherwise, call V->truncate(SIZE).   

References vec< T, A, vl_embed >::truncate().

Referenced by clear_edges(), and expand_omp_taskreg().


Variable Documentation

vnull vNULL
@verbatim Vector API for GNU compiler.

Copyright (C) 2004-2013 Free Software Foundation, Inc. Contributed by Nathan Sidwell natha.nosp@m.n@co.nosp@m.desou.nosp@m.rcer.nosp@m.y.com Re-implemented in C++ by Diego Novillo dnovi.nosp@m.llo@.nosp@m.googl.nosp@m.e.co.nosp@m.m

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/.

This file is compiled twice: once for the generator programs
   once for the compiler.   
vNULL is an empty type with a template cast operation that returns
   a zero-initialized vec<T, A, L> instance.  Use this when you want
   to assign nil values to new vec instances or pass a nil vector as
   a function call argument.

   We use this technique because vec<T, A, L> must be PODs (they are
   stored in unions and passed in vararg functions), this means that
   they cannot have ctors/dtors.   

Referenced by agg_replacements_to_vector(), assign_parms_augmented_arg_list(), classify_partition(), clone_inlined_nodes(), collect_callers_of_node(), compute_avail(), compute_data_dependences_for_bb(), cond_if_else_store_replacement(), cond_move_process_if_block(), vec< T, A, vl_ptr >::copy(), copy_plats_to_inter(), create_reference_ops_from_call(), create_variable_info_for(), create_variable_info_for_1(), decide_whether_version_node(), determine_loop_nest_reuse(), df_worklist_dataflow_doublequeue(), DFS(), discover_iteration_bound_by_body_walk(), do_estimate_edge_hints(), do_estimate_edge_size(), do_partial_partial_insertion(), do_regular_insertion(), do_structure_copy(), dot_scop(), dr_analyze_indices(), eliminate_indirect_cycles(), emit_case_bit_tests(), estimate_function_body_sizes(), estimate_ipcp_clone_size_and_time(), evaluate_properties_for_edge(), execute_cse_sincos_1(), execute_late_warn_uninitialized(), expand_used_vars(), extract_and_process_scc_for_name(), find_aggregate_values_for_callers_subset(), find_def_preds(), find_func_aliases(), find_func_aliases_for_builtin_call(), find_func_aliases_for_call(), find_func_clobbers(), find_predicates(), find_rarely_executed_basic_blocks_and_crossing_edges(), find_removable_extensions(), find_split_points(), finish_tm_clone_pairs(), flow_loop_nodes_find(), gen_producer_string(), get_all_loop_exits(), get_constraint_for_1(), get_dominated_by(), get_dominated_by_region(), get_dominated_to_depth(), get_loop_exit_edges(), get_loop_exit_edges_unique_dests(), get_loop_hot_path(), get_loop_latch_edges(), get_odr_type(), get_tm_region_blocks(), graphds_domtree(), graphds_scc(), graphite_transform_loops(), gt_pch_save(), handle_common_deferred_options(), handle_const_call(), handle_lhs_call(), handle_rhs_call(), hoist_code(), init_reassoc(), inline_merge_summary(), inline_node_duplication_hook(), inline_read_section(), inline_small_functions(), inline_update_overall_summary(), input_cgraph_1(), input_cgraph_opt_section(), input_node(), ipa_get_nodes_in_cycle(), ipa_prop_read_section(), ipa_tm_create_version(), ipa_tm_transform_calls(), ipcp_discover_new_direct_edges(), ipcp_transform_function(), ira_loop_tree_body_rev_postorder(), ira_traverse_loop_tree(), lower_eh_dispatch(), lto_input_toplevel_asms(), lto_read_body(), lto_symtab_merge_decls_2(), make_constraint_to(), maybe_lower_iteration_bound(), maybe_optimize_range_tests(), maybe_unwind_expanded_macro_loc(), minimize_DFA(), normalize_preds(), phi_translate_1(), possible_polymorphic_call_targets(), process_ipa_clobber(), propagate_threaded_block_debug_into(), reachable_at_most_once(), read_replacements_section(), reassociate_bb(), recursive_inlining(), remove_edge_and_dominated_blocks(), self_referential_size(), sjlj_emit_dispatch_table(), split_function(), stmt_has_simple_data_refs_p(), thread_across_edge(), thread_prologue_and_epilogue_insns(), tm_region_init(), tree_call_cdce(), tree_loop_distribution(), tree_predictive_commoning_loop(), tree_transform_and_unroll_loop(), try_combine_chains(), try_unroll_loop_completely(), unschedule_insns_until(), update_call_from_tree(), update_dominators_in_loop(), valueize_shared_reference_ops_from_call(), valueize_shared_reference_ops_from_ref(), vect_analyze_slp(), vect_analyze_slp_instance(), vect_build_slp_tree(), vect_create_epilog_for_reduction(), vect_create_new_slp_node(), vect_create_vectorized_promotion_stmts(), vect_get_slp_defs(), vect_slp_analyze_data_ref_dependences(), vect_supported_load_permutation_p(), vect_transform_grouped_load(), vectorizable_assignment(), vectorizable_call(), vectorizable_condition(), vectorizable_conversion(), vectorizable_load(), vectorizable_operation(), vectorizable_reduction(), vectorizable_shift(), vectorizable_store(), verify_non_ssa_vars(), vn_phi_insert(), and vn_reference_lookup_3().