GCC Middle and Back End API Reference
gimple-lower-bitint.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "ssa.h"
#include "fold-const.h"
#include "gimplify.h"
#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-dfa.h"
#include "cfgloop.h"
#include "cfganal.h"
#include "target.h"
#include "tree-ssa-live.h"
#include "tree-ssa-coalesce.h"
#include "domwalk.h"
#include "memmodel.h"
#include "optabs.h"
#include "varasm.h"
#include "gimple-range.h"
#include "value-range.h"
#include "langhooks.h"
#include "gimplify-me.h"
#include "diagnostic-core.h"
#include "tree-eh.h"
#include "tree-pretty-print.h"
#include "alloc-pool.h"
#include "tree-into-ssa.h"
#include "tree-cfgcleanup.h"
#include "tree-switch-conversion.h"
#include "ubsan.h"
#include "stor-layout.h"
#include "gimple-lower-bitint.h"
Include dependency graph for gimple-lower-bitint.cc:

Enumerations

enum  bitint_prec_kind { bitint_prec_small , bitint_prec_middle , bitint_prec_large , bitint_prec_huge }
 

Functions

static bitint_prec_kind bitint_precision_kind (int prec)
 
static bitint_prec_kind bitint_precision_kind (tree type)
 
static unsigned bitint_min_cst_precision (tree cst, int &ext)
 
void build_bitint_stmt_ssa_conflicts (gimple *stmt, live_track *live, ssa_conflicts *graph, bitmap names, void(*def)(live_track *, tree, ssa_conflicts *), void(*use)(live_track *, tree))
 
static bitint_prec_kind arith_overflow_arg_kind (gimple *stmt)
 
static unsigned int gimple_lower_bitint (void)
 
gimple_opt_passmake_pass_lower_bitint (gcc::context *ctxt)
 
gimple_opt_passmake_pass_lower_bitint_O0 (gcc::context *ctxt)
 

Variables

static int small_max_prec
 
static int mid_min_prec
 
static int large_min_prec
 
static int huge_min_prec
 
static int limb_prec
 

Enumeration Type Documentation

◆ bitint_prec_kind

Lower _BitInt(N) operations to scalar operations.
   Copyright (C) 2023-2024 Free Software Foundation, Inc.
   Contributed by Jakub Jelinek <jakub@redhat.com>.

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/>.   
Split BITINT_TYPE precisions in 4 categories.  Small _BitInt, where
target hook says it is a single limb, middle _BitInt which per ABI
does not, but there is some INTEGER_TYPE in which arithmetics can be
performed (operations on such _BitInt are lowered to casts to that
arithmetic type and cast back; e.g. on x86_64 limb is DImode, but
target supports TImode, so _BitInt(65) to _BitInt(128) are middle
ones), large _BitInt which should by straight line code and
finally huge _BitInt which should be handled by loops over the limbs.   
Enumerator
bitint_prec_small 
bitint_prec_middle 
bitint_prec_large 
bitint_prec_huge 

Function Documentation

◆ arith_overflow_arg_kind()

static bitint_prec_kind arith_overflow_arg_kind ( gimple * stmt)
static
If STMT is .{ADD,SUB,MUL}_OVERFLOW with INTEGER_CST arguments,
return the largest bitint_prec_kind of them, otherwise return
bitint_prec_small.   

References a, bitint_prec_small, bitint_precision_kind(), ggc_alloc(), gimple_call_arg(), gimple_call_internal_fn(), gimple_call_internal_p(), i, is_gimple_call(), MAX, TREE_CODE, and TREE_TYPE.

Referenced by gimple_lower_bitint().

◆ bitint_min_cst_precision()

static unsigned bitint_min_cst_precision ( tree cst,
int & ext )
static
Return minimum precision needed to describe INTEGER_CST
CST.  All bits above that precision up to precision of
TREE_TYPE (CST) are cleared if EXT is set to 0, or set
if EXT is set to -1.   

References ggc_alloc(), wi::min_precision(), SIGNED, wi::to_wide(), tree_int_cst_sgn(), TREE_TYPE, TYPE_SIGN, and TYPE_UNSIGNED.

Referenced by gimple_lower_bitint().

◆ bitint_precision_kind() [1/2]

◆ bitint_precision_kind() [2/2]

static bitint_prec_kind bitint_precision_kind ( tree type)
static
Same for a TYPE.   

References bitint_precision_kind(), and TYPE_PRECISION.

◆ build_bitint_stmt_ssa_conflicts()

void build_bitint_stmt_ssa_conflicts ( gimple * stmt,
live_track * live,
ssa_conflicts * graph,
bitmap names,
void(*)(live_track *, tree, ssa_conflicts *) def,
void(*)(live_track *, tree) use )
Replacement for normal processing of STMT in tree-ssa-coalesce.cc
build_ssa_conflict_graph.
The differences are:
1) don't process assignments with large/huge _BitInt lhs not in NAMES
2) for large/huge _BitInt multiplication/division/modulo process def
   only after processing uses rather than before to make uses conflict
   with the definition
3) for large/huge _BitInt uses not in NAMES mark the uses of their
   SSA_NAME_DEF_STMT (recursively), because those uses will be sunk into
   the final statement.   

References bitint_prec_large, bitint_precision_kind(), bitmap_bit_p, FOR_EACH_SSA_TREE_OPERAND, ggc_alloc(), gimple_assign_lhs(), gimple_assign_rhs_code(), is_gimple_assign(), names, NULL_TREE, SSA_NAME_DEF_STMT, SSA_NAME_VERSION, SSA_OP_DEF, SSA_OP_USE, TREE_CODE, TREE_TYPE, and worklist.

Referenced by build_ssa_conflict_graph().

◆ gimple_lower_bitint()

