GCC Middle and Back End API Reference
hwint.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
Include dependency graph for hwint.cc:

Functions

int floor_log2 (unsigned HOST_WIDE_INT x)
 
int ceil_log2 (unsigned HOST_WIDE_INT x)
 
int exact_log2 (unsigned HOST_WIDE_INT x)
 
int ctz_hwi (unsigned HOST_WIDE_INT x)
 
int clz_hwi (unsigned HOST_WIDE_INT x)
 
int ffs_hwi (unsigned HOST_WIDE_INT x)
 
int popcount_hwi (unsigned HOST_WIDE_INT x)
 
HOST_WIDE_INT gcd (HOST_WIDE_INT a, HOST_WIDE_INT b)
 
HOST_WIDE_INT pos_mul_hwi (HOST_WIDE_INT x, HOST_WIDE_INT y)
 
HOST_WIDE_INT mul_hwi (HOST_WIDE_INT x, HOST_WIDE_INT y)
 
HOST_WIDE_INT least_common_multiple (HOST_WIDE_INT a, HOST_WIDE_INT b)
 
unsigned HOST_WIDE_INT reflect_hwi (unsigned HOST_WIDE_INT value, unsigned bitwidth)
 

Function Documentation

◆ ceil_log2()

◆ clz_hwi()

int clz_hwi ( unsigned HOST_WIDE_INT x)

◆ ctz_hwi()

int ctz_hwi ( unsigned HOST_WIDE_INT x)

◆ exact_log2()

int exact_log2 ( unsigned HOST_WIDE_INT x)
Return the logarithm of X, base 2, considering X unsigned,
if X is a power of 2.  Otherwise, returns -1.   

References floor_log2(), and pow2p_hwi().

Referenced by tree_vector_builder::build(), calculate_table_based_CRC(), canonicalize_reload_addr(), carry_backpropagate(), check_func(), combine_simplify_rtx(), debug_set_to_format(), dump_generic_node(), encode_lfs(), wi::exact_log2(), expand_ifn_atomic_compare_exchange_into_call(), expand_omp_atomic(), expand_vec_perm_var(), ext_dce_process_sets(), final_addr_vec_align(), final_scan_insn_1(), find_split_point(), force_int_to_mode(), get_misalign_in_elems(), get_pos_from_mask(), get_required_cycles(), get_shiftadd_cost(), get_ubsan_type_info_for_type(), group_limit(), hwasan_check_func(), init_ggc(), int_loc_descriptor(), interpret_rhs_expr(), loc_list_from_tree_1(), low_bitmask_len(), make_compound_operation_int(), make_extraction(), noce_try_store_flag_constants(), report_error_func(), scan_store_can_perm_p(), SET_TYPE_VECTOR_SUBPARTS(), simd_clone_adjust(), simplify_and_const_int_1(), simplify_context::simplify_binary_operation_1(), simplify_comparison(), simplify_if_then_else(), simplify_shift_const_1(), synth_mult(), try_combine(), vect_create_epilog_for_reduction(), vect_gen_vector_loop_niters(), vect_gen_vector_loop_niters_mult_vf(), vect_grouped_load_supported(), vect_grouped_store_supported(), vect_lower_load_permutations(), vect_model_reduction_cost(), vect_need_peeling_or_partial_vectors_p(), vect_permute_load_chain(), vect_permute_store_chain(), vect_shift_permute_load_chain(), and vectorizable_simd_clone_call().

◆ ffs_hwi()

int ffs_hwi ( unsigned HOST_WIDE_INT x)
Similar to ctz_hwi, except that the least significant bit is numbered
starting from 1, and X == 0 yields 0.   

References floor_log2(), and least_bit_hwi().

Referenced by auto_flag< T >::auto_flag(), build_printable_array_type(), ctz_or_zero(), and layout_type().

◆ floor_log2()

int floor_log2 ( unsigned HOST_WIDE_INT x)
Operations on HOST_WIDE_INT.
   Copyright (C) 1987-2024 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/>.   
The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2, ceil_log2,
and exact_log2 are defined as inline functions in hwint.h
if GCC_VERSION >= 3004.
The definitions here are used for older versions of GCC and
non-GCC bootstrap compilers.   
Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
If X is 0, return -1.   

References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT_1U.

Referenced by asan_emit_stack_protection(), assemble_align(), assemble_start_function(), assemble_trampoline_template(), assemble_variable(), bp_pack_int_in_range(), bp_unpack_int_in_range(), carry_backpropagate(), ceil_log2(), clz_hwi(), constant_size(), ctz_hwi(), estimate_num_insns(), exact_log2(), expand_divmod(), expand_mult(), expand_sdiv_pow2(), expand_smod_pow2(), expand_vector_divmod(), expand_widening_mult(), extended_count(), ffs_hwi(), force_int_to_mode(), get_required_cycles(), get_vectype_for_scalar_type(), nonzero_bits1(), sreal::normalize_down(), sreal::normalize_up(), num_sign_bit_copies1(), optimize_constant_pool(), output_call_frame_info(), output_constant_def_contents(), output_fde(), profile_function(), read_log_maxskip(), real_to_decimal_for_mode(), setup_allocno_priorities(), simplify_rotate(), switch_to_eh_frame_section(), synth_mult(), try_store_by_multiple_pieces(), vect_build_slp_instance(), vectorizable_bb_reduc_epilogue(), and vectorizable_simd_clone_call().

◆ gcd()

HOST_WIDE_INT gcd ( HOST_WIDE_INT a,
HOST_WIDE_INT b )

◆ least_common_multiple()

◆ mul_hwi()

HOST_WIDE_INT mul_hwi ( HOST_WIDE_INT x,
HOST_WIDE_INT y )
Return X multiplied by Y and check that the result does not
overflow.   

References gcc_checking_assert, HOST_WIDE_INT_MIN, pos_mul_hwi(), and y.

Referenced by lambda_matrix_row_add(), and least_common_multiple().

◆ popcount_hwi()

int popcount_hwi ( unsigned HOST_WIDE_INT x)
Return the number of set bits in X.   

References CHAR_BIT, and i.

Referenced by get_nearest_type_subqualifiers(), condition_info::popcount(), double_int::popcount(), and wi::popcount().

◆ pos_mul_hwi()

HOST_WIDE_INT pos_mul_hwi ( HOST_WIDE_INT x,
HOST_WIDE_INT y )
For X and Y positive integers, return X multiplied by Y and check
that the result does not overflow.   

References gcc_checking_assert, HOST_WIDE_INT_MAX, and y.

Referenced by mul_hwi().

◆ reflect_hwi()

unsigned HOST_WIDE_INT reflect_hwi ( unsigned HOST_WIDE_INT value,
unsigned bitwidth )
Reflect (reverse) the bits of a given VALUE within a specified BITWIDTH.   

References i.