static unsigned int gimple_lower_bitint ( void )
static
Entry point for _BitInt(N) operation lowering during optimization.   

References add_phi_arg(), tree_switch_conversion::switch_decision_tree::analyze_switch_statement(), arith_overflow_arg_kind(), basic_block_def::aux, bitint_min_cst_precision(), bitint_prec_large, bitint_prec_middle, bitint_prec_small, bitint_precision_kind(), BITMAP_ALLOC, bitmap_and_compl_into(), bitmap_bit_p, BITMAP_FREE, bitmap_set_bit, build1(), build2(), build_array_type_nelts(), build_bitint_type(), build_fold_addr_expr, build_int_cst(), build_nonstandard_integer_type(), build_pointer_type(), build_zero_cst(), builtin_decl_implicit(), calculate_dominance_info(), CASE_HIGH, CASE_LOW, CDI_DOMINATORS, CDI_POST_DOMINATORS, CEIL, cfun, cleanup_tree_cfg(), clear_aux_for_blocks(), coalesce_ssa_name(), COMPARISON_CLASS_P, copy_ssa_name(), create_phi_node(), create_tmp_reg(), create_tmp_var, DECL_BIT_FIELD_TYPE, disable_ranger(), dom_info_available_p(), dump_file, dump_flags, dump_var_map(), EDGE_COUNT, EDGE_PRED, enable_ranger(), ENTRY_BLOCK_PTR_FOR_FN, profile_probability::even(), EXECUTE_IF_SET_IN_BITMAP, find_fallthru_edge(), fold_build2, fold_convert, FOR_EACH_BB_FN, FOR_EACH_BB_REVERSE_FN, FOR_EACH_IMM_USE_FAST, FOR_EACH_IMM_USE_ON_STMT, FOR_EACH_IMM_USE_STMT, FOR_EACH_SSA_TREE_OPERAND, FOR_EACH_SSA_USE_OPERAND, FOR_EACH_VEC_ELT, free_dominance_info(), g, gcc_assert, gcc_checking_assert, gcc_unreachable, get_or_create_ssa_default_def(), ggc_alloc(), gimple_assign_cast_p(), gimple_assign_lhs(), gimple_assign_load_p(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), gimple_assign_set_rhs1(), gimple_assign_set_rhs2(), gimple_assign_single_p(), gimple_bb(), gimple_build_assign(), gimple_build_call(), gimple_build_cond(), gimple_build_nop(), gimple_call_lhs(), gimple_clobber_p(), gimple_get_lhs(), gimple_has_volatile_ops(), gimple_location(), gimple_num_ops(), gimple_op(), gimple_phi_arg_def(), gimple_phi_arg_edge(), gimple_phi_num_args(), gimple_phi_result(), gimple_set_lhs(), gimple_set_location(), gimple_set_op(), gimple_store_p(), gimple_switch_index(), gimple_switch_num_labels(), group_case_labels_stmt(), gsi_after_labels(), gsi_bb(), gsi_commit_edge_inserts(), gsi_end_p(), gsi_for_stmt(), gsi_insert_after(), gsi_insert_before(), gsi_insert_on_edge(), gsi_insert_on_edge_immediate(), gsi_last_bb(), gsi_next(), gsi_prev(), gsi_remove(), gsi_replace(), gsi_safe_insert_before(), GSI_SAME_STMT, gsi_start_phis(), gsi_stmt(), has_single_use(), huge_min_prec, i, init_var_map(), integer_minus_one_node, integer_zerop(), INTEGRAL_TYPE_P, is_gimple_assign(), is_gimple_call(), is_gimple_debug(), large_min_prec, limb_prec, make_edge(), make_ssa_name(), mark_addressable(), mark_virtual_operands_for_renaming(), MAX, MAX_FIXED_MODE_SIZE, mid_min_prec, NULL, NULL_TREE, num_ssa_names, num_var_partitions(), partition_view_normal(), POINTER_TYPE_P, basic_block_def::preds, print_generic_expr(), release_ssa_name(), SCALAR_FLOAT_TYPE_P, set_immediate_dominator(), set_ssa_default_def(), SET_USE, single_imm_use(), single_succ_edge(), sizetype, small_max_prec, split_block(), ssa_name, SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_IS_VIRTUAL_OPERAND, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_NAME_VAR, SSA_NAME_VERSION, SSA_OP_ALL_OPERANDS, SSA_OP_USE, stmt_ends_bb_p(), suppress_warning(), TDF_DETAILS, TDF_SLIM, TODO_cleanup_cfg, TODO_update_ssa, TODO_update_ssa_only_virtuals, TREE_CODE, tree_int_cst_equal(), TREE_OPERAND, tree_output_constant_def(), tree_to_uhwi(), TREE_TYPE, TYPE_PRECISION, TYPE_SIZE, TYPE_SIZE_UNIT, TYPE_UNSIGNED, UNKNOWN_LOCATION, update_stmt(), USE_FROM_PTR, USE_STMT, VAR_P, and var_to_partition().

◆ make_pass_lower_bitint()

gimple_opt_pass * make_pass_lower_bitint ( gcc::context * ctxt)

References ggc_alloc().

◆ make_pass_lower_bitint_O0()

gimple_opt_pass * make_pass_lower_bitint_O0 ( gcc::context * ctxt)

References ggc_alloc().

Variable Documentation

◆ huge_min_prec

int huge_min_prec
static

◆ large_min_prec

int large_min_prec
static

◆ limb_prec

int limb_prec
static

◆ mid_min_prec

int mid_min_prec
static

◆ small_max_prec

int small_max_prec
static
Caches to speed up bitint_precision_kind.   

Referenced by bitint_precision_kind(), and gimple_lower_bitint